diff --git a/labs/abiquo/README.md b/labs/abiquo/README.md deleted file mode 100644 index cdf6b8489d..0000000000 --- a/labs/abiquo/README.md +++ /dev/null @@ -1,10 +0,0 @@ -Jclouds Abiquo Provider -======================= - -This is the jclouds Abiquo provider. It enables compute features for the Abiquo cloud platform. - -Detailed information about the Abiquo REST API can be found in the -[Abiquo documentation page](http://community.abiquo.com). - -If you find any issue in the provider api, please submit it to the [Bug tracking system](http://jira.abiquo.com/browse/ABIQUOJC) and we will do our best to fix it. - diff --git a/labs/abiquo/pom.xml b/labs/abiquo/pom.xml deleted file mode 100644 index f0f0f8f4bf..0000000000 --- a/labs/abiquo/pom.xml +++ /dev/null @@ -1,226 +0,0 @@ - - - 4.0.0 - - org.jclouds.labs - jclouds-labs-project - 1.7.0-SNAPSHOT - ../project/pom.xml - - - abiquo - jclouds Abiquo api - jclouds components to access an implementation of Abiquo - bundle - - - 2.2.0.1 - 2.1.2.1 - http://localhost/api - FIXME - FIXME - - - org.jclouds.abiquo*;version="${project.version}" - - org.jclouds.labs*;version="${project.version}", - org.jclouds*;version="${jclouds.version}", - * - - - - - - org.jclouds - jclouds-core - ${jclouds.version} - - - org.jclouds - jclouds-compute - ${jclouds.version} - - - - com.abiquo - api-model-transport - ${abiquomodel.version} - - - javax.ws.rs - jsr311-api - - - org.uncommons - reportng - - - - - com.abiquo - am-model - ${abiquoam.version} - - - javax.ws.rs - jsr311-api - - - org.uncommons - reportng - - - - - - org.apache.wink - wink-common - 1.1-incubating - - - org.slf4j - slf4j-jdk14 - - - javax.ws.rs - jsr311-api - - - javax.xml.stream - stax-api - - - - - - org.jclouds - jclouds-core - ${jclouds.version} - test-jar - test - - - org.jclouds - jclouds-compute - ${jclouds.version} - test-jar - test - - - org.jclouds.driver - jclouds-sshj - ${jclouds.version} - test - - - org.jclouds.driver - jclouds-slf4j - ${jclouds.version} - test - - - ch.qos.logback - logback-core - test - - - ch.qos.logback - logback-classic - test - - - - - - - src/test/resources - true - - - - - org.apache.maven.plugins - maven-surefire-plugin - - - **/*IntegrationTest.java - **/*LiveTest.java - **/*LiveApiTest.java - **/*LiveUcsTest.java - - - - - - - - - live - - - - org.apache.maven.plugins - maven-surefire-plugin - - - integration - integration-test - - test - - - - ${test.abiquo.idenfity} - ${test.abiquo.credential} - ${test.abiquo.api-version} - ${test.abiquo.build-version} - - - - - - - - - - api - - - src/test/resources/filters/filters.properties - - - - org.apache.maven.plugins - maven-surefire-plugin - - - integration - integration-test - - test - - - - 1 - - none - - - **/*LiveApiTest.java - - - ${test.abiquo.identity} - ${test.abiquo.credential} - ${test.abiquo.api-version} - ${test.abiquo.build-version} - - - - - - - - - - diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/AbiquoApi.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/AbiquoApi.java deleted file mode 100644 index b7a4391f34..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/AbiquoApi.java +++ /dev/null @@ -1,96 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo; - -import org.jclouds.abiquo.features.AdminApi; -import org.jclouds.abiquo.features.CloudApi; -import org.jclouds.abiquo.features.ConfigApi; -import org.jclouds.abiquo.features.EnterpriseApi; -import org.jclouds.abiquo.features.EventApi; -import org.jclouds.abiquo.features.InfrastructureApi; -import org.jclouds.abiquo.features.PricingApi; -import org.jclouds.abiquo.features.TaskApi; -import org.jclouds.abiquo.features.VirtualMachineTemplateApi; -import org.jclouds.rest.annotations.Delegate; - -/** - * Provides synchronous access to Abiquo. - * - * @see API: - * http://community.abiquo.com/display/ABI20/API+Reference - * @see AbiquoAsyncApi - * @author Ignasi Barrera - */ -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 Cloud features. - */ - @Delegate - CloudApi getCloudApi(); - - /** - * Provides synchronous access to Apps library features. - */ - @Delegate - VirtualMachineTemplateApi getVirtualMachineTemplateApi(); - - /** - * Provides synchronous access to Enterprise features. - */ - @Delegate - EnterpriseApi getEnterpriseApi(); - - /** - * Provides synchronous access to configuration features. - */ - @Delegate - ConfigApi getConfigApi(); - - /** - * Provides synchronous access to task asynchronous features. - */ - @Delegate - TaskApi getTaskApi(); - - /** - * Provides synchronous access to Event features. - */ - @Delegate - EventApi getEventApi(); - - /** - * 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 deleted file mode 100644 index c99b4ccc0c..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/AbiquoApiMetadata.java +++ /dev/null @@ -1,110 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo; -import static org.jclouds.Constants.PROPERTY_MAX_REDIRECTS; -import static org.jclouds.abiquo.config.AbiquoProperties.ASYNC_TASK_MONITOR_DELAY; -import static org.jclouds.abiquo.config.AbiquoProperties.CREDENTIAL_IS_TOKEN; -import static org.jclouds.reflect.Reflection2.typeToken; - -import java.net.URI; -import java.util.Properties; - -import org.jclouds.abiquo.compute.config.AbiquoComputeServiceContextModule; -import org.jclouds.abiquo.config.AbiquoRestClientModule; -import org.jclouds.apis.ApiMetadata; -import org.jclouds.concurrent.config.ScheduledExecutorServiceModule; -import org.jclouds.rest.RestContext; -import org.jclouds.rest.internal.BaseRestApiMetadata; - -import com.google.common.base.CharMatcher; -import com.google.common.collect.ImmutableSet; -import com.google.common.reflect.TypeToken; -import com.google.inject.Module; - -/** - * Implementation of {@link ApiMetadata} for Abiquo API. - * - * @author Ignasi Barrera - */ -public class AbiquoApiMetadata extends BaseRestApiMetadata { - - /** The token describing the rest api context. */ - public static TypeToken> CONTEXT_TOKEN = new TypeToken>() { - private static final long serialVersionUID = -2098594161943130770L; - }; - - public AbiquoApiMetadata() { - this(new Builder()); - } - - @Override - public Builder toBuilder() { - return new Builder().fromApiMetadata(this); - } - - protected AbiquoApiMetadata(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 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(AbiquoContext.class)) - .defaultProperties(AbiquoApiMetadata.defaultProperties()) - .defaultModules( - ImmutableSet.> of(AbiquoRestClientModule.class, - AbiquoComputeServiceContextModule.class, ScheduledExecutorServiceModule.class)); - } - - @Override - public AbiquoApiMetadata build() { - return new AbiquoApiMetadata(this); - } - - @Override - protected Builder self() { - 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 deleted file mode 100644 index 166e3fdfd9..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/AbiquoAsyncApi.java +++ /dev/null @@ -1,107 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo; - -import org.jclouds.abiquo.features.AdminAsyncApi; -import org.jclouds.abiquo.features.CloudAsyncApi; -import org.jclouds.abiquo.features.ConfigAsyncApi; -import org.jclouds.abiquo.features.EnterpriseAsyncApi; -import org.jclouds.abiquo.features.EventAsyncApi; -import org.jclouds.abiquo.features.InfrastructureAsyncApi; -import org.jclouds.abiquo.features.PricingAsyncApi; -import org.jclouds.abiquo.features.TaskAsyncApi; -import org.jclouds.abiquo.features.VirtualMachineTemplateAsyncApi; -import org.jclouds.rest.annotations.Delegate; - -import com.abiquo.model.transport.SingleResourceTransportDto; - -/** - * Provides asynchronous access to Abiquo via their REST API. - * - * @see API: - * http://community.abiquo.com/display/ABI20/API+Reference - * @see InfrastructureAsyncApi - * @author Ignasi Barrera - */ -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"; - - /** - * Provides asynchronous access to Admin features. - */ - @Delegate - AdminAsyncApi getAdminApi(); - - /** - * Provides asynchronous access to Infrastructure features. - */ - @Delegate - InfrastructureAsyncApi getInfrastructureApi(); - - /** - * Provides asynchronous access to Cloud features. - */ - @Delegate - CloudAsyncApi getCloudApi(); - - /** - * Provides asynchronous access to Apps library features. - */ - @Delegate - VirtualMachineTemplateAsyncApi getVirtualMachineTemplateApi(); - - /** - * Provides asynchronous access to Enterprise features. - */ - @Delegate - EnterpriseAsyncApi getEnterpriseApi(); - - /** - * Provides asynchronous access to configuration features. - */ - @Delegate - ConfigAsyncApi getConfigApi(); - - /** - * Provides asynchronous access to task asynchronous features. - */ - @Delegate - TaskAsyncApi getTaskApi(); - - /** - * Provides asynchronous access to Event features. - */ - @Delegate - EventAsyncApi getEventApi(); - - /** - * 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 deleted file mode 100644 index 7989a90ef2..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/AbiquoContext.java +++ /dev/null @@ -1,93 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo; - -import org.jclouds.abiquo.features.services.AdministrationService; -import org.jclouds.abiquo.features.services.CloudService; -import org.jclouds.abiquo.features.services.EventService; -import org.jclouds.abiquo.features.services.MonitoringService; -import org.jclouds.abiquo.features.services.PricingService; -import org.jclouds.abiquo.features.services.SearchService; -import org.jclouds.abiquo.internal.AbiquoContextImpl; -import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.rest.RestContext; - -import com.google.inject.ImplementedBy; - -/** - * 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(); - - /** - * 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 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 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(); -} diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/AbiquoFallbacks.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/AbiquoFallbacks.java deleted file mode 100644 index 05a9b1cc90..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/AbiquoFallbacks.java +++ /dev/null @@ -1,180 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo; - -import static com.google.common.base.Throwables.getCausalChain; -import static com.google.common.base.Throwables.propagate; -import static com.google.common.collect.Iterables.find; -import static com.google.common.util.concurrent.Futures.immediateFuture; - -import javax.ws.rs.core.Response.Status; - -import org.jclouds.Fallback; -import org.jclouds.abiquo.domain.exception.AbiquoException; -import org.jclouds.http.HttpResponse; -import org.jclouds.http.HttpResponseException; -import org.jclouds.rest.ResourceNotFoundException; - -import com.google.common.base.Predicate; -import com.google.common.util.concurrent.ListenableFuture; - -/** - * fallbacks common to abiquo - * - * @author Ignasi Barrera - */ -public final class AbiquoFallbacks { - private AbiquoFallbacks() { - } - - /** - * Return an Abiquo Exception on not found errors. - */ - public static final class PropagateAbiquoExceptionOnNotFoundOr4xx implements Fallback { - @Override - public ListenableFuture create(Throwable from) throws Exception { - return immediateFuture(createOrPropagate(from)); - } - - @Override - public Object createOrPropagate(Throwable from) throws Exception { - Throwable exception = find(getCausalChain(from), isNotFoundAndHasAbiquoException(from), null); - throw propagate(exception == null ? from : exception.getCause()); - } - } - - /** - * Return null on 303 response codes when requesting a task. - */ - public static final class NullOn303 implements Fallback { - @Override - public ListenableFuture create(Throwable from) throws Exception { - return immediateFuture(createOrPropagate(from)); - } - - @Override - public Object createOrPropagate(Throwable from) throws Exception { - Throwable exception = find(getCausalChain(from), hasResponse(from), null); - - if (exception != null) { - HttpResponseException responseException = (HttpResponseException) exception; - HttpResponse response = responseException.getResponse(); - - if (response != null && response.getStatusCode() == Status.SEE_OTHER.getStatusCode()) { - return null; - } - } - - throw propagate(from); - } - - } - - /** - * Return false on service error exceptions. - */ - public static final class FalseOn5xx implements Fallback { - @Override - public ListenableFuture create(Throwable from) throws Exception { - return immediateFuture(createOrPropagate(from)); - } - - @Override - public Boolean createOrPropagate(Throwable from) throws Exception { - Throwable exception = find(getCausalChain(from), hasResponse(from), null); - - if (exception != null) { - HttpResponseException responseException = (HttpResponseException) exception; - HttpResponse response = responseException.getResponse(); - - if (response != null && response.getStatusCode() >= 500 && response.getStatusCode() < 600) { - return false; - } - } - - throw propagate(from); - } - - } - - /** - * Return false on service error exceptions. - */ - public static final class FalseIfNotAvailable implements Fallback { - @Override - public ListenableFuture create(Throwable from) throws Exception { - return immediateFuture(createOrPropagate(from)); - } - - @Override - public Boolean createOrPropagate(Throwable from) throws Exception { - Throwable exception = find(getCausalChain(from), isNotAvailableException(from), null); - - 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; - } - } else { - // Will enter here when exception is a ResourceNotFoundException - return false; - } - } - - throw propagate(from); - } - - } - - 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 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; - - return notAvailable; - } - }; - } - - 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; - } - }; - } -} \ No newline at end of file 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 deleted file mode 100644 index ff05887e99..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/binders/AppendToPath.java +++ /dev/null @@ -1,53 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.binders; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.net.URI; - -import javax.inject.Singleton; - -import org.jclouds.http.HttpRequest; -import org.jclouds.rest.Binder; - -/** - * Appends the parameter value to the end of the request URI. - * - * @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(); - } - - /** - * 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 deleted file mode 100644 index e7bd255a05..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/binders/BindLinkToPath.java +++ /dev/null @@ -1,46 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.binders; - -import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.base.Preconditions.checkNotNull; - -import javax.inject.Singleton; - -import org.jclouds.rest.internal.GeneratedHttpRequest; - -import com.abiquo.model.rest.RESTLink; - -/** - * Binds the given link to the uri. - * - * @author Francesc Montserrat - */ -@Singleton -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"); - - 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 deleted file mode 100644 index e8ae015693..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/binders/BindLinkToPathAndAcceptHeader.java +++ /dev/null @@ -1,50 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.binders; - -import static com.google.common.base.Preconditions.checkNotNull; - -import javax.inject.Singleton; -import javax.ws.rs.core.HttpHeaders; - -import org.jclouds.http.HttpRequest; - -import com.abiquo.model.rest.RESTLink; -import com.google.common.annotations.VisibleForTesting; - -/** - * Binds the given link to the uri and the Accept header. - * - * @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()); - } - - @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 deleted file mode 100644 index 3dc129fcfc..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/binders/BindRefsToPayload.java +++ /dev/null @@ -1,68 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.binders; - -import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.base.Preconditions.checkNotNull; - -import javax.inject.Inject; - -import org.jclouds.http.HttpRequest; -import org.jclouds.rest.binders.BindToXMLPayload; -import org.jclouds.xml.XMLParser; - -import com.abiquo.model.rest.RESTLink; -import com.abiquo.model.transport.LinksDto; -import com.abiquo.model.transport.SingleResourceTransportDto; - -/** - * Bind multiple objects to the payload of the request as a list of links. - * - * @author Ignasi Barrera - */ -public abstract class BindRefsToPayload extends BindToXMLPayload { - @Inject - public BindRefsToPayload(final XMLParser xmlParser) { - super(xmlParser); - } - - protected abstract String getRelToUse(final Object input); - - @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(); - - 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())); - } - } - - 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 deleted file mode 100644 index ca892d90dc..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/binders/BindToPath.java +++ /dev/null @@ -1,139 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.binders; - -import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.base.Preconditions.checkState; - -import java.lang.annotation.Annotation; -import java.net.URI; -import java.util.Arrays; - -import javax.inject.Singleton; - -import org.jclouds.abiquo.rest.annotations.EndpointLink; -import org.jclouds.http.HttpRequest; -import org.jclouds.rest.Binder; -import org.jclouds.rest.binders.BindException; -import org.jclouds.rest.internal.GeneratedHttpRequest; - -import com.abiquo.model.rest.RESTLink; -import com.abiquo.model.transport.SingleResourceTransportDto; -import com.google.common.base.Predicates; -import com.google.common.collect.Iterables; - -/** - * Binds the given object to the path.. - * - * @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, - "this binder is only valid for GeneratedHttpRequests"); - GeneratedHttpRequest gRequest = (GeneratedHttpRequest) request; - checkState(gRequest.getInvocation().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); - } - - /** - * 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.getInvocation().getArgs().indexOf(payload); - Annotation[] annotations = request.getInvocation().getInvokable().getParameters().get(argIndex).getAnnotations(); - - 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"); - } - - 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 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(); - } - - protected static SingleResourceTransportDto checkValidInput(final Object input) { - checkArgument(checkNotNull(input, "input") instanceof SingleResourceTransportDto, - "this binder is only valid for SingleResourceTransportDto objects"); - - return (SingleResourceTransportDto) input; - } - - protected static String getParameterString(final R request) { - String endpoint = request.getEndpoint().toString(); - - int query = endpoint.indexOf('?'); - - if (query == -1) { - // No parameters - return ""; - } else { - // Only request parameters - return endpoint.substring(query); - } - - } -} 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 deleted file mode 100644 index 620a700618..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/binders/BindToXMLPayloadAndPath.java +++ /dev/null @@ -1,80 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.binders; - -import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.base.Preconditions.checkState; - -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jclouds.http.HttpRequest; -import org.jclouds.rest.binders.BindToXMLPayload; -import org.jclouds.rest.internal.GeneratedHttpRequest; -import org.jclouds.xml.XMLParser; - -import com.abiquo.model.transport.SingleResourceTransportDto; - -/** - * Binds the 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. - * - * @author Ignasi Barrera - */ -@Singleton -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, - "this binder is only valid for GeneratedHttpRequests"); - GeneratedHttpRequest gRequest = (GeneratedHttpRequest) request; - checkState(gRequest.getInvocation().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); - - // 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(); - } -} 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 deleted file mode 100644 index 1762ccd64b..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/binders/cloud/BindHardDiskRefsToPayload.java +++ /dev/null @@ -1,46 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.binders.cloud; - -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jclouds.abiquo.binders.BindRefsToPayload; -import org.jclouds.xml.XMLParser; - -/** - * 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); - } - - @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 deleted file mode 100644 index e9a1ec4377..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/binders/cloud/BindIpRefToPayload.java +++ /dev/null @@ -1,61 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.binders.cloud; - -import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.base.Preconditions.checkNotNull; - -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jclouds.http.HttpRequest; -import org.jclouds.rest.binders.BindToXMLPayload; -import org.jclouds.xml.XMLParser; - -import com.abiquo.model.rest.RESTLink; -import com.abiquo.model.transport.LinksDto; -import com.abiquo.server.core.infrastructure.network.AbstractIpDto; - -/** - * Bind the link reference to an {@link AbstractIpDto} object into the payload. - * - * @author Ignasi Barrera - */ -@Singleton -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, - "this binder is only valid for AbstractIpDto objects"); - - 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())); - - 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 deleted file mode 100644 index 71596fe3c7..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/binders/cloud/BindIpRefsToPayload.java +++ /dev/null @@ -1,68 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.binders.cloud; - -import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.base.Preconditions.checkNotNull; - -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jclouds.abiquo.domain.util.LinkUtils; -import org.jclouds.http.HttpRequest; -import org.jclouds.rest.binders.BindToXMLPayload; -import org.jclouds.xml.XMLParser; - -import com.abiquo.model.rest.RESTLink; -import com.abiquo.model.transport.LinksDto; -import com.abiquo.server.core.infrastructure.network.AbstractIpDto; - -/** - * Bind the link reference to an {@link AbstractIpDto} object into the payload. - * - * @author Ignasi Barrera - */ -@Singleton -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[], - "this binder is only valid for AbstractIpDto arrays"); - - 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); - } - } - - 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 deleted file mode 100644 index f11d190227..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/binders/cloud/BindMoveVolumeToPath.java +++ /dev/null @@ -1,49 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.binders.cloud; - -import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.base.Preconditions.checkNotNull; - -import org.jclouds.abiquo.binders.BindToPath; -import org.jclouds.rest.internal.GeneratedHttpRequest; - -import com.abiquo.model.rest.RESTLink; -import com.abiquo.server.core.infrastructure.storage.VolumeManagementDto; - -/** - * Binds the move volume action to the request endpoint. - * - * @author Ignasi Barrera - */ -public class BindMoveVolumeToPath extends BindToPath { - - @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"); - - 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 deleted file mode 100644 index f166d31a4a..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/binders/cloud/BindNetworkConfigurationRefToPayload.java +++ /dev/null @@ -1,73 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.binders.cloud; - -import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.base.Preconditions.checkState; - -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jclouds.http.HttpRequest; -import org.jclouds.rest.binders.BindToXMLPayload; -import org.jclouds.rest.internal.GeneratedHttpRequest; -import org.jclouds.xml.XMLParser; - -import com.abiquo.model.rest.RESTLink; -import com.abiquo.model.transport.LinksDto; -import com.abiquo.server.core.cloud.VirtualMachineDto; -import com.abiquo.server.core.infrastructure.network.VLANNetworkDto; -import com.google.common.base.Predicates; -import com.google.common.collect.Iterables; - -/** - * Bind multiple objects to the payload of the request as a list of links. - * - * @author Ignasi Barrera - */ -@Singleton -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, - "this binder is only valid for GeneratedHttpRequests"); - checkArgument(checkNotNull(input, "input") instanceof VLANNetworkDto, - "this binder is only valid for VLANNetworkDto"); - GeneratedHttpRequest gRequest = (GeneratedHttpRequest) request; - checkState(gRequest.getInvocation().getArgs() != null, "args should be initialized at this point"); - - VLANNetworkDto network = (VLANNetworkDto) input; - VirtualMachineDto vm = (VirtualMachineDto) Iterables.find(gRequest.getInvocation().getArgs(), - Predicates.instanceOf(VirtualMachineDto.class)); - - RESTLink configLink = checkNotNull(vm.searchLink("configurations"), "missing required link"); - - LinksDto dto = new LinksDto(); - dto.addLink(new RESTLink("network_configuration", configLink.getHref() + "/" + network.getId())); - - 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 deleted file mode 100644 index 5d9ede9580..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/binders/cloud/BindNetworkRefToPayload.java +++ /dev/null @@ -1,78 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.binders.cloud; - -import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.base.Preconditions.checkNotNull; - -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jclouds.http.HttpRequest; -import org.jclouds.rest.binders.BindToXMLPayload; -import org.jclouds.xml.XMLParser; - -import com.abiquo.model.rest.RESTLink; -import com.abiquo.model.transport.LinksDto; -import com.abiquo.server.core.infrastructure.network.VLANNetworkDto; - -/** - * Bind the link reference to an {@link VLANNetworkDto} object into the payload. - * - * @author Ignasi Barrera - */ -@Singleton -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, - "this binder is only valid for VLANNetworkDto objects"); - - 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"); - } - - 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 deleted file mode 100644 index a2b057dce4..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/binders/cloud/BindUnmanagedIpRefToPayload.java +++ /dev/null @@ -1,64 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.binders.cloud; - -import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.base.Preconditions.checkNotNull; - -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jclouds.http.HttpRequest; -import org.jclouds.rest.binders.BindToXMLPayload; -import org.jclouds.xml.XMLParser; - -import com.abiquo.model.enumerator.NetworkType; -import com.abiquo.model.rest.RESTLink; -import com.abiquo.model.transport.LinksDto; -import com.abiquo.server.core.infrastructure.network.VLANNetworkDto; - -/** - * Bind the link reference to an {@link AbstractIpDto} object into the payload. - * - * @author Ignasi Barrera - */ -@Singleton -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, - "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"); - - RESTLink ipsLink = checkNotNull(network.searchLink("ips"), "VLANNetworkDto must have an ips link"); - - LinksDto refs = new LinksDto(); - refs.addLink(new RESTLink("unmanagedip", ipsLink.getHref())); - - 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 deleted file mode 100644 index daca344376..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/binders/cloud/BindVirtualDatacenterRefToPayload.java +++ /dev/null @@ -1,62 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.binders.cloud; - -import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.base.Preconditions.checkNotNull; - -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jclouds.http.HttpRequest; -import org.jclouds.rest.binders.BindToXMLPayload; -import org.jclouds.xml.XMLParser; - -import com.abiquo.model.rest.RESTLink; -import com.abiquo.model.transport.LinksDto; -import com.abiquo.server.core.cloud.VirtualDatacenterDto; - -/** - * 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); - } - - @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())); - - 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 deleted file mode 100644 index fcecff5565..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/binders/cloud/BindVolumeRefsToPayload.java +++ /dev/null @@ -1,46 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.binders.cloud; - -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jclouds.abiquo.binders.BindRefsToPayload; -import org.jclouds.xml.XMLParser; - -/** - * 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); - } - - @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 deleted file mode 100644 index 1ca5f91568..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/binders/infrastructure/AppendMachineIdToPath.java +++ /dev/null @@ -1,49 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.binders.infrastructure; - -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jclouds.abiquo.binders.AppendToPath; -import org.jclouds.abiquo.functions.infrastructure.ParseMachineId; -import org.jclouds.http.HttpRequest; - -/** - * Append the {@link Machine} id to the request URI. - * - * @author Ignasi Barrera - */ -@Singleton -public class AppendMachineIdToPath extends AppendToPath { - private ParseMachineId 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); - } - -} 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 deleted file mode 100644 index 77cd04de57..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/binders/infrastructure/AppendRemoteServiceTypeToPath.java +++ /dev/null @@ -1,52 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.binders.infrastructure; - -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jclouds.abiquo.binders.AppendToPath; -import org.jclouds.abiquo.functions.infrastructure.ParseRemoteServiceType; -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. - * - * @author Ignasi Barrera - */ -@Singleton -public class AppendRemoteServiceTypeToPath extends AppendToPath { - private ParseRemoteServiceType 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); - } - -} 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 deleted file mode 100644 index e35dff8c23..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/binders/infrastructure/BindSupportedDevicesLinkToPath.java +++ /dev/null @@ -1,40 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.binders.infrastructure; - -import javax.inject.Singleton; - -import org.jclouds.abiquo.binders.BindToPath; -import org.jclouds.rest.internal.GeneratedHttpRequest; - -/** - * Binds the given link to the uri appends the supported devices action path. - * - * @author Ignasi Barrera - */ -@Singleton -public class BindSupportedDevicesLinkToPath extends BindToPath { - - @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 deleted file mode 100644 index dc819c4c53..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/binders/infrastructure/ucs/BindLogicServerParameters.java +++ /dev/null @@ -1,51 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.binders.infrastructure.ucs; - -import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.base.Preconditions.checkNotNull; - -import javax.inject.Singleton; - -import org.jclouds.http.HttpRequest; -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}. - * - * @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, - "this binder is only valid for LogicServerDto objects"); - - LogicServerDto server = (LogicServerDto) input; - - return (R) request.toBuilder().addQueryParam("lsName", checkNotNull(server.getName(), "server.name")).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 deleted file mode 100644 index d63214e1ac..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/binders/infrastructure/ucs/BindOrganizationParameters.java +++ /dev/null @@ -1,52 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.binders.infrastructure.ucs; - -import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.base.Preconditions.checkNotNull; - -import javax.inject.Singleton; - -import org.jclouds.http.HttpRequest; -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}. - * - * @author Francesc Montserrat - * @author Ignasi Barrera - */ -@Singleton -public class BindOrganizationParameters implements Binder { - - @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; - - return (R) request.toBuilder().addQueryParam("org", checkNotNull(org.getDn(), "org.dn")).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 deleted file mode 100644 index fe72c8d88e..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/compute/config/AbiquoComputeServiceContextModule.java +++ /dev/null @@ -1,79 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.compute.config; - -import org.jclouds.abiquo.compute.functions.DatacenterToLocation; -import org.jclouds.abiquo.compute.functions.VirtualDatacenterToLocation; -import org.jclouds.abiquo.compute.functions.VirtualMachineTemplateToImage; -import org.jclouds.abiquo.compute.functions.VirtualMachineTemplateInVirtualDatacenterToHardware; -import org.jclouds.abiquo.compute.functions.VirtualMachineToNodeMetadata; -import org.jclouds.abiquo.compute.options.AbiquoTemplateOptions; -import org.jclouds.abiquo.compute.strategy.AbiquoComputeServiceAdapter; -import org.jclouds.abiquo.domain.cloud.VirtualDatacenter; -import org.jclouds.abiquo.domain.cloud.VirtualMachine; -import org.jclouds.abiquo.domain.cloud.VirtualMachineTemplate; -import org.jclouds.abiquo.domain.cloud.VirtualMachineTemplateInVirtualDatacenter; -import org.jclouds.abiquo.domain.infrastructure.Datacenter; -import org.jclouds.compute.ComputeServiceAdapter; -import org.jclouds.compute.config.ComputeServiceAdapterContextModule; -import org.jclouds.compute.domain.Hardware; -import org.jclouds.compute.domain.Image; -import org.jclouds.compute.domain.NodeMetadata; -import org.jclouds.compute.options.TemplateOptions; -import org.jclouds.domain.Location; -import org.jclouds.location.suppliers.ImplicitLocationSupplier; -import org.jclouds.location.suppliers.implicit.OnlyLocationOrFirstZone; - -import com.google.common.base.Function; -import com.google.inject.Scopes; -import com.google.inject.TypeLiteral; - -/** - * Abiquo Compute service configuration module. - * - * @author Ignasi Barrera - */ -public class AbiquoComputeServiceContextModule - extends - ComputeServiceAdapterContextModule { - - @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() { - }); - } - -} 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 deleted file mode 100644 index 73e0ec53ff..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/compute/functions/DatacenterToLocation.java +++ /dev/null @@ -1,56 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.compute.functions; - -import javax.inject.Singleton; - -import org.jclouds.abiquo.domain.infrastructure.Datacenter; -import org.jclouds.domain.Location; -import org.jclouds.domain.LocationBuilder; -import org.jclouds.domain.LocationScope; - -import com.google.common.base.Function; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; - -/** - * Converts a {@link Datacenter} to a {@link Location} one. - *

- * Physical datacenters will be considered regions. - * - * @author Ignasi Barrera - */ -@Singleton -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()); - - builder.parent(new LocationBuilder().scope(LocationScope.PROVIDER).id("abiquo").description("abiquo").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 deleted file mode 100644 index aca53ea8dd..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/compute/functions/VirtualDatacenterToLocation.java +++ /dev/null @@ -1,78 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.compute.functions; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.Map; - -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jclouds.abiquo.domain.cloud.VirtualDatacenter; -import org.jclouds.abiquo.domain.infrastructure.Datacenter; -import org.jclouds.abiquo.reference.rest.ParentLinkName; -import org.jclouds.collect.Memoized; -import org.jclouds.domain.Location; -import org.jclouds.domain.LocationBuilder; -import org.jclouds.domain.LocationScope; - -import com.google.common.base.Function; -import com.google.common.base.Supplier; -import com.google.common.collect.ImmutableMap; -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). - * - * @author Ignasi Barrera - */ -@Singleton -public class VirtualDatacenterToLocation implements Function { - private final Function datacenterToLocation; - - private final Supplier> 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()); - - Datacenter parent = regionMap.get().get(vdc.unwrap().getIdFromLink(ParentLinkName.DATACENTER)); - builder.parent(datacenterToLocation.apply(parent)); - - 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 deleted file mode 100644 index 2ab7e4c272..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/compute/functions/VirtualMachineStateToNodeState.java +++ /dev/null @@ -1,55 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.compute.functions; - -import javax.inject.Singleton; - -import org.jclouds.compute.domain.NodeMetadata.Status; - -import com.abiquo.server.core.cloud.VirtualMachineState; -import com.google.common.base.Function; - -/** - * Converts a {@link VirtualMachineState} object to a {@link Status} one. - * - * @author Ignasi Barrera - */ -@Singleton -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; - } - } -} 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 deleted file mode 100644 index c5338d2bd3..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/compute/functions/VirtualMachineTemplateInVirtualDatacenterToHardware.java +++ /dev/null @@ -1,95 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.compute.functions; - -import static com.google.common.base.Preconditions.checkNotNull; - -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jclouds.abiquo.domain.cloud.VirtualDatacenter; -import org.jclouds.abiquo.domain.cloud.VirtualMachineTemplate; -import org.jclouds.abiquo.domain.cloud.VirtualMachineTemplateInVirtualDatacenter; -import org.jclouds.compute.domain.Hardware; -import org.jclouds.compute.domain.HardwareBuilder; -import org.jclouds.compute.domain.Processor; -import org.jclouds.compute.domain.Volume; -import org.jclouds.compute.domain.VolumeBuilder; -import org.jclouds.compute.predicates.ImagePredicates; -import org.jclouds.domain.Location; - -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. - * - * @author Ignasi Barrera - */ -@Singleton -public class VirtualMachineTemplateInVirtualDatacenterToHardware implements - Function { - /** The default core speed, 2.0Ghz. */ - public static final double DEFAULT_CORE_SPEED = 2.0; - - private final Function 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(); - - 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()); - - // 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()); - - return builder.build(); - } - - private static float toGb(final long bytes) { - return bytes / (float) (1024 * 1024 * 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 deleted file mode 100644 index 9cf7a0ff22..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/compute/functions/VirtualMachineTemplateToImage.java +++ /dev/null @@ -1,91 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.compute.functions; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.net.URI; -import java.util.Map; - -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jclouds.abiquo.domain.cloud.VirtualMachineTemplate; -import org.jclouds.abiquo.domain.infrastructure.Datacenter; -import org.jclouds.abiquo.reference.rest.ParentLinkName; -import org.jclouds.collect.Memoized; -import org.jclouds.compute.domain.Image; -import org.jclouds.compute.domain.Image.Status; -import org.jclouds.compute.domain.ImageBuilder; -import org.jclouds.compute.domain.OperatingSystem; -import org.jclouds.domain.Location; - -import com.abiquo.model.rest.RESTLink; -import com.google.common.base.Function; -import com.google.common.base.Supplier; - -/** - * Transforms a {@link VirtualMachineTemplate} into an {@link Image}. - *

- * Images are scoped to a region (physical datacenter). - * - * @author Ignasi Barrera - */ -@Singleton -public class VirtualMachineTemplateToImage implements Function { - private final Function datacenterToLocation; - - private final Supplier> regionMap; - - @Inject - public VirtualMachineTemplateToImage(final Function datacenterToLocation, - @Memoized final Supplier> regionMap) { - this.datacenterToLocation = checkNotNull(datacenterToLocation, "datacenterToLocation"); - this.regionMap = checkNotNull(regionMap, "regionMap"); - } - - @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)); - - // 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())); - - // 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(); - } -} 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 deleted file mode 100644 index 04fd623415..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/compute/functions/VirtualMachineToNodeMetadata.java +++ /dev/null @@ -1,141 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.compute.functions; - -import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.collect.Iterables.filter; -import static com.google.common.collect.Iterables.transform; - -import java.util.List; - -import javax.annotation.Resource; -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jclouds.abiquo.domain.cloud.VirtualDatacenter; -import org.jclouds.abiquo.domain.cloud.VirtualMachine; -import org.jclouds.abiquo.domain.cloud.VirtualMachineTemplate; -import org.jclouds.abiquo.domain.cloud.VirtualMachineTemplateInVirtualDatacenter; -import org.jclouds.abiquo.domain.network.Ip; -import org.jclouds.abiquo.domain.network.PrivateIp; -import org.jclouds.compute.domain.Hardware; -import org.jclouds.compute.domain.HardwareBuilder; -import org.jclouds.compute.domain.Image; -import org.jclouds.compute.domain.NodeMetadata; -import org.jclouds.compute.domain.NodeMetadataBuilder; -import org.jclouds.compute.domain.Processor; -import org.jclouds.domain.Location; -import org.jclouds.logging.Logger; - -import com.abiquo.server.core.cloud.VirtualMachineState; -import com.google.common.base.Function; -import com.google.common.base.Predicates; -import com.google.common.collect.Lists; - -/** - * Links a {@link VirtualMachine} object to a {@link NodeMetadata} one. - * - * @author Ignasi Barrera - */ -@Singleton -public class VirtualMachineToNodeMetadata implements Function { - @Resource - protected Logger logger = Logger.NULL; - - private final VirtualMachineTemplateToImage virtualMachineTemplateToImage; - - private final VirtualMachineTemplateInVirtualDatacenterToHardware virtualMachineTemplateToHardware; - - private final VirtualMachineStateToNodeState virtualMachineStateToNodeState; - - 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"); - } - - @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 - - // 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()); - - // 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(), - VirtualMachineTemplateInVirtualDatacenterToHardware.DEFAULT_CORE_SPEED))) // - .build(); - - 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))))); - - // Node state - VirtualMachineState state = vm.getState(); - builder.status(virtualMachineStateToNodeState.apply(state)); - builder.backendStatus(state.name()); - - 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(); - } - }); - } - -} 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 deleted file mode 100644 index 2bc7b30411..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/compute/options/AbiquoTemplateOptions.java +++ /dev/null @@ -1,128 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.compute.options; - -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. - * - * @author Ignasi Barrera - */ -public class AbiquoTemplateOptions extends TemplateOptions implements Cloneable { - public static final AbiquoTemplateOptions NONE = new AbiquoTemplateOptions(); - - private Integer overrideCores; - - private Integer overrideRam; - - private String vncPassword; - - @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 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; - } - - /** - * 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; - } - - /** - * 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 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#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 deleted file mode 100644 index f7689cc751..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/compute/strategy/AbiquoComputeServiceAdapter.java +++ /dev/null @@ -1,259 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.compute.strategy; - -import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.collect.Iterables.concat; -import static com.google.common.collect.Iterables.transform; - -import java.util.List; -import java.util.Map; - -import javax.annotation.Resource; -import javax.inject.Named; -import javax.inject.Singleton; - -import org.jclouds.abiquo.AbiquoApi; -import org.jclouds.abiquo.AbiquoAsyncApi; -import org.jclouds.abiquo.compute.options.AbiquoTemplateOptions; -import org.jclouds.abiquo.domain.cloud.VirtualAppliance; -import org.jclouds.abiquo.domain.cloud.VirtualDatacenter; -import org.jclouds.abiquo.domain.cloud.VirtualMachine; -import org.jclouds.abiquo.domain.cloud.VirtualMachineTemplate; -import org.jclouds.abiquo.domain.cloud.VirtualMachineTemplateInVirtualDatacenter; -import org.jclouds.abiquo.domain.enterprise.Enterprise; -import org.jclouds.abiquo.domain.infrastructure.Datacenter; -import org.jclouds.abiquo.domain.network.PublicIp; -import org.jclouds.abiquo.features.services.AdministrationService; -import org.jclouds.abiquo.features.services.CloudService; -import org.jclouds.abiquo.features.services.MonitoringService; -import org.jclouds.abiquo.monitor.VirtualMachineMonitor; -import org.jclouds.abiquo.predicates.cloud.VirtualAppliancePredicates; -import org.jclouds.abiquo.predicates.cloud.VirtualMachineTemplatePredicates; -import org.jclouds.abiquo.predicates.network.IpPredicates; -import org.jclouds.collect.Memoized; -import org.jclouds.compute.ComputeServiceAdapter; -import org.jclouds.compute.domain.Hardware; -import org.jclouds.compute.domain.Processor; -import org.jclouds.compute.domain.Template; -import org.jclouds.compute.reference.ComputeServiceConstants; -import org.jclouds.logging.Logger; -import org.jclouds.rest.RestContext; - -import com.abiquo.server.core.cloud.VirtualMachineState; -import com.google.common.base.Function; -import com.google.common.base.Predicate; -import com.google.common.base.Supplier; -import com.google.common.collect.Lists; -import com.google.inject.Inject; - -/** - * 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; - - private final RestContext context; - - private final AdministrationService adminService; - - private final CloudService cloudService; - - private final MonitoringService monitoringService; - - private final FindCompatibleVirtualDatacenters compatibleVirtualDatacenters; - - 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"); - } - - @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())); - - // 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())); - - // 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(); - - 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(); - - // 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(); - - 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) - - 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); - } - }); - } - })); - } - - @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 Iterable listLocations() { - return cloudService.listVirtualDatacenters(); - } - - @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 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 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(); - } - - 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(); - } - -} 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 deleted file mode 100644 index a80bb5391e..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/compute/strategy/FindCompatibleVirtualDatacenters.java +++ /dev/null @@ -1,37 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.compute.strategy; - -import org.jclouds.abiquo.compute.strategy.internal.FindCompatibleVirtualDatacentersForImageAndConversions; -import org.jclouds.abiquo.domain.cloud.VirtualDatacenter; -import org.jclouds.abiquo.domain.cloud.VirtualMachineTemplate; - -import com.google.inject.ImplementedBy; - -/** - * 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); -} 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 deleted file mode 100644 index d5eecd7b6e..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/compute/strategy/internal/FindCompatibleVirtualDatacentersForImageAndConversions.java +++ /dev/null @@ -1,79 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.abiquo.compute.strategy.internal; - -import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.collect.Iterables.filter; -import static org.jclouds.abiquo.domain.DomainWrapper.wrap; -import static org.jclouds.abiquo.predicates.cloud.VirtualDatacenterPredicates.compatibleWithTemplateOrConversions; - -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jclouds.abiquo.AbiquoApi; -import org.jclouds.abiquo.AbiquoAsyncApi; -import org.jclouds.abiquo.compute.strategy.FindCompatibleVirtualDatacenters; -import org.jclouds.abiquo.domain.cloud.VirtualDatacenter; -import org.jclouds.abiquo.domain.cloud.VirtualMachineTemplate; -import org.jclouds.abiquo.domain.infrastructure.Datacenter; -import org.jclouds.abiquo.features.services.CloudService; -import org.jclouds.abiquo.predicates.cloud.VirtualDatacenterPredicates; -import org.jclouds.abiquo.reference.rest.ParentLinkName; -import org.jclouds.rest.RestContext; - -import com.abiquo.server.core.infrastructure.DatacenterDto; - -/** - * 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. - * - * @author Ignasi Barrera - */ -@Singleton -public class FindCompatibleVirtualDatacentersForImageAndConversions implements FindCompatibleVirtualDatacenters { - private final RestContext context; - - private final 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); - - Iterable vdcs = cloudService.listVirtualDatacenters(VirtualDatacenterPredicates - .datacenter(datacenter)); - - 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 deleted file mode 100644 index 862bb0bbd2..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/compute/strategy/internal/FindCompatibleVirtualDatacentersForImageBaseFormat.java +++ /dev/null @@ -1,89 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.abiquo.compute.strategy.internal; - -import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.collect.Iterables.filter; -import static org.jclouds.abiquo.domain.DomainWrapper.wrap; - -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jclouds.abiquo.AbiquoApi; -import org.jclouds.abiquo.AbiquoAsyncApi; -import org.jclouds.abiquo.compute.strategy.FindCompatibleVirtualDatacenters; -import org.jclouds.abiquo.domain.cloud.VirtualDatacenter; -import org.jclouds.abiquo.domain.cloud.VirtualMachineTemplate; -import org.jclouds.abiquo.domain.infrastructure.Datacenter; -import org.jclouds.abiquo.features.services.CloudService; -import org.jclouds.abiquo.predicates.cloud.VirtualDatacenterPredicates; -import org.jclouds.abiquo.reference.rest.ParentLinkName; -import org.jclouds.rest.RestContext; - -import com.abiquo.model.enumerator.HypervisorType; -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. - *

- * 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; - - private final 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); - - 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()); - } - }); - } - -} 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 deleted file mode 100644 index 158b0f5f60..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/config/AbiquoEdition.java +++ /dev/null @@ -1,29 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.config; - -/** - * The Abiquo Edition (Community or Enterprise). - * - * @author Francesc Montserrat - */ -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 deleted file mode 100644 index 1edb0ca0fa..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/config/AbiquoProperties.java +++ /dev/null @@ -1,42 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.config; - -/** - * Configuration properties and constants used in Abiquo connections. - * - * @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"; - - /** - * 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 deleted file mode 100644 index 3bbe2d5e39..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/config/AbiquoRestClientModule.java +++ /dev/null @@ -1,173 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.config; - -import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL; -import static org.jclouds.abiquo.domain.DomainWrapper.wrap; -import static org.jclouds.rest.config.BinderUtils.bindHttpApi; - -import java.util.List; -import java.util.Map; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicReference; - -import javax.inject.Named; - -import org.jclouds.abiquo.AbiquoApi; -import org.jclouds.abiquo.AbiquoAsyncApi; -import org.jclouds.abiquo.domain.enterprise.Enterprise; -import org.jclouds.abiquo.domain.enterprise.User; -import org.jclouds.abiquo.domain.infrastructure.Datacenter; -import org.jclouds.abiquo.features.AdminApi; -import org.jclouds.abiquo.features.AdminAsyncApi; -import org.jclouds.abiquo.features.CloudApi; -import org.jclouds.abiquo.features.CloudAsyncApi; -import org.jclouds.abiquo.features.ConfigApi; -import org.jclouds.abiquo.features.ConfigAsyncApi; -import org.jclouds.abiquo.features.EnterpriseApi; -import org.jclouds.abiquo.features.EnterpriseAsyncApi; -import org.jclouds.abiquo.features.EventApi; -import org.jclouds.abiquo.features.EventAsyncApi; -import org.jclouds.abiquo.features.InfrastructureApi; -import org.jclouds.abiquo.features.InfrastructureAsyncApi; -import org.jclouds.abiquo.features.PricingApi; -import org.jclouds.abiquo.features.PricingAsyncApi; -import org.jclouds.abiquo.features.TaskApi; -import org.jclouds.abiquo.features.TaskAsyncApi; -import org.jclouds.abiquo.features.VirtualMachineTemplateApi; -import org.jclouds.abiquo.features.VirtualMachineTemplateAsyncApi; -import org.jclouds.abiquo.handlers.AbiquoErrorHandler; -import org.jclouds.abiquo.rest.internal.AbiquoHttpAsyncClient; -import org.jclouds.abiquo.rest.internal.AbiquoHttpClient; -import org.jclouds.abiquo.rest.internal.ExtendedUtils; -import org.jclouds.collect.Memoized; -import org.jclouds.http.HttpErrorHandler; -import org.jclouds.http.annotation.ClientError; -import org.jclouds.http.annotation.Redirection; -import org.jclouds.http.annotation.ServerError; -import org.jclouds.rest.AuthorizationException; -import org.jclouds.rest.ConfiguresRestClient; -import org.jclouds.rest.RestContext; -import org.jclouds.rest.Utils; -import org.jclouds.rest.config.RestClientModule; -import org.jclouds.rest.suppliers.MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier; - -import com.google.common.base.Function; -import com.google.common.base.Supplier; -import com.google.common.base.Suppliers; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.Maps; -import com.google.inject.Provides; -import com.google.inject.Singleton; - -/** - * Configures the Abiquo connection. - * - * @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 AbiquoRestClientModule() { - super(DELEGATE_MAP); - } - - @Override - protected void configure() { - super.configure(); - bindHttpApi(binder(), AbiquoHttpClient.class, AbiquoHttpAsyncClient.class); - 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); - } - - @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, @Memoized final 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 = Suppliers.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, - 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 deleted file mode 100644 index 82cddcd393..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/DomainWithLimitsWrapper.java +++ /dev/null @@ -1,161 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.domain; - -import org.jclouds.abiquo.AbiquoApi; -import org.jclouds.abiquo.AbiquoAsyncApi; -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. - * - * @author Ignasi Barrera - */ -public abstract class DomainWithLimitsWrapper extends DomainWrapper { - - protected DomainWithLimitsWrapper(final RestContext context, final T target) { - super(context, target); - } - - // Delegate methods - - public int getCpuCountHardLimit() { - return target.getCpuCountHardLimit(); - } - - public int getCpuCountSoftLimit() { - return target.getCpuCountSoftLimit(); - } - - public long getHdHardLimitInMb() { - return target.getHdHardLimitInMb(); - } - - public long getHdSoftLimitInMb() { - return target.getHdSoftLimitInMb(); - } - - public long getPublicIpsHard() { - return target.getPublicIpsHard(); - } - - public long getPublicIpsSoft() { - return target.getPublicIpsSoft(); - } - - public int getRamHardLimitInMb() { - return target.getRamHardLimitInMb(); - } - - public int getRamSoftLimitInMb() { - return target.getRamSoftLimitInMb(); - } - - public long getStorageHard() { - return target.getStorageHard(); - } - - public long getStorageSoft() { - return target.getStorageSoft(); - } - - public long getVlansHard() { - return target.getVlansHard(); - } - - public long getVlansSoft() { - return target.getVlansSoft(); - } - - public void setCpuCountHardLimit(final int cpuCountHardLimit) { - target.setCpuCountHardLimit(cpuCountHardLimit); - } - - public void setCpuCountLimits(final int softLimit, final int hardLimit) { - target.setCpuCountLimits(softLimit, hardLimit); - } - - public void setCpuCountSoftLimit(final int cpuCountSoftLimit) { - target.setCpuCountSoftLimit(cpuCountSoftLimit); - } - - public void setHdHardLimitInMb(final long hdHardLimitInMb) { - target.setHdHardLimitInMb(hdHardLimitInMb); - } - - public void setHdLimitsInMb(final long softLimit, final long hardLimit) { - target.setHdLimitsInMb(softLimit, hardLimit); - } - - public void setHdSoftLimitInMb(final long hdSoftLimitInMb) { - target.setHdSoftLimitInMb(hdSoftLimitInMb); - } - - public void setPublicIPLimits(final long softLimit, final long hardLimit) { - target.setPublicIPLimits(softLimit, hardLimit); - } - - public void setPublicIpsHard(final long publicIpsHard) { - target.setPublicIpsHard(publicIpsHard); - } - - public void setPublicIpsSoft(final long publicIpsSoft) { - target.setPublicIpsSoft(publicIpsSoft); - } - - public void setRamHardLimitInMb(final int ramHardLimitInMb) { - target.setRamHardLimitInMb(ramHardLimitInMb); - } - - public void setRamLimitsInMb(final int softLimit, final int hardLimit) { - target.setRamLimitsInMb(softLimit, hardLimit); - } - - public void setRamSoftLimitInMb(final int ramSoftLimitInMb) { - target.setRamSoftLimitInMb(ramSoftLimitInMb); - } - - public void setStorageHard(final long storageHard) { - target.setStorageHard(storageHard); - } - - public void setStorageLimits(final long softLimit, final long hardLimit) { - target.setStorageLimits(softLimit, hardLimit); - } - - public void setStorageSoft(final long storageSoft) { - target.setStorageSoft(storageSoft); - } - - public void setVlansHard(final long vlansHard) { - target.setVlansHard(vlansHard); - } - - public void setVlansLimits(final long softLimit, final long hardLimit) { - target.setVlansLimits(softLimit, hardLimit); - } - - 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 deleted file mode 100644 index ac9dd0e894..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/DomainWithTasksWrapper.java +++ /dev/null @@ -1,75 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.domain; - -import static com.google.common.collect.Iterables.filter; - -import java.util.Collections; -import java.util.List; - -import org.jclouds.abiquo.AbiquoApi; -import org.jclouds.abiquo.AbiquoAsyncApi; -import org.jclouds.abiquo.domain.task.AsyncTask; -import org.jclouds.rest.RestContext; - -import com.abiquo.model.transport.SingleResourceTransportDto; -import com.abiquo.server.core.task.TaskDto; -import com.abiquo.server.core.task.TasksDto; -import com.google.common.base.Predicate; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.Iterables; -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} - * - * @author Ignasi Barrera - */ -public abstract class DomainWithTasksWrapper extends DomainWrapper { - - 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()); - - // 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; - } - - public List listTasks(final Predicate filter) { - return ImmutableList.copyOf(filter(listTasks(), filter)); - } - - 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 deleted file mode 100644 index 2b19d9155a..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/DomainWrapper.java +++ /dev/null @@ -1,240 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.domain; - -import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.collect.Iterables.concat; -import static com.google.common.collect.Iterables.transform; -import static org.jclouds.reflect.Reflection2.constructor; - -import java.lang.reflect.InvocationTargetException; -import java.net.URI; -import java.util.Collection; -import java.util.List; - -import org.jclouds.abiquo.AbiquoApi; -import org.jclouds.abiquo.AbiquoAsyncApi; -import org.jclouds.abiquo.domain.exception.WrapperException; -import org.jclouds.abiquo.domain.task.AsyncTask; -import org.jclouds.abiquo.domain.util.LinkUtils; -import org.jclouds.abiquo.reference.ValidationErrors; -import org.jclouds.abiquo.rest.internal.ExtendedUtils; -import org.jclouds.http.HttpResponse; -import org.jclouds.http.functions.ParseXMLWithJAXB; -import org.jclouds.rest.RestContext; - -import com.abiquo.model.rest.RESTLink; -import com.abiquo.model.transport.AcceptedRequestDto; -import com.abiquo.model.transport.SingleResourceTransportDto; -import com.abiquo.model.transport.WrapperDto; -import com.abiquo.server.core.task.TaskDto; -import com.google.common.base.Function; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.Lists; -import com.google.common.reflect.Invokable; -import com.google.inject.TypeLiteral; - -/** - * 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; - - /** 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"); - } - - /** - * 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; - } - - /** - * Refresh the state of the current object. - */ - @SuppressWarnings("unchecked") - public void refresh() { - RESTLink link = checkNotNull(LinkUtils.getSelfLink(target), ValidationErrors.MISSING_REQUIRED_LINK + " edit/self"); - - ExtendedUtils utils = (ExtendedUtils) context.getUtils(); - HttpResponse response = utils.getAbiquoHttpClient().get(link); - - ParseXMLWithJAXB parser = new ParseXMLWithJAXB(utils.getXml(), - TypeLiteral.get((Class) target.getClass())); - - target = parser.apply(response); - } - - /** - * 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; - } - - try { - Invokable cons = constructor(wrapperClass, RestContext.class, target.getClass()); - return cons.invoke(null, context, target); - } catch (InvocationTargetException e) { - throw new WrapperException(wrapperClass, target, e.getTargetException()); - } catch (IllegalAccessException e) { - throw new WrapperException(wrapperClass, target, e); - } - } - - /** - * 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 ImmutableList.copyOf(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 ImmutableList.copyOf(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; - - 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()); - } - } - - /** - * 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) { - return concat(transform(collection, new Function, Collection>() { - @Override - public Collection apply(WrapperDto input) { - return input.getCollection(); - } - })); - } - - /** - * 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); - } - - /** - * 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 = Lists.newArrayList(); - - 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); - } - -} 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 deleted file mode 100644 index 013e0a3c8c..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/builder/LimitsBuilder.java +++ /dev/null @@ -1,98 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.domain.builder; - -/** - * Base class for all builders that represent limits. - * - * @author Ignasi Barrera - * @param - * The type of the target builder. - */ -public abstract class LimitsBuilder> { - /** The default limits for enterprises (unlimited). */ - protected static final int DEFAULT_LIMITS = 0; - - protected Integer ramSoftLimitInMb = DEFAULT_LIMITS; - - protected Integer ramHardLimitInMb = DEFAULT_LIMITS; - - protected Integer cpuCountSoftLimit = DEFAULT_LIMITS; - - protected Integer cpuCountHardLimit = DEFAULT_LIMITS; - - protected Long hdSoftLimitInMb = Long.valueOf(DEFAULT_LIMITS); - - protected Long hdHardLimitInMb = Long.valueOf(DEFAULT_LIMITS); - - protected Long storageSoft = Long.valueOf(DEFAULT_LIMITS); - - protected Long storageHard = Long.valueOf(DEFAULT_LIMITS); - - protected Long vlansSoft = Long.valueOf(DEFAULT_LIMITS); - - protected Long vlansHard = Long.valueOf(DEFAULT_LIMITS); - - protected Long publicIpsSoft = 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 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 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 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 deleted file mode 100644 index 9f93668b7a..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/cloud/Conversion.java +++ /dev/null @@ -1,131 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.domain.cloud; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.Date; - -import org.jclouds.abiquo.AbiquoApi; -import org.jclouds.abiquo.AbiquoAsyncApi; -import org.jclouds.abiquo.domain.DomainWithTasksWrapper; -import org.jclouds.abiquo.domain.task.AsyncTask; -import org.jclouds.abiquo.reference.ValidationErrors; -import org.jclouds.abiquo.reference.rest.ParentLinkName; -import org.jclouds.abiquo.rest.internal.ExtendedUtils; -import org.jclouds.http.HttpResponse; -import org.jclouds.http.functions.ParseXMLWithJAXB; -import org.jclouds.rest.RestContext; - -import com.abiquo.model.enumerator.ConversionState; -import com.abiquo.model.enumerator.DiskFormatType; -import com.abiquo.model.rest.RESTLink; -import com.abiquo.server.core.appslibrary.ConversionDto; -import com.abiquo.server.core.appslibrary.VirtualMachineTemplateDto; -import com.google.inject.TypeLiteral; - -/** - * Adds high level functionality to {@link ConversionDto}. - * - * @author Ignasi Barrera - * @author Francesc Montserrat - * @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); - } - - // 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); - - ExtendedUtils utils = (ExtendedUtils) context.getUtils(); - HttpResponse response = utils.getAbiquoHttpClient().get(link); - - ParseXMLWithJAXB parser = new ParseXMLWithJAXB( - utils.getXml(), TypeLiteral.get(VirtualMachineTemplateDto.class)); - - 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()); - } - - // Delegate methods - - public String getSourcePath() { - return target.getSourcePath(); - } - - public ConversionState getState() { - return target.getState(); - } - - public String getTargetPath() { - return target.getTargetPath(); - } - - public Long getTargetSizeInBytes() { - return target.getTargetSizeInBytes(); - } - - public DiskFormatType getSourceFormat() { - return target.getSourceFormat(); - } - - public DiskFormatType getTargetFormat() { - return target.getTargetFormat(); - } - - 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() + "]"; - } -} 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 deleted file mode 100644 index 81d9af7072..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/cloud/HardDisk.java +++ /dev/null @@ -1,164 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.domain.cloud; - -import static com.google.common.base.Preconditions.checkNotNull; - -import org.jclouds.abiquo.AbiquoApi; -import org.jclouds.abiquo.AbiquoAsyncApi; -import org.jclouds.abiquo.domain.DomainWrapper; -import org.jclouds.abiquo.reference.ValidationErrors; -import org.jclouds.abiquo.reference.rest.ParentLinkName; -import org.jclouds.rest.RestContext; - -import com.abiquo.server.core.cloud.VirtualDatacenterDto; -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. - * - * @author Ignasi Barrera - * @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; - - /** - * Constructor to be used only by the builder. - */ - protected HardDisk(final RestContext context, final DiskManagementDto target) { - super(context, target); - } - - // 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); - } - - /** - * Deletes the hard disk. - */ - public void delete() { - context.getApi().getCloudApi().deleteHardDisk(target); - target = null; - } - - // 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; - } - - // Builder - - public static Builder builder(final RestContext context, - final VirtualDatacenter virtualDatacenter) { - return new Builder(context, virtualDatacenter); - } - - public static class Builder { - private RestContext context; - - private Long sizeInMb; - - 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 sizeInMb(final long sizeInMb) { - this.sizeInMb = sizeInMb; - return this; - } - - public HardDisk build() { - DiskManagementDto dto = new DiskManagementDto(); - dto.setSizeInMb(sizeInMb); - - HardDisk hardDisk = new HardDisk(context, dto); - hardDisk.virtualDatacenter = virtualDatacenter; - - return hardDisk; - } - } - - // 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 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(); - } - - @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 deleted file mode 100644 index 0fb209b8ef..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/cloud/VirtualAppliance.java +++ /dev/null @@ -1,382 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.domain.cloud; - -import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.collect.Iterables.filter; - -import java.util.List; - -import org.jclouds.abiquo.AbiquoApi; -import org.jclouds.abiquo.AbiquoAsyncApi; -import org.jclouds.abiquo.domain.DomainWrapper; -import org.jclouds.abiquo.domain.cloud.options.VirtualMachineOptions; -import org.jclouds.abiquo.domain.enterprise.Enterprise; -import org.jclouds.abiquo.domain.task.AsyncTask; -import org.jclouds.abiquo.reference.ValidationErrors; -import org.jclouds.abiquo.reference.rest.ParentLinkName; -import org.jclouds.rest.RestContext; - -import com.abiquo.model.transport.AcceptedRequestDto; -import com.abiquo.server.core.cloud.VirtualApplianceDto; -import com.abiquo.server.core.cloud.VirtualApplianceState; -import com.abiquo.server.core.cloud.VirtualApplianceStateDto; -import com.abiquo.server.core.cloud.VirtualDatacenterDto; -import com.abiquo.server.core.cloud.VirtualMachineTaskDto; -import com.abiquo.server.core.cloud.VirtualMachineWithNodeExtendedDto; -import com.abiquo.server.core.cloud.VirtualMachinesWithNodeExtendedDto; -import com.abiquo.server.core.enterprise.EnterpriseDto; -import com.google.common.base.Predicate; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.Iterables; - -/** - * Represents a virtual appliance. - *

- * A virtual appliance is a logic container for virtual machines that together - * make an appliance. - * - * @author Ignasi Barrera - * @author Francesc Montserrat - * @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; - - /** - * Constructor to be used only by the builder. - */ - protected VirtualAppliance(final RestContext context, final VirtualApplianceDto target) { - super(context, target); - } - - // Domain operations - - /** - * 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); - } - - /** - * Updates the virtual appliance information when some of its properties have - * changed. - */ - public void update() { - target = context.getApi().getCloudApi().updateVirtualAppliance(target); - } - - // Parent access - - /** - * Gets the virtual datacenter where the virtual appliance belongs to. - * - * @return 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 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 - - /** - * 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 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 ImmutableList.copyOf(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 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 - - /** - * 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); - - AcceptedRequestDto response = context.getApi().getCloudApi().deployVirtualAppliance(unwrap(), force); - - 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. - * - * @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); - - 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); - } - - // Builder - - public static Builder builder(final RestContext context, - final VirtualDatacenter virtualDatacenter) { - return new Builder(context, virtualDatacenter); - } - - public static class Builder { - private RestContext context; - - private String name; - - 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 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 VirtualAppliance build() { - VirtualApplianceDto dto = new VirtualApplianceDto(); - dto.setName(name); - - VirtualAppliance virtualAppliance = new VirtualAppliance(context, dto); - virtualAppliance.virtualDatacenter = virtualDatacenter; - - return virtualAppliance; - } - - public static Builder fromVirtualAppliance(final VirtualAppliance in) { - return VirtualAppliance.builder(in.context, in.virtualDatacenter).name(in.getName()); - } - } - - // Delegate methods - - public int getError() { - return target.getError(); - } - - public int getHighDisponibility() { - return target.getHighDisponibility(); - } - - public Integer getId() { - return target.getId(); - } - - public String getName() { - return target.getName(); - } - - public int getPublicApp() { - return target.getPublicApp(); - } - - public void setHighDisponibility(final int highDisponibility) { - target.setHighDisponibility(highDisponibility); - } - - public void setName(final String name) { - target.setName(name); - } - - public void setPublicApp(final int publicApp) { - target.setPublicApp(publicApp); - } - - @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 deleted file mode 100644 index 61a4050f2f..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/cloud/VirtualDatacenter.java +++ /dev/null @@ -1,629 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.domain.cloud; - -import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.collect.Iterables.filter; - -import java.util.List; - -import org.jclouds.abiquo.AbiquoApi; -import org.jclouds.abiquo.AbiquoAsyncApi; -import org.jclouds.abiquo.domain.DomainWithLimitsWrapper; -import org.jclouds.abiquo.domain.builder.LimitsBuilder; -import org.jclouds.abiquo.domain.cloud.options.VirtualMachineTemplateOptions; -import org.jclouds.abiquo.domain.enterprise.Enterprise; -import org.jclouds.abiquo.domain.infrastructure.Datacenter; -import org.jclouds.abiquo.domain.infrastructure.Tier; -import org.jclouds.abiquo.domain.network.ExternalNetwork; -import org.jclouds.abiquo.domain.network.Network; -import org.jclouds.abiquo.domain.network.PrivateIp; -import org.jclouds.abiquo.domain.network.PrivateNetwork; -import org.jclouds.abiquo.domain.network.PublicIp; -import org.jclouds.abiquo.domain.network.options.IpOptions; -import org.jclouds.abiquo.predicates.infrastructure.DatacenterPredicates; -import org.jclouds.abiquo.reference.ValidationErrors; -import org.jclouds.abiquo.reference.rest.ParentLinkName; -import org.jclouds.rest.RestContext; - -import com.abiquo.model.enumerator.HypervisorType; -import com.abiquo.model.enumerator.NetworkType; -import com.abiquo.model.enumerator.StatefulInclusion; -import com.abiquo.server.core.appslibrary.VirtualMachineTemplatesDto; -import com.abiquo.server.core.cloud.VirtualApplianceDto; -import com.abiquo.server.core.cloud.VirtualAppliancesDto; -import com.abiquo.server.core.cloud.VirtualDatacenterDto; -import com.abiquo.server.core.infrastructure.network.PublicIpsDto; -import com.abiquo.server.core.infrastructure.network.VLANNetworkDto; -import com.abiquo.server.core.infrastructure.network.VLANNetworksDto; -import com.abiquo.server.core.infrastructure.storage.DiskManagementDto; -import com.abiquo.server.core.infrastructure.storage.DisksManagementDto; -import com.abiquo.server.core.infrastructure.storage.TierDto; -import com.abiquo.server.core.infrastructure.storage.TiersDto; -import com.abiquo.server.core.infrastructure.storage.VolumeManagementDto; -import com.abiquo.server.core.infrastructure.storage.VolumesManagementDto; -import com.google.common.base.Predicate; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.Iterables; - -/** - * Represents a virtual datacenter. - *

- * 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 - */ -public class VirtualDatacenter extends DomainWithLimitsWrapper { - /** The enterprise where the rack belongs. */ - private Enterprise enterprise; - - /** The datacenter 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); - } - - // 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; - } - - /** - * 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); - } - - // 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 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 - - /** - * 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 ImmutableList.copyOf(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 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 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 ImmutableList.copyOf(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); - } - - /** - * Gets the storage tier with the given id from the current virtual - * datacenter. - * - * @param id - * The id of the storage tier. - * @return The storage 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 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 ImmutableList.copyOf(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); - } - - 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()); - } - - public List listHardDisks(final Predicate filter) { - return ImmutableList.copyOf(filter(listHardDisks(), filter)); - } - - 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); - } - - /** - * @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()); - } - - public List listPrivateNetworks(final Predicate> filter) { - return ImmutableList.copyOf(filter(listPrivateNetworks(), filter)); - } - - 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); - } - - /** - * TODO needs to be in the wiki - */ - public List listAvailableTemplates() { - VirtualMachineTemplatesDto templates = context.getApi().getCloudApi().listAvailableTemplates(target); - - return wrap(context, VirtualMachineTemplate.class, templates.getCollection()); - } - - public List listAvailableTemplates(final VirtualMachineTemplateOptions options) { - VirtualMachineTemplatesDto templates = context.getApi().getCloudApi().listAvailableTemplates(target, options); - - return wrap(context, VirtualMachineTemplate.class, templates.getCollection()); - } - - public List listAvailableTemplates(final Predicate filter) { - return ImmutableList.copyOf(filter(listAvailableTemplates(), filter)); - } - - 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()); - - 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()); - - 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(); - - PublicIpsDto ips = context.getApi().getCloudApi().listAvailablePublicIps(target, options); - - return wrap(context, PublicIp.class, ips.getCollection()); - } - - public List listAvailablePublicIps(final Predicate filter) { - return ImmutableList.copyOf(filter(listAvailablePublicIps(), filter)); - } - - 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(); - - PublicIpsDto ips = context.getApi().getCloudApi().listPurchasedPublicIps(target, options); - - return wrap(context, PublicIp.class, ips.getCollection()); - } - - public List listPurchasedPublicIps(final Predicate filter) { - return ImmutableList.copyOf(filter(listPurchasedPublicIps(), filter)); - } - - 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 releasePublicIp(final PublicIp ip) { - checkNotNull(ip.unwrap().searchLink("release"), ValidationErrors.MISSING_REQUIRED_LINK); - context.getApi().getCloudApi().releasePublicIp(ip.unwrap()); - } - - // Actions - - public void setDefaultNetwork(final Network network) { - context.getApi().getCloudApi().setDefaultNetwork(target, network.unwrap()); - } - - // Builder - - 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; - - private String name; - - private HypervisorType hypervisorType; - - private Enterprise enterprise; - - private Datacenter datacenter; - - 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 name(final String name) { - this.name = name; - 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 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 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; - - 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()); - } - } - - // Delegate methods - - public HypervisorType getHypervisorType() { - return target.getHypervisorType(); - } - - public Integer getId() { - return target.getId(); - } - - public String getName() { - return target.getName(); - } - - public void setHypervisorType(final HypervisorType hypervisorType) { - target.setHypervisorType(hypervisorType); - } - - public void setName(final String name) { - target.setName(name); - } - - @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 deleted file mode 100644 index f9353694f5..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/cloud/VirtualMachine.java +++ /dev/null @@ -1,899 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.domain.cloud; - -import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.collect.Iterables.filter; - -import java.util.Arrays; -import java.util.List; - -import org.jclouds.abiquo.AbiquoApi; -import org.jclouds.abiquo.AbiquoAsyncApi; -import org.jclouds.abiquo.domain.DomainWithTasksWrapper; -import org.jclouds.abiquo.domain.cloud.options.VirtualMachineOptions; -import org.jclouds.abiquo.domain.enterprise.Enterprise; -import org.jclouds.abiquo.domain.network.Ip; -import org.jclouds.abiquo.domain.network.Network; -import org.jclouds.abiquo.domain.network.UnmanagedNetwork; -import org.jclouds.abiquo.domain.task.AsyncTask; -import org.jclouds.abiquo.domain.util.LinkUtils; -import org.jclouds.abiquo.features.services.MonitoringService; -import org.jclouds.abiquo.monitor.VirtualMachineMonitor; -import org.jclouds.abiquo.predicates.LinkPredicates; -import org.jclouds.abiquo.reference.ValidationErrors; -import org.jclouds.abiquo.reference.rest.ParentLinkName; -import org.jclouds.abiquo.rest.internal.ExtendedUtils; -import org.jclouds.abiquo.strategy.cloud.ListAttachedNics; -import org.jclouds.http.HttpResponse; -import org.jclouds.http.functions.ParseXMLWithJAXB; -import org.jclouds.rest.RestContext; - -import com.abiquo.model.rest.RESTLink; -import com.abiquo.model.transport.AcceptedRequestDto; -import com.abiquo.server.core.appslibrary.VirtualMachineTemplateDto; -import com.abiquo.server.core.cloud.VirtualApplianceDto; -import com.abiquo.server.core.cloud.VirtualDatacenterDto; -import com.abiquo.server.core.cloud.VirtualMachineState; -import com.abiquo.server.core.cloud.VirtualMachineStateDto; -import com.abiquo.server.core.cloud.VirtualMachineTaskDto; -import com.abiquo.server.core.cloud.VirtualMachineWithNodeExtendedDto; -import com.abiquo.server.core.enterprise.EnterpriseDto; -import com.abiquo.server.core.infrastructure.network.UnmanagedIpDto; -import com.abiquo.server.core.infrastructure.network.VMNetworkConfigurationDto; -import com.abiquo.server.core.infrastructure.network.VMNetworkConfigurationsDto; -import com.abiquo.server.core.infrastructure.storage.DiskManagementDto; -import com.abiquo.server.core.infrastructure.storage.DisksManagementDto; -import com.abiquo.server.core.infrastructure.storage.DvdManagementDto; -import com.abiquo.server.core.infrastructure.storage.VolumeManagementDto; -import com.abiquo.server.core.infrastructure.storage.VolumesManagementDto; -import com.google.common.base.Function; -import com.google.common.base.Predicate; -import com.google.common.base.Predicates; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.Iterables; -import com.google.common.collect.Lists; -import com.google.inject.TypeLiteral; - -/** - * Adds high level functionality to {@link VirtualMachineWithNodeExtendedDto}. - * - * @author Ignasi Barrera - * @author Francesc Montserrat - * @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; - } - - // 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 ImmutableList.copyOf(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 ImmutableList.copyOf(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 ImmutableList.copyOf(strategy.execute(this)); - } - - public List> listAttachedNics(final Predicate> filter) { - return ImmutableList.copyOf(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 = Lists.newArrayList(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 = Lists.newArrayList(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 = Lists.newArrayList(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 = Lists.newArrayList(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 unmanagedNetworks) { - // 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 (unmanagedNetworks != null && !unmanagedNetworks.isEmpty()) { - gateway = unmanagedNetworks.get(0); - } - - return setNics(gateway, ips, unmanagedNetworks); - } - - 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 unmanagedNetworks) { - // 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 (unmanagedNetworks != null) { - for (UnmanagedNetwork unmanaged : unmanagedNetworks) { - 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 = checkNotNull(nameLabel, "nameLabel must not be null"); - 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(checkNotNull(nameLabel, ValidationErrors.MISSING_REQUIRED_FIELD + "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 deleted file mode 100644 index 202f3b0af8..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/cloud/VirtualMachineTemplate.java +++ /dev/null @@ -1,380 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.domain.cloud; - -import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.collect.Iterables.filter; - -import java.util.Date; -import java.util.List; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import org.jclouds.abiquo.AbiquoApi; -import org.jclouds.abiquo.AbiquoAsyncApi; -import org.jclouds.abiquo.domain.DomainWrapper; -import org.jclouds.abiquo.domain.cloud.options.ConversionOptions; -import org.jclouds.abiquo.domain.config.Category; -import org.jclouds.abiquo.domain.config.CostCode; -import org.jclouds.abiquo.domain.enterprise.Enterprise; -import org.jclouds.abiquo.domain.infrastructure.Datacenter; -import org.jclouds.abiquo.domain.infrastructure.Tier; -import org.jclouds.abiquo.domain.task.AsyncTask; -import org.jclouds.abiquo.reference.rest.ParentLinkName; -import org.jclouds.abiquo.rest.internal.ExtendedUtils; -import org.jclouds.http.HttpResponse; -import org.jclouds.http.functions.ParseXMLWithJAXB; -import org.jclouds.rest.RestContext; - -import com.abiquo.model.enumerator.ConversionState; -import com.abiquo.model.enumerator.DiskFormatType; -import com.abiquo.model.enumerator.HypervisorType; -import com.abiquo.model.rest.RESTLink; -import com.abiquo.model.transport.AcceptedRequestDto; -import com.abiquo.server.core.appslibrary.CategoryDto; -import com.abiquo.server.core.appslibrary.ConversionDto; -import com.abiquo.server.core.appslibrary.ConversionsDto; -import com.abiquo.server.core.appslibrary.VirtualMachineTemplateDto; -import com.abiquo.server.core.appslibrary.VirtualMachineTemplatePersistentDto; -import com.abiquo.server.core.infrastructure.storage.VolumeManagementDto; -import com.abiquo.server.core.pricing.CostCodeDto; -import com.google.common.base.Predicate; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.Iterables; -import com.google.inject.TypeLiteral; - -/** - * Adds high level functionality to {@link VirtualMachineTemplateDto}. - * - * @author Ignasi Barrera - * @author Francesc Montserrat - * @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); - } - - // Domain operations - - public void delete() { - context.getApi().getVirtualMachineTemplateApi().deleteVirtualMachineTemplate(target); - target = null; - } - - 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 makePersistent(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 makePersistent(vdc, storageLink, persistentTemplateName, persistentVolumeName); - } - - private AsyncTask makePersistent(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); - - // 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); - - return getTask(response); - } - - // 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/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)); - - VolumeManagementDto dto = parser.apply(rp); - return new Volume(context, dto); - } - return null; - } - - public boolean isPersistent() { - return target.searchLink("volume") != null; - } - - // 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/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 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 ImmutableList.copyOf(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); - } - - /** - * 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); - - AcceptedRequestDto taskRef = context.getApi().getVirtualMachineTemplateApi() - .requestConversion(target, diskFormat, request); - - 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); - } - - // Delegate methods - - public int getCpuRequired() { - return target.getCpuRequired(); - } - - public Date getCreationDate() { - return target.getCreationDate(); - } - - public String getCreationUser() { - return target.getCreationUser(); - } - - public String getDescription() { - return target.getDescription(); - } - - public long getDiskFileSize() { - return target.getDiskFileSize(); - } - - public DiskFormatType getDiskFormatType() { - return DiskFormatType.valueOf(target.getDiskFormatType()); - } - - public long getHdRequired() { - return target.getHdRequired(); - } - - public String getName() { - return target.getName(); - } - - public String getPath() { - return target.getPath(); - } - - public int getRamRequired() { - return target.getRamRequired(); - } - - public boolean isChefEnabled() { - return target.isChefEnabled(); - } - - public void setChefEnabled(final boolean chefEnabled) { - target.setChefEnabled(chefEnabled); - } - - public void setName(final String name) { - target.setName(name); - } - - public Integer getId() { - return target.getId(); - } - - 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() - + ", 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 deleted file mode 100644 index e5bb53053c..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/cloud/VirtualMachineTemplateInVirtualDatacenter.java +++ /dev/null @@ -1,48 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.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. - * - * @author Ignasi Barrera - */ -public class VirtualMachineTemplateInVirtualDatacenter { - private VirtualMachineTemplate template; - - private VirtualDatacenter 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 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 deleted file mode 100644 index fe814e3ba9..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/cloud/Volume.java +++ /dev/null @@ -1,224 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.domain.cloud; - -import static com.google.common.base.Preconditions.checkNotNull; - -import org.jclouds.abiquo.AbiquoApi; -import org.jclouds.abiquo.AbiquoAsyncApi; -import org.jclouds.abiquo.domain.DomainWrapper; -import org.jclouds.abiquo.domain.infrastructure.Tier; -import org.jclouds.abiquo.domain.task.AsyncTask; -import org.jclouds.abiquo.reference.ValidationErrors; -import org.jclouds.abiquo.reference.annotations.EnterpriseEdition; -import org.jclouds.abiquo.reference.rest.ParentLinkName; -import org.jclouds.rest.RestContext; - -import com.abiquo.model.enumerator.VolumeState; -import com.abiquo.model.rest.RESTLink; -import com.abiquo.model.transport.AcceptedRequestDto; -import com.abiquo.server.core.cloud.VirtualDatacenterDto; -import com.abiquo.server.core.infrastructure.storage.TierDto; -import com.abiquo.server.core.infrastructure.storage.VolumeManagementDto; - -/** - * Adds high level functionality to {@link VolumeManagementDto}. - * - * @author Ignasi Barrera - * @see API: - * http://community.abiquo.com/display/ABI20/Volume+Resource - */ -@EnterpriseEdition -public class Volume extends DomainWrapper { - /** The default state for volumes. */ - public static final VolumeState DEFAULT_STATE = VolumeState.DETACHED; - - /** The virtual datacenter where the volume belongs. */ - private VirtualDatacenter virtualDatacenter; - - /** 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); - } - - // Domain operations - - public void delete() { - context.getApi().getCloudApi().deleteVolume(target); - target = null; - } - - 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); - } - - // 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; - } - - /** - * 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 - - /** - * 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 - - 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; - - private String name; - - private String description; - - private Long sizeInMb; - - private VirtualDatacenter virtualDatacenter; - - 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 name(final String name) { - this.name = name; - 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 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())); - - Volume volume = new Volume(context, dto); - volume.virtualDatacenter = virtualDatacenter; - volume.tier = tier; - - return volume; - } - } - - // Delegate methods - - public Integer getId() { - return target.getId(); - } - - public String getState() { - return target.getState(); - } - - public String getName() { - return target.getName(); - } - - public void setName(final String name) { - target.setName(name); - } - - public long getSizeInMB() { - return target.getSizeInMB(); - } - - public void setSizeInMB(final long sizeInMB) { - target.setSizeInMB(sizeInMB); - } - - public String getDescription() { - return target.getDescription(); - } - - 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() + "]"; - } - -} 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 deleted file mode 100644 index e074f9e4b9..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/cloud/options/ConversionOptions.java +++ /dev/null @@ -1,73 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.domain.cloud.options; - -import org.jclouds.http.options.BaseHttpRequestOptions; - -import com.abiquo.model.enumerator.ConversionState; -import com.abiquo.model.enumerator.HypervisorType; - -/** - * Available options to filter virtual machine template conversions - */ -public class ConversionOptions extends BaseHttpRequestOptions { - - public static Builder builder() { - return new Builder(); - } - - @Override - protected Object clone() throws CloneNotSupportedException { - ConversionOptions options = new ConversionOptions(); - options.queryParameters.putAll(queryParameters); - return options; - } - - public static class Builder { - private HypervisorType hypervisorType; - - private ConversionState conversionState; - - /** 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; - } - - 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()); - } - - 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 deleted file mode 100644 index 3fdf07a646..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/cloud/options/VirtualApplianceOptions.java +++ /dev/null @@ -1,61 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.domain.cloud.options; - -import org.jclouds.http.options.BaseHttpRequestOptions; - -/** - * Available options to query virtual appliances. - * - * @author Francesc Montserrat - * @author Ignasi Barrera - */ -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; - } - - public static class Builder { - - private Boolean available; - - public Builder available(final boolean available) { - this.available = available; - return this; - } - - public VirtualApplianceOptions build() { - VirtualApplianceOptions options = new VirtualApplianceOptions(); - - if (available != null) { - options.queryParameters.put("available", String.valueOf(available)); - } - - 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 deleted file mode 100644 index 27bea5d092..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/cloud/options/VirtualDatacenterOptions.java +++ /dev/null @@ -1,75 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.domain.cloud.options; - -import org.jclouds.http.options.BaseHttpRequestOptions; - -/** - * Available options to query virtual datacenters. - * - * @author Francesc Montserrat - */ -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; - } - - public static class Builder { - private Integer datacenterId; - - private Integer enterpriseId; - - /** - * 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; - } - - public VirtualDatacenterOptions build() { - VirtualDatacenterOptions options = new VirtualDatacenterOptions(); - - if (datacenterId != null) { - options.queryParameters.put("datacenter", datacenterId.toString()); - } - - 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 deleted file mode 100644 index e78c02baac..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/cloud/options/VirtualMachineOptions.java +++ /dev/null @@ -1,60 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.domain.cloud.options; - -import org.jclouds.abiquo.domain.options.search.FilterOptions.BaseFilterOptionsBuilder; -import org.jclouds.http.options.BaseHttpRequestOptions; - -/** - * Available options to query virtual machine. - * - * @author Alessia Prete - */ -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; - } - - public static class Builder extends BaseFilterOptionsBuilder { - private Boolean force; - - public Builder force(final Boolean force) { - this.force = force; - return this; - } - - public VirtualMachineOptions build() { - VirtualMachineOptions options = new VirtualMachineOptions(); - - if (force != null) { - options.queryParameters.put("force", String.valueOf(force)); - } - - 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 deleted file mode 100644 index 7f587187d9..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/cloud/options/VirtualMachineTemplateOptions.java +++ /dev/null @@ -1,105 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.domain.cloud.options; - -import org.jclouds.abiquo.domain.config.Category; -import org.jclouds.http.options.BaseHttpRequestOptions; - -import com.abiquo.model.enumerator.HypervisorType; -import com.abiquo.model.enumerator.StatefulInclusion; - -/** - * Available options to query virtual machine templates. - * - * @author Ignasi Barrera - */ -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; - } - - public static class Builder { - private StatefulInclusion persistent; - - private HypervisorType hypervisorType; - - private Category category; - - private String categoryName; - - private Integer idTemplate; - - public Builder persistent(final StatefulInclusion persistent) { - this.persistent = persistent; - 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 categoryName(final String categoryName) { - this.categoryName = categoryName; - return this; - } - - public Builder idTemplate(final Integer idTemplate) { - this.idTemplate = idTemplate; - return this; - } - - 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 (category == null && categoryName != null) { - options.queryParameters.put("categoryName", categoryName); - } - - if (idTemplate != null) { - options.queryParameters.put("idTemplate", String.valueOf(idTemplate)); - } - - 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 deleted file mode 100644 index 9048da61bf..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/cloud/options/VolumeOptions.java +++ /dev/null @@ -1,62 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.domain.cloud.options; - -import org.jclouds.abiquo.domain.options.search.FilterOptions.BaseFilterOptionsBuilder; -import org.jclouds.abiquo.reference.annotations.EnterpriseEdition; -import org.jclouds.http.options.BaseHttpRequestOptions; - -/** - * Available options to query volumes. - * - * @author Ignasi Barrera - */ -@EnterpriseEdition -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; - } - - public static class Builder extends BaseFilterOptionsBuilder { - private Boolean onlyAvailable; - - public Builder onlyAvailable(final boolean onlyAvailable) { - this.onlyAvailable = onlyAvailable; - return this; - } - - public VolumeOptions build() { - VolumeOptions options = new VolumeOptions(); - - if (onlyAvailable != null) { - options.queryParameters.put("available", String.valueOf(onlyAvailable)); - } - - 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 deleted file mode 100644 index f0206d67d3..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/config/Category.java +++ /dev/null @@ -1,169 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.domain.config; - -import org.jclouds.abiquo.AbiquoAsyncApi; -import org.jclouds.abiquo.AbiquoApi; -import org.jclouds.abiquo.domain.DomainWrapper; -import org.jclouds.rest.RestContext; - -import com.abiquo.server.core.appslibrary.CategoryDto; - -/** - * Adds high level functionality to {@link CategoryDto}. - * - * @author Ignasi Barrera - * @author Francesc Montserrat - * @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; - - /** 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); - } - - // 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-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); - } - - // Builder - - public static Builder builder(final RestContext context) { - return new Builder(context); - } - - public static class Builder { - private RestContext context; - - private String name; - - private Boolean erasable = DEFAULT_ERASABLE; - - private Boolean defaultCategory = DEFAULT_DEFAULT_CATEGORY; - - public Builder(final RestContext context) { - super(); - this.context = context; - } - - public Builder name(final String name) { - this.name = name; - 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 Category build() { - CategoryDto dto = new CategoryDto(); - dto.setErasable(erasable); - dto.setDefaultCategory(defaultCategory); - dto.setName(name); - Category category = new Category(context, dto); - - return category; - } - - public static Builder fromCategory(final Category in) { - Builder builder = Category.builder(in.context).name(in.getName()).erasable(in.isErasable()) - .defaultCategory(in.isDefaultCategory()); - - return builder; - } - } - - // Delegate methods - - public Integer getId() { - return target.getId(); - } - - public String getName() { - return target.getName(); - } - - public boolean isDefaultCategory() { - return target.isDefaultCategory(); - } - - public boolean isErasable() { - return target.isErasable(); - } - - public void setDefaultCategory(final boolean defaultCategory) { - target.setDefaultCategory(defaultCategory); - } - - public void setErasable(final boolean erasable) { - target.setErasable(erasable); - } - - 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 deleted file mode 100644 index 751db83f1f..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/config/CostCode.java +++ /dev/null @@ -1,173 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.domain.config; - -import java.util.List; - -import org.jclouds.abiquo.AbiquoApi; -import org.jclouds.abiquo.AbiquoAsyncApi; -import org.jclouds.abiquo.domain.DomainWrapper; -import org.jclouds.rest.RestContext; - -import com.abiquo.model.rest.RESTLink; -import com.abiquo.server.core.pricing.CostCodeCurrenciesDto; -import com.abiquo.server.core.pricing.CostCodeCurrencyDto; -import com.abiquo.server.core.pricing.CostCodeDto; -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. - *

- * 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 { - - 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); - } - - // Domain operations - - public void delete() { - context.getApi().getPricingApi().deleteCostCode(target); - target = null; - } - - 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(); - - 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); - } - - // Builder - - public static Builder builder(final RestContext context) { - return new Builder(context); - } - - public static class Builder { - private RestContext context; - - private String name; - - private String description; - - private List defaultPrices = Lists.newArrayList(); - - public Builder(final RestContext context) { - super(); - 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 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 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 - - 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 List getDefaultPrices() { - return defaultPrices; - } - - public void setDefaultPrices(final List defaultPrices) { - this.defaultPrices = defaultPrices; - } - - @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 deleted file mode 100644 index f0a63dfefb..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/config/CostCodeCurrency.java +++ /dev/null @@ -1,50 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.abiquo.domain.config; - -import java.math.BigDecimal; - -import org.jclouds.abiquo.AbiquoApi; -import org.jclouds.abiquo.AbiquoAsyncApi; -import org.jclouds.abiquo.domain.DomainWrapper; -import org.jclouds.rest.RestContext; - -import com.abiquo.server.core.pricing.CostCodeCurrencyDto; - -public class CostCodeCurrency extends DomainWrapper { - - protected CostCodeCurrency(final RestContext context, final CostCodeCurrencyDto target) { - super(context, target); - } - - // Delegate methods - - public Integer getId() { - return target.getId(); - } - - public BigDecimal getPrice() { - return target.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 deleted file mode 100644 index 324d11ea78..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/config/CostCodePrice.java +++ /dev/null @@ -1,60 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.abiquo.domain.config; - -import java.math.BigDecimal; - -/** - * Gives a price to a {@link CostCode}. - * - * @author Susana Acedo - */ -public class CostCodePrice { - private Currency currency; - - private BigDecimal price; - - public CostCodePrice(final Currency currency, final BigDecimal price) { - super(); - this.currency = currency; - this.price = price; - } - - public Currency getCurrency() { - return currency; - } - - public void setCurrency(final Currency currency) { - this.currency = currency; - } - - public BigDecimal getPrice() { - return price; - } - - public void setPrice(final BigDecimal price) { - this.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 deleted file mode 100644 index 1e0aa35568..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/config/Currency.java +++ /dev/null @@ -1,148 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.domain.config; - -import org.jclouds.abiquo.AbiquoApi; -import org.jclouds.abiquo.AbiquoAsyncApi; -import org.jclouds.abiquo.domain.DomainWrapper; -import org.jclouds.rest.RestContext; - -import com.abiquo.server.core.pricing.CurrencyDto; - -/** - * Adds high level functionality to {@link CurrencyDto}. - * - * @author Ignasi Barrera - * @author Susana Acedo - */ -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); - } - - // Domain operations - - public void delete() { - context.getApi().getPricingApi().deleteCurrency(target); - target = null; - } - - public void save() { - target = context.getApi().getPricingApi().createCurrency(target); - } - - public void update() { - target = context.getApi().getPricingApi().updateCurrency(target); - } - - // Builder - - public static Builder builder(final RestContext context) { - return new Builder(context); - } - - public static class Builder { - private RestContext context; - - private String name; - - private String symbol; - - private int digits; - - public Builder(final RestContext context) { - super(); - this.context = context; - } - - public Builder name(final String name) { - this.name = name; - 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 Currency build() { - CurrencyDto dto = new CurrencyDto(); - dto.setName(name); - dto.setSymbol(symbol); - dto.setDigits(digits); - Currency currency = new Currency(context, dto); - - return currency; - } - - public static Builder fromCurrency(final Currency in) { - Builder builder = Currency.builder(in.context).name(in.getName()).symbol(in.getSymbol()) - .digits(in.getDigits()); - - 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 getSymbol() { - return target.getSymbol(); - } - - public void setSymbol(final String symbol) { - target.setSymbol(symbol); - } - - public int getDigits() { - return target.getDigits(); - } - - public void setDigits(final int digits) { - target.setDigits(digits); - } - - @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 deleted file mode 100644 index d7f1c29f2c..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/config/License.java +++ /dev/null @@ -1,123 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.domain.config; - -import org.jclouds.abiquo.AbiquoAsyncApi; -import org.jclouds.abiquo.AbiquoApi; -import org.jclouds.abiquo.domain.DomainWrapper; -import org.jclouds.abiquo.reference.annotations.EnterpriseEdition; -import org.jclouds.rest.RestContext; - -import com.abiquo.server.core.config.LicenseDto; - -/** - * Adds high level functionality to {@link LicenseDto}. - * - * @author Ignasi Barrera - * @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); - } - - // Domain operations - - public void remove() { - context.getApi().getConfigApi().removeLicense(target); - target = null; - } - - public void add() { - target = context.getApi().getConfigApi().addLicense(target); - } - - // Builder - - public static Builder builder(final RestContext context, final String code) { - return new Builder(context, code); - } - - public static class Builder { - private RestContext context; - - private String 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 License build() { - LicenseDto dto = new LicenseDto(); - dto.setCode(code); - - License license = new License(context, dto); - return license; - } - - public static Builder fromLicense(final License in) { - return License.builder(in.context, in.getCode()); - } - } - - // Delegate methods - - public String getCode() { - return target.getCode(); - } - - public String getCustomerId() { - return target.getCustomerid(); - } - - public String getEnabledIp() { - return target.getEnabledip(); - } - - public String getExpiration() { - return target.getExpiration(); - } - - public Integer getId() { - return target.getId(); - } - - public Integer getNumCores() { - return target.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 deleted file mode 100644 index 397f03a74d..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/config/PricingCostCode.java +++ /dev/null @@ -1,115 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.abiquo.domain.config; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.math.BigDecimal; - -import org.jclouds.abiquo.AbiquoApi; -import org.jclouds.abiquo.AbiquoAsyncApi; -import org.jclouds.abiquo.domain.DomainWrapper; -import org.jclouds.abiquo.reference.ValidationErrors; -import org.jclouds.rest.RestContext; - -import com.abiquo.model.rest.RESTLink; -import com.abiquo.server.core.pricing.PricingCostCodeDto; - -/** - * Associates a {@link CostCode} with a pricing template. - * - * @author Susana Acedo - */ -public class PricingCostCode extends DomainWrapper { - private CostCode costcode; - - private PricingTemplate pricingTemplate; - - protected PricingCostCode(final RestContext context, final PricingCostCodeDto target) { - super(context, target); - } - - // Builder - - 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; - - private Integer id; - - private PricingTemplate pricingTemplate; - - private CostCode costcode; - - 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 price(final BigDecimal price) { - this.price = price; - return this; - } - - 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())); - - PricingCostCode pricingcostcode = new PricingCostCode(context, dto); - pricingcostcode.pricingTemplate = pricingTemplate; - pricingcostcode.costcode = costcode; - - return pricingcostcode; - } - - public static Builder fromPricingCostCode(final PricingCostCode in) { - return PricingCostCode.builder(in.context, in.pricingTemplate, in.costcode).price(in.getPrice()); - } - } - - // Delegate methods - - public Integer getId() { - return target.getId(); - } - - public BigDecimal getPrice() { - return target.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 deleted file mode 100644 index 7e7ce1714e..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/config/PricingTemplate.java +++ /dev/null @@ -1,378 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.domain.config; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.math.BigDecimal; -import java.util.Date; - -import org.jclouds.abiquo.AbiquoApi; -import org.jclouds.abiquo.AbiquoAsyncApi; -import org.jclouds.abiquo.domain.DomainWrapper; -import org.jclouds.abiquo.reference.ValidationErrors; -import org.jclouds.rest.RestContext; - -import com.abiquo.model.enumerator.PricingPeriod; -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}. - *

- * 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 { - - /** 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); - } - - // Domain operations - - public void delete() { - context.getApi().getPricingApi().deletePricingTemplate(target); - target = null; - } - - public void save() { - target = context.getApi().getPricingApi().createPricingTemplate(target); - } - - public void update() { - target = context.getApi().getPricingApi().updatePricingTemplate(target); - } - - // Builder - - public static Builder builder(final RestContext context, final Currency currency) { - return new Builder(context, currency); - } - - public static class Builder { - private RestContext context; - - private Currency currency; - - private String name; - - private String description; - - private BigDecimal hdGB; - - private BigDecimal standingChargePeriod; - - private BigDecimal vlan; - - private PricingPeriod chargingPeriod; - - private BigDecimal minimumChargePeriod; - - 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 deleted file mode 100644 index 89f4ec548c..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/config/PricingTier.java +++ /dev/null @@ -1,115 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.abiquo.domain.config; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.math.BigDecimal; - -import org.jclouds.abiquo.AbiquoApi; -import org.jclouds.abiquo.AbiquoAsyncApi; -import org.jclouds.abiquo.domain.DomainWrapper; -import org.jclouds.abiquo.domain.infrastructure.Tier; -import org.jclouds.abiquo.reference.ValidationErrors; -import org.jclouds.rest.RestContext; - -import com.abiquo.model.rest.RESTLink; -import com.abiquo.server.core.pricing.PricingTierDto; - -/** - * Associates an storage {@link Tier} with a {@link PricingTemplate}. - * - * @author Susana Acedo - */ -public class PricingTier extends DomainWrapper { - private Tier tier; - - private PricingTemplate pricingTemplate; - - protected PricingTier(final RestContext context, final PricingTierDto target) { - super(context, target); - } - - // Builder - - 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; - - private Integer id; - - private PricingTemplate pricingTemplate; - - private Tier tier; - - 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 price(final BigDecimal price) { - this.price = price; - return this; - } - - 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())); - - PricingTier pricingTier = new PricingTier(context, dto); - pricingTier.pricingTemplate = pricingTemplate; - pricingTier.tier = tier; - - return pricingTier; - } - - public static Builder fromPricingTier(final PricingTier in) { - return PricingTier.builder(in.context, in.pricingTemplate, in.tier).price(in.getPrice()); - } - } - - // Delegate methods - - public Integer getId() { - return target.getId(); - } - - public BigDecimal getPrice() { - return target.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 deleted file mode 100644 index 8c828dbdcf..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/config/Privilege.java +++ /dev/null @@ -1,61 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.domain.config; - -import org.jclouds.abiquo.AbiquoAsyncApi; -import org.jclouds.abiquo.AbiquoApi; -import org.jclouds.abiquo.domain.DomainWrapper; -import org.jclouds.abiquo.reference.annotations.EnterpriseEdition; -import org.jclouds.rest.RestContext; - -import com.abiquo.server.core.enterprise.PrivilegeDto; - -/** - * Adds high level functionality to {@link PrivilegeDto}. - * - * @author Ignasi Barrera - * @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); - } - - // Delegate methods - - public Integer getId() { - return target.getId(); - } - - public String getName() { - return target.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 deleted file mode 100644 index 6366f324c8..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/config/SystemProperty.java +++ /dev/null @@ -1,79 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.domain.config; - -import org.jclouds.abiquo.AbiquoAsyncApi; -import org.jclouds.abiquo.AbiquoApi; -import org.jclouds.abiquo.domain.DomainWrapper; -import org.jclouds.rest.RestContext; - -import com.abiquo.server.core.config.SystemPropertyDto; - -/** - * Adds high level functionality to {@link SystemPropertyDto}. - * - * @author Ignasi Barrera - * @author Francesc Montserrat - * @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); - } - - // Domain operations - - /** - * @see API: http://community.abiquo.com/display/ABI20/System+Property+resource# - * SystemPropertyresource-ModifyanexistingSystemProperty - */ - public void update() { - target = context.getApi().getConfigApi().updateSystemProperty(target); - } - - // Delegate methods - - public String getName() { - return target.getName(); - } - - public String getValue() { - return target.getValue(); - } - - public void setValue(final String value) { - target.setValue(value); - } - - @Override - public String toString() { - return "SystemProperty [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 deleted file mode 100644 index 792abeefd1..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/config/options/IconOptions.java +++ /dev/null @@ -1,58 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.domain.config.options; - -import org.jclouds.http.options.BaseHttpRequestOptions; - -/** - * Available options to query icons. - * - * @author Francesc Montserrat - */ -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; - } - - public static class Builder { - private String path; - - 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); - } - - 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 deleted file mode 100644 index 80504d7df7..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/config/options/LicenseOptions.java +++ /dev/null @@ -1,70 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.domain.config.options; - -import org.jclouds.abiquo.reference.annotations.EnterpriseEdition; -import org.jclouds.http.options.BaseHttpRequestOptions; - -/** - * Available options to query licenses. - * - * @author Francesc Montserrat - */ -@EnterpriseEdition -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; - } - - public static class Builder { - private Boolean active; - - /** - * Search active licenses - */ - public Builder active(final boolean active) { - this.active = active; - return this; - } - - /** - * Search inactive 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; - } - } -} 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 deleted file mode 100644 index 8b9c597619..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/config/options/PropertyOptions.java +++ /dev/null @@ -1,68 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.domain.config.options; - -import org.jclouds.http.options.BaseHttpRequestOptions; - -/** - * Available options to query system properties. - * - * @author Francesc Montserrat - */ -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; - } - - public static class Builder { - private String component; - - private String name; - - public Builder component(final String component) { - this.component = component; - 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()); - } - - 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 deleted file mode 100644 index 158e64921b..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/enterprise/Enterprise.java +++ /dev/null @@ -1,933 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.domain.enterprise; - -import static com.google.common.collect.Iterables.filter; - -import java.util.List; - -import org.jclouds.abiquo.AbiquoApi; -import org.jclouds.abiquo.AbiquoAsyncApi; -import org.jclouds.abiquo.domain.DomainWithLimitsWrapper; -import org.jclouds.abiquo.domain.builder.LimitsBuilder; -import org.jclouds.abiquo.domain.cloud.VirtualAppliance; -import org.jclouds.abiquo.domain.cloud.VirtualDatacenter; -import org.jclouds.abiquo.domain.cloud.VirtualMachine; -import org.jclouds.abiquo.domain.cloud.VirtualMachineTemplate; -import org.jclouds.abiquo.domain.exception.AbiquoException; -import org.jclouds.abiquo.domain.infrastructure.Datacenter; -import org.jclouds.abiquo.domain.infrastructure.Machine; -import org.jclouds.abiquo.domain.network.ExternalIp; -import org.jclouds.abiquo.domain.network.ExternalNetwork; -import org.jclouds.abiquo.domain.network.Network; -import org.jclouds.abiquo.domain.network.UnmanagedIp; -import org.jclouds.abiquo.domain.network.UnmanagedNetwork; -import org.jclouds.abiquo.reference.annotations.EnterpriseEdition; -import org.jclouds.abiquo.rest.internal.ExtendedUtils; -import org.jclouds.abiquo.strategy.enterprise.ListVirtualMachineTemplates; -import org.jclouds.http.HttpResponse; -import org.jclouds.http.functions.ParseXMLWithJAXB; -import org.jclouds.rest.RestContext; - -import com.abiquo.model.rest.RESTLink; -import com.abiquo.server.core.appslibrary.TemplateDefinitionListDto; -import com.abiquo.server.core.appslibrary.TemplateDefinitionListsDto; -import com.abiquo.server.core.appslibrary.VirtualMachineTemplateDto; -import com.abiquo.server.core.appslibrary.VirtualMachineTemplatesDto; -import com.abiquo.server.core.cloud.VirtualAppliancesDto; -import com.abiquo.server.core.cloud.VirtualDatacentersDto; -import com.abiquo.server.core.cloud.VirtualMachinesWithNodeExtendedDto; -import com.abiquo.server.core.enterprise.DatacenterLimitsDto; -import com.abiquo.server.core.enterprise.DatacentersLimitsDto; -import com.abiquo.server.core.enterprise.EnterpriseDto; -import com.abiquo.server.core.enterprise.EnterprisePropertiesDto; -import com.abiquo.server.core.enterprise.RolesDto; -import com.abiquo.server.core.enterprise.UserDto; -import com.abiquo.server.core.enterprise.UsersDto; -import com.abiquo.server.core.infrastructure.DatacentersDto; -import com.abiquo.server.core.infrastructure.MachinesDto; -import com.abiquo.server.core.infrastructure.network.VLANNetworksDto; -import com.google.common.base.Predicate; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.Iterables; -import com.google.inject.TypeLiteral; - -/** - * Represents a tenant. - *

- * Each tenant has a set of available locations, and a set of compute, - * networking and storage resources that can be consumed in the assigned - * locations. - * - * @author Ignasi Barrera - * @author Francesc Montserrat - */ -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); - } - - // 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; - } - - /** - * 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 enterprise 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 - - /** - * 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 ImmutableList.copyOf(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 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 ImmutableList.copyOf(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 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 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 ImmutableList.copyOf(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 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 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 ImmutableList.copyOf(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 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 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 ImmutableList.copyOf(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); - } - - 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 ImmutableList.copyOf(filter(listTemplatesInRepository(datacenter), filter)); - } - - 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 List listTemplates() { - ListVirtualMachineTemplates strategy = context.getUtils().getInjector() - .getInstance(ListVirtualMachineTemplates.class); - return ImmutableList.copyOf(strategy.execute(this)); - } - - public List listTemplates(final Predicate filter) { - ListVirtualMachineTemplates strategy = context.getUtils().getInjector() - .getInstance(ListVirtualMachineTemplates.class); - return ImmutableList.copyOf(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 List listAllowedDatacenters() { - DatacentersDto datacenters = context.getApi().getEnterpriseApi().listAllowedDatacenters(target.getId()); - return wrap(context, Datacenter.class, datacenters.getCollection()); - } - - public List listAllowedDatacenters(final Predicate filter) { - return ImmutableList.copyOf(filter(listAllowedDatacenters(), filter)); - } - - 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); - - ExtendedUtils utils = (ExtendedUtils) context.getUtils(); - HttpResponse response = utils.getAbiquoHttpClient().get(limitForDatacenter.searchLink("externalnetworks")); - - ParseXMLWithJAXB parser = new ParseXMLWithJAXB(utils.getXml(), - TypeLiteral.get(VLANNetworksDto.class)); - - return wrap(context, ExternalNetwork.class, parser.apply(response).getCollection()); - } - - @EnterpriseEdition - public List listExternalNetworks(final Datacenter datacenter, - final Predicate> filter) { - return ImmutableList.copyOf(filter(listExternalNetworks(datacenter), filter)); - } - - @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); - - ExtendedUtils utils = (ExtendedUtils) context.getUtils(); - // The "rel" for the unmanaged networks is the same than the one used for - // external networks - HttpResponse response = utils.getAbiquoHttpClient().get(limitForDatacenter.searchLink("externalnetworks")); - - ParseXMLWithJAXB parser = new ParseXMLWithJAXB(utils.getXml(), - TypeLiteral.get(VLANNetworksDto.class)); - - return wrap(context, UnmanagedNetwork.class, parser.apply(response).getCollection()); - } - - @EnterpriseEdition - public List listUnmanagedNetworks(final Datacenter datacenter, - final Predicate> filter) { - return ImmutableList.copyOf(filter(listUnmanagedNetworks(datacenter), filter)); - } - - @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 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 ImmutableList.copyOf(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 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 ImmutableList.copyOf(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); - } - - public List listReservedMachines() { - MachinesDto machines = context.getApi().getEnterpriseApi().listReservedMachines(target); - return wrap(context, Machine.class, machines.getCollection()); - } - - public List listReservedMachines(final Predicate filter) { - return ImmutableList.copyOf(filter(listVirtualMachines(), filter)); - } - - public VirtualMachine findReservedMachine(final Predicate filter) { - return Iterables.getFirst(filter(listVirtualMachines(), filter), null); - } - - // 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()); - } - - /** - * 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(); - - // 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); - } - - /** - * Prohibit 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()) { - // Should be only one limit - context.getApi().getEnterpriseApi().deleteLimits(dto.getCollection().get(0)); - } - } - - /** - * 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(); - } - - // Builder - - public static Builder builder(final RestContext context) { - return new Builder(context); - } - - public static class Builder extends LimitsBuilder { - private RestContext context; - - private String name; - - protected Long repositorySoft = Long.valueOf(DEFAULT_LIMITS); - - protected Long repositoryHard = Long.valueOf(DEFAULT_LIMITS); - - private Boolean isReservationRestricted = DEFAULT_RESERVATION_RESTRICTED; - - private String chefURL; - - private String chefClient; - - private String chefValidator; - - private String chefApiCertificate; - - private String chefValidatorCertificate; - - public Builder(final RestContext context) { - super(); - this.context = context; - } - - public Builder isReservationRestricted(final boolean isReservationRestricted) { - this.isReservationRestricted = isReservationRestricted; - return this; - } - - public Builder chefURL(final String chefURL) { - this.chefURL = chefURL; - return this; - } - - public Builder chefClient(final String chefClient) { - this.chefClient = chefClient; - return this; - } - - public Builder chefApiCertificate(final String chefApiCertificate) { - this.chefApiCertificate = chefApiCertificate; - return this; - } - - public Builder chefValidator(final String chefValidator) { - this.chefValidator = chefValidator; - return this; - } - - public Builder chefValidatorCertificate(final String chefValidatorCertificate) { - this.chefValidatorCertificate = chefValidatorCertificate; - return this; - } - - public Builder name(final String name) { - this.name = name; - return this; - } - - public Builder repositoryLimits(final long soft, final long hard) { - this.repositorySoft = soft; - this.repositoryHard = hard; - 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); - - return new Enterprise(context, dto); - } - - 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()); - } - } - - // Delegate methods - - public Integer getId() { - return target.getId(); - } - - public boolean getIsReservationRestricted() { - return target.getIsReservationRestricted(); - } - - public String getName() { - return target.getName(); - } - - public long getRepositoryHard() { - return target.getRepositoryHard(); - } - - public long getRepositorySoft() { - return target.getRepositorySoft(); - } - - public void setIsReservationRestricted(final boolean isReservationRestricted) { - target.setIsReservationRestricted(isReservationRestricted); - } - - public void setName(final String name) { - target.setName(name); - } - - public void setRepositoryHard(final long repositoryHard) { - target.setRepositoryHard(repositoryHard); - } - - public void setRepositoryLimits(final long soft, final long hard) { - target.setRepositoryLimits(soft, hard); - } - - public void setRepositorySoft(final long repositorySoft) { - target.setRepositorySoft(repositorySoft); - } - - public String getChefClient() { - return target.getChefClient(); - } - - public String getChefApiCertificate() { - return target.getChefClientCertificate(); - } - - public String getChefURL() { - return target.getChefURL(); - } - - public String getChefValidator() { - return target.getChefValidator(); - } - - public String getChefValidatorCertificate() { - return target.getChefValidatorCertificate(); - } - - public void setChefClient(final String chefClient) { - target.setChefClient(chefClient); - } - - public void setChefClientCertificate(final String chefClientCertificate) { - target.setChefClientCertificate(chefClientCertificate); - } - - public void setChefURL(final String chefURL) { - target.setChefURL(chefURL); - } - - public void setChefValidator(final String chefValidator) { - target.setChefValidator(chefValidator); - } - - 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 deleted file mode 100644 index fcf2060e56..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/enterprise/EnterpriseProperties.java +++ /dev/null @@ -1,85 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.domain.enterprise; - -import java.util.Map; - -import org.jclouds.abiquo.AbiquoApi; -import org.jclouds.abiquo.AbiquoAsyncApi; -import org.jclouds.abiquo.domain.DomainWrapper; -import org.jclouds.abiquo.reference.annotations.EnterpriseEdition; -import org.jclouds.abiquo.reference.rest.ParentLinkName; -import org.jclouds.rest.RestContext; - -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 - * - */ -@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); - } - - // 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)); - } - - // Delegate methods - public Map getProperties() { - return target.getProperties(); - } - - 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 deleted file mode 100644 index 6bb068fd9b..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/enterprise/Limits.java +++ /dev/null @@ -1,151 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.domain.enterprise; - -import org.jclouds.abiquo.AbiquoApi; -import org.jclouds.abiquo.AbiquoAsyncApi; -import org.jclouds.abiquo.domain.DomainWithLimitsWrapper; -import org.jclouds.abiquo.domain.builder.LimitsBuilder; -import org.jclouds.rest.RestContext; - -import com.abiquo.server.core.enterprise.DatacenterLimitsDto; - -/** - * Adds high level functionality to {@link DatacenterLimitsDto}. - * - * @author Ignasi Barrera - * @author Francesc Montserrat - * @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); - } - - // Domain operations - - /** - * @see API: - * http://community.abiquo.com/display/ABI20/Datacenter+Limits+Resource - * #DatacenterLimitsResource - * -UpdatesanexistingLimitforanenterpriseinadatacenter - */ - public void update() { - target = context.getApi().getEnterpriseApi().updateLimits(target); - } - - // Builder - - public static Builder builder(final RestContext context) { - return new Builder(context); - } - - public static class Builder extends LimitsBuilder { - private RestContext context; - - protected Long repositorySoft = Long.valueOf(DEFAULT_LIMITS); - - protected Long repositoryHard = Long.valueOf(DEFAULT_LIMITS); - - 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 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); - - 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()); - } - } - - // Delegate methods - - public Integer getId() { - return target.getId(); - } - - public long getRepositoryHard() { - return target.getRepositoryHardLimitsInMb(); - } - - public long getRepositorySoft() { - return target.getRepositorySoftLimitsInMb(); - } - - 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 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() - + "]"; - } - -} 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 deleted file mode 100644 index 5a4c9eb356..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/enterprise/Role.java +++ /dev/null @@ -1,223 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.domain.enterprise; - -import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.collect.Iterables.filter; - -import java.util.List; - -import org.jclouds.abiquo.AbiquoApi; -import org.jclouds.abiquo.AbiquoAsyncApi; -import org.jclouds.abiquo.domain.DomainWrapper; -import org.jclouds.abiquo.domain.config.Privilege; -import org.jclouds.abiquo.reference.ValidationErrors; -import org.jclouds.abiquo.reference.annotations.EnterpriseEdition; -import org.jclouds.rest.RestContext; - -import com.abiquo.model.rest.RESTLink; -import com.abiquo.server.core.enterprise.PrivilegesDto; -import com.abiquo.server.core.enterprise.RoleDto; -import com.google.common.base.Predicate; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.Iterables; - -/** - * Adds high level functionality to {@link RoleDto}. - * - * @author Ignasi Barrera - * @author Francesc Montserrat - * @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; - - /** - * Constructor to be used only by the builder. - */ - protected Role(final RestContext context, final RoleDto target) { - super(context, target); - } - - // 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 - * -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); - } - - 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"); - - checkNotNull(link, ValidationErrors.MISSING_REQUIRED_LINK); - - target.addLink(new RESTLink("enterprise", link.getHref())); - } - - @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); - - 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"); - } - - checkNotNull(link, ValidationErrors.MISSING_REQUIRED_LINK); - - target.addLink(new RESTLink("privilege" + privilege.getId(), link.getHref())); - } - - // Children access - - /** - * @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()); - } - - public List listPrivileges(final Predicate filter) { - return ImmutableList.copyOf(filter(listPrivileges(), filter)); - } - - public Privilege findPrivileges(final Predicate filter) { - return Iterables.getFirst(filter(listPrivileges(), filter), null); - } - - // Builder - - public static Builder builder(final RestContext context) { - return new Builder(context); - } - - public static class Builder { - private RestContext context; - - private String name; - - private boolean blocked = DEFAULT_BLOCKED; - - public Builder(final RestContext context) { - super(); - this.context = context; - } - - public Builder name(final String name) { - this.name = name; - 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); - - return role; - } - - public static Builder fromRole(final Role in) { - return Role.builder(in.context).blocked(in.isBlocked()).name(in.getName()); - } - } - - // Delegate methods - - public Integer getId() { - return target.getId(); - } - - public String getName() { - return target.getName(); - } - - public boolean isBlocked() { - return target.isBlocked(); - } - - public void setBlocked(final boolean blocked) { - target.setBlocked(blocked); - } - - public void setName(final String name) { - target.setName(name); - } - - @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 deleted file mode 100644 index 494f010be2..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/enterprise/TemplateDefinitionList.java +++ /dev/null @@ -1,219 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.domain.enterprise; - -import static com.google.common.collect.Iterables.filter; - -import java.util.List; - -import org.jclouds.abiquo.AbiquoApi; -import org.jclouds.abiquo.AbiquoAsyncApi; -import org.jclouds.abiquo.domain.DomainWrapper; -import org.jclouds.abiquo.domain.infrastructure.Datacenter; -import org.jclouds.rest.RestContext; - -import com.abiquo.am.model.TemplatesStateDto; -import com.abiquo.server.core.appslibrary.TemplateDefinitionListDto; -import com.google.common.base.Predicate; -import com.google.common.collect.ImmutableList; - -/** - * 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; - - /** - * Constructor to be used only by the builder. - */ - protected TemplateDefinitionList(final RestContext context, - final TemplateDefinitionListDto target) { - super(context, target); - } - - // 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; - } - - /** - * 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); - } - - // 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 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 ImmutableList.copyOf(filter(listStatus(datacenter), filter)); - } - - // Builder - - public static Builder builder(final RestContext context, final Enterprise enterprise) { - return new Builder(context, enterprise); - } - - public static class Builder { - private RestContext context; - - private Enterprise enterprise; - - private String name; - - private String url; - - 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 url(final String url) { - this.url = url; - return this; - } - - public TemplateDefinitionList build() { - TemplateDefinitionListDto dto = new TemplateDefinitionListDto(); - dto.setName(name); - dto.setUrl(url); - - 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()); - } - } - - // Delegate methods - - public Integer getId() { - return target.getId(); - } - - public String getName() { - return target.getName(); - } - - public String getUrl() { - return target.getUrl(); - } - - public void setName(final String name) { - target.setName(name); - } - - public void setUrl(final String url) { - target.setUrl(url); - } - - @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 deleted file mode 100644 index 536ac9a8f1..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/enterprise/TemplateState.java +++ /dev/null @@ -1,72 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.domain.enterprise; - -import org.jclouds.abiquo.AbiquoApi; -import org.jclouds.abiquo.AbiquoAsyncApi; -import org.jclouds.abiquo.domain.DomainWrapper; -import org.jclouds.rest.RestContext; - -import com.abiquo.am.model.TemplateStateDto; -import com.abiquo.am.model.TemplateStatusEnumType; - -/** - * Adds high level functionality to {@link TemplateStateDto}. - * - * @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); - } - - // Domain operations - - public Double getDownloadingProgress() { - return target.getDownloadingProgress(); - } - - public String getErrorCause() { - return target.getErrorCause(); - } - - public String getMasterOvf() { - return target.getMasterOvf(); - } - - public String getOvfId() { - return target.getOvfId(); - } - - public TemplateStatusEnumType getStatus() { - return target.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 deleted file mode 100644 index 6f3ad9432a..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/enterprise/User.java +++ /dev/null @@ -1,444 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.domain.enterprise; - -import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.collect.Iterables.filter; - -import java.util.List; -import java.util.StringTokenizer; - -import org.jclouds.abiquo.AbiquoApi; -import org.jclouds.abiquo.AbiquoAsyncApi; -import org.jclouds.abiquo.domain.DomainWrapper; -import org.jclouds.abiquo.domain.cloud.VirtualDatacenter; -import org.jclouds.abiquo.domain.cloud.VirtualMachine; -import org.jclouds.abiquo.reference.ValidationErrors; -import org.jclouds.abiquo.reference.rest.ParentLinkName; -import org.jclouds.abiquo.strategy.cloud.ListVirtualDatacenters; -import org.jclouds.rest.RestContext; - -import com.abiquo.model.rest.RESTLink; -import com.abiquo.server.core.cloud.VirtualMachinesWithNodeExtendedDto; -import com.abiquo.server.core.enterprise.RoleDto; -import com.abiquo.server.core.enterprise.UserDto; -import com.google.common.base.Joiner; -import com.google.common.base.Predicate; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.Iterables; -import com.google.common.collect.Lists; - -/** - * Adds high level functionality to {@link UserDto}. - * - * @author Ignasi Barrera - * @author Francesc Montserrat - * @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 listPermittedVirtualDatacenters() { - 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 ImmutableList.copyOf(listVirtualDatacenters.execute(ids)); - } - - public List listPermittedVirtualDatacenters(final Predicate filter) { - return ImmutableList.copyOf(filter(listPermittedVirtualDatacenters(), filter)); - } - - public VirtualDatacenter findPermittedVirtualDatacenter(final Predicate filter) { - return Iterables.getFirst(filter(listPermittedVirtualDatacenters(), 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 datacenters from the user's enterprise. - */ - public void setPermittedVirtualDatacenters(final List vdcs) { - List ids = Lists.newArrayList(); - - 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 ImmutableList.copyOf(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 deleted file mode 100644 index f64e95a1a7..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/enterprise/options/EnterpriseOptions.java +++ /dev/null @@ -1,115 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.domain.enterprise.options; - -import org.jclouds.abiquo.domain.options.search.FilterOptions.BaseFilterOptionsBuilder; -import org.jclouds.http.options.BaseHttpRequestOptions; - -/** - * Available options to query enterprises. - * - * @author Francesc Montserrat - */ -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; - } - - public static class Builder extends BaseFilterOptionsBuilder { - private String idPricingTemplate; - - private Boolean included; - - private String filter; - - private Integer page; - - private Integer results; - - private Boolean network; - - public Builder pricingTemplate(final String idPricingTemplate) { - this.idPricingTemplate = idPricingTemplate; - 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 network(final boolean network) { - this.network = network; - 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 EnterpriseOptions build() { - EnterpriseOptions options = new EnterpriseOptions(); - - if (idPricingTemplate != null) { - options.queryParameters.put("idPricingTemplate", String.valueOf(idPricingTemplate)); - } - - if (included != null) { - options.queryParameters.put("included", String.valueOf(included)); - } - - if (filter != null) { - options.queryParameters.put("filter", String.valueOf(filter)); - } - - if (page != null) { - options.queryParameters.put("page", String.valueOf(page)); - } - - if (results != null) { - options.queryParameters.put("numResults", String.valueOf(results)); - } - - if (network != null) { - options.queryParameters.put("network", String.valueOf(network)); - } - - 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 deleted file mode 100644 index 695ce355f5..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/event/Event.java +++ /dev/null @@ -1,321 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.domain.event; - -import java.util.Date; - -import org.jclouds.abiquo.AbiquoAsyncApi; -import org.jclouds.abiquo.AbiquoApi; -import org.jclouds.abiquo.domain.DomainWrapper; -import org.jclouds.rest.RestContext; - -import com.abiquo.model.enumerator.SeverityType; -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() - + ", stacktrace=" + 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 deleted file mode 100644 index 5225f67199..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/event/options/EventOptions.java +++ /dev/null @@ -1,169 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.domain.event.options; - -import java.util.Date; -import java.util.Map; -import java.util.Map.Entry; - -import org.jclouds.abiquo.domain.options.search.FilterOptions.BaseFilterOptionsBuilder; -import org.jclouds.http.options.BaseHttpRequestOptions; - -import com.abiquo.model.enumerator.ComponentType; -import com.abiquo.model.enumerator.EventType; -import com.abiquo.model.enumerator.SeverityType; -import com.google.common.collect.Maps; - -/** - * Available options to query events. - * - * @author Vivien Mahé - */ -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; - } - - public static class Builder extends BaseFilterOptionsBuilder { - private Map filters = Maps.newHashMap(); - - 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 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 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 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 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 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 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 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 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 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 dateTo(final Date date) { - this.filters.put("dateTo", String.valueOf(date.getTime())); - return this; - } - - public EventOptions build() { - EventOptions options = new EventOptions(); - - for (Entry filter : filters.entrySet()) { - options.queryParameters.put(filter.getKey(), filter.getValue()); - } - - 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 deleted file mode 100644 index c2e6d725b8..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/exception/AbiquoException.java +++ /dev/null @@ -1,117 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.domain.exception; - -import static com.google.common.collect.Iterables.any; -import static com.google.common.collect.Iterables.filter; -import static com.google.common.collect.Iterables.find; -import static org.jclouds.abiquo.predicates.ErrorPredicates.code; - -import java.util.List; - -import javax.ws.rs.core.Response.Status; - -import com.abiquo.model.transport.error.ErrorDto; -import com.abiquo.model.transport.error.ErrorsDto; -import com.google.common.collect.ImmutableList; - -/** - * Abiquo API exception. - * - * @author Francesc Montserrat - * @author Ignasi Barrera - */ -public class AbiquoException extends RuntimeException { - - private static final long serialVersionUID = 3627304442037389536L; - - /** The HTTP status. */ - private Status httpStatus; - - /** The errors. */ - private ErrorsDto 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)); - } - - /** - * 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 ImmutableList.copyOf(filter(errors.getCollection(), code(code))); - } - - /** - * 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 HTTP status code. - */ - public int getHttpStatusCode() { - return httpStatus.getStatusCode(); - } - - /** - * Get the HTTP status name. - */ - public String getHttpStatusName() { - return httpStatus.getReasonPhrase(); - } - - /** - * Get the HTTP status. - */ - public Status getHttpStatus() { - return httpStatus; - } - - @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 deleted file mode 100644 index 791ba78371..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/exception/BuilderException.java +++ /dev/null @@ -1,62 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.domain.exception; - -/** - * Exception thrown during domain object building. - * - * @author Ignasi Barrera - */ -public class BuilderException extends RuntimeException { - - private static final long serialVersionUID = 540948631643049450L; - - /** - * 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 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 deleted file mode 100644 index e2205809c3..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/exception/WrapperException.java +++ /dev/null @@ -1,68 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.domain.exception; - -import org.jclouds.abiquo.domain.DomainWrapper; - -import com.abiquo.model.transport.SingleResourceTransportDto; - -/** - * Exception thrown during the wrapping process. - * - * @author Ignasi Barrera - */ -public class WrapperException extends RuntimeException { - - private static final long serialVersionUID = 3756802225851609583L; - - private Class> wrapperClass; - - private SingleResourceTransportDto 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(); - } - - public Class> getWrapperClass() { - return wrapperClass; - } - - public void setWrapperClass(Class> wrapperClass) { - this.wrapperClass = wrapperClass; - } - - public SingleResourceTransportDto getTarget() { - return 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 deleted file mode 100644 index 5ab2408807..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/AbstractPhysicalMachine.java +++ /dev/null @@ -1,270 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.domain.infrastructure; - -import static com.google.common.collect.Iterables.find; - -import java.util.List; - -import org.jclouds.abiquo.AbiquoApi; -import org.jclouds.abiquo.AbiquoAsyncApi; -import org.jclouds.abiquo.domain.DomainWrapper; -import org.jclouds.abiquo.predicates.infrastructure.DatastorePredicates; -import org.jclouds.abiquo.predicates.infrastructure.NetworkInterfacePredicates; -import org.jclouds.rest.RestContext; - -import com.abiquo.model.enumerator.HypervisorType; -import com.abiquo.model.enumerator.MachineIpmiState; -import com.abiquo.model.enumerator.MachineState; -import com.abiquo.server.core.infrastructure.DatastoresDto; -import com.abiquo.server.core.infrastructure.MachineDto; -import com.abiquo.server.core.infrastructure.MachineIpmiStateDto; -import com.abiquo.server.core.infrastructure.MachineStateDto; - -/** - * 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: - * 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; - - /** The default virtual cpu used in MB. */ - protected static final int DEFAULT_VCPU_USED = 1; - - /** - * Constructor to be used only by the builder. - */ - protected AbstractPhysicalMachine(final RestContext context, final MachineDto target) { - super(context, target); - } - - public void delete() { - context.getApi().getInfrastructureApi().deleteMachine(target); - target = null; - } - - 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 MachineIpmiState checkIpmi() { - MachineIpmiStateDto dto = context.getApi().getInfrastructureApi().checkMachineIpmiState(target); - return dto.getState(); - } - - // Children access - - 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 List getNetworkInterfaces() { - return wrap(context, NetworkInterface.class, target.getNetworkInterfaces().getCollection()); - } - - public NetworkInterface findNetworkInterface(final String name) { - return find(getNetworkInterfaces(), NetworkInterfacePredicates.name(name), null); - } - - // Delegate methods - - public Integer getId() { - return target.getId(); - } - - public String getIp() { - return target.getIp(); - } - - public String getIpmiIp() { - return target.getIpmiIP(); - } - - public String getIpmiPassword() { - return target.getIpmiPassword(); - } - - public Integer getIpmiPort() { - return target.getIpmiPort(); - } - - public String getIpmiUser() { - return target.getIpmiUser(); - } - - public String getIpService() { - return target.getIpService(); - } - - public String getName() { - return target.getName(); - } - - public String getPassword() { - return target.getPassword(); - } - - public Integer getPort() { - return target.getPort(); - } - - public MachineState getState() { - return target.getState(); - } - - public HypervisorType getType() { - return target.getType(); - } - - public String getUser() { - return target.getUser(); - } - - public Integer getVirtualCpuCores() { - return target.getVirtualCpuCores(); - } - - public Integer getVirtualCpusUsed() { - return target.getVirtualCpusUsed(); - } - - public Integer getVirtualRamInMb() { - return target.getVirtualRamInMb(); - } - - public Integer getVirtualRamUsedInMb() { - return target.getVirtualRamUsedInMb(); - } - - 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 setIp(final String ip) { - target.setIp(ip); - } - - public void setIpmiIp(final String ipmiIp) { - target.setIpmiIP(ipmiIp); - } - - public void setIpmiPassword(final String ipmiPassword) { - target.setIpmiPassword(ipmiPassword); - } - - public void setIpmiPort(final Integer ipmiPort) { - target.setIpmiPort(ipmiPort); - } - - public void setIpmiUser(final String ipmiUser) { - target.setIpmiUser(ipmiUser); - } - - public void setIpService(final String ipService) { - target.setIpService(ipService); - } - - public void setName(final String name) { - target.setName(name); - } - - public void setPassword(final String password) { - target.setPassword(password); - } - - public void setPort(final Integer port) { - target.setPort(port); - } - - public void setState(final MachineState state) { - target.setState(state); - } - - public void setType(final HypervisorType type) { - target.setType(type); - } - - public void setUser(final String user) { - target.setUser(user); - } - - public void setVirtualCpuCores(final Integer virtualCpuCores) { - target.setVirtualCpuCores(virtualCpuCores); - } - - public void setVirtualCpusUsed(final Integer virtualCpusUsed) { - target.setVirtualCpusUsed(virtualCpusUsed); - } - - public void setVirtualRamInMb(final Integer virtualRamInMb) { - target.setVirtualRamInMb(virtualRamInMb); - } - - public void setVirtualRamUsedInMb(final Integer virtualRamUsedInMb) { - target.setVirtualRamUsedInMb(virtualRamUsedInMb); - } - - public String getDescription() { - return target.getDescription(); - } - - // Aux operations - - public NetworkInterface findAvailableVirtualSwitch(final String virtualswitch) { - return find(getNetworkInterfaces(), NetworkInterfacePredicates.name(virtualswitch)); - } - - @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() + ", description=" - + getDescription() + "]"; - } - -} 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 deleted file mode 100644 index b6954e4c61..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/Blade.java +++ /dev/null @@ -1,173 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.domain.infrastructure; - -import static com.google.common.base.Preconditions.checkNotNull; - -import org.jclouds.abiquo.AbiquoApi; -import org.jclouds.abiquo.AbiquoAsyncApi; -import org.jclouds.abiquo.reference.ValidationErrors; -import org.jclouds.abiquo.reference.rest.ParentLinkName; -import org.jclouds.abiquo.rest.internal.ExtendedUtils; -import org.jclouds.http.HttpResponse; -import org.jclouds.http.functions.ParseXMLWithJAXB; -import org.jclouds.rest.RestContext; - -import com.abiquo.model.rest.RESTLink; -import com.abiquo.server.core.infrastructure.BladeLocatorLedDto; -import com.abiquo.server.core.infrastructure.LogicServerDto; -import com.abiquo.server.core.infrastructure.MachineDto; -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. - * - * @author Ignasi Barrera - * @author Francesc Montserrat - * @see API: - * http://community.abiquo.com/display/ABI20/MachineResource - */ -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); - } - - // 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); - - ExtendedUtils utils = (ExtendedUtils) context.getUtils(); - HttpResponse response = utils.getAbiquoHttpClient().get(link); - - ParseXMLWithJAXB parser = new ParseXMLWithJAXB(utils.getXml(), - TypeLiteral.get(UcsRackDto.class)); - - 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); - - return wrap(context, LogicServer.class, server); - } - - // 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 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 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); - - 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 deleted file mode 100644 index 0bf843d635..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/BladeLocatorLed.java +++ /dev/null @@ -1,73 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.domain.infrastructure; - -import org.jclouds.abiquo.AbiquoApi; -import org.jclouds.abiquo.AbiquoAsyncApi; -import org.jclouds.abiquo.domain.DomainWrapper; -import org.jclouds.abiquo.reference.annotations.EnterpriseEdition; -import org.jclouds.rest.RestContext; - -import com.abiquo.server.core.infrastructure.BladeLocatorLedDto; - -/** - * Adds high level functionality to {@link BladeLocatorLedDto}. - * - * @author Ignasi Barrera - * @author Francesc Montserrat - * @see API: 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); - } - - // Delegate Methods - - public String getAdminStatus() { - return target.getAdminStatus(); - } - - public String getBladeDn() { - return target.getBladeDn(); - } - - public String getColor() { - return target.getColor(); - } - - public String getDn() { - return target.getDn(); - } - - @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 deleted file mode 100644 index 1e3ea9cb67..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/Datacenter.java +++ /dev/null @@ -1,1271 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.domain.infrastructure; - -import static com.google.common.collect.Iterables.filter; -import static com.google.common.collect.Iterables.find; -import static com.google.common.collect.Iterables.getFirst; -import static com.google.common.collect.Iterables.transform; - -import java.util.List; - -import org.jclouds.abiquo.AbiquoApi; -import org.jclouds.abiquo.AbiquoAsyncApi; -import org.jclouds.abiquo.config.AbiquoEdition; -import org.jclouds.abiquo.domain.DomainWrapper; -import org.jclouds.abiquo.domain.cloud.VirtualMachineTemplate; -import org.jclouds.abiquo.domain.enterprise.Enterprise; -import org.jclouds.abiquo.domain.enterprise.Limits; -import org.jclouds.abiquo.domain.infrastructure.options.DatacenterOptions; -import org.jclouds.abiquo.domain.infrastructure.options.IpmiOptions; -import org.jclouds.abiquo.domain.infrastructure.options.MachineOptions; -import org.jclouds.abiquo.domain.network.Network; -import org.jclouds.abiquo.domain.network.NetworkServiceType; -import org.jclouds.abiquo.domain.network.PrivateNetwork; -import org.jclouds.abiquo.domain.network.options.NetworkOptions; -import org.jclouds.abiquo.predicates.network.NetworkServiceTypePredicates; -import org.jclouds.abiquo.reference.annotations.EnterpriseEdition; -import org.jclouds.rest.RestContext; - -import com.abiquo.model.enumerator.HypervisorType; -import com.abiquo.model.enumerator.MachineIpmiState; -import com.abiquo.model.enumerator.MachineState; -import com.abiquo.model.enumerator.NetworkType; -import com.abiquo.model.enumerator.RemoteServiceType; -import com.abiquo.model.enumerator.VlanTagAvailabilityType; -import com.abiquo.server.core.appslibrary.VirtualMachineTemplateDto; -import com.abiquo.server.core.appslibrary.VirtualMachineTemplatesDto; -import com.abiquo.server.core.cloud.HypervisorTypeDto; -import com.abiquo.server.core.cloud.HypervisorTypesDto; -import com.abiquo.server.core.enterprise.DatacentersLimitsDto; -import com.abiquo.server.core.infrastructure.DatacenterDto; -import com.abiquo.server.core.infrastructure.MachineDto; -import com.abiquo.server.core.infrastructure.MachineIpmiStateDto; -import com.abiquo.server.core.infrastructure.MachineStateDto; -import com.abiquo.server.core.infrastructure.MachinesDto; -import com.abiquo.server.core.infrastructure.RackDto; -import com.abiquo.server.core.infrastructure.RacksDto; -import com.abiquo.server.core.infrastructure.RemoteServicesDto; -import com.abiquo.server.core.infrastructure.UcsRackDto; -import com.abiquo.server.core.infrastructure.UcsRacksDto; -import com.abiquo.server.core.infrastructure.network.NetworkServiceTypeDto; -import com.abiquo.server.core.infrastructure.network.NetworkServiceTypesDto; -import com.abiquo.server.core.infrastructure.network.VLANNetworkDto; -import com.abiquo.server.core.infrastructure.network.VLANNetworksDto; -import com.abiquo.server.core.infrastructure.network.VlanTagAvailabilityDto; -import com.abiquo.server.core.infrastructure.storage.StorageDeviceDto; -import com.abiquo.server.core.infrastructure.storage.StorageDevicesDto; -import com.abiquo.server.core.infrastructure.storage.StorageDevicesMetadataDto; -import com.abiquo.server.core.infrastructure.storage.TiersDto; -import com.google.common.base.Function; -import com.google.common.base.Predicate; -import com.google.common.collect.ImmutableList; - -/** - * Adds high level functionality to {@link DatacenterDto}. - * - * @author Ignasi Barrera - * @author Francesc Montserrat - * @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; - - /** - * 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); - } - - // 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; - } - - /** - * 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(); - } - } - - /** - * 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); - - return availability.getAvailable(); - } - - // 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 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 ImmutableList.copyOf(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 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 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 ImmutableList.copyOf(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 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 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 ImmutableList.copyOf(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 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 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 ImmutableList.copyOf(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 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); - } - - /** - * Return the list of Network Service Types defined in a datacenter. By - * default, a Network Service Type called 'Service Network' will be created - * with the datacenter. - * - * @return List of network services in this datacenter. - */ - public List listNetworkServiceTypes() { - NetworkServiceTypesDto dtos = context.getApi().getInfrastructureApi().listNetworkServiceTypes(target); - return wrap(context, NetworkServiceType.class, dtos.getCollection()); - } - - /** - * Retrieve a filtered list of network service types in this datacenter. - * - * @param filter - * Filter to be applied to the list. - * @return Filtered list of storage devices in this datacenter. - */ - public List listNetworkServiceTypes(final Predicate filter) { - return ImmutableList.copyOf(filter(listNetworkServiceTypes(), filter)); - } - - /** - * Retrieve the first network service type matching the filter within the - * list of nsts in this datacenter. - * - * @param filter - * Filter to be applied to the list. - * @return First network service type matching the filter or - * null if there is none. - */ - public NetworkServiceType findNetworkServiceType(final Predicate filter) { - return getFirst(filter(listNetworkServiceTypes(), filter), null); - } - - /** - * Retrieve a single network service type. - * - * @param id - * Unique ID of the network service type in this datacenter. - * @return Network Service Type with the given id or null if it - * does not exist. - */ - public NetworkServiceType getNetworkServiceType(final Integer id) { - NetworkServiceTypeDto nst = context.getApi().getInfrastructureApi().getNetworkServiceType(target, id); - return wrap(context, NetworkServiceType.class, nst); - } - - /** - * Return the default network service type used by the datacenter. This - * datacenter will be the one used by {@link PrivateNetwork}. Even it can not - * be deleted, it can be modified. - * - * @return the defult {@link NetworkServiceType} - */ - public NetworkServiceType defaultNetworkServiceType() { - return find(listNetworkServiceTypes(), NetworkServiceTypePredicates.isDefault()); - } - - /** - * 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 ImmutableList.copyOf(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 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); - } - - 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(); - } - - /** - * 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 ImmutableList.copyOf(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 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 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 ImmutableList.copyOf(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 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 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 ImmutableList.copyOf(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 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 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 ImmutableList.copyOf(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 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 appropriate 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 - - /** - * 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); - - 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); - - 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 ImmutableList.copyOf(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 getFirst(filter(listAvailableHypervisors(), filter), null); - } - - private List getHypervisorTypes(final HypervisorTypesDto dtos) { - return ImmutableList.copyOf(transform(dtos.getCollection(), new Function() { - @Override - public HypervisorType apply(HypervisorTypeDto input) { - return HypervisorType.fromId(input.getId()); - } - })); - } - - /** - * 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()); - - // Credentials are not returned by the API - dto.setUser(user); - dto.setPassword(password); - - 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. - * @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); - } - - 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, - 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); - - 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(); - } - - /** - * 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 ImmutableList.copyOf(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 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 enterprise - * 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 - - public static Builder builder(final RestContext context) { - return new Builder(context); - } - - public static class Builder { - private RestContext context; - - private String name; - - private String location; - - private String ip; - - private AbiquoEdition edition; - - 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 name(final String name) { - this.name = name; - 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 static Builder fromDatacenter(final Datacenter in) { - return Datacenter.builder(in.context).name(in.getName()).location(in.getLocation()); - } - } - - // Delegate methods - - public Integer getId() { - return target.getId(); - } - - public String getLocation() { - return target.getLocation(); - } - - public String getName() { - return target.getName(); - } - - public void setLocation(final String location) { - target.setLocation(location); - } - - public void setName(final String name) { - target.setName(name); - } - - public String getUUID() { - return target.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 deleted file mode 100644 index 3d105e62c8..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/Datastore.java +++ /dev/null @@ -1,89 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.domain.infrastructure; - -import org.jclouds.abiquo.AbiquoApi; -import org.jclouds.abiquo.AbiquoAsyncApi; -import org.jclouds.abiquo.domain.DomainWrapper; -import org.jclouds.rest.RestContext; - -import com.abiquo.server.core.infrastructure.DatastoreDto; - -/** - * Adds high level functionality to {@link 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); - } - - // Delegate methods - - public String getDatastoreUUID() { - return target.getDatastoreUUID(); - } - - public String getDirectory() { - return target.getDirectory(); - } - - public Integer getId() { - return target.getId(); - } - - public String getName() { - return target.getName(); - } - - public String getRootPath() { - return target.getRootPath(); - } - - public long getSize() { - return target.getSize(); - } - - public long getUsedSize() { - return target.getUsedSize(); - } - - public boolean isEnabled() { - return target.isEnabled(); - } - - 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() + "]"; - } - -} 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 deleted file mode 100644 index 860affa622..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/Fsm.java +++ /dev/null @@ -1,75 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.domain.infrastructure; - -import org.jclouds.abiquo.AbiquoApi; -import org.jclouds.abiquo.AbiquoAsyncApi; -import org.jclouds.abiquo.domain.DomainWrapper; -import org.jclouds.abiquo.reference.annotations.EnterpriseEdition; -import org.jclouds.rest.RestContext; - -import com.abiquo.server.core.infrastructure.FsmDto; - -/** - * Adds high level functionality to {@link FsmDto}. - * - * @author Ignasi Barrera - * @author Francesc Montserrat - * @see API: - * 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); - } - - // Delegate Methods - - public String getDescription() { - return target.getDescription(); - } - - public String getDn() { - return target.getDn(); - } - - public String getError() { - return target.getError(); - } - - public String getProgress() { - return target.getProgress(); - } - - public String getStatus() { - return target.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 deleted file mode 100644 index 61ce21f0c9..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/LogicServer.java +++ /dev/null @@ -1,90 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.domain.infrastructure; - -import java.util.List; - -import org.jclouds.abiquo.AbiquoApi; -import org.jclouds.abiquo.AbiquoAsyncApi; -import org.jclouds.abiquo.domain.DomainWrapper; -import org.jclouds.abiquo.reference.annotations.EnterpriseEdition; -import org.jclouds.rest.RestContext; - -import com.abiquo.server.core.infrastructure.LogicServerDto; -import com.abiquo.server.core.infrastructure.LogicServerPolicyDto; - -/** - * Adds high level functionality to {@link LogicServerDto}. - * - * @author Ignasi Barrera - * @author Francesc Montserrat - * @see API: - * 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); - } - - // Delegate Methods - - public String getName() { - return target.getName(); - } - - public void setType(final String value) { - target.setType(value); - } - - public String getAssociated() { - return target.getAssociated(); - } - - public String getType() { - return target.getType(); - } - - public String getAssociatedTo() { - return target.getAssociatedTo(); - } - - public String getDescription() { - return target.getDescription(); - } - - public void setDescription(final String value) { - target.setDescription(value); - } - - public List getCollection() { - return target.getCollection(); - } - - @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 deleted file mode 100644 index ab9bdcae97..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/Machine.java +++ /dev/null @@ -1,526 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.domain.infrastructure; - -import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.collect.Iterables.filter; -import static com.google.common.collect.Iterables.find; - -import java.util.List; - -import org.jclouds.abiquo.AbiquoApi; -import org.jclouds.abiquo.AbiquoAsyncApi; -import org.jclouds.abiquo.domain.cloud.VirtualMachine; -import org.jclouds.abiquo.domain.enterprise.Enterprise; -import org.jclouds.abiquo.domain.infrastructure.options.MachineOptions; -import org.jclouds.abiquo.predicates.infrastructure.DatastorePredicates; -import org.jclouds.abiquo.predicates.infrastructure.NetworkInterfacePredicates; -import org.jclouds.abiquo.reference.ValidationErrors; -import org.jclouds.abiquo.reference.rest.ParentLinkName; -import org.jclouds.abiquo.rest.internal.ExtendedUtils; -import org.jclouds.http.HttpResponse; -import org.jclouds.http.functions.ParseXMLWithJAXB; -import org.jclouds.rest.RestContext; - -import com.abiquo.model.enumerator.HypervisorType; -import com.abiquo.model.enumerator.MachineState; -import com.abiquo.model.rest.RESTLink; -import com.abiquo.server.core.cloud.VirtualMachineWithNodeExtendedDto; -import com.abiquo.server.core.cloud.VirtualMachinesWithNodeExtendedDto; -import com.abiquo.server.core.enterprise.EnterpriseDto; -import com.abiquo.server.core.infrastructure.DatastoresDto; -import com.abiquo.server.core.infrastructure.MachineDto; -import com.abiquo.server.core.infrastructure.MachineStateDto; -import com.abiquo.server.core.infrastructure.RackDto; -import com.abiquo.server.core.infrastructure.network.NetworkInterfacesDto; -import com.google.common.base.Predicate; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.Iterables; -import com.google.inject.TypeLiteral; - -/** - * 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: - * 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); - } - - @Override - public List getNetworkInterfaces() { - return wrap(context, NetworkInterface.class, target.getNetworkInterfaces().getCollection()); - } - - @Override - public NetworkInterface findNetworkInterface(final String name) { - return find(getNetworkInterfaces(), NetworkInterfacePredicates.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 ImmutableList.copyOf(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 synchronizing - * 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 synchronizing 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 ImmutableList.copyOf(filter(listVirtualMachines(), filter)); - } - - /** - * Gets a single virtual machine in the physical machine matching the given - * filter synchronizing 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; - - private String description; - - private Integer virtualRamInMb; - - private Integer virtualRamUsedInMb = DEFAULT_VRAM_USED; - - private Integer virtualCpuCores; - - private Integer virtualCpusUsed = DEFAULT_VCPU_USED; - - 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 Iterable networkInterfaces; - - 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 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 networkInterfaces(final Iterable networkInterfaces) { - this.networkInterfaces = networkInterfaces; - 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); - 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); - - NetworkInterfacesDto networkInterfacesDto = new NetworkInterfacesDto(); - networkInterfacesDto.getCollection().addAll(unwrap(networkInterfaces)); - dto.setNetworkInterfaces(networkInterfacesDto); - - 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()) - .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()) - .networkInterfaces(in.getNetworkInterfaces()); - - // 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 deleted file mode 100644 index 697ed62089..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/ManagedRack.java +++ /dev/null @@ -1,713 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.domain.infrastructure; - -import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.collect.Iterables.filter; - -import java.util.List; - -import org.jclouds.abiquo.AbiquoApi; -import org.jclouds.abiquo.AbiquoAsyncApi; -import org.jclouds.abiquo.domain.DomainWrapper; -import org.jclouds.abiquo.reference.ValidationErrors; -import org.jclouds.abiquo.reference.annotations.EnterpriseEdition; -import org.jclouds.abiquo.reference.rest.ParentLinkName; -import org.jclouds.rest.RestContext; - -import com.abiquo.server.core.infrastructure.FsmsDto; -import com.abiquo.server.core.infrastructure.LogicServersDto; -import com.abiquo.server.core.infrastructure.MachinesDto; -import com.abiquo.server.core.infrastructure.OrganizationsDto; -import com.abiquo.server.core.infrastructure.RackDto; -import com.abiquo.server.core.infrastructure.UcsRackDto; -import com.google.common.base.Predicate; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.Iterables; - -/** - * Adds high level functionality to {@link RackDto}. - * - * @author Ignasi Barrera - * @author Francesc Montserrat - * @see API: - * 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; - - /** 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 nrsq factor. */ - private static final int DEFAULT_NRSQ = 10; - - /** 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); - } - - // 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; - } - - /** - * 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); - } - - // 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 - - /** - * 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 ImmutableList.copyOf(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 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 ImmutableList.copyOf(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 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 ImmutableList.copyOf(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 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 ImmutableList.copyOf(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); - } - - /** - * @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 - - /** - * 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.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=" - + getVlansIdAvoided() + ", ip=" + getIp() + ", longDescription=" + getLongDescription() - + ", maxMachinesOn=" + getMaxMachinesOn() + ", password=**PROTECTED**, port=" + getPort() + ", user=" - + getUser() + ", defaultTemplate=" + getDefaultTemplate() + "]"; - } - -} diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/NetworkInterface.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/NetworkInterface.java deleted file mode 100644 index 413b202ffd..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/NetworkInterface.java +++ /dev/null @@ -1,79 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.abiquo.domain.infrastructure; - -import static com.google.common.base.Preconditions.checkNotNull; - -import org.jclouds.abiquo.AbiquoApi; -import org.jclouds.abiquo.AbiquoAsyncApi; -import org.jclouds.abiquo.domain.DomainWrapper; -import org.jclouds.abiquo.domain.network.NetworkServiceType; -import org.jclouds.abiquo.rest.internal.ExtendedUtils; -import org.jclouds.http.HttpResponse; -import org.jclouds.http.functions.ParseXMLWithJAXB; -import org.jclouds.rest.RestContext; - -import com.abiquo.model.rest.RESTLink; -import com.abiquo.server.core.infrastructure.network.NetworkInterfaceDto; -import com.abiquo.server.core.infrastructure.network.NetworkServiceTypeDto; -import com.google.inject.TypeLiteral; - -/** - * Represents a physical attached NIC. - * - * Allows to specify the {@link NetworkServiceType} for the network interface. - * This way all network interfaces have the information of the kind of network - * they are attached to. - * - * @author Jaume Devesa - */ -public class NetworkInterface extends DomainWrapper { - /** - * Constructor to be used only by the builder. This resource cannot be - * created. - */ - protected NetworkInterface(final RestContext context, final NetworkInterfaceDto target) { - super(context, target); - } - - public String getName() { - return target.getName(); - } - - public String getMac() { - return target.getMac(); - } - - public void setNetworkServiceType(final NetworkServiceType type) { - checkNotNull(type, "network service type cannot be null"); - target.setNetworkServiceTypeLink(type.unwrap().getEditLink().getHref()); - } - - public NetworkServiceType getNetworkServiceType() { - RESTLink link = target.getNetworkServiceTypeLink(); - - ExtendedUtils utils = (ExtendedUtils) context.getUtils(); - HttpResponse response = utils.getAbiquoHttpClient().get(link); - - ParseXMLWithJAXB parser = new ParseXMLWithJAXB(utils.getXml(), - TypeLiteral.get(NetworkServiceTypeDto.class)); - - return wrap(context, NetworkServiceType.class, parser.apply(response)); - } -} 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 deleted file mode 100644 index bffeaec042..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/Organization.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.domain.infrastructure; - -import org.jclouds.abiquo.AbiquoApi; -import org.jclouds.abiquo.AbiquoAsyncApi; -import org.jclouds.abiquo.domain.DomainWrapper; -import org.jclouds.abiquo.reference.annotations.EnterpriseEdition; -import org.jclouds.rest.RestContext; - -import com.abiquo.server.core.infrastructure.OrganizationDto; - -/** - * Adds high level functionality to {@link OrganizationDto}. - * - * @author Ignasi Barrera - * @author Francesc Montserrat - * @see API: - * 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); - } - - // Delegate Methods - - public String getDescription() { - return target.getDescription(); - } - - public String getDn() { - return target.getDn(); - } - - public String getLevel() { - return target.getLevel(); - } - - public String getName() { - return target.getName(); - } - - public String getStatus() { - return target.getStatus(); - } - - public void setDescription(final String value) { - target.setDescription(value); - } - - public void setDn(final String dn) { - target.setDn(dn); - } - - public void setLevel(final String value) { - target.setLevel(value); - } - - public void setName(final String value) { - target.setName(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() + "]"; - } -} 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 deleted file mode 100644 index e824f0360d..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/Rack.java +++ /dev/null @@ -1,377 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.domain.infrastructure; - -import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.collect.Iterables.filter; - -import java.util.List; - -import org.jclouds.abiquo.AbiquoApi; -import org.jclouds.abiquo.AbiquoAsyncApi; -import org.jclouds.abiquo.domain.DomainWrapper; -import org.jclouds.abiquo.reference.ValidationErrors; -import org.jclouds.abiquo.reference.rest.ParentLinkName; -import org.jclouds.rest.RestContext; - -import com.abiquo.server.core.infrastructure.MachineDto; -import com.abiquo.server.core.infrastructure.MachinesDto; -import com.abiquo.server.core.infrastructure.RackDto; -import com.google.common.base.Predicate; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.Iterables; - -/** - * 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; - - /** 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 nrsq factor. */ - private static final int DEFAULT_NRSQ = 10; - - /** 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); - } - - // 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; - } - - /** - * 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); - } - - // 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 - - /** - * 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 ImmutableList.copyOf(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 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 - - 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 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 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 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()); - } - } - - // Delegate methods - - public Integer getId() { - return target.getId(); - } - - public String getName() { - return target.getName(); - } - - public String getShortDescription() { - return target.getShortDescription(); - } - - public void setName(final String name) { - target.setName(name); - } - - 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); - } - - @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 deleted file mode 100644 index 94d6e532e9..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/RemoteService.java +++ /dev/null @@ -1,249 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.domain.infrastructure; - -import static com.google.common.base.Preconditions.checkNotNull; - -import org.jclouds.abiquo.AbiquoApi; -import org.jclouds.abiquo.AbiquoAsyncApi; -import org.jclouds.abiquo.domain.DomainWrapper; -import org.jclouds.abiquo.reference.ValidationErrors; -import org.jclouds.abiquo.reference.rest.ParentLinkName; -import org.jclouds.rest.RestContext; - -import com.abiquo.model.enumerator.RemoteServiceType; -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. - * - * @author Ignasi Barrera - * @author Francesc Montserrat - * @see API: - * http://community.abiquo.com/display/ABI20/RemoteServiceResource - */ -public class RemoteService extends DomainWrapper { - /** The default status. */ - private static final int DEFAULT_STATUS = 0; - - /** 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); - } - - /** - * 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); - } - - /** - * 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); - } - - // 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; - } - - 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 Datacenter datacenter; - - private String ip; - - private Integer port; - - private RemoteServiceType type; - - private Integer status = DEFAULT_STATUS; - - // 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 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 type(final RemoteServiceType type) { - this.type = type; - return this; - } - - public Builder ip(final String ip) { - this.ip = ip; - 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(); - } - - 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); - } - - 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; - } - } - - // Delegate methods - - public Integer getId() { - return target.getId(); - } - - public RemoteServiceType getType() { - return target.getType(); - } - - public int getStatus() { - return target.getStatus(); - } - - public String getUri() { - return target.getUri(); - } - - public void setStatus(final int status) { - target.setStatus(status); - } - - public void setType(final RemoteServiceType type) { - target.setType(type); - } - - 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() + "]"; - } - -} 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 deleted file mode 100644 index aa3d1e81d4..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/StorageDevice.java +++ /dev/null @@ -1,482 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.domain.infrastructure; - -import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.collect.Iterables.filter; - -import java.util.List; - -import org.jclouds.abiquo.AbiquoApi; -import org.jclouds.abiquo.AbiquoAsyncApi; -import org.jclouds.abiquo.domain.DomainWrapper; -import org.jclouds.abiquo.domain.infrastructure.options.StoragePoolOptions; -import org.jclouds.abiquo.reference.ValidationErrors; -import org.jclouds.abiquo.reference.annotations.EnterpriseEdition; -import org.jclouds.abiquo.reference.rest.ParentLinkName; -import org.jclouds.rest.RestContext; - -import com.abiquo.server.core.infrastructure.DatacenterDto; -import com.abiquo.server.core.infrastructure.storage.StorageDeviceDto; -import com.abiquo.server.core.infrastructure.storage.StoragePoolDto; -import com.abiquo.server.core.infrastructure.storage.StoragePoolsDto; -import com.abiquo.server.core.infrastructure.storage.TiersDto; -import com.google.common.base.Predicate; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.Iterables; - -/** - * 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: - * 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 ImmutableList.copyOf(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 ImmutableList.copyOf(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 ImmutableList.copyOf(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 deleted file mode 100644 index d900ac9eeb..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/StorageDeviceMetadata.java +++ /dev/null @@ -1,61 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.domain.infrastructure; - -import org.jclouds.abiquo.AbiquoApi; -import org.jclouds.abiquo.AbiquoAsyncApi; -import org.jclouds.abiquo.domain.DomainWrapper; -import org.jclouds.rest.RestContext; - -import com.abiquo.server.core.infrastructure.storage.StorageDeviceMetadataDto; - -/** - * metadata describing a Storage Device. - * - * @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); - } - - // Delegate methods - - public String getType() { - return target.getType(); - } - - public int getDefaultManagementPort() { - return target.getDefaultManagementPort(); - } - - public int getDefaultIscsiPort() { - return target.getDefaultIscsiPort(); - } - - 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 deleted file mode 100644 index b5a79210ba..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/StoragePool.java +++ /dev/null @@ -1,258 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.domain.infrastructure; - -import static com.google.common.base.Preconditions.checkNotNull; - -import org.jclouds.abiquo.AbiquoApi; -import org.jclouds.abiquo.AbiquoAsyncApi; -import org.jclouds.abiquo.domain.DomainWrapper; -import org.jclouds.abiquo.domain.config.Privilege; -import org.jclouds.abiquo.domain.infrastructure.options.StoragePoolOptions; -import org.jclouds.abiquo.reference.ValidationErrors; -import org.jclouds.abiquo.reference.annotations.EnterpriseEdition; -import org.jclouds.abiquo.reference.rest.ParentLinkName; -import org.jclouds.abiquo.rest.internal.ExtendedUtils; -import org.jclouds.http.HttpResponse; -import org.jclouds.http.functions.ParseXMLWithJAXB; -import org.jclouds.rest.RestContext; - -import com.abiquo.model.rest.RESTLink; -import com.abiquo.server.core.infrastructure.storage.StorageDeviceDto; -import com.abiquo.server.core.infrastructure.storage.StoragePoolDto; -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. - * - * @author Ignasi Barrera - * @author Francesc Montserrat - * @see API: - * http://community.abiquo.com/display/ABI20/StoragePoolResource - */ -@EnterpriseEdition -public class StoragePool extends DomainWrapper { - - /** 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); - } - - // 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; - } - - /** - * 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); - } - - @Override - 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); - - this.updateLink(target, ParentLinkName.TIER, tier.unwrap(), "edit"); - } - - // 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); - - ExtendedUtils utils = (ExtendedUtils) context.getUtils(); - HttpResponse response = utils.getAbiquoHttpClient().get(link); - - ParseXMLWithJAXB parser = new ParseXMLWithJAXB(utils.getXml(), - TypeLiteral.get(StorageDeviceDto.class)); - - return wrap(context, StorageDevice.class, parser.apply(response)); - } - - // Children access - - /** - * Get the tier assigned to the pool. The storage pool needs to be persisted - * in Abiquo first. - * - * @return The tier assigned 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); - - ParseXMLWithJAXB parser = new ParseXMLWithJAXB(utils.getXml(), TypeLiteral.get(TierDto.class)); - - return wrap(context, Tier.class, parser.apply(response)); - } - - // Builder - - public static Builder builder(final RestContext context, final StorageDevice storageDevice) { - return new Builder(context, storageDevice); - } - - public static class Builder { - private RestContext context; - private StorageDevice storageDevice; - private String name; - private Long totalSizeInMb; - - 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 name(final String name) { - this.name = name; - return this; - } - - public Builder totalSizeInMb(final long totalSizeInMb) { - this.totalSizeInMb = totalSizeInMb; - return this; - } - - public StoragePool build() { - StoragePoolDto dto = new StoragePoolDto(); - dto.setName(name); - dto.setTotalSizeInMb(totalSizeInMb); - 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()).totalSizeInMb(in.getTotalSizeInMb()); - - return builder; - } - } - - // Delegate methods - - public String getName() { - return target.getName(); - } - - public long getTotalSizeInMb() { - return target.getTotalSizeInMb(); - } - - public void setName(final String name) { - target.setName(name); - } - - public void setTotalSizeInMb(final long totalSizeInMb) { - target.setTotalSizeInMb(totalSizeInMb); - } - - // Readonly property - public String getUUID() { - return target.getIdStorage(); - } - - @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 deleted file mode 100644 index 919e2a18c0..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/Tier.java +++ /dev/null @@ -1,177 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.domain.infrastructure; - -import static com.google.common.collect.Iterables.filter; - -import java.util.List; - -import org.jclouds.abiquo.AbiquoApi; -import org.jclouds.abiquo.AbiquoAsyncApi; -import org.jclouds.abiquo.domain.DomainWrapper; -import org.jclouds.abiquo.reference.annotations.EnterpriseEdition; -import org.jclouds.abiquo.reference.rest.ParentLinkName; -import org.jclouds.rest.RestContext; - -import com.abiquo.server.core.infrastructure.DatacenterDto; -import com.abiquo.server.core.infrastructure.storage.StoragePoolsDto; -import com.abiquo.server.core.infrastructure.storage.TierDto; -import com.google.common.base.Predicate; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.Iterables; - -/** - * 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 - * @see API: - * http://community.abiquo.com/display/ABI20/TierResource - */ -@EnterpriseEdition -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); - } - - // 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); - } - - /** - * 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 ImmutableList.copyOf(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); - } - - // 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; - } - - // Delegate methods - - public String getDescription() { - return target.getDescription(); - } - - public boolean getEnabled() { - return target.getEnabled(); - } - - public Integer getId() { - return target.getId(); - } - - public String getName() { - return target.getName(); - } - - public void setDescription(final String description) { - target.setDescription(description); - } - - public void setEnabled(final boolean enabled) { - target.setEnabled(enabled); - } - - public void setName(final String name) { - target.setName(name); - } - - @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 deleted file mode 100644 index d8d56358ee..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/options/DatacenterOptions.java +++ /dev/null @@ -1,57 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.domain.infrastructure.options; - -import org.jclouds.http.options.BaseHttpRequestOptions; - -/** - * Available options to query datacenters. - * - * @author Francesc Montserrat - */ -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; - } - - public static class Builder { - private String ip; - - 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; - } - } -} 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 deleted file mode 100644 index 4d691e1060..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/options/IpmiOptions.java +++ /dev/null @@ -1,61 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.domain.infrastructure.options; - -import org.jclouds.http.options.BaseHttpRequestOptions; - -/** - * Available options to query ipmi config. - * - * @author scastro - */ -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; - } - - public static class Builder { - private Integer port; - - /** - * 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()); - } - - 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 deleted file mode 100644 index bd37a73ba8..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/options/MachineOptions.java +++ /dev/null @@ -1,75 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.domain.infrastructure.options; - -import org.jclouds.http.options.BaseHttpRequestOptions; - -/** - * Available options to query machines. - * - * @author Francesc Montserrat - */ -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; - } - - public static class Builder { - private Integer port; - - private Boolean sync; - - /** - * 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; - } - - 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()); - } - - 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 deleted file mode 100644 index 77b73fe3b5..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/options/StoragePoolOptions.java +++ /dev/null @@ -1,64 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.domain.infrastructure.options; - -import org.jclouds.abiquo.reference.annotations.EnterpriseEdition; -import org.jclouds.http.options.BaseHttpRequestOptions; - -/** - * Available options to query storage pools. - * - * @author Francesc Montserrat - */ - -@EnterpriseEdition -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; - } - - public static class Builder { - private Boolean sync; - - /** - * 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()); - } - - 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 deleted file mode 100644 index 42afb05aec..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/network/AbstractPublicIp.java +++ /dev/null @@ -1,60 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.domain.network; - -import org.jclouds.abiquo.AbiquoApi; -import org.jclouds.abiquo.AbiquoAsyncApi; -import org.jclouds.rest.RestContext; - -import com.abiquo.server.core.infrastructure.network.AbstractInfrastructureIpDto; - -/** - * Adds generic high level functionality to {@link 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); - } - - // Delegate methods - - public boolean isAvailable() { - return target.isAvailable(); - } - - public boolean isQuarantine() { - return target.isQuarantine(); - } - - public void setAvailable(final boolean available) { - target.setAvailable(available); - } - - 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 deleted file mode 100644 index c98f321a3b..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/network/ExternalIp.java +++ /dev/null @@ -1,81 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.domain.network; - -import static com.google.common.base.Preconditions.checkNotNull; - -import org.jclouds.abiquo.AbiquoApi; -import org.jclouds.abiquo.AbiquoAsyncApi; -import org.jclouds.abiquo.reference.ValidationErrors; -import org.jclouds.abiquo.reference.rest.ParentLinkName; -import org.jclouds.abiquo.rest.internal.ExtendedUtils; -import org.jclouds.http.HttpResponse; -import org.jclouds.http.functions.ParseXMLWithJAXB; -import org.jclouds.rest.RestContext; - -import com.abiquo.model.enumerator.NetworkType; -import com.abiquo.model.rest.RESTLink; -import com.abiquo.server.core.infrastructure.network.ExternalIpDto; -import com.abiquo.server.core.infrastructure.network.VLANNetworkDto; -import com.google.inject.TypeLiteral; - -/** - * Adds generic high level functionality to {@link ExternalIpDto}. - * - * @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); - } - - // Domain operations - - @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); - - ParseXMLWithJAXB parser = new ParseXMLWithJAXB(utils.getXml(), - TypeLiteral.get(VLANNetworkDto.class)); - - return wrap(context, ExternalNetwork.class, parser.apply(response)); - } - - @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() + "]"; - } - -} 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 deleted file mode 100644 index 592693b4c9..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/network/ExternalNetwork.java +++ /dev/null @@ -1,242 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.domain.network; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.List; - -import org.jclouds.abiquo.AbiquoApi; -import org.jclouds.abiquo.AbiquoAsyncApi; -import org.jclouds.abiquo.domain.enterprise.Enterprise; -import org.jclouds.abiquo.domain.infrastructure.Datacenter; -import org.jclouds.abiquo.domain.network.options.IpOptions; -import org.jclouds.abiquo.reference.ValidationErrors; -import org.jclouds.abiquo.reference.annotations.EnterpriseEdition; -import org.jclouds.abiquo.reference.rest.ParentLinkName; -import org.jclouds.abiquo.rest.internal.ExtendedUtils; -import org.jclouds.http.HttpResponse; -import org.jclouds.http.functions.ParseXMLWithJAXB; -import org.jclouds.rest.RestContext; - -import com.abiquo.model.enumerator.NetworkType; -import com.abiquo.model.rest.RESTLink; -import com.abiquo.server.core.enterprise.EnterpriseDto; -import com.abiquo.server.core.infrastructure.DatacenterDto; -import com.abiquo.server.core.infrastructure.network.ExternalIpDto; -import com.abiquo.server.core.infrastructure.network.ExternalIpsDto; -import com.abiquo.server.core.infrastructure.network.VLANNetworkDto; -import com.google.common.base.Optional; -import com.google.inject.TypeLiteral; - -/** - * Adds high level functionality to external {@link VLANNetworkDto}. - * - * @author Ignasi Barrera - * @author Francesc Montserrat - * @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; - - /** 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); - } - - /** - * @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 -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()); - } - - @Override - public ExternalIp getIp(final Integer id) { - ExternalIpDto ip = context.getApi().getInfrastructureApi().getExternalIp(target, id); - return wrap(context, ExternalIp.class, ip); - } - - // Parent access - - 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); - - ParseXMLWithJAXB parser = new ParseXMLWithJAXB(utils.getXml(), - TypeLiteral.get(EnterpriseDto.class)); - - 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); - - ExtendedUtils utils = (ExtendedUtils) context.getUtils(); - HttpResponse response = utils.getAbiquoHttpClient().get(link); - - ParseXMLWithJAXB parser = new ParseXMLWithJAXB(utils.getXml(), - TypeLiteral.get(DatacenterDto.class)); - - 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); - - RESTLink link = enterprise.unwrap().getEditLink(); - checkNotNull(link, ValidationErrors.MISSING_REQUIRED_LINK); - - target.addLink(new RESTLink("enterprise", link.getHref())); - } - - // Builder - - 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; - - private Enterprise enterprise; - - private Optional networkServiceType = Optional.absent(); - - public Builder(final RestContext context, final Datacenter datacenter, - final Enterprise enterprise) { - super(context); - this.datacenter = checkNotNull(datacenter, - ValidationErrors.NULL_RESOURCE + Datacenter.class.getCanonicalName()); - this.enterprise = checkNotNull(enterprise, - ValidationErrors.NULL_RESOURCE + Enterprise.class.getCanonicalName()); - this.context = context; - } - - public Builder datacenter(final Datacenter datacenter) { - this.datacenter = checkNotNull(datacenter, - ValidationErrors.NULL_RESOURCE + Datacenter.class.getCanonicalName()); - return this; - } - - public Builder enterprise(final Enterprise enterprise) { - this.enterprise = checkNotNull(enterprise, - ValidationErrors.NULL_RESOURCE + Enterprise.class.getCanonicalName()); - return this; - } - - public Builder networkServiceType(final NetworkServiceType networkServiceType) { - this.networkServiceType = Optional.of(networkServiceType); - 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(suffixDNS); - dto.setDefaultNetwork(defaultNetwork == null ? Boolean.FALSE : defaultNetwork); - dto.setUnmanaged(Boolean.FALSE); - dto.setType(NetworkType.EXTERNAL); - - NetworkServiceType nst = networkServiceType.or(datacenter.defaultNetworkServiceType()); - dto.addLink(new RESTLink("networkservicetype", nst.unwrap().getEditLink().getHref())); - - ExternalNetwork network = new ExternalNetwork(context, dto); - network.datacenter = datacenter; - network.enterprise = enterprise; - - 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()).suffixDNS(in.getSuffixDNS()).defaultNetwork(in.getDefaultNetwork()); - } - } - - @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 deleted file mode 100644 index 09173d3d88..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/network/Ip.java +++ /dev/null @@ -1,77 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.domain.network; - -import org.jclouds.abiquo.AbiquoApi; -import org.jclouds.abiquo.AbiquoAsyncApi; -import org.jclouds.abiquo.domain.DomainWrapper; -import org.jclouds.rest.RestContext; - -import com.abiquo.model.enumerator.NetworkType; -import com.abiquo.server.core.infrastructure.network.AbstractIpDto; - -/** - * Adds generic high level functionality to {@link 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); - } - - // Domain operations - - public abstract N getNetwork(); - - public abstract NetworkType getNetworkType(); - - // Delegate methods - - public Integer getId() { - return target.getId(); - } - - public String getIp() { - return target.getIp(); - } - - public String getMac() { - return target.getMac(); - } - - public String getName() { - return target.getName(); - } - - public String getNetworkName() { - return target.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 deleted file mode 100644 index dc4f56095f..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/network/Network.java +++ /dev/null @@ -1,332 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.domain.network; - -import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.collect.Iterables.filter; -import static com.google.common.collect.Iterables.transform; - -import java.util.List; - -import org.jclouds.abiquo.AbiquoApi; -import org.jclouds.abiquo.AbiquoAsyncApi; -import org.jclouds.abiquo.domain.DomainWrapper; -import org.jclouds.abiquo.domain.network.options.IpOptions; -import org.jclouds.abiquo.predicates.network.IpPredicates; -import org.jclouds.abiquo.reference.ValidationErrors; -import org.jclouds.rest.RestContext; - -import com.abiquo.model.enumerator.NetworkType; -import com.abiquo.server.core.infrastructure.network.VLANNetworkDto; -import com.google.common.base.Function; -import com.google.common.base.Predicate; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.Iterables; - -/** - * Adds generic high level functionality to {@link VLANNetworkDto}. - * - * @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); - } - - // Domain operations - - public abstract void save(); - - public abstract void update(); - - public abstract void delete(); - - public abstract List listIps(IpOptions options); - - public abstract T getIp(Integer id); - - public List listIps() { - // Disable pagination by default - return listIps(IpOptions.builder().disablePagination().build()); - } - - public List listIps(final Predicate filter) { - return ImmutableList.copyOf(filter(listIps(), filter)); - } - - public T findIp(final Predicate filter) { - return Iterables.getFirst(filter(listIps(), filter), null); - } - - public List listUnusedIps() { - return listIps(IpPredicates. notUsed()); - } - - public T findUnusedIp(final Predicate filter) { - return Iterables.getFirst(filter(listUnusedIps(), filter), null); - } - - // Builder - - public static class NetworkBuilder> { - protected RestContext context; - - protected String name; - - protected Integer tag; - - protected String gateway; - - protected String address; - - protected Integer mask; - - protected String primaryDNS; - - protected String secondaryDNS; - - protected String suffixDNS; - - protected Boolean defaultNetwork; - - 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 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 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 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 suffixDNS(final String suffixDNS) { - this.suffixDNS = suffixDNS; - 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), - ValidationErrors.INVALID_NETWORK_TYPE + target.getType()); - - return wrap(context, PrivateNetwork.class, target); - - } - - public ExternalNetwork toExternalNetwork() { - checkArgument(target.getType().equals(NetworkType.EXTERNAL), - ValidationErrors.INVALID_NETWORK_TYPE + target.getType()); - - return wrap(context, ExternalNetwork.class, target); - - } - - public PublicNetwork toPublicNetwork() { - checkArgument(target.getType().equals(NetworkType.PUBLIC), - ValidationErrors.INVALID_NETWORK_TYPE + target.getType()); - - return wrap(context, PublicNetwork.class, target); - - } - - public UnmanagedNetwork toUnmanagedNetwork() { - checkArgument(target.getType().equals(NetworkType.UNMANAGED), - ValidationErrors.INVALID_NETWORK_TYPE + target.getType()); - - return wrap(context, UnmanagedNetwork.class, target); - - } - - // Delegate methods - - public String getAddress() { - return target.getAddress(); - } - - public Boolean getDefaultNetwork() { - return target.getDefaultNetwork(); - } - - public String getGateway() { - return target.getGateway(); - } - - public Integer getId() { - return target.getId(); - } - - public Integer getMask() { - return target.getMask(); - } - - public String getName() { - return target.getName(); - } - - public String getPrimaryDNS() { - return target.getPrimaryDNS(); - } - - public String getSecondaryDNS() { - return target.getSecondaryDNS(); - } - - public String getSuffixDNS() { - return target.getSufixDNS(); - } - - public Integer getTag() { - return target.getTag(); - } - - public NetworkType getType() { - return target.getType(); - } - - public void setAddress(final String address) { - target.setAddress(address); - } - - public void setDefaultNetwork(final Boolean defaultNetwork) { - target.setDefaultNetwork(defaultNetwork); - } - - public void setGateway(final String gateway) { - target.setGateway(gateway); - } - - public void setMask(final Integer mask) { - target.setMask(mask); - } - - public void setName(final String name) { - target.setName(name); - } - - public void setPrimaryDNS(final String primaryDNS) { - target.setPrimaryDNS(primaryDNS); - } - - public void setSecondaryDNS(final String secondaryDNS) { - target.setSecondaryDNS(secondaryDNS); - } - - public void setSuffixDNS(final String suffixDNS) { - target.setSufixDNS(suffixDNS); - } - - 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=" + getSuffixDNS() + ", tag=" - + getTag() + ", type=" + getType() + "]"; - } - - public static Network wrapNetwork(final RestContext context, final VLANNetworkDto dto) { - if (dto == null) { - return 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; - } - - return network; - } - - public static List> wrapNetworks(final RestContext context, - final List dtos) { - return ImmutableList.copyOf(transform(dtos, new Function>() { - @Override - public Network apply(VLANNetworkDto input) { - return wrapNetwork(context, input); - } - })); - } -} diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/network/NetworkServiceType.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/network/NetworkServiceType.java deleted file mode 100644 index 78f5a46508..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/network/NetworkServiceType.java +++ /dev/null @@ -1,135 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.domain.network; - -import static com.google.common.base.Preconditions.checkNotNull; - -import org.jclouds.abiquo.AbiquoApi; -import org.jclouds.abiquo.AbiquoAsyncApi; -import org.jclouds.abiquo.domain.DomainWrapper; -import org.jclouds.abiquo.domain.infrastructure.Datacenter; -import org.jclouds.abiquo.reference.ValidationErrors; -import org.jclouds.rest.RestContext; - -import com.abiquo.server.core.infrastructure.network.NetworkServiceTypeDto; - -/** - * Network Service Type defines a network service. - * - * The network Service Type is used to select the network interface of the - * target host where a NIC in the virtual machine will be attached. - * - * They are scoped at {@link Datacenter} level: two {@link NetworkServiceType} - * can have the same name if they belong to a different {@link Datacenter} - * - * @author Jaume Devesa - */ -public class NetworkServiceType extends DomainWrapper { - public static Builder builder(final RestContext context, final Datacenter datacenter) { - return new Builder(context, datacenter); - } - - /** - * Helper class to build {@link NetworkServiceType} in a controlled way. - * - * @author Jaume Devesa - */ - public static class Builder { - private RestContext context; - - private Datacenter datacenter; - - private String name; - - public Builder(final RestContext context, final Datacenter datacenter) { - super(); - checkNotNull(datacenter, ValidationErrors.NULL_RESOURCE + Datacenter.class); - this.datacenter = datacenter; - this.context = context; - } - - public NetworkServiceType build() { - NetworkServiceTypeDto dto = new NetworkServiceTypeDto(); - dto.setName(this.name); - - NetworkServiceType nst = new NetworkServiceType(context, dto); - nst.datacenter = this.datacenter; - return nst; - } - - public Builder name(final String name) { - this.name = checkNotNull(name, ValidationErrors.MISSING_REQUIRED_FIELD + name); - return this; - } - } - - /** The datacenter where the NetworkServiceType belongs. */ - private Datacenter datacenter; - - /** Constructor will only be used by the builder. */ - protected NetworkServiceType(final RestContext context, final NetworkServiceTypeDto target) { - super(context, target); - } - - /** - * Delete the Network Service Type. - */ - public void delete() { - context.getApi().getInfrastructureApi().deleteNetworkServiceType(target); - target = null; - } - - /** - * Create a new Network Service Type - */ - public void save() { - target = context.getApi().getInfrastructureApi().createNetworkServiceType(datacenter.unwrap(), target); - } - - /** - * Update Network Service Type information in the server with the data from - * this NST. - */ - public void update() { - target = context.getApi().getInfrastructureApi().updateNetworkServiceType(target); - } - - public Integer getId() { - return target.getId(); - } - - public String getName() { - return target.getName(); - } - - public Boolean isDefaultNST() { - return target.isDefaultNST(); - } - - public void setName(final String name) { - target.setName(name); - } - - @Override - public String toString() { - return "NetworkServiceType [id=" + getId() + ", name=" + getName() + ", isDefault=" + isDefaultNST() + "]"; - } - -} 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 deleted file mode 100644 index e98e3febd6..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/network/Nic.java +++ /dev/null @@ -1,62 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.domain.network; - -import org.jclouds.abiquo.AbiquoApi; -import org.jclouds.abiquo.AbiquoAsyncApi; -import org.jclouds.abiquo.domain.DomainWrapper; -import org.jclouds.rest.RestContext; - -import com.abiquo.server.core.infrastructure.network.NicDto; - -/** - * Adds high level functionality to {@link NicDto}. - * - * @author Ignasi Barrera - * @author Francesc Montserrat - * @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); - } - - // Parent access - - // Delegate methods - - public Integer getId() { - return target.getId(); - } - - public String getIp() { - return target.getIp(); - } - - 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 deleted file mode 100644 index c14a91462c..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/network/PrivateIp.java +++ /dev/null @@ -1,80 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.domain.network; - -import static com.google.common.base.Preconditions.checkNotNull; - -import org.jclouds.abiquo.AbiquoApi; -import org.jclouds.abiquo.AbiquoAsyncApi; -import org.jclouds.abiquo.reference.ValidationErrors; -import org.jclouds.abiquo.reference.rest.ParentLinkName; -import org.jclouds.abiquo.rest.internal.ExtendedUtils; -import org.jclouds.http.HttpResponse; -import org.jclouds.http.functions.ParseXMLWithJAXB; -import org.jclouds.rest.RestContext; - -import com.abiquo.model.enumerator.NetworkType; -import com.abiquo.model.rest.RESTLink; -import com.abiquo.server.core.infrastructure.network.PrivateIpDto; -import com.abiquo.server.core.infrastructure.network.VLANNetworkDto; -import com.google.inject.TypeLiteral; - -/** - * Adds generic high level functionality to {@link PrivateIpDto}. - * - * @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); - } - - // Domain operations - - @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); - - ParseXMLWithJAXB parser = new ParseXMLWithJAXB(utils.getXml(), - TypeLiteral.get(VLANNetworkDto.class)); - - return wrap(context, PrivateNetwork.class, parser.apply(response)); - } - - @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() + "]"; - } - -} 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 deleted file mode 100644 index 7c2babcfea..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/network/PrivateNetwork.java +++ /dev/null @@ -1,169 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.domain.network; - -import java.util.List; - -import org.jclouds.abiquo.AbiquoApi; -import org.jclouds.abiquo.AbiquoAsyncApi; -import org.jclouds.abiquo.domain.cloud.VirtualDatacenter; -import org.jclouds.abiquo.domain.network.options.IpOptions; -import org.jclouds.rest.RestContext; - -import com.abiquo.model.enumerator.NetworkType; -import com.abiquo.server.core.infrastructure.network.PrivateIpDto; -import com.abiquo.server.core.infrastructure.network.PrivateIpsDto; -import com.abiquo.server.core.infrastructure.network.VLANNetworkDto; - -/** - * Adds high level functionality to private {@link VLANNetworkDto}. - * - * @author Ignasi Barrera - * @author Francesc Montserrat - * @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; - - /** - * Constructor to be used only by the builder. - */ - protected PrivateNetwork(final RestContext context, final VLANNetworkDto target) { - super(context, target); - } - - // 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 -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 -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 - public PrivateIp getIp(final Integer id) { - PrivateIpDto ip = context.getApi().getCloudApi().getPrivateNetworkIp(target, id); - return wrap(context, PrivateIp.class, ip); - } - - // Builder - - public static Builder builder(final RestContext context) { - return new Builder(context); - } - - public static class Builder extends NetworkBuilder { - private VirtualDatacenter virtualDatacenter; - - public Builder(final RestContext context) { - super(context); - this.context = context; - } - - 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(suffixDNS); - dto.setDefaultNetwork(defaultNetwork); - dto.setUnmanaged(false); - dto.setType(NetworkType.INTERNAL); - - PrivateNetwork network = new PrivateNetwork(context, dto); - network.virtualDatacenter = virtualDatacenter; - - 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()).suffixDNS(in.getSuffixDNS()).defaultNetwork(in.getDefaultNetwork()) - .virtualDatacenter(in.virtualDatacenter); - } - } - - @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 deleted file mode 100644 index 26138d3491..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/network/PublicIp.java +++ /dev/null @@ -1,79 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.domain.network; - -import static com.google.common.base.Preconditions.checkNotNull; - -import org.jclouds.abiquo.AbiquoApi; -import org.jclouds.abiquo.AbiquoAsyncApi; -import org.jclouds.abiquo.reference.ValidationErrors; -import org.jclouds.abiquo.reference.rest.ParentLinkName; -import org.jclouds.abiquo.rest.internal.ExtendedUtils; -import org.jclouds.http.HttpResponse; -import org.jclouds.http.functions.ParseXMLWithJAXB; -import org.jclouds.rest.RestContext; - -import com.abiquo.model.enumerator.NetworkType; -import com.abiquo.model.rest.RESTLink; -import com.abiquo.server.core.infrastructure.network.PublicIpDto; -import com.abiquo.server.core.infrastructure.network.VLANNetworkDto; -import com.google.inject.TypeLiteral; - -/** - * Adds generic high level functionality to {@link PublicIpDto}. - * - * @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); - } - - @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); - - ParseXMLWithJAXB parser = new ParseXMLWithJAXB(utils.getXml(), - TypeLiteral.get(VLANNetworkDto.class)); - - return wrap(context, PublicNetwork.class, parser.apply(response)); - } - - @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() + "]"; - } - -} 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 deleted file mode 100644 index b7d5ba1100..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/network/PublicNetwork.java +++ /dev/null @@ -1,199 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.domain.network; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.List; - -import org.jclouds.abiquo.AbiquoApi; -import org.jclouds.abiquo.AbiquoAsyncApi; -import org.jclouds.abiquo.domain.infrastructure.Datacenter; -import org.jclouds.abiquo.domain.network.options.IpOptions; -import org.jclouds.abiquo.reference.ValidationErrors; -import org.jclouds.abiquo.reference.annotations.EnterpriseEdition; -import org.jclouds.abiquo.reference.rest.ParentLinkName; -import org.jclouds.abiquo.rest.internal.ExtendedUtils; -import org.jclouds.http.HttpResponse; -import org.jclouds.http.functions.ParseXMLWithJAXB; -import org.jclouds.rest.RestContext; - -import com.abiquo.model.enumerator.NetworkType; -import com.abiquo.model.rest.RESTLink; -import com.abiquo.server.core.infrastructure.DatacenterDto; -import com.abiquo.server.core.infrastructure.network.PublicIpDto; -import com.abiquo.server.core.infrastructure.network.PublicIpsDto; -import com.abiquo.server.core.infrastructure.network.VLANNetworkDto; -import com.google.common.base.Optional; -import com.google.inject.TypeLiteral; - -/** - * Adds high level functionality to public {@link VLANNetworkDto}. - * - * @author Ignasi Barrera - * @author Francesc Montserrat - * @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; - - /** - * 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 -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+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); - } - - // Parent access - - 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); - - ParseXMLWithJAXB parser = new ParseXMLWithJAXB(utils.getXml(), - TypeLiteral.get(DatacenterDto.class)); - - datacenter = wrap(context, Datacenter.class, parser.apply(response)); - return datacenter; - } - - // Builder - - public static Builder builder(final RestContext context, final Datacenter datacenter) { - return new Builder(context, datacenter); - } - - public static class Builder extends NetworkBuilder { - private Datacenter datacenter; - - private Optional networkServiceType = Optional.absent(); - - public Builder(final RestContext context, final Datacenter datacenter) { - super(context); - this.datacenter = checkNotNull(datacenter, - ValidationErrors.NULL_RESOURCE + Datacenter.class.getCanonicalName()); - this.context = context; - } - - public Builder datacenter(final Datacenter datacenter) { - this.datacenter = checkNotNull(datacenter, - ValidationErrors.NULL_RESOURCE + Datacenter.class.getCanonicalName()); - return this; - } - - public Builder networkServiceType(final NetworkServiceType networkServiceType) { - this.networkServiceType = Optional.of(networkServiceType); - 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(suffixDNS); - dto.setDefaultNetwork(defaultNetwork); - dto.setUnmanaged(false); - dto.setType(NetworkType.PUBLIC); - - NetworkServiceType nst = networkServiceType.or(datacenter.defaultNetworkServiceType()); - dto.addLink(new RESTLink("networkservicetype", nst.unwrap().getEditLink().getHref())); - - PublicNetwork network = new PublicNetwork(context, dto); - network.datacenter = datacenter; - - 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()).suffixDNS(in.getSuffixDNS()).defaultNetwork(in.getDefaultNetwork()); - } - } - - @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 deleted file mode 100644 index 4b8963ab38..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/network/UnmanagedIp.java +++ /dev/null @@ -1,81 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.domain.network; - -import static com.google.common.base.Preconditions.checkNotNull; - -import org.jclouds.abiquo.AbiquoApi; -import org.jclouds.abiquo.AbiquoAsyncApi; -import org.jclouds.abiquo.reference.ValidationErrors; -import org.jclouds.abiquo.reference.rest.ParentLinkName; -import org.jclouds.abiquo.rest.internal.ExtendedUtils; -import org.jclouds.http.HttpResponse; -import org.jclouds.http.functions.ParseXMLWithJAXB; -import org.jclouds.rest.RestContext; - -import com.abiquo.model.enumerator.NetworkType; -import com.abiquo.model.rest.RESTLink; -import com.abiquo.server.core.infrastructure.network.UnmanagedIpDto; -import com.abiquo.server.core.infrastructure.network.VLANNetworkDto; -import com.google.inject.TypeLiteral; - -/** - * Adds generic high level functionality to {@link UnmanagedIpDto}. - * - * @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); - } - - // Domain operations - - @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); - - ParseXMLWithJAXB parser = new ParseXMLWithJAXB(utils.getXml(), - TypeLiteral.get(VLANNetworkDto.class)); - - return wrap(context, UnmanagedNetwork.class, parser.apply(response)); - } - - @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() + "]"; - } - -} 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 deleted file mode 100644 index 42dc116a93..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/network/UnmanagedNetwork.java +++ /dev/null @@ -1,244 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.domain.network; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.List; - -import org.jclouds.abiquo.AbiquoApi; -import org.jclouds.abiquo.AbiquoAsyncApi; -import org.jclouds.abiquo.domain.enterprise.Enterprise; -import org.jclouds.abiquo.domain.infrastructure.Datacenter; -import org.jclouds.abiquo.domain.network.options.IpOptions; -import org.jclouds.abiquo.reference.ValidationErrors; -import org.jclouds.abiquo.reference.annotations.EnterpriseEdition; -import org.jclouds.abiquo.reference.rest.ParentLinkName; -import org.jclouds.abiquo.rest.internal.ExtendedUtils; -import org.jclouds.http.HttpResponse; -import org.jclouds.http.functions.ParseXMLWithJAXB; -import org.jclouds.rest.RestContext; - -import com.abiquo.model.enumerator.NetworkType; -import com.abiquo.model.rest.RESTLink; -import com.abiquo.server.core.enterprise.EnterpriseDto; -import com.abiquo.server.core.infrastructure.DatacenterDto; -import com.abiquo.server.core.infrastructure.network.UnmanagedIpDto; -import com.abiquo.server.core.infrastructure.network.UnmanagedIpsDto; -import com.abiquo.server.core.infrastructure.network.VLANNetworkDto; -import com.google.common.base.Optional; -import com.google.inject.TypeLiteral; - -/** - * Adds high level functionality to external {@link VLANNetworkDto}. - * - * @author Ignasi Barrera - * @author Francesc Montserrat - * @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; - - /** 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); - } - - /** - * @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 -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()); - } - - @Override - public UnmanagedIp getIp(final Integer id) { - UnmanagedIpDto ip = context.getApi().getInfrastructureApi().getUnmanagedIp(target, id); - return wrap(context, UnmanagedIp.class, ip); - } - - // Parent access - - 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); - - ParseXMLWithJAXB parser = new ParseXMLWithJAXB(utils.getXml(), - TypeLiteral.get(EnterpriseDto.class)); - - 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); - - ExtendedUtils utils = (ExtendedUtils) context.getUtils(); - HttpResponse response = utils.getAbiquoHttpClient().get(link); - - ParseXMLWithJAXB parser = new ParseXMLWithJAXB(utils.getXml(), - TypeLiteral.get(DatacenterDto.class)); - - 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.getCanonicalName()); - - RESTLink link = enterprise.unwrap().searchLink("edit"); - - checkNotNull(link, ValidationErrors.MISSING_REQUIRED_LINK); - - target.addLink(new RESTLink("enterprise", link.getHref())); - } - - // Builder - - 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; - - private Enterprise enterprise; - - private Optional networkServiceType = Optional.absent(); - - public Builder(final RestContext context, final Datacenter datacenter, - final Enterprise enterprise) { - super(context); - this.datacenter = checkNotNull(datacenter, - ValidationErrors.NULL_RESOURCE + Datacenter.class.getCanonicalName()); - this.enterprise = checkNotNull(enterprise, - ValidationErrors.NULL_RESOURCE + Enterprise.class.getCanonicalName()); - this.context = context; - } - - public Builder datacenter(final Datacenter datacenter) { - this.datacenter = checkNotNull(datacenter, - ValidationErrors.NULL_RESOURCE + Datacenter.class.getCanonicalName()); - return this; - } - - public Builder enterprise(final Enterprise enterprise) { - this.enterprise = checkNotNull(enterprise, - ValidationErrors.NULL_RESOURCE + Enterprise.class.getCanonicalName()); - return this; - } - - public Builder networkServiceType(final NetworkServiceType networkServiceType) { - this.networkServiceType = Optional.of(networkServiceType); - 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(suffixDNS); - dto.setDefaultNetwork(defaultNetwork); - dto.setUnmanaged(true); - dto.setType(NetworkType.UNMANAGED); - - NetworkServiceType nst = networkServiceType.or(datacenter.defaultNetworkServiceType()); - dto.getLinks().add(new RESTLink("networkservicetype", nst.unwrap().getEditLink().getHref())); - - UnmanagedNetwork network = new UnmanagedNetwork(context, dto); - network.datacenter = datacenter; - network.enterprise = enterprise; - - 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()).suffixDNS(in.getSuffixDNS()).defaultNetwork(in.getDefaultNetwork()); - } - } - - @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 deleted file mode 100644 index dfcbdc5bac..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/network/options/IpOptions.java +++ /dev/null @@ -1,60 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.domain.network.options; - -import org.jclouds.abiquo.domain.options.search.FilterOptions.BaseFilterOptionsBuilder; -import org.jclouds.http.options.BaseHttpRequestOptions; - -/** - * Available options to query ips. - * - * @author Francesc Montserrat - */ -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; - } - - public static class Builder extends BaseFilterOptionsBuilder { - private Boolean free; - - public Builder free(final boolean free) { - this.free = free; - return this; - } - - public IpOptions build() { - IpOptions options = new IpOptions(); - - if (free != null) { - options.queryParameters.put("free", String.valueOf(free)); - } - - 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 deleted file mode 100644 index 304d6b9356..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/network/options/NetworkOptions.java +++ /dev/null @@ -1,72 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.domain.network.options; - -import org.jclouds.http.options.BaseHttpRequestOptions; - -import com.abiquo.model.enumerator.NetworkType; - -/** - * Available options to query networks. - * - * @author Francesc Montserrat - */ -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; - } - - public static class Builder { - private NetworkType type; - - private Boolean all; - - public Builder type(final NetworkType type) { - this.type = type; - return this; - } - - public Builder all(final boolean all) { - this.all = all; - return this; - } - - public NetworkOptions build() { - NetworkOptions options = new NetworkOptions(); - - if (type != null) { - options.queryParameters.put("type", String.valueOf(type)); - } - - if (all != null) { - options.queryParameters.put("all", String.valueOf(all)); - } - - 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 deleted file mode 100644 index 8364f65885..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/options/search/FilterOptions.java +++ /dev/null @@ -1,124 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.domain.options.search; - -import org.jclouds.abiquo.domain.options.search.reference.OrderBy; -import org.jclouds.http.options.BaseHttpRequestOptions; - -import com.google.common.collect.Multimap; - -/** - * Available options to filter and pagination methods. - * - * @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 static FilterOptionsBuilder builder() { - return new FilterOptionsBuilder(); - } - - 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; - - protected Integer limit; - - protected OrderBy by; - - protected String has; - - protected Boolean asc; - - 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 limit(final int limit) { - this.limit = limit; - 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 descendant(final boolean desc) { - this.asc = !desc; - return (T) this; - } - - public T disablePagination() { - this.limit = 0; - return (T) this; - } - - protected O addFilterOptions(final O options) { - Multimap queryParameters = options.buildQueryParameters(); - - if (startWith != null) { - queryParameters.put("startwith", startWith.toString()); - } - - if (limit != null) { - queryParameters.put("limit", limit.toString()); - } - - if (has != null) { - queryParameters.put("has", has); - } - - if (by != null) { - queryParameters.put("by", by.getValue()); - } - - if (asc != null) { - queryParameters.put("asc", asc.toString()); - } - - 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 deleted file mode 100644 index 65db94df61..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/options/search/reference/OrderBy.java +++ /dev/null @@ -1,41 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.domain.options.search.reference; - -/** - * Available fields to order search results. - * - * @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 String value; - - public String getValue() { - return 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 deleted file mode 100644 index f1283b801e..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/task/AsyncJob.java +++ /dev/null @@ -1,76 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.domain.task; - -import org.jclouds.abiquo.AbiquoAsyncApi; -import org.jclouds.abiquo.AbiquoApi; -import org.jclouds.abiquo.domain.DomainWrapper; -import org.jclouds.rest.RestContext; - -import com.abiquo.server.core.task.Job.JobState; -import com.abiquo.server.core.task.Job.JobType; -import com.abiquo.server.core.task.JobDto; - -/** - * Adds generic high level functionality to {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); - } - - // Delegate methods - - public String getDescription() { - return target.getDescription(); - } - - public String getId() { - return target.getId(); - } - - public JobState getRollbackState() { - return target.getRollbackState(); - } - - public JobState getState() { - return target.getState(); - } - - public long getTimestamp() { - return target.getTimestamp(); - } - - public JobType getType() { - return target.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 deleted file mode 100644 index 4a3ac50576..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/task/AsyncTask.java +++ /dev/null @@ -1,102 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.domain.task; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.List; - -import org.jclouds.abiquo.AbiquoApi; -import org.jclouds.abiquo.AbiquoAsyncApi; -import org.jclouds.abiquo.domain.DomainWrapper; -import org.jclouds.abiquo.reference.ValidationErrors; -import org.jclouds.rest.RestContext; - -import com.abiquo.model.rest.RESTLink; -import com.abiquo.server.core.task.TaskDto; -import com.abiquo.server.core.task.enums.TaskState; -import com.abiquo.server.core.task.enums.TaskType; - -/** - * Adds generic high level functionality to {TaskDto}. - * - * @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); - } - - // Domain operations - - /** - * Refresh the state of the task. - */ - @Override - public void refresh() { - RESTLink self = checkNotNull(target.searchLink("self"), ValidationErrors.MISSING_REQUIRED_LINK + "self"); - - target = context.getApi().getTaskApi().getTask(self); - } - - // Children access - - /** - * Get the individual jobs that compose the current task. - */ - public List getJobs() { - return wrap(context, AsyncJob.class, target.getJobs().getCollection()); - } - - // Delegate methods - - public String getOwnerId() { - return target.getOwnerId(); - } - - public TaskState getState() { - return target.getState(); - } - - public String getTaskId() { - return target.getTaskId(); - } - - public long getTimestamp() { - return target.getTimestamp(); - } - - public TaskType getType() { - return target.getType(); - } - - public String getUserId() { - return target.getUserId(); - } - - @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 deleted file mode 100644 index 563dc76486..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/util/LinkUtils.java +++ /dev/null @@ -1,60 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.domain.util; - -import static com.google.common.collect.Iterables.filter; - -import java.util.List; - -import org.jclouds.abiquo.predicates.LinkPredicates; - -import com.abiquo.model.rest.RESTLink; -import com.abiquo.model.transport.SingleResourceTransportDto; -import com.google.common.collect.ImmutableList; - -/** - * Utility method to work with {@link RESTLink} objects. - * - * @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; - } - - /** - * 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 list with all links that point to a NIC. - */ - public static List filterNicLinks(final List links) { - return ImmutableList.copyOf(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 deleted file mode 100644 index d5a022f6a7..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/events/handlers/AbstractEventHandler.java +++ /dev/null @@ -1,57 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.events.handlers; - -import javax.annotation.Resource; - -import org.jclouds.abiquo.events.monitor.MonitorEvent; -import org.jclouds.logging.Logger; - -/** - * Base class for all {@link MonitorEvent} handlers. - * - * @author Ignasi Barrera - */ -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); - - // Public getters and setters to allow non-guice code to set the appropriate - // logger - - public Logger getLogger() { - return 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 deleted file mode 100644 index 45c14994ea..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/events/handlers/BlockingEventHandler.java +++ /dev/null @@ -1,149 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.events.handlers; - -import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.List; -import java.util.concurrent.CountDownLatch; - -import org.jclouds.abiquo.events.monitor.MonitorEvent; -import org.jclouds.logging.Logger; - -import com.google.common.annotations.VisibleForTesting; -import com.google.common.base.Throwables; -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. - *

- * Due to Guava - * Issue 786 {@link #handle(MonitorEvent)} is marked finalto - * avoid having duplicate events. - * - * @author Ignasi Barrera - * @param - * The monitored object. - */ -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; - - 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); - } - - @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); - - 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."); - } - } - - /** - * 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()); - } - } - - /** - * 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 deleted file mode 100644 index cac8e36d45..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/events/monitor/CompletedEvent.java +++ /dev/null @@ -1,32 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.events.monitor; - -/** - * Event dispatched when a monitoring job completes without error. - * - * @author Ignasi Barrera - */ -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 deleted file mode 100644 index 7d185c2260..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/events/monitor/FailedEvent.java +++ /dev/null @@ -1,32 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.events.monitor; - -/** - * Event dispatched when a monitoring job completes with errors. - * - * @author Ignasi Barrera - */ -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 deleted file mode 100644 index 7a263dd247..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/events/monitor/MonitorEvent.java +++ /dev/null @@ -1,70 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.events.monitor; - -import static com.google.common.base.Preconditions.checkNotNull; - -/** - * base class for all monitor events. - * - * @author Ignasi Barrera - */ -public class MonitorEvent { - /** - * The type of the event. - */ - public static enum Type { - COMPLETED, FAILED, TIMEOUT; - } - - /** The type of the event. */ - private Type type; - - /** 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 Type getType() { - return type; - } - - public void setType(final Type type) { - this.type = type; - } - - public T getTarget() { - return target; - } - - public void setTarget(final T target) { - this.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 deleted file mode 100644 index b98c38f5cd..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/events/monitor/TimeoutEvent.java +++ /dev/null @@ -1,32 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.events.monitor; - -/** - * Event dispatched when a monitoring job times out. - * - * @author Ignasi Barrera - */ -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/fallbacks/MovedVolume.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/fallbacks/MovedVolume.java deleted file mode 100644 index f2b32b8a6e..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/fallbacks/MovedVolume.java +++ /dev/null @@ -1,101 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.fallbacks; - -import static com.google.common.base.Throwables.getCausalChain; -import static com.google.common.base.Throwables.propagate; -import static com.google.common.collect.Iterables.find; -import static com.google.common.util.concurrent.Futures.immediateFuture; - -import javax.inject.Inject; -import javax.inject.Singleton; -import javax.ws.rs.core.Response.Status; - -import org.jclouds.Fallback; -import org.jclouds.http.HttpResponse; -import org.jclouds.http.HttpResponseException; -import org.jclouds.http.functions.ParseXMLWithJAXB; -import org.jclouds.xml.XMLParser; - -import com.abiquo.server.core.infrastructure.storage.MovedVolumeDto; -import com.abiquo.server.core.infrastructure.storage.VolumeManagementDto; -import com.google.common.annotations.VisibleForTesting; -import com.google.common.base.Predicate; -import com.google.common.util.concurrent.ListenableFuture; -import com.google.inject.TypeLiteral; - -/** - * Return false on service error exceptions. - * - * @author Ignasi Barrera - */ -@Singleton -public class MovedVolume implements Fallback { - - @Singleton - @VisibleForTesting - static class ReturnMoveVolumeReference extends ParseXMLWithJAXB { - @Inject - public ReturnMoveVolumeReference(final XMLParser xml, final TypeLiteral type) { - super(xml, type); - } - - } - - private ParseXMLWithJAXB parser; - - @Inject - public MovedVolume(final ReturnMoveVolumeReference parser) { - this.parser = parser; - } - - @Override - public ListenableFuture create(Throwable from) throws Exception { - return immediateFuture(createOrPropagate(from)); - } - - @Override - public VolumeManagementDto createOrPropagate(Throwable from) throws Exception { - Throwable exception = find(getCausalChain(from), isMovedException(from), null); - - if (exception != null) { - HttpResponseException responseException = (HttpResponseException) exception; - HttpResponse response = responseException.getResponse(); - - return parser.apply(response).getVolume(); - } - - throw propagate(from); - } - - 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/features/AdminApi.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/features/AdminApi.java deleted file mode 100644 index f2f58991ba..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/features/AdminApi.java +++ /dev/null @@ -1,115 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.features; - -import com.abiquo.server.core.enterprise.EnterpriseDto; -import com.abiquo.server.core.enterprise.PrivilegesDto; -import com.abiquo.server.core.enterprise.RoleDto; -import com.abiquo.server.core.enterprise.RolesDto; -import com.abiquo.server.core.enterprise.UserDto; - -/** - * Provides synchronous access to Abiquo Admin API. - * - * @see API: - * http://community.abiquo.com/display/ABI20/API+Reference - * @see AdminAsyncApi - * @author Ignasi Barrera - * @author Francesc Montserrat - */ -public interface AdminApi { - /* ********************** User ********************** */ - - /** - * Get the information of the current user. - * - * @return The information of the current user. - */ - UserDto getCurrentUser(); - - /* ********************** Role ********************** */ - - /** - * 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); - - /** - * 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); - - /** - * 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); - - /** - * 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); -} 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 deleted file mode 100644 index 9d18d48889..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/features/AdminAsyncApi.java +++ /dev/null @@ -1,159 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.features; - -import javax.inject.Named; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; - -import org.jclouds.Fallbacks.NullOnNotFoundOr404; -import org.jclouds.abiquo.binders.BindToPath; -import org.jclouds.abiquo.binders.BindToXMLPayloadAndPath; -import org.jclouds.abiquo.domain.enterprise.Enterprise; -import org.jclouds.abiquo.functions.enterprise.ParseEnterpriseId; -import org.jclouds.abiquo.http.filters.AbiquoAuthentication; -import org.jclouds.abiquo.http.filters.AppendApiVersionToMediaType; -import org.jclouds.abiquo.rest.annotations.EndpointLink; -import org.jclouds.rest.annotations.BinderParam; -import org.jclouds.rest.annotations.Fallback; -import org.jclouds.rest.annotations.JAXBResponseParser; -import org.jclouds.rest.annotations.ParamParser; -import org.jclouds.rest.annotations.RequestFilters; -import org.jclouds.rest.binders.BindToXMLPayload; - -import com.abiquo.server.core.enterprise.EnterpriseDto; -import com.abiquo.server.core.enterprise.PrivilegesDto; -import com.abiquo.server.core.enterprise.RoleDto; -import com.abiquo.server.core.enterprise.RolesDto; -import com.abiquo.server.core.enterprise.UserDto; -import com.google.common.util.concurrent.ListenableFuture; - -/** - * Provides asynchronous access to Abiquo Admin API. - * - * @see API: - * http://community.abiquo.com/display/ABI20/API+Reference - * @see AdminApi - * @author Ignasi Barrera - * @author Francesc Montserrat - */ -@RequestFilters({ AbiquoAuthentication.class, AppendApiVersionToMediaType.class }) -public interface AdminAsyncApi { - /*********************** Login ***********************/ - - /** - * @see AdminApi#getCurrentUser() - */ - @Named("user:get") - @GET - @Path("/login") - @Consumes(UserDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture getCurrentUser(); - - /*********************** Role ***********************/ - - /** - * @see AdminApi#listRoles() - */ - @Named("role:list") - @GET - @Path("/admin/roles") - @Consumes(RolesDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listRoles(); - - /** - * @see AdminApi#listRoles(Enterprise enterprise) - */ - @Named("role:list") - @GET - @Path("/admin/roles") - @Consumes(RolesDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listRoles( - @QueryParam("identerprise") @ParamParser(ParseEnterpriseId.class) final EnterpriseDto enterprise); - - /** - * @see AdminApi#getRole(UserDto) - */ - @Named("role:get") - @GET - @Consumes(RoleDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - @Fallback(NullOnNotFoundOr404.class) - ListenableFuture getRole(@EndpointLink("role") @BinderParam(BindToPath.class) UserDto user); - - /** - * @see AdminApi#getRole(Integer) - */ - @Named("role:get") - @GET - @Path("/admin/roles/{role}") - @Consumes(RoleDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - @Fallback(NullOnNotFoundOr404.class) - ListenableFuture getRole(@PathParam("role") Integer roleId); - - /** - * @see AdminApi#deleteRole(RoleDto) - */ - @Named("role:delete") - @DELETE - ListenableFuture deleteRole(@EndpointLink("edit") @BinderParam(BindToPath.class) RoleDto role); - - /** - * @see AdminApi#updateRole(RoleDto) - */ - @Named("role:update") - @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) - */ - @Named("role:create") - @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) - */ - @Named("privilege:list") - @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 deleted file mode 100644 index cd23b41a66..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/features/CloudApi.java +++ /dev/null @@ -1,775 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.features; - -import org.jclouds.abiquo.domain.cloud.options.VirtualApplianceOptions; -import org.jclouds.abiquo.domain.cloud.options.VirtualDatacenterOptions; -import org.jclouds.abiquo.domain.cloud.options.VirtualMachineOptions; -import org.jclouds.abiquo.domain.cloud.options.VirtualMachineTemplateOptions; -import org.jclouds.abiquo.domain.cloud.options.VolumeOptions; -import org.jclouds.abiquo.domain.network.options.IpOptions; -import org.jclouds.abiquo.reference.annotations.EnterpriseEdition; - -import com.abiquo.model.transport.AcceptedRequestDto; -import com.abiquo.server.core.appslibrary.VirtualMachineTemplateDto; -import com.abiquo.server.core.appslibrary.VirtualMachineTemplatesDto; -import com.abiquo.server.core.cloud.VirtualApplianceDto; -import com.abiquo.server.core.cloud.VirtualApplianceStateDto; -import com.abiquo.server.core.cloud.VirtualAppliancesDto; -import com.abiquo.server.core.cloud.VirtualDatacenterDto; -import com.abiquo.server.core.cloud.VirtualDatacentersDto; -import com.abiquo.server.core.cloud.VirtualMachineDto; -import com.abiquo.server.core.cloud.VirtualMachineStateDto; -import com.abiquo.server.core.cloud.VirtualMachineTaskDto; -import com.abiquo.server.core.cloud.VirtualMachineWithNodeExtendedDto; -import com.abiquo.server.core.cloud.VirtualMachinesWithNodeExtendedDto; -import com.abiquo.server.core.enterprise.EnterpriseDto; -import com.abiquo.server.core.infrastructure.DatacenterDto; -import com.abiquo.server.core.infrastructure.network.PrivateIpDto; -import com.abiquo.server.core.infrastructure.network.PrivateIpsDto; -import com.abiquo.server.core.infrastructure.network.PublicIpDto; -import com.abiquo.server.core.infrastructure.network.PublicIpsDto; -import com.abiquo.server.core.infrastructure.network.VLANNetworkDto; -import com.abiquo.server.core.infrastructure.network.VLANNetworksDto; -import com.abiquo.server.core.infrastructure.network.VMNetworkConfigurationsDto; -import com.abiquo.server.core.infrastructure.storage.DiskManagementDto; -import com.abiquo.server.core.infrastructure.storage.DisksManagementDto; -import com.abiquo.server.core.infrastructure.storage.TierDto; -import com.abiquo.server.core.infrastructure.storage.TiersDto; -import com.abiquo.server.core.infrastructure.storage.VolumeManagementDto; -import com.abiquo.server.core.infrastructure.storage.VolumesManagementDto; - -/** - * Provides synchronous access to Abiquo Cloud API. - * - * @see API: - * http://community.abiquo.com/display/ABI20/API+Reference - * @see CloudAsyncApi - * @author Ignasi Barrera - * @author Francesc Montserrat - */ -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. - */ - 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. - */ - 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. - */ - AcceptedRequestDto deployVirtualMachine(VirtualMachineDto virtualMachine, VirtualMachineTaskDto options); - - /** - * Undeploy a virtual machine with task options. - * - * @param virtualMachine - * The virtual machine to undeploy. - * @param options - * extra undeploy options. - * @return Response message to the undeploy request. - */ - 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. - */ - 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 - 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 - AcceptedRequestDto updateVolume(VolumeManagementDto volume); - - /** - * Delete the given volume. - * - * @param volume - * The volume to delete. - */ - @EnterpriseEdition - 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 deleted file mode 100644 index 4501f98175..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/features/CloudAsyncApi.java +++ /dev/null @@ -1,849 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.features; - -import javax.inject.Named; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.MediaType; - -import org.jclouds.Fallbacks.NullOnNotFoundOr404; -import org.jclouds.abiquo.binders.AppendToPath; -import org.jclouds.abiquo.binders.BindToPath; -import org.jclouds.abiquo.binders.BindToXMLPayloadAndPath; -import org.jclouds.abiquo.binders.cloud.BindHardDiskRefsToPayload; -import org.jclouds.abiquo.binders.cloud.BindMoveVolumeToPath; -import org.jclouds.abiquo.binders.cloud.BindNetworkConfigurationRefToPayload; -import org.jclouds.abiquo.binders.cloud.BindNetworkRefToPayload; -import org.jclouds.abiquo.binders.cloud.BindVirtualDatacenterRefToPayload; -import org.jclouds.abiquo.binders.cloud.BindVolumeRefsToPayload; -import org.jclouds.abiquo.domain.cloud.VirtualDatacenter; -import org.jclouds.abiquo.domain.cloud.options.VirtualApplianceOptions; -import org.jclouds.abiquo.domain.cloud.options.VirtualDatacenterOptions; -import org.jclouds.abiquo.domain.cloud.options.VirtualMachineOptions; -import org.jclouds.abiquo.domain.cloud.options.VirtualMachineTemplateOptions; -import org.jclouds.abiquo.domain.cloud.options.VolumeOptions; -import org.jclouds.abiquo.domain.enterprise.Enterprise; -import org.jclouds.abiquo.domain.infrastructure.Datacenter; -import org.jclouds.abiquo.domain.network.options.IpOptions; -import org.jclouds.abiquo.fallbacks.MovedVolume; -import org.jclouds.abiquo.functions.ReturnTaskReferenceOrNull; -import org.jclouds.abiquo.functions.enterprise.ParseEnterpriseId; -import org.jclouds.abiquo.functions.infrastructure.ParseDatacenterId; -import org.jclouds.abiquo.http.filters.AbiquoAuthentication; -import org.jclouds.abiquo.http.filters.AppendApiVersionToMediaType; -import org.jclouds.abiquo.reference.annotations.EnterpriseEdition; -import org.jclouds.abiquo.rest.annotations.EndpointLink; -import org.jclouds.http.functions.ReturnStringIf2xx; -import org.jclouds.rest.annotations.BinderParam; -import org.jclouds.rest.annotations.Fallback; -import org.jclouds.rest.annotations.JAXBResponseParser; -import org.jclouds.rest.annotations.ParamParser; -import org.jclouds.rest.annotations.RequestFilters; -import org.jclouds.rest.annotations.ResponseParser; -import org.jclouds.rest.binders.BindToXMLPayload; - -import com.abiquo.model.transport.AcceptedRequestDto; -import com.abiquo.model.transport.LinksDto; -import com.abiquo.server.core.appslibrary.VirtualMachineTemplateDto; -import com.abiquo.server.core.appslibrary.VirtualMachineTemplatesDto; -import com.abiquo.server.core.cloud.VirtualApplianceDto; -import com.abiquo.server.core.cloud.VirtualApplianceStateDto; -import com.abiquo.server.core.cloud.VirtualAppliancesDto; -import com.abiquo.server.core.cloud.VirtualDatacenterDto; -import com.abiquo.server.core.cloud.VirtualDatacentersDto; -import com.abiquo.server.core.cloud.VirtualMachineDto; -import com.abiquo.server.core.cloud.VirtualMachineStateDto; -import com.abiquo.server.core.cloud.VirtualMachineTaskDto; -import com.abiquo.server.core.cloud.VirtualMachineWithNodeExtendedDto; -import com.abiquo.server.core.cloud.VirtualMachinesWithNodeExtendedDto; -import com.abiquo.server.core.enterprise.EnterpriseDto; -import com.abiquo.server.core.infrastructure.DatacenterDto; -import com.abiquo.server.core.infrastructure.network.PrivateIpDto; -import com.abiquo.server.core.infrastructure.network.PrivateIpsDto; -import com.abiquo.server.core.infrastructure.network.PublicIpDto; -import com.abiquo.server.core.infrastructure.network.PublicIpsDto; -import com.abiquo.server.core.infrastructure.network.VLANNetworkDto; -import com.abiquo.server.core.infrastructure.network.VLANNetworksDto; -import com.abiquo.server.core.infrastructure.network.VMNetworkConfigurationDto; -import com.abiquo.server.core.infrastructure.network.VMNetworkConfigurationsDto; -import com.abiquo.server.core.infrastructure.storage.DiskManagementDto; -import com.abiquo.server.core.infrastructure.storage.DisksManagementDto; -import com.abiquo.server.core.infrastructure.storage.MovedVolumeDto; -import com.abiquo.server.core.infrastructure.storage.TierDto; -import com.abiquo.server.core.infrastructure.storage.TiersDto; -import com.abiquo.server.core.infrastructure.storage.VolumeManagementDto; -import com.abiquo.server.core.infrastructure.storage.VolumesManagementDto; -import com.google.common.util.concurrent.ListenableFuture; - -/** - * Provides asynchronous access to Abiquo Cloud API. - * - * @see API: - * http://community.abiquo.com/display/ABI20/API+Reference - * @see CloudApi - * @author Ignasi Barrera - * @author Francesc Montserrat - */ -@RequestFilters({ AbiquoAuthentication.class, AppendApiVersionToMediaType.class }) -@Path("/cloud") -public interface CloudAsyncApi { - /*********************** Virtual Datacenter ***********************/ - - /** - * @see CloudApi#listVirtualDatacenters(VirtualDatacenterOptions) - */ - @Named("vdc:list") - @GET - @Path("/virtualdatacenters") - @Consumes(VirtualDatacentersDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listVirtualDatacenters(VirtualDatacenterOptions options); - - /** - * @see CloudApi#getVirtualDatacenter(Integer) - */ - @Named("vdc:get") - @GET - @Path("/virtualdatacenters/{virtualdatacenter}") - @Fallback(NullOnNotFoundOr404.class) - @Consumes(VirtualDatacenterDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture getVirtualDatacenter( - @PathParam("virtualdatacenter") Integer virtualDatacenterId); - - /** - * @see CloudApi#createVirtualDatacenter(VirtualDatacenterDto, Datacenter, - * Enterprise) - */ - @Named("vdc:create") - @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) - */ - @Named("vdc:update") - @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) - */ - @Named("vdc:delete") - @DELETE - ListenableFuture deleteVirtualDatacenter( - @EndpointLink("edit") @BinderParam(BindToPath.class) VirtualDatacenterDto virtualDatacenter); - - /** - * @see CloudApi#listAvailableTemplates(VirtualDatacenterDto) - */ - @Named("vdc:listtemplates") - @GET - @Consumes(VirtualMachineTemplatesDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listAvailableTemplates( - @EndpointLink("templates") @BinderParam(BindToPath.class) VirtualDatacenterDto virtualDatacenter); - - /** - * @see CloudApi#listAvailableTemplates(VirtualDatacenterDto, - * VirtualMachineTemplateOptions) - */ - @Named("vdc:listtemplates") - @GET - @Consumes(VirtualMachineTemplatesDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listAvailableTemplates( - @EndpointLink("templates") @BinderParam(BindToPath.class) VirtualDatacenterDto virtualDatacenter, - VirtualMachineTemplateOptions options); - - /** - * @see CloudApi#listStorageTiers(VirtualDatacenterDto) - */ - @Named("vdc:listtiers") - @EnterpriseEdition - @GET - @Consumes(TiersDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listStorageTiers( - @EndpointLink("tiers") @BinderParam(BindToPath.class) VirtualDatacenterDto virtualDatacenter); - - /** - * @see CloudApi#getStorageTier(VirtualDatacenterDto, Integer) - */ - @Named("vdc:gettier") - @EnterpriseEdition - @GET - @Fallback(NullOnNotFoundOr404.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) - */ - @Named("vdc:listavailablepublicips") - @GET - @Consumes(PublicIpsDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listAvailablePublicIps( - @EndpointLink("topurchase") @BinderParam(BindToPath.class) VirtualDatacenterDto virtualDatacenter, - IpOptions options); - - /** - * @see CloudApi#listPurchasedPublicIps(VirtualDatacenterDto, IpOptions) - */ - @Named("vdc:listpurchasedpublicips") - @GET - @Consumes(PublicIpsDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listPurchasedPublicIps( - @EndpointLink("purchased") @BinderParam(BindToPath.class) VirtualDatacenterDto virtualDatacenter, - IpOptions options); - - /** - * @see CloudApi#purchasePublicIp(PublicIpDto) - */ - @Named("vdc:purchasepublicip") - @PUT - @Consumes(PublicIpDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture purchasePublicIp( - @EndpointLink("purchase") @BinderParam(BindToPath.class) PublicIpDto publicIp); - - /** - * @see CloudApi#releasePublicIp(PublicIpDto) - */ - @Named("vdc:releasepublicip") - @PUT - @Consumes(PublicIpDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture releasePublicIp( - @EndpointLink("release") @BinderParam(BindToPath.class) PublicIpDto publicIp); - - /*********************** Private Network ***********************/ - - /** - * @see CloudApi#listPrivateNetworks(VirtualDatacenter) - */ - @Named("privatenetwork:list") - @GET - @Consumes(VLANNetworksDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listPrivateNetworks( - @EndpointLink("privatenetworks") @BinderParam(BindToPath.class) VirtualDatacenterDto virtualDatacenter); - - /** - * @see CloudApi#getPrivateNetwork(VirtualDatacenterDto, Integer) - */ - @Named("privatenetwork:get") - @GET - @Fallback(NullOnNotFoundOr404.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) - */ - @Named("privatenetwork:create") - @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) - */ - @Named("privatenetwork:update") - @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) - */ - @Named("privatenetwork:delete") - @DELETE - ListenableFuture deletePrivateNetwork( - @EndpointLink("edit") @BinderParam(BindToPath.class) VLANNetworkDto privateNetwork); - - /** - * @see CloudApi#getDefaultNetwork(VirtualDatacenterDto) - */ - @Named("vdc:getdefaultnetwork") - @GET - @Consumes(VLANNetworkDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture getDefaultNetwork( - @EndpointLink("defaultnetwork") @BinderParam(BindToPath.class) VirtualDatacenterDto virtualDatacenter); - - /** - * @see CloudApi#setDefaultNetwork(VirtualDatacenterDto, VLANNetworkDto) - */ - @Named("vdc:setdefaultnetwork") - @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) - */ - @Named("privatenetwork:listips") - @GET - @Consumes(PrivateIpsDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listPrivateNetworkIps( - @EndpointLink("ips") @BinderParam(BindToPath.class) VLANNetworkDto network); - - /** - * @see CloudApi#listPrivateNetworkIps(VLANNetworkDto, IpOptions) - */ - @Named("privatenetwork:listips") - @GET - @Consumes(PrivateIpsDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listPrivateNetworkIps( - @EndpointLink("ips") @BinderParam(BindToPath.class) VLANNetworkDto network, IpOptions options); - - /** - * @see CloudApi#getPrivateNetworkIp(VLANNetworkDto, Integer) - */ - @Named("privatenetwork:getip") - @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) - */ - @Named("vapp:list") - @GET - @Consumes(VirtualAppliancesDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listVirtualAppliances( - @EndpointLink("virtualappliances") @BinderParam(BindToPath.class) VirtualDatacenterDto virtualDatacenter); - - /** - * @see CloudApi#getVirtualAppliance(VirtualDatacenterDto, Integer) - */ - @Named("vapp:get") - @GET - @Fallback(NullOnNotFoundOr404.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) - */ - @Named("vapp:getstate") - @GET - @Consumes(VirtualApplianceStateDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture getVirtualApplianceState( - @EndpointLink("state") @BinderParam(BindToPath.class) VirtualApplianceDto virtualAppliance); - - /** - * @see CloudApi#createVirtualAppliance(VirtualDatacenterDto, - * VirtualApplianceDto) - */ - @Named("vapp:create") - @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) - */ - @Named("vapp:update") - @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) - */ - @Named("vapp:delete") - @DELETE - ListenableFuture deleteVirtualAppliance( - @EndpointLink("edit") @BinderParam(BindToPath.class) VirtualApplianceDto virtualAppliance); - - /** - * @see CloudApi#deleteVirtualAppliance(VirtualApplianceDto, - * VirtualApplianceOptions) - */ - @Named("vapp:delete") - @DELETE - ListenableFuture deleteVirtualAppliance( - @EndpointLink("edit") @BinderParam(BindToPath.class) VirtualApplianceDto virtualAppliance, - VirtualApplianceOptions options); - - /** - * @see CloudApi#deployVirtualAppliance(VirtualApplianceDto, - * VirtualMachineTaskDto) - */ - @Named("vapp:deploy") - @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) - */ - @Named("vapp:undeploy") - @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) - */ - @Named("vapp:gerprice") - @GET - @Consumes(MediaType.TEXT_PLAIN) - @ResponseParser(ReturnStringIf2xx.class) - ListenableFuture getVirtualAppliancePrice( - @EndpointLink("price") @BinderParam(BindToPath.class) VirtualApplianceDto virtualAppliance); - - /*********************** Virtual Machine ***********************/ - - /** - * @see CloudApi#listVirtualMachines(VirtualApplianceDto) - */ - @Named("vm:list") - @GET - @Consumes(VirtualMachinesWithNodeExtendedDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listVirtualMachines( - @EndpointLink("virtualmachines") @BinderParam(BindToPath.class) VirtualApplianceDto virtualAppliance); - - /** - * @see CloudApi#listVirtualMachines(VirtualApplianceDto, - * VirtualMachineOptions) - */ - @Named("vm:list") - @GET - @Consumes(VirtualMachinesWithNodeExtendedDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listVirtualMachines( - @EndpointLink("virtualmachines") @BinderParam(BindToPath.class) VirtualApplianceDto virtualAppliance, - VirtualMachineOptions options); - - /** - * @see CloudApi#getVirtualMachine(VirtualApplianceDto, Integer) - */ - @Named("vm:get") - @GET - @Fallback(NullOnNotFoundOr404.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) - */ - @Named("vm:create") - @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) - */ - @Named("vm:delete") - @DELETE - ListenableFuture deleteVirtualMachine( - @EndpointLink("edit") @BinderParam(BindToPath.class) VirtualMachineDto virtualMachine); - - /** - * @see CloudApi#updateVirtualMachine(VirtualMachineWithNodeExtendedDto) - */ - @Named("vm:update") - @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) - */ - @Named("vm:update") - @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) - */ - @Named("vm:changestate") - @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) - */ - @Named("vm:getstate") - @GET - @Consumes(VirtualMachineStateDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture getVirtualMachineState( - @EndpointLink("state") @BinderParam(BindToPath.class) VirtualMachineDto virtualMachine); - - /** - * @see CloudApi#listNetworkConfigurations(VirtualMachineDto) - */ - @Named("vm:listnetworkconfigurations") - @GET - @Consumes(VMNetworkConfigurationsDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listNetworkConfigurations( - @EndpointLink("configurations") @BinderParam(BindToPath.class) VirtualMachineDto virtualMachine); - - /** - * @see CloudApi#setGatewayNetwork(VirtualMachineDto, - * VMNetworkConfigurationDto) - */ - @Named("vm:setgateway") - @PUT - @Produces(LinksDto.BASE_MEDIA_TYPE) - ListenableFuture setGatewayNetwork( - @EndpointLink("configurations") @BinderParam(BindToPath.class) VirtualMachineDto virtualMachine, - @BinderParam(BindNetworkConfigurationRefToPayload.class) VLANNetworkDto network); - - /** - * @see CloudApi#rebootVirtualMachine(VirtualMachineDto) - */ - @Named("vm:reboot") - @POST - @Consumes(AcceptedRequestDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture> rebootVirtualMachine( - @EndpointLink("reset") @BinderParam(BindToPath.class) VirtualMachineDto virtualMachine); - - /*********************** Virtual Machine Template ***********************/ - - /** - * @see CloudApi#getVirtualMachineTemplate(VirtualMachineTemplateDto) - */ - @Named("vm:gettemplate") - @GET - @Consumes(VirtualMachineTemplateDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture getVirtualMachineTemplate( - @EndpointLink("virtualmachinetemplate") @BinderParam(BindToPath.class) VirtualMachineDto virtualMachine); - - /** - * @see CloudApi#listAttachedVolumes(VirtualMachineDto) - */ - @Named("vm:listvolumes") - @GET - @Consumes(VolumesManagementDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listAttachedVolumes( - @EndpointLink("volumes") @BinderParam(BindToPath.class) VirtualMachineDto virtualMachine); - - /** - * @see CloudApi#detachAllVolumes(VirtualMachineDto) - */ - @Named("vm:detachvolumes") - @DELETE - @ResponseParser(ReturnTaskReferenceOrNull.class) - @Consumes(AcceptedRequestDto.BASE_MEDIA_TYPE) - ListenableFuture> detachAllVolumes( - @EndpointLink("volumes") @BinderParam(BindToPath.class) VirtualMachineDto virtualMachine); - - /** - * @see CloudApi#replaceVolumes(VirtualMachineDto, VirtualMachineOptions, - * VolumeManagementDto...) - */ - @Named("vm:changevolumes") - @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) - */ - @Named("vm:listharddisks") - @GET - @Consumes(DisksManagementDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listAttachedHardDisks( - @EndpointLink("disks") @BinderParam(BindToPath.class) VirtualMachineDto virtualMachine); - - /** - * @see CloudApi#detachAllHardDisks(VirtualMachineDto) - */ - @Named("vm:detachharddisks") - @DELETE - @ResponseParser(ReturnTaskReferenceOrNull.class) - @Consumes(AcceptedRequestDto.BASE_MEDIA_TYPE) - ListenableFuture> detachAllHardDisks( - @EndpointLink("disks") @BinderParam(BindToPath.class) VirtualMachineDto virtualMachine); - - /** - * @see CloudApi#replaceHardDisks(VirtualMachineDto, DiskManagementDto...) - */ - @Named("vm:changeharddisks") - @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) - */ - @Named("vm:deploy") - @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) - */ - @Named("vm:undeploy") - @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) - */ - @Named("harddisk:list") - @GET - @Consumes(DisksManagementDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listHardDisks( - @EndpointLink("disks") @BinderParam(BindToPath.class) VirtualDatacenterDto virtualDatacenter); - - /** - * @see CloudApi#getHardDisk(VirtualDatacenterDto, Integer) - */ - @Named("harddisk:get") - @GET - @Fallback(NullOnNotFoundOr404.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) - */ - @Named("harddisk:create") - @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) - */ - @Named("harddisk:delete") - @DELETE - ListenableFuture deleteHardDisk(@EndpointLink("edit") @BinderParam(BindToPath.class) DiskManagementDto hardDisk); - - /*********************** Volumes ***********************/ - - /** - * @see CloudApi#listVolumes(VirtualDatacenterDto) - */ - @Named("volume:list") - @EnterpriseEdition - @GET - @Consumes(VolumesManagementDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listVolumes( - @EndpointLink("volumes") @BinderParam(BindToPath.class) VirtualDatacenterDto virtualDatacenter); - - /** - * @see CloudApi#listVolumes(VirtualDatacenterDto, VolumeOptions) - */ - @Named("volume:list") - @EnterpriseEdition - @GET - @Consumes(VolumesManagementDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listVolumes( - @EndpointLink("volumes") @BinderParam(BindToPath.class) VirtualDatacenterDto virtualDatacenter, - VolumeOptions options); - - /** - * @see CloudApi#getVolume(VirtualDatacenterDto, Integer) - */ - @Named("volume:get") - @EnterpriseEdition - @GET - @Fallback(NullOnNotFoundOr404.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) - */ - @Named("volume:create") - @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) - */ - @Named("volume:update") - @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) - */ - @Named("volume:delete") - @EnterpriseEdition - @DELETE - ListenableFuture deleteVolume(@EndpointLink("edit") @BinderParam(BindToPath.class) VolumeManagementDto volume); - - /** - * @see CloudApi#moveVolume(VolumeManagementDto, VirtualDatacenterDto) - */ - @Named("volume:move") - @EnterpriseEdition - @POST - @Fallback(MovedVolume.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 deleted file mode 100644 index a251ab61f3..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/features/ConfigApi.java +++ /dev/null @@ -1,172 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.features; - -import org.jclouds.abiquo.domain.config.options.LicenseOptions; -import org.jclouds.abiquo.domain.config.options.PropertyOptions; -import org.jclouds.abiquo.reference.annotations.EnterpriseEdition; - -import com.abiquo.server.core.appslibrary.CategoriesDto; -import com.abiquo.server.core.appslibrary.CategoryDto; -import com.abiquo.server.core.config.LicenseDto; -import com.abiquo.server.core.config.LicensesDto; -import com.abiquo.server.core.config.SystemPropertiesDto; -import com.abiquo.server.core.config.SystemPropertyDto; -import com.abiquo.server.core.enterprise.PrivilegeDto; -import com.abiquo.server.core.enterprise.PrivilegesDto; - -/** - * Provides synchronous access to Abiquo Admin API. - * - * @see API: - * http://community.abiquo.com/display/ABI20/API+Reference - * @see ConfigAsyncApi - * @author Ignasi Barrera - * @author Francesc Montserrat - */ -public interface ConfigApi { - /*********************** License ***********************/ - - /** - * 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); - - /** - * 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); - - /*********************** Privilege ***********************/ - - /** - * 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); - - /*********************** System Properties ***********************/ - - /** - * 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); - - /** - * Updates a system property. - * - * @param property - * The new attributes for the system property. - * @return The updated system property. - */ - SystemPropertyDto updateSystemProperty(SystemPropertyDto property); - - /*********************** Category ***********************/ - - /** - * 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); - - /** - * 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); - - /** - * 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 deleted file mode 100644 index 9d05799dd8..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/features/ConfigAsyncApi.java +++ /dev/null @@ -1,221 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.features; - -import javax.inject.Named; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; - -import org.jclouds.Fallbacks.NullOnNotFoundOr404; -import org.jclouds.abiquo.binders.BindToPath; -import org.jclouds.abiquo.binders.BindToXMLPayloadAndPath; -import org.jclouds.abiquo.domain.config.options.LicenseOptions; -import org.jclouds.abiquo.domain.config.options.PropertyOptions; -import org.jclouds.abiquo.http.filters.AbiquoAuthentication; -import org.jclouds.abiquo.http.filters.AppendApiVersionToMediaType; -import org.jclouds.abiquo.reference.annotations.EnterpriseEdition; -import org.jclouds.abiquo.rest.annotations.EndpointLink; -import org.jclouds.rest.annotations.BinderParam; -import org.jclouds.rest.annotations.Fallback; -import org.jclouds.rest.annotations.JAXBResponseParser; -import org.jclouds.rest.annotations.RequestFilters; -import org.jclouds.rest.binders.BindToXMLPayload; - -import com.abiquo.server.core.appslibrary.CategoriesDto; -import com.abiquo.server.core.appslibrary.CategoryDto; -import com.abiquo.server.core.cloud.VirtualDatacenterDto; -import com.abiquo.server.core.config.LicenseDto; -import com.abiquo.server.core.config.LicensesDto; -import com.abiquo.server.core.config.SystemPropertiesDto; -import com.abiquo.server.core.config.SystemPropertyDto; -import com.abiquo.server.core.enterprise.PrivilegeDto; -import com.abiquo.server.core.enterprise.PrivilegesDto; -import com.google.common.util.concurrent.ListenableFuture; - -/** - * Provides asynchronous access to Abiquo Config API. - * - * @see API: - * http://community.abiquo.com/display/ABI20/API+Reference - * @see AdminApi - * @author Ignasi Barrera - * @author Francesc Montserrat - */ -@RequestFilters({ AbiquoAuthentication.class, AppendApiVersionToMediaType.class }) -@Path("/config") -public interface ConfigAsyncApi { - /*********************** License ***********************/ - - /** - * @see ConfigApi#listLicenses() - */ - @Named("license:list") - @EnterpriseEdition - @GET - @Path("/licenses") - @Consumes(LicensesDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listLicenses(); - - /** - * @see ConfigApi#listLicenses(LicenseOptions) - */ - @Named("license:list") - @EnterpriseEdition - @GET - @Path("/licenses") - @Consumes(LicensesDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listLicenses(LicenseOptions options); - - /** - * @see ConfigApi#addLicense(LicenseDto) - */ - @Named("license:add") - @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) - */ - @Named("license:remove") - @DELETE - @EnterpriseEdition - ListenableFuture removeLicense(@EndpointLink("edit") @BinderParam(BindToPath.class) LicenseDto license); - - /*********************** Privilege ***********************/ - - /** - * @see ConfigApi#listPrivileges() - */ - @Named("privilege:list") - @GET - @Path("/privileges") - @Consumes(PrivilegesDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listPrivileges(); - - /** - * @see ConfigApi#getPrivilege(Integer) - */ - @Named("privilege:get") - @GET - @Path("/privileges/{privilege}") - @Consumes(PrivilegeDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - @Fallback(NullOnNotFoundOr404.class) - ListenableFuture getPrivilege(@PathParam("privilege") Integer privilegeId); - - /*********************** System Properties ***********************/ - - /** - * @see ConfigApi#listSystemProperties() - */ - @Named("property:list") - @GET - @Path("/properties") - @Consumes(SystemPropertiesDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listSystemProperties(); - - /** - * @see ConfigApi#listSystemProperties(PropertyOptions) - */ - @Named("property:list") - @GET - @Path("/properties") - @Consumes(SystemPropertiesDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listSystemProperties(PropertyOptions options); - - /** - * @see ConfigApi#updateSystemProperty(VirtualDatacenterDto) - */ - @Named("property:update") - @PUT - @Produces(SystemPropertyDto.BASE_MEDIA_TYPE) - @Consumes(SystemPropertyDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture updateSystemProperty( - @EndpointLink("edit") @BinderParam(BindToXMLPayloadAndPath.class) SystemPropertyDto property); - - /*********************** Category ***********************/ - - /** - * @see ConfigApi#listCategories() - */ - @Named("category:list") - @GET - @Path("/categories") - @Consumes(CategoriesDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listCategories(); - - /** - * @see ConfigApi#getCategory(Integer) - */ - @Named("category:get") - @GET - @Path("/categories/{category}") - @Consumes(CategoryDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - @Fallback(NullOnNotFoundOr404.class) - ListenableFuture getCategory(@PathParam("category") Integer categoryId); - - /** - * @see ConfigApi#createCategory(CategoryDto) - */ - @Named("category:create") - @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) - */ - @Named("category:update") - @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) - */ - @Named("category:delete") - @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 deleted file mode 100644 index db2253a559..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/features/EnterpriseApi.java +++ /dev/null @@ -1,398 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.features; - -import org.jclouds.abiquo.domain.enterprise.options.EnterpriseOptions; -import org.jclouds.abiquo.reference.annotations.EnterpriseEdition; - -import com.abiquo.am.model.TemplatesStateDto; -import com.abiquo.server.core.appslibrary.DatacenterRepositoryDto; -import com.abiquo.server.core.appslibrary.TemplateDefinitionListDto; -import com.abiquo.server.core.appslibrary.TemplateDefinitionListsDto; -import com.abiquo.server.core.cloud.VirtualAppliancesDto; -import com.abiquo.server.core.cloud.VirtualDatacentersDto; -import com.abiquo.server.core.cloud.VirtualMachinesWithNodeExtendedDto; -import com.abiquo.server.core.enterprise.DatacenterLimitsDto; -import com.abiquo.server.core.enterprise.DatacentersLimitsDto; -import com.abiquo.server.core.enterprise.EnterpriseDto; -import com.abiquo.server.core.enterprise.EnterprisePropertiesDto; -import com.abiquo.server.core.enterprise.EnterprisesDto; -import com.abiquo.server.core.enterprise.UserDto; -import com.abiquo.server.core.enterprise.UsersDto; -import com.abiquo.server.core.infrastructure.DatacenterDto; -import com.abiquo.server.core.infrastructure.DatacentersDto; -import com.abiquo.server.core.infrastructure.MachinesDto; -import com.abiquo.server.core.infrastructure.network.VLANNetworksDto; - -/** - * Provides synchronous access to Abiquo Enterprise API. - * - * @see API: - * http://community.abiquo.com/display/ABI20/API+Reference - * @see EnterpriseAsyncApi - * @author Ignasi Barrera - * @author Francesc Montserrat - */ -public interface EnterpriseApi { - - /*********************** Enterprise ********************** */ - - /** - * 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 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); - - /** - * 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); - - /** - * 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 all virtual datacenters of an enterprise. - * - * @param enterprise - * The given enterprise. - * @return The list of Datacenters. - */ - VirtualDatacentersDto listVirtualDatacenters(EnterpriseDto enterprise); - - /*********************** Enterprise Properties ***********************/ - - /** - * 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); - - /*********************** 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); - - /** - * Retrieves 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); - - /** - * Retrieves 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); - - /** - * Deletes existing limits for a pair enterprise-datacenter. - * - * @param limits - * The limits to delete. - */ - void deleteLimits(DatacenterLimitsDto limits); - - /*********************** User ********************** */ - - /** - * Retrieves 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); - - /** - * 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); - - /** - * 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); - - /*********************** 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); - - /** - * 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 containing the templates. - */ - void refreshTemplateRepository(Integer enterpriseId, Integer datacenterRepositoryId); - - /*********************** 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); - - /*********************** 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); - - /** - * 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 reserved 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); - - /** - * 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); - - /** - * 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 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 deleted file mode 100644 index 5f8ff2a2b9..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/features/EnterpriseAsyncApi.java +++ /dev/null @@ -1,451 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.features; - -import javax.inject.Named; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; - -import org.jclouds.Fallbacks.NullOnNotFoundOr404; -import org.jclouds.abiquo.binders.AppendToPath; -import org.jclouds.abiquo.binders.BindToPath; -import org.jclouds.abiquo.binders.BindToXMLPayloadAndPath; -import org.jclouds.abiquo.domain.enterprise.options.EnterpriseOptions; -import org.jclouds.abiquo.functions.infrastructure.ParseDatacenterId; -import org.jclouds.abiquo.http.filters.AbiquoAuthentication; -import org.jclouds.abiquo.http.filters.AppendApiVersionToMediaType; -import org.jclouds.abiquo.reference.annotations.EnterpriseEdition; -import org.jclouds.abiquo.rest.annotations.EndpointLink; -import org.jclouds.rest.annotations.BinderParam; -import org.jclouds.rest.annotations.Fallback; -import org.jclouds.rest.annotations.JAXBResponseParser; -import org.jclouds.rest.annotations.ParamParser; -import org.jclouds.rest.annotations.RequestFilters; -import org.jclouds.rest.binders.BindToXMLPayload; - -import com.abiquo.am.model.TemplatesStateDto; -import com.abiquo.server.core.appslibrary.DatacenterRepositoryDto; -import com.abiquo.server.core.appslibrary.TemplateDefinitionListDto; -import com.abiquo.server.core.appslibrary.TemplateDefinitionListsDto; -import com.abiquo.server.core.cloud.VirtualAppliancesDto; -import com.abiquo.server.core.cloud.VirtualDatacentersDto; -import com.abiquo.server.core.cloud.VirtualMachinesWithNodeExtendedDto; -import com.abiquo.server.core.enterprise.DatacenterLimitsDto; -import com.abiquo.server.core.enterprise.DatacentersLimitsDto; -import com.abiquo.server.core.enterprise.EnterpriseDto; -import com.abiquo.server.core.enterprise.EnterprisePropertiesDto; -import com.abiquo.server.core.enterprise.EnterprisesDto; -import com.abiquo.server.core.enterprise.UserDto; -import com.abiquo.server.core.enterprise.UsersDto; -import com.abiquo.server.core.infrastructure.DatacenterDto; -import com.abiquo.server.core.infrastructure.DatacentersDto; -import com.abiquo.server.core.infrastructure.MachinesDto; -import com.abiquo.server.core.infrastructure.network.VLANNetworksDto; -import com.google.common.util.concurrent.ListenableFuture; - -/** - * Provides asynchronous access to Abiquo Enterprise API. - * - * @see API: - * http://community.abiquo.com/display/ABI20/API+Reference - * @see EnterpriseApi - * @author Ignasi Barrera - * @author Francesc Montserrat - */ -@RequestFilters({ AbiquoAuthentication.class, AppendApiVersionToMediaType.class }) -@Path("/admin") -public interface EnterpriseAsyncApi { - /*********************** Enterprise ***********************/ - - /** - * @see EnterpriseApi#listEnterprises() - */ - @Named("enterprise:list") - @GET - @Path("/enterprises") - @Consumes(EnterprisesDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listEnterprises(); - - /** - * @see EnterpriseApi#listEnterprises(EnterpriseOptions) - */ - @Named("enterprise:list") - @GET - @Path("/enterprises") - @Consumes(EnterprisesDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listEnterprises(EnterpriseOptions options); - - /** - * @see EnterpriseApi#listEnterprises(DatacenterDto, EnterpriseOptions) - */ - @Named("enterprise:list") - @GET - @Consumes(EnterprisesDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listEnterprises( - @EndpointLink("enterprises") @BinderParam(BindToPath.class) DatacenterDto datacenter, EnterpriseOptions options); - - /** - * @see EnterpriseApi#createEnterprise(EnterpriseDto) - */ - @Named("enterprise:create") - @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) - */ - @Named("enterprise:get") - @GET - @Path("/enterprises/{enterprise}") - @Consumes(EnterpriseDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - @Fallback(NullOnNotFoundOr404.class) - ListenableFuture getEnterprise(@PathParam("enterprise") Integer enterpriseId); - - /** - * @see EnterpriseApi#updateEnterprise(EnterpriseDto) - */ - @Named("enterprise:update") - @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) - */ - @Named("enterprise:delete") - @DELETE - ListenableFuture deleteEnterprise(@EndpointLink("edit") @BinderParam(BindToPath.class) EnterpriseDto enterprise); - - /** - * @see EnterpriseApi#listAllowedDatacenters(Integer) - */ - @Named("enterprise:listalloweddatacenters") - @GET - @Path("/datacenters") - @Consumes(DatacentersDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listAllowedDatacenters(@QueryParam("idEnterprise") Integer enterpriseId); - - /** - * @see EnterpriseApi#listVirtualDatacenters(EnterpriseDto) - */ - @Named("enterprise:listvirtualdatacenters") - @GET - @Consumes(VirtualDatacentersDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listVirtualDatacenters( - @EndpointLink("cloud/virtualdatacenters") @BinderParam(BindToPath.class) EnterpriseDto enterprise); - - /*********************** Enterprise Properties ***********************/ - - /** - * @see EnterpriseApi#getEnterpriseProperties(EnterpriseDto) - */ - @Named("enterprise:getproperties") - @EnterpriseEdition - @GET - @Consumes(EnterprisePropertiesDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture getEnterpriseProperties( - @EndpointLink("properties") @BinderParam(BindToPath.class) EnterpriseDto enterprise); - - /** - * @see EnterpriseApi#updateEnterpriseProperties(EnterprisePropertiesDto) - */ - @Named("enterprse:setproperties") - @EnterpriseEdition - @PUT - @Produces(EnterprisePropertiesDto.BASE_MEDIA_TYPE) - @Consumes(EnterprisePropertiesDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture updateEnterpriseProperties( - @EndpointLink("edit") @BinderParam(BindToXMLPayloadAndPath.class) EnterprisePropertiesDto properties); - - /*********************** Enterprise Limits ***********************/ - - /** - * @see EnterpriseApi#createLimits(EnterpriseDto, DatacenterDto, - * DatacenterLimitsDto) - */ - @Named("limit:create") - @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) - */ - @Named("limit:get") - @GET - @Consumes(DatacentersLimitsDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - @Fallback(NullOnNotFoundOr404.class) - ListenableFuture getLimits( - @EndpointLink("limits") @BinderParam(BindToPath.class) final EnterpriseDto enterprise, - @QueryParam("datacenter") @ParamParser(ParseDatacenterId.class) final DatacenterDto datacenter); - - /** - * @see EnterpriseApi#updateLimits(DatacenterLimitsDto) - */ - @Named("limit:update") - @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) - */ - @Named("limit:delete") - @DELETE - ListenableFuture deleteLimits(@EndpointLink("edit") @BinderParam(BindToPath.class) DatacenterLimitsDto limits); - - /** - * @see EnterpriseApi#listLimits(EnterpriseDto) - */ - @Named("limit:list") - @GET - @Consumes(DatacentersLimitsDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listLimits( - @EndpointLink("limits") @BinderParam(BindToPath.class) EnterpriseDto enterprise); - - /*********************** User ***********************/ - - /** - * @see EnterpriseApi#listUsers(EnterpriseDto) - */ - @Named("user:list") - @GET - @Consumes(UsersDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listUsers(@EndpointLink("users") @BinderParam(BindToPath.class) EnterpriseDto enterprise); - - /** - * @see EnterpriseApi#getUser(EnterpriseDto, Integer) - */ - @Named("user:get") - @GET - @Consumes(UserDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - @Fallback(NullOnNotFoundOr404.class) - ListenableFuture getUser(@EndpointLink("users") @BinderParam(BindToPath.class) EnterpriseDto enterprise, - @BinderParam(AppendToPath.class) Integer userId); - - /** - * @see EnterpriseApi#createUser(EnterpriseDto) - */ - @Named("user:create") - @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) - */ - @Named("user:update") - @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) - */ - @Named("user:delete") - @DELETE - ListenableFuture deleteUser(@EndpointLink("edit") @BinderParam(BindToPath.class) UserDto user); - - /** - * @see EnterpriseApi#listVirtualMachines(UserDto) - */ - @Named("user:listvms") - @GET - @Consumes(VirtualMachinesWithNodeExtendedDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listVirtualMachines( - @EndpointLink("virtualmachines") @BinderParam(BindToPath.class) final UserDto user); - - /*********************** Datacenter Repository ***********************/ - - /** - * @see EnterpriseApi#getDatacenterRepository(EnterpriseDto, Integer) - */ - @Named("repository:get") - @GET - @Consumes(DatacenterRepositoryDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - @Fallback(NullOnNotFoundOr404.class) - ListenableFuture getDatacenterRepository( - @EndpointLink("datacenterrepositories") @BinderParam(BindToPath.class) EnterpriseDto enterprise, - @BinderParam(AppendToPath.class) Integer datacenterRepositoryId); - - /** - * @see EnterpriseApi#refreshTemplateRepository(Integer, Integer) - */ - @Named("repository:refresh") - @PUT - @Path("/enterprises/{enterprise}/datacenterrepositories/{datacenterrepository}/actions/refresh") - ListenableFuture refreshTemplateRepository(@PathParam("enterprise") Integer enterpriseId, - @PathParam("datacenterrepository") Integer datacenterRepositoryId); - - /*********************** External Network ***********************/ - - /** - * @see EnterpriseApi#listExternalNetworks(EnterpriseDto) - */ - @Named("enterprise:listexternalnetworks") - @EnterpriseEdition - @GET - @Consumes(VLANNetworksDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listExternalNetworks( - @EndpointLink("externalnetworks") @BinderParam(BindToPath.class) EnterpriseDto enterprise); - - /*********************** Cloud ***********************/ - - /** - * @see EnterpriseApi#listVirtualAppliances(EnterpriseDto) - */ - @Named("enterprise:listvapps") - @GET - @Consumes(VirtualAppliancesDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listVirtualAppliances( - @EndpointLink("virtualappliances") @BinderParam(BindToPath.class) final EnterpriseDto enterprise); - - /** - * @see EnterpriseApi#listVirtualMachines(EnterpriseDto) - */ - @Named("enterprise:listvms") - @GET - @Consumes(VirtualMachinesWithNodeExtendedDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listVirtualMachines( - @EndpointLink("virtualmachines") @BinderParam(BindToPath.class) EnterpriseDto enterprise); - - /*********************** Machine ***********************/ - - /** - * @see EnterpriseApi#listVirtualMachines(EnterpriseDto) - */ - @Named("enterprise:listreservedmachines") - @GET - @Consumes(MachinesDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listReservedMachines( - @EndpointLink("reservedmachines") @BinderParam(BindToPath.class) EnterpriseDto enterprise); - - /*********************** Template definition list ***********************/ - - /** - * @see EnterpriseApi#listTemplateDefinitionLists(EnterpriseDto) - */ - @Named("templatedefinitionlist:list") - @GET - @Consumes(TemplateDefinitionListsDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listTemplateDefinitionLists( - @EndpointLink("appslib/templateDefinitionLists") @BinderParam(BindToPath.class) EnterpriseDto enterprise); - - /** - * @see EnterpriseApi#createTemplateDefinitionList(EnterpriseDto, - * TemplateDefinitionListDto) - */ - @Named("templatedefinitionlist:create") - @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) - */ - @Named("templatedefinitionlist:update") - @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) - */ - @Named("templatedefinitionlist:delete") - @DELETE - ListenableFuture deleteTemplateDefinitionList( - @EndpointLink("edit") @BinderParam(BindToPath.class) TemplateDefinitionListDto templateList); - - /** - * @see EnterpriseApi#getTemplateDefinitionList(EnterpriseDto, Integer) - */ - @Named("templatedefinitionlist:get") - @GET - @Consumes(TemplateDefinitionListDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - @Fallback(NullOnNotFoundOr404.class) - ListenableFuture getTemplateDefinitionList( - @EndpointLink("appslib/templateDefinitionLists") @BinderParam(BindToPath.class) EnterpriseDto enterprise, - @BinderParam(AppendToPath.class) Integer templateListId); - - /** - * @see EnterpriseApi#getTemplateDefinitionList(EnterpriseDto, Integer) - */ - @Named("templatedefinitionlist:status") - @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 deleted file mode 100644 index 3c41c57591..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/features/EventApi.java +++ /dev/null @@ -1,49 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.features; - -import org.jclouds.abiquo.domain.event.options.EventOptions; - -import com.abiquo.server.core.event.EventsDto; - -/** - * Provides synchronous access to Abiquo Event API. - * - * @see API: - * http://community.abiquo.com/display/ABI20/API+Reference - * @see EventAsyncApi - * @author Ignasi Barrera - * @author Vivien Mahé - */ -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); -} 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 deleted file mode 100644 index 514ccac318..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/features/EventAsyncApi.java +++ /dev/null @@ -1,66 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.features; - -import javax.inject.Named; -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.Path; - -import org.jclouds.abiquo.domain.event.options.EventOptions; -import org.jclouds.abiquo.http.filters.AbiquoAuthentication; -import org.jclouds.abiquo.http.filters.AppendApiVersionToMediaType; -import org.jclouds.rest.annotations.JAXBResponseParser; -import org.jclouds.rest.annotations.RequestFilters; - -import com.abiquo.server.core.event.EventsDto; -import com.google.common.util.concurrent.ListenableFuture; - -/** - * Provides asynchronous access to Abiquo Event API. - * - * @see API: - * http://community.abiquo.com/display/ABI20/API+Reference - * @see EventApi - * @author Ignasi Barrera - * @author Vivien Mahé - */ -@RequestFilters({ AbiquoAuthentication.class, AppendApiVersionToMediaType.class }) -public interface EventAsyncApi { - /** - * @see EventApi#listEvents() - */ - @Named("event:list") - @GET - @Path("/events") - @Consumes(EventsDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listEvents(); - - /** - * @see EventApi#listEvents() - */ - @Named("event:list") - @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 deleted file mode 100644 index 50be0087b7..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/features/InfrastructureApi.java +++ /dev/null @@ -1,1234 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.features; - -import org.jclouds.abiquo.domain.infrastructure.options.DatacenterOptions; -import org.jclouds.abiquo.domain.infrastructure.options.IpmiOptions; -import org.jclouds.abiquo.domain.infrastructure.options.MachineOptions; -import org.jclouds.abiquo.domain.infrastructure.options.StoragePoolOptions; -import org.jclouds.abiquo.domain.network.options.IpOptions; -import org.jclouds.abiquo.domain.network.options.NetworkOptions; -import org.jclouds.abiquo.domain.options.search.FilterOptions; -import org.jclouds.abiquo.reference.annotations.EnterpriseEdition; - -import com.abiquo.model.enumerator.HypervisorType; -import com.abiquo.model.enumerator.RemoteServiceType; -import com.abiquo.server.core.cloud.HypervisorTypesDto; -import com.abiquo.server.core.cloud.VirtualMachineWithNodeExtendedDto; -import com.abiquo.server.core.cloud.VirtualMachinesWithNodeExtendedDto; -import com.abiquo.server.core.enterprise.DatacentersLimitsDto; -import com.abiquo.server.core.enterprise.EnterpriseDto; -import com.abiquo.server.core.infrastructure.BladeLocatorLedDto; -import com.abiquo.server.core.infrastructure.DatacenterDto; -import com.abiquo.server.core.infrastructure.DatacentersDto; -import com.abiquo.server.core.infrastructure.FsmsDto; -import com.abiquo.server.core.infrastructure.LogicServerDto; -import com.abiquo.server.core.infrastructure.LogicServersDto; -import com.abiquo.server.core.infrastructure.MachineDto; -import com.abiquo.server.core.infrastructure.MachineIpmiStateDto; -import com.abiquo.server.core.infrastructure.MachineStateDto; -import com.abiquo.server.core.infrastructure.MachinesDto; -import com.abiquo.server.core.infrastructure.OrganizationDto; -import com.abiquo.server.core.infrastructure.OrganizationsDto; -import com.abiquo.server.core.infrastructure.RackDto; -import com.abiquo.server.core.infrastructure.RacksDto; -import com.abiquo.server.core.infrastructure.RemoteServiceDto; -import com.abiquo.server.core.infrastructure.RemoteServicesDto; -import com.abiquo.server.core.infrastructure.UcsRackDto; -import com.abiquo.server.core.infrastructure.UcsRacksDto; -import com.abiquo.server.core.infrastructure.network.ExternalIpDto; -import com.abiquo.server.core.infrastructure.network.ExternalIpsDto; -import com.abiquo.server.core.infrastructure.network.NetworkServiceTypeDto; -import com.abiquo.server.core.infrastructure.network.NetworkServiceTypesDto; -import com.abiquo.server.core.infrastructure.network.PublicIpDto; -import com.abiquo.server.core.infrastructure.network.PublicIpsDto; -import com.abiquo.server.core.infrastructure.network.UnmanagedIpDto; -import com.abiquo.server.core.infrastructure.network.UnmanagedIpsDto; -import com.abiquo.server.core.infrastructure.network.VLANNetworkDto; -import com.abiquo.server.core.infrastructure.network.VLANNetworksDto; -import com.abiquo.server.core.infrastructure.network.VlanTagAvailabilityDto; -import com.abiquo.server.core.infrastructure.storage.StorageDeviceDto; -import com.abiquo.server.core.infrastructure.storage.StorageDevicesDto; -import com.abiquo.server.core.infrastructure.storage.StorageDevicesMetadataDto; -import com.abiquo.server.core.infrastructure.storage.StoragePoolDto; -import com.abiquo.server.core.infrastructure.storage.StoragePoolsDto; -import com.abiquo.server.core.infrastructure.storage.TierDto; -import com.abiquo.server.core.infrastructure.storage.TiersDto; - -/** - * Provides synchronous access to Abiquo Infrastructure API. - * - * @see API: - * http://community.abiquo.com/display/ABI20/API+Reference - * @see InfrastructureAsyncApi - * @author Ignasi Barrera - * @author Francesc Montserrat - */ -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. - */ - 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. - */ - 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. - */ - 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. - */ - MachinesDto discoverMultipleMachines(final DatacenterDto datacenter, final String ipFrom, final String ipTo, - final HypervisorType hypervisorType, final String user, final String password, final MachineOptions options); - - /** - * Retrieves 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 ***********************/ - - /** - * Retrieves 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); - - /** - * Retrieves 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 - 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 - 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 - 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 - 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 - 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 - 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 - 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 - 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 - 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 - OrganizationsDto listOrganizations(UcsRackDto rack, FilterOptions options); - - /** - * Clone a service profile. - * - * @param rack - * The managed rack where the 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 - 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 - 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 - 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 - 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 - 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 - 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 - 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 datacenter); - - /** - * 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 - * @param sync 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 machine - * The physical machine. - */ - @EnterpriseEdition - void powerOff(MachineDto machine); - - /** - * Power on a physical machine in a UCS rack. - * - * @param machine - * The physical machine. - */ - @EnterpriseEdition - void powerOn(MachineDto machine); - - /** - * Get the logic server associated with a machine in a Cisco UCS rack. - * - * @param machine - * The physical machine. - * @return The logic server. - */ - @EnterpriseEdition - LogicServerDto getLogicServer(MachineDto machine); - - /** - * Turn off locator led of a physical machine in a UCS rack. - * - * @param machine - * The physical machine. - */ - @EnterpriseEdition - void ledOn(MachineDto machine); - - /** - * Light locator led of a physical machine in a UCS rack. - * - * @param machine - * The physical machine. - */ - @EnterpriseEdition - void ledOff(MachineDto machine); - - /** - * Get led locator info from a physical machine in a UCS rack. - * - * @param machine - * The physical 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); - - /** - * List all the Network Service types definied into a datacenter. - * - * @param datacenter - * The datacenter - * @return The list of Network Service Types in the datacenter. - */ - NetworkServiceTypesDto listNetworkServiceTypes(DatacenterDto datacenter); - - /** - * Create a new Network Service Type Dto. - * - * @param datacenter - * the datacenter where the network service type will belong to - * @param nst - * {@link NetworkServiceTypeDto} instance to create - * @return the created {@link NetworkServiceTypeDto} - */ - NetworkServiceTypeDto createNetworkServiceType(DatacenterDto datacenter, NetworkServiceTypeDto nst); - - /** - * Get a single instance of a {@link NetworkServiceTypeDto} - * - * @param datacenter - * datacenter where search into - * @param nstId - * identifier of the {@link NetworkServiceTypeDto} - * @return the found entity - */ - NetworkServiceTypeDto getNetworkServiceType(DatacenterDto datacenter, Integer nstId); - - /** - * Update the value of a {@link NetworkServiceTypeDto} - * - * @param nstDto - * the instance to update with the new values. - * @return the updated entity. - */ - NetworkServiceTypeDto updateNetworkServiceType(NetworkServiceTypeDto nstDto); - - /** - * Remove a {@link NetworkServiceTypeDto} entity. - * - * @param nstDto - * the entity to delete - */ - void deleteNetworkServiceType(NetworkServiceTypeDto nstDto); - -} 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 deleted file mode 100644 index 62dbe5d858..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/features/InfrastructureAsyncApi.java +++ /dev/null @@ -1,1238 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.features; - -import javax.inject.Named; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.MediaType; - -import org.jclouds.Fallbacks.NullOnNotFoundOr404; -import org.jclouds.abiquo.AbiquoFallbacks.FalseIfNotAvailable; -import org.jclouds.abiquo.AbiquoFallbacks.PropagateAbiquoExceptionOnNotFoundOr4xx; -import org.jclouds.abiquo.binders.AppendToPath; -import org.jclouds.abiquo.binders.BindToPath; -import org.jclouds.abiquo.binders.BindToXMLPayloadAndPath; -import org.jclouds.abiquo.binders.infrastructure.AppendMachineIdToPath; -import org.jclouds.abiquo.binders.infrastructure.AppendRemoteServiceTypeToPath; -import org.jclouds.abiquo.binders.infrastructure.BindSupportedDevicesLinkToPath; -import org.jclouds.abiquo.binders.infrastructure.ucs.BindLogicServerParameters; -import org.jclouds.abiquo.binders.infrastructure.ucs.BindOrganizationParameters; -import org.jclouds.abiquo.domain.infrastructure.options.DatacenterOptions; -import org.jclouds.abiquo.domain.infrastructure.options.IpmiOptions; -import org.jclouds.abiquo.domain.infrastructure.options.MachineOptions; -import org.jclouds.abiquo.domain.infrastructure.options.StoragePoolOptions; -import org.jclouds.abiquo.domain.network.options.IpOptions; -import org.jclouds.abiquo.domain.network.options.NetworkOptions; -import org.jclouds.abiquo.domain.options.search.FilterOptions; -import org.jclouds.abiquo.functions.infrastructure.ParseDatacenterId; -import org.jclouds.abiquo.http.filters.AbiquoAuthentication; -import org.jclouds.abiquo.http.filters.AppendApiVersionToMediaType; -import org.jclouds.abiquo.reference.annotations.EnterpriseEdition; -import org.jclouds.abiquo.rest.annotations.EndpointLink; -import org.jclouds.http.functions.ReturnStringIf2xx; -import org.jclouds.rest.annotations.BinderParam; -import org.jclouds.rest.annotations.Fallback; -import org.jclouds.rest.annotations.JAXBResponseParser; -import org.jclouds.rest.annotations.ParamParser; -import org.jclouds.rest.annotations.RequestFilters; -import org.jclouds.rest.annotations.ResponseParser; -import org.jclouds.rest.binders.BindToXMLPayload; - -import com.abiquo.model.enumerator.HypervisorType; -import com.abiquo.model.enumerator.RemoteServiceType; -import com.abiquo.server.core.cloud.HypervisorTypesDto; -import com.abiquo.server.core.cloud.VirtualMachineWithNodeExtendedDto; -import com.abiquo.server.core.cloud.VirtualMachinesWithNodeExtendedDto; -import com.abiquo.server.core.enterprise.DatacentersLimitsDto; -import com.abiquo.server.core.enterprise.EnterpriseDto; -import com.abiquo.server.core.infrastructure.BladeLocatorLedDto; -import com.abiquo.server.core.infrastructure.DatacenterDto; -import com.abiquo.server.core.infrastructure.DatacentersDto; -import com.abiquo.server.core.infrastructure.FsmsDto; -import com.abiquo.server.core.infrastructure.LogicServerDto; -import com.abiquo.server.core.infrastructure.LogicServersDto; -import com.abiquo.server.core.infrastructure.MachineDto; -import com.abiquo.server.core.infrastructure.MachineIpmiStateDto; -import com.abiquo.server.core.infrastructure.MachineStateDto; -import com.abiquo.server.core.infrastructure.MachinesDto; -import com.abiquo.server.core.infrastructure.OrganizationDto; -import com.abiquo.server.core.infrastructure.OrganizationsDto; -import com.abiquo.server.core.infrastructure.RackDto; -import com.abiquo.server.core.infrastructure.RacksDto; -import com.abiquo.server.core.infrastructure.RemoteServiceDto; -import com.abiquo.server.core.infrastructure.RemoteServicesDto; -import com.abiquo.server.core.infrastructure.UcsRackDto; -import com.abiquo.server.core.infrastructure.UcsRacksDto; -import com.abiquo.server.core.infrastructure.network.ExternalIpDto; -import com.abiquo.server.core.infrastructure.network.ExternalIpsDto; -import com.abiquo.server.core.infrastructure.network.NetworkServiceTypeDto; -import com.abiquo.server.core.infrastructure.network.NetworkServiceTypesDto; -import com.abiquo.server.core.infrastructure.network.PublicIpDto; -import com.abiquo.server.core.infrastructure.network.PublicIpsDto; -import com.abiquo.server.core.infrastructure.network.UnmanagedIpDto; -import com.abiquo.server.core.infrastructure.network.UnmanagedIpsDto; -import com.abiquo.server.core.infrastructure.network.VLANNetworkDto; -import com.abiquo.server.core.infrastructure.network.VLANNetworksDto; -import com.abiquo.server.core.infrastructure.network.VlanTagAvailabilityDto; -import com.abiquo.server.core.infrastructure.storage.StorageDeviceDto; -import com.abiquo.server.core.infrastructure.storage.StorageDevicesDto; -import com.abiquo.server.core.infrastructure.storage.StorageDevicesMetadataDto; -import com.abiquo.server.core.infrastructure.storage.StoragePoolDto; -import com.abiquo.server.core.infrastructure.storage.StoragePoolsDto; -import com.abiquo.server.core.infrastructure.storage.TierDto; -import com.abiquo.server.core.infrastructure.storage.TiersDto; -import com.google.common.util.concurrent.ListenableFuture; - -/** - * Provides asynchronous access to Abiquo Infrastructure API. - * - * @see API: - * http://community.abiquo.com/display/ABI20/API+Reference - * @see InfrastructureApi - * @author Ignasi Barrera - * @author Francesc Montserrat - */ -@RequestFilters({ AbiquoAuthentication.class, AppendApiVersionToMediaType.class }) -@Path("/admin") -public interface InfrastructureAsyncApi { - /*********************** Datacenter ***********************/ - - /** - * @see InfrastructureApi#listDatacenters() - */ - @Named("datacenter:list") - @GET - @Path("/datacenters") - @Consumes(DatacentersDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listDatacenters(); - - /** - * @see InfrastructureApi#createDatacenter(DatacenterDto) - */ - @Named("datacenter:create") - @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) - */ - @Named("datacenter:get") - @GET - @Path("/datacenters/{datacenter}") - @Consumes(DatacenterDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - @Fallback(NullOnNotFoundOr404.class) - ListenableFuture getDatacenter(@PathParam("datacenter") Integer datacenterId); - - /** - * @see InfrastructureApi#updateDatacenter(DatacenterDto) - */ - @Named("datacenter:update") - @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) - */ - @Named("datacenter:delete") - @DELETE - ListenableFuture deleteDatacenter(@EndpointLink("edit") @BinderParam(BindToPath.class) DatacenterDto datacenter); - - /** - * @see InfrastructureApi#discoverSingleMachine(DatacenterDto, String, - * HypervisorType, String, String) - */ - @Named("machine:discover") - @GET - @Consumes(MachineDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - @Fallback(PropagateAbiquoExceptionOnNotFoundOr4xx.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) - */ - @Named("machine:discover") - @GET - @Consumes(MachineDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - @Fallback(PropagateAbiquoExceptionOnNotFoundOr4xx.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) - */ - @Named("machine:discover") - @GET - @Consumes(MachinesDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - @Fallback(PropagateAbiquoExceptionOnNotFoundOr4xx.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) - */ - @Named("machine:discover") - @GET - @Consumes(MachinesDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - @Fallback(PropagateAbiquoExceptionOnNotFoundOr4xx.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) - */ - @Named("limit:list") - @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) - */ - @Named("machine:checkstate") - @GET - @Consumes(MachineStateDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - @Fallback(PropagateAbiquoExceptionOnNotFoundOr4xx.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) - */ - @Named("machine:checkstate") - @GET - @Consumes(MachineStateDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - @Fallback(PropagateAbiquoExceptionOnNotFoundOr4xx.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) - */ - @Named("machine:checkipmi") - @GET - @Consumes(MachineIpmiStateDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - @Fallback(PropagateAbiquoExceptionOnNotFoundOr4xx.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) - */ - @Named("machine:checkipmi") - @GET - @Consumes(MachineIpmiStateDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - @Fallback(PropagateAbiquoExceptionOnNotFoundOr4xx.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) - */ - @Named("hypervisortype:getfrommachine") - @GET - @Consumes(MediaType.TEXT_PLAIN) - @ResponseParser(ReturnStringIf2xx.class) - ListenableFuture getHypervisorTypeFromMachine( - @EndpointLink("hypervisor") @BinderParam(BindToPath.class) DatacenterDto datacenter, DatacenterOptions options); - - /** - * @see InfrastructureApi#getHypervisorTypes(DatacenterDto) - */ - @Named("hypervisortype:list") - @GET - @Consumes(HypervisorTypesDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture getHypervisorTypes( - @EndpointLink("hypervisors") @BinderParam(BindToPath.class) DatacenterDto datacenter); - - /*********************** Unmanaged Rack ***********************/ - - /** - * @see InfrastructureApi#listRacks(DatacenterDto) - */ - @Named("rack:list") - @GET - @Consumes(RacksDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listRacks(@EndpointLink("racks") @BinderParam(BindToPath.class) DatacenterDto datacenter); - - /** - * @see InfrastructureApi#createRack(DatacenterDto, RackDto) - */ - @Named("rack:create") - @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) - */ - @Named("rack:get") - @GET - @Consumes(RackDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - @Fallback(NullOnNotFoundOr404.class) - ListenableFuture getRack(@EndpointLink("racks") @BinderParam(BindToPath.class) DatacenterDto datacenter, - @BinderParam(AppendToPath.class) Integer rackId); - - /** - * @see InfrastructureApi#updateRack(RackDto) - */ - @Named("rack:update") - @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) - */ - @Named("rack:delete") - @DELETE - ListenableFuture deleteRack(@EndpointLink("edit") @BinderParam(BindToPath.class) RackDto rack); - - /*********************** Managed Rack ***********************/ - - /** - * @see InfrastructureApi#listManagedRacks(DatacenterDto) - */ - @Named("ucs:listracks") - @EnterpriseEdition - @GET - @Consumes(UcsRacksDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listManagedRacks( - @EndpointLink("racks") @BinderParam(BindToPath.class) DatacenterDto datacenter); - - /** - * @see InfrastructureApi#createManagedRack(DatacenterDto, UcsRackDto) - */ - @Named("ucs:createrack") - @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) - */ - @Named("ucs:getrack") - @EnterpriseEdition - @GET - @Consumes(UcsRackDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - @Fallback(NullOnNotFoundOr404.class) - ListenableFuture getManagedRack( - @EndpointLink("racks") @BinderParam(BindToPath.class) DatacenterDto datacenter, - @BinderParam(AppendToPath.class) Integer rackId); - - /** - * @see InfrastructureApi#updateManagedRack(UcsRackDto) - */ - @Named("ucs:updaterack") - @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) - */ - @Named("ucs:listserviceprofiles") - @EnterpriseEdition - @GET - @Consumes(LogicServersDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listServiceProfiles( - @EndpointLink("logicservers") @BinderParam(BindToPath.class) UcsRackDto rack); - - /** - * @see InfrastructureApi#listServiceProfiles(UcsRackDto, QueryOptions) - */ - @Named("ucs:listserviceprofiles") - @EnterpriseEdition - @GET - @Consumes(LogicServersDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listServiceProfiles( - @EndpointLink("logicservers") @BinderParam(BindToPath.class) UcsRackDto rack, FilterOptions options); - - /** - * @see InfrastructureApi#listServiceProfileTemplates(UcsRackDto) - */ - @Named("ucs:listserviceprofiletemplates") - @EnterpriseEdition - @GET - @Consumes(LogicServersDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listServiceProfileTemplates( - @EndpointLink("ls-templates") @BinderParam(BindToPath.class) UcsRackDto rack); - - /** - * @see InfrastructureApi#listServiceProfileTemplates(UcsRackDto, - * LogicServerOptions) - */ - @Named("ucs:listserviceproviletemplates") - @EnterpriseEdition - @GET - @Consumes(LogicServersDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listServiceProfileTemplates( - @EndpointLink("ls-templates") @BinderParam(BindToPath.class) UcsRackDto rack, FilterOptions options); - - /** - * @see InfrastructureApi#listOrganizations(UcsRackDto) - */ - @Named("ucs:listorganizations") - @EnterpriseEdition - @GET - @Consumes(OrganizationsDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listOrganizations( - @EndpointLink("organizations") @BinderParam(BindToPath.class) UcsRackDto rack); - - /** - * @see InfrastructureApi#listOrganizations(UcsRackDto, OrganizationOptions) - */ - @Named("ucs:listorganizations") - @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) - */ - @Named("ucs:clonelogicserver") - @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) - */ - @Named("ucs:associatelogicserver") - @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) - */ - @Named("ucs:associatetemplate") - @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) - */ - @Named("ucs:cloneandassociatelogicserver") - @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) - */ - @Named("ucs:dissociatelogicserver") - @EnterpriseEdition - @POST - ListenableFuture dissociateLogicServer( - @EndpointLink("ls-dissociate") @BinderParam(BindToPath.class) UcsRackDto rack, - @BinderParam(BindLogicServerParameters.class) LogicServerDto logicServer); - - /** - * @see InfrastructureApi#deleteLogicServer(UcsRackDto, LogicServerDto) - */ - @Named("ucs:deletelogicserver") - @EnterpriseEdition - @POST - ListenableFuture deleteLogicServer(@EndpointLink("ls-delete") @BinderParam(BindToPath.class) UcsRackDto rack, - @BinderParam(BindLogicServerParameters.class) LogicServerDto logicServer); - - /** - * @see InfrastructureApi#listFsms(UcsRackDto, String) - */ - @Named("ucs:listfsms") - @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) - */ - @Named("rs:list") - @GET - @Consumes(RemoteServicesDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listRemoteServices( - @EndpointLink("remoteservices") @BinderParam(BindToPath.class) DatacenterDto datacenter); - - /** - * @see InfrastructureApi#createRemoteService(DatacenterDto, - * RemoteServiceDto) - */ - @Named("rs:create") - @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) - */ - @Named("rs:get") - @GET - @Consumes(RemoteServiceDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - @Fallback(NullOnNotFoundOr404.class) - ListenableFuture getRemoteService( - @EndpointLink("remoteservices") @BinderParam(BindToPath.class) final DatacenterDto datacenter, - @BinderParam(AppendRemoteServiceTypeToPath.class) final RemoteServiceType remoteServiceType); - - /** - * @see InfrastructureApi#updateRemoteService(RemoteServiceDto) - */ - @Named("rs:update") - @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) - */ - @Named("rs:delete") - @DELETE - ListenableFuture deleteRemoteService( - @EndpointLink("edit") @BinderParam(BindToPath.class) RemoteServiceDto remoteService); - - /** - * @see InfrastructureApi#isAvailable(RemoteServiceDto) - */ - @Named("rs:available") - @GET - @Fallback(FalseIfNotAvailable.class) - ListenableFuture isAvailable( - @EndpointLink("check") @BinderParam(BindToPath.class) RemoteServiceDto remoteService); - - /*********************** Machine ***********************/ - - /** - * @see InfrastructureApi#listMachines(RackDto) - */ - @Named("machine:list") - @GET - @Consumes(MachinesDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listMachines(@EndpointLink("machines") @BinderParam(BindToPath.class) RackDto rack); - - /** - * @see InfrastructureApi#createMachine(RackDto, MachineDto) - */ - @Named("machine:create") - @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) - */ - @Named("machine:get") - @GET - @Consumes(MachineDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - @Fallback(NullOnNotFoundOr404.class) - ListenableFuture getMachine(@EndpointLink("machines") @BinderParam(BindToPath.class) final RackDto rack, - @BinderParam(AppendToPath.class) Integer machineId); - - /** - * @see InfrastructureApi#checkMachineState(MachineDto) - */ - @Named("machine:checkstate") - @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) - */ - @Named("machine:checkipmi") - @GET - @Consumes(MachineIpmiStateDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture checkMachineIpmiState( - @EndpointLink("checkipmistate") @BinderParam(BindToPath.class) final MachineDto machine); - - /** - * @see InfrastructureApi#updateMachine(MachineDto) - */ - @Named("machine:update") - @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) - */ - @Named("machine:delete") - @DELETE - ListenableFuture deleteMachine(@EndpointLink("edit") @BinderParam(BindToPath.class) MachineDto machine); - - /** - * @see InfrastructureApi#reserveMachine(EnterpriseDto, MachineDto) - */ - @Named("machine:reserve") - @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) - */ - @Named("machine:cancelreservation") - @DELETE - ListenableFuture cancelReservation( - @EndpointLink("reservedmachines") @BinderParam(BindToPath.class) EnterpriseDto enterprise, - @BinderParam(AppendMachineIdToPath.class) MachineDto machine); - - /*********************** Blade ***********************/ - - /** - * @see InfrastructureApi#powerOff(MachineDto) - */ - @Named("machine:poweroff") - @EnterpriseEdition - @PUT - ListenableFuture powerOff(@EndpointLink("poweroff") @BinderParam(BindToPath.class) MachineDto machine); - - /** - * @see InfrastructureApi#powerOn(MachineDto) - */ - @Named("machine:poweron") - @EnterpriseEdition - @PUT - ListenableFuture powerOn(@EndpointLink("poweron") @BinderParam(BindToPath.class) MachineDto machine); - - /** - * @see InfrastructureApi#getLogicServer(MachineDto) - */ - @Named("machine:getlogicserver") - @EnterpriseEdition - @GET - @Consumes(LogicServerDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture getLogicServer( - @EndpointLink("logicserver") @BinderParam(BindToPath.class) MachineDto machine); - - /** - * @see InfrastructureApi#ledOn(MachineDto) - */ - @Named("machine:ledon") - @EnterpriseEdition - @POST - ListenableFuture ledOn(@EndpointLink("ledon") @BinderParam(BindToPath.class) MachineDto machine); - - /** - * @see InfrastructureApi#ledOff(MachineDto) - */ - @Named("machine:ledoff") - @EnterpriseEdition - @POST - ListenableFuture ledOff(@EndpointLink("ledoff") @BinderParam(BindToPath.class) MachineDto machine); - - /** - * @see InfrastructureApi#getLedLocator(MachineDto) - */ - @Named("machine:getlocatorled") - @EnterpriseEdition - @GET - @Consumes(BladeLocatorLedDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture getLocatorLed( - @EndpointLink("led") @BinderParam(BindToPath.class) MachineDto machine); - - /** - * @see InfrastructureApi#listVirtualMachinesByMachine(MachineDto) - */ - @Named("machine:listvms") - @GET - @Consumes(VirtualMachinesWithNodeExtendedDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listVirtualMachinesByMachine( - @EndpointLink("virtualmachines") @BinderParam(BindToPath.class) MachineDto machine, MachineOptions options); - - /** - * @see InfrastructureApi#getVirtualMachine(MachineDto, Integer) - */ - @Named("machine:getvm") - @GET - @Fallback(NullOnNotFoundOr404.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) - */ - @Named("storagedevice:list") - @EnterpriseEdition - @GET - @Consumes(StorageDevicesDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listStorageDevices( - @EndpointLink("devices") @BinderParam(BindToPath.class) DatacenterDto datacenter); - - /** - * @see InfrastructureApi#listSupportedStorageDevices(DatacenterDto) - */ - @Named("storagedevice:listsupported") - @EnterpriseEdition - @GET - @Consumes(StorageDevicesMetadataDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listSupportedStorageDevices( - @EndpointLink("devices") @BinderParam(BindSupportedDevicesLinkToPath.class) DatacenterDto datacenter); - - /** - * @see InfrastructureApi#getStorageDevice(DatacenterDto, Integer) - */ - @Named("storagedevice:get") - @EnterpriseEdition - @GET - @Consumes(StorageDeviceDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - @Fallback(NullOnNotFoundOr404.class) - ListenableFuture getStorageDevice( - @EndpointLink("devices") @BinderParam(BindToPath.class) DatacenterDto datacenter, - @BinderParam(AppendToPath.class) Integer storageDeviceId); - - /** - * @see InfrastructureApi#createStorageDevice(DatacenterDto, - * StorageDeviceDto) - */ - @Named("storagedevice:create") - @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) - */ - @Named("storagedevice:delete") - @EnterpriseEdition - @DELETE - ListenableFuture deleteStorageDevice( - @EndpointLink("edit") @BinderParam(BindToPath.class) StorageDeviceDto storageDevice); - - /** - * @see InfrastructureApi#updateStorageDevice(StorageDeviceDto) - */ - @Named("storagedevice:update") - @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) - */ - @Named("tier:list") - @EnterpriseEdition - @GET - @Consumes(TiersDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listTiers(@EndpointLink("tiers") @BinderParam(BindToPath.class) DatacenterDto datacenter); - - /** - * @see InfrastructureApi#updateTier(TierDto) - */ - @Named("tier:update") - @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) - */ - @Named("tier:get") - @EnterpriseEdition - @GET - @Consumes(TierDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - @Fallback(NullOnNotFoundOr404.class) - ListenableFuture getTier(@EndpointLink("tiers") @BinderParam(BindToPath.class) DatacenterDto datacenter, - @BinderParam(AppendToPath.class) Integer tierId); - - /*********************** Storage Pool ***********************/ - - /** - * @see InfrastructureApi#listStoragePools(StorageDeviceDto, - * StoragePoolOptions) - */ - @Named("storagepool:list") - @EnterpriseEdition - @GET - @Consumes(StoragePoolsDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listStoragePools( - @EndpointLink("pools") @BinderParam(BindToPath.class) StorageDeviceDto storageDevice, - StoragePoolOptions options); - - /** - * @see InfrastructureApi#listStoragePools(TierDto) - */ - @Named("storagepool:list") - @EnterpriseEdition - @GET - @Consumes(StoragePoolsDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listStoragePools(@EndpointLink("pools") @BinderParam(BindToPath.class) TierDto tier); - - /** - * @see InfrastructureApi#createStoragePool(StorageDeviceDto, StoragePoolDto) - */ - @Named("storagepool:create") - @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) - */ - @Named("storagepool:update") - @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) - */ - @Named("storagepool:delete") - @EnterpriseEdition - @DELETE - ListenableFuture deleteStoragePool( - @EndpointLink("edit") @BinderParam(BindToPath.class) StoragePoolDto storagePool); - - /** - * @see InfrastructureApi#getStoragePool(StorageDeviceDto, String) - */ - @Named("storagepool:get") - @EnterpriseEdition - @GET - @Consumes(StoragePoolDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - @Fallback(NullOnNotFoundOr404.class) - ListenableFuture getStoragePool( - @EndpointLink("pools") @BinderParam(BindToPath.class) final StorageDeviceDto storageDevice, - @BinderParam(AppendToPath.class) final String storagePoolId); - - /** - * @see InfrastructureApi#refreshStoragePool(StoragePoolDto, - * StoragePoolOptions) - */ - @Named("storagepool:refresh") - @EnterpriseEdition - @GET - @Consumes(StoragePoolDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture refreshStoragePool( - @EndpointLink("edit") @BinderParam(BindToPath.class) StoragePoolDto storagePool, StoragePoolOptions options); - - /*********************** Network ***********************/ - - /** - * @see InfrastructureApi#listNetworks(DatacenterDto) - */ - @Named("network:list") - @EnterpriseEdition - @GET - @Consumes(VLANNetworksDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listNetworks( - @EndpointLink("network") @BinderParam(BindToPath.class) DatacenterDto datacenter); - - /** - * @see InfrastructureApi#listNetwork(DatacenterDto, NetworkOptions) - */ - @Named("network:list") - @EnterpriseEdition - @GET - @Consumes(VLANNetworksDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listNetworks( - @EndpointLink("network") @BinderParam(BindToPath.class) DatacenterDto datacenter, NetworkOptions options); - - /** - * @see InfrastructureApi#getNetwork(DatacenterDto, Integer) - */ - @Named("network:get") - @EnterpriseEdition - @GET - @Consumes(VLANNetworkDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - @Fallback(NullOnNotFoundOr404.class) - ListenableFuture getNetwork( - @EndpointLink("network") @BinderParam(BindToPath.class) DatacenterDto datacenter, - @BinderParam(AppendToPath.class) Integer networkId); - - /** - * @see InfrastructureApi#createNetwork(DatacenterDto, VLANNetworkDto) - */ - @Named("network:create") - @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) - */ - @Named("network:update") - @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) - */ - @Named("network:delete") - @EnterpriseEdition - @DELETE - ListenableFuture deleteNetwork(@EndpointLink("edit") @BinderParam(BindToPath.class) VLANNetworkDto network); - - /** - * @see InfrastructureApi#checkTagAvailability(DatacenterDto, Integer) - */ - @Named("network:checktag") - @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) - */ - @Named("publicnetwork:listips") - @GET - @Consumes(PublicIpsDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listPublicIps( - @EndpointLink("ips") @BinderParam(BindToPath.class) VLANNetworkDto network); - - /** - * @see InfrastructureApi#listPublicIps(VLANNetworkDto, IpOptions) - */ - @Named("publicnetwork:listips") - @GET - @Consumes(PublicIpsDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listPublicIps( - @EndpointLink("ips") @BinderParam(BindToPath.class) VLANNetworkDto network, IpOptions options); - - /** - * @see InfrastructureApi#getPublicIp(VLANNetworkDto, Integer) - */ - @Named("publicnetwork:getip") - @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) - */ - @Named("externalnetwork:listips") - @GET - @Consumes(ExternalIpsDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listExternalIps( - @EndpointLink("ips") @BinderParam(BindToPath.class) VLANNetworkDto network); - - /** - * @see InfrastructureApi#listExternalIps(VLANNetworkDto, IpOptions) - */ - @Named("externalnetwork:listips") - @GET - @Consumes(ExternalIpsDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listExternalIps( - @EndpointLink("ips") @BinderParam(BindToPath.class) VLANNetworkDto network, IpOptions options); - - /** - * @see InfrastructureApi#getExternalIp(VLANNetworkDto, Integer) - */ - @Named("externalnetwork:getip") - @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) - */ - @Named("unmanagednetwork:listips") - @GET - @Consumes(UnmanagedIpsDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listUnmanagedIps( - @EndpointLink("ips") @BinderParam(BindToPath.class) VLANNetworkDto network); - - /** - * @see InfrastructureApi#listUnmanagedIps(VLANNetworkDto, IpOptions) - */ - @Named("unmanagednetwork:listips") - @GET - @Consumes(UnmanagedIpsDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listUnmanagedIps( - @EndpointLink("ips") @BinderParam(BindToPath.class) VLANNetworkDto network, IpOptions options); - - /** - * @see InfrastructureApi#getUnmanagedIp(VLANNetworkDto, Integer) - */ - @Named("unmanagednetwork:getip") - @GET - @Consumes(UnmanagedIpDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture getUnmanagedIp( - @EndpointLink("ips") @BinderParam(BindToPath.class) VLANNetworkDto network, - @BinderParam(AppendToPath.class) Integer ipId); - - /***************************** NETWORK SERVICE TYPES *******************************************/ - - /** - * @see InfrastructureApi#listNetworkServiceTypes(DatacenterDto) - */ - @Named("networkservicetype:list") - @GET - @Consumes(NetworkServiceTypesDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listNetworkServiceTypes( - @EndpointLink("networkservicetypes") @BinderParam(BindToPath.class) DatacenterDto datacenter); - - /** - * @see InfrastructureApi#createNetworkServiceType(DatacenterDto, - * NetworkServiceTypeDto) - */ - @Named("networkservicetype:create") - @POST - @Produces(NetworkServiceTypeDto.BASE_MEDIA_TYPE) - @Consumes(NetworkServiceTypeDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture createNetworkServiceType( - @EndpointLink("networkservicetypes") @BinderParam(BindToPath.class) DatacenterDto datacenter, - @BinderParam(BindToXMLPayload.class) NetworkServiceTypeDto nst); - - /** - * @see InfrastructureApi#getNetworkServiceType(DatacenterDto, Integer) - */ - @Named("networkservicetype:get") - @GET - @Consumes(NetworkServiceTypeDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - @Fallback(NullOnNotFoundOr404.class) - ListenableFuture getNetworkServiceType( - @EndpointLink("networkservicetypes") @BinderParam(BindToPath.class) DatacenterDto datacenter, - @BinderParam(AppendToPath.class) Integer nstId); - - /** - * Update the value of a {@link NetworkServiceTypeDto} - * - * @param nstDto - * the instance to update with the new values. - * @return the updated entity. - */ - @Named("networkservicetype:update") - @PUT - @Produces(NetworkServiceTypeDto.BASE_MEDIA_TYPE) - @Consumes(NetworkServiceTypeDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture updateNetworkServiceType( - @EndpointLink("edit") @BinderParam(BindToXMLPayloadAndPath.class) NetworkServiceTypeDto nstDto); - - /** - * Remove a {@link NetworkServiceTypeDto} entity. - * - * @param nstDto - * the entity to delete - */ - @Named("networkservicetype:delete") - @DELETE - ListenableFuture deleteNetworkServiceType( - @EndpointLink("edit") @BinderParam(BindToPath.class) NetworkServiceTypeDto nstDto); -} 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 deleted file mode 100644 index c36a4e5a6d..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/features/PricingApi.java +++ /dev/null @@ -1,252 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.abiquo.features; - -import com.abiquo.server.core.pricing.CostCodeCurrenciesDto; -import com.abiquo.server.core.pricing.CostCodeDto; -import com.abiquo.server.core.pricing.CostCodesDto; -import com.abiquo.server.core.pricing.CurrenciesDto; -import com.abiquo.server.core.pricing.CurrencyDto; -import com.abiquo.server.core.pricing.PricingCostCodeDto; -import com.abiquo.server.core.pricing.PricingCostCodesDto; -import com.abiquo.server.core.pricing.PricingTemplateDto; -import com.abiquo.server.core.pricing.PricingTemplatesDto; -import com.abiquo.server.core.pricing.PricingTierDto; -import com.abiquo.server.core.pricing.PricingTiersDto; - -/** - * Provides synchronous access to Abiquo Pricing API. - * - * @see API: - * http://community.abiquo.com/display/ABI20/APIReference - * @see PricingAsyncApi - * @author Ignasi Barrera - * @author Susana Acedo - */ -public interface PricingApi { - - /*********************** Currency ********************** */ - - /** - * 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); - - /** - * 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); - - /** - * Deletes an existing currency - * - * @param currency - * The currency to delete - */ - void deleteCurrency(final CurrencyDto currency); - - /*********************** CostCode ********************** */ - - /** - * 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); - - /** - * 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); - - /** - * Deletes an existing costcode - * - * @param currency - * The costcode to delete - */ - void deleteCostCode(CostCodeDto costcode); - - /*********************** PricingTemplate ********************** */ - - /** - * 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); - - /** - * 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); - - /** - * Deletes an existing pricingtemplate - * - * @param pricingtemplate - * The pricingtemplate to delete - */ - void deletePricingTemplate(PricingTemplateDto pricingtemplate); - - /*********************** CostCodeCurrency ********************** */ - - /** - * 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); - - /*********************** PricingTemplateCostCode ********************** */ - - /** - * 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); - - /** - * 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 ********************** */ - - /** - * 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); - - /** - * 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 deleted file mode 100644 index 87936a8fbe..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/features/PricingAsyncApi.java +++ /dev/null @@ -1,328 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.abiquo.features; - -import javax.inject.Named; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; - -import org.jclouds.Fallbacks.NullOnNotFoundOr404; -import org.jclouds.abiquo.binders.BindToPath; -import org.jclouds.abiquo.binders.BindToXMLPayloadAndPath; -import org.jclouds.abiquo.http.filters.AbiquoAuthentication; -import org.jclouds.abiquo.http.filters.AppendApiVersionToMediaType; -import org.jclouds.abiquo.rest.annotations.EndpointLink; -import org.jclouds.rest.annotations.BinderParam; -import org.jclouds.rest.annotations.Fallback; -import org.jclouds.rest.annotations.JAXBResponseParser; -import org.jclouds.rest.annotations.RequestFilters; -import org.jclouds.rest.binders.BindToXMLPayload; - -import com.abiquo.server.core.pricing.CostCodeCurrenciesDto; -import com.abiquo.server.core.pricing.CostCodeDto; -import com.abiquo.server.core.pricing.CostCodesDto; -import com.abiquo.server.core.pricing.CurrenciesDto; -import com.abiquo.server.core.pricing.CurrencyDto; -import com.abiquo.server.core.pricing.PricingCostCodeDto; -import com.abiquo.server.core.pricing.PricingCostCodesDto; -import com.abiquo.server.core.pricing.PricingTemplateDto; -import com.abiquo.server.core.pricing.PricingTemplatesDto; -import com.abiquo.server.core.pricing.PricingTierDto; -import com.abiquo.server.core.pricing.PricingTiersDto; -import com.google.common.util.concurrent.ListenableFuture; - -/** - * Provides synchronous access to Abiquo Pricing API. - * - * @see API: - * http://community.abiquo.com/display/ABI20/APIReference - * @see PricingAsyncApi - * @author Ignasi Barrera - * @author Susana Acedo - */ -@RequestFilters({ AbiquoAuthentication.class, AppendApiVersionToMediaType.class }) -@Path("/config") -public interface PricingAsyncApi { - /*********************** Currency ********************** */ - - /** - * @see ConfigApi#listCurrencies() - */ - @Named("currency:list") - @GET - @Path("/currencies") - @Consumes(CurrenciesDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listCurrencies(); - - /** - * @see ConfigApi#getCurrency(Integer) - */ - @Named("currency:get") - @GET - @Path("/currencies/{currency}") - @Consumes(CurrencyDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - @Fallback(NullOnNotFoundOr404.class) - ListenableFuture getCurrency(@PathParam("currency") Integer currencyId); - - /** - * @see ConfigApi#createCurrency(CurrencyDto) - */ - @Named("currency:create") - @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) - */ - @Named("currency:update") - @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) - */ - @Named("currency:delete") - @DELETE - ListenableFuture deleteCurrency(@EndpointLink("edit") @BinderParam(BindToPath.class) CurrencyDto currency); - - /*********************** CostCode ********************** */ - - /** - * @see PricingApi#listCostCodes() - */ - @Named("costcode:list") - @GET - @Path("/costcodes") - @Consumes(CostCodesDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listCostCodes(); - - /** - * @see PricingApi#getCostCode(Integer) - */ - @Named("costcode:get") - @GET - @Path("/costcodes/{costcode}") - @Consumes(CostCodeDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - @Fallback(NullOnNotFoundOr404.class) - ListenableFuture getCostCode(@PathParam("costcode") Integer costcodeId); - - /** - * @see PricingApi#createCostCode(CostCodeDto) - */ - @Named("costcode:create") - @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) - */ - @Named("costcode:update") - @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) - */ - @Named("costcode:delete") - @DELETE - ListenableFuture deleteCostCode(@EndpointLink("edit") @BinderParam(BindToPath.class) CostCodeDto costcode); - - /*********************** PricingTemplate ********************** */ - - /** - * @see PricingApi#listPricingTemplates() - */ - @Named("pricingtemplate:list") - @GET - @Path("/pricingtemplates") - @Consumes(PricingTemplatesDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listPricingTemplates(); - - /** - * @see PricingApi#getPricingTemplate(Integer) - */ - @Named("pricingtemplate:get") - @GET - @Path("/pricingtemplates/{pricingtemplate}") - @Consumes(PricingTemplateDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - @Fallback(NullOnNotFoundOr404.class) - ListenableFuture getPricingTemplate(@PathParam("pricingtemplate") Integer pricingTemplateId); - - /** - * @see PricingApi#createPricingTemplate(PricingTemplateDto) - */ - @Named("pricingtemplate:create") - @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) - */ - @Named("pricingtemplate:update") - @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) - */ - @Named("pricingtemplate:delete") - @DELETE - ListenableFuture deletePricingTemplate( - @EndpointLink("edit") @BinderParam(BindToPath.class) PricingTemplateDto pricingtemplate); - - /*********************** CostCodeCurrency ********************** */ - - /** - * @see PricingApi#getCostCodeCurrency(Integer) - */ - @Named("costcodecurrency:get") - @GET - @Path("/costcodes/{costcode}/currencies") - @Consumes(CostCodeCurrenciesDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - @Fallback(NullOnNotFoundOr404.class) - ListenableFuture getCostCodeCurrencies(@PathParam("costcode") Integer costcodeId, - @QueryParam("idCurrency") Integer currencyId); - - /** - * @see PricingApi#updateCostCodeCurrencies(CostCodeCurrenciesDto) - */ - @Named("costcodecurrency:update") - @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 ********************** */ - - /** - * @see PricingApi#getPricingCostCodes(Integer) - */ - @Named("pricingcostcode:get") - @GET - @Path("/pricingtemplates/{pricingtemplate}/costcodes") - @Consumes(PricingCostCodesDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - @Fallback(NullOnNotFoundOr404.class) - ListenableFuture getPricingCostCodes(@PathParam("pricingtemplate") Integer pricingTemplateId); - - /** - * @see PricingApi#getPricingCostCode(Integer) - */ - @Named("pricingcostcode:get") - @GET - @Path("/pricingtemplates/{pricingtemplate}/costcodes/{costcode}") - @Consumes(PricingCostCodeDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - @Fallback(NullOnNotFoundOr404.class) - ListenableFuture getPricingCostCode(@PathParam("pricingtemplate") Integer pricingTemplateId, - @PathParam("costcode") Integer pricingCostcodeId); - - /** - * @see PricingApi#updatePricingCostCode(PricingCostCodeDto) - */ - @Named("pricingcostcode:update") - @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 ********************** */ - - /** - * @see PricingApi#getPricingTiers(Integer) - */ - @Named("pricingtier:get") - @GET - @Path("/pricingtemplates/{pricingtemplate}/tiers") - @Consumes(PricingTiersDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - @Fallback(NullOnNotFoundOr404.class) - ListenableFuture getPricingTiers(@PathParam("pricingtemplate") Integer pricingTemplateId); - - /** - * @see PricingApi#getPricingTier(Integer) - */ - @Named("pricingtier:get") - @GET - @Path("/pricingtemplates/{pricingtemplate}/tiers/{tier}") - @Consumes(PricingTierDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - @Fallback(NullOnNotFoundOr404.class) - ListenableFuture getPricingTier(@PathParam("pricingtemplate") Integer pricingTemplateId, - @PathParam("tier") Integer pricingTierId); - - /** - * @see PricingApi#updatePricingTier(PricingTierDto) - */ - @Named("pricingtier:update") - @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 deleted file mode 100644 index 12a9d81d6a..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/features/TaskApi.java +++ /dev/null @@ -1,56 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.features; - -import com.abiquo.model.rest.RESTLink; -import com.abiquo.model.transport.SingleResourceTransportDto; -import com.abiquo.server.core.task.TaskDto; -import com.abiquo.server.core.task.TasksDto; - -/** - * Provides synchronous access to Abiquo Task API. - * - * @see API: - * http://community.abiquo.com/display/ABI20/API+Reference - * @see TaskAsyncApi - * @author Ignasi Barrera - * @author Francesc Montserrat - */ -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 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 deleted file mode 100644 index 0832a9bd65..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/features/TaskAsyncApi.java +++ /dev/null @@ -1,75 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.features; - -import javax.inject.Named; -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; - -import org.jclouds.abiquo.AbiquoFallbacks.NullOn303; -import org.jclouds.abiquo.binders.BindLinkToPath; -import org.jclouds.abiquo.binders.BindToPath; -import org.jclouds.abiquo.http.filters.AbiquoAuthentication; -import org.jclouds.abiquo.http.filters.AppendApiVersionToMediaType; -import org.jclouds.abiquo.rest.annotations.EndpointLink; -import org.jclouds.rest.annotations.BinderParam; -import org.jclouds.rest.annotations.Fallback; -import org.jclouds.rest.annotations.JAXBResponseParser; -import org.jclouds.rest.annotations.RequestFilters; - -import com.abiquo.model.rest.RESTLink; -import com.abiquo.model.transport.SingleResourceTransportDto; -import com.abiquo.server.core.task.TaskDto; -import com.abiquo.server.core.task.TasksDto; -import com.google.common.util.concurrent.ListenableFuture; - -/** - * Provides asynchronous access to Abiquo Task API. - * - * @see API: - * http://community.abiquo.com/display/ABI20/API+Reference - * @see TaskApi - * @author Ignasi Barrera - * @author Francesc Montserrat - */ -@RequestFilters({ AbiquoAuthentication.class, AppendApiVersionToMediaType.class }) -public interface TaskAsyncApi { - /*********************** Task ***********************/ - - /** - * @see TaskApi#getTask(RESTLink) - */ - @Named("task:get") - @GET - @Consumes(TaskDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - @Fallback(NullOn303.class) - ListenableFuture getTask(@BinderParam(BindLinkToPath.class) RESTLink link); - - /** - * @see TaskApi#listTasks(SingleResourceTransportDto) - */ - @Named("task:list") - @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 deleted file mode 100644 index c673c52667..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/features/VirtualMachineTemplateApi.java +++ /dev/null @@ -1,171 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.features; - -import org.jclouds.abiquo.domain.cloud.options.ConversionOptions; -import org.jclouds.abiquo.domain.cloud.options.VirtualMachineTemplateOptions; - -import com.abiquo.model.enumerator.DiskFormatType; -import com.abiquo.model.transport.AcceptedRequestDto; -import com.abiquo.server.core.appslibrary.ConversionDto; -import com.abiquo.server.core.appslibrary.ConversionsDto; -import com.abiquo.server.core.appslibrary.VirtualMachineTemplateDto; -import com.abiquo.server.core.appslibrary.VirtualMachineTemplatePersistentDto; -import com.abiquo.server.core.appslibrary.VirtualMachineTemplatesDto; - -/** - * Provides synchronous access to Abiquo Apps library API. - * - * @see API: - * http://community.abiquo.com/display/ABI20/API+Reference - * @see VirtualMachineTemplateAsyncApi - * @author Ignasi Barrera - * @author Francesc Montserrat - */ -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 containing 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 containing 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 containing 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 enterpriseId, 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); - - /** - * 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. - */ - 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 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); - - /** - * 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 deleted file mode 100644 index 83a1769aaa..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/features/VirtualMachineTemplateAsyncApi.java +++ /dev/null @@ -1,196 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.features; - -import javax.inject.Named; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; - -import org.jclouds.Fallbacks.NullOnNotFoundOr404; -import org.jclouds.abiquo.binders.AppendToPath; -import org.jclouds.abiquo.binders.BindToPath; -import org.jclouds.abiquo.binders.BindToXMLPayloadAndPath; -import org.jclouds.abiquo.domain.cloud.options.ConversionOptions; -import org.jclouds.abiquo.domain.cloud.options.VirtualMachineTemplateOptions; -import org.jclouds.abiquo.functions.ReturnTaskReferenceOrNull; -import org.jclouds.abiquo.http.filters.AbiquoAuthentication; -import org.jclouds.abiquo.http.filters.AppendApiVersionToMediaType; -import org.jclouds.abiquo.rest.annotations.EndpointLink; -import org.jclouds.rest.annotations.BinderParam; -import org.jclouds.rest.annotations.Fallback; -import org.jclouds.rest.annotations.JAXBResponseParser; -import org.jclouds.rest.annotations.RequestFilters; -import org.jclouds.rest.annotations.ResponseParser; -import org.jclouds.rest.binders.BindToXMLPayload; - -import com.abiquo.model.enumerator.DiskFormatType; -import com.abiquo.model.transport.AcceptedRequestDto; -import com.abiquo.server.core.appslibrary.ConversionDto; -import com.abiquo.server.core.appslibrary.ConversionsDto; -import com.abiquo.server.core.appslibrary.DatacenterRepositoryDto; -import com.abiquo.server.core.appslibrary.VirtualMachineTemplateDto; -import com.abiquo.server.core.appslibrary.VirtualMachineTemplatePersistentDto; -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: - * - * http://community.abiquo.com/display/ABI20/API+Reference - * - * @see VirtualMachineTemplateApi - * @author Ignasi Barrera - * @author Francesc Montserrat - */ -@RequestFilters({ AbiquoAuthentication.class, AppendApiVersionToMediaType.class }) -@Path("/admin/enterprises") -public interface VirtualMachineTemplateAsyncApi { - /*********************** Virtual Machine Template ***********************/ - - /** - * @see VirtualMachineTemplateApi#listVirtualMachineTemplates(Integer, - * Integer) - */ - @Named("template:list") - @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) - */ - @Named("template:list") - @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) - */ - @Named("template:get") - @GET - @Path("/{enterprise}/datacenterrepositories/{datacenterrepository}/virtualmachinetemplates/{virtualmachinetemplate}") - @Consumes(VirtualMachineTemplateDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - @Fallback(NullOnNotFoundOr404.class) - ListenableFuture getVirtualMachineTemplate(@PathParam("enterprise") Integer enterpriseId, - @PathParam("datacenterrepository") Integer datacenterRepositoryId, - @PathParam("virtualmachinetemplate") Integer virtualMachineTemplateId); - - /** - * @see VirtualMachineTemplateApi#updateVirtualMachineTemplate(VirtualMachineTemplateDto) - */ - @Named("template:update") - @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) - */ - @Named("template:delete") - @DELETE - ListenableFuture deleteVirtualMachineTemplate( - @EndpointLink("edit") @BinderParam(BindToPath.class) VirtualMachineTemplateDto template); - - /** - * @see VirtualMachineTemplateApi#createPersistentVirtualMachineTemplate(DatacenterRepositoryDto, - * VirtualMachineTemplatePersistentDto) - */ - @Named("template:createpersistent") - @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 ***********************/ - - /** - * @see VirtualMachineTemplateApi#listConversions(VirtualMachineTemplateDto) - */ - @Named("conversion:list") - @GET - @Consumes(ConversionsDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listConversions( - @EndpointLink("conversions") @BinderParam(BindToPath.class) VirtualMachineTemplateDto template); - - /** - * @see VirtualMachineTemplateApi#listConversions(VirtualMachineTemplateDto, - * ConversionOptions) - */ - @Named("conversion:list") - @GET - @Consumes(ConversionsDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listConversions( - @EndpointLink("conversions") @BinderParam(BindToPath.class) final VirtualMachineTemplateDto template, - ConversionOptions options); - - /** - * @see VirtualMachineTemplateApi#getConversion(VirtualMachineTemplateDto, - * DiskFormatType) - */ - @Named("conversion:get") - @GET - @Consumes(ConversionDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - @Fallback(NullOnNotFoundOr404.class) - ListenableFuture getConversion( - @EndpointLink("conversions") @BinderParam(BindToPath.class) final VirtualMachineTemplateDto template, - @BinderParam(AppendToPath.class) DiskFormatType targetFormat); - - /** - * @see VirtualMachineTemplateApi#updateConversion(ConversionDto) - */ - @Named("conversion:request") - @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 deleted file mode 100644 index b73e35e9f2..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/features/services/AdministrationService.java +++ /dev/null @@ -1,259 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.features.services; - -import org.jclouds.abiquo.domain.config.Category; -import org.jclouds.abiquo.domain.config.License; -import org.jclouds.abiquo.domain.config.Privilege; -import org.jclouds.abiquo.domain.config.SystemProperty; -import org.jclouds.abiquo.domain.enterprise.Enterprise; -import org.jclouds.abiquo.domain.enterprise.EnterpriseProperties; -import org.jclouds.abiquo.domain.enterprise.Role; -import org.jclouds.abiquo.domain.enterprise.User; -import org.jclouds.abiquo.domain.infrastructure.Datacenter; -import org.jclouds.abiquo.domain.infrastructure.Machine; -import org.jclouds.abiquo.internal.BaseAdministrationService; - -import com.google.common.base.Predicate; -import com.google.inject.ImplementedBy; - -/** - * Provides high level Abiquo administration operations. - * - * @author Ignasi Barrera - * @author Francesc Montserrat - */ -@ImplementedBy(BaseAdministrationService.class) -public interface AdministrationService { - /*********************** Datacenter ***********************/ - - /** - * Get the list of all datacenters. - */ - Iterable listDatacenters(); - - /** - * 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 datacenter with the given id. - */ - Datacenter getDatacenter(final Integer datacenterId); - - /*********************** Machine ***********************/ - - /** - * 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 first machine in the infrastructure that matches the given filter. - */ - public Machine findMachine(Predicate filter); - - /*********************** Enterprise ***********************/ - - /** - * Get the list of all enterprises. - */ - Iterable listEnterprises(); - - /** - * 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 enterprise with the given id. - */ - Enterprise getEnterprise(final Integer enterpriseId); - - /*********************** Enterprise Properties ***********************/ - /** - * Get the properties of an enterprise. - */ - EnterpriseProperties getEnterpriseProperties(final Enterprise enterprise); - - /*********************** Role ***********************/ - - /** - * Get the list of global roles. - */ - Iterable listRoles(); - - /** - * 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 role with the given id. - */ - Role getRole(final Integer roleId); - - /*********************** Privilege ***********************/ - - /** - * Get the list of global privileges. - */ - Iterable listPrivileges(); - - /** - * 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 a privilege given its id. - * - * @param privilegeId - * The id of the privilege. - * @return The privilege. - */ - Privilege getPrivilege(Integer privilegeId); - - /*********************** User ***********************/ - - /** - * Get the current user. - */ - User getCurrentUser(); - - /** - * Get the enterprise of the current user. - */ - Enterprise getCurrentEnterprise(); - - /*********************** License ***********************/ - - /** - * 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 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); - - /*********************** System Properties ***********************/ - - /** - * 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 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 list of system properties with options. - */ - Iterable listSystemProperties(String component); - - /*********************** Category ***********************/ - - /** - * Get the list of categories. - */ - Iterable listCategories(); - - /** - * 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 category identified by the given id. - * - * @param categoryId - * The id of the category. - * @return The requested category. - */ - Category getCategory(Integer categoryId); -} 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 deleted file mode 100644 index 9ab79e84c8..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/features/services/CloudService.java +++ /dev/null @@ -1,112 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.features.services; - -import java.util.List; - -import org.jclouds.abiquo.domain.cloud.VirtualAppliance; -import org.jclouds.abiquo.domain.cloud.VirtualDatacenter; -import org.jclouds.abiquo.domain.cloud.VirtualMachine; -import org.jclouds.abiquo.domain.enterprise.Enterprise; -import org.jclouds.abiquo.internal.BaseCloudService; - -import com.google.common.base.Predicate; -import com.google.inject.ImplementedBy; - -/** - * Provides high level Abiquo cloud operations. - * - * @author Ignasi Barrera - * @author Francesc Montserrat - */ -@ImplementedBy(BaseCloudService.class) -public interface CloudService { - /*********************** Virtual Datacenter ***********************/ - - /** - * 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 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 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); - - /*********************** Virtual Appliance ***********************/ - - /** - * 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 first virtual appliance that matches the given filter. - */ - VirtualAppliance findVirtualAppliance(Predicate filter); - - /*********************** Virtual Machine ***********************/ - - /** - * 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 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 deleted file mode 100644 index 37fdaf373c..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/features/services/EventService.java +++ /dev/null @@ -1,45 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.features.services; - -import org.jclouds.abiquo.domain.event.Event; -import org.jclouds.abiquo.domain.event.options.EventOptions; -import org.jclouds.abiquo.internal.BaseEventService; - -import com.google.inject.ImplementedBy; - -/** - * Provides high level Abiquo event operations. - * - * @author Ignasi Barrera - * @author Vivien Mahé - */ -@ImplementedBy(BaseEventService.class) -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); -} 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 deleted file mode 100644 index 812134bff3..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/features/services/MonitoringService.java +++ /dev/null @@ -1,151 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.features.services; - -import java.util.concurrent.TimeUnit; - -import org.jclouds.abiquo.events.handlers.AbstractEventHandler; -import org.jclouds.abiquo.internal.BaseMonitoringService; -import org.jclouds.abiquo.monitor.AsyncTaskMonitor; -import org.jclouds.abiquo.monitor.ConversionMonitor; -import org.jclouds.abiquo.monitor.MonitorStatus; -import org.jclouds.abiquo.monitor.VirtualApplianceMonitor; -import org.jclouds.abiquo.monitor.VirtualMachineMonitor; - -import com.google.common.base.Function; -import com.google.inject.ImplementedBy; - -/** - * Utility service to monitor asynchronous operations. - * - * @author Ignasi Barrera - * @author Francesc Montserrat - */ -@ImplementedBy(BaseMonitoringService.class) -public interface MonitoringService { - - /*************** 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 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 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 ***************/ - - /** - * 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); - - /*************** Delegating monitors ***************/ - - /** - * 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 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(); -} 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 deleted file mode 100644 index dc55123306..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/features/services/PricingService.java +++ /dev/null @@ -1,156 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.features.services; - -import java.util.Collection; - -import org.jclouds.abiquo.domain.config.CostCode; -import org.jclouds.abiquo.domain.config.CostCodeCurrency; -import org.jclouds.abiquo.domain.config.Currency; -import org.jclouds.abiquo.domain.config.PricingCostCode; -import org.jclouds.abiquo.domain.config.PricingTemplate; -import org.jclouds.abiquo.domain.config.PricingTier; -import org.jclouds.abiquo.internal.BasePricingService; - -import com.google.common.base.Predicate; -import com.google.inject.ImplementedBy; - -/** - * Provides high level Abiquo administration operations. - * - * @author Ignasi Barrera - * @author Susana Acedo - */ -@ImplementedBy(BasePricingService.class) -public interface PricingService { - - /*********************** Currency ***********************/ - - /** - * Get the list of currencies. - */ - Iterable listCurrencies(); - - /** - * 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 currency with the given id. - * - * @param currencyId - * The id of the currency to get. - * @return The currency with the gicen id. - */ - Currency getCurrency(final Integer currencyId); - - /*********************** CostCode ***********************/ - - /** - * Get the list of costcodes. - */ - Iterable listCostCodes(); - - /** - * 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 a cost code given its id. - * - * @param costCodeId - * The id of the cost code. - * @return The cost code. - */ - CostCode getCostCode(Integer costCodeId); - - /*********************** PricingTemplate ***********************/ - - /** - * Get the list of pricingtemplates. - */ - Iterable listPricingTemplates(); - - /** - * Get the list of pricingtemplates matching the given filter. - */ - Iterable listPricingTemplates(final Predicate filter); - - /** - * Get the first pricingtemplates that matches the given filter or - * null if none is found. - */ - PricingTemplate findPricingTemplate(final Predicate filter); - - /** - * Get a pricing template given its id. - * - * @param pricingTemplateId - * The id of the pricing template. - * @return The pricing template. - */ - PricingTemplate getPricingTemplate(Integer pricingTemplateId); - - /*********************** CostCodeCurrency ***********************/ - - /** - * Get a cost code currency - */ - Iterable getCostCodeCurrencies(Integer costcodeid, Integer currencyid); - - /*********************** PricingCostCode ***********************/ - - /** - * Get pricing cost codes - */ - Collection getPricingCostCodes(Integer pricingTemplateId); - - /** - * Get a pricing cost code - */ - PricingCostCode getPricingCostCode(Integer pricingTemplateId, Integer pricingCostCodeId); - - /*********************** PricingTier ***********************/ - - /** - * Get pricing tiers - */ - Collection getPricingTiers(Integer pricingTemplateId); - - /** - * 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 deleted file mode 100644 index d4d1c3033f..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/features/services/SearchService.java +++ /dev/null @@ -1,153 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.features.services; - -import org.jclouds.abiquo.domain.cloud.VirtualDatacenter; -import org.jclouds.abiquo.domain.cloud.Volume; -import org.jclouds.abiquo.domain.cloud.options.VolumeOptions; -import org.jclouds.abiquo.domain.enterprise.Enterprise; -import org.jclouds.abiquo.domain.enterprise.options.EnterpriseOptions; -import org.jclouds.abiquo.domain.infrastructure.Datacenter; -import org.jclouds.abiquo.domain.infrastructure.LogicServer; -import org.jclouds.abiquo.domain.infrastructure.ManagedRack; -import org.jclouds.abiquo.domain.infrastructure.StorageDevice; -import org.jclouds.abiquo.domain.infrastructure.StoragePool; -import org.jclouds.abiquo.domain.infrastructure.options.StoragePoolOptions; -import org.jclouds.abiquo.domain.network.PrivateIp; -import org.jclouds.abiquo.domain.network.PrivateNetwork; -import org.jclouds.abiquo.domain.network.PublicIp; -import org.jclouds.abiquo.domain.network.options.IpOptions; -import org.jclouds.abiquo.domain.options.search.FilterOptions; -import org.jclouds.abiquo.internal.BaseSearchService; - -import com.google.inject.ImplementedBy; - -/** - * Provides high level Abiquo search, filter and pagination operations. - * - * @author Ignasi Barrera - * @author Francesc Montserrat - */ -@ImplementedBy(BaseSearchService.class) -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 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 ***********************/ - - /** - * 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 ***********************/ - - /** - * 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 ***********************/ - - /** - * 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 ***********************/ - - /** - * 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); - - /*********************** 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 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 deleted file mode 100644 index 00e9d3f940..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/functions/AppendApiVersionToAbiquoMimeType.java +++ /dev/null @@ -1,65 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.functions; - -import static com.google.common.base.Preconditions.checkNotNull; - -import javax.inject.Inject; -import javax.inject.Singleton; -import javax.ws.rs.core.MediaType; - -import org.jclouds.rest.annotations.ApiVersion; - -import com.google.common.base.Function; - -/** - * Appends the Api version to the given mime type. - * - * @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."; - - /** 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"); - } - - @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); - } - -} 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 deleted file mode 100644 index 2042cc2a90..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/functions/ParseErrors.java +++ /dev/null @@ -1,43 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.functions; - -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jclouds.http.functions.ParseXMLWithJAXB; -import org.jclouds.xml.XMLParser; - -import com.abiquo.model.transport.error.ErrorsDto; -import com.google.inject.TypeLiteral; - -/** - * Parses a errors object. - * - * @author Ignasi Barrera - */ -@Singleton -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/ReturnTaskReferenceOrNull.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/functions/ReturnTaskReferenceOrNull.java deleted file mode 100644 index d5d9691e91..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/functions/ReturnTaskReferenceOrNull.java +++ /dev/null @@ -1,65 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.functions; - -import static org.jclouds.http.HttpUtils.releasePayload; - -import javax.inject.Inject; -import javax.inject.Singleton; -import javax.ws.rs.core.Response.Status; - -import org.jclouds.http.HttpResponse; -import org.jclouds.http.functions.ParseXMLWithJAXB; -import org.jclouds.xml.XMLParser; - -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. - *

- * 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
  • - *
- * - * @author Ignasi Barrera - */ -@Singleton -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); - } - } - -} 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 deleted file mode 100644 index d8e8728539..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/functions/enterprise/ParseEnterpriseId.java +++ /dev/null @@ -1,45 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.functions.enterprise; - -import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.base.Preconditions.checkNotNull; - -import javax.inject.Singleton; - -import com.abiquo.server.core.enterprise.EnterpriseDto; -import com.google.common.base.Function; - -/** - * Parses a {@link EnterpriseDto} object to extract its id. - * - * @author Francesc Montserrat - */ -@Singleton -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(); - } - -} 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 deleted file mode 100644 index cadee5c762..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/functions/infrastructure/ParseDatacenterId.java +++ /dev/null @@ -1,45 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.functions.infrastructure; - -import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.base.Preconditions.checkNotNull; - -import javax.inject.Singleton; - -import com.abiquo.server.core.infrastructure.DatacenterDto; -import com.google.common.base.Function; - -/** - * Parses a {@link DatacenterDto} object to extract its id. - * - * @author Francesc Montserrat - */ -@Singleton -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(); - } - -} 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 deleted file mode 100644 index 25e9b3b4ca..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/functions/infrastructure/ParseMachineId.java +++ /dev/null @@ -1,45 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.functions.infrastructure; - -import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.base.Preconditions.checkNotNull; - -import javax.inject.Singleton; - -import com.abiquo.server.core.infrastructure.MachineDto; -import com.google.common.base.Function; - -/** - * Parses a {@link MachineDto} object to extract its id. - * - * @author Ignasi Barrera - */ -@Singleton -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(); - } - -} 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 deleted file mode 100644 index bac565a5fd..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/functions/infrastructure/ParseRemoteServiceType.java +++ /dev/null @@ -1,46 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.functions.infrastructure; - -import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.base.Preconditions.checkNotNull; - -import javax.inject.Singleton; - -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. - * - * @author Francesc Montserrat - */ -@Singleton -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(); - } - -} 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 deleted file mode 100644 index 7003f5a15a..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/handlers/AbiquoErrorHandler.java +++ /dev/null @@ -1,120 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.handlers; - -import static javax.ws.rs.core.Response.Status.fromStatusCode; - -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jclouds.abiquo.domain.exception.AbiquoException; -import org.jclouds.abiquo.functions.ParseErrors; -import org.jclouds.http.HttpCommand; -import org.jclouds.http.HttpErrorHandler; -import org.jclouds.http.HttpResponse; -import org.jclouds.http.HttpResponseException; -import org.jclouds.rest.AuthorizationException; -import org.jclouds.rest.ResourceNotFoundException; - -import com.abiquo.model.transport.error.ErrorsDto; -import com.google.common.io.Closeables; - -/** - * Parse Abiquo API errors and set the appropriate exception. - * - * @author Ignasi Barrera - */ -@Singleton -public class AbiquoErrorHandler implements HttpErrorHandler { - /** The error parser. */ - private ParseErrors 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()); - - try { - switch (response.getStatusCode()) { - case 401: - case 403: - // Authorization 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 { - Closeables.closeQuietly(response.getPayload()); - command.setException(exception); - } - } - - 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 - exception = new HttpResponseException(command, response, defaultMessage); - } - - return exception; - } - - 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 deleted file mode 100644 index 5a97ac45c9..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/http/filters/AbiquoAuthentication.java +++ /dev/null @@ -1,73 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.http.filters; - -import static com.google.common.base.Preconditions.checkNotNull; -import static org.jclouds.abiquo.config.AbiquoProperties.CREDENTIAL_IS_TOKEN; -import static org.jclouds.http.filters.BasicAuthentication.basic; - -import javax.inject.Inject; -import javax.inject.Named; -import javax.inject.Singleton; -import javax.ws.rs.core.HttpHeaders; - -import org.jclouds.domain.Credentials; -import org.jclouds.http.HttpException; -import org.jclouds.http.HttpRequest; -import org.jclouds.http.HttpRequestFilter; -import org.jclouds.location.Provider; - -import com.google.common.annotations.VisibleForTesting; -import com.google.common.base.Supplier; - -/** - * 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"; - - protected Supplier creds; - protected boolean credentialIsToken; - - @Inject - public AbiquoAuthentication(@Provider Supplier creds, - @Named(CREDENTIAL_IS_TOKEN) boolean credentialIsToken) { - this.creds = checkNotNull(creds, "creds"); - this.credentialIsToken = credentialIsToken; - } - - @Override - public HttpRequest filter(final HttpRequest request) throws HttpException { - Credentials currentCreds = checkNotNull(creds.get(), "credential supplier returned null"); - String header = credentialIsToken ? tokenAuth(currentCreds.credential) : basic(currentCreds.identity, - currentCreds.credential); - return request.toBuilder() - .replaceHeader(credentialIsToken ? HttpHeaders.COOKIE : HttpHeaders.AUTHORIZATION, header).build(); - } - - @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 deleted file mode 100644 index a671315042..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/http/filters/AppendApiVersionToMediaType.java +++ /dev/null @@ -1,78 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.http.filters; - -import java.util.Collection; - -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jclouds.abiquo.functions.AppendApiVersionToAbiquoMimeType; -import org.jclouds.http.HttpException; -import org.jclouds.http.HttpRequest; -import org.jclouds.http.HttpRequestFilter; - -import com.google.common.annotations.VisibleForTesting; -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. - * - * @author Ignasi Barrera - */ -@Singleton -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; - } - - @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 - .toBuilder() - .replaceHeader(HttpHeaders.ACCEPT, - 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); - } - - 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 deleted file mode 100644 index 582a6f98eb..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/internal/AbiquoContextImpl.java +++ /dev/null @@ -1,115 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.internal; - -import static com.google.common.base.Preconditions.checkNotNull; - -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jclouds.Context; -import org.jclouds.abiquo.AbiquoApi; -import org.jclouds.abiquo.AbiquoAsyncApi; -import org.jclouds.abiquo.AbiquoContext; -import org.jclouds.abiquo.features.services.AdministrationService; -import org.jclouds.abiquo.features.services.CloudService; -import org.jclouds.abiquo.features.services.EventService; -import org.jclouds.abiquo.features.services.MonitoringService; -import org.jclouds.abiquo.features.services.PricingService; -import org.jclouds.abiquo.features.services.SearchService; -import org.jclouds.compute.ComputeService; -import org.jclouds.compute.Utils; -import org.jclouds.compute.internal.ComputeServiceContextImpl; -import org.jclouds.location.Provider; -import org.jclouds.rest.RestContext; - -import com.google.common.reflect.TypeToken; - -/** - * 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; - - private final CloudService cloudService; - - private final SearchService searchService; - - private final MonitoringService monitoringService; - - private final EventService eventService; - - private final 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 AdministrationService getAdministrationService() { - return administrationService; - } - - @Override - public CloudService getCloudService() { - return cloudService; - } - - @Override - public SearchService getSearchService() { - return searchService; - } - - @Override - public MonitoringService getMonitoringService() { - return monitoringService; - } - - @Override - public EventService getEventService() { - return eventService; - } - - @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 deleted file mode 100644 index 458a091fe2..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/internal/BaseAdministrationService.java +++ /dev/null @@ -1,312 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.internal; - -import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.collect.Iterables.filter; -import static com.google.common.collect.Iterables.getFirst; -import static org.jclouds.abiquo.domain.DomainWrapper.wrap; - -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jclouds.abiquo.AbiquoApi; -import org.jclouds.abiquo.AbiquoAsyncApi; -import org.jclouds.abiquo.domain.config.Category; -import org.jclouds.abiquo.domain.config.License; -import org.jclouds.abiquo.domain.config.Privilege; -import org.jclouds.abiquo.domain.config.SystemProperty; -import org.jclouds.abiquo.domain.config.options.LicenseOptions; -import org.jclouds.abiquo.domain.config.options.PropertyOptions; -import org.jclouds.abiquo.domain.enterprise.Enterprise; -import org.jclouds.abiquo.domain.enterprise.EnterpriseProperties; -import org.jclouds.abiquo.domain.enterprise.Role; -import org.jclouds.abiquo.domain.enterprise.User; -import org.jclouds.abiquo.domain.infrastructure.Datacenter; -import org.jclouds.abiquo.domain.infrastructure.Machine; -import org.jclouds.abiquo.features.services.AdministrationService; -import org.jclouds.abiquo.reference.ValidationErrors; -import org.jclouds.abiquo.strategy.infrastructure.ListMachines; -import org.jclouds.collect.Memoized; -import org.jclouds.rest.RestContext; - -import com.abiquo.server.core.appslibrary.CategoriesDto; -import com.abiquo.server.core.appslibrary.CategoryDto; -import com.abiquo.server.core.config.LicensesDto; -import com.abiquo.server.core.config.SystemPropertiesDto; -import com.abiquo.server.core.enterprise.EnterpriseDto; -import com.abiquo.server.core.enterprise.EnterprisePropertiesDto; -import com.abiquo.server.core.enterprise.EnterprisesDto; -import com.abiquo.server.core.enterprise.PrivilegeDto; -import com.abiquo.server.core.enterprise.PrivilegesDto; -import com.abiquo.server.core.enterprise.RoleDto; -import com.abiquo.server.core.enterprise.RolesDto; -import com.abiquo.server.core.infrastructure.DatacenterDto; -import com.abiquo.server.core.infrastructure.DatacentersDto; -import com.google.common.annotations.VisibleForTesting; -import com.google.common.base.Predicate; -import com.google.common.base.Supplier; -import com.google.common.collect.Iterables; - -/** - * Provides high level Abiquo administration operations. - * - * @author Ignasi Barrera - * @author Francesc Montserrat - */ -@Singleton -public class BaseAdministrationService implements AdministrationService { - @VisibleForTesting - protected RestContext context; - - @VisibleForTesting - protected final ListMachines listMachines; - - @VisibleForTesting - protected final Supplier currentUser; - - @VisibleForTesting - protected final Supplier currentEnterprise; - - @Inject - protected BaseAdministrationService(final RestContext context, - final ListMachines listMachines, @Memoized final Supplier currentUser, - @Memoized final Supplier currentEnterprise) { - this.context = checkNotNull(context, "context"); - this.listMachines = checkNotNull(listMachines, "listMachines"); - this.currentUser = checkNotNull(currentUser, "currentUser"); - this.currentEnterprise = checkNotNull(currentEnterprise, "currentEnterprise"); - } - - /*********************** Datacenter ********************** */ - - @Override - public Iterable listDatacenters() { - DatacentersDto result = context.getApi().getInfrastructureApi().listDatacenters(); - return wrap(context, Datacenter.class, result.getCollection()); - } - - @Override - public Iterable listDatacenters(final Predicate filter) { - return filter(listDatacenters(), filter); - } - - @Override - public Datacenter findDatacenter(final Predicate filter) { - return getFirst(listDatacenters(filter), null); - } - - @Override - public Datacenter getDatacenter(final Integer datacenterId) { - DatacenterDto datacenter = context.getApi().getInfrastructureApi().getDatacenter(datacenterId); - return wrap(context, Datacenter.class, datacenter); - } - - /*********************** Machine ***********************/ - - @Override - public Iterable listMachines() { - return listMachines.execute(); - } - - @Override - public Iterable listMachines(final Predicate filter) { - return listMachines.execute(filter); - } - - @Override - public Machine findMachine(final Predicate filter) { - return Iterables.getFirst(listMachines(filter), null); - } - - /*********************** Enterprise ***********************/ - - @Override - public Iterable listEnterprises() { - EnterprisesDto result = context.getApi().getEnterpriseApi().listEnterprises(); - return wrap(context, Enterprise.class, result.getCollection()); - } - - @Override - public Iterable listEnterprises(final Predicate filter) { - return filter(listEnterprises(), filter); - } - - @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); - } - - /*********************** Enterprise Properties ***********************/ - - @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); - } - - /*********************** Role ********************** */ - - @Override - public Iterable listRoles() { - RolesDto result = context.getApi().getAdminApi().listRoles(); - return wrap(context, Role.class, result.getCollection()); - } - - @Override - public Iterable listRoles(final Predicate filter) { - return filter(listRoles(), filter); - } - - @Override - public Role findRole(final Predicate filter) { - return getFirst(listRoles(filter), null); - } - - @Override - public Role getRole(final Integer roleId) { - RoleDto role = context.getApi().getAdminApi().getRole(roleId); - return wrap(context, Role.class, role); - } - - /*********************** Privilege ***********************/ - - @Override - public Iterable listPrivileges() { - PrivilegesDto result = context.getApi().getConfigApi().listPrivileges(); - return wrap(context, Privilege.class, result.getCollection()); - } - - @Override - public Iterable listPrivileges(final Predicate filter) { - return filter(listPrivileges(), filter); - } - - @Override - public Privilege findPrivilege(final Predicate filter) { - return getFirst(listPrivileges(filter), null); - } - - @Override - public Privilege getPrivilege(Integer privilegeId) { - PrivilegeDto result = context.getApi().getConfigApi().getPrivilege(privilegeId); - return wrap(context, Privilege.class, result); - } - - /*********************** User ***********************/ - - @Override - public User getCurrentUser() { - return currentUser.get(); - } - - @Override - public Enterprise getCurrentEnterprise() { - return currentEnterprise.get(); - } - - /*********************** License ***********************/ - - @Override - public Iterable listLicenses() { - LicensesDto result = context.getApi().getConfigApi().listLicenses(); - return wrap(context, License.class, result.getCollection()); - } - - @Override - public Iterable listLicenses(final boolean active) { - LicenseOptions options = LicenseOptions.builder().active(active).build(); - LicensesDto result = context.getApi().getConfigApi().listLicenses(options); - return wrap(context, License.class, result.getCollection()); - } - - @Override - public Iterable listLicenses(final Predicate filter) { - return filter(listLicenses(), filter); - } - - @Override - public License findLicense(final Predicate filter) { - return getFirst(listLicenses(filter), null); - } - - /*********************** System Properties ***********************/ - - @Override - public Iterable listSystemProperties() { - SystemPropertiesDto result = context.getApi().getConfigApi().listSystemProperties(); - return wrap(context, SystemProperty.class, result.getCollection()); - } - - @Override - public Iterable listSystemProperties(final Predicate filter) { - return filter(listSystemProperties(), filter); - } - - @Override - public SystemProperty findSystemProperty(final Predicate filter) { - return getFirst(listSystemProperties(filter), null); - } - - @Override - public SystemProperty getSystemProperty(final String name) { - PropertyOptions options = PropertyOptions.builder().name(name).build(); - SystemPropertiesDto result = context.getApi().getConfigApi().listSystemProperties(options); - return getFirst(wrap(context, SystemProperty.class, result.getCollection()), null); - } - - @Override - public Iterable listSystemProperties(final String component) { - PropertyOptions options = PropertyOptions.builder().component(component).build(); - SystemPropertiesDto result = context.getApi().getConfigApi().listSystemProperties(options); - return wrap(context, SystemProperty.class, result.getCollection()); - } - - @Override - public Iterable listCategories() { - CategoriesDto result = context.getApi().getConfigApi().listCategories(); - return wrap(context, Category.class, result.getCollection()); - } - - @Override - public Iterable listCategories(final Predicate filter) { - return filter(listCategories(), filter); - } - - @Override - public Category findCategory(final Predicate filter) { - return Iterables.getFirst(listCategories(filter), null); - } - - @Override - public Category getCategory(Integer categoryId) { - CategoryDto result = context.getApi().getConfigApi().getCategory(categoryId); - return wrap(context, Category.class, result); - } -} 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 deleted file mode 100644 index 16d99cba16..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/internal/BaseCloudService.java +++ /dev/null @@ -1,150 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.internal; - -import static com.google.common.base.Preconditions.checkNotNull; -import static org.jclouds.abiquo.domain.DomainWrapper.wrap; - -import java.util.List; - -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jclouds.abiquo.AbiquoAsyncApi; -import org.jclouds.abiquo.AbiquoApi; -import org.jclouds.abiquo.domain.cloud.VirtualAppliance; -import org.jclouds.abiquo.domain.cloud.VirtualDatacenter; -import org.jclouds.abiquo.domain.cloud.VirtualMachine; -import org.jclouds.abiquo.domain.cloud.options.VirtualDatacenterOptions; -import org.jclouds.abiquo.domain.enterprise.Enterprise; -import org.jclouds.abiquo.features.services.CloudService; -import org.jclouds.abiquo.reference.ValidationErrors; -import org.jclouds.abiquo.strategy.cloud.ListVirtualAppliances; -import org.jclouds.abiquo.strategy.cloud.ListVirtualDatacenters; -import org.jclouds.abiquo.strategy.cloud.ListVirtualMachines; -import org.jclouds.rest.RestContext; - -import com.abiquo.server.core.cloud.VirtualDatacenterDto; -import com.google.common.annotations.VisibleForTesting; -import com.google.common.base.Predicate; -import com.google.common.collect.Iterables; - -/** - * Provides high level Abiquo cloud operations. - * - * @author Ignasi Barrera - * @author Francesc Montserrat - */ -@Singleton -public class BaseCloudService implements CloudService { - @VisibleForTesting - protected RestContext context; - - @VisibleForTesting - protected final ListVirtualDatacenters listVirtualDatacenters; - - @VisibleForTesting - protected ListVirtualAppliances listVirtualAppliances; - - @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"); - } - - /*********************** Virtual Datacenter ********************** */ - - @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); - - VirtualDatacenterOptions options = VirtualDatacenterOptions.builder().enterpriseId(enterprise.getId()).build(); - - return listVirtualDatacenters.execute(options); - } - - @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 Iterable getVirtualDatacenters(final List virtualDatacenterIds) { - return listVirtualDatacenters.execute(virtualDatacenterIds); - } - - @Override - public VirtualDatacenter findVirtualDatacenter(final Predicate filter) { - return Iterables.getFirst(listVirtualDatacenters(filter), null); - } - - /*********************** Virtual Appliance ********************** */ - - @Override - public Iterable listVirtualAppliances() { - return listVirtualAppliances.execute(); - } - - @Override - public Iterable listVirtualAppliances(final Predicate filter) { - return listVirtualAppliances.execute(filter); - } - - @Override - public VirtualAppliance findVirtualAppliance(final Predicate filter) { - return Iterables.getFirst(listVirtualAppliances(filter), null); - } - - /*********************** Virtual Machine ********************** */ - - @Override - public Iterable listVirtualMachines() { - return listVirtualMachines.execute(); - } - - @Override - public Iterable listVirtualMachines(final Predicate filter) { - return listVirtualMachines.execute(filter); - } - - @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 deleted file mode 100644 index e3c5c994bc..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/internal/BaseEventService.java +++ /dev/null @@ -1,65 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.internal; - -import static com.google.common.base.Preconditions.checkNotNull; -import static org.jclouds.abiquo.domain.DomainWrapper.wrap; - -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jclouds.abiquo.AbiquoApi; -import org.jclouds.abiquo.AbiquoAsyncApi; -import org.jclouds.abiquo.domain.event.Event; -import org.jclouds.abiquo.domain.event.options.EventOptions; -import org.jclouds.abiquo.features.services.EventService; -import org.jclouds.rest.RestContext; - -import com.abiquo.server.core.event.EventsDto; -import com.google.common.annotations.VisibleForTesting; - -/** - * Provides high level Abiquo event operations. - * - * @author Ignasi Barrera - * @author Vivien Mahé - */ -@Singleton -public class BaseEventService implements EventService { - @VisibleForTesting - protected RestContext context; - - @Inject - protected BaseEventService(final RestContext context) { - this.context = checkNotNull(context, "context"); - } - - @Override - public Iterable listEvents() { - EventsDto result = context.getApi().getEventApi().listEvents(); - return wrap(context, Event.class, result.getCollection()); - } - - @Override - public Iterable listEvents(final EventOptions options) { - EventsDto result = context.getApi().getEventApi().listEvents(options); - return wrap(context, Event.class, result.getCollection()); - } -} 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 deleted file mode 100644 index a4a3c7dc13..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/internal/BaseMonitoringService.java +++ /dev/null @@ -1,300 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.internal; - -import static com.google.common.base.Preconditions.checkNotNull; -import static org.jclouds.Constants.PROPERTY_SCHEDULER_THREADS; -import static org.jclouds.abiquo.config.AbiquoProperties.ASYNC_TASK_MONITOR_DELAY; - -import java.util.concurrent.Future; -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.TimeUnit; - -import javax.annotation.Resource; -import javax.inject.Named; -import javax.inject.Singleton; - -import org.jclouds.abiquo.AbiquoApi; -import org.jclouds.abiquo.AbiquoAsyncApi; -import org.jclouds.abiquo.events.handlers.AbstractEventHandler; -import org.jclouds.abiquo.events.handlers.BlockingEventHandler; -import org.jclouds.abiquo.events.monitor.CompletedEvent; -import org.jclouds.abiquo.events.monitor.FailedEvent; -import org.jclouds.abiquo.events.monitor.TimeoutEvent; -import org.jclouds.abiquo.features.services.MonitoringService; -import org.jclouds.abiquo.monitor.AsyncTaskMonitor; -import org.jclouds.abiquo.monitor.ConversionMonitor; -import org.jclouds.abiquo.monitor.MonitorStatus; -import org.jclouds.abiquo.monitor.VirtualApplianceMonitor; -import org.jclouds.abiquo.monitor.VirtualMachineMonitor; -import org.jclouds.logging.Logger; -import org.jclouds.rest.RestContext; - -import com.google.common.annotations.VisibleForTesting; -import com.google.common.base.Function; -import com.google.common.eventbus.EventBus; -import com.google.inject.Inject; - -/** - * Utility service to monitor asynchronous operations. - * - * @author Ignasi Barrera - * @author Francesc Montserrat - */ -@Singleton -public class BaseMonitoringService implements MonitoringService { - @VisibleForTesting - protected RestContext context; - - /** The scheduler used to perform monitoring tasks. */ - @VisibleForTesting - protected ScheduledExecutorService scheduler; - - @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; - - @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"); - } - - /*************** Generic monitoring methods ***************/ - - @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"); - - if (objects != null && objects.length > 0) { - BlockingEventHandler blockingHandler = new BlockingEventHandler(logger, objects); - register(blockingHandler); - - monitor(maxWait, timeUnit, completeCondition, objects); - blockingHandler.lock(); - - unregister(blockingHandler); - } - } - - @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"); - } - - if (objects != null && objects.length > 0) { - for (T object : objects) { - AsyncMonitor monitor = new AsyncMonitor(object, completeCondition); - monitor.startMonitoring(maxWait, timeUnit); - } - } - } - - @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); - } - - /*************** Delegating monitors ***************/ - - @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), - "virtualApplianceMonitor"); - } - - @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"); - } - - /** - * 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 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; - - 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. - * @param timeUnit The timeunit used in the maxWait parameter. - */ - public void startMonitoring(final Long maxWait, TimeUnit timeUnit) { - if (maxWait != null) { - checkNotNull(timeUnit, "timeUnit must not be null when using timeouts"); - } - future = scheduler.scheduleWithFixedDelay(this, 0L, pollingDelay, TimeUnit.MILLISECONDS); - timeout = maxWait == null ? null : System.currentTimeMillis() + timeUnit.toMillis(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); - - 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); - } - } - - /** - * 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; - } - - 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; - } - } - - public T getMonitoredObject() { - return monitoredObject; - } - - public Function getCompleteCondition() { - return completeCondition; - } - - public Future getFuture() { - return future; - } - - 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 deleted file mode 100644 index 27083cfefa..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/internal/BasePricingService.java +++ /dev/null @@ -1,182 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.internal; - -import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.collect.Iterables.filter; -import static com.google.common.collect.Iterables.getFirst; -import static org.jclouds.abiquo.domain.DomainWrapper.wrap; - -import java.util.Collection; - -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jclouds.abiquo.AbiquoApi; -import org.jclouds.abiquo.AbiquoAsyncApi; -import org.jclouds.abiquo.domain.config.CostCode; -import org.jclouds.abiquo.domain.config.CostCodeCurrency; -import org.jclouds.abiquo.domain.config.Currency; -import org.jclouds.abiquo.domain.config.PricingCostCode; -import org.jclouds.abiquo.domain.config.PricingTemplate; -import org.jclouds.abiquo.domain.config.PricingTier; -import org.jclouds.abiquo.features.services.PricingService; -import org.jclouds.rest.RestContext; - -import com.abiquo.server.core.pricing.CostCodeCurrenciesDto; -import com.abiquo.server.core.pricing.CostCodeDto; -import com.abiquo.server.core.pricing.CostCodesDto; -import com.abiquo.server.core.pricing.CurrenciesDto; -import com.abiquo.server.core.pricing.CurrencyDto; -import com.abiquo.server.core.pricing.PricingCostCodeDto; -import com.abiquo.server.core.pricing.PricingCostCodesDto; -import com.abiquo.server.core.pricing.PricingTemplateDto; -import com.abiquo.server.core.pricing.PricingTemplatesDto; -import com.abiquo.server.core.pricing.PricingTierDto; -import com.abiquo.server.core.pricing.PricingTiersDto; -import com.google.common.annotations.VisibleForTesting; -import com.google.common.base.Predicate; -import com.google.common.collect.Iterables; - -/** - * Provides access to Abiquo pricing features. - * - * @author Ignasi Barrera - * @author Susana Acedo - */ -@Singleton -public class BasePricingService implements PricingService { - @VisibleForTesting - protected RestContext context; - - @Inject - protected BasePricingService(final RestContext context) { - this.context = checkNotNull(context, "context"); - } - - /*********************** Currency ********************** */ - - @Override - public Iterable listCurrencies() { - CurrenciesDto result = context.getApi().getPricingApi().listCurrencies(); - return wrap(context, Currency.class, result.getCollection()); - } - - @Override - public Iterable listCurrencies(final Predicate filter) { - return filter(listCurrencies(), filter); - } - - @Override - public Currency findCurrency(final Predicate filter) { - return getFirst(listCurrencies(filter), null); - } - - @Override - public Currency getCurrency(final Integer currencyId) { - CurrencyDto result = context.getApi().getPricingApi().getCurrency(currencyId); - return wrap(context, Currency.class, result); - } - - /*********************** CostCode ********************** */ - - @Override - public Iterable listCostCodes() { - CostCodesDto result = context.getApi().getPricingApi().listCostCodes(); - return wrap(context, CostCode.class, result.getCollection()); - } - - @Override - public Iterable listCostCodes(final Predicate filter) { - return filter(listCostCodes(), filter); - } - - @Override - public CostCode findCostCode(final Predicate filter) { - return Iterables.getFirst(listCostCodes(filter), null); - } - - @Override - public CostCode getCostCode(Integer costCodeId) { - CostCodeDto result = context.getApi().getPricingApi().getCostCode(costCodeId); - return wrap(context, CostCode.class, result); - } - - /*********************** PricingTemplate ********************** */ - - @Override - public Iterable listPricingTemplates() { - PricingTemplatesDto result = context.getApi().getPricingApi().listPricingTemplates(); - return wrap(context, PricingTemplate.class, result.getCollection()); - } - - @Override - public Iterable listPricingTemplates(final Predicate filter) { - return filter(listPricingTemplates(), filter); - } - - @Override - public PricingTemplate findPricingTemplate(final Predicate filter) { - return getFirst(listPricingTemplates(filter), null); - } - - @Override - public PricingTemplate getPricingTemplate(Integer pricingTemplateId) { - PricingTemplateDto result = context.getApi().getPricingApi().getPricingTemplate(pricingTemplateId); - return wrap(context, PricingTemplate.class, result); - } - - /*********************** 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()); - } - - /*********************** 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 PricingCostCode getPricingCostCode(final Integer pricingTemplateId, final Integer pricingCostCodeId) { - PricingCostCodeDto pricingcostcode = context.getApi().getPricingApi() - .getPricingCostCode(pricingTemplateId, pricingCostCodeId); - return wrap(context, PricingCostCode.class, pricingcostcode); - } - - /*********************** 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 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 deleted file mode 100644 index 0326205ebb..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/internal/BaseSearchService.java +++ /dev/null @@ -1,156 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.internal; - -import static com.google.common.base.Preconditions.checkNotNull; -import static org.jclouds.abiquo.domain.DomainWrapper.wrap; - -import java.util.List; - -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jclouds.abiquo.AbiquoAsyncApi; -import org.jclouds.abiquo.AbiquoApi; -import org.jclouds.abiquo.domain.cloud.VirtualDatacenter; -import org.jclouds.abiquo.domain.cloud.Volume; -import org.jclouds.abiquo.domain.cloud.options.VolumeOptions; -import org.jclouds.abiquo.domain.enterprise.Enterprise; -import org.jclouds.abiquo.domain.enterprise.options.EnterpriseOptions; -import org.jclouds.abiquo.domain.infrastructure.Datacenter; -import org.jclouds.abiquo.domain.infrastructure.LogicServer; -import org.jclouds.abiquo.domain.infrastructure.ManagedRack; -import org.jclouds.abiquo.domain.infrastructure.StorageDevice; -import org.jclouds.abiquo.domain.infrastructure.StoragePool; -import org.jclouds.abiquo.domain.infrastructure.options.StoragePoolOptions; -import org.jclouds.abiquo.domain.network.PrivateIp; -import org.jclouds.abiquo.domain.network.PrivateNetwork; -import org.jclouds.abiquo.domain.network.PublicIp; -import org.jclouds.abiquo.domain.network.options.IpOptions; -import org.jclouds.abiquo.domain.options.search.FilterOptions; -import org.jclouds.abiquo.features.services.SearchService; -import org.jclouds.rest.RestContext; - -import com.abiquo.server.core.enterprise.EnterpriseDto; -import com.abiquo.server.core.infrastructure.LogicServerDto; -import com.abiquo.server.core.infrastructure.network.PrivateIpDto; -import com.abiquo.server.core.infrastructure.network.PublicIpDto; -import com.abiquo.server.core.infrastructure.storage.StoragePoolDto; -import com.abiquo.server.core.infrastructure.storage.VolumeManagementDto; -import com.google.common.annotations.VisibleForTesting; - -/** - * Provides high level Abiquo search, filter and pagination operations. - * - * @author Ignasi Barrera - * @author Francesc Montserrat - */ -@Singleton -public class BaseSearchService implements SearchService { - @VisibleForTesting - protected RestContext context; - - @Inject - protected BaseSearchService(final RestContext context) { - this.context = checkNotNull(context, "context"); - } - - /*********************** Enterprise ***********************/ - - @Override - public Iterable searchEnterprises(final EnterpriseOptions options) { - List enterprises = context.getApi().getEnterpriseApi().listEnterprises(options).getCollection(); - - 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(); - - return wrap(context, Enterprise.class, enterprises); - } - - /*********************** Volume ********************** */ - - @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); - } - - /*********************** Storage Pool ***********************/ - - @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); - } - - /*********************** Private Network ***********************/ - - @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); - } - - @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); - } - - @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); - } - - @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); - } - - @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); - } - -} 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 deleted file mode 100644 index 28d4b1f1f5..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/monitor/AsyncTaskMonitor.java +++ /dev/null @@ -1,78 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.monitor; - -import java.util.concurrent.TimeUnit; - -import org.jclouds.abiquo.domain.task.AsyncTask; -import org.jclouds.abiquo.features.services.MonitoringService; -import org.jclouds.abiquo.monitor.internal.BaseAsyncTaskMonitor; - -import com.google.inject.ImplementedBy; - -/** - * {@link VirtualMachine} monitoring features. - * - * @author Ignasi Barrera - */ -@ImplementedBy(BaseAsyncTaskMonitor.class) -public interface AsyncTaskMonitor extends MonitoringService { - /** - * Monitor the given {@link AsyncTask}s and block until they finish. - * - * @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 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); -} 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 deleted file mode 100644 index b293b380bb..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/monitor/ConversionMonitor.java +++ /dev/null @@ -1,78 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.monitor; - -import java.util.concurrent.TimeUnit; - -import org.jclouds.abiquo.domain.cloud.Conversion; -import org.jclouds.abiquo.features.services.MonitoringService; -import org.jclouds.abiquo.monitor.internal.BaseConversionMonitor; - -import com.google.inject.ImplementedBy; - -/** - * {@link Conversion} monitoring features. - * - * @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); - - /** - * 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 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 deleted file mode 100644 index 1b744a2be8..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/monitor/MonitorStatus.java +++ /dev/null @@ -1,36 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.monitor; - -/** - * Represents the states of a running monitor. - * - * @author Serafin Sedano - */ -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 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 deleted file mode 100644 index 07766bc786..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/monitor/VirtualApplianceMonitor.java +++ /dev/null @@ -1,126 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.monitor; - -import java.util.concurrent.TimeUnit; - -import org.jclouds.abiquo.domain.cloud.VirtualAppliance; -import org.jclouds.abiquo.features.services.MonitoringService; -import org.jclouds.abiquo.monitor.internal.BaseVirtualApplianceMonitor; - -import com.google.inject.ImplementedBy; - -/** - * {@link VirtualAppliance} monitoring features. - * - * @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); - - /** - * 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 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 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 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 deleted file mode 100644 index f42bceb0d6..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/monitor/VirtualMachineMonitor.java +++ /dev/null @@ -1,174 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.monitor; - -import java.util.concurrent.TimeUnit; - -import org.jclouds.abiquo.domain.cloud.VirtualMachine; -import org.jclouds.abiquo.features.services.MonitoringService; -import org.jclouds.abiquo.monitor.internal.BaseVirtualMachineMonitor; - -import com.abiquo.server.core.cloud.VirtualMachineState; -import com.google.inject.ImplementedBy; - -/** - * {@link VirtualMachine} monitoring features. - * - * @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); - - /** - * 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 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 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 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 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 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 deleted file mode 100644 index 433df10f86..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/monitor/functions/AsyncTaskStatusMonitor.java +++ /dev/null @@ -1,69 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.monitor.functions; - -import static com.google.common.base.Preconditions.checkNotNull; - -import javax.annotation.Resource; -import javax.inject.Singleton; - -import org.jclouds.abiquo.domain.task.AsyncTask; -import org.jclouds.abiquo.monitor.MonitorStatus; -import org.jclouds.logging.Logger; - -import com.google.common.base.Function; - -/** - * This class takes care of monitoring {@link AsyncTask} jobs. - * - * @author Ignasi Barrera - */ -@Singleton -public class AsyncTaskStatusMonitor implements Function { - @Resource - protected Logger logger = Logger.NULL; - - @Override - public MonitorStatus apply(final AsyncTask asyncTask) { - checkNotNull(asyncTask, "asyncTask"); - - 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()); - - 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 deleted file mode 100644 index 357e0e53f0..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/monitor/functions/ConversionStatusMonitor.java +++ /dev/null @@ -1,67 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.monitor.functions; - -import static com.google.common.base.Preconditions.checkNotNull; - -import javax.annotation.Resource; -import javax.inject.Singleton; - -import org.jclouds.abiquo.domain.cloud.Conversion; -import org.jclouds.abiquo.monitor.MonitorStatus; -import org.jclouds.logging.Logger; - -import com.google.common.base.Function; - -/** - * This class takes care of monitoring {@link Conversion} jobs. - * - * @author Sergi Castro - */ -@Singleton -public class ConversionStatusMonitor implements Function { - @Resource - protected Logger logger = Logger.NULL; - - @Override - public MonitorStatus apply(final Conversion conversion) { - checkNotNull(conversion, "conversion"); - - 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()); - - 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 deleted file mode 100644 index 7a77141a2d..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/monitor/functions/VirtualApplianceDeployMonitor.java +++ /dev/null @@ -1,70 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.monitor.functions; - -import static com.google.common.base.Preconditions.checkNotNull; - -import javax.annotation.Resource; -import javax.inject.Singleton; - -import org.jclouds.abiquo.domain.cloud.VirtualAppliance; -import org.jclouds.abiquo.monitor.MonitorStatus; -import org.jclouds.logging.Logger; - -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}. - * - * @author Serafin Sedano - */ -@Singleton -public class VirtualApplianceDeployMonitor implements Function { - @Resource - protected Logger logger = Logger.NULL; - - @Override - public MonitorStatus apply(final VirtualAppliance virtualAppliance) { - checkNotNull(virtualAppliance, "virtualAppliance"); - - 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()); - - 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 deleted file mode 100644 index ccc0e5e69c..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/monitor/functions/VirtualApplianceUndeployMonitor.java +++ /dev/null @@ -1,75 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.monitor.functions; - -import static com.google.common.base.Preconditions.checkNotNull; - -import javax.annotation.Resource; -import javax.inject.Singleton; - -import org.jclouds.abiquo.domain.cloud.VirtualAppliance; -import org.jclouds.abiquo.monitor.MonitorStatus; -import org.jclouds.logging.Logger; -import org.jclouds.rest.ResourceNotFoundException; - -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}. - * - * @author Serafin Sedano - */ -@Singleton -public class VirtualApplianceUndeployMonitor implements Function { - @Resource - protected Logger logger = Logger.NULL; - - @Override - public MonitorStatus apply(final VirtualAppliance virtualAppliance) { - checkNotNull(virtualAppliance, "virtualAppliance"); - - 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()); - - 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 deleted file mode 100644 index 13da1dfb7e..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/monitor/functions/VirtualMachineDeployMonitor.java +++ /dev/null @@ -1,68 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.monitor.functions; - -import static com.google.common.base.Preconditions.checkNotNull; - -import javax.annotation.Resource; - -import org.jclouds.abiquo.domain.cloud.VirtualMachine; -import org.jclouds.abiquo.monitor.MonitorStatus; -import org.jclouds.logging.Logger; - -import com.abiquo.server.core.cloud.VirtualMachineState; -import com.google.common.base.Function; -import com.google.inject.Singleton; - -/** - * This class takes care of monitoring the a deploy of a {@link VirtualMachine}. - * - * @author Serafin Sedano - * @see MonitoringService - */ -@Singleton -public class VirtualMachineDeployMonitor implements Function { - @Resource - private Logger logger = Logger.NULL; - - @Override - public MonitorStatus apply(final VirtualMachine virtualMachine) { - checkNotNull(virtualMachine, "virtualMachine"); - - 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()); - - 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 deleted file mode 100644 index 00f3bd3b87..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/monitor/functions/VirtualMachineStateMonitor.java +++ /dev/null @@ -1,65 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.monitor.functions; - -import static com.google.common.base.Preconditions.checkNotNull; - -import javax.annotation.Resource; - -import org.jclouds.abiquo.domain.cloud.VirtualMachine; -import org.jclouds.abiquo.monitor.MonitorStatus; -import org.jclouds.logging.Logger; - -import com.abiquo.server.core.cloud.VirtualMachineState; -import com.google.common.base.Function; - -/** - * This class takes care of monitoring the state of a {@link VirtualMachine}. - * - * @author Ignasi Barrera - * @see MonitoringService - */ -public class VirtualMachineStateMonitor implements Function { - @Resource - private Logger logger = Logger.NULL; - - private VirtualMachineState expectedState; - - public VirtualMachineStateMonitor(final VirtualMachineState expectedState) { - super(); - this.expectedState = checkNotNull(expectedState, "expectedState"); - } - - @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()); - - 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 deleted file mode 100644 index f1f9fb69c9..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/monitor/functions/VirtualMachineUndeployMonitor.java +++ /dev/null @@ -1,78 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.monitor.functions; - -import static com.google.common.base.Preconditions.checkNotNull; - -import javax.annotation.Resource; -import javax.inject.Singleton; - -import org.jclouds.abiquo.domain.cloud.VirtualMachine; -import org.jclouds.abiquo.monitor.MonitorStatus; -import org.jclouds.logging.Logger; -import org.jclouds.rest.ResourceNotFoundException; - -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}. - * - * @author Serafin Sedano - */ -@Singleton -public class VirtualMachineUndeployMonitor implements Function { - @Resource - protected Logger logger = Logger.NULL; - - @Override - public MonitorStatus apply(final VirtualMachine virtualMachine) { - checkNotNull(virtualMachine, "virtualMachine"); - - 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; - } - - 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; - } - } -} 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 deleted file mode 100644 index 7d98f97fbb..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/monitor/internal/BaseAsyncTaskMonitor.java +++ /dev/null @@ -1,84 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.monitor.internal; - -import static com.google.common.base.Preconditions.checkNotNull; -import static org.jclouds.Constants.PROPERTY_SCHEDULER_THREADS; -import static org.jclouds.abiquo.config.AbiquoProperties.ASYNC_TASK_MONITOR_DELAY; - -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.TimeUnit; - -import javax.inject.Inject; -import javax.inject.Named; -import javax.inject.Singleton; - -import org.jclouds.abiquo.AbiquoApi; -import org.jclouds.abiquo.AbiquoAsyncApi; -import org.jclouds.abiquo.domain.task.AsyncTask; -import org.jclouds.abiquo.internal.BaseMonitoringService; -import org.jclouds.abiquo.monitor.AsyncTaskMonitor; -import org.jclouds.abiquo.monitor.functions.AsyncTaskStatusMonitor; -import org.jclouds.rest.RestContext; - -import com.google.common.annotations.VisibleForTesting; -import com.google.common.eventbus.EventBus; - -/** - * Default monitor for {@link AsyncTask} objects. - * - * @author Ignasi Barrera - */ -@Singleton -public class BaseAsyncTaskMonitor extends BaseMonitoringService implements AsyncTaskMonitor { - - @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"); - } - - @Override - public void awaitCompletion(final AsyncTask... tasks) { - awaitCompletion(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 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 deleted file mode 100644 index a7cff8e1b7..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/monitor/internal/BaseConversionMonitor.java +++ /dev/null @@ -1,84 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.monitor.internal; - -import static com.google.common.base.Preconditions.checkNotNull; -import static org.jclouds.Constants.PROPERTY_SCHEDULER_THREADS; -import static org.jclouds.abiquo.config.AbiquoProperties.ASYNC_TASK_MONITOR_DELAY; - -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.TimeUnit; - -import javax.inject.Inject; -import javax.inject.Named; -import javax.inject.Singleton; - -import org.jclouds.abiquo.AbiquoApi; -import org.jclouds.abiquo.AbiquoAsyncApi; -import org.jclouds.abiquo.domain.cloud.Conversion; -import org.jclouds.abiquo.internal.BaseMonitoringService; -import org.jclouds.abiquo.monitor.ConversionMonitor; -import org.jclouds.abiquo.monitor.functions.ConversionStatusMonitor; -import org.jclouds.rest.RestContext; - -import com.google.common.annotations.VisibleForTesting; -import com.google.common.eventbus.EventBus; - -/** - * Default monitor for {@link Conversion} objects. - * - * @author Sergi Castro - */ -@Singleton -public class BaseConversionMonitor extends BaseMonitoringService implements 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"); - } - - @Override - public void awaitCompletion(final Conversion... conversions) { - awaitCompletion(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 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 deleted file mode 100644 index f2cd05b27e..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/monitor/internal/BaseVirtualApplianceMonitor.java +++ /dev/null @@ -1,107 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.monitor.internal; - -import static com.google.common.base.Preconditions.checkNotNull; -import static org.jclouds.Constants.PROPERTY_SCHEDULER_THREADS; -import static org.jclouds.abiquo.config.AbiquoProperties.ASYNC_TASK_MONITOR_DELAY; - -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.TimeUnit; - -import javax.inject.Inject; -import javax.inject.Named; -import javax.inject.Singleton; - -import org.jclouds.abiquo.AbiquoApi; -import org.jclouds.abiquo.AbiquoAsyncApi; -import org.jclouds.abiquo.domain.cloud.VirtualAppliance; -import org.jclouds.abiquo.internal.BaseMonitoringService; -import org.jclouds.abiquo.monitor.VirtualApplianceMonitor; -import org.jclouds.abiquo.monitor.functions.VirtualApplianceDeployMonitor; -import org.jclouds.abiquo.monitor.functions.VirtualApplianceUndeployMonitor; -import org.jclouds.rest.RestContext; - -import com.google.common.annotations.VisibleForTesting; -import com.google.common.eventbus.EventBus; - -/** - * Default monitor for {@link VirtualAppliance} objects. - * - * @author Ignasi Barrera - */ -@Singleton -public class BaseVirtualApplianceMonitor extends BaseMonitoringService implements VirtualApplianceMonitor { - @VisibleForTesting - protected VirtualApplianceDeployMonitor deployMonitor; - - @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"); - } - - @Override - public void awaitCompletionDeploy(final VirtualAppliance... vapps) { - awaitCompletion(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 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 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 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 deleted file mode 100644 index e1bf8f41db..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/monitor/internal/BaseVirtualMachineMonitor.java +++ /dev/null @@ -1,131 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.monitor.internal; - -import static com.google.common.base.Preconditions.checkNotNull; -import static org.jclouds.Constants.PROPERTY_SCHEDULER_THREADS; -import static org.jclouds.abiquo.config.AbiquoProperties.ASYNC_TASK_MONITOR_DELAY; - -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.TimeUnit; - -import javax.inject.Inject; -import javax.inject.Named; -import javax.inject.Singleton; - -import org.jclouds.abiquo.AbiquoApi; -import org.jclouds.abiquo.AbiquoAsyncApi; -import org.jclouds.abiquo.domain.cloud.VirtualMachine; -import org.jclouds.abiquo.internal.BaseMonitoringService; -import org.jclouds.abiquo.monitor.VirtualMachineMonitor; -import org.jclouds.abiquo.monitor.functions.VirtualMachineDeployMonitor; -import org.jclouds.abiquo.monitor.functions.VirtualMachineStateMonitor; -import org.jclouds.abiquo.monitor.functions.VirtualMachineUndeployMonitor; -import org.jclouds.rest.RestContext; - -import com.abiquo.server.core.cloud.VirtualMachineState; -import com.google.common.annotations.VisibleForTesting; -import com.google.common.eventbus.EventBus; - -/** - * Default monitor for {@link VirtualMachine} objects. - * - * @author Ignasi Barrera - */ -@Singleton -public class BaseVirtualMachineMonitor extends BaseMonitoringService implements VirtualMachineMonitor { - @VisibleForTesting - protected VirtualMachineDeployMonitor deployMonitor; - - @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"); - } - - @Override - public void awaitCompletionDeploy(final VirtualMachine... vms) { - awaitCompletion(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 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 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 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 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 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 deleted file mode 100644 index 2a5f2c427b..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/ErrorPredicates.java +++ /dev/null @@ -1,45 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.predicates; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.Arrays; - -import com.abiquo.model.transport.error.ErrorDto; -import com.google.common.base.Predicate; - -/** - * Container for {@link ErrorDto} filters. - * - * @author Ignasi Barrera - */ -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()); - } - }; - } -} 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 deleted file mode 100644 index bd512284ae..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/LinkPredicates.java +++ /dev/null @@ -1,54 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.predicates; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.Arrays; - -import com.abiquo.model.rest.RESTLink; -import com.google.common.base.Predicate; - -/** - * Container for {@link RESTLink} filters. - * - * @author Ignasi Barrera - */ -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()); - } - }; - } - - 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 deleted file mode 100644 index 4a144e0461..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/cloud/ConversionPredicates.java +++ /dev/null @@ -1,84 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.predicates.cloud; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.Arrays; - -import org.jclouds.abiquo.domain.cloud.Conversion; - -import com.abiquo.model.enumerator.ConversionState; -import com.abiquo.model.enumerator.DiskFormatType; -import com.abiquo.model.enumerator.HypervisorType; -import com.google.common.base.Predicate; - -/** - * Container for {@link VirtualMachineTemplate} filters. - * - * @author Francesc Montserrat - */ -public class ConversionPredicates { - - 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()); - } - }; - } - - 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()); - } - }; - } - - 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()); - } - }; - } - - 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()); - } - }; - } - -} 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 deleted file mode 100644 index 35b5cba0b6..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/cloud/VirtualAppliancePredicates.java +++ /dev/null @@ -1,58 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.predicates.cloud; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.Arrays; - -import org.jclouds.abiquo.domain.cloud.VirtualAppliance; - -import com.abiquo.server.core.cloud.VirtualApplianceState; -import com.google.common.base.Predicate; - -/** - * Container for {@link VirtualAppliance} filters. - * - * @author Serafín Sedano - */ -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()); - } - }; - } - - 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()); - } - }; - } -} 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 deleted file mode 100644 index 81f3b4956a..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/cloud/VirtualDatacenterPredicates.java +++ /dev/null @@ -1,117 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.predicates.cloud; - -import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.collect.Iterables.transform; - -import java.util.Arrays; -import java.util.List; - -import org.jclouds.abiquo.domain.cloud.Conversion; -import org.jclouds.abiquo.domain.cloud.VirtualDatacenter; -import org.jclouds.abiquo.domain.cloud.VirtualMachineTemplate; -import org.jclouds.abiquo.domain.infrastructure.Datacenter; -import org.jclouds.abiquo.reference.ValidationErrors; -import org.jclouds.abiquo.reference.rest.ParentLinkName; - -import com.abiquo.model.enumerator.ConversionState; -import com.abiquo.model.enumerator.HypervisorType; -import com.google.common.base.Function; -import com.google.common.base.Predicate; -import com.google.common.collect.Lists; - -/** - * Container for {@link VirtualDatacenter} filters. - * - * @author Ignasi Barrera - */ -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()); - } - }; - } - - 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; - } - }; - } -} 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 deleted file mode 100644 index bc2c95e17e..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/cloud/VirtualMachinePredicates.java +++ /dev/null @@ -1,70 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.predicates.cloud; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.Arrays; - -import org.jclouds.abiquo.domain.cloud.VirtualMachine; - -import com.abiquo.server.core.cloud.VirtualMachineState; -import com.google.common.base.Predicate; - -/** - * Container for {@link VirtualMachine} filters. - * - * @author Ignasi Barrera - */ -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()); - } - }; - } - - 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()); - } - }; - } - - 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()); - } - }; - } -} 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 deleted file mode 100644 index c3277da44b..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/cloud/VirtualMachineTemplatePredicates.java +++ /dev/null @@ -1,99 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.predicates.cloud; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.Arrays; - -import org.jclouds.abiquo.domain.cloud.VirtualMachineTemplate; - -import com.abiquo.model.enumerator.DiskFormatType; -import com.abiquo.model.enumerator.HypervisorType; -import com.google.common.base.Predicate; - -/** - * Container for {@link VirtualMachineTemplate} filters. - * - * @author Francesc Montserrat - */ -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()); - } - }; - } - - 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()); - } - }; - } - - 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()); - } - }; - } - - 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()); - } - }; - } - - 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; - } - }; - } -} 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 deleted file mode 100644 index 0b012a664b..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/cloud/VolumePredicates.java +++ /dev/null @@ -1,89 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.predicates.cloud; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.Arrays; - -import org.jclouds.abiquo.domain.cloud.Volume; - -import com.abiquo.model.enumerator.VolumeState; -import com.google.common.base.Predicate; -import com.google.common.base.Predicates; - -/** - * Container for {@link Volume} filters. - * - * @author Ignasi Barrera - */ -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()); - } - }; - } - - 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; - } - }; - } - - 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; - } - }; - } - - 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 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())); - } - }; - } -} 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 deleted file mode 100644 index 0d172a4970..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/config/CategoryPredicates.java +++ /dev/null @@ -1,48 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.predicates.config; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.Arrays; - -import org.jclouds.abiquo.domain.config.Category; - -import com.google.common.base.Predicate; - -/** - * Container for {@link Category} filters. - * - * @author Ignasi Barrera - * @author Francesc Montserrat - */ -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()); - } - }; - } - -} 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 deleted file mode 100644 index a845cc26be..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/config/LicensePredicates.java +++ /dev/null @@ -1,57 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.predicates.config; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.Arrays; - -import org.jclouds.abiquo.domain.config.License; - -import com.google.common.base.Predicate; - -/** - * Container for {@link License} filters. - * - * @author Ignasi Barrera - */ -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()); - } - }; - } - - 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()); - } - }; - } -} 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 deleted file mode 100644 index cbeda4c360..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/config/PricingPredicates.java +++ /dev/null @@ -1,71 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.predicates.config; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.Arrays; - -import org.jclouds.abiquo.domain.config.CostCode; -import org.jclouds.abiquo.domain.config.Currency; -import org.jclouds.abiquo.domain.config.PricingTemplate; - -import com.google.common.base.Predicate; - -/** - * Container for pricing related filters. - * - * @author Ignasi Barrera - * @author Susana Acedo - */ -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()); - } - }; - } - - 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()); - } - }; - } - - 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()); - } - }; - } -} 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 deleted file mode 100644 index 93e4510915..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/config/PrivilegePredicates.java +++ /dev/null @@ -1,47 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.predicates.config; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.Arrays; - -import org.jclouds.abiquo.domain.config.Privilege; - -import com.google.common.base.Predicate; - -/** - * Container for {@link Privilege} filters. - * - * @author Ignasi Barrera - */ -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()); - } - }; - } - -} 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 deleted file mode 100644 index b0b04aaa5d..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/config/SystemPropertyPredicates.java +++ /dev/null @@ -1,48 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.predicates.config; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.Arrays; - -import org.jclouds.abiquo.domain.config.SystemProperty; - -import com.google.common.base.Predicate; - -/** - * Container for {@link SystemProperty} filters. - * - * @author Ignasi Barrera - * @author Francesc Montserrat - */ -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()); - } - }; - } - -} 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 deleted file mode 100644 index b7eaf33234..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/enterprise/EnterprisePredicates.java +++ /dev/null @@ -1,46 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.predicates.enterprise; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.Arrays; - -import org.jclouds.abiquo.domain.enterprise.Enterprise; - -import com.google.common.base.Predicate; - -/** - * Container for {@link Enterprise} filters. - * - * @author Ignasi Barrera - */ -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()); - } - }; - } -} 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 deleted file mode 100644 index 0226f12263..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/enterprise/RolePredicates.java +++ /dev/null @@ -1,46 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.predicates.enterprise; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.Arrays; - -import org.jclouds.abiquo.domain.enterprise.Role; - -import com.google.common.base.Predicate; - -/** - * Container for {@link Role} filters. - * - * @author Ignasi Barrera - */ -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()); - } - }; - } -} 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 deleted file mode 100644 index 5cd228a3c2..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/enterprise/TemplateDefinitionListPredicates.java +++ /dev/null @@ -1,47 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.predicates.enterprise; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.Arrays; - -import org.jclouds.abiquo.domain.enterprise.TemplateDefinitionList; - -import com.google.common.base.Predicate; - -/** - * Container for {@link TemplateDefinitionList} filters. - * - * @author Ignasi Barrera - * @author Francesc Montserrat - */ -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()); - } - }; - } -} 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 deleted file mode 100644 index d910d345c0..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/enterprise/UserPredicates.java +++ /dev/null @@ -1,46 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.predicates.enterprise; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.Arrays; - -import org.jclouds.abiquo.domain.enterprise.User; - -import com.google.common.base.Predicate; - -/** - * Container for {@link User} filters. - * - * @author Ignasi Barrera - */ -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()); - } - }; - } -} 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 deleted file mode 100644 index 5e857b2f5a..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/infrastructure/BladePredicates.java +++ /dev/null @@ -1,62 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.predicates.infrastructure; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.Arrays; - -import org.jclouds.abiquo.domain.infrastructure.Blade; - -import com.google.common.base.Predicate; - -/** - * Container for {@link Blade} filters. - * - * @author Ignasi Barrera - * @author Francesc Montserrat - */ -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()); - } - }; - } - - 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"); - - 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 deleted file mode 100644 index f68b40d325..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/infrastructure/DatacenterPredicates.java +++ /dev/null @@ -1,68 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.predicates.infrastructure; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.Arrays; - -import org.jclouds.abiquo.domain.infrastructure.Datacenter; - -import com.google.common.base.Predicate; - -/** - * Container for {@link Datacenter} filters. - * - * @author Ignasi Barrera - */ -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()); - } - }; - } - - 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()); - } - }; - } - - 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()); - } - }; - } -} 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 deleted file mode 100644 index ff135d7494..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/infrastructure/DatastorePredicates.java +++ /dev/null @@ -1,46 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.predicates.infrastructure; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.Arrays; - -import org.jclouds.abiquo.domain.infrastructure.Datastore; - -import com.google.common.base.Predicate; - -/** - * Container for {@link Datastore} filters. - * - * @author Ignasi Barrera - */ -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()); - } - }; - } -} 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 deleted file mode 100644 index 07cbca22fc..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/infrastructure/HypervisorPredicates.java +++ /dev/null @@ -1,46 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.predicates.infrastructure; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.Arrays; - -import com.abiquo.model.enumerator.HypervisorType; -import com.google.common.base.Predicate; - -/** - * Container for {@link HypervisorType} filters. - * - * @author Ignasi Barrera - * @author Francesc Montserrat - */ -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); - } - }; - } -} 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 deleted file mode 100644 index d185b08283..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/infrastructure/LogicServerPredicates.java +++ /dev/null @@ -1,46 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.predicates.infrastructure; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.Arrays; - -import org.jclouds.abiquo.domain.infrastructure.LogicServer; - -import com.google.common.base.Predicate; - -/** - * Container for {@link LogicServer} filters. - * - * @author Francesc Montserrat - */ -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()); - } - }; - } -} 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 deleted file mode 100644 index f7bfb3add7..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/infrastructure/MachinePredicates.java +++ /dev/null @@ -1,62 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.predicates.infrastructure; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.Arrays; - -import org.jclouds.abiquo.domain.infrastructure.Machine; - -import com.google.common.base.Predicate; - -/** - * Container for {@link Machine} filters. - * - * @author Ignasi Barrera - * @author Francesc Montserrat - */ -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()); - } - }; - } - - 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"); - - 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 deleted file mode 100644 index 51b6771cb2..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/infrastructure/ManagedRackPredicates.java +++ /dev/null @@ -1,47 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.predicates.infrastructure; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.Arrays; - -import org.jclouds.abiquo.domain.infrastructure.ManagedRack; - -import com.google.common.base.Predicate; - -/** - * Container for {@link ManagedRack} filters. - * - * @author Ignasi Barrera - * @author Francesc Montserrat - */ -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()); - } - }; - } -} diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/infrastructure/NetworkInterfacePredicates.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/infrastructure/NetworkInterfacePredicates.java deleted file mode 100644 index a56b3525bd..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/infrastructure/NetworkInterfacePredicates.java +++ /dev/null @@ -1,46 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.abiquo.predicates.infrastructure; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.Arrays; - -import org.jclouds.abiquo.domain.infrastructure.NetworkInterface; - -import com.google.common.base.Predicate; - -/** - * Container for {@link NetworkInterface} filters. - * - * @author Jaume Devesa - */ -public class NetworkInterfacePredicates { - public static Predicate name(final String... names) { - checkNotNull(names, "names must be defined"); - - return new Predicate() { - @Override - public boolean apply(final NetworkInterface ni) { - return Arrays.asList(names).contains(ni.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 deleted file mode 100644 index 9b418632bf..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/infrastructure/RackPredicates.java +++ /dev/null @@ -1,47 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.predicates.infrastructure; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.Arrays; - -import org.jclouds.abiquo.domain.infrastructure.Rack; - -import com.google.common.base.Predicate; - -/** - * Container for {@link Rack} filters. - * - * @author Ignasi Barrera - * @author Francesc Montserrat - */ -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()); - } - }; - } -} 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 deleted file mode 100644 index 8b7cf7daaa..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/infrastructure/RemoteServicePredicates.java +++ /dev/null @@ -1,48 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.predicates.infrastructure; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.Arrays; - -import org.jclouds.abiquo.domain.infrastructure.RemoteService; - -import com.abiquo.model.enumerator.RemoteServiceType; -import com.google.common.base.Predicate; - -/** - * Container for {@link RemoteService} filters. - * - * @author Ignasi Barrera - * @author Francesc Montserrat - */ -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()); - } - }; - } -} 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 deleted file mode 100644 index 52ce2106e4..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/infrastructure/StorageDeviceMetadataPredicates.java +++ /dev/null @@ -1,47 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.predicates.infrastructure; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.Arrays; - -import org.jclouds.abiquo.domain.infrastructure.StorageDeviceMetadata; - -import com.google.common.base.Predicate; - -/** - * Container for {@link StorageDeviceMetadata} filters. - * - * @author Ignasi Barrera - */ -public class StorageDeviceMetadataPredicates { - - 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()); - } - }; - } -} 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 deleted file mode 100644 index e957057205..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/infrastructure/StorageDevicePredicates.java +++ /dev/null @@ -1,69 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.predicates.infrastructure; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.Arrays; - -import org.jclouds.abiquo.domain.infrastructure.StorageDevice; - -import com.google.common.base.Predicate; - -/** - * Container for {@link StorageDevice} filters. - * - * @author Ignasi Barrera - * @author Francesc Montserrat - */ -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()); - } - }; - } - - 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()); - } - }; - } - - 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()); - } - }; - } -} 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 deleted file mode 100644 index 7cfc033c5e..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/infrastructure/StoragePoolPredicates.java +++ /dev/null @@ -1,47 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.predicates.infrastructure; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.Arrays; - -import org.jclouds.abiquo.domain.infrastructure.StoragePool; - -import com.google.common.base.Predicate; - -/** - * Container for {@link StoragePool} filters. - * - * @author Ignasi Barrera - * @author Francesc Montserrat - */ -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()); - } - }; - } -} 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 deleted file mode 100644 index 7ae1047b47..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/infrastructure/TierPredicates.java +++ /dev/null @@ -1,47 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.predicates.infrastructure; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.Arrays; - -import org.jclouds.abiquo.domain.infrastructure.Tier; - -import com.google.common.base.Predicate; - -/** - * Container for {@link Tier} filters. - * - * @author Ignasi Barrera - * @author Francesc Montserrat - */ -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()); - } - }; - } -} 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 deleted file mode 100644 index 8c69188eaf..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/network/IpPredicates.java +++ /dev/null @@ -1,76 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.predicates.network; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.Arrays; - -import org.jclouds.abiquo.domain.network.AbstractPublicIp; -import org.jclouds.abiquo.domain.network.Ip; - -import com.google.common.base.Predicate; - -/** - * Container for {@link Network} filters. - * - * @author Francesc Montserrat - */ -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()); - } - }; - } - - 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()); - } - }; - } - - 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; - } - }; - } -} 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 deleted file mode 100644 index 440d829c73..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/network/NetworkPredicates.java +++ /dev/null @@ -1,47 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.predicates.network; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.Arrays; - -import org.jclouds.abiquo.domain.network.Ip; -import org.jclouds.abiquo.domain.network.Network; - -import com.google.common.base.Predicate; - -/** - * Container for {@link Network} filters. - * - * @author Francesc Montserrat - */ -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()); - } - }; - } -} diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/network/NetworkServiceTypePredicates.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/network/NetworkServiceTypePredicates.java deleted file mode 100644 index a34ff630d0..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/network/NetworkServiceTypePredicates.java +++ /dev/null @@ -1,40 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.predicates.network; - -import org.jclouds.abiquo.domain.network.NetworkServiceType; - -import com.google.common.base.Predicate; - -/** - * Container for {@link NetworkServiceType} filters. - * - * @author Jaume Devesa - */ -public class NetworkServiceTypePredicates { - public static Predicate isDefault() { - return new Predicate() { - @Override - public boolean apply(final NetworkServiceType ni) { - return ni.isDefaultNST(); - } - }; - } -} 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 deleted file mode 100644 index 35477fb91f..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/network/NicPredicates.java +++ /dev/null @@ -1,57 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.predicates.network; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.Arrays; - -import org.jclouds.abiquo.domain.network.Nic; - -import com.google.common.base.Predicate; - -/** - * Container for {@link Nic} filters. - * - * @author Francesc Montserrat - */ -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()); - } - }; - } - - 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()); - } - }; - } -} 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 deleted file mode 100644 index 73c74f0711..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/task/AsyncTaskPredicates.java +++ /dev/null @@ -1,47 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.predicates.task; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.Arrays; - -import org.jclouds.abiquo.domain.task.AsyncTask; - -import com.abiquo.server.core.task.enums.TaskState; -import com.google.common.base.Predicate; - -/** - * Container for {@link AsyncTask} filters. - * - * @author Ignasi Barrera - */ -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()); - } - }; - } -} 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 deleted file mode 100644 index 7b04c84a25..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/reference/ValidationErrors.java +++ /dev/null @@ -1,36 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.reference; - -/** - * Error constants. - * - * @author Francesc Montserrat - */ -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_LINK = "Missing required link "; - - 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 deleted file mode 100644 index 7eb1972b3e..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/reference/annotations/EnterpriseEdition.java +++ /dev/null @@ -1,34 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.reference.annotations; - -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; - -/** - * Indicates that the annotated element will access Abiquo Enterprise Edition - * functionality. 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 { -} 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 deleted file mode 100644 index 6ae462eef1..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/reference/rest/ParentLinkName.java +++ /dev/null @@ -1,65 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.reference.rest; - -/** - * Names of the "rel" attribute of the links that point to parent objects. - * - * @author Francesc Montserrat - */ -public class ParentLinkName { - public static final String RACK = "rack"; - - public static final String DATACENTER = "datacenter"; - - public static final String ENTERPRISE = "enterprise"; - - public static final String ROLE = "role"; - - public static final String TIER = "tier"; - - public static final String STORAGE_DEVICE = "device"; - - public static final String VIRTUAL_DATACENTER = "virtualdatacenter"; - - public static final String VIRTUAL_APPLIANCE = "virtualappliance"; - - public static final String VIRTUAL_MACHINE_TEMPLATE = "virtualmachinetemplate"; - - public static final String DATACENTER_REPOSITORY = "datacenterrepository"; - - public static final String COST_CODE = "costcode"; - - public static final String CATEGORY = "category"; - - public static final String ICON = "icon"; - - public static final String PRIVATE_NETWORK = "privatenetwork"; - - public static final String PUBLIC_NETWORK = "publicnetwork"; - - public static final String EXTERNAL_NETWORK = "externalnetwork"; - - public static final String UNMANAGED_NETWORK = "unmanagednetwork"; - - public static final String NETWORK_CONFIGURATIONS = "configurations"; - - public static final 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 deleted file mode 100644 index e7392f6adf..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/rest/annotations/EndpointLink.java +++ /dev/null @@ -1,40 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.rest.annotations; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Indicates the link to be used to generate the endpoint for the request. - * - * @author Ignasi Barrera - */ -@Target({ ElementType.PARAMETER }) -@Retention(RetentionPolicy.RUNTIME) -public @interface EndpointLink { - - /** - * 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 deleted file mode 100644 index 758981d687..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/rest/internal/AbiquoHttpAsyncClient.java +++ /dev/null @@ -1,49 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.rest.internal; - -import javax.ws.rs.GET; - -import org.jclouds.Fallbacks.NullOnNotFoundOr404; -import org.jclouds.abiquo.binders.BindLinkToPathAndAcceptHeader; -import org.jclouds.abiquo.http.filters.AbiquoAuthentication; -import org.jclouds.abiquo.http.filters.AppendApiVersionToMediaType; -import org.jclouds.http.HttpResponse; -import org.jclouds.rest.annotations.BinderParam; -import org.jclouds.rest.annotations.Fallback; -import org.jclouds.rest.annotations.RequestFilters; - -import com.abiquo.model.rest.RESTLink; -import com.google.common.util.concurrent.ListenableFuture; - -/** - * Custom Rest methods to work with the Abiquo Api. - * - * @author Ignasi Barrera - */ -@RequestFilters({ AbiquoAuthentication.class, AppendApiVersionToMediaType.class }) -public interface AbiquoHttpAsyncClient { - /** - * @see AbiquoHttpClient#get(RESTLink) - */ - @GET - @Fallback(NullOnNotFoundOr404.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 deleted file mode 100644 index 01d6e62ec8..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/rest/internal/AbiquoHttpClient.java +++ /dev/null @@ -1,40 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.rest.internal; - -import org.jclouds.http.HttpResponse; - -import com.abiquo.model.rest.RESTLink; - -/** - * Custom Rest methods to work with the Abiquo Api. - * - * @author Ignasi Barrera - */ -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 deleted file mode 100644 index c6358ec94c..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/rest/internal/ExtendedUtils.java +++ /dev/null @@ -1,78 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.rest.internal; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.Map; - -import javax.inject.Inject; -import javax.inject.Named; - -import org.jclouds.Constants; -import org.jclouds.crypto.Crypto; -import org.jclouds.date.DateService; -import org.jclouds.domain.Credentials; -import org.jclouds.json.Json; -import org.jclouds.logging.Logger.LoggerFactory; -import org.jclouds.rest.HttpAsyncClient; -import org.jclouds.rest.HttpClient; -import org.jclouds.rest.Utils; -import org.jclouds.rest.internal.UtilsImpl; -import org.jclouds.xml.XMLParser; - -import com.google.common.eventbus.EventBus; -import com.google.common.util.concurrent.ListeningExecutorService; -import com.google.inject.Injector; -import com.google.inject.Singleton; - -/** - * Custom utility methods. - * - * @author Ignasi Barrera - */ -@Singleton -public class ExtendedUtils extends UtilsImpl implements Utils { - private AbiquoHttpClient abiquoHttpClient; - - 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 ListeningExecutorService userExecutor, - @Named(Constants.PROPERTY_IO_WORKER_THREADS) final ListeningExecutorService ioExecutor, final EventBus eventBus, - final Map credentialStore, final LoggerFactory loggerFactory, - final AbiquoHttpClient abiquoHttpClient, final AbiquoHttpAsyncClient abiquoHttpAsyncApi) { - super(injector, json, xml, simpleApi, simpleAsyncApi, encryption, date, userExecutor, ioExecutor, eventBus, - credentialStore, loggerFactory); - this.abiquoHttpClient = checkNotNull(abiquoHttpClient, "abiquoHttpClient"); - this.abiquoHttpAsyncApi = checkNotNull(abiquoHttpAsyncApi, "abiquoHttpAsyncApi"); - } - - public AbiquoHttpClient getAbiquoHttpClient() { - return abiquoHttpClient; - } - - 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 deleted file mode 100644 index 2606517d02..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/ListEntities.java +++ /dev/null @@ -1,35 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.strategy; - -import org.jclouds.abiquo.domain.DomainWrapper; - -import com.google.common.base.Predicate; - -/** - * List all entities of the given type. - * - * @author Ignasi Barrera - */ -public interface ListEntities, P extends DomainWrapper> { - Iterable execute(P parent); - - 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 deleted file mode 100644 index 255eb2f08d..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/ListRootEntities.java +++ /dev/null @@ -1,35 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.strategy; - -import org.jclouds.abiquo.domain.DomainWrapper; - -import com.google.common.base.Predicate; - -/** - * List all entities of the given type. - * - * @author Ignasi Barrera - */ -public interface ListRootEntities> { - Iterable execute(); - - Iterable execute(Predicate 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 deleted file mode 100644 index 51abbb10d1..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/cloud/ListAttachedNics.java +++ /dev/null @@ -1,114 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.strategy.cloud; - -import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.collect.Iterables.filter; -import static com.google.common.collect.Iterables.transform; -import static org.jclouds.abiquo.domain.DomainWrapper.wrap; - -import org.jclouds.abiquo.AbiquoApi; -import org.jclouds.abiquo.AbiquoAsyncApi; -import org.jclouds.abiquo.domain.cloud.VirtualMachine; -import org.jclouds.abiquo.domain.network.ExternalIp; -import org.jclouds.abiquo.domain.network.Ip; -import org.jclouds.abiquo.domain.network.PrivateIp; -import org.jclouds.abiquo.domain.network.PublicIp; -import org.jclouds.abiquo.domain.network.UnmanagedIp; -import org.jclouds.abiquo.domain.util.LinkUtils; -import org.jclouds.abiquo.rest.internal.ExtendedUtils; -import org.jclouds.abiquo.strategy.ListEntities; -import org.jclouds.http.HttpResponse; -import org.jclouds.http.functions.ParseXMLWithJAXB; -import org.jclouds.rest.RestContext; - -import com.abiquo.model.rest.RESTLink; -import com.abiquo.server.core.infrastructure.network.ExternalIpDto; -import com.abiquo.server.core.infrastructure.network.PrivateIpDto; -import com.abiquo.server.core.infrastructure.network.PublicIpDto; -import com.abiquo.server.core.infrastructure.network.UnmanagedIpDto; -import com.google.common.base.Function; -import com.google.common.base.Predicate; -import com.google.inject.Inject; -import com.google.inject.Singleton; -import com.google.inject.TypeLiteral; - -/** - * List all NICs attached to a given virtual machine. - * - * @author Ignasi Barrera - */ -@Singleton -public class ListAttachedNics implements ListEntities, VirtualMachine> { - protected final RestContext context; - - protected final ExtendedUtils extendedUtils; - - @Inject - public ListAttachedNics(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, 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); - - 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, 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, 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/ListVirtualAppliances.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/cloud/ListVirtualAppliances.java deleted file mode 100644 index e1d84207d8..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/cloud/ListVirtualAppliances.java +++ /dev/null @@ -1,103 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.strategy.cloud; - -import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.collect.Iterables.filter; -import static org.jclouds.abiquo.domain.DomainWrapper.wrap; -import static org.jclouds.concurrent.FutureIterables.transformParallel; - -import javax.annotation.Resource; -import javax.inject.Named; - -import org.jclouds.Constants; -import org.jclouds.abiquo.AbiquoApi; -import org.jclouds.abiquo.AbiquoAsyncApi; -import org.jclouds.abiquo.domain.DomainWrapper; -import org.jclouds.abiquo.domain.cloud.VirtualAppliance; -import org.jclouds.abiquo.domain.cloud.VirtualDatacenter; -import org.jclouds.abiquo.strategy.ListRootEntities; -import org.jclouds.logging.Logger; -import org.jclouds.rest.RestContext; - -import com.abiquo.server.core.cloud.VirtualApplianceDto; -import com.abiquo.server.core.cloud.VirtualAppliancesDto; -import com.google.common.base.Function; -import com.google.common.base.Predicate; -import com.google.common.util.concurrent.ListenableFuture; -import com.google.common.util.concurrent.ListeningExecutorService; -import com.google.inject.Inject; -import com.google.inject.Singleton; - -/** - * List virtual appliances in each virtual datacenter. - * - * @author Ignasi Barrera - */ -@Singleton -public class ListVirtualAppliances implements ListRootEntities { - protected final RestContext context; - - protected final ListVirtualDatacenters listVirtualDatacenters; - - protected final ListeningExecutorService userExecutor; - - @Resource - protected Logger logger = Logger.NULL; - - @Inject(optional = true) - @Named(Constants.PROPERTY_REQUEST_TIMEOUT) - protected Long maxTime; - - @Inject - ListVirtualAppliances(final RestContext context, - @Named(Constants.PROPERTY_USER_THREADS) final ListeningExecutorService 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); - - return wrap(context, VirtualAppliance.class, vapps); - } - - @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 ListenableFuture apply(final VirtualDatacenter input) { - return context.getAsyncApi().getCloudApi().listVirtualAppliances(input.unwrap()); - } - }, userExecutor, maxTime, logger, "getting virtual appliances"); - - return DomainWrapper.join(vapps); - } -} 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 deleted file mode 100644 index d0dd08a2b7..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/cloud/ListVirtualDatacenters.java +++ /dev/null @@ -1,116 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.strategy.cloud; - -import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.collect.Iterables.filter; -import static org.jclouds.abiquo.domain.DomainWrapper.wrap; -import static org.jclouds.concurrent.FutureIterables.transformParallel; - -import java.util.List; - -import javax.annotation.Resource; -import javax.inject.Named; - -import org.jclouds.Constants; -import org.jclouds.abiquo.AbiquoApi; -import org.jclouds.abiquo.AbiquoAsyncApi; -import org.jclouds.abiquo.domain.DomainWrapper; -import org.jclouds.abiquo.domain.cloud.VirtualDatacenter; -import org.jclouds.abiquo.domain.cloud.options.VirtualDatacenterOptions; -import org.jclouds.abiquo.strategy.ListRootEntities; -import org.jclouds.logging.Logger; -import org.jclouds.rest.RestContext; - -import com.abiquo.server.core.cloud.VirtualDatacenterDto; -import com.abiquo.server.core.cloud.VirtualDatacentersDto; -import com.google.common.base.Function; -import com.google.common.base.Predicate; -import com.google.common.collect.Lists; -import com.google.common.util.concurrent.ListenableFuture; -import com.google.common.util.concurrent.ListeningExecutorService; -import com.google.inject.Inject; -import com.google.inject.Singleton; - -/** - * List virtual datacenters. - * - * @author Ignasi Barrera - */ -@Singleton -public class ListVirtualDatacenters implements ListRootEntities { - protected final RestContext context; - - protected final ListeningExecutorService userExecutor; - - @Resource - protected Logger logger = Logger.NULL; - - @Inject(optional = true) - @Named(Constants.PROPERTY_REQUEST_TIMEOUT) - protected Long maxTime; - - @Inject - ListVirtualDatacenters(final RestContext context, - @Named(Constants.PROPERTY_USER_THREADS) final ListeningExecutorService userExecutor) { - this.context = checkNotNull(context, "context"); - this.userExecutor = checkNotNull(userExecutor, "userExecutor"); - } - - @Override - public Iterable execute() { - VirtualDatacenterOptions virtualDatacenterOptions = VirtualDatacenterOptions.builder().build(); - - return execute(virtualDatacenterOptions); - } - - @Override - public Iterable execute(final Predicate selector) { - return filter(execute(), selector); - } - - public Iterable execute(final VirtualDatacenterOptions virtualDatacenterOptions) { - VirtualDatacentersDto result = context.getApi().getCloudApi().listVirtualDatacenters(virtualDatacenterOptions); - return wrap(context, VirtualDatacenter.class, result.getCollection()); - } - - public Iterable execute(final Predicate selector, - final VirtualDatacenterOptions virtualDatacenterOptions) { - return filter(execute(virtualDatacenterOptions), selector); - } - - 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 ListenableFuture 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)); - } - -} 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 deleted file mode 100644 index 03687e4114..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/cloud/ListVirtualMachines.java +++ /dev/null @@ -1,110 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.strategy.cloud; - -import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.collect.Iterables.filter; -import static org.jclouds.abiquo.domain.DomainWrapper.wrap; -import static org.jclouds.concurrent.FutureIterables.transformParallel; - -import javax.annotation.Resource; -import javax.inject.Named; - -import org.jclouds.Constants; -import org.jclouds.abiquo.AbiquoApi; -import org.jclouds.abiquo.AbiquoAsyncApi; -import org.jclouds.abiquo.domain.DomainWrapper; -import org.jclouds.abiquo.domain.cloud.VirtualAppliance; -import org.jclouds.abiquo.domain.cloud.VirtualMachine; -import org.jclouds.abiquo.domain.cloud.options.VirtualMachineOptions; -import org.jclouds.abiquo.strategy.ListRootEntities; -import org.jclouds.logging.Logger; -import org.jclouds.rest.RestContext; - -import com.abiquo.server.core.cloud.VirtualMachineWithNodeExtendedDto; -import com.abiquo.server.core.cloud.VirtualMachinesWithNodeExtendedDto; -import com.google.common.base.Function; -import com.google.common.base.Predicate; -import com.google.common.util.concurrent.ListenableFuture; -import com.google.common.util.concurrent.ListeningExecutorService; -import com.google.inject.Inject; -import com.google.inject.Singleton; - -/** - * List virtual machines in each virtual datacenter and each virtual appliance. - * - * @author Ignasi Barrera - */ -@Singleton -public class ListVirtualMachines implements ListRootEntities { - protected final RestContext context; - - protected final ListeningExecutorService userExecutor; - - protected final ListVirtualAppliances listVirtualAppliances; - - @Resource - protected Logger logger = Logger.NULL; - - @Inject(optional = true) - @Named(Constants.PROPERTY_REQUEST_TIMEOUT) - protected Long maxTime; - - @Inject - ListVirtualMachines(final RestContext context, - @Named(Constants.PROPERTY_USER_THREADS) final ListeningExecutorService 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()); - } - - 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); - } - - @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 ListenableFuture apply(final VirtualAppliance input) { - return context.getAsyncApi().getCloudApi().listVirtualMachines(input.unwrap(), options); - } - }, userExecutor, maxTime, logger, "getting virtual machines"); - - return DomainWrapper.join(vms); - } -} 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 deleted file mode 100644 index 93780fa304..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/enterprise/ListVirtualMachineTemplates.java +++ /dev/null @@ -1,104 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.strategy.enterprise; - -import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.collect.Iterables.filter; -import static org.jclouds.abiquo.domain.DomainWrapper.wrap; -import static org.jclouds.concurrent.FutureIterables.transformParallel; - -import javax.annotation.Resource; -import javax.inject.Named; - -import org.jclouds.Constants; -import org.jclouds.abiquo.AbiquoApi; -import org.jclouds.abiquo.AbiquoAsyncApi; -import org.jclouds.abiquo.domain.DomainWrapper; -import org.jclouds.abiquo.domain.cloud.VirtualMachineTemplate; -import org.jclouds.abiquo.domain.enterprise.Enterprise; -import org.jclouds.abiquo.domain.infrastructure.Datacenter; -import org.jclouds.abiquo.strategy.ListEntities; -import org.jclouds.logging.Logger; -import org.jclouds.rest.RestContext; - -import com.abiquo.server.core.appslibrary.VirtualMachineTemplateDto; -import com.abiquo.server.core.appslibrary.VirtualMachineTemplatesDto; -import com.google.common.base.Function; -import com.google.common.base.Predicate; -import com.google.common.util.concurrent.ListenableFuture; -import com.google.common.util.concurrent.ListeningExecutorService; -import com.google.inject.Inject; -import com.google.inject.Singleton; - -/** - * List all virtual machine templates available to an enterprise. - * - * @author Ignasi Barrera - */ -@Singleton -public class ListVirtualMachineTemplates implements ListEntities { - protected final RestContext context; - - protected final ListeningExecutorService userExecutor; - - @Resource - protected Logger logger = Logger.NULL; - - @Inject(optional = true) - @Named(Constants.PROPERTY_REQUEST_TIMEOUT) - protected Long maxTime; - - @Inject - ListVirtualMachineTemplates(final RestContext context, - @Named(Constants.PROPERTY_USER_THREADS) final ListeningExecutorService 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); - - return wrap(context, VirtualMachineTemplate.class, templates); - } - - @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 ListenableFuture apply(final Datacenter input) { - return context.getAsyncApi().getVirtualMachineTemplateApi() - .listVirtualMachineTemplates(parent.getId(), input.getId()); - } - }, userExecutor, maxTime, logger, "getting virtual machine templates"); - - return DomainWrapper.join(templates); - } -} 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 deleted file mode 100644 index 275e1781b4..0000000000 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/infrastructure/ListMachines.java +++ /dev/null @@ -1,115 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.strategy.infrastructure; - -import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.collect.Iterables.filter; -import static org.jclouds.abiquo.domain.DomainWrapper.wrap; -import static org.jclouds.concurrent.FutureIterables.transformParallel; - -import javax.annotation.Resource; -import javax.inject.Named; - -import org.jclouds.Constants; -import org.jclouds.abiquo.AbiquoApi; -import org.jclouds.abiquo.AbiquoAsyncApi; -import org.jclouds.abiquo.domain.DomainWrapper; -import org.jclouds.abiquo.domain.infrastructure.Datacenter; -import org.jclouds.abiquo.domain.infrastructure.Machine; -import org.jclouds.abiquo.strategy.ListRootEntities; -import org.jclouds.logging.Logger; -import org.jclouds.rest.RestContext; - -import com.abiquo.server.core.infrastructure.DatacentersDto; -import com.abiquo.server.core.infrastructure.MachineDto; -import com.abiquo.server.core.infrastructure.MachinesDto; -import com.abiquo.server.core.infrastructure.RackDto; -import com.abiquo.server.core.infrastructure.RacksDto; -import com.google.common.base.Function; -import com.google.common.base.Predicate; -import com.google.common.util.concurrent.ListenableFuture; -import com.google.common.util.concurrent.ListeningExecutorService; -import com.google.inject.Inject; -import com.google.inject.Singleton; - -/** - * List machines in each datacenter and rack. - * - * @author Ignasi Barrera - */ -@Singleton -public class ListMachines implements ListRootEntities { - protected RestContext context; - - protected final ListeningExecutorService userExecutor; - - @Resource - protected Logger logger = Logger.NULL; - - @Inject(optional = true) - @Named(Constants.PROPERTY_REQUEST_TIMEOUT) - protected Long maxTime; - - @Inject - ListMachines(final RestContext context, - @Named(Constants.PROPERTY_USER_THREADS) final ListeningExecutorService userExecutor) { - super(); - this.context = checkNotNull(context, "context"); - this.userExecutor = checkNotNull(userExecutor, "userExecutor"); - } - - @Override - public Iterable execute() { - // Find machines in concurrent requests - DatacentersDto result = context.getApi().getInfrastructureApi().listDatacenters(); - Iterable datacenters = wrap(context, Datacenter.class, result.getCollection()); - Iterable racks = listConcurrentRacks(datacenters); - Iterable machines = listConcurrentMachines(racks); - - return wrap(context, Machine.class, machines); - } - - @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 ListenableFuture apply(final Datacenter input) { - return context.getAsyncApi().getInfrastructureApi().listRacks(input.unwrap()); - } - }, userExecutor, maxTime, logger, "getting racks"); - - return DomainWrapper.join(racks); - } - - private Iterable listConcurrentMachines(final Iterable racks) { - Iterable machines = transformParallel(racks, new Function>() { - @Override - public ListenableFuture apply(final RackDto input) { - return context.getAsyncApi().getInfrastructureApi().listMachines(input); - } - }, userExecutor, maxTime, logger, "getting machines"); - - return DomainWrapper.join(machines); - } -} diff --git a/labs/abiquo/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata b/labs/abiquo/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata deleted file mode 100644 index 642f443f14..0000000000 --- a/labs/abiquo/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata +++ /dev/null @@ -1 +0,0 @@ -org.jclouds.abiquo.AbiquoApiMetadata \ No newline at end of file diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/AbiquoApiMetadataTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/AbiquoApiMetadataTest.java deleted file mode 100644 index 018575b9c4..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/AbiquoApiMetadataTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertTrue; - -import org.jclouds.apis.ApiMetadata; -import org.jclouds.apis.Apis; -import org.jclouds.compute.internal.BaseComputeServiceApiMetadataTest; -import org.testng.annotations.Test; - -/** - * Unit tests for the {@link AbiquoApiMetadata} class. - * - * @author Ignasi Barrera - */ -@Test(groups = "unit", testName = "AbiquoApiMetadataTest") -public class AbiquoApiMetadataTest extends BaseComputeServiceApiMetadataTest { - - public AbiquoApiMetadataTest() { - super(new AbiquoApiMetadata()); - } - - public void testAbiquoApiRegistered() { - ApiMetadata api = Apis.withId("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 deleted file mode 100644 index 99488ded4c..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/AbiquoDelegateApiTest.java +++ /dev/null @@ -1,77 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo; - -import static org.testng.Assert.assertNotNull; - -import java.io.IOException; -import java.util.concurrent.ExecutionException; - -import org.jclouds.abiquo.features.BaseAbiquoAsyncApiTest; -import org.jclouds.http.HttpRequest; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -/** - * Tests asynchronous and synchronous API delegates. - * - * @author Ignasi Barrera - */ -@Test(groups = "unit", testName = "AbiquoDelegateApiTest") -public class AbiquoDelegateApiTest extends BaseAbiquoAsyncApiTest { - private AbiquoAsyncApi asyncApi; - - private AbiquoApi syncApi; - - @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 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 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 deleted file mode 100644 index 19ec5e2a10..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/binders/AppendToPathTest.java +++ /dev/null @@ -1,56 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.binders; - -import static org.testng.Assert.assertEquals; - -import java.net.URI; - -import org.jclouds.http.HttpRequest; -import org.testng.annotations.Test; - -/** - * Unit tests for the {@link AppendToPath} binder. - * - * @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 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"); - } -} 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 deleted file mode 100644 index 426ff9a0af..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/binders/BindLinkToPathAndAcceptHeaderTest.java +++ /dev/null @@ -1,57 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.binders; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; - -import java.net.URI; - -import javax.ws.rs.core.HttpHeaders; - -import org.jclouds.http.HttpRequest; -import org.testng.annotations.Test; - -/** - * Unit tests for the {@link BindLinkToPathAndAcceptHeader} class. - * - * @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 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"); - - String accept = updatedRequest.getFirstHeaderOrNull(HttpHeaders.ACCEPT); - - 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 deleted file mode 100644 index b266696625..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/binders/BindLinkToPathTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.binders; - -import static org.testng.Assert.assertEquals; - -import org.testng.annotations.Test; - -import com.abiquo.model.rest.RESTLink; - -/** - * Unit tests for the {@link BindLinkToPath} class. - * - * @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); - } - - @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"); - } -} 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 deleted file mode 100644 index e4effc8391..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/binders/BindToPathTest.java +++ /dev/null @@ -1,166 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.binders; -import static org.jclouds.reflect.Reflection2.method; -import static org.testng.Assert.assertEquals; - -import java.net.URI; - -import javax.ws.rs.GET; -import javax.ws.rs.HttpMethod; -import javax.ws.rs.core.MediaType; - -import org.jclouds.abiquo.rest.annotations.EndpointLink; -import org.jclouds.http.HttpRequest; -import org.jclouds.reflect.Invocation; -import org.jclouds.rest.binders.BindException; -import org.jclouds.rest.internal.GeneratedHttpRequest; -import org.testng.annotations.Test; - -import com.abiquo.model.rest.RESTLink; -import com.abiquo.model.transport.SingleResourceTransportDto; -import com.google.common.collect.ImmutableList; -import com.google.common.reflect.Invokable; - -/** - * Unit tests for the {@link BindToPath} binder. - * - * @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()); - } - - @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 { - Invokable withEndpointLink = method(TestEndpointLink.class, "withEndpointLink", TestDto.class); - GeneratedHttpRequest request = GeneratedHttpRequest.builder() - .invocation(Invocation.create(withEndpointLink, ImmutableList. of(new TestDto()))) - .method(HttpMethod.GET) - .endpoint(URI.create("http://localhost")).build(); - - BindToPath binder = new BindToPath(); - binder.bindToRequest(request, null); - } - - @Test(expectedExceptions = IllegalArgumentException.class) - public void testInvalidInputType() throws SecurityException, NoSuchMethodException { - Invokable withEndpointLink = method(TestEndpointLink.class, "withEndpointLink", TestDto.class); - GeneratedHttpRequest request = GeneratedHttpRequest.builder() - .invocation(Invocation.create(withEndpointLink, ImmutableList. of(new TestDto()))) - .method(HttpMethod.GET) - .endpoint(URI.create("http://localhost")).build(); - - BindToPath binder = new BindToPath(); - binder.bindToRequest(request, new Object()); - } - - @Test(expectedExceptions = BindException.class) - public void testAnnotationNotPresent() throws SecurityException, NoSuchMethodException { - TestDto dto = new TestDto(); - Invokable withoutEndpointLink = method(TestEndpointLink.class, "withoutEndpointLink", TestDto.class); - GeneratedHttpRequest request = GeneratedHttpRequest.builder() - .invocation(Invocation.create(withoutEndpointLink, ImmutableList. of(dto))) - .method(HttpMethod.GET) - .endpoint(URI.create("http://localhost")).build(); - - BindToPath binder = new BindToPath(); - binder.bindToRequest(request, dto); - } - - @Test(expectedExceptions = NullPointerException.class) - public void testLinkNotPresent() throws SecurityException, NoSuchMethodException { - TestDto dto = new TestDto(); - Invokable withUnexistingLink = method(TestEndpointLink.class, "withUnexistingLink", TestDto.class); - GeneratedHttpRequest request = GeneratedHttpRequest.builder() - .invocation(Invocation.create(withUnexistingLink, ImmutableList. of(dto))) - .method(HttpMethod.GET) - .endpoint(URI.create("http://localhost")).build(); - - BindToPath binder = new BindToPath(); - binder.bindToRequest(request, dto); - } - - public void testBindWithoutParameters() throws SecurityException, NoSuchMethodException { - TestDto dto = new TestDto(); - Invokable withEndpointLink = method(TestEndpointLink.class, "withEndpointLink", TestDto.class); - GeneratedHttpRequest request = GeneratedHttpRequest.builder() - .invocation(Invocation.create(withEndpointLink, 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"); - } - - public void testBindWithQueryParameters() throws SecurityException, NoSuchMethodException { - TestDto dto = new TestDto(); - Invokable withEndpointLink = method(TestEndpointLink.class, "withEndpointLink", TestDto.class); - GeneratedHttpRequest request = GeneratedHttpRequest.builder() - .invocation(Invocation.create(withEndpointLink, 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"); - } - - static interface TestEndpointLink { - @GET - void withEndpointLink(@EndpointLink("edit") TestDto dto); - - @GET - void withUnexistingLink(@EndpointLink("unexisting") TestDto dto); - - @GET - void withoutEndpointLink(TestDto dto); - } - - static class TestDto extends SingleResourceTransportDto { - - private static final long serialVersionUID = 5381713583837345158L; - - public TestDto() { - addLink(new RESTLink("edit", "http://linkuri")); - } - - @Override - public String getMediaType() { - 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 deleted file mode 100644 index 220fa363ba..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/binders/cloud/BindHardDiskRefsToPayloadTest.java +++ /dev/null @@ -1,82 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.binders.cloud; - -import static org.jclouds.abiquo.domain.DomainUtils.withHeader; -import static org.jclouds.abiquo.util.Assert.assertPayloadEquals; - -import java.io.IOException; -import java.net.URI; - -import org.jclouds.abiquo.domain.CloudResources; -import org.jclouds.http.HttpRequest; -import org.jclouds.xml.internal.JAXBParser; -import org.testng.annotations.Test; - -import com.abiquo.model.transport.LinksDto; -import com.abiquo.server.core.infrastructure.storage.DiskManagementDto; - -/** - * Unit tests for the {@link BindHardDiskRefsToPayload} binder. - * - * @author Ignasi Barrera - */ -@Test(groups = "unit", testName = "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 = 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 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); - } -} 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 deleted file mode 100644 index b8649e106f..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/binders/cloud/BindIpRefToPayloadTest.java +++ /dev/null @@ -1,69 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.binders.cloud; - -import static org.jclouds.abiquo.domain.DomainUtils.withHeader; -import static org.jclouds.abiquo.util.Assert.assertPayloadEquals; - -import java.io.IOException; -import java.net.URI; - -import org.jclouds.abiquo.domain.NetworkResources; -import org.jclouds.http.HttpRequest; -import org.jclouds.xml.internal.JAXBParser; -import org.testng.annotations.Test; - -import com.abiquo.model.rest.RESTLink; -import com.abiquo.model.transport.LinksDto; -import com.abiquo.server.core.infrastructure.network.PrivateIpDto; - -/** - * Unit tests for the {@link BindIpRefToPayload} binder. - * - * @author Ignasi Barrera - */ -@Test(groups = "unit", testName = "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 = 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); - - } -} 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 deleted file mode 100644 index dd907b043a..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/binders/cloud/BindIpRefsToPayloadTest.java +++ /dev/null @@ -1,83 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.binders.cloud; - -import static org.jclouds.abiquo.domain.DomainUtils.withHeader; -import static org.jclouds.abiquo.util.Assert.assertPayloadEquals; - -import java.io.IOException; -import java.net.URI; - -import org.jclouds.abiquo.domain.NetworkResources; -import org.jclouds.http.HttpRequest; -import org.jclouds.xml.internal.JAXBParser; -import org.testng.annotations.Test; - -import com.abiquo.model.transport.LinksDto; -import com.abiquo.server.core.infrastructure.network.AbstractIpDto; -import com.abiquo.server.core.infrastructure.network.PrivateIpDto; - -/** - * Unit tests for the {@link BindIpRefsToPayload} binder. - * - * @author Ignasi Barrera - */ -@Test(groups = "unit", testName = "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 = 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 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); - } -} 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 deleted file mode 100644 index 16f65b02d5..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/binders/cloud/BindMoveVolumeToPathTest.java +++ /dev/null @@ -1,71 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.binders.cloud; -import static org.jclouds.reflect.Reflection2.method; -import static org.testng.Assert.assertEquals; - -import java.net.URI; - -import javax.ws.rs.HttpMethod; - -import org.jclouds.abiquo.domain.CloudResources; -import org.jclouds.abiquo.features.CloudAsyncApi; -import org.jclouds.reflect.Invocation; -import org.jclouds.rest.internal.GeneratedHttpRequest; -import org.testng.annotations.Test; - -import com.abiquo.server.core.cloud.VirtualDatacenterDto; -import com.abiquo.server.core.infrastructure.storage.VolumeManagementDto; -import com.google.common.collect.ImmutableList; -import com.google.common.reflect.Invokable; - -/** - * Unit tests for the {@link BindMoveVolumeToPath} binder. - * - * @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); - } - - @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"); - } - - private static GeneratedHttpRequest generatedHttpRequest() throws SecurityException, NoSuchMethodException { - Invokable withEndpointLink = method(CloudAsyncApi.class, "moveVolume", VolumeManagementDto.class, - VirtualDatacenterDto.class); - return GeneratedHttpRequest.builder() - .invocation(Invocation.create(withEndpointLink, 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 deleted file mode 100644 index 8842a01bd4..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/binders/cloud/BindNetworkConfigurationRefToPayloadTest.java +++ /dev/null @@ -1,140 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.binders.cloud; - -import static org.jclouds.abiquo.domain.DomainUtils.withHeader; -import static org.jclouds.abiquo.util.Assert.assertPayloadEquals; -import static org.jclouds.reflect.Reflection2.method; - -import java.io.IOException; -import java.net.URI; -import java.util.NoSuchElementException; - -import javax.ws.rs.GET; -import javax.ws.rs.HttpMethod; - -import org.jclouds.abiquo.domain.CloudResources; -import org.jclouds.abiquo.domain.NetworkResources; -import org.jclouds.http.HttpRequest; -import org.jclouds.reflect.Invocation; -import org.jclouds.rest.internal.GeneratedHttpRequest; -import org.jclouds.xml.internal.JAXBParser; -import org.testng.annotations.Test; - -import com.abiquo.model.transport.LinksDto; -import com.abiquo.server.core.cloud.VirtualMachineDto; -import com.abiquo.server.core.infrastructure.network.VLANNetworkDto; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.Lists; -import com.google.common.reflect.Invokable; -/** - * Unit tests for the {@link BindNetworkConfigurationRefToPayload} binder. - * - * @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()); - } - - @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()); - } - - @Test(expectedExceptions = NullPointerException.class) - public void testInvalidNullInput() throws SecurityException, NoSuchMethodException { - VirtualMachineDto vm = CloudResources.virtualMachinePut(); - - Invokable method = method(TestNetworkConfig.class, "withAll", VirtualMachineDto.class, - VLANNetworkDto.class); - GeneratedHttpRequest request = GeneratedHttpRequest.builder() - .invocation(Invocation.create(method, Lists. newArrayList(vm, null))) - .method(HttpMethod.GET) - .endpoint(URI.create("http://localhost")).build(); - - 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(); - - Invokable method = method(TestNetworkConfig.class, "withAll", VirtualMachineDto.class, - VLANNetworkDto.class); - GeneratedHttpRequest request = GeneratedHttpRequest.builder() - .invocation(Invocation.create(method, ImmutableList. of(vm, network))) - .method(HttpMethod.GET) - .endpoint(URI.create("http://localhost")).build(); - - 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(); - - Invokable method = method(TestNetworkConfig.class, "withoutVirtualMachine", - VLANNetworkDto.class); - GeneratedHttpRequest request = GeneratedHttpRequest.builder() - .invocation(Invocation.create(method, ImmutableList. of(network))) - .method(HttpMethod.GET) - .endpoint(URI.create("http://localhost")).build(); - - 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(); - - Invokable method = method(TestNetworkConfig.class, "withAll", VirtualMachineDto.class, - VLANNetworkDto.class); - GeneratedHttpRequest request = GeneratedHttpRequest.builder() - .invocation(Invocation.create(method, ImmutableList. of(vm, network))) - .method(HttpMethod.GET) - .endpoint(URI.create("http://localhost")).build(); - - BindNetworkConfigurationRefToPayload binder = new BindNetworkConfigurationRefToPayload(new JAXBParser("false")); - - 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); - - @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 deleted file mode 100644 index 94af9f24ca..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/binders/cloud/BindNetworkRefToPayloadTest.java +++ /dev/null @@ -1,66 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.binders.cloud; - -import static org.jclouds.abiquo.domain.DomainUtils.withHeader; -import static org.jclouds.abiquo.util.Assert.assertPayloadEquals; - -import java.io.IOException; -import java.net.URI; - -import org.jclouds.abiquo.domain.NetworkResources; -import org.jclouds.http.HttpRequest; -import org.jclouds.xml.internal.JAXBParser; -import org.testng.annotations.Test; - -import com.abiquo.model.transport.LinksDto; -import com.abiquo.server.core.infrastructure.network.VLANNetworkDto; - -/** - * Unit tests for the {@link BindNetworkRefToPayload} binder. - * - * @author Ignasi Barrera - */ -@Test(groups = "unit", testName = "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 = 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); - } -} 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 deleted file mode 100644 index f29a5d4a83..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/binders/cloud/BindUnmanagedIpRefToPayloadTest.java +++ /dev/null @@ -1,68 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.binders.cloud; - -import static org.jclouds.abiquo.domain.DomainUtils.withHeader; -import static org.jclouds.abiquo.util.Assert.assertPayloadEquals; - -import java.io.IOException; -import java.net.URI; - -import org.jclouds.abiquo.domain.NetworkResources; -import org.jclouds.http.HttpRequest; -import org.jclouds.xml.internal.JAXBParser; -import org.testng.annotations.Test; - -import com.abiquo.model.rest.RESTLink; -import com.abiquo.model.transport.LinksDto; -import com.abiquo.server.core.infrastructure.network.VLANNetworkDto; - -/** - * Unit tests for the {@link BindUnmanagedIpRefToPayload} binder. - * - * @author Ignasi Barrera - */ -@Test(groups = "unit", testName = "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 = 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); - } -} 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 deleted file mode 100644 index ff66ae3e42..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/binders/cloud/BindVirtualDatacenterRefToPayloadTest.java +++ /dev/null @@ -1,66 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.binders.cloud; - -import static org.jclouds.abiquo.domain.DomainUtils.withHeader; -import static org.jclouds.abiquo.util.Assert.assertPayloadEquals; - -import java.io.IOException; -import java.net.URI; - -import org.jclouds.abiquo.domain.CloudResources; -import org.jclouds.http.HttpRequest; -import org.jclouds.xml.internal.JAXBParser; -import org.testng.annotations.Test; - -import com.abiquo.model.transport.LinksDto; -import com.abiquo.server.core.cloud.VirtualDatacenterDto; - -/** - * Unit tests for the {@link BindVirtualDatacenterRefToPayload} binder. - * - * @author Ignasi Barrera - */ -@Test(groups = "unit", testName = "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 = 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); - } -} 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 deleted file mode 100644 index 67dfc0e5cf..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/binders/cloud/BindVolumeRefsToPayloadTest.java +++ /dev/null @@ -1,82 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.binders.cloud; - -import static org.jclouds.abiquo.domain.DomainUtils.withHeader; -import static org.jclouds.abiquo.util.Assert.assertPayloadEquals; - -import java.io.IOException; -import java.net.URI; - -import org.jclouds.abiquo.domain.CloudResources; -import org.jclouds.http.HttpRequest; -import org.jclouds.xml.internal.JAXBParser; -import org.testng.annotations.Test; - -import com.abiquo.model.transport.LinksDto; -import com.abiquo.server.core.infrastructure.storage.VolumeManagementDto; - -/** - * Unit tests for the {@link BindVolumeRefsToPayload} binder. - * - * @author Ignasi Barrera - */ -@Test(groups = "unit", testName = "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 = 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 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); - } -} 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 deleted file mode 100644 index 8a85c3c032..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/binders/infrastructure/AppendMachineIdToPathTest.java +++ /dev/null @@ -1,61 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.binders.infrastructure; - -import static org.testng.Assert.assertEquals; - -import java.net.URI; - -import org.jclouds.abiquo.functions.infrastructure.ParseMachineId; -import org.jclouds.http.HttpRequest; -import org.testng.annotations.Test; - -import com.abiquo.server.core.infrastructure.MachineDto; - -/** - * Unit tests for the {@link AppendMachineIdToPath} binder. - * - * @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); - } - - @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(); - - 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 deleted file mode 100644 index a0b1f52d65..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/binders/infrastructure/AppendRemoteServiceTypeToPathTest.java +++ /dev/null @@ -1,59 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.binders.infrastructure; - -import static org.testng.Assert.assertEquals; - -import java.net.URI; - -import org.jclouds.abiquo.functions.infrastructure.ParseRemoteServiceType; -import org.jclouds.http.HttpRequest; -import org.testng.annotations.Test; - -import com.abiquo.model.enumerator.RemoteServiceType; - -/** - * Unit tests for the {@link AppendRemoteServiceTypeToPath} binder. - * - * @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); - } - - @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(); - - 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 deleted file mode 100644 index d0247f0f9a..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/binders/infrastructure/BindSupportedDevicesLinkToPathTest.java +++ /dev/null @@ -1,90 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.binders.infrastructure; -import static org.jclouds.reflect.Reflection2.method; -import static org.testng.Assert.assertEquals; - -import java.net.URI; - -import javax.ws.rs.HttpMethod; - -import org.jclouds.abiquo.features.InfrastructureAsyncApi; -import org.jclouds.reflect.Invocation; -import org.jclouds.rest.internal.GeneratedHttpRequest; -import org.testng.annotations.Test; - -import com.abiquo.model.rest.RESTLink; -import com.abiquo.server.core.infrastructure.DatacenterDto; -import com.google.common.collect.ImmutableList; -import com.google.common.reflect.Invokable; - -/** - * Unit tests for the {@link BindSupportedDevicesLinkToPath} class. - * - * @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); - } - - @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")); - - BindSupportedDevicesLinkToPath binder = new BindSupportedDevicesLinkToPath(); - - Invokable withEndpointLink = method(InfrastructureAsyncApi.class, "listSupportedStorageDevices", - DatacenterDto.class); - - GeneratedHttpRequest request = GeneratedHttpRequest.builder() - .invocation(Invocation.create(withEndpointLink, ImmutableList. of(datacenter))) - .method(HttpMethod.GET) - .endpoint(URI.create("http://foo/bar")).build(); - - assertEquals(binder.getNewEndpoint(request, datacenter), "http://foo/bar/action/supported"); - } - - @Test(expectedExceptions = NullPointerException.class) - public void testGetNewEnpointWithoutLink() throws Exception { - DatacenterDto datacenter = new DatacenterDto(); - - BindSupportedDevicesLinkToPath binder = new BindSupportedDevicesLinkToPath(); - - Invokable withEndpointLink = method(InfrastructureAsyncApi.class, "listSupportedStorageDevices", - DatacenterDto.class); - - GeneratedHttpRequest request = GeneratedHttpRequest.builder() - .invocation(Invocation.create(withEndpointLink, ImmutableList. of(datacenter))) - .method(HttpMethod.GET) - .endpoint(URI.create("http://foo/bar")).build(); - - 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 deleted file mode 100644 index 0ef5089bbc..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/binders/infrastructure/ucs/BindLogicServerParametersTest.java +++ /dev/null @@ -1,68 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.binders.infrastructure.ucs; - -import static org.testng.Assert.assertEquals; - -import java.net.URI; - -import org.jclouds.http.HttpRequest; -import org.testng.annotations.Test; - -import com.abiquo.server.core.infrastructure.LogicServerDto; - -/** - * Unit tests for the {@link BindLogicServerParameters} binder. - * - * @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); - } - - @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); - } - - 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 deleted file mode 100644 index 753d7e4f9b..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/binders/infrastructure/ucs/BindOrganizationParametersTest.java +++ /dev/null @@ -1,68 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.binders.infrastructure.ucs; - -import static org.testng.Assert.assertEquals; - -import java.net.URI; - -import org.jclouds.http.HttpRequest; -import org.testng.annotations.Test; - -import com.abiquo.server.core.infrastructure.OrganizationDto; - -/** - * Unit tests for the {@link BindOrganizationParameters} binder. - * - * @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); - } - - @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); - } - - 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 deleted file mode 100644 index 1c14de89be..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/compute/AbiquoComputeServiceLiveTest.java +++ /dev/null @@ -1,127 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.compute; - -import static org.jclouds.compute.util.ComputeServiceUtils.getCores; -import static org.testng.Assert.assertEquals; - -import java.util.Properties; - -import org.jclouds.Constants; -import org.jclouds.compute.domain.ComputeType; -import org.jclouds.compute.domain.ExecResponse; -import org.jclouds.compute.domain.Hardware; -import org.jclouds.compute.domain.NodeMetadata; -import org.jclouds.compute.internal.BaseComputeServiceLiveTest; -import org.jclouds.logging.config.LoggingModule; -import org.jclouds.logging.slf4j.config.SLF4JLoggingModule; -import org.jclouds.sshj.config.SshjSshClientModule; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; -import com.google.inject.Module; - -/** - * Live tests for the Abiquo ComputeService. - * - * @author Ignasi Barrera - */ -@Test(groups = "live", testName = "AbiquoComputeServiceLiveTest", singleThreaded = true) -// 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. -// This class is still a work in progress and will fail until the race condition -// (when creating the virtual appliance) in the AbiquoComputeServiceAdapter is -// fixed and a proper test environment is configured. -public abstract 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 - 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 LoggingModule getLoggingModule() { - return new SLF4JLoggingModule(); - } - - @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 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 support metadata - @Override - protected void checkUserMetadataContains(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); - } - -} 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 deleted file mode 100644 index 715af5cdb5..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/compute/functions/DatacenterToLocationTest.java +++ /dev/null @@ -1,52 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.compute.functions; - -import static org.testng.Assert.assertEquals; - -import org.easymock.EasyMock; -import org.jclouds.abiquo.AbiquoApi; -import org.jclouds.abiquo.AbiquoAsyncApi; -import org.jclouds.abiquo.domain.infrastructure.Datacenter; -import org.jclouds.domain.Location; -import org.jclouds.domain.LocationScope; -import org.jclouds.rest.RestContext; -import org.testng.annotations.Test; - -/** - * Unit tests for the {@link DatacenterToLocation} function. - * - * @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(); - - 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); - } -} 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 deleted file mode 100644 index 644eb11eda..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/compute/functions/VirtualDatacenterToLocationTest.java +++ /dev/null @@ -1,99 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.compute.functions; - -import static org.easymock.EasyMock.anyObject; -import static org.easymock.EasyMock.expect; -import static org.easymock.EasyMock.replay; -import static org.easymock.EasyMock.verify; -import static org.testng.Assert.assertEquals; - -import java.util.Collections; -import java.util.Map; - -import org.easymock.EasyMock; -import org.jclouds.abiquo.AbiquoApi; -import org.jclouds.abiquo.AbiquoAsyncApi; -import org.jclouds.abiquo.domain.cloud.VirtualDatacenter; -import org.jclouds.abiquo.domain.enterprise.Enterprise; -import org.jclouds.abiquo.domain.infrastructure.Datacenter; -import org.jclouds.abiquo.domain.network.PrivateNetwork; -import org.jclouds.domain.Location; -import org.jclouds.domain.LocationScope; -import org.jclouds.rest.RestContext; -import org.testng.annotations.Test; - -import com.google.common.base.Function; -import com.google.common.base.Supplier; - -/** - * Unit tests for the {@link VirtualDatacenterToLocation} function. - * - * @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); - - VirtualDatacenter vdc = mockVirtualDatacenter(); - - Location location = function.apply(vdc); - - verify(regionMap); - verify(dcToLocation); - - 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); - - VirtualDatacenter vdc = VirtualDatacenter.builder(context, datacenter, enterprise) // - .network(network) // - .name("mock").build(); - vdc.unwrap().setId(5); - - 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 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 deleted file mode 100644 index c5c210677d..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/compute/functions/VirtualMachineStateToNodeStateTest.java +++ /dev/null @@ -1,48 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.compute.functions; - -import static org.testng.Assert.assertEquals; - -import org.jclouds.compute.domain.NodeMetadata.Status; -import org.testng.annotations.Test; - -import com.abiquo.server.core.cloud.VirtualMachineState; - -/** - * Unit tests for the {@link VirtualMachineStateToNodeState} function. - * - * @author Ignasi Barrera - */ -@Test(groups = "unit", testName = "VirtualMachineStateToNodeStateTest") -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); - } -} 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 deleted file mode 100644 index 6ede999c5c..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/compute/functions/VirtualMachineTemplateInVirtualDatacenterToHardwareTest.java +++ /dev/null @@ -1,236 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.compute.functions; - -import static org.easymock.EasyMock.anyObject; -import static org.easymock.EasyMock.expect; -import static org.easymock.EasyMock.replay; -import static org.easymock.EasyMock.verify; -import static org.jclouds.abiquo.domain.DomainWrapper.wrap; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNull; - -import java.net.URI; - -import org.easymock.EasyMock; -import org.jclouds.abiquo.AbiquoApi; -import org.jclouds.abiquo.AbiquoAsyncApi; -import org.jclouds.abiquo.domain.cloud.VirtualDatacenter; -import org.jclouds.abiquo.domain.cloud.VirtualMachineTemplate; -import org.jclouds.abiquo.domain.cloud.VirtualMachineTemplateInVirtualDatacenter; -import org.jclouds.compute.domain.Hardware; -import org.jclouds.compute.domain.Volume; -import org.jclouds.domain.Location; -import org.jclouds.rest.RestContext; -import org.testng.annotations.Test; - -import com.abiquo.model.enumerator.HypervisorType; -import com.abiquo.model.rest.RESTLink; -import com.abiquo.server.core.appslibrary.VirtualMachineTemplateDto; -import com.abiquo.server.core.cloud.VirtualDatacenterDto; -import com.google.common.base.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); - - 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); - - Hardware hardware = function.apply(new VirtualMachineTemplateInVirtualDatacenter(template, vdc)); - - 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.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); - } - - @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); - - 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)); - - verify(vdcToLocation); - - 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); - - VirtualMachineTemplate template = wrap(context, VirtualMachineTemplate.class, new VirtualMachineTemplateDto()); - VirtualDatacenter vdc = wrap(context, VirtualDatacenter.class, new VirtualDatacenterDto()); - - 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); - - 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); - - Hardware hardware = function.apply(new VirtualMachineTemplateInVirtualDatacenter(template, vdc)); - - verify(vdcToLocation); - - 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); - - 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); - - Hardware hardware = function.apply(new VirtualMachineTemplateInVirtualDatacenter(template, vdc)); - - verify(vdcToLocation); - - assertEquals(hardware.getRam(), 0); - } - - @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); - - 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)); - - verify(vdcToLocation); - - 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; - } -} 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 deleted file mode 100644 index 8ca7319609..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/compute/functions/VirtualMachineTemplateToImageTest.java +++ /dev/null @@ -1,131 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.compute.functions; - -import static org.easymock.EasyMock.anyObject; -import static org.easymock.EasyMock.expect; -import static org.easymock.EasyMock.replay; -import static org.easymock.EasyMock.verify; -import static org.jclouds.abiquo.domain.DomainWrapper.wrap; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNull; - -import java.net.URI; -import java.util.Collections; -import java.util.Map; - -import org.easymock.EasyMock; -import org.jclouds.abiquo.AbiquoApi; -import org.jclouds.abiquo.AbiquoAsyncApi; -import org.jclouds.abiquo.domain.cloud.VirtualMachineTemplate; -import org.jclouds.abiquo.domain.infrastructure.Datacenter; -import org.jclouds.compute.domain.Image; -import org.jclouds.compute.domain.OperatingSystem; -import org.jclouds.domain.Location; -import org.jclouds.rest.RestContext; -import org.testng.annotations.Test; - -import com.abiquo.model.rest.RESTLink; -import com.abiquo.server.core.appslibrary.VirtualMachineTemplateDto; -import com.google.common.base.Function; -import com.google.common.base.Supplier; - -/** - * Unit tests for the {@link VirtualMachineTemplateToImage} class. - * - * @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); - - 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)); - - 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()); - } - - @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")); - - Image image = function.apply(wrap(context, VirtualMachineTemplate.class, dto)); - - verify(regionMap); - verify(dcToLocation); - - 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); - - 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 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 deleted file mode 100644 index 0a24831924..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/compute/functions/VirtualMachineToNodeMetadataTest.java +++ /dev/null @@ -1,223 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.compute.functions; - -import static org.easymock.EasyMock.anyObject; -import static org.easymock.EasyMock.expect; -import static org.easymock.EasyMock.replay; -import static org.easymock.EasyMock.verify; -import static org.jclouds.abiquo.domain.DomainWrapper.wrap; -import static org.testng.Assert.assertEquals; - -import java.net.URI; - -import org.easymock.EasyMock; -import org.jclouds.abiquo.domain.cloud.VirtualAppliance; -import org.jclouds.abiquo.domain.cloud.VirtualDatacenter; -import org.jclouds.abiquo.domain.cloud.VirtualMachine; -import org.jclouds.abiquo.domain.cloud.VirtualMachineTemplate; -import org.jclouds.abiquo.domain.cloud.VirtualMachineTemplateInVirtualDatacenter; -import org.jclouds.abiquo.domain.network.ExternalIp; -import org.jclouds.abiquo.domain.network.Ip; -import org.jclouds.abiquo.domain.network.PrivateIp; -import org.jclouds.abiquo.domain.network.PublicIp; -import org.jclouds.compute.domain.Hardware; -import org.jclouds.compute.domain.HardwareBuilder; -import org.jclouds.compute.domain.Image; -import org.jclouds.compute.domain.NodeMetadata; -import org.jclouds.compute.domain.NodeMetadata.Status; -import org.jclouds.domain.Location; -import org.jclouds.rest.RestContext; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -import com.abiquo.model.enumerator.HypervisorType; -import com.abiquo.model.rest.RESTLink; -import com.abiquo.server.core.cloud.VirtualMachineState; -import com.abiquo.server.core.cloud.VirtualMachineWithNodeExtendedDto; -import com.abiquo.server.core.infrastructure.network.ExternalIpDto; -import com.abiquo.server.core.infrastructure.network.PrivateIpDto; -import com.abiquo.server.core.infrastructure.network.PublicIpDto; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.Iterables; - -/** - * Unit tests for the {@link VirtualMachineToNodeMetadata} class. - * - * @author Ignasi Barrera - */ -@Test(groups = "unit", testName = "VirtualMachineToNodeMetadataTest") -public class VirtualMachineToNodeMetadataTest { - private VirtualMachineToNodeMetadata function; - - private VirtualMachineWithNodeExtendedDto vm; - - private PrivateIpDto privNic; - - private PublicIpDto pubNic; - - private ExternalIpDto extNic; - - 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")); - - 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"); - - extNic = new ExternalIpDto(); - extNic.setIp("10.10.10.10"); - extNic.setMac("2a:6e:40:69:84:e2"); - - hardware = new HardwareBuilder() // - .ids("1") // - .build(); - - function = new VirtualMachineToNodeMetadata(templateToImage(), templateToHardware(), stateToNodeState(), - virtualDatacenterToLocation()); - } - - public void testVirtualMachineToNodeMetadata() { - VirtualAppliance vapp = EasyMock.createMock(VirtualAppliance.class); - VirtualMachine mockVm = mockVirtualMachine(vapp); - - NodeMetadata node = function.apply(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()); - } - - 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); - - replay(image); - replay(templateToImage); - - return templateToImage; - } - - private VirtualMachineTemplateInVirtualDatacenterToHardware templateToHardware() { - VirtualMachineTemplateInVirtualDatacenterToHardware virtualMachineTemplateToHardware = EasyMock - .createMock(VirtualMachineTemplateInVirtualDatacenterToHardware.class); - - expect(virtualMachineTemplateToHardware.apply(anyObject(VirtualMachineTemplateInVirtualDatacenter.class))) - .andReturn(hardware); - - replay(virtualMachineTemplateToHardware); - - return virtualMachineTemplateToHardware; - } - - 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(datacenterToLocation.apply(anyObject(VirtualDatacenter.class))).andReturn(location); - - replay(location); - replay(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 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); - } - - @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); - - 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); - - 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 deleted file mode 100644 index 13b3064b9c..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/compute/options/AbiquoTemplateOptionsTest.java +++ /dev/null @@ -1,54 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.compute.options; - -import static org.testng.Assert.assertEquals; - -import org.jclouds.compute.options.TemplateOptions; -import org.testng.annotations.Test; - -/** - * Unit tests for the {@link AbiquoTemplateOptions} class. - * - * @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 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 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 deleted file mode 100644 index 1f160b4b25..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/config/SchedulerModuleTest.java +++ /dev/null @@ -1,44 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.config; - -import static org.testng.Assert.assertNotNull; - -import java.util.concurrent.ScheduledExecutorService; - -import org.jclouds.Constants; -import org.jclouds.abiquo.internal.BaseInjectionTest; -import org.testng.annotations.Test; - -import com.google.inject.Key; -import com.google.inject.name.Names; - -/** - * Unit tests for the {@link SchedulerModule} class. - * - * @author Ignasi Barrera - */ -@Test(groups = "unit", testName = "SchedulerModuleTest") -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 deleted file mode 100644 index 1998ab483d..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/AbiquoVersionLiveApiTest.java +++ /dev/null @@ -1,55 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.domain; - -import static org.jclouds.abiquo.util.Assert.assertHasError; -import static org.testng.Assert.fail; - -import java.util.Properties; - -import javax.ws.rs.core.Response.Status; - -import org.jclouds.abiquo.domain.exception.AbiquoException; -import org.jclouds.abiquo.internal.BaseAbiquoLiveApiTest; -import org.testng.annotations.Test; - -/** - * Live integration tests for the Abiquo versioning support. - * - * @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 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 deleted file mode 100644 index bb80ce68df..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/AdminResources.java +++ /dev/null @@ -1,200 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.domain; - -import static org.jclouds.abiquo.domain.DomainUtils.link; - -import com.abiquo.model.rest.RESTLink; -import com.abiquo.server.core.enterprise.DatacenterLimitsDto; -import com.abiquo.server.core.enterprise.EnterpriseDto; -import com.abiquo.server.core.enterprise.RoleDto; -import com.abiquo.server.core.enterprise.UserDto; - -/** - * Enterprise domain utilities. - * - * @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 static RoleDto rolePut() { - RoleDto role = rolePost(); - role.setId(1); - role.addLink(new RESTLink("edit", "http://localhost/api/admin/roles/1")); - - return role; - } - - public static String rolePostPayload() { - StringBuilder buffer = new StringBuilder(); - 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() { - StringBuilder buffer = new StringBuilder(); - 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 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() { - StringBuilder buffer = new StringBuilder(); - 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) { - StringBuilder buffer = new StringBuilder(); - 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() { - StringBuilder buffer = new StringBuilder(); - 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 String userPutPayload() { - StringBuilder buffer = new StringBuilder(); - 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", - "http://localhost/api/admin/enterprises/1/users/1/action/virtualmachines")); - 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 deleted file mode 100644 index bf975609e7..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/CloudResources.java +++ /dev/null @@ -1,455 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.domain; - -import static org.jclouds.abiquo.domain.DomainUtils.link; - -import com.abiquo.model.enumerator.DiskFormatType; -import com.abiquo.model.enumerator.HypervisorType; -import com.abiquo.model.enumerator.VolumeState; -import com.abiquo.model.rest.RESTLink; -import com.abiquo.server.core.appslibrary.VirtualMachineTemplateDto; -import com.abiquo.server.core.cloud.VirtualApplianceDto; -import com.abiquo.server.core.cloud.VirtualDatacenterDto; -import com.abiquo.server.core.cloud.VirtualMachineDto; -import com.abiquo.server.core.cloud.VirtualMachineState; -import com.abiquo.server.core.cloud.VirtualMachineStateDto; -import com.abiquo.server.core.cloud.VirtualMachineTaskDto; -import com.abiquo.server.core.infrastructure.storage.DiskManagementDto; -import com.abiquo.server.core.infrastructure.storage.TierDto; -import com.abiquo.server.core.infrastructure.storage.VolumeManagementDto; - -/** - * Cloud domain utilities. - * - * @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 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 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", - "http://localhost/api/cloud/virtualdatacenters/1/privatenetworks")); - virtualDatacenter.addLink(new RESTLink("defaultnetwork", - "http://localhost/api/cloud/virtualdatacenters/1/privatenetworks/1")); - virtualDatacenter.addLink(new RESTLink("defaultvlan", - "http://localhost/api/cloud/virtualdatacenters/1/action/defaultvlan")); - virtualDatacenter.addLink(new RESTLink("topurchase", - "http://localhost/api/cloud/virtualdatacenters/1/publicips/topurchase")); - virtualDatacenter.addLink(new RESTLink("purchased", - "http://localhost/api/cloud/virtualdatacenters/1/publicips/purchased")); - virtualDatacenter.addLink(new RESTLink("templates", - "http://localhost/api/cloud/virtualdatacenters/1/action/templates")); - 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", - "http://localhost/api/cloud/virtualdatacenters/1/virtualappliances/1/action/deploy")); - virtualAppliance.addLink(new RESTLink("edit", - "http://localhost/api/cloud/virtualdatacenters/1/virtualappliances/1")); - virtualAppliance.addLink(new RESTLink("state", - "http://localhost/api/cloud/virtualdatacenters/1/virtualappliances/1/state")); - virtualAppliance.addLink(new RESTLink("undeploy", - "http://localhost/api/cloud/virtualdatacenters/1/virtualappliances/1/action/undeploy")); - virtualAppliance.addLink(new RESTLink("virtualmachines", - "http://localhost/api/cloud/virtualdatacenters/1/virtualappliances/1/virtualmachines")); - virtualAppliance.addLink(new RESTLink("price", - "http://localhost/api/cloud/virtualdatacenters/1/virtualappliances/1/action/price")); - 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", - "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 - .addLink(new RESTLink("configurations", - "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 String virtualMachineStatePayload() { - StringBuilder buffer = new StringBuilder(); - 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 volumePut() { - VolumeManagementDto volume = volumePost(); - volume.setId(1); - volume.setState(VolumeState.DETACHED.name()); - - 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; - } - - 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; - - } - - 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 undeployOptions() { - VirtualMachineTaskDto deploy = new VirtualMachineTaskDto(); - deploy.setForceUndeploy(true); - return deploy; - } - - public static String virtualDatacenterPostPayload() { - StringBuilder buffer = new StringBuilder(); - 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() { - StringBuilder buffer = new StringBuilder(); - buffer.append(""); - buffer.append("0"); - buffer.append("0"); - buffer.append("VA"); - buffer.append("0"); - buffer.append(""); - return buffer.toString(); - } - - public static String virtualMachinePostPayload() { - StringBuilder buffer = new StringBuilder(); - 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() { - StringBuilder buffer = new StringBuilder(); - 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() { - StringBuilder buffer = new StringBuilder(); - buffer.append(""); - buffer.append(link("/cloud/virtualdatacenters/1", "virtualdatacenter")); - buffer.append(""); - return buffer.toString(); - } - - public static String virtualAppliancePutPayload() { - StringBuilder buffer = new StringBuilder(); - 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() { - StringBuilder buffer = new StringBuilder(); - 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", - "persistent")); - 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("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() { - StringBuilder buffer = new StringBuilder(); - 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() { - StringBuilder buffer = new StringBuilder(); - 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() { - StringBuilder buffer = new StringBuilder(); - 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() { - StringBuilder buffer = new StringBuilder(); - buffer.append(""); - buffer.append("false"); - buffer.append(""); - return buffer.toString(); - } - - public static String undeployPayload() { - StringBuilder buffer = new StringBuilder(); - 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 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() { - StringBuilder buffer = new StringBuilder(); - buffer.append(""); - buffer.append("1024"); - buffer.append(""); - return buffer.toString(); - } - - public static String hardDiskPutPayload() { - StringBuilder buffer = new StringBuilder(); - 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 deleted file mode 100644 index 02a724ef69..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/ConfigResources.java +++ /dev/null @@ -1,164 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.domain; - -import static org.jclouds.abiquo.domain.DomainUtils.link; - -import java.io.IOException; -import java.net.URL; -import java.nio.charset.Charset; - -import com.abiquo.model.rest.RESTLink; -import com.abiquo.server.core.appslibrary.CategoryDto; -import com.abiquo.server.core.config.LicenseDto; -import com.abiquo.server.core.config.SystemPropertyDto; -import com.google.common.io.Resources; - -/** - * Enterprise domain utilities. - * - * @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 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 LicenseDto licensePut() { - LicenseDto license = licensePost(); - license.setId(1); - license.addLink(new RESTLink("edit", "http://localhost/api/config/licenses/1")); - - 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")); - - return property; - } - - public static String licensePutPayload() { - StringBuilder buffer = new StringBuilder(); - 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() { - StringBuilder buffer = new StringBuilder(); - buffer.append(""); - buffer.append("3bca6d1d-5fe2-42c5-82ea-a5276ea8c71c"); - buffer.append("" + readLicense("license/expired") + ""); - buffer.append(""); - return buffer.toString(); - } - - public static String categoryPostPayload() { - StringBuilder buffer = new StringBuilder(); - buffer.append(""); - buffer.append("false"); - buffer.append("false"); - buffer.append("category"); - buffer.append(""); - return buffer.toString(); - } - - public static String categoryPutPayload() { - StringBuilder buffer = new StringBuilder(); - 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() { - StringBuilder buffer = new StringBuilder(); - 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() { - StringBuilder buffer = new StringBuilder(); - buffer.append(""); - buffer.append("icon"); - buffer.append("http://www.pixeljoint.com/files/icons/mipreview1.gif"); - buffer.append(""); - return buffer.toString(); - } - - public static String propertyPutPayload() { - StringBuilder buffer = new StringBuilder(); - 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); - } - } -} 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 deleted file mode 100644 index 23557553ff..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/DomainUtils.java +++ /dev/null @@ -1,60 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.domain; - -import org.jclouds.xml.XMLParser; - -import com.abiquo.model.rest.RESTLink; - -/** - * Utility class to build domain objects used in tests. - * - * @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; - } - - /** - * 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 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 deleted file mode 100644 index dad64026e1..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/EnterpriseResources.java +++ /dev/null @@ -1,322 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.domain; - -import static org.jclouds.abiquo.domain.DomainUtils.link; - -import java.util.Map; - -import com.abiquo.model.rest.RESTLink; -import com.abiquo.server.core.appslibrary.TemplateDefinitionListDto; -import com.abiquo.server.core.enterprise.DatacenterLimitsDto; -import com.abiquo.server.core.enterprise.EnterpriseDto; -import com.abiquo.server.core.enterprise.EnterprisePropertiesDto; -import com.abiquo.server.core.enterprise.UserDto; -import com.google.common.collect.Maps; - -/** - * Enterprise domain utilities. - * - * @author Ignasi Barrera - * @author Francesc Montserrat - */ -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", - "http://localhost/api/admin/enterprises/1/datacenterrepositories")); - enterprise.addLink(new RESTLink("externalnetworks", - "http://localhost/api/admin/enterprises/1/action/externalnetworks")); - enterprise.addLink(new RESTLink("virtualmachines", - "http://localhost/api/admin/enterprises/1/action/virtualmachines")); - enterprise.addLink(new RESTLink("cloud/virtualdatacenters", - "http://localhost/api/admin/enterprises/1/action/virtualdatacenters")); - enterprise.addLink(new RESTLink("virtualappliances", - "http://localhost/api/admin/enterprises/1/action/virtualappliances")); - enterprise.addLink(new RESTLink("appslib/templateDefinitionLists", - "http://localhost/api/admin/enterprises/1/appslib/templateDefinitionLists")); - - return enterprise; - } - - public static EnterprisePropertiesDto enterprisePropertiesPut() { - EnterprisePropertiesDto enterpriseProp = new EnterprisePropertiesDto(); - enterpriseProp.setId(1); - Map props = Maps.newHashMap(); - 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; - } - - public static String enterprisePostPayload() { - StringBuilder buffer = new StringBuilder(); - 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() { - StringBuilder buffer = new StringBuilder(); - 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() { - StringBuilder buffer = new StringBuilder(); - 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 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 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; - } - - public static String datacenterLimitsPostPayload() { - StringBuilder buffer = new StringBuilder(); - 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() { - StringBuilder buffer = new StringBuilder(); - buffer.append(""); - buffer.append("myList"); - buffer.append("http://virtualapp-repository.com/vapp1.ovf"); - buffer.append(""); - return buffer.toString(); - } - - public static String templateListPutPayload() { - StringBuilder buffer = new StringBuilder(); - 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(); - } - - public static String datacenterLimitsPutPayload(final EnterpriseDto enterprise) { - StringBuilder buffer = new StringBuilder(); - 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() { - StringBuilder buffer = new StringBuilder(); - 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 String userPutPayload() { - StringBuilder buffer = new StringBuilder(); - 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", - "http://localhost/api/admin/enterprises/1/users/1/action/virtualmachines")); - 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 deleted file mode 100644 index bdfe6a7383..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/InfrastructureResources.java +++ /dev/null @@ -1,490 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.domain; - -import static org.jclouds.abiquo.domain.DomainUtils.link; - -import com.abiquo.model.enumerator.RemoteServiceType; -import com.abiquo.model.rest.RESTLink; -import com.abiquo.server.core.infrastructure.DatacenterDto; -import com.abiquo.server.core.infrastructure.LogicServerDto; -import com.abiquo.server.core.infrastructure.MachineDto; -import com.abiquo.server.core.infrastructure.OrganizationDto; -import com.abiquo.server.core.infrastructure.RackDto; -import com.abiquo.server.core.infrastructure.RemoteServiceDto; -import com.abiquo.server.core.infrastructure.UcsRackDto; -import com.abiquo.server.core.infrastructure.storage.StorageDeviceDto; -import com.abiquo.server.core.infrastructure.storage.StoragePoolDto; -import com.abiquo.server.core.infrastructure.storage.TierDto; - -/** - * Infrastructure domain utilities. - * - * @author Ignasi Barrera - */ -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 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); - 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 StorageDeviceDto storageDevicePost() { - StorageDeviceDto storage = new StorageDeviceDto(); - storage.setName("Aloha aloha"); - storage.setIscsiIp("10.10.10.10"); - storage.setIscsiPort(99); - storage.setManagementPort(90); - - return storage; - } - - 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", - "http://localhost/api/admin/datacenters/1/action/checkmachinestate")); - datacenter.addLink(new RESTLink("checkmachineipmistate", - "http://localhost/api/admin/datacenters/1/action/checkmachineipmistate")); - 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", - "http://localhost/api/admin/datacenters/1/action/discovermultiple")); - 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; - } - - 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", - "http://localhost/api/admin/datacenters/1/racks/1/logicservers/associate")); - rack.addLink(new RESTLink("ls-associateclone", - "http://localhost/api/admin/datacenters/1/racks/1/logicservers/assocclone")); - 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", - "http://localhost/api/admin/datacenters/1/racks/1/logicservers/dissociate")); - return rack; - } - - public static LogicServerDto logicServerPut() { - LogicServerDto logicServer = new LogicServerDto(); - logicServer.setName("server"); - logicServer.setAssociated("associated"); - logicServer.setType("instance"); - - return logicServer; - } - - public static OrganizationDto organizationPut() { - OrganizationDto org = new OrganizationDto(); - org.setName("org"); - org.setDn("org-root/org-Finance"); - org.setLevel("1"); - - 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")); - - 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")); - - 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", - "http://localhost/api/admin/datacenters/1/storage/devices/1/pools/tururututu")); - - return storagePool; - } - - 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", - "http://localhost/api/admin/datacenters/1/remoteservices/nodecollector")); - 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", - "http://localhost/api/admin/datacenters/1/racks/1/machines/1/action/checkstate")); - 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", - "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", - "http://localhost/api/admin/datacenters/1/racks/1/machines/1/logicserver")); - machine.addLink(new RESTLink("poweroff", - "http://localhost/api/admin/datacenters/1/racks/1/machines/1/action/poweroff")); - machine.addLink(new RESTLink("poweron", - "http://localhost/api/admin/datacenters/1/racks/1/machines/1/action/poweron")); - machine.addLink(new RESTLink("virtualmachines", - "http://localhost/api/admin/datacenters/1/racks/1/machines/1/virtualmachines")); - machine.setVirtualCpuCores(5); - - return machine; - } - - public static String datacenterPostPayload() { - StringBuilder buffer = new StringBuilder(); - buffer.append(""); - buffer.append("Honolulu"); - buffer.append("DC"); - buffer.append(""); - return buffer.toString(); - } - - public static String rackPostPayload() { - StringBuilder buffer = new StringBuilder(); - 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() { - StringBuilder buffer = new StringBuilder(); - 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() { - StringBuilder buffer = new StringBuilder(); - 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() { - StringBuilder buffer = new StringBuilder(); - 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() { - StringBuilder buffer = new StringBuilder(); - 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() { - StringBuilder buffer = new StringBuilder(); - buffer.append(""); - buffer.append("0"); - buffer.append("NODE_COLLECTOR"); - buffer.append("http://localhost:80/nodecollector"); - buffer.append(""); - return buffer.toString(); - } - - public static String datacenterPutPayload() { - StringBuilder buffer = new StringBuilder(); - 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() { - StringBuilder buffer = new StringBuilder(); - 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() { - StringBuilder buffer = new StringBuilder(); - 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() { - StringBuilder buffer = new StringBuilder(); - 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() { - StringBuilder buffer = new StringBuilder(); - 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() { - StringBuilder buffer = new StringBuilder(); - 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() { - StringBuilder buffer = new StringBuilder(); - 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() { - StringBuilder buffer = new StringBuilder(); - 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 deleted file mode 100644 index 8432494252..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/NetworkResources.java +++ /dev/null @@ -1,248 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.domain; - -import static org.jclouds.abiquo.domain.DomainUtils.link; - -import com.abiquo.model.enumerator.NetworkType; -import com.abiquo.model.rest.RESTLink; -import com.abiquo.model.transport.LinksDto; -import com.abiquo.server.core.infrastructure.network.NicDto; -import com.abiquo.server.core.infrastructure.network.PrivateIpDto; -import com.abiquo.server.core.infrastructure.network.PublicIpDto; -import com.abiquo.server.core.infrastructure.network.VLANNetworkDto; - -/** - * Network domain utilities. - * - * @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); - - 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 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 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; - } - - 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; - } - - 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; - } - - 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; - } - - 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; - } - - public static String vlanNetworkPostPayload() { - StringBuilder buffer = new StringBuilder(); - 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() { - StringBuilder buffer = new StringBuilder(); - 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() { - StringBuilder buffer = new StringBuilder(); - 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() { - StringBuilder buffer = new StringBuilder(); - 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() { - StringBuilder buffer = new StringBuilder(); - 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() { - StringBuilder buffer = new StringBuilder(); - 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) { - StringBuilder buffer = new StringBuilder(); - 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 deleted file mode 100644 index f69c6a8fc0..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/PricingResources.java +++ /dev/null @@ -1,276 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.domain; - -import static org.jclouds.abiquo.domain.DomainUtils.link; - -import java.math.BigDecimal; - -import com.abiquo.model.rest.RESTLink; -import com.abiquo.server.core.pricing.CostCodeCurrenciesDto; -import com.abiquo.server.core.pricing.CostCodeCurrencyDto; -import com.abiquo.server.core.pricing.CostCodeDto; -import com.abiquo.server.core.pricing.CurrencyDto; -import com.abiquo.server.core.pricing.PricingCostCodeDto; -import com.abiquo.server.core.pricing.PricingTemplateDto; -import com.abiquo.server.core.pricing.PricingTierDto; - -/** - * Enterprise domain utilities. - * - * @author Ignasi Barrera - * @author Susana Acedo - */ -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 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() { - StringBuilder buffer = new StringBuilder(); - buffer.append(""); - buffer.append("DUMMY"); - buffer.append("3"); - buffer.append("yuan"); - buffer.append(""); - return buffer.toString(); - } - - public static String currencyPutPayload() { - StringBuilder buffer = new StringBuilder(); - 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 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() { - StringBuilder buffer = new StringBuilder(); - buffer.append(""); - buffer.append("cost code"); - buffer.append("description"); - buffer.append(""); - return buffer.toString(); - } - - public static String costcodePutPayload() { - StringBuilder buffer = new StringBuilder(); - 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 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() { - StringBuilder buffer = new StringBuilder(); - 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() { - StringBuilder buffer = new StringBuilder(); - 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 String costcodecurrencyPutPayload() { - StringBuilder buffer = new StringBuilder(); - buffer.append(""); - buffer.append(""); - buffer.append("300"); - buffer.append(""); - buffer.append(""); - buffer.append(""); - - 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 String pricingCostCodePutPayload() { - StringBuilder buffer = new StringBuilder(); - 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 String pricingTierPutPayload() { - StringBuilder buffer = new StringBuilder(); - 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 deleted file mode 100644 index 2e9bdc8d85..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/TemplateResources.java +++ /dev/null @@ -1,155 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.domain; - -import static org.jclouds.abiquo.domain.DomainUtils.link; - -import com.abiquo.model.enumerator.ConversionState; -import com.abiquo.model.enumerator.DiskFormatType; -import com.abiquo.model.rest.RESTLink; -import com.abiquo.server.core.appslibrary.ConversionDto; -import com.abiquo.server.core.appslibrary.DatacenterRepositoryDto; -import com.abiquo.server.core.appslibrary.VirtualMachineTemplateDto; -import com.abiquo.server.core.appslibrary.VirtualMachineTemplatePersistentDto; - -/** - * VM template domain utilities. - * - * @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", - "http://localhost/api/admin/enterprises/1/datacenterrepositories/1/actions/refresh")); - dcRepository.addLink(new RESTLink("virtualmachinetemplates", - "http://localhost/api/admin/enterprises/1/datacenterrepositories/1/virtualmachinetemplates")); - - 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" - + "/datacenterrepositories/1/virtualmachinetemplates/1/conversions")); - template.addLink(new RESTLink("tasks", "http://localhost/api/admin/enterprises/1" - + "/datacenterrepositories/1/virtualmachinetemplates/1/tasks")); - template.setCostCode(0); - return template; - } - - public static String virtualMachineTemplatePutPayload() { - StringBuilder buffer = new StringBuilder(); - 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(); - } - - 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; - } - - public static String persistentPayload() { - StringBuilder buffer = new StringBuilder(); - 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(); - } - - 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 - .addLink(new RESTLink("tasks", - "http://localhost/api/admin/enterprises/1/datacenterrepositories/1/virtualmachinetemplates/1/conversions/RAW/tasks")); - - return conversion; - } - - public static String conversionPutPlayload() { - StringBuilder buffer = new StringBuilder(); - 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(); - } -} 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 deleted file mode 100644 index c29b183ad3..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/admin/RoleLiveApiTest.java +++ /dev/null @@ -1,103 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.domain.admin; - -import static org.jclouds.abiquo.util.Assert.assertHasError; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.fail; - -import java.util.List; - -import javax.ws.rs.core.Response.Status; - -import org.jclouds.abiquo.domain.DomainWrapper; -import org.jclouds.abiquo.domain.config.Privilege; -import org.jclouds.abiquo.domain.enterprise.Role; -import org.jclouds.abiquo.domain.exception.AbiquoException; -import org.jclouds.abiquo.internal.BaseAbiquoApiLiveApiTest; -import org.jclouds.abiquo.predicates.config.PrivilegePredicates; -import org.jclouds.abiquo.predicates.enterprise.RolePredicates; -import org.testng.annotations.Test; - -import com.abiquo.server.core.enterprise.PrivilegeDto; -import com.abiquo.server.core.enterprise.RoleDto; -import com.google.common.collect.Lists; - -/** - * Live integration tests for the {@link Role} domain class. - * - * @author Francesc Montserrat - */ -@Test(groups = "api", testName = "RoleLiveApiTest") -public class RoleLiveApiTest extends BaseAbiquoApiLiveApiTest { - - public void testUpdate() { - Role role = Role.builder(env.context.getApiContext()).name("dummyRoleUpdateRole").blocked(false).build(); - role.save(); - - role.setName("UPDATED_ROLE"); - role.update(); - - // Recover the updated role - RoleDto updated = env.adminApi.getRole(role.getId()); - - assertEquals(updated.getName(), "UPDATED_ROLE"); - - role.delete(); - } - - 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"); - } - } - - 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())); - - assertNotNull(entRole); - } - - public void testAddPrivilege() { - PrivilegeDto dto = env.configApi.getPrivilege(8); - Privilege privilege = DomainWrapper.wrap(env.context.getApiContext(), Privilege.class, dto); - List privileges = Lists.newArrayList(env.role.listPrivileges()); - privileges.add(privilege); - - env.role.setPrivileges(privileges); - - env.role.update(); - - privilege = env.role.findPrivileges(PrivilegePredicates.name(dto.getName())); - - assertNotNull(privilege); - } -} diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/cloud/AccountLiveTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/cloud/AccountLiveTest.java deleted file mode 100644 index ca0ea4d8d6..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/cloud/AccountLiveTest.java +++ /dev/null @@ -1,59 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.domain.cloud; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertTrue; - -import org.jclouds.abiquo.domain.enterprise.Enterprise; -import org.jclouds.abiquo.internal.BaseAbiquoLiveApiTest; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -/** - * Live integration tests - * - * @author Susana Acedo - */ -@Test(groups = "live", testName = "AccountLiveTest") -public class AccountLiveTest extends BaseAbiquoLiveApiTest { - - private Enterprise enterprise; - - @BeforeClass(groups = { "integration", "live" }) - @Override - public void setupContext() { - super.setupContext(); - enterprise = view.getAdministrationService().getCurrentEnterprise(); - } - - public void testGetCurrentUser() { - assertEquals(view.getAdministrationService().getCurrentUser().getNick(), view.getApiContext().getIdentity()); - } - - public void testAllowedDatacenters() { - assertTrue(enterprise.listAllowedDatacenters().size() > 0); - } - - public void testAvailableTemplates() { - assertTrue(enterprise.listTemplates().size() > 0); - } - -} 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 deleted file mode 100644 index 3c745f5372..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/cloud/HardDiskLiveApiTest.java +++ /dev/null @@ -1,70 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.domain.cloud; - -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertNull; - -import org.jclouds.abiquo.internal.BaseAbiquoApiLiveApiTest; -import org.testng.SkipException; -import org.testng.annotations.Test; - -import com.abiquo.model.enumerator.HypervisorType; - -/** - * Live integration tests for the {@link HardDisk} domain class. - * - * @author Ignasi Barrera - */ -@Test(groups = "api", testName = "HardDiskLiveApiTest") -public class HardDiskLiveApiTest extends BaseAbiquoApiLiveApiTest { - private HardDisk hardDisk; - - public void createHardDisk() { - skipIfUnsupported(); - - hardDisk = HardDisk.builder(env.context.getApiContext(), env.virtualDatacenter).sizeInMb(64L).build(); - hardDisk.save(); - - assertNotNull(hardDisk.getId()); - assertNotNull(hardDisk.getSequence()); - - assertNotNull(env.virtualDatacenter.getHardDisk(hardDisk.getId())); - } - - @Test(dependsOnMethods = "createHardDisk") - public void deleteHardDisk() { - skipIfUnsupported(); - - HardDisk hd = env.virtualDatacenter.getHardDisk(hardDisk.getId()); - assertNotNull(hd); - - 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"); - } - } -} 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 deleted file mode 100644 index 5ca524d308..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/cloud/VirtualApplianceLiveApiTest.java +++ /dev/null @@ -1,96 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.domain.cloud; - -import static com.google.common.collect.Iterables.size; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertTrue; - -import java.util.List; - -import org.jclouds.abiquo.internal.BaseAbiquoApiLiveApiTest; -import org.testng.annotations.Test; - -import com.abiquo.server.core.cloud.VirtualApplianceDto; -import com.abiquo.server.core.cloud.VirtualApplianceState; -import com.google.common.collect.Lists; - -/** - * Live integration tests for the {@link VirtualAppliance} domain class. - * - * @author Francesc Montserrat - */ -@Test(groups = "api", testName = "VirtualApplianceLiveApiTest") -public class VirtualApplianceLiveApiTest extends BaseAbiquoApiLiveApiTest { - - 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()); - - assertEquals(updated.getName(), "Virtual AppAloha updated"); - } - - public void testCreateRepeated() { - VirtualAppliance repeated = VirtualAppliance.Builder.fromVirtualAppliance(env.virtualAppliance).build(); - - repeated.save(); - - List virtualAppliances = env.cloudApi.listVirtualAppliances(env.virtualDatacenter.unwrap()) - .getCollection(); - - assertEquals(virtualAppliances.size(), 2); - repeated.delete(); - } - - public void testGetState() { - assertEquals(env.virtualAppliance.getState(), VirtualApplianceState.NOT_DEPLOYED); - } - - public void testListVirtualMachinesReturnsAll() { - List vms = Lists.newArrayList(); - - // 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); - } - - try { - Iterable all = env.virtualAppliance.listVirtualMachines(); - - 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/VirtualApplianceLiveTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/cloud/VirtualApplianceLiveTest.java deleted file mode 100644 index ceb776974b..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/cloud/VirtualApplianceLiveTest.java +++ /dev/null @@ -1,128 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.domain.cloud; - -import static com.google.common.collect.Iterables.getLast; -import static org.jclouds.abiquo.reference.AbiquoTestConstants.PREFIX; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertNull; - -import java.util.concurrent.TimeUnit; - -import org.jclouds.abiquo.domain.task.AsyncTask; -import org.jclouds.abiquo.features.services.MonitoringService; -import org.jclouds.abiquo.internal.BaseAbiquoLiveApiTest; -import org.jclouds.abiquo.predicates.cloud.VirtualAppliancePredicates; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -import com.abiquo.server.core.cloud.VirtualApplianceState; -import com.abiquo.server.core.cloud.VirtualMachineState; -import com.google.common.collect.Ordering; -import com.google.common.primitives.Longs; - -/** - * Live integration tests for the {@link VirtualAppliance} domain class. - * - * @author Susana Acedo - */ -@Test(groups = "live", testName = "VirtualApplianceLiveTest") -public class VirtualApplianceLiveTest extends BaseAbiquoLiveApiTest { - private static final long MAX_WAIT = 2; - - private VirtualDatacenter vdc; - - private VirtualAppliance vapp; - - private VirtualMachine vm; - - private VirtualMachineTemplate vmt; - - private MonitoringService monitoringService; - - @BeforeClass(groups = { "integration", "live" }) - @Override - public void setupContext() { - super.setupContext(); - monitoringService = view.getMonitoringService(); - vdc = getLast(view.getCloudService().listVirtualDatacenters()); - vmt = templateBySize().min(vdc.listAvailableTemplates()); - } - - public void testCreateVirtualAppliance() { - vapp = VirtualAppliance.builder(view.getApiContext(), vdc).name(PREFIX + "Virtual Appliance Ohana").build(); - vapp.save(); - - assertNotNull(vapp.getId()); - } - - @Test(dependsOnMethods = "testCreateVirtualAppliance") - public void testUpdateVirtualAppliance() { - vapp.setName(PREFIX + "Virtual Appliance Updated"); - vapp.update(); - - // Reload the appliance to check the updated name - VirtualAppliance updated = vdc.getVirtualAppliance(vapp.getId()); - assertEquals(updated.getName(), PREFIX + "Virtual Appliance Updated"); - } - - @Test(dependsOnMethods = "testUpdateVirtualAppliance") - public void testDeployVirtualAppliance() { - vm = VirtualMachine.builder(view.getApiContext(), vapp, vmt).cpu(1).nameLabel(PREFIX + "VM Makua").ram(128) - .build(); - - vm.save(); - assertNotNull(vm.getId()); - - AsyncTask[] tasks = vapp.deploy(); - assertEquals(tasks.length, 1); // One task for each VM in the VAPP - - monitoringService.getVirtualApplianceMonitor().awaitCompletionDeploy(MAX_WAIT, TimeUnit.MINUTES, vapp); - assertEquals(vapp.getState(), VirtualApplianceState.DEPLOYED); - assertEquals(vm.getState(), VirtualMachineState.ON); - } - - @Test(dependsOnMethods = "testDeployVirtualAppliance") - public void testUndeployVirtualAppliance() { - AsyncTask[] tasks = vapp.undeploy(); - assertEquals(tasks.length, 1); // One task for each VM in the VAPP - - monitoringService.getVirtualApplianceMonitor().awaitCompletionUndeploy(MAX_WAIT, TimeUnit.MINUTES, vapp); - assertEquals(vapp.getState(), VirtualApplianceState.NOT_DEPLOYED); - assertEquals(vm.getState(), VirtualMachineState.NOT_ALLOCATED); - } - - @Test(dependsOnMethods = "testUndeployVirtualAppliance") - public void testDeleteVirtualAppliance() { - vapp.delete(); - assertNull(view.getCloudService().findVirtualAppliance( - VirtualAppliancePredicates.name(PREFIX + "Virtual Appliance Updated"))); - } - - private static Ordering templateBySize() { - return new Ordering() { - @Override - public int compare(final VirtualMachineTemplate left, final VirtualMachineTemplate right) { - return Longs.compare(left.getDiskFileSize(), right.getDiskFileSize()); - } - }; - } -} 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 deleted file mode 100644 index 10bc282ee4..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/cloud/VirtualDatacenterLiveApiTest.java +++ /dev/null @@ -1,181 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.domain.cloud; - -import static com.google.common.collect.Iterables.size; -import static org.jclouds.abiquo.reference.AbiquoTestConstants.PREFIX; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertNull; -import static org.testng.Assert.assertTrue; - -import java.util.List; - -import org.jclouds.abiquo.domain.cloud.VirtualDatacenter.Builder; -import org.jclouds.abiquo.domain.cloud.options.VirtualDatacenterOptions; -import org.jclouds.abiquo.domain.enterprise.Enterprise; -import org.jclouds.abiquo.domain.infrastructure.Datacenter; -import org.jclouds.abiquo.domain.network.PrivateNetwork; -import org.jclouds.abiquo.domain.network.PublicIp; -import org.jclouds.abiquo.internal.BaseAbiquoApiLiveApiTest; -import org.jclouds.abiquo.predicates.cloud.VirtualMachineTemplatePredicates; -import org.jclouds.abiquo.predicates.network.IpPredicates; -import org.testng.annotations.Test; - -import com.abiquo.model.enumerator.HypervisorType; -import com.abiquo.server.core.cloud.VirtualDatacenterDto; - -/** - * Live integration tests for the {@link VirtualDatacenter} domain class. - * - * @author Francesc Montserrat - */ -@Test(groups = "api", testName = "VirtualDatacenterLiveApiTest") -public class VirtualDatacenterLiveApiTest extends BaseAbiquoApiLiveApiTest { - private VirtualMachineTemplate template; - - public void testUpdate() { - env.virtualDatacenter.setName("Aloha updated"); - env.virtualDatacenter.update(); - - // Recover the updated virtual datacenter - VirtualDatacenterDto updated = env.cloudApi.getVirtualDatacenter(env.virtualDatacenter.getId()); - - 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(); - - VirtualDatacenter repeated = Builder.fromVirtualDatacenter(env.virtualDatacenter).network(newnet).build(); - - repeated.save(); - - List virtualDatacenters = env.cloudApi.listVirtualDatacenters( - VirtualDatacenterOptions.builder().build()).getCollection(); - - 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); - - List datacenters = enterprise.listAllowedDatacenters(); - assertNotNull(datacenters); - assertTrue(size(datacenters) > 0); - - Datacenter datacenter = datacenters.get(0); - - List hypervisors = datacenter.listAvailableHypervisors(); - assertNotNull(datacenters); - assertTrue(size(datacenters) > 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(); - - 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.delete(); - } - - public void testCreateFromVirtualDatacenter() { - HypervisorType hypervisor = env.virtualDatacenter.getHypervisorType(); - - Enterprise enterprise = env.user.getEnterprise(); - assertNotNull(enterprise); - - 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(); - - 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.delete(); - } - - 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); - - env.virtualDatacenter.releasePublicIp(apiIp); - apiIp = env.virtualDatacenter.findPurchasedPublicIp(IpPredicates. address(publicIp.getIp())); - assertNull(apiIp); - } - - public void testGetDefaultNetwork() { - PrivateNetwork network = env.virtualDatacenter.getDefaultNetwork().toPrivateNetwork(); - - 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()); - - template = templates.get(0); - } - - @Test(dependsOnMethods = "testGetAvailableTemplates") - public void testFindAvailableTemplate() { - VirtualMachineTemplate templateFound = env.virtualDatacenter - .findAvailableTemplate(VirtualMachineTemplatePredicates.id(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()); - } - -} 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 deleted file mode 100644 index 4f867928ef..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/cloud/VirtualMachineLiveApiTest.java +++ /dev/null @@ -1,125 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.domain.cloud; - -import static org.jclouds.abiquo.reference.AbiquoTestConstants.PREFIX; -import static org.jclouds.abiquo.util.Assert.assertHasError; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertNull; -import static org.testng.Assert.fail; - -import java.util.List; - -import javax.ws.rs.core.Response.Status; - -import org.jclouds.abiquo.domain.exception.AbiquoException; -import org.jclouds.abiquo.domain.task.AsyncTask; -import org.jclouds.abiquo.internal.BaseAbiquoApiLiveApiTest; -import org.testng.annotations.Test; - -import com.abiquo.server.core.cloud.VirtualMachineDto; -import com.abiquo.server.core.cloud.VirtualMachineState; - -/** - * Live integration tests for the {@link VirtualMachine} domain class. - * - * @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 void testUpdateInfoFromNode() { - env.virtualMachine.setNameLabel(PREFIX + "-label-updated"); - env.virtualMachine.update(); - env.virtualMachine.refresh(); - - assertEquals(env.virtualMachine.getNameLabel(), PREFIX + "-label-updated"); - } - - 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 testIsPersistent() { - assertFalse(env.virtualMachine.isPersistent()); - } - - 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 - - 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(); - - 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); - - 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(); - - VirtualMachineDto updated = env.cloudApi.getVirtualMachine(env.virtualAppliance.unwrap(), vm.getId()); - - assertNotNull(updated.getDvd()); - } -} diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/cloud/VirtualMachineLiveTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/cloud/VirtualMachineLiveTest.java deleted file mode 100644 index 5a5d9a39d2..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/cloud/VirtualMachineLiveTest.java +++ /dev/null @@ -1,184 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.domain.cloud; - -import static com.google.common.collect.Iterables.getLast; -import static org.jclouds.abiquo.reference.AbiquoTestConstants.PREFIX; -import static org.jclouds.abiquo.util.Assert.assertHasError; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertNull; -import static org.testng.Assert.fail; - -import java.util.concurrent.TimeUnit; - -import javax.ws.rs.core.Response.Status; - -import org.jclouds.abiquo.domain.enterprise.Enterprise; -import org.jclouds.abiquo.domain.exception.AbiquoException; -import org.jclouds.abiquo.domain.network.Ip; -import org.jclouds.abiquo.domain.task.AsyncTask; -import org.jclouds.abiquo.features.services.MonitoringService; -import org.jclouds.abiquo.internal.BaseAbiquoLiveApiTest; -import org.jclouds.abiquo.predicates.cloud.VirtualMachinePredicates; -import org.jclouds.abiquo.predicates.network.IpPredicates; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -import com.abiquo.server.core.cloud.VirtualMachineState; -import com.google.common.collect.Lists; -import com.google.common.collect.Ordering; -import com.google.common.primitives.Longs; - -/** - * Live integration tests for the {@link VirtualMachine} domain class. - * - * @author Susana Acedo - */ -@Test(groups = "live", testName = "VirtualMachineLiveTest") -public class VirtualMachineLiveTest extends BaseAbiquoLiveApiTest { - private static final long MAX_WAIT = 2; - - private VirtualDatacenter vdc; - - private VirtualAppliance vapp; - - private VirtualMachine vm; - - private VirtualMachineTemplate vmt; - - private MonitoringService monitoringService; - - @BeforeClass(groups = { "integration", "live" }) - @Override - public void setupContext() { - super.setupContext(); - monitoringService = view.getMonitoringService(); - vdc = getLast(view.getCloudService().listVirtualDatacenters()); - vmt = templateBySize().min(vdc.listAvailableTemplates()); - - vapp = VirtualAppliance.builder(view.getApiContext(), vdc).name(PREFIX + "Virtual Appliance Wahine").build(); - vapp.save(); - assertNotNull(vapp.getId()); - } - - @AfterClass(groups = { "integration", "live" }) - @Override - protected void tearDownContext() { - vapp.delete(); - super.tearDownContext(); - } - - @Test - public void testCreateVirtualMachine() { - vm = VirtualMachine.builder(view.getApiContext(), vapp, vmt).cpu(1).nameLabel(PREFIX + "VM Kane").ram(128) - .build(); - - vm.save(); - assertNotNull(vm.getId()); - } - - @Test(dependsOnMethods = "testCreateVirtualMachine") - public void testUpdateVirtualMachineWhenNotDeployed() { - vm.setNameLabel(PREFIX + "VM Kane Updated"); - AsyncTask task = vm.update(); - assertNull(task); - - VirtualMachine updated = vapp.findVirtualMachine(VirtualMachinePredicates.nameLabel(PREFIX + "VM Kane Updated")); - assertNotNull(updated); - } - - @Test(dependsOnMethods = "testUpdateVirtualMachineWhenNotDeployed") - public void testDeployVirtualMachine() { - AsyncTask task = vm.deploy(true); - assertNotNull(task); - - monitoringService.getVirtualMachineMonitor().awaitCompletionDeploy(MAX_WAIT, TimeUnit.MINUTES, vm); - assertEquals(vm.getState(), VirtualMachineState.ON); - } - - @Test(dependsOnMethods = "testDeployVirtualMachine") - public void testChangeVirtualMachineState() { - AsyncTask task = vm.changeState(VirtualMachineState.OFF); - assertNotNull(task); - - monitoringService.getVirtualMachineMonitor().awaitState(MAX_WAIT, TimeUnit.MINUTES, VirtualMachineState.OFF, vm); - assertEquals(vm.getState(), VirtualMachineState.OFF); - } - - @Test(dependsOnMethods = "testChangeVirtualMachineState") - public void testReconfigure() { - Ip ip = getLast(vdc.getDefaultNetwork().listUnusedIps()); - - AsyncTask task = vm.setNics(Lists.> newArrayList(ip)); - assertNotNull(task); - - monitoringService.getVirtualMachineMonitor().awaitState(MAX_WAIT, TimeUnit.MINUTES, VirtualMachineState.OFF, vm); - assertNotNull(vm.findAttachedNic(IpPredicates.address(ip.getIp()))); - } - - @Test(dependsOnMethods = "testReconfigure") - public void testUndeployVirtualMachine() { - AsyncTask task = vm.undeploy(); - assertNotNull(task); - - monitoringService.getVirtualMachineMonitor().awaitCompletionUndeploy(MAX_WAIT, TimeUnit.MINUTES, vm); - assertEquals(vm.getState(), VirtualMachineState.NOT_ALLOCATED); - } - - @Test(dependsOnMethods = "testUndeployVirtualMachine") - public void testDeployFailsWhenHardLimitsAreExceeded() { - Enterprise ent = view.getAdministrationService().getCurrentEnterprise(); - - if (vdc.getCpuCountHardLimit() != 0) { - vm.setCpu(vdc.getCpuCountHardLimit() + 1); - } else if (ent.getCpuCountHardLimit() != 0) { - vm.setCpu(ent.getCpuCountHardLimit() + 1); - } - - AsyncTask task = vm.update(); - assertNull(task); - - try { - vm.deploy(true); - fail("Deployments over the hard limits should not be allowed"); - } catch (AbiquoException ex) { - assertHasError(ex, Status.CONFLICT, "LIMIT_EXCEEDED"); - } - } - - @Test(dependsOnMethods = "testDeployFailsWhenHardLimitsAreExceeded") - public void tesDeleteVirtualMachine() { - Integer vmId = vm.getId(); - vm.delete(); - assertNull(vapp.getVirtualMachine(vmId)); - } - - private static Ordering templateBySize() { - return new Ordering() { - @Override - public int compare(final VirtualMachineTemplate left, final VirtualMachineTemplate right) { - return Longs.compare(left.getDiskFileSize(), right.getDiskFileSize()); - } - }; - } - -} 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 deleted file mode 100644 index 0d6b3ccd86..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/cloud/VirtualMachineNetworkingLiveApiTest.java +++ /dev/null @@ -1,219 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.domain.cloud; - -import static org.jclouds.abiquo.util.Assert.assertHasError; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertNull; -import static org.testng.Assert.fail; - -import java.util.List; - -import javax.ws.rs.core.Response.Status; - -import org.jclouds.abiquo.domain.exception.AbiquoException; -import org.jclouds.abiquo.domain.network.ExternalIp; -import org.jclouds.abiquo.domain.network.Ip; -import org.jclouds.abiquo.domain.network.PrivateIp; -import org.jclouds.abiquo.domain.network.PublicIp; -import org.jclouds.abiquo.domain.network.PublicNetwork; -import org.jclouds.abiquo.domain.network.UnmanagedIp; -import org.jclouds.abiquo.domain.network.UnmanagedNetwork; -import org.jclouds.abiquo.domain.task.AsyncTask; -import org.jclouds.abiquo.internal.BaseAbiquoApiLiveApiTest; -import org.jclouds.abiquo.predicates.network.IpPredicates; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -import com.google.common.collect.Lists; - -/** - * Live integration tests for the {@link VirtualMachine} networking operations. - * - * @author Ignasi Barrera - */ -@Test(groups = "api", testName = "VirtualMachineNetworkingLiveApiTest") -public class VirtualMachineNetworkingLiveApiTest extends BaseAbiquoApiLiveApiTest { - private PrivateIp privateIp; - - private ExternalIp externalIp; - - private PublicIp publicIpInfrastructure; - - private PublicIp publicIpCloud; - - private UnmanagedIp unmanagedIp1; - - private UnmanagedIp unmanagedIp2; - - @BeforeClass - public void setupIps() { - privateIp = env.privateNetwork.listUnusedIps().get(0); - assertNotNull(privateIp); - - externalIp = env.externalNetwork.listUnusedIps().get(0); - assertNotNull(externalIp); - - publicIpInfrastructure = env.virtualDatacenter.listAvailablePublicIps().get(0); - env.virtualDatacenter.purchasePublicIp(publicIpInfrastructure); - - publicIpCloud = env.virtualDatacenter.findPurchasedPublicIp(IpPredicates - . address(publicIpInfrastructure.getIp())); - assertNotNull(publicIpCloud); - } - - @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()); - - String address = publicIpCloud.getIp(); - env.virtualDatacenter.releasePublicIp(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); - - 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); - - List> nics = env.virtualMachine.listAttachedNics(); - assertEquals(nics.size(), 1); - assertEquals(nics.get(0).getId(), publicIpCloud.getId()); - } - - @Test(dependsOnMethods = "testAttachPublicIp") - public void testAttachPrivateIp() { - List> nics = Lists.newArrayList(env.virtualMachine.listAttachedNics()); - nics.add(privateIp); - - 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()); - } - - @Test(dependsOnMethods = "testAttachPrivateIp") - public void testAttachExternalIp() { - List> nics = Lists.newArrayList(env.virtualMachine.listAttachedNics()); - nics.add(externalIp); - - 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()); - } - - @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); - - 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); - } - - @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); - - 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(); - - 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()); - } - - @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()); - } - - // 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"); - } - } -} 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 deleted file mode 100644 index 99f694989f..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/cloud/VirtualMachineStorageLiveApiTest.java +++ /dev/null @@ -1,149 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.domain.cloud; - -import static org.jclouds.abiquo.reference.AbiquoTestConstants.PREFIX; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertNull; -import static org.testng.Assert.assertTrue; - -import java.util.List; - -import org.jclouds.abiquo.domain.infrastructure.Tier; -import org.jclouds.abiquo.domain.task.AsyncTask; -import org.jclouds.abiquo.internal.BaseAbiquoApiLiveApiTest; -import org.jclouds.abiquo.predicates.infrastructure.TierPredicates; -import org.testng.annotations.Test; - -/** - * Live integration tests for the {@link VirtualMachine} storage operations. - * - * @author Francesc Montserrat - */ -@Test(groups = "api", testName = "VirtualMachineStorageLiveApiTest") -public class VirtualMachineStorageLiveApiTest extends BaseAbiquoApiLiveApiTest { - private Volume volume; - - private HardDisk hardDisk; - - 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); - - 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 = "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()); - - deleteVolume(volume); - } - - 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); - - 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 = "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()); - - deleteHardDisk(hardDisk); - } - - 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(); - - assertNotNull(volume.getId()); - assertNotNull(env.virtualDatacenter.getVolume(volume.getId())); - - return volume; - } - - 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(); - - assertNotNull(hardDisk.getId()); - assertNotNull(hardDisk.getSequence()); - - return hardDisk; - } - - 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 deleted file mode 100644 index 1ed86cbf88..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/cloud/VirtualMachineTemplateLiveApiTest.java +++ /dev/null @@ -1,63 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.domain.cloud; - -import static org.jclouds.abiquo.util.Assert.assertHasError; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.fail; - -import javax.ws.rs.core.Response.Status; - -import org.jclouds.abiquo.domain.config.Category; -import org.jclouds.abiquo.domain.exception.AbiquoException; -import org.jclouds.abiquo.domain.infrastructure.Datacenter; -import org.jclouds.abiquo.internal.BaseAbiquoApiLiveApiTest; -import org.testng.annotations.Test; - -/** - * Live integration tests for the {@link VirtualMachineTemplate} domain class. - * - * @author Francesc Montserrat - */ -@Test(groups = "api", testName = "VirtualMachineTemplateLiveApiTest") -public class VirtualMachineTemplateLiveApiTest extends BaseAbiquoApiLiveApiTest { - - 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 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/VirtualMachineTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/cloud/VirtualMachineTest.java deleted file mode 100644 index 3a9e2598b2..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/cloud/VirtualMachineTest.java +++ /dev/null @@ -1,41 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.abiquo.domain.cloud; - -import org.easymock.EasyMock; -import org.jclouds.abiquo.AbiquoContext; -import org.testng.annotations.Test; - -/** - * Unit tests for the {@link VirtualMachine} class. - * - * @author Ignasi Barrera - */ -@Test(groups = "unit", testName = "VirtualMachineTest") -public class VirtualMachineTest { - - @Test(expectedExceptions = NullPointerException.class, expectedExceptionsMessageRegExp = "Missing required field nameLabel") - public void testNameLabelIsMandatory() { - AbiquoContext context = EasyMock.createMock(AbiquoContext.class); - VirtualAppliance vapp = EasyMock.createMock(VirtualAppliance.class); - VirtualMachineTemplate template = EasyMock.createMock(VirtualMachineTemplate.class); - - VirtualMachine.builder(context.getApiContext(), vapp, template).build(); - } -} 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 deleted file mode 100644 index ccce353d67..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/cloud/VolumeLiveApiTest.java +++ /dev/null @@ -1,130 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.domain.cloud; - -import static org.jclouds.abiquo.reference.AbiquoTestConstants.PREFIX; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertNull; -import static org.testng.Assert.assertTrue; - -import java.util.List; - -import org.jclouds.abiquo.domain.cloud.options.VolumeOptions; -import org.jclouds.abiquo.domain.infrastructure.Tier; -import org.jclouds.abiquo.domain.network.PrivateNetwork; -import org.jclouds.abiquo.domain.task.AsyncTask; -import org.jclouds.abiquo.internal.BaseAbiquoApiLiveApiTest; -import org.jclouds.abiquo.predicates.cloud.VolumePredicates; -import org.jclouds.abiquo.predicates.infrastructure.TierPredicates; -import org.testng.annotations.Test; - -import com.abiquo.server.core.infrastructure.storage.VolumeManagementDto; - -/** - * Live integration tests for the {@link Volume} domain class. - * - * @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())); - - 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())); - } - - @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(); - - assertEquals(volumes.size(), 1); - - volumes = env.cloudApi.listVolumes(env.virtualDatacenter.unwrap(), invalidOptions).getCollection(); - - assertEquals(volumes.size(), 0); - } - - @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); - - // 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(); - - 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.moveTo(newVdc); - - // 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); - - // 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(); - } - - @Test(dependsOnMethods = "testMoveVolume") - public void testDeleteVolume() { - Volume volume = env.virtualDatacenter.findVolume(VolumePredicates.name("Hawaian volume updated")); - assertNotNull(volume); - - Integer id = volume.getId(); - volume.delete(); - - 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 deleted file mode 100644 index 4cb31b829e..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/config/CategoryLiveApiTest.java +++ /dev/null @@ -1,69 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.domain.config; - -import static org.jclouds.abiquo.reference.AbiquoTestConstants.PREFIX; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; - -import org.jclouds.abiquo.internal.BaseAbiquoApiLiveApiTest; -import org.jclouds.abiquo.predicates.config.CategoryPredicates; -import org.testng.annotations.Test; - -/** - * Live integration tests for the {@link Category} domain class. - * - * @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(); - - Category apiCategory = env.context.getAdministrationService().findCategory( - CategoryPredicates.name(PREFIX + "-test-category")); - assertNotNull(apiCategory); - assertEquals(category.getName(), apiCategory.getName()); - - apiCategory.delete(); - } - - @Test(dependsOnMethods = "testCreateAndGet") - public void testUpdate() { - Iterable categories = env.context.getAdministrationService().listCategories(); - assertNotNull(categories); - - Category category = categories.iterator().next(); - String name = category.getName(); - - category.setName(PREFIX + "-test-category-updated"); - category.update(); - - Category apiCategory = env.context.getAdministrationService().findCategory( - CategoryPredicates.name(PREFIX + "-test-category-updated")); - - assertNotNull(apiCategory); - assertEquals(PREFIX + "-test-category-updated", apiCategory.getName()); - - 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 deleted file mode 100644 index 3701f7c537..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/config/CostCodeLiveApiTest.java +++ /dev/null @@ -1,129 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.domain.config; - -import static org.jclouds.abiquo.reference.AbiquoTestConstants.PREFIX; -import static org.jclouds.abiquo.util.Assert.assertHasError; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.fail; - -import java.math.BigDecimal; -import java.util.List; - -import javax.ws.rs.core.Response.Status; - -import com.google.common.collect.Lists; - -import org.jclouds.abiquo.domain.exception.AbiquoException; -import org.jclouds.abiquo.internal.BaseAbiquoApiLiveApiTest; -import org.jclouds.abiquo.predicates.config.PricingPredicates; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -/** - * Live integration tests for the {@link CostCode} domain class. - * - * @author Susana Acedo - */ -@Test(groups = "api", testName = "CostCodeLiveApiTest") -public class CostCodeLiveApiTest extends BaseAbiquoApiLiveApiTest { - private CostCode costcode; - - private Currency currency; - - private CostCodePrice costcodeprice; - - private List defaultPrices; - - @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.save(); - } - - @AfterClass - public void tearDownCostCode() { - currency.delete(); - costcode.delete(); - } - - 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"); - } - } - - public void testUpdate() { - costcode.setName(PREFIX + "costcode-updated"); - costcode.update(); - - CostCode apiCostCode = env.context.getPricingService().findCostCode( - PricingPredicates.costCode(PREFIX + "costcode-updated")); - - assertNotNull(apiCostCode); - assertEquals(PREFIX + "costcode-updated", apiCostCode.getName()); - - } - - 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 = Lists.newArrayList(); - 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")); - - 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); - } - - 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 deleted file mode 100644 index c2626b1326..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/config/CurrencyLiveApiTest.java +++ /dev/null @@ -1,70 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.domain.config; - -import static org.jclouds.abiquo.reference.AbiquoTestConstants.PREFIX; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; - -import org.jclouds.abiquo.internal.BaseAbiquoApiLiveApiTest; -import org.jclouds.abiquo.predicates.config.PricingPredicates; -import org.testng.annotations.Test; - -/** - * Live integration tests for the {@link Currency} domain class. - * - * @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(); - - Currency apiCurrency = env.context.getPricingService().findCurrency( - PricingPredicates.currency(PREFIX + "test-currency")); - assertNotNull(apiCurrency); - assertEquals(currency.getName(), apiCurrency.getName()); - - apiCurrency.delete(); - } - - @Test(dependsOnMethods = "testCreateAndGet") - public void testUpdate() { - Iterable currencies = env.context.getPricingService().listCurrencies(); - assertNotNull(currencies); - - Currency currency = currencies.iterator().next(); - String name = currency.getName(); - - currency.setName(PREFIX + "t-currency-upd"); - currency.update(); - - Currency apiCurrency = env.context.getPricingService().findCurrency( - PricingPredicates.currency(PREFIX + "t-currency-upd")); - - assertNotNull(apiCurrency); - assertEquals(PREFIX + "t-currency-upd", apiCurrency.getName()); - - 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 deleted file mode 100644 index e10a123fa5..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/config/LicenseLiveApiTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.domain.config; - -import static org.jclouds.abiquo.util.Assert.assertHasError; -import static org.testng.Assert.fail; - -import javax.ws.rs.core.Response.Status; - -import org.jclouds.abiquo.domain.enterprise.User; -import org.jclouds.abiquo.domain.exception.AbiquoException; -import org.jclouds.abiquo.internal.BaseAbiquoApiLiveApiTest; -import org.testng.annotations.Test; - -/** - * Live integration tests for the {@link User} domain class. - * - * @author Francesc Montserrat - */ -@Test(groups = "api", testName = "LicenseLiveApiTest") -public class LicenseLiveApiTest extends BaseAbiquoApiLiveApiTest { - - 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"); - } - } -} 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 deleted file mode 100644 index 470f1d36b3..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/config/PricingTemplateLiveApiTest.java +++ /dev/null @@ -1,131 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.domain.config; - -import static org.jclouds.abiquo.reference.AbiquoTestConstants.PREFIX; -import static org.jclouds.abiquo.util.Assert.assertHasError; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.fail; - -import java.math.BigDecimal; -import java.util.Collection; -import java.util.Date; - -import javax.ws.rs.core.Response.Status; - -import org.jclouds.abiquo.domain.exception.AbiquoException; -import org.jclouds.abiquo.internal.BaseAbiquoApiLiveApiTest; -import org.jclouds.abiquo.predicates.config.PricingPredicates; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -import com.abiquo.model.enumerator.PricingPeriod; - -/** - * Live integration tests for the {@link PricingTemplate} domain class. - * - * @author Susana Acedo - */ -@Test(groups = "api", testName = "PricingTemplateLiveApiTest") -public class PricingTemplateLiveApiTest extends BaseAbiquoApiLiveApiTest { - private PricingTemplate pricingTemplate; - - private Currency currency; - - private CostCode costcode; - - private BigDecimal zero = new BigDecimal(0); - - @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.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.save(); - } - - @AfterClass - public void tearDownPricingTemplate() { - pricingTemplate.delete(); - costcode.delete(); - } - - 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"); - } - } - - public void testUpdate() { - pricingTemplate.setName(PREFIX + "pt-updated"); - pricingTemplate.update(); - - PricingTemplate apiPricingTemplate = env.context.getPricingService().findPricingTemplate( - PricingPredicates.pricingTemplate(PREFIX + "pt-updated")); - - 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 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); - } - } -} 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 deleted file mode 100644 index 6546d6730f..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/config/SystemPropertiesLiveApiTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.domain.config; - -import static org.testng.Assert.assertEquals; - -import org.jclouds.abiquo.domain.enterprise.User; -import org.jclouds.abiquo.internal.BaseAbiquoApiLiveApiTest; -import org.testng.annotations.Test; - -/** - * Live integration tests for the {@link User} domain class. - * - * @author Francesc Montserrat - */ -@Test(groups = "api", testName = "SystemPropertiesLiveApiTest") -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(); - - // Recover the updated datacenter - SystemProperty updated = env.administrationService.getSystemProperty("client.dashboard.showStartUpAlert"); - - assertEquals(updated.getValue(), "0"); - - 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 deleted file mode 100644 index fdaa4d5cc4..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/enterprise/EnterpriseLiveApiTest.java +++ /dev/null @@ -1,168 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.domain.enterprise; - -import static org.jclouds.abiquo.reference.AbiquoTestConstants.PREFIX; -import static org.jclouds.abiquo.util.Assert.assertHasError; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertTrue; -import static org.testng.Assert.fail; - -import java.util.List; - -import javax.ws.rs.core.Response.Status; - -import org.jclouds.abiquo.domain.cloud.VirtualAppliance; -import org.jclouds.abiquo.domain.cloud.VirtualMachine; -import org.jclouds.abiquo.domain.enterprise.Enterprise.Builder; -import org.jclouds.abiquo.domain.exception.AbiquoException; -import org.jclouds.abiquo.domain.infrastructure.Datacenter; -import org.jclouds.abiquo.internal.BaseAbiquoApiLiveApiTest; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -import com.abiquo.server.core.enterprise.DatacentersLimitsDto; -import com.abiquo.server.core.enterprise.EnterpriseDto; - -/** - * Live integration tests for the {@link Enterprise} domain class. - * - * @author Ignasi Barrera - */ -@Test(groups = "api", testName = "EnterpriseLiveApiTest") -public class EnterpriseLiveApiTest extends BaseAbiquoApiLiveApiTest { - private Enterprise enterprise; - - private Limits limits; - - @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); - - 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); - - 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()); - - enterprise.delete(); - } - - public void testUpdate() { - enterprise.setName("Updated Enterprise"); - enterprise.update(); - - // Recover the updated enterprise - EnterpriseDto updated = env.enterpriseApi.getEnterprise(enterprise.getId()); - - assertEquals(updated.getName(), "Updated Enterprise"); - } - - 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"); - } - } - - 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); - } - - 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); - - try { - limits.update(); - } catch (AbiquoException ex) { - assertHasError(ex, Status.BAD_REQUEST, "CONSTR-LIMITRANGE"); - } - } - - 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); - } - - public void testListAllowedDatacenters() { - List allowed = enterprise.listAllowedDatacenters(); - - 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 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 deleted file mode 100644 index 9e3b4c45ed..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/enterprise/EnterprisePropertiesLiveApiTest.java +++ /dev/null @@ -1,52 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.domain.enterprise; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertTrue; - -import org.jclouds.abiquo.internal.BaseAbiquoApiLiveApiTest; -import org.testng.annotations.Test; - -import com.abiquo.server.core.enterprise.EnterprisePropertiesDto; - -/** - * Live integration tests for the {@link Enterprise} domain class. - * - * @author Ignasi Barrera - */ -@Test(groups = "api", testName = "EnterprisePropertiesLiveApiTest") -public class EnterprisePropertiesLiveApiTest extends BaseAbiquoApiLiveApiTest { - - public void testUpdate() { - EnterpriseProperties properties = env.administrationService.getEnterpriseProperties(env.enterprise); - - Integer size = properties.getProperties().size(); - properties.getProperties().put("Prop", "Value"); - properties.update(); - - // 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")); - } -} 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 deleted file mode 100644 index 7be86b98a2..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/enterprise/TemplateDefinitionListLiveApiTest.java +++ /dev/null @@ -1,74 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.domain.enterprise; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertNull; - -import java.util.List; - -import org.jclouds.abiquo.internal.BaseAbiquoApiLiveApiTest; -import org.jclouds.abiquo.predicates.enterprise.TemplateDefinitionListPredicates; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -/** - * Live integration tests for the {@link TemplateDefinitionList} domain class. - * - * @author Francesc Montserrat - */ -@Test(groups = "api", testName = "TemplateDefinitionListLiveApiTest") -public class TemplateDefinitionListLiveApiTest extends BaseAbiquoApiLiveApiTest { - private TemplateDefinitionList list; - - public void testUpdate() { - list.setName(list.getName() + "Updated"); - list.update(); - - List lists = env.enterprise.listTemplateDefinitionLists(TemplateDefinitionListPredicates - .name("myListUpdated")); - - assertEquals(lists.size(), 1); - } - - 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(); - - list.save(); - - assertNotNull(list.getId()); - } - - @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 deleted file mode 100644 index 88b096010d..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/enterprise/UserLiveApiTest.java +++ /dev/null @@ -1,100 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.domain.enterprise; - -import static org.jclouds.abiquo.predicates.enterprise.UserPredicates.nick; -import static org.jclouds.abiquo.util.Assert.assertHasError; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.fail; - -import javax.ws.rs.core.Response.Status; - -import org.jclouds.abiquo.domain.exception.AbiquoException; -import org.jclouds.abiquo.internal.BaseAbiquoApiLiveApiTest; -import org.jclouds.abiquo.predicates.enterprise.UserPredicates; -import org.testng.annotations.Test; - -import com.abiquo.server.core.enterprise.UserDto; -import com.google.common.collect.Iterables; - -/** - * Live integration tests for the {@link User} domain class. - * - * @author Francesc Montserrat - */ -@Test(groups = "api", testName = "UserLiveApiTest") -public class UserLiveApiTest extends BaseAbiquoApiLiveApiTest { - - 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()); - - assertEquals(updated.getName(), "Manolo"); - - env.user.setName(username); - env.user.update(); - } - - 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"); - } - } - - public void testChangeRoleAndUpdate() { - env.user.setRole(env.anotherRole); - env.user.update(); - - Role role2 = env.enterprise.findUser(UserPredicates.nick(env.user.getNick())).getRole(); - - assertEquals(env.anotherRole.getId(), role2.getId()); - assertEquals(role2.getName(), "Another role"); - - env.user.setRole(env.role); - env.user.update(); - } - - 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.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()); - } -} 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 deleted file mode 100644 index 9522dad059..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/event/EventLiveApiTest.java +++ /dev/null @@ -1,245 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.domain.event; - -import static org.jclouds.abiquo.reference.AbiquoTestConstants.PREFIX; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertTrue; - -import java.util.Date; -import java.util.UUID; - -import org.jclouds.abiquo.domain.cloud.VirtualMachine; -import org.jclouds.abiquo.domain.cloud.Volume; -import org.jclouds.abiquo.domain.enterprise.User; -import org.jclouds.abiquo.domain.event.options.EventOptions; -import org.jclouds.abiquo.domain.infrastructure.Tier; -import org.jclouds.abiquo.internal.BaseAbiquoApiLiveApiTest; -import org.jclouds.abiquo.predicates.infrastructure.TierPredicates; -import org.testng.annotations.Test; - -import com.abiquo.model.enumerator.ComponentType; -import com.abiquo.model.enumerator.EventType; -import com.abiquo.model.enumerator.SeverityType; -import com.google.common.collect.Iterables; - -/** - * Live integration tests for the {@link Event} domain class. - * - * @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(); - - 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(); - - 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(); - - 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(); - - 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); - - 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(); - } - } - - 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(); - - EventOptions options = EventOptions.builder().dateFrom(new Date()).enterpriseName(name).build(); - assertEvents(options); - - 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(); - - 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(); - - 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(); - - EventOptions options = EventOptions.builder().dateFrom(new Date()).virtualAppName(name).build(); - assertEvents(options); - } - - public void testListEventsFilteredByVM() { - VirtualMachine vm = createVirtualMachine(); - vm.delete(); - - 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 - - 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(); - - 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(); - - 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(); - - 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(); - - EventOptions options = EventOptions.builder().dateFrom(new Date()).virtualAppName(name) - .description("Virtual appliance '" + name + "' has been modified.").build(); - assertEvents(options); - } - - // Helpers - - 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(); - - volume.save(); - assertNotNull(volume.getId()); - - return volume; - } - - private VirtualMachine createVirtualMachine() { - VirtualMachine virtualMachine = VirtualMachine - .builder(env.context.getApiContext(), env.virtualAppliance, env.template).cpu(2).ram(128) - .nameLabel(PREFIX + "events").build(); - - virtualMachine.save(); - assertNotNull(virtualMachine.getId()); - - return virtualMachine; - } - - 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 deleted file mode 100644 index 82bfaea18c..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/infrastructure/BladeLiveUcsTest.java +++ /dev/null @@ -1,84 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.domain.infrastructure; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertTrue; - -import org.jclouds.abiquo.internal.BaseAbiquoApiLiveApiTest; -import org.jclouds.abiquo.util.Config; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -import com.google.common.collect.Iterables; - -/** - * Live integration tests for the {@link Blade} domain class. - * - * @author Ignasi Barrera - */ -@Test(groups = "ucs", testName = "BladeLiveUcsTest") -public class BladeLiveUcsTest extends BaseAbiquoApiLiveApiTest { - Blade blade; - - public void testFindAvailableVirtualSwitch() { - String vswitch = Config.get("abiquo.hypervisor.vswitch"); - NetworkInterface found = env.machine.findAvailableVirtualSwitch(vswitch); - assertEquals(found, vswitch); - } - - 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 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 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); - } -} 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 deleted file mode 100644 index af6cbe49a0..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/infrastructure/DatacenterLiveApiTest.java +++ /dev/null @@ -1,82 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.domain.infrastructure; - -import static org.jclouds.abiquo.util.Assert.assertHasError; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertTrue; -import static org.testng.Assert.fail; - -import java.util.List; - -import javax.ws.rs.core.Response.Status; - -import org.jclouds.abiquo.domain.enterprise.Limits; -import org.jclouds.abiquo.domain.exception.AbiquoException; -import org.jclouds.abiquo.domain.infrastructure.Datacenter.Builder; -import org.jclouds.abiquo.internal.BaseAbiquoApiLiveApiTest; -import org.testng.annotations.Test; - -import com.abiquo.model.enumerator.HypervisorType; -import com.abiquo.server.core.infrastructure.DatacenterDto; - -/** - * Live integration tests for the {@link Datacenter} domain class. - * - * @author Ignasi Barrera - */ -@Test(groups = "api", testName = "DatacenterLiveApiTest") -public class DatacenterLiveApiTest extends BaseAbiquoApiLiveApiTest { - - public void testUpdate() { - env.datacenter.setLocation("New York"); - env.datacenter.update(); - - // Recover the updated datacenter - DatacenterDto updated = env.infrastructureApi.getDatacenter(env.datacenter.getId()); - - assertEquals(updated.getLocation(), "New York"); - } - - public void testCheckHypervisorType() { - HypervisorType type = env.datacenter.getHypervisorType(env.machine.getIp()); - - assertEquals(env.machine.getType(), type); - } - - 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"); - } - } - - 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 deleted file mode 100644 index c44fac683a..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/infrastructure/MachineLiveApiTest.java +++ /dev/null @@ -1,152 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.domain.infrastructure; - -import static org.jclouds.abiquo.util.Assert.assertHasError; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertNull; -import static org.testng.Assert.assertTrue; - -import java.net.URI; -import java.util.List; - -import javax.ws.rs.core.Response.Status; - -import org.jclouds.abiquo.domain.cloud.VirtualMachine; -import org.jclouds.abiquo.domain.enterprise.Enterprise; -import org.jclouds.abiquo.domain.exception.AbiquoException; -import org.jclouds.abiquo.internal.BaseAbiquoApiLiveApiTest; -import org.jclouds.abiquo.predicates.infrastructure.RemoteServicePredicates; -import org.jclouds.abiquo.util.Config; -import org.testng.annotations.Test; - -import com.abiquo.model.enumerator.HypervisorType; -import com.abiquo.model.enumerator.MachineState; -import com.abiquo.model.enumerator.RemoteServiceType; -import com.abiquo.server.core.infrastructure.MachineDto; - -/** - * Live integration tests for the {@link Machine} domain class. - * - * @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(); - - 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"); - } - - 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(); - } - - 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"); - } - - 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); - } - - 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); - - // 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 testFindAvailableVirtualSwitch() { - String vswitch = Config.get("abiquo.hypervisor.vswitch"); - NetworkInterface found = env.machine.findAvailableVirtualSwitch(vswitch); - assertEquals(found.getName(), vswitch); - } - - 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 testReserveMachine() { - assertFalse(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()); - } - - @Test(dependsOnMethods = "testReserveMachine") - public void testCancelReservation() { - env.machine.cancelReservationFor(env.enterprise); - assertFalse(env.machine.isReserved()); - - 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 deleted file mode 100644 index cf0ce82818..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/infrastructure/ManagedRackLiveUcsTest.java +++ /dev/null @@ -1,111 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.domain.infrastructure; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertNull; -import static org.testng.Assert.assertTrue; - -import java.util.List; - -import org.jclouds.abiquo.internal.BaseAbiquoApiLiveApiTest; -import org.jclouds.abiquo.predicates.infrastructure.LogicServerPredicates; -import org.jclouds.abiquo.predicates.infrastructure.ManagedRackPredicates; -import org.testng.annotations.Test; - -import com.abiquo.server.core.infrastructure.UcsRackDto; -import com.google.common.collect.Iterables; - -/** - * Live integration tests for the {@link ManagedRack} domain class. - * - * @author Francesc Montserrat - */ -@Test(groups = "ucs", testName = "ManagedRackLiveUcsTest") -public class ManagedRackLiveUcsTest extends BaseAbiquoApiLiveApiTest { - private LogicServer logicServer; - - private Organization organization; - - 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()); - - assertEquals(updated.getShortDescription(), "Updated description"); - } - - 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); - } - - 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); - } - - 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); - - env.ucsRack.cloneLogicServer(original, organization, "jclouds"); - - 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"); - } - - @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(); - - env.ucsRack.deleteLogicServer(logicServer); - - LogicServer profile = env.ucsRack.findServiceProfile(LogicServerPredicates.name(name)); - assertNull(profile); - } -} diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/infrastructure/NetworkServiceTypeLiveApiTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/infrastructure/NetworkServiceTypeLiveApiTest.java deleted file mode 100644 index ec004b053b..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/infrastructure/NetworkServiceTypeLiveApiTest.java +++ /dev/null @@ -1,68 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.abiquo.domain.infrastructure; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertNull; - -import org.jclouds.abiquo.domain.network.NetworkServiceType; -import org.jclouds.abiquo.internal.BaseAbiquoApiLiveApiTest; -import org.testng.annotations.Test; - -/** - * Live integration tests for the {@link NetworkServiceType} domain class. - * - * @author Jaume Devesa - */ -@Test(groups = "api", testName = "NetworkServiceTypeLiveApiTest") -public class NetworkServiceTypeLiveApiTest extends BaseAbiquoApiLiveApiTest { - - private NetworkServiceType nst = null; - - @Test - public void testCreate() { - nst = NetworkServiceType.builder(env.context.getApiContext(), env.datacenter).name("Storage Network").build(); - nst.save(); - - assertNotNull(nst.getId()); - NetworkServiceType copy = env.datacenter.getNetworkServiceType(nst.getId()); - assertEquals(copy.getName(), nst.getName()); - - } - - @Test(dependsOnMethods = "testCreate") - public void testUpdate() { - nst.setName("Storage Network Updated"); - nst.update(); - - NetworkServiceType copy = env.datacenter.getNetworkServiceType(nst.getId()); - assertEquals(copy.getName(), nst.getName()); - } - - @Test(dependsOnMethods = "testUpdate") - public void testDelete() { - Integer deleteId = nst.getId(); - nst.delete(); - - // Assert it is deleted - assertNull(env.datacenter.getNetworkServiceType(deleteId)); - - } -} 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 deleted file mode 100644 index 23c3c76eb0..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/infrastructure/RackLiveApiTest.java +++ /dev/null @@ -1,70 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.domain.infrastructure; - -import static org.jclouds.abiquo.predicates.infrastructure.RackPredicates.name; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertNull; - -import org.jclouds.abiquo.internal.BaseAbiquoApiLiveApiTest; -import org.testng.annotations.Test; - -import com.abiquo.server.core.infrastructure.RackDto; -import com.google.common.collect.Iterables; - -/** - * Live integration tests for the {@link Rack} domain class. - * - * @author Ignasi Barrera - */ -@Test(groups = "api", testName = "RackLiveApiTest") -public class RackLiveApiTest extends BaseAbiquoApiLiveApiTest { - - 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()); - - assertEquals(updated.getName(), "Updated rack"); - } - - 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() + "FAIL")); - assertEquals(Iterables.size(racks), 0); - } - - 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); - } - -} 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 deleted file mode 100644 index 95060e704a..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/infrastructure/RemoteServiceLiveApiTest.java +++ /dev/null @@ -1,115 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.domain.infrastructure; - -import static org.jclouds.abiquo.predicates.infrastructure.RemoteServicePredicates.type; -import static org.jclouds.abiquo.util.Assert.assertHasError; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertNull; -import static org.testng.Assert.assertTrue; -import static org.testng.Assert.fail; - -import java.net.URI; - -import javax.ws.rs.core.Response.Status; - -import org.jclouds.abiquo.domain.exception.AbiquoException; -import org.jclouds.abiquo.domain.infrastructure.RemoteService.Builder; -import org.jclouds.abiquo.internal.BaseAbiquoApiLiveApiTest; -import org.testng.annotations.Test; - -import com.abiquo.model.enumerator.RemoteServiceType; -import com.abiquo.server.core.infrastructure.RemoteServiceDto; -import com.google.common.collect.Iterables; - -/** - * Live integration tests for the {@link RemoteService} domain class. - * - * @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(); - - // Recover the updated remote service - RemoteServiceDto updated = env.infrastructureApi.getRemoteService(env.datacenter.unwrap(), - RemoteServiceType.VIRTUAL_FACTORY); - - assertEquals(updated.getUri(), rs.getUri()); - } - - 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); - - assertNull(deleted); - - 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(); - } - - 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 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"); - } - } - - 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); - } - - 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 deleted file mode 100644 index 179c5ef739..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/infrastructure/StorageDeviceLiveApiTest.java +++ /dev/null @@ -1,75 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.domain.infrastructure; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertNull; - -import org.jclouds.abiquo.internal.BaseAbiquoApiLiveApiTest; -import org.jclouds.abiquo.predicates.infrastructure.StorageDevicePredicates; -import org.testng.annotations.Test; - -import com.abiquo.server.core.infrastructure.storage.StorageDeviceDto; -import com.google.common.collect.Iterables; - -/** - * Live integration tests for the {@link StorageDevice} domain class. - * - * @author Ignasi Barrera - * @author Francesc Montserrat - */ -@Test(groups = "api", testName = "StorageDeviceLiveApiTest") -public class StorageDeviceLiveApiTest extends BaseAbiquoApiLiveApiTest { - - 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()); - - assertEquals(updated.getName(), "Updated storage device"); - } - - 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() - + "FAIL")); - assertEquals(Iterables.size(storageDevices), 0); - } - - 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); - } - -} 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 deleted file mode 100644 index 303e4598ce..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/infrastructure/StoragePoolLiveApiTest.java +++ /dev/null @@ -1,87 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.domain.infrastructure; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertNull; - -import org.jclouds.abiquo.internal.BaseAbiquoApiLiveApiTest; -import org.jclouds.abiquo.predicates.infrastructure.StoragePoolPredicates; -import org.jclouds.abiquo.predicates.infrastructure.TierPredicates; -import org.testng.annotations.Test; - -import com.google.common.collect.Iterables; - -/** - * Live integration tests for the {@link StorageDevice} domain class. - * - * @author Ignasi Barrera - * @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 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()); - } - } - - 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() + "FAIL")); - assertEquals(Iterables.size(storagePools), 0); - } - - 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); - } - - 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 deleted file mode 100644 index 96ea1aee1d..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/infrastructure/TierLiveApiTest.java +++ /dev/null @@ -1,64 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.domain.infrastructure; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; - -import org.jclouds.abiquo.internal.BaseAbiquoApiLiveApiTest; -import org.jclouds.abiquo.predicates.infrastructure.TierPredicates; -import org.testng.annotations.Test; - -import com.google.common.collect.Iterables; - -/** - * Live integration tests for the {@link StorageDevice} domain class. - * - * @author Ignasi Barrera - * @author Francesc Montserrat - */ -@Test(groups = "api", testName = "TierLiveApiTest") -public class TierLiveApiTest extends BaseAbiquoApiLiveApiTest { - - public void testUpdate() { - Tier tier = env.datacenter.listTiers().get(0); - assertNotNull(tier); - - 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"); - - // Set original name - tier.setName(previousName); - tier.update(); - } - - 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); - } -} 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 deleted file mode 100644 index 013bd93684..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/network/ExternalNetworkLiveApiTest.java +++ /dev/null @@ -1,160 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.domain.network; - -import static org.jclouds.abiquo.reference.AbiquoTestConstants.PREFIX; -import static org.jclouds.abiquo.util.Assert.assertHasError; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.fail; - -import java.util.List; - -import javax.ws.rs.core.Response.Status; - -import org.jclouds.abiquo.domain.exception.AbiquoException; -import org.jclouds.abiquo.domain.network.options.IpOptions; -import org.jclouds.abiquo.internal.BaseAbiquoApiLiveApiTest; -import org.jclouds.abiquo.predicates.network.IpPredicates; -import org.jclouds.abiquo.predicates.network.NetworkPredicates; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -import com.abiquo.server.core.infrastructure.network.ExternalIpsDto; - -/** - * Live integration tests for the {@link ExternalNetwork} domain class. - * - * @author Ignasi Barrera - */ -@Test(groups = "api", testName = "ExternalNetworkLiveApiTest") -public class ExternalNetworkLiveApiTest extends BaseAbiquoApiLiveApiTest { - private ExternalNetwork externalNetwork; - - @BeforeClass - public void setupNetwork() { - externalNetwork = createNetwork(env.externalNetwork, PREFIX + "-externalnetwork-test"); - } - - @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(); - - List ips = externalNetwork.listIps(); - - assertEquals(ips.size(), totalIps); - } - - 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(); - - 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(); - - 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())); - - 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"); - - 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(); - } - } - - public void testUpdateWithInvalidValues() { - ExternalNetwork toUpdate = createNetwork(externalNetwork, PREFIX + "-exttoupdate-test"); - - try { - toUpdate.setMask(60); - toUpdate.update(); - - 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 testGetDatacenter() { - assertEquals(externalNetwork.getDatacenter().getId(), env.datacenter.getId()); - } - - public void testGetNetworkFromIp() { - ExternalIp ip = externalNetwork.findIp(IpPredicates. notUsed()); - ExternalNetwork network = ip.getNetwork(); - - 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; - } -} 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 deleted file mode 100644 index 1d80e2ed89..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/network/GenericNetworkLiveApiTest.java +++ /dev/null @@ -1,84 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.domain.network; - -import static org.jclouds.abiquo.util.Assert.assertHasError; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; - -import java.util.List; - -import javax.ws.rs.core.Response.Status; - -import org.jclouds.abiquo.domain.exception.AbiquoException; -import org.jclouds.abiquo.internal.BaseAbiquoApiLiveApiTest; -import org.testng.annotations.Test; - -import com.abiquo.model.enumerator.NetworkType; - -/** - * Live integration tests for the {@link Network} domain class. - * - * @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 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(); - } - - 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(); - } - - 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(); - } - - 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 deleted file mode 100644 index f17881f8b4..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/network/PrivateNetworkLiveApiTest.java +++ /dev/null @@ -1,150 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.domain.network; - -import static org.jclouds.abiquo.reference.AbiquoTestConstants.PREFIX; -import static org.jclouds.abiquo.util.Assert.assertHasError; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.fail; - -import java.util.List; - -import javax.ws.rs.core.Response.Status; - -import org.jclouds.abiquo.domain.cloud.VirtualDatacenter; -import org.jclouds.abiquo.domain.exception.AbiquoException; -import org.jclouds.abiquo.domain.network.options.IpOptions; -import org.jclouds.abiquo.internal.BaseAbiquoApiLiveApiTest; -import org.jclouds.abiquo.predicates.network.IpPredicates; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -import com.abiquo.server.core.infrastructure.network.PrivateIpsDto; - -/** - * Live integration tests for the {@link PrivateNetwork} domain class. - * - * @author Ignasi Barrera - */ -@Test(groups = "api", testName = "PrivateNetworkLiveApiTest") -public class PrivateNetworkLiveApiTest extends BaseAbiquoApiLiveApiTest { - private PrivateNetwork privateNetwork; - - @BeforeClass - public void setupNetwork() { - privateNetwork = createNetwork(env.virtualDatacenter, env.privateNetwork, PREFIX + "-privatenetwork-test"); - } - - @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(); - - List ips = privateNetwork.listIps(); - - assertEquals(ips.size(), totalIps); - } - - 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(); - - 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(); - - 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()); - - 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"); - - 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(); - } - } - - public void testUpdateWithInvalidValues() { - PrivateNetwork toUpdate = createNetwork(env.virtualDatacenter, privateNetwork, PREFIX + "-privtoupdate-test"); - - try { - toUpdate.setMask(60); - toUpdate.update(); - - 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(); - - 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; - } -} 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 deleted file mode 100644 index 94200fc268..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/network/PublicNetworkLiveApiTest.java +++ /dev/null @@ -1,154 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.domain.network; - -import static org.jclouds.abiquo.reference.AbiquoTestConstants.PREFIX; -import static org.jclouds.abiquo.util.Assert.assertHasError; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.fail; - -import java.util.List; - -import javax.ws.rs.core.Response.Status; - -import org.jclouds.abiquo.domain.exception.AbiquoException; -import org.jclouds.abiquo.domain.network.options.IpOptions; -import org.jclouds.abiquo.internal.BaseAbiquoApiLiveApiTest; -import org.jclouds.abiquo.predicates.network.IpPredicates; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -import com.abiquo.server.core.infrastructure.network.PublicIpsDto; - -/** - * Live integration tests for the {@link PublicNetwork} domain class. - * - * @author Ignasi Barrera - */ -@Test(groups = "api", testName = "PublicNetworkLiveApiTest") -public class PublicNetworkLiveApiTest extends BaseAbiquoApiLiveApiTest { - private PublicNetwork publicNetwork; - - @BeforeClass - public void setupNetwork() { - publicNetwork = createNetwork(env.publicNetwork, PREFIX + "-publicnetwork-test"); - } - - @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(); - - List ips = publicNetwork.listIps(); - - assertEquals(ips.size(), totalIps); - } - - 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(); - - 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(); - - 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(); - - 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"); - - 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(); - } - } - - public void testUpdateWithInvalidValues() { - PublicNetwork toUpdate = createNetwork(publicNetwork, PREFIX + "-pubtoupdate-test"); - - try { - toUpdate.setMask(60); - toUpdate.update(); - - 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 testGetNetworkFromIp() { - PublicIp ip = publicNetwork.findIp(IpPredicates. notUsed()); - PublicNetwork network = ip.getNetwork(); - - 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; - } -} 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 deleted file mode 100644 index cf2ebf77bb..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/network/UnmanagedNetworkLiveApiTest.java +++ /dev/null @@ -1,161 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.domain.network; - -import static org.jclouds.abiquo.reference.AbiquoTestConstants.PREFIX; -import static org.jclouds.abiquo.util.Assert.assertHasError; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertNull; -import static org.testng.Assert.fail; - -import java.util.List; - -import javax.ws.rs.core.Response.Status; - -import org.jclouds.abiquo.domain.exception.AbiquoException; -import org.jclouds.abiquo.domain.network.options.IpOptions; -import org.jclouds.abiquo.internal.BaseAbiquoApiLiveApiTest; -import org.jclouds.abiquo.predicates.network.IpPredicates; -import org.jclouds.abiquo.predicates.network.NetworkPredicates; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -import com.abiquo.server.core.infrastructure.network.UnmanagedIpsDto; - -/** - * Live integration tests for the {@link UnmanagedNetwork} domain class. - * - * @author Ignasi Barrera - */ -@Test(groups = "api", testName = "UnmanagedNetworkLiveApiTest") -public class UnmanagedNetworkLiveApiTest extends BaseAbiquoApiLiveApiTest { - private UnmanagedNetwork unmanagedNetwork; - - @BeforeClass - public void setupNetwork() { - unmanagedNetwork = createNetwork(env.unmanagedNetwork, PREFIX + "-unmanagednetwork-test"); - } - - @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(); - - List ips = unmanagedNetwork.listIps(); - - 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 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); - } - - 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"); - - // 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"); - } - - 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(); - - 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"); - - try { - toUpdate.setMask(60); - toUpdate.update(); - - 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 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); - } - - 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 deleted file mode 100644 index 8b38a93ffa..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/environment/CloudTestEnvironment.java +++ /dev/null @@ -1,223 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.environment; - -import static com.google.common.base.Preconditions.checkNotNull; -import static org.jclouds.abiquo.reference.AbiquoTestConstants.PREFIX; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertNull; - -import java.util.Collections; -import java.util.List; - -import org.jclouds.ContextBuilder; -import org.jclouds.abiquo.AbiquoApiMetadata; -import org.jclouds.abiquo.AbiquoContext; -import org.jclouds.abiquo.domain.cloud.VirtualAppliance; -import org.jclouds.abiquo.domain.cloud.VirtualDatacenter; -import org.jclouds.abiquo.domain.cloud.VirtualMachine; -import org.jclouds.abiquo.domain.cloud.VirtualMachineTemplate; -import org.jclouds.abiquo.domain.enterprise.Enterprise; -import org.jclouds.abiquo.domain.network.PrivateIp; -import org.jclouds.abiquo.domain.network.PrivateNetwork; -import org.jclouds.abiquo.features.CloudApi; -import org.jclouds.abiquo.features.services.EventService; -import org.jclouds.abiquo.predicates.enterprise.EnterprisePredicates; -import org.jclouds.abiquo.predicates.network.NetworkPredicates; -import org.testng.collections.Lists; - -import com.google.common.collect.Ordering; -import com.google.common.primitives.Longs; - -/** - * Test environment for cloud live tests. - * - * @author Francesc Montserrat - */ -public class CloudTestEnvironment extends InfrastructureTestEnvironment { - - // Environment data made public so tests can use them easily - public CloudApi cloudApi; - - public EventService eventService; - - public VirtualDatacenter virtualDatacenter; - - public VirtualAppliance virtualAppliance; - - public VirtualMachine virtualMachine; - - public VirtualMachineTemplate template; - - public PrivateNetwork privateNetwork; - - public Enterprise defaultEnterprise; - - public AbiquoContext plainUserContext; - - public AbiquoContext enterpriseAdminContext; - - 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(); - - createUserContext(); - createEnterpriseAdminContext(); - - findDefaultEnterprise(); - createVirtualDatacenter(); - createVirtualAppliance(); - refreshTemplateRepository(); - createVirtualMachine(); - } - - @Override - public void tearDown() throws Exception { - closeEnterpriseAdminContext(); - closeUserContext(); - - deleteVirtualMachine(); - deleteVirtualAppliance(); - deleteVirtualDatacenter(); - - // Delete base infrastructure - super.tearDown(); - } - - // Setup - - private void createUserContext() { - String endpoint = checkNotNull(System.getProperty("test.abiquo.endpoint"), "test.abiquo.endpoint"); - - 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"); - - 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 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.save(); - assertNotNull(virtualDatacenter.getId()); - - privateNetwork = virtualDatacenter - .findPrivateNetwork(NetworkPredicates. name(privateNetwork.getName())); - } - - protected void createVirtualAppliance() { - virtualAppliance = VirtualAppliance.builder(context.getApiContext(), virtualDatacenter) - .name(PREFIX + "Virtual AppAloha").build(); - - virtualAppliance.save(); - assertNotNull(virtualAppliance.getId()); - } - - protected void createVirtualMachine() { - List templates = virtualDatacenter.listAvailableTemplates(); - assertFalse(templates.isEmpty()); - - List sorted = Lists.newArrayList(templates); - - // Sort by size to use the smallest one - Collections.sort(sorted, new Ordering() { - @Override - public int compare(final VirtualMachineTemplate left, final VirtualMachineTemplate right) { - return Longs.compare(left.getDiskFileSize(), right.getDiskFileSize()); - } - }); - - template = sorted.get(0); - - virtualMachine = VirtualMachine.builder(context.getApiContext(), virtualAppliance, template).cpu(2) - .nameLabel(PREFIX + "VM Aloha").ram(128).build(); - - virtualMachine.save(); - assertNotNull(virtualMachine.getId()); - - } - - protected void refreshTemplateRepository() { - defaultEnterprise.refreshTemplateRepository(datacenter); - } - - // Tear down - - private void closeUserContext() { - plainUserContext.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 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)); - } - - } - -} 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 deleted file mode 100644 index d4edcebe66..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/environment/InfrastructureTestEnvironment.java +++ /dev/null @@ -1,474 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.environment; - -import static com.google.common.collect.Iterables.find; -import static org.jclouds.abiquo.reference.AbiquoTestConstants.PREFIX; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertNull; - -import java.io.IOException; -import java.net.URI; -import java.net.URL; -import java.nio.charset.Charset; -import java.util.List; -import java.util.UUID; - -import org.jclouds.abiquo.AbiquoContext; -import org.jclouds.abiquo.config.AbiquoEdition; -import org.jclouds.abiquo.domain.config.License; -import org.jclouds.abiquo.domain.enterprise.Enterprise; -import org.jclouds.abiquo.domain.enterprise.Limits; -import org.jclouds.abiquo.domain.enterprise.Role; -import org.jclouds.abiquo.domain.enterprise.User; -import org.jclouds.abiquo.domain.infrastructure.Datacenter; -import org.jclouds.abiquo.domain.infrastructure.Datastore; -import org.jclouds.abiquo.domain.infrastructure.Machine; -import org.jclouds.abiquo.domain.infrastructure.ManagedRack; -import org.jclouds.abiquo.domain.infrastructure.NetworkInterface; -import org.jclouds.abiquo.domain.infrastructure.Rack; -import org.jclouds.abiquo.domain.infrastructure.RemoteService; -import org.jclouds.abiquo.domain.infrastructure.StorageDevice; -import org.jclouds.abiquo.domain.infrastructure.StorageDeviceMetadata; -import org.jclouds.abiquo.domain.infrastructure.StoragePool; -import org.jclouds.abiquo.domain.infrastructure.Tier; -import org.jclouds.abiquo.domain.network.ExternalNetwork; -import org.jclouds.abiquo.domain.network.NetworkServiceType; -import org.jclouds.abiquo.domain.network.PublicNetwork; -import org.jclouds.abiquo.domain.network.UnmanagedNetwork; -import org.jclouds.abiquo.features.AdminApi; -import org.jclouds.abiquo.features.ConfigApi; -import org.jclouds.abiquo.features.EnterpriseApi; -import org.jclouds.abiquo.features.InfrastructureApi; -import org.jclouds.abiquo.features.services.AdministrationService; -import org.jclouds.abiquo.predicates.enterprise.RolePredicates; -import org.jclouds.abiquo.predicates.enterprise.UserPredicates; -import org.jclouds.abiquo.predicates.infrastructure.RemoteServicePredicates; -import org.jclouds.abiquo.predicates.infrastructure.StorageDeviceMetadataPredicates; -import org.jclouds.abiquo.predicates.infrastructure.StoragePoolPredicates; -import org.jclouds.abiquo.predicates.infrastructure.TierPredicates; -import org.jclouds.abiquo.util.Config; - -import com.abiquo.model.enumerator.HypervisorType; -import com.abiquo.model.enumerator.RemoteServiceType; -import com.google.common.collect.Iterables; -import com.google.common.io.Resources; - -/** - * Test environment for infrastructure live tests. - * - * @author Ignasi Barrera - */ -public class InfrastructureTestEnvironment implements TestEnvironment { - /** The rest context. */ - public AbiquoContext context; - - // Environment data made public so tests can use them easily - - public AdministrationService administrationService; - - public InfrastructureApi infrastructureApi; - - public EnterpriseApi enterpriseApi; - - public AdminApi adminApi; - - public ConfigApi configApi; - - // Resources - - public License license; - - public Datacenter datacenter; - - public PublicNetwork publicNetwork; - - public ExternalNetwork externalNetwork; - - public UnmanagedNetwork unmanagedNetwork; - - public List remoteServices; - - public Rack rack; - - public Machine machine; - - public Enterprise enterprise; - - public StorageDevice storageDevice; - - public StoragePool storagePool; - - public Tier tier; - - public User user; - - public User enterpriseAdmin; - - public Role role; - - public Role anotherRole; - - 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(); - } - - @Override - public void setup() throws Exception { - // Configuration - createLicense(); - - // Intrastructure - createDatacenter(); - createRack(); - createMachine(); - createStorageDevice(); - createStoragePool(); - createPublicNetwork(); - - // Enterprise - createEnterprise(); - createRoles(); - createUsers(); - - // Networking - createExternalNetwork(); - createUnmanagedNetwork(); - } - - @Override - public void tearDown() throws Exception { - deleteUsers(); - - deleteRole(role); - deleteRole(anotherRole); - - deleteUnmanagedNetwork(); - deleteExternalNetwork(); - deletePublicNetwork(); - deleteStoragePool(); - deleteStorageDevice(); - deleteMachine(); - deleteUcsRack(); - deleteRack(); - deleteDatacenter(); - deleteEnterprise(); - - deleteLicense(); - } - - // Setup - - protected void createLicense() throws IOException { - license = License.builder(context.getApiContext(), readLicense()).build(); - - license.add(); - assertNotNull(license.getId()); - } - - 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()); - - 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"); - - machine = datacenter.discoverSingleMachine(ip, type, user, pass); - - NetworkServiceType nst = datacenter.defaultNetworkServiceType(); - NetworkInterface vswitch = machine.findAvailableVirtualSwitch(Config.get("abiquo.hypervisor.vswitch")); - vswitch.setNetworkServiceType(nst); - - Datastore datastore = machine.findDatastore(Config.get("abiquo.hypervisor.datastore")); - datastore.setEnabled(true); - - 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()); - } - - 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.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"); - - List devices = datacenter.listSupportedStorageDevices(); - StorageDeviceMetadata metadata = Iterables.find(devices, StorageDeviceMetadataPredicates.type(type)); - - storageDevice = StorageDevice.builder(context.getApiContext(), datacenter) // - .name(PREFIX + "Storage Device")// - .type(type)// - .managementIp(ip).managementPort(metadata.getDefaultManagementPort())// - .iscsiIp(ip).iscsiPort(metadata.getDefaultIscsiPort()) // - .username(user)// - .password(pass) // - .build(); - - storageDevice.save(); - assertNotNull(storageDevice.getId()); - } - - 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.setTier(tier); - storagePool.save(); - - assertNotNull(storagePool.getUUID()); - } - - 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.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.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(); - - anotherRole = Role.Builder.fromRole(role).build(); - anotherRole.setName("Another role"); - anotherRole.save(); - - 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 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 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 - - 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 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))); - } - - 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 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 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 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); - - 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 deleteLicense() { - license.remove(); - } - - protected static String randomName() { - return PREFIX + UUID.randomUUID().toString().substring(0, 12); - } - - // Utility methods - - public static String readLicense() throws IOException { - URL url = CloudTestEnvironment.class.getResource("/license/expired"); - - return Resources.toString(url, Charset.defaultCharset()); - } - - 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 deleted file mode 100644 index 53426fa32e..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/environment/TestEnvironment.java +++ /dev/null @@ -1,40 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.environment; - -/** - * Base class fot test environment populators. - *

- * 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; - - /** - * 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 deleted file mode 100644 index 87f45229eb..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/events/handlers/BlockingEventHandlerTest.java +++ /dev/null @@ -1,112 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.events.handlers; - -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertNull; -import static org.testng.Assert.assertTrue; - -import java.util.concurrent.Executors; -import java.util.concurrent.TimeUnit; - -import org.jclouds.abiquo.events.monitor.MonitorEvent; -import org.jclouds.abiquo.events.monitor.MonitorEvent.Type; -import org.testng.annotations.Test; - -/** - * Unit tests for the {@link BlockingEventHandler} handler. - * - * @author Ignasi Barrera - */ -@Test(groups = "unit", testName = "BlockingEventHandlerTest") -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 = IllegalArgumentException.class) - public void testConstructorWithtEmptyObjects() { - new BlockingEventHandler(new 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()))); - } - - 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); - - // 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); - - handler.lock(); - } - - 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()); - } - - }, 500L, TimeUnit.MILLISECONDS); - - handler.lock(); - } - - public void testLockDoesNothingIfNoObjects() { - Object object = new Object(); - BlockingEventHandler handler = new BlockingEventHandler(object); - handler.lockedObjects.clear(); - - handler.lock(); // Lock should do nothing - - assertNull(handler.completeSignal); - } -} diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/fallbacks/AppendApiVersionToAbiquoMimeTypeTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/fallbacks/AppendApiVersionToAbiquoMimeTypeTest.java deleted file mode 100644 index b9c3dcbd96..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/fallbacks/AppendApiVersionToAbiquoMimeTypeTest.java +++ /dev/null @@ -1,65 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.fallbacks; - -import static org.testng.Assert.assertEquals; - -import org.jclouds.abiquo.AbiquoAsyncApi; -import org.jclouds.abiquo.functions.AppendApiVersionToAbiquoMimeType; -import org.testng.annotations.Test; - -import com.google.common.base.Function; - -/** - * Unit tests for the {@link AppendApiVersionToAbiquoMimeType} 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); - } - - @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 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"), - "application/vnd.abiquo.datacenters+xml;version=" + AbiquoAsyncApi.API_VERSION); - } -} diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/fallbacks/FalseIfNotAvailableTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/fallbacks/FalseIfNotAvailableTest.java deleted file mode 100644 index 104c324693..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/fallbacks/FalseIfNotAvailableTest.java +++ /dev/null @@ -1,110 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.fallbacks; - -import static org.easymock.EasyMock.expect; -import static org.easymock.EasyMock.replay; -import static org.easymock.EasyMock.verify; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; - -import org.easymock.EasyMock; -import org.jclouds.abiquo.AbiquoFallbacks.FalseIfNotAvailable; -import org.jclouds.http.HttpResponse; -import org.jclouds.http.HttpResponseException; -import org.jclouds.rest.ResourceNotFoundException; -import org.testng.annotations.Test; - -/** - * Unit tests for the {@link FalseIfNotAvailable} function. - * - * @author Ignasi Barrera - */ -@Test(groups = "unit", testName = "FalseIfNotAvailableTest") -public class FalseIfNotAvailableTest { - public void testOriginalExceptionIfUnknownException() { - FalseIfNotAvailable function = new FalseIfNotAvailable(); - RuntimeException exception = new RuntimeException(); - - try { - function.createOrPropagate(exception); - } catch (Exception ex) { - assertEquals(ex, exception); - } - } - - public void testFalseIf5xx() throws Exception { - FalseIfNotAvailable function = new FalseIfNotAvailable(); - 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); - - replay(response); - replay(exception); - - assertFalse(function.createOrPropagate(exception)); - - verify(response); - verify(exception); - } - - public void testExceptionIfNot5xx() { - FalseIfNotAvailable function = new FalseIfNotAvailable(); - 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); - - replay(response); - replay(exception); - - try { - function.createOrPropagate(exception); - } catch (Exception ex) { - assertEquals(ex, exception); - } - - verify(response); - verify(exception); - } - - public void testFalseIfResourceNotFound() throws Exception { - FalseIfNotAvailable function = new FalseIfNotAvailable(); - ResourceNotFoundException exception = new ResourceNotFoundException(); - - assertFalse(function.createOrPropagate(exception)); - } - -} diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/fallbacks/FalseOn5xxTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/fallbacks/FalseOn5xxTest.java deleted file mode 100644 index 8e37e11320..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/fallbacks/FalseOn5xxTest.java +++ /dev/null @@ -1,101 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.fallbacks; - -import static org.easymock.EasyMock.expect; -import static org.easymock.EasyMock.replay; -import static org.easymock.EasyMock.verify; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; - -import org.easymock.EasyMock; -import org.jclouds.abiquo.AbiquoFallbacks.FalseOn5xx; -import org.jclouds.http.HttpResponse; -import org.jclouds.http.HttpResponseException; -import org.testng.annotations.Test; - -/** - * Unit tests for the {@link FalseOn5xx} function. - * - * @author Ignasi Barrera - */ -@Test(groups = "unit", testName = "FalseOn5xxTest") -public class FalseOn5xxTest { - public void testOriginalExceptionIfNotHttpResponseException() { - FalseOn5xx function = new FalseOn5xx(); - RuntimeException exception = new RuntimeException(); - - try { - function.createOrPropagate(exception); - } catch (Exception ex) { - assertEquals(ex, exception); - } - } - - public void testFalseIf5xx() throws Exception { - FalseOn5xx function = new FalseOn5xx(); - 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); - - replay(response); - replay(exception); - - assertFalse(function.createOrPropagate(exception)); - - verify(response); - verify(exception); - } - - public void testExceptionIfNot5xx() { - FalseOn5xx function = new FalseOn5xx(); - 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); - - replay(response); - replay(exception); - - try { - function.createOrPropagate(exception); - } catch (Exception ex) { - assertEquals(ex, exception); - } - - verify(response); - verify(exception); - } -} diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/fallbacks/MovedVolumeTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/fallbacks/MovedVolumeTest.java deleted file mode 100644 index dad9ebddb6..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/fallbacks/MovedVolumeTest.java +++ /dev/null @@ -1,97 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.fallbacks; - -import static org.easymock.EasyMock.expect; -import static org.easymock.EasyMock.replay; -import static org.easymock.EasyMock.verify; -import static org.testng.Assert.assertEquals; - -import javax.ws.rs.core.Response.Status; - -import org.easymock.EasyMock; -import org.jclouds.abiquo.fallbacks.MovedVolume.ReturnMoveVolumeReference; -import org.jclouds.http.HttpResponse; -import org.jclouds.http.HttpResponseException; -import org.jclouds.io.Payload; -import org.jclouds.io.Payloads; -import org.jclouds.xml.internal.JAXBParser; -import org.testng.annotations.Test; - -import com.abiquo.server.core.infrastructure.storage.MovedVolumeDto; -import com.abiquo.server.core.infrastructure.storage.VolumeManagementDto; -import com.google.inject.TypeLiteral; - -/** - * Unit tests for the {@link MovedVolume} function. - * - * @author Ignasi Barrera - */ -@Test(groups = "unit", testName = "MovedVolumeTest") -public class MovedVolumeTest { - public void testReturnOriginalExceptionIfNotHttpResponseException() { - MovedVolume function = new MovedVolume(new ReturnMoveVolumeReference( - new JAXBParser("false"), TypeLiteral.get(MovedVolumeDto.class))); - - RuntimeException exception = new RuntimeException(); - - try { - function.create(exception); - } catch (Exception ex) { - assertEquals(ex, exception); - } - } - - public void testReturnVolume() throws Exception { - JAXBParser xmlParser = new JAXBParser("false"); - MovedVolume function = new MovedVolume(new ReturnMoveVolumeReference( - new JAXBParser("false"), TypeLiteral.get(MovedVolumeDto.class))); - - 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)); - - // 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); - - function.create(exception); - - verify(response); - verify(exception); - } -} diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/fallbacks/NullOn303Test.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/fallbacks/NullOn303Test.java deleted file mode 100644 index b056312d95..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/fallbacks/NullOn303Test.java +++ /dev/null @@ -1,99 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.fallbacks; - -import static org.easymock.EasyMock.expect; -import static org.easymock.EasyMock.replay; -import static org.easymock.EasyMock.verify; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNull; - -import org.easymock.EasyMock; -import org.jclouds.abiquo.AbiquoFallbacks.NullOn303; -import org.jclouds.http.HttpResponse; -import org.jclouds.http.HttpResponseException; -import org.testng.annotations.Test; - -/** - * Unit tests for the {@link NullOn303} function. - * - * @author Ignasi Barrera - */ -@Test(groups = "unit", testName = "NullOn303Test") -public class NullOn303Test { - public void testOriginalExceptionIfNotHttpResponseException() { - NullOn303 function = new NullOn303(); - RuntimeException exception = new RuntimeException(); - - try { - function.createOrPropagate(exception); - } catch (Exception ex) { - assertEquals(ex, exception); - } - } - - public void testNullIf303() throws Exception { - NullOn303 function = new NullOn303(); - 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); - - replay(response); - replay(exception); - - assertNull(function.createOrPropagate(exception)); - - verify(response); - verify(exception); - } - - public void testExceptionIfNot303() { - NullOn303 function = new NullOn303(); - 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); - - replay(response); - replay(exception); - - try { - function.createOrPropagate(exception); - } catch (Exception ex) { - assertEquals(ex, exception); - } - - verify(response); - verify(exception); - } -} diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/fallbacks/PropagateAbiquoExceptionOnNotFoundOr4xxTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/fallbacks/PropagateAbiquoExceptionOnNotFoundOr4xxTest.java deleted file mode 100644 index ea1fd96407..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/fallbacks/PropagateAbiquoExceptionOnNotFoundOr4xxTest.java +++ /dev/null @@ -1,73 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.fallbacks; - -import static org.testng.Assert.assertEquals; - -import javax.ws.rs.core.Response.Status; - -import org.jclouds.abiquo.AbiquoFallbacks.PropagateAbiquoExceptionOnNotFoundOr4xx; -import org.jclouds.abiquo.domain.exception.AbiquoException; -import org.jclouds.rest.ResourceNotFoundException; -import org.testng.annotations.Test; - -import com.abiquo.model.transport.error.ErrorsDto; - -/** - * Unit tests for the {@link PropagateAbiquoExceptionOnNotFoundOr4xx} function. - * - * @author Ignasi Barrera - */ -@Test(groups = "unit", testName = "PropagateAbiquoExceptionOnNotFoundOr4xxTest") -public class PropagateAbiquoExceptionOnNotFoundOr4xxTest { - public void testOriginalExceptionIfNotResourceNotFound() { - PropagateAbiquoExceptionOnNotFoundOr4xx function = new PropagateAbiquoExceptionOnNotFoundOr4xx(); - RuntimeException exception = new RuntimeException(); - - try { - function.create(exception); - } catch (Exception ex) { - assertEquals(ex, exception); - } - } - - public void testOriginalExceptionIfNotAbiquoException() { - PropagateAbiquoExceptionOnNotFoundOr4xx function = new PropagateAbiquoExceptionOnNotFoundOr4xx(); - ResourceNotFoundException exception = new ResourceNotFoundException(); - - try { - function.create(exception); - } catch (Exception ex) { - assertEquals(ex, exception); - } - } - - public void testAbiquoException() { - PropagateAbiquoExceptionOnNotFoundOr4xx function = new PropagateAbiquoExceptionOnNotFoundOr4xx(); - AbiquoException abiquoException = new AbiquoException(Status.NOT_FOUND, new ErrorsDto()); - ResourceNotFoundException exception = new ResourceNotFoundException(abiquoException); - - try { - function.create(exception); - } catch (Exception ex) { - assertEquals(ex, abiquoException); - } - } -} 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 deleted file mode 100644 index b76593917b..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/features/AdminAsyncApiTest.java +++ /dev/null @@ -1,181 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.features; - -import static org.jclouds.abiquo.domain.DomainUtils.withHeader; -import static org.jclouds.reflect.Reflection2.method; - -import java.io.IOException; - -import org.jclouds.Fallbacks.NullOnNotFoundOr404; -import org.jclouds.abiquo.domain.AdminResources; -import org.jclouds.abiquo.domain.EnterpriseResources; -import org.jclouds.http.functions.ParseXMLWithJAXB; -import org.jclouds.http.functions.ReleasePayloadAndReturn; -import org.jclouds.reflect.Invocation; -import org.jclouds.rest.internal.GeneratedHttpRequest; -import org.testng.annotations.Test; - -import com.abiquo.server.core.enterprise.PrivilegesDto; -import com.abiquo.server.core.enterprise.RoleDto; -import com.abiquo.server.core.enterprise.RolesDto; -import com.abiquo.server.core.enterprise.UserDto; -import com.google.common.collect.ImmutableList; -import com.google.common.reflect.Invokable; - -/** - * Tests annotation parsing of {@code AdminAsyncApi} - * - * @author Ignasi Barrera - * @author Francesc Montserrat - */ -@Test(groups = "unit", testName = "AdminAsyncApiTest") -public class AdminAsyncApiTest extends BaseAbiquoAsyncApiTest { - /*********************** Role ***********************/ - - public void testListRoles() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(AdminAsyncApi.class, "listRoles"); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, ImmutableList.of())); - - 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); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testGetRoleFromUser() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(AdminAsyncApi.class, "getRole", UserDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, NullOnNotFoundOr404.class); - - checkFilters(request); - } - - public void testCreateRole() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(AdminAsyncApi.class, "createRole", RoleDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(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, - RoleDto.BASE_MEDIA_TYPE, false); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testDeleteRole() throws SecurityException, NoSuchMethodException { - Invokable method = method(AdminAsyncApi.class, "deleteRole", RoleDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(AdminResources.rolePut()))); - - 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); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testUpdateRole() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(AdminAsyncApi.class, "updateRole", RoleDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testGetRoleById() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(AdminAsyncApi.class, "getRole", Integer.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, ImmutableList. of(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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, NullOnNotFoundOr404.class); - - checkFilters(request); - } - - public void testListPrivilegesByRoles() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(AdminAsyncApi.class, "listPrivileges", RoleDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - /*********************** Current User **********************/ - - public void testGetCurrentUser() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(AdminAsyncApi.class, "getCurrentUser"); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, ImmutableList. of(1))); - - 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); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } -} 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 deleted file mode 100644 index 561418f602..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/features/BaseAbiquoAsyncApiTest.java +++ /dev/null @@ -1,92 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.features; - -import static org.jclouds.Constants.PROPERTY_PRETTY_PRINT_PAYLOADS; -import static org.testng.Assert.assertEquals; - -import java.io.IOException; -import java.util.Properties; - -import org.jclouds.abiquo.AbiquoApiMetadata; -import org.jclouds.abiquo.config.AbiquoRestClientModule; -import org.jclouds.abiquo.http.filters.AbiquoAuthentication; -import org.jclouds.abiquo.http.filters.AppendApiVersionToMediaType; -import org.jclouds.http.HttpRequest; -import org.jclouds.providers.AnonymousProviderMetadata; -import org.jclouds.providers.ProviderMetadata; -import org.jclouds.rest.internal.BaseAsyncClientTest; -import org.jclouds.xml.XMLParser; -import org.testng.annotations.BeforeClass; - -import com.abiquo.model.transport.SingleResourceTransportDto; -import com.google.inject.Module; - -/** - * Tests annotation parsing of {@code AbiquoAsyncApi}. - * - * @author Ignasi Barrera - */ -public abstract class BaseAbiquoAsyncApiTest extends BaseAsyncClientTest { - private XMLParser xml; - - @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 Module createModule() { - return new AbiquoRestClientModule(); - } - - @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; - } - - 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); - } - -} diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/features/BaseAbiquoRestApiExpectTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/features/BaseAbiquoRestApiExpectTest.java deleted file mode 100644 index c76ff4532b..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/features/BaseAbiquoRestApiExpectTest.java +++ /dev/null @@ -1,64 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.features; - -import java.util.Properties; - -import javax.ws.rs.core.MediaType; - -import org.jclouds.abiquo.AbiquoApi; -import org.jclouds.abiquo.AbiquoApiMetadata; -import org.jclouds.apis.ApiMetadata; -import org.jclouds.http.HttpRequest; -import org.jclouds.http.HttpResponse; -import org.jclouds.rest.internal.BaseRestApiExpectTest; - -import com.google.common.base.Function; -import com.google.inject.Module; - -/** - * Base class for Abiquo expect tests. - * - * @author Ignasi Barrera - */ -public abstract class BaseAbiquoRestApiExpectTest extends BaseRestApiExpectTest { - protected final String basicAuth = "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA=="; - - public BaseAbiquoRestApiExpectTest() { - provider = "abiquo"; - } - - @Override - protected ApiMetadata createApiMetadata() { - return new AbiquoApiMetadata(); - } - - @Override - public S createClient(final Function fn, final Module module, final Properties props) { - return clientFrom(createInjector(fn, module, props).getInstance(AbiquoApi.class)); - } - - protected abstract S clientFrom(AbiquoApi api); - - protected String normalize(final String mediatType) { - return MediaType.valueOf(mediatType).toString(); - } - -} 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 deleted file mode 100644 index 8a474362c5..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/features/CloudAsyncApiTest.java +++ /dev/null @@ -1,1321 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.features; - -import static org.jclouds.abiquo.domain.DomainUtils.withHeader; -import static org.jclouds.reflect.Reflection2.method; - -import java.io.IOException; - -import javax.ws.rs.core.MediaType; - -import org.jclouds.Fallbacks.NullOnNotFoundOr404; -import org.jclouds.abiquo.domain.CloudResources; -import org.jclouds.abiquo.domain.EnterpriseResources; -import org.jclouds.abiquo.domain.InfrastructureResources; -import org.jclouds.abiquo.domain.NetworkResources; -import org.jclouds.abiquo.domain.cloud.options.VirtualDatacenterOptions; -import org.jclouds.abiquo.domain.cloud.options.VirtualMachineOptions; -import org.jclouds.abiquo.domain.cloud.options.VirtualMachineTemplateOptions; -import org.jclouds.abiquo.domain.cloud.options.VolumeOptions; -import org.jclouds.abiquo.domain.network.options.IpOptions; -import org.jclouds.abiquo.domain.options.search.reference.OrderBy; -import org.jclouds.abiquo.fallbacks.MovedVolume; -import org.jclouds.abiquo.functions.ReturnTaskReferenceOrNull; -import org.jclouds.http.functions.ParseXMLWithJAXB; -import org.jclouds.http.functions.ReleasePayloadAndReturn; -import org.jclouds.http.functions.ReturnStringIf2xx; -import org.jclouds.reflect.Invocation; -import org.jclouds.rest.internal.GeneratedHttpRequest; -import org.testng.annotations.Test; - -import com.abiquo.model.enumerator.HypervisorType; -import com.abiquo.model.rest.RESTLink; -import com.abiquo.model.transport.AcceptedRequestDto; -import com.abiquo.model.transport.LinksDto; -import com.abiquo.server.core.appslibrary.VirtualMachineTemplateDto; -import com.abiquo.server.core.appslibrary.VirtualMachineTemplatesDto; -import com.abiquo.server.core.cloud.VirtualApplianceDto; -import com.abiquo.server.core.cloud.VirtualApplianceStateDto; -import com.abiquo.server.core.cloud.VirtualAppliancesDto; -import com.abiquo.server.core.cloud.VirtualDatacenterDto; -import com.abiquo.server.core.cloud.VirtualDatacentersDto; -import com.abiquo.server.core.cloud.VirtualMachineDto; -import com.abiquo.server.core.cloud.VirtualMachineStateDto; -import com.abiquo.server.core.cloud.VirtualMachineTaskDto; -import com.abiquo.server.core.cloud.VirtualMachineWithNodeExtendedDto; -import com.abiquo.server.core.cloud.VirtualMachinesWithNodeExtendedDto; -import com.abiquo.server.core.enterprise.EnterpriseDto; -import com.abiquo.server.core.infrastructure.DatacenterDto; -import com.abiquo.server.core.infrastructure.network.PrivateIpDto; -import com.abiquo.server.core.infrastructure.network.PrivateIpsDto; -import com.abiquo.server.core.infrastructure.network.PublicIpDto; -import com.abiquo.server.core.infrastructure.network.PublicIpsDto; -import com.abiquo.server.core.infrastructure.network.VLANNetworkDto; -import com.abiquo.server.core.infrastructure.network.VLANNetworksDto; -import com.abiquo.server.core.infrastructure.network.VMNetworkConfigurationsDto; -import com.abiquo.server.core.infrastructure.storage.DiskManagementDto; -import com.abiquo.server.core.infrastructure.storage.DisksManagementDto; -import com.abiquo.server.core.infrastructure.storage.MovedVolumeDto; -import com.abiquo.server.core.infrastructure.storage.TierDto; -import com.abiquo.server.core.infrastructure.storage.TiersDto; -import com.abiquo.server.core.infrastructure.storage.VolumeManagementDto; -import com.abiquo.server.core.infrastructure.storage.VolumesManagementDto; -import com.google.common.collect.ImmutableList; -import com.google.common.reflect.Invokable; - -/** - * Tests annotation parsing of {@code CloudAsyncApi} - * - * @author Ignasi Barrera - * @author Francesc Montserrat - */ -@Test(groups = "unit", testName = "CloudAsyncApiTest") -public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest { - /*********************** Virtual Datacenter ***********************/ - - public void testListVirtualDatacentersParams() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(CloudAsyncApi.class, "listVirtualDatacenters", VirtualDatacenterOptions.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(VirtualDatacenterOptions.builder().datacenterId(1).enterpriseId(1).build()))); - - 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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testListVirtualDatacentersNoParams() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(CloudAsyncApi.class, "listVirtualDatacenters", VirtualDatacenterOptions.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testCreateVirtualDatacenter() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(CloudAsyncApi.class, "createVirtualDatacenter", VirtualDatacenterDto.class, - DatacenterDto.class, EnterpriseDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, ImmutableList. of( - CloudResources.virtualDatacenterPost(), InfrastructureResources.datacenterPut(), - EnterpriseResources.enterprisePut()))); - - assertRequestLineEquals(request, - "POST http://localhost/api/cloud/virtualdatacenters?datacenter=1&enterprise=1 HTTP/1.1"); - 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); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testGetVirtualDatacenter() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(CloudAsyncApi.class, "getVirtualDatacenter", Integer.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, ImmutableList. of(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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, NullOnNotFoundOr404.class); - - checkFilters(request); - } - - public void testUpdateVirtualDatacenter() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(CloudAsyncApi.class, "updateVirtualDatacenter", VirtualDatacenterDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(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()), - VirtualDatacenterDto.class, VirtualDatacenterDto.BASE_MEDIA_TYPE, false); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testDeleteVirtualDatacenter() throws SecurityException, NoSuchMethodException { - Invokable method = method(CloudAsyncApi.class, "deleteVirtualDatacenter", VirtualDatacenterDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(CloudResources.virtualDatacenterPut()))); - - 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); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - /*********************** Ips ***********************/ - - public void testListAvailablePublicIpsWithOptions() throws SecurityException, NoSuchMethodException, IOException { - IpOptions options = IpOptions.builder().limit(5).build(); - Invokable method = method(CloudAsyncApi.class, "listAvailablePublicIps", VirtualDatacenterDto.class, - IpOptions.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(CloudResources.virtualDatacenterPut(), options))); - - 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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testListPurchasedPublicIpsWithOptions() throws SecurityException, NoSuchMethodException, IOException { - IpOptions options = IpOptions.builder().limit(5).build(); - Invokable method = method(CloudAsyncApi.class, "listPurchasedPublicIps", VirtualDatacenterDto.class, - IpOptions.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(CloudResources.virtualDatacenterPut(), options))); - - 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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testPurchasePublicIp() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(CloudAsyncApi.class, "purchasePublicIp", PublicIpDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(NetworkResources.publicIpToPurchase()))); - - 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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testReleasePublicIp() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(CloudAsyncApi.class, "releasePublicIp", PublicIpDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(NetworkResources.publicIpToRelease()))); - - 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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - /*********************** Available templates ***********************/ - - public void testListAvailableTemplates() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(CloudAsyncApi.class, "listAvailableTemplates", VirtualDatacenterDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testListAvailableTemplatesWithOptions() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(CloudAsyncApi.class, "listAvailableTemplates", VirtualDatacenterDto.class, - VirtualMachineTemplateOptions.class); - GeneratedHttpRequest request = processor.apply(Invocation.create( - method, - ImmutableList. of(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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - /*********************** Storage Tiers ***********************/ - - public void testListStorageTiers() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(CloudAsyncApi.class, "listStorageTiers", VirtualDatacenterDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testGetStorageTier() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(CloudAsyncApi.class, "getStorageTier", VirtualDatacenterDto.class, Integer.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, NullOnNotFoundOr404.class); - - checkFilters(request); - } - - public void testGetDefaultNetwork() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(CloudAsyncApi.class, "getDefaultNetwork", VirtualDatacenterDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testSetDefaultNetworkInternal() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(CloudAsyncApi.class, "setDefaultNetwork", VirtualDatacenterDto.class, - VLANNetworkDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(CloudResources.virtualDatacenterPut(), NetworkResources.privateNetworkPut()))); - - RESTLink netLink = NetworkResources.privateNetworkPut().getEditLink(); - - 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); - - assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testSetDefaultNetworkExternal() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(CloudAsyncApi.class, "setDefaultNetwork", VirtualDatacenterDto.class, - VLANNetworkDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(CloudResources.virtualDatacenterPut(), NetworkResources.externalNetworkPut()))); - - RESTLink netLink = NetworkResources.externalNetworkPut().getEditLink(); - - 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); - - assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - /*********************** Private Network ***********************/ - - public void testListPrivateNetworks() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(CloudAsyncApi.class, "listPrivateNetworks", VirtualDatacenterDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testGetPrivateNetwork() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(CloudAsyncApi.class, "getPrivateNetwork", VirtualDatacenterDto.class, - Integer.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, NullOnNotFoundOr404.class); - - checkFilters(request); - } - - public void testCreatePrivateNetwork() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(CloudAsyncApi.class, "createPrivateNetwork", VirtualDatacenterDto.class, - VLANNetworkDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testUpdatePrivateNetwork() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(CloudAsyncApi.class, "updatePrivateNetwork", VLANNetworkDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testDeletePrivateNetwork() throws SecurityException, NoSuchMethodException { - Invokable method = method(CloudAsyncApi.class, "deletePrivateNetwork", VLANNetworkDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(NetworkResources.privateNetworkPut()))); - - assertRequestLineEquals(request, - "DELETE http://localhost/api/cloud/virtualdatacenters/1/privatenetworks/1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, ""); - assertPayloadEquals(request, null, null, false); - - assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - /*********************** Private Network IPs ***********************/ - - public void testListPrivateNetworkIps() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(CloudAsyncApi.class, "listPrivateNetworkIps", VLANNetworkDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(NetworkResources.privateNetworkPut()))); - - 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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testListPrivateNetworkIpsWithOptions() throws SecurityException, NoSuchMethodException, IOException { - IpOptions options = IpOptions.builder().startWith(10).build(); - Invokable method = method(CloudAsyncApi.class, "listPrivateNetworkIps", VLANNetworkDto.class, - IpOptions.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(NetworkResources.privateNetworkPut(), options))); - - 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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testGetPrivateNetworkIp() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(CloudAsyncApi.class, "getPrivateNetworkIp", VLANNetworkDto.class, Integer.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(NetworkResources.privateNetworkPut(), 1))); - - 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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - /*********************** Virtual Appliance ***********************/ - - public void testListVirtualAppliances() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(CloudAsyncApi.class, "listVirtualAppliances", VirtualDatacenterDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testGetVirtualAppliance() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(CloudAsyncApi.class, "getVirtualAppliance", VirtualDatacenterDto.class, - Integer.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(CloudResources.virtualDatacenterPut(), 1))); - - 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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, NullOnNotFoundOr404.class); - - checkFilters(request); - } - - public void testGetVirtualApplianceState() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(CloudAsyncApi.class, "getVirtualApplianceState", VirtualApplianceDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(CloudResources.virtualAppliancePut()))); - - 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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testCreateVirtualAppliance() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(CloudAsyncApi.class, "createVirtualAppliance", VirtualDatacenterDto.class, - VirtualApplianceDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(CloudResources.virtualDatacenterPut(), CloudResources.virtualAppliancePost()))); - - 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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testUpdateVirtualAppliance() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(CloudAsyncApi.class, "updateVirtualAppliance", VirtualApplianceDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(CloudResources.virtualAppliancePut()))); - - 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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testDeleteVirtualAppliance() throws SecurityException, NoSuchMethodException { - Invokable method = method(CloudAsyncApi.class, "deleteVirtualAppliance", VirtualApplianceDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(CloudResources.virtualAppliancePut()))); - - assertRequestLineEquals(request, - "DELETE http://localhost/api/cloud/virtualdatacenters/1/virtualappliances/1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, ""); - assertPayloadEquals(request, null, null, false); - - assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testDeployVirtualAppliance() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(CloudAsyncApi.class, "deployVirtualAppliance", VirtualApplianceDto.class, - VirtualMachineTaskDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(CloudResources.virtualAppliancePut(), CloudResources.deployOptions()))); - - 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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testUndeployVirtualAppliance() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(CloudAsyncApi.class, "undeployVirtualAppliance", VirtualApplianceDto.class, - VirtualMachineTaskDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(CloudResources.virtualAppliancePut(), CloudResources.undeployOptions()))); - - 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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testGetVirtualAppliancePrice() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(CloudAsyncApi.class, "getVirtualAppliancePrice", VirtualApplianceDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(CloudResources.virtualAppliancePut()))); - - 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); - - assertResponseParserClassEquals(method, request, ReturnStringIf2xx.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - /*********************** Virtual Machine ***********************/ - - public void testListVirtualMachines() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(CloudAsyncApi.class, "listVirtualMachines", VirtualApplianceDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(CloudResources.virtualAppliancePut()))); - - 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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testListVirtualMachinesWithOptions() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(CloudAsyncApi.class, "listVirtualMachines", VirtualApplianceDto.class, - VirtualMachineOptions.class); - GeneratedHttpRequest request = processor.apply(Invocation.create( - method, - ImmutableList. of(CloudResources.virtualAppliancePut(), VirtualMachineOptions.builder() - .disablePagination().build()))); - - 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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testGetVirtualMachine() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(CloudAsyncApi.class, "getVirtualMachine", VirtualApplianceDto.class, - Integer.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(CloudResources.virtualAppliancePut(), 1))); - - 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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, NullOnNotFoundOr404.class); - - checkFilters(request); - } - - public void testCreateVirtualMachine() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(CloudAsyncApi.class, "createVirtualMachine", VirtualApplianceDto.class, - VirtualMachineWithNodeExtendedDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(CloudResources.virtualAppliancePut(), CloudResources.virtualMachinePost()))); - - 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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testUpdateVirtualMachine() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(CloudAsyncApi.class, "updateVirtualMachine", - VirtualMachineWithNodeExtendedDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(CloudResources.virtualMachinePut()))); - - 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); - - assertResponseParserClassEquals(method, request, ReturnTaskReferenceOrNull.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testUpdateVirtualMachineWithOptions() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(CloudAsyncApi.class, "updateVirtualMachine", - VirtualMachineWithNodeExtendedDto.class, VirtualMachineOptions.class); - GeneratedHttpRequest request = processor.apply(Invocation.create( - method, - ImmutableList. of(CloudResources.virtualMachinePut(), VirtualMachineOptions.builder().force(true) - .build()))); - - 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); - - assertResponseParserClassEquals(method, request, ReturnTaskReferenceOrNull.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testChangeVirtualMachineState() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(CloudAsyncApi.class, "changeVirtualMachineState", VirtualMachineDto.class, - VirtualMachineStateDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(CloudResources.virtualMachinePut(), CloudResources.virtualMachineState()))); - - 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()), - VirtualMachineStateDto.class, VirtualMachineStateDto.BASE_MEDIA_TYPE, false); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testDeleteVirtualMachine() throws SecurityException, NoSuchMethodException { - Invokable method = method(CloudAsyncApi.class, "deleteVirtualMachine", VirtualMachineDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(CloudResources.virtualMachinePut()))); - - assertRequestLineEquals(request, - "DELETE http://localhost/api/cloud/virtualdatacenters/1/virtualappliances/1/virtualmachines/1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, ""); - assertPayloadEquals(request, null, null, false); - - assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testGetVirtualMachineState() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(CloudAsyncApi.class, "getVirtualMachineState", VirtualMachineDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(CloudResources.virtualMachinePut()))); - - 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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testDeployVirtualMachine() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(CloudAsyncApi.class, "deployVirtualMachine", VirtualMachineDto.class, - VirtualMachineTaskDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(CloudResources.virtualMachinePut(), CloudResources.deployOptions()))); - - 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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testUndeployVirtualMachine() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(CloudAsyncApi.class, "undeployVirtualMachine", VirtualMachineDto.class, - VirtualMachineTaskDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(CloudResources.virtualMachinePut(), CloudResources.undeployOptions()))); - - 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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testRebootVirtualMachine() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(CloudAsyncApi.class, "rebootVirtualMachine", VirtualMachineDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(CloudResources.virtualMachinePut()))); - - 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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testListNetworkConfigurations() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(CloudAsyncApi.class, "listNetworkConfigurations", VirtualMachineDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(CloudResources.virtualMachinePut()))); - - 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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testSetGatewayNetwork() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(CloudAsyncApi.class, "setGatewayNetwork", VirtualMachineDto.class, - VLANNetworkDto.class); - - VirtualMachineDto vm = CloudResources.virtualMachinePut(); - VLANNetworkDto network = NetworkResources.privateNetworkPut(); - - GeneratedHttpRequest request = processor.apply(Invocation.create(method, ImmutableList. of(vm, network))); - - String configLink = vm.searchLink("configurations").getHref() + "/" + network.getId(); - - 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); - - assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - /*********************** Virtual Machine Template ***********************/ - - public void testGetVirtualMachineTemplate() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(CloudAsyncApi.class, "getVirtualMachineTemplate", VirtualMachineDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(CloudResources.virtualMachinePut()))); - - 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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testListAttachedVolumes() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(CloudAsyncApi.class, "listAttachedVolumes", VirtualMachineDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(CloudResources.virtualMachinePut()))); - - 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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testDetachAllVolumes() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(CloudAsyncApi.class, "detachAllVolumes", VirtualMachineDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(CloudResources.virtualMachinePut()))); - - 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); - - assertResponseParserClassEquals(method, request, ReturnTaskReferenceOrNull.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testReplaceVolumes() throws SecurityException, NoSuchMethodException, IOException { - VolumeManagementDto first = CloudResources.volumePut(); - VolumeManagementDto second = CloudResources.volumePut(); - second.getEditLink().setHref(second.getEditLink().getHref() + "second"); - - Invokable method = method(CloudAsyncApi.class, "replaceVolumes", VirtualMachineDto.class, - VirtualMachineOptions.class, VolumeManagementDto[].class); - GeneratedHttpRequest request = processor.apply(Invocation.create( - method, - ImmutableList. of(CloudResources.virtualMachinePut(), VirtualMachineOptions.builder().force(true) - .build(), new VolumeManagementDto[] { first, second }))); - - 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); - - assertResponseParserClassEquals(method, request, ReturnTaskReferenceOrNull.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testListAttachedHardDisks() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(CloudAsyncApi.class, "listAttachedHardDisks", VirtualMachineDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(CloudResources.virtualMachinePut()))); - - 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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testDetachAllHardDisks() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(CloudAsyncApi.class, "detachAllHardDisks", VirtualMachineDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(CloudResources.virtualMachinePut()))); - - 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); - - assertResponseParserClassEquals(method, request, ReturnTaskReferenceOrNull.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testReplaceHardDisks() throws SecurityException, NoSuchMethodException, IOException { - DiskManagementDto first = CloudResources.hardDiskPut(); - DiskManagementDto second = CloudResources.hardDiskPut(); - second.getEditLink().setHref(second.getEditLink().getHref() + "second"); - - Invokable method = method(CloudAsyncApi.class, "replaceHardDisks", VirtualMachineDto.class, - DiskManagementDto[].class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(CloudResources.virtualMachinePut(), new DiskManagementDto[] { first, second }))); - - 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); - - assertResponseParserClassEquals(method, request, ReturnTaskReferenceOrNull.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - /*********************** Hard disks ***********************/ - - public void testListHardDisks() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(CloudAsyncApi.class, "listHardDisks", VirtualDatacenterDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testGetHardDisk() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(CloudAsyncApi.class, "getHardDisk", VirtualDatacenterDto.class, Integer.class); - ; - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, NullOnNotFoundOr404.class); - - checkFilters(request); - } - - public void testCreateHardDisk() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(CloudAsyncApi.class, "createHardDisk", VirtualDatacenterDto.class, - DiskManagementDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testDeleteHardDisk() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(CloudAsyncApi.class, "deleteHardDisk", DiskManagementDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(CloudResources.hardDiskPut()))); - - 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); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - /*********************** Volumes ***********************/ - - public void testListVolumes() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(CloudAsyncApi.class, "listVolumes", VirtualDatacenterDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testListVolumesWithOptions() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(CloudAsyncApi.class, "listVolumes", VirtualDatacenterDto.class, - VolumeOptions.class); - GeneratedHttpRequest request = processor.apply(Invocation.create( - method, - ImmutableList. of(CloudResources.virtualDatacenterPut(), VolumeOptions.builder() - .onlyAvailable(true).build()))); - - 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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testListVolumesWithFilterOptions() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(CloudAsyncApi.class, "listVolumes", VirtualDatacenterDto.class, - VolumeOptions.class); - - GeneratedHttpRequest request = processor.apply(Invocation.create( - method, - ImmutableList. of(CloudResources.virtualDatacenterPut(), VolumeOptions.builder().has("vol") - .orderBy(OrderBy.NAME).ascendant(true).build()))); - - 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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testGetVolume() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(CloudAsyncApi.class, "getVolume", VirtualDatacenterDto.class, Integer.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, NullOnNotFoundOr404.class); - - checkFilters(request); - } - - public void testCreateVolume() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(CloudAsyncApi.class, "createVolume", VirtualDatacenterDto.class, - VolumeManagementDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testUpdateVolume() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(CloudAsyncApi.class, "updateVolume", VolumeManagementDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(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); - - assertResponseParserClassEquals(method, request, ReturnTaskReferenceOrNull.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testDeleteVolume() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(CloudAsyncApi.class, "deleteVolume", VolumeManagementDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(CloudResources.volumePut()))); - - 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); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testMoveVolume() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(CloudAsyncApi.class, "moveVolume", VolumeManagementDto.class, - VirtualDatacenterDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(CloudResources.volumePut(), CloudResources.virtualDatacenterPut()))); - - 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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, MovedVolume.class); - - checkFilters(request); - } -} 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 deleted file mode 100644 index a26e52b230..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/features/ConfigAsyncApiTest.java +++ /dev/null @@ -1,285 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.features; - -import static org.jclouds.abiquo.domain.DomainUtils.withHeader; -import static org.jclouds.reflect.Reflection2.method; - -import java.io.IOException; - -import org.jclouds.Fallbacks.NullOnNotFoundOr404; -import org.jclouds.abiquo.domain.ConfigResources; -import org.jclouds.abiquo.domain.config.options.LicenseOptions; -import org.jclouds.abiquo.domain.config.options.PropertyOptions; -import org.jclouds.http.functions.ParseXMLWithJAXB; -import org.jclouds.http.functions.ReleasePayloadAndReturn; -import org.jclouds.reflect.Invocation; -import org.jclouds.rest.internal.GeneratedHttpRequest; -import org.testng.annotations.Test; - -import com.abiquo.server.core.appslibrary.CategoriesDto; -import com.abiquo.server.core.appslibrary.CategoryDto; -import com.abiquo.server.core.config.LicenseDto; -import com.abiquo.server.core.config.LicensesDto; -import com.abiquo.server.core.config.SystemPropertiesDto; -import com.abiquo.server.core.config.SystemPropertyDto; -import com.abiquo.server.core.enterprise.PrivilegeDto; -import com.abiquo.server.core.enterprise.PrivilegesDto; -import com.google.common.collect.ImmutableList; -import com.google.common.reflect.Invokable; - -/** - * Tests annotation parsing of {@code AdminAsyncApi}. - * - * @author Ignasi Barrera - * @author Francesc Montserrat - */ -@Test(groups = "unit", testName = "ConfigAsyncApiTest") -public class ConfigAsyncApiTest extends BaseAbiquoAsyncApiTest { - /*********************** License ***********************/ - - public void testListLicenses() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(ConfigAsyncApi.class, "listLicenses"); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, ImmutableList.of())); - - 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); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testListLicenseWithOptions() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(ConfigAsyncApi.class, "listLicenses", LicenseOptions.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testAddLicense() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(ConfigAsyncApi.class, "addLicense", LicenseDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testRemoveLicense() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(ConfigAsyncApi.class, "removeLicense", LicenseDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(ConfigResources.licensePut()))); - - 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); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - /*********************** Privilege ***********************/ - - public void testListPrivileges() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(ConfigAsyncApi.class, "listPrivileges"); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, ImmutableList.of())); - - 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); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testGetPrivilege() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(ConfigAsyncApi.class, "getPrivilege", Integer.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, ImmutableList. of(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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, NullOnNotFoundOr404.class); - - checkFilters(request); - } - - /*********************** System Properties ***********************/ - - public void testListSystemProperties() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(ConfigAsyncApi.class, "listSystemProperties"); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, ImmutableList.of())); - - 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); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testListSystemPropertiesWithOptions() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(ConfigAsyncApi.class, "listSystemProperties", PropertyOptions.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testUpdateSystemProperty() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(ConfigAsyncApi.class, "updateSystemProperty", SystemPropertyDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - /*********************** Category ***********************/ - - public void testListCategories() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(ConfigAsyncApi.class, "listCategories"); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, ImmutableList.of())); - - 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); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testGetCategory() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(ConfigAsyncApi.class, "getCategory", Integer.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, ImmutableList. of(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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, NullOnNotFoundOr404.class); - - checkFilters(request); - } - - public void testCreateCategory() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(ConfigAsyncApi.class, "createCategory", CategoryDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testUpdateCategory() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(ConfigAsyncApi.class, "updateCategory", CategoryDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testDeleteCategory() throws SecurityException, NoSuchMethodException { - Invokable method = method(ConfigAsyncApi.class, "deleteCategory", CategoryDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(ConfigResources.categoryPut()))); - - 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); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } -} 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 deleted file mode 100644 index 8608876473..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/features/EnterpriseAsyncApiTest.java +++ /dev/null @@ -1,683 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.features; - -import static org.jclouds.abiquo.domain.DomainUtils.withHeader; -import static org.jclouds.reflect.Reflection2.method; - -import java.io.IOException; - -import org.jclouds.Fallbacks.NullOnNotFoundOr404; -import org.jclouds.abiquo.domain.EnterpriseResources; -import org.jclouds.abiquo.domain.InfrastructureResources; -import org.jclouds.abiquo.domain.enterprise.options.EnterpriseOptions; -import org.jclouds.abiquo.domain.options.search.reference.OrderBy; -import org.jclouds.fallbacks.MapHttp4xxCodesToExceptions; -import org.jclouds.http.functions.ParseXMLWithJAXB; -import org.jclouds.http.functions.ReleasePayloadAndReturn; -import org.jclouds.reflect.Invocation; -import org.jclouds.rest.internal.GeneratedHttpRequest; -import org.testng.annotations.Test; - -import com.abiquo.am.model.TemplatesStateDto; -import com.abiquo.server.core.appslibrary.DatacenterRepositoryDto; -import com.abiquo.server.core.appslibrary.TemplateDefinitionListDto; -import com.abiquo.server.core.appslibrary.TemplateDefinitionListsDto; -import com.abiquo.server.core.cloud.VirtualAppliancesDto; -import com.abiquo.server.core.cloud.VirtualDatacentersDto; -import com.abiquo.server.core.cloud.VirtualMachinesWithNodeExtendedDto; -import com.abiquo.server.core.enterprise.DatacenterLimitsDto; -import com.abiquo.server.core.enterprise.DatacentersLimitsDto; -import com.abiquo.server.core.enterprise.EnterpriseDto; -import com.abiquo.server.core.enterprise.EnterprisePropertiesDto; -import com.abiquo.server.core.enterprise.EnterprisesDto; -import com.abiquo.server.core.enterprise.UserDto; -import com.abiquo.server.core.enterprise.UsersDto; -import com.abiquo.server.core.infrastructure.DatacenterDto; -import com.abiquo.server.core.infrastructure.DatacentersDto; -import com.abiquo.server.core.infrastructure.MachinesDto; -import com.abiquo.server.core.infrastructure.network.VLANNetworksDto; -import com.google.common.collect.ImmutableList; -import com.google.common.reflect.Invokable; - -/** - * Tests annotation parsing of {@code EnterpriseAsyncApi} - * - * @author Ignasi Barrera - * @author Francesc Montserrat - */ -@Test(groups = "unit", testName = "EnterpriseAsyncApiTest") -public class EnterpriseAsyncApiTest extends BaseAbiquoAsyncApiTest { - /*********************** Enterprise ********************** */ - - public void testListEnterprises() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(EnterpriseAsyncApi.class, "listEnterprises"); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, ImmutableList.of())); - - 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); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testListEnterprisesWithOptions() throws SecurityException, NoSuchMethodException, IOException { - EnterpriseOptions options = EnterpriseOptions.builder().has("abi").orderBy(OrderBy.NAME).ascendant(true).build(); - - Invokable method = method(EnterpriseAsyncApi.class, "listEnterprises", EnterpriseOptions.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, ImmutableList. of(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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testListEnterprisesByDatacenter() throws SecurityException, NoSuchMethodException, IOException { - EnterpriseOptions options = EnterpriseOptions.builder().startWith(0).limit(25).network(true).build(); - - Invokable method = method(EnterpriseAsyncApi.class, "listEnterprises", DatacenterDto.class, - EnterpriseOptions.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(InfrastructureResources.datacenterPut(), options))); - - 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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testCreateEnterprise() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(EnterpriseAsyncApi.class, "createEnterprise", EnterpriseDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testGetEnterprise() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(EnterpriseAsyncApi.class, "getEnterprise", Integer.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, ImmutableList. of(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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, NullOnNotFoundOr404.class); - - checkFilters(request); - } - - public void testUpdateEnterprise() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(EnterpriseAsyncApi.class, "updateEnterprise", EnterpriseDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testDeleteEnterprise() throws SecurityException, NoSuchMethodException { - Invokable method = method(EnterpriseAsyncApi.class, "deleteEnterprise", EnterpriseDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(EnterpriseResources.enterprisePut()))); - - 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); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testListAllowedDatacenters() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(EnterpriseAsyncApi.class, "listAllowedDatacenters", Integer.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, ImmutableList. of(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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testListVirtualDatacentersFromEnterprise() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(EnterpriseAsyncApi.class, "listVirtualDatacenters", EnterpriseDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(EnterpriseResources.enterprisePut()))); - - 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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - /*********************** Enterprise Properties ********************** */ - - public void testGetEnterpriseProperties() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(EnterpriseAsyncApi.class, "getEnterpriseProperties", EnterpriseDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, MapHttp4xxCodesToExceptions.class); - - checkFilters(request); - } - - public void testUpdateEnterpriseProperties() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(EnterpriseAsyncApi.class, "updateEnterpriseProperties", - EnterprisePropertiesDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(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()), - EnterprisePropertiesDto.class, EnterprisePropertiesDto.BASE_MEDIA_TYPE, false); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - /*********************** Enterprise Limits ********************** */ - - public void testCreateLimits() throws SecurityException, NoSuchMethodException, IOException { - EnterpriseDto enterprise = EnterpriseResources.enterprisePut(); - DatacenterDto datacenter = InfrastructureResources.datacenterPut(); - DatacenterLimitsDto limits = EnterpriseResources.datacenterLimitsPost(); - - Invokable method = method(EnterpriseAsyncApi.class, "createLimits", EnterpriseDto.class, - DatacenterDto.class, DatacenterLimitsDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(enterprise, datacenter, limits))); - - 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()), - DatacenterLimitsDto.class, DatacenterLimitsDto.BASE_MEDIA_TYPE, false); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testGetLimits() throws SecurityException, NoSuchMethodException, IOException { - EnterpriseDto enterprise = EnterpriseResources.enterprisePut(); - DatacenterDto datacenter = InfrastructureResources.datacenterPut(); - - Invokable method = method(EnterpriseAsyncApi.class, "getLimits", EnterpriseDto.class, DatacenterDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(enterprise, datacenter))); - - 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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, NullOnNotFoundOr404.class); - - checkFilters(request); - } - - public void testUpdateLimits() throws SecurityException, NoSuchMethodException, IOException { - EnterpriseDto enterprise = EnterpriseResources.enterprisePut(); - - Invokable method = method(EnterpriseAsyncApi.class, "updateLimits", DatacenterLimitsDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(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)), - DatacenterLimitsDto.class, DatacenterLimitsDto.BASE_MEDIA_TYPE, false); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testDeleteLimits() throws SecurityException, NoSuchMethodException { - EnterpriseDto enterprise = EnterpriseResources.enterprisePut(); - - Invokable method = method(EnterpriseAsyncApi.class, "deleteLimits", DatacenterLimitsDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(EnterpriseResources.datacenterLimitsPut(enterprise)))); - - 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); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testListLimitsEnterprise() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(EnterpriseAsyncApi.class, "listLimits", EnterpriseDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - /*********************** User ***********************/ - - public void testGetUser() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(EnterpriseAsyncApi.class, "getUser", EnterpriseDto.class, Integer.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, NullOnNotFoundOr404.class); - - checkFilters(request); - } - - public void testListUsers() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(EnterpriseAsyncApi.class, "listUsers", EnterpriseDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testCreateUser() throws SecurityException, NoSuchMethodException, IOException { - EnterpriseDto enterprise = EnterpriseResources.enterprisePut(); - UserDto user = EnterpriseResources.userPost(); - - Invokable method = method(EnterpriseAsyncApi.class, "createUser", EnterpriseDto.class, UserDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testUpdateUser() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(EnterpriseAsyncApi.class, "updateUser", UserDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testDeleteUser() throws SecurityException, NoSuchMethodException { - Invokable method = method(EnterpriseAsyncApi.class, "deleteUser", UserDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(EnterpriseResources.userPut()))); - - 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); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testListVirtualMachinesByUser() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(EnterpriseAsyncApi.class, "listVirtualMachines", UserDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(EnterpriseResources.userPut()))); - - 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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - /*********************** Datacenter Repository ********************** */ - - public void testGetDatacenterRepository() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(EnterpriseAsyncApi.class, "getDatacenterRepository", EnterpriseDto.class, - Integer.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, ImmutableList. of( - 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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, NullOnNotFoundOr404.class); - - checkFilters(request); - } - - public void testRefreshTemplateRepository() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(EnterpriseAsyncApi.class, "refreshTemplateRepository", Integer.class, - Integer.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, ImmutableList. of( - EnterpriseResources.enterprisePut().getId(), InfrastructureResources.datacenterPut().getId()))); - - assertRequestLineEquals(request, - "PUT http://localhost/api/admin/enterprises/1/datacenterrepositories/1/actions/refresh HTTP/1.1"); - assertNonPayloadHeadersEqual(request, ""); - assertPayloadEquals(request, null, null, false); - - assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - /*********************** External Network ********************** */ - - public void testListExternalNetworks() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(EnterpriseAsyncApi.class, "listExternalNetworks", EnterpriseDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - /*********************** Cloud ********************** */ - - public void testListVirtualMachines() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(EnterpriseAsyncApi.class, "listVirtualMachines", EnterpriseDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testListVirtualAppliances() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(EnterpriseAsyncApi.class, "listVirtualAppliances", EnterpriseDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - /*********************** Machine ********************** */ - - public void testListReservedMachines() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(EnterpriseAsyncApi.class, "listReservedMachines", EnterpriseDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - /*********************** Template definition list ***********************/ - - public void testListTemplateDefinitionLists() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(EnterpriseAsyncApi.class, "listTemplateDefinitionLists", EnterpriseDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(EnterpriseResources.enterprisePut()))); - - 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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testCreateTemplateDefinitionList() throws SecurityException, NoSuchMethodException, IOException { - EnterpriseDto enterprise = EnterpriseResources.enterprisePut(); - TemplateDefinitionListDto template = EnterpriseResources.templateListPost(); - - Invokable method = method(EnterpriseAsyncApi.class, "createTemplateDefinitionList", EnterpriseDto.class, - TemplateDefinitionListDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(enterprise, template))); - - 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()), - TemplateDefinitionListDto.class, TemplateDefinitionListDto.BASE_MEDIA_TYPE, false); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testUpdateTemplateDefinitionList() throws SecurityException, NoSuchMethodException, IOException { - TemplateDefinitionListDto template = EnterpriseResources.templateListPut(); - - Invokable method = method(EnterpriseAsyncApi.class, "updateTemplateDefinitionList", - TemplateDefinitionListDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, ImmutableList. of(template))); - - 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()), - TemplateDefinitionListDto.class, TemplateDefinitionListDto.BASE_MEDIA_TYPE, false); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testDeleteTemplateDefinitionList() throws SecurityException, NoSuchMethodException { - Invokable method = method(EnterpriseAsyncApi.class, "deleteTemplateDefinitionList", - TemplateDefinitionListDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(EnterpriseResources.templateListPut()))); - - assertRequestLineEquals(request, - "DELETE http://localhost/api/admin/enterprises/1/appslib/templateDefinitionLists/1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, ""); - assertPayloadEquals(request, null, null, false); - - assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testGetTemplateDefinitionList() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(EnterpriseAsyncApi.class, "getTemplateDefinitionList", EnterpriseDto.class, - Integer.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(EnterpriseResources.enterprisePut(), 1))); - - 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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, NullOnNotFoundOr404.class); - - checkFilters(request); - } - - public void testListTemplateListStatus() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(EnterpriseAsyncApi.class, "listTemplateListStatus", - TemplateDefinitionListDto.class, DatacenterDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(EnterpriseResources.templateListPut(), InfrastructureResources.datacenterPut()))); - - 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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } -} 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 deleted file mode 100644 index ed67486505..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/features/EventAsyncApiTest.java +++ /dev/null @@ -1,57 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.features; - -import static org.jclouds.reflect.Reflection2.method; - -import java.io.IOException; - -import org.jclouds.http.functions.ParseXMLWithJAXB; -import org.jclouds.reflect.Invocation; -import org.jclouds.rest.internal.GeneratedHttpRequest; -import org.testng.annotations.Test; - -import com.abiquo.server.core.event.EventsDto; -import com.google.common.collect.ImmutableList; -import com.google.common.reflect.Invokable; - -/** - * Tests annotation parsing of {@code EventAsyncApi} - * - * @author Ignasi Barrera - * @author Vivien Mahé - */ -@Test(groups = "unit", testName = "EventAsyncApiTest") -public class EventAsyncApiTest extends BaseAbiquoAsyncApiTest { - public void testListEvents() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(EventAsyncApi.class, "listEvents"); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, ImmutableList.of())); - - 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); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } -} diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/features/InfrastructureApiExpectTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/features/InfrastructureApiExpectTest.java deleted file mode 100644 index 8099e4f50f..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/features/InfrastructureApiExpectTest.java +++ /dev/null @@ -1,201 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.abiquo.features; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertNull; - -import java.net.URI; - -import org.jclouds.abiquo.AbiquoApi; -import org.jclouds.http.HttpRequest; -import org.jclouds.http.HttpResponse; -import org.testng.annotations.Test; - -import com.abiquo.model.rest.RESTLink; -import com.abiquo.server.core.infrastructure.DatacenterDto; -import com.abiquo.server.core.infrastructure.network.NetworkServiceTypeDto; -import com.abiquo.server.core.infrastructure.network.NetworkServiceTypesDto; - -/** - * xpect tests for the {@link InfrastructureApi} class. - * - * @author Ignasi Barrera - */ -@Test(groups = "unit", testName = "InfrastructureApiExpectTest") -public class InfrastructureApiExpectTest extends BaseAbiquoRestApiExpectTest { - - public void testListNetworkServiceTypesReturns2xx() { - InfrastructureApi api = requestSendsResponse( - HttpRequest.builder() // - .method("GET") // - .endpoint(URI.create("http://localhost/api/admin/datacenters/1/networkservicetypes")) // - .addHeader("Authorization", basicAuth) // - .addHeader("Accept", normalize(NetworkServiceTypesDto.MEDIA_TYPE)) // - .build(), - HttpResponse - .builder() - .statusCode(200) - .payload( - payloadFromResourceWithContentType("/payloads/nst-list.xml", - normalize(NetworkServiceTypesDto.MEDIA_TYPE))) // - .build()); - - DatacenterDto datacenter = new DatacenterDto(); - datacenter.addLink(new RESTLink("networkservicetypes", - "http://localhost/api/admin/datacenters/1/networkservicetypes")); - - NetworkServiceTypesDto nsts = api.listNetworkServiceTypes(datacenter); - assertEquals(nsts.getCollection().size(), 2); - assertEquals(nsts.getCollection().get(0).getName(), "Service Network"); - assertEquals(nsts.getCollection().get(1).getName(), "Storage Network"); - } - - public void testGetNetworkServiceTypeReturns2xx() { - InfrastructureApi api = requestSendsResponse( - HttpRequest.builder() // - .method("GET") // - .endpoint(URI.create("http://localhost/api/admin/datacenters/1/networkservicetypes/1")) // - .addHeader("Authorization", basicAuth) // - .addHeader("Accept", normalize(NetworkServiceTypeDto.MEDIA_TYPE)) // - .build(), - HttpResponse - .builder() - .statusCode(200) - .payload( - payloadFromResourceWithContentType("/payloads/nst-edit.xml", - normalize(NetworkServiceTypeDto.MEDIA_TYPE))) // - .build()); - - DatacenterDto datacenter = new DatacenterDto(); - datacenter.addLink(new RESTLink("networkservicetypes", - "http://localhost/api/admin/datacenters/1/networkservicetypes")); - - NetworkServiceTypeDto created = api.getNetworkServiceType(datacenter, 1); - assertNotNull(created.getId()); - assertEquals(created.getName(), "Service Network"); - assertEquals(created.isDefaultNST(), true); - } - - public void testGetNetworkServiceTypeReturns4xx() { - InfrastructureApi api = requestSendsResponse(HttpRequest.builder() // - .method("GET") // - .endpoint(URI.create("http://localhost/api/admin/datacenters/1/networkservicetypes/1")) // - .addHeader("Authorization", basicAuth) // - .addHeader("Accept", normalize(NetworkServiceTypeDto.MEDIA_TYPE)) // - .build(), // - HttpResponse.builder().statusCode(404).build()); - - DatacenterDto datacenter = new DatacenterDto(); - datacenter.addLink(new RESTLink("networkservicetypes", - "http://localhost/api/admin/datacenters/1/networkservicetypes")); - - assertNull(api.getNetworkServiceType(datacenter, 1)); - } - - public void testCreateNetworkServiceTypeReturns2xx() { - InfrastructureApi api = requestSendsResponse( - HttpRequest.builder() // - .method("POST") // - .endpoint(URI.create("http://localhost/api/admin/datacenters/1/networkservicetypes")) // - .addHeader("Authorization", basicAuth) // - .addHeader("Accept", normalize(NetworkServiceTypeDto.MEDIA_TYPE)) - // - .payload( - payloadFromResourceWithContentType("/payloads/nst-create.xml", - normalize(NetworkServiceTypeDto.MEDIA_TYPE))) // - .build(), - HttpResponse - .builder() - .statusCode(201) - .payload( - payloadFromResourceWithContentType("/payloads/nst-edit.xml", - normalize(NetworkServiceTypeDto.MEDIA_TYPE))) // - .build()); - - DatacenterDto datacenter = new DatacenterDto(); - datacenter.addLink(new RESTLink("networkservicetypes", - "http://localhost/api/admin/datacenters/1/networkservicetypes")); - - NetworkServiceTypeDto nst = new NetworkServiceTypeDto(); - nst.setName("Service Network"); - nst.setDefaultNST(true); - - NetworkServiceTypeDto created = api.createNetworkServiceType(datacenter, nst); - assertNotNull(created.getId()); - assertEquals(created.getName(), "Service Network"); - assertEquals(created.isDefaultNST(), true); - } - - public void testUpdateNetworkServiceTypeReturns2xx() { - InfrastructureApi api = requestSendsResponse( - HttpRequest.builder() // - .method("PUT") // - .endpoint(URI.create("http://localhost/api/admin/datacenters/1/networkservicetypes/1")) // - .addHeader("Authorization", basicAuth) // - .addHeader("Accept", normalize(NetworkServiceTypeDto.MEDIA_TYPE)) - // - .payload( - payloadFromResourceWithContentType("/payloads/nst-edit.xml", - normalize(NetworkServiceTypeDto.MEDIA_TYPE))) // - .build(), - HttpResponse - .builder() - .statusCode(200) - .payload( - payloadFromResourceWithContentType("/payloads/nst-edit.xml", - normalize(NetworkServiceTypeDto.MEDIA_TYPE))) // - .build()); - - NetworkServiceTypeDto nst = new NetworkServiceTypeDto(); - RESTLink editLink = new RESTLink("edit", "http://localhost/api/admin/datacenters/1/networkservicetypes/1"); - editLink.setType(NetworkServiceTypeDto.BASE_MEDIA_TYPE); - nst.addLink(editLink); - nst.setId(1); - nst.setDefaultNST(true); - nst.setName("Service Network"); - - NetworkServiceTypeDto created = api.updateNetworkServiceType(nst); - assertNotNull(created.getId()); - assertEquals(created.getName(), "Service Network"); - } - - public void testDeleteNetworkServiceTypeReturns2xx() { - InfrastructureApi api = requestSendsResponse(HttpRequest.builder() // - .method("DELETE") // - .endpoint(URI.create("http://localhost/api/admin/datacenters/1/networkservicetypes/1")) // - .addHeader("Authorization", basicAuth) // - .build(), // - HttpResponse.builder().statusCode(204).build()); - - NetworkServiceTypeDto nst = new NetworkServiceTypeDto(); - RESTLink editLink = new RESTLink("edit", "http://localhost/api/admin/datacenters/1/networkservicetypes/1"); - editLink.setType(NetworkServiceTypeDto.BASE_MEDIA_TYPE); - nst.addLink(editLink); - - api.deleteNetworkServiceType(nst); - } - - @Override - protected InfrastructureApi clientFrom(AbiquoApi api) { - return api.getInfrastructureApi(); - } - -} 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 deleted file mode 100644 index c793aa7e46..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/features/InfrastructureAsyncApiTest.java +++ /dev/null @@ -1,1832 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.features; - -import static org.jclouds.abiquo.domain.DomainUtils.withHeader; -import static org.jclouds.reflect.Reflection2.method; - -import java.io.IOException; - -import javax.ws.rs.core.MediaType; - -import org.jclouds.Fallbacks.NullOnNotFoundOr404; -import org.jclouds.abiquo.AbiquoFallbacks.FalseIfNotAvailable; -import org.jclouds.abiquo.AbiquoFallbacks.PropagateAbiquoExceptionOnNotFoundOr4xx; -import org.jclouds.abiquo.domain.EnterpriseResources; -import org.jclouds.abiquo.domain.InfrastructureResources; -import org.jclouds.abiquo.domain.NetworkResources; -import org.jclouds.abiquo.domain.infrastructure.options.DatacenterOptions; -import org.jclouds.abiquo.domain.infrastructure.options.IpmiOptions; -import org.jclouds.abiquo.domain.infrastructure.options.MachineOptions; -import org.jclouds.abiquo.domain.infrastructure.options.StoragePoolOptions; -import org.jclouds.abiquo.domain.network.options.IpOptions; -import org.jclouds.abiquo.domain.network.options.NetworkOptions; -import org.jclouds.abiquo.domain.options.search.FilterOptions; -import org.jclouds.fallbacks.MapHttp4xxCodesToExceptions; -import org.jclouds.http.functions.ParseXMLWithJAXB; -import org.jclouds.http.functions.ReleasePayloadAndReturn; -import org.jclouds.http.functions.ReturnStringIf2xx; -import org.jclouds.http.functions.ReturnTrueIf2xx; -import org.jclouds.reflect.Invocation; -import org.jclouds.rest.internal.GeneratedHttpRequest; -import org.testng.annotations.Test; - -import com.abiquo.model.enumerator.HypervisorType; -import com.abiquo.model.enumerator.NetworkType; -import com.abiquo.model.enumerator.RemoteServiceType; -import com.abiquo.server.core.cloud.HypervisorTypesDto; -import com.abiquo.server.core.cloud.VirtualMachineWithNodeExtendedDto; -import com.abiquo.server.core.cloud.VirtualMachinesWithNodeExtendedDto; -import com.abiquo.server.core.enterprise.DatacentersLimitsDto; -import com.abiquo.server.core.enterprise.EnterpriseDto; -import com.abiquo.server.core.infrastructure.BladeLocatorLedDto; -import com.abiquo.server.core.infrastructure.DatacenterDto; -import com.abiquo.server.core.infrastructure.DatacentersDto; -import com.abiquo.server.core.infrastructure.FsmsDto; -import com.abiquo.server.core.infrastructure.LogicServerDto; -import com.abiquo.server.core.infrastructure.LogicServersDto; -import com.abiquo.server.core.infrastructure.MachineDto; -import com.abiquo.server.core.infrastructure.MachineIpmiStateDto; -import com.abiquo.server.core.infrastructure.MachineStateDto; -import com.abiquo.server.core.infrastructure.MachinesDto; -import com.abiquo.server.core.infrastructure.OrganizationDto; -import com.abiquo.server.core.infrastructure.OrganizationsDto; -import com.abiquo.server.core.infrastructure.RackDto; -import com.abiquo.server.core.infrastructure.RacksDto; -import com.abiquo.server.core.infrastructure.RemoteServiceDto; -import com.abiquo.server.core.infrastructure.RemoteServicesDto; -import com.abiquo.server.core.infrastructure.UcsRackDto; -import com.abiquo.server.core.infrastructure.UcsRacksDto; -import com.abiquo.server.core.infrastructure.network.ExternalIpDto; -import com.abiquo.server.core.infrastructure.network.ExternalIpsDto; -import com.abiquo.server.core.infrastructure.network.PublicIpDto; -import com.abiquo.server.core.infrastructure.network.PublicIpsDto; -import com.abiquo.server.core.infrastructure.network.UnmanagedIpDto; -import com.abiquo.server.core.infrastructure.network.UnmanagedIpsDto; -import com.abiquo.server.core.infrastructure.network.VLANNetworkDto; -import com.abiquo.server.core.infrastructure.network.VLANNetworksDto; -import com.abiquo.server.core.infrastructure.network.VlanTagAvailabilityDto; -import com.abiquo.server.core.infrastructure.storage.StorageDeviceDto; -import com.abiquo.server.core.infrastructure.storage.StorageDevicesDto; -import com.abiquo.server.core.infrastructure.storage.StorageDevicesMetadataDto; -import com.abiquo.server.core.infrastructure.storage.StoragePoolDto; -import com.abiquo.server.core.infrastructure.storage.StoragePoolsDto; -import com.abiquo.server.core.infrastructure.storage.TierDto; -import com.abiquo.server.core.infrastructure.storage.TiersDto; -import com.google.common.collect.ImmutableList; -import com.google.common.reflect.Invokable; - -/** - * Tests annotation parsing of {@code InfrastructureAsyncApi} - * - * @author Ignasi Barrera - */ -@Test(groups = "unit", testName = "InfrastructureAsyncApiTest") -public class InfrastructureAsyncApiTest extends BaseAbiquoAsyncApiTest { - /*********************** Datacenter ***********************/ - - public void testListDatacenters() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(InfrastructureAsyncApi.class, "listDatacenters"); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, ImmutableList.of())); - - 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); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testCreateDatacenter() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(InfrastructureAsyncApi.class, "createDatacenter", DatacenterDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testGetDatacenter() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(InfrastructureAsyncApi.class, "getDatacenter", Integer.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, ImmutableList. of(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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, NullOnNotFoundOr404.class); - - checkFilters(request); - } - - public void testUpdateDatacenter() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(InfrastructureAsyncApi.class, "updateDatacenter", DatacenterDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testDeleteDatacenter() throws SecurityException, NoSuchMethodException { - Invokable method = method(InfrastructureAsyncApi.class, "deleteDatacenter", DatacenterDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(InfrastructureResources.datacenterPut()))); - - 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); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testListLimitsDatacenter() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(InfrastructureAsyncApi.class, "listLimits", DatacenterDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - /*********************** Hypervisor ***********************/ - - public void testGetHypervisorTypeFromMachine() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(InfrastructureAsyncApi.class, "getHypervisorTypeFromMachine", - DatacenterDto.class, DatacenterOptions.class); - GeneratedHttpRequest request = processor.apply(Invocation.create( - method, - ImmutableList. of(InfrastructureResources.datacenterPut(), - DatacenterOptions.builder().ip("10.60.1.120").build()))); - - 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); - - assertResponseParserClassEquals(method, request, ReturnStringIf2xx.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testGetHypervisorTypesFromDatacenter() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(InfrastructureAsyncApi.class, "getHypervisorTypes", DatacenterDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - /*********************** Managed Rack ***********************/ - - public void testListRacks() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(InfrastructureAsyncApi.class, "listRacks", DatacenterDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testCreateRack() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(InfrastructureAsyncApi.class, "createRack", DatacenterDto.class, RackDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testGetRack() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(InfrastructureAsyncApi.class, "getRack", DatacenterDto.class, Integer.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, NullOnNotFoundOr404.class); - - checkFilters(request); - } - - public void testUpdateRack() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(InfrastructureAsyncApi.class, "updateRack", RackDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testDeleteRack() throws SecurityException, NoSuchMethodException { - Invokable method = method(InfrastructureAsyncApi.class, "deleteRack", RackDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(InfrastructureResources.rackPut()))); - - 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); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - /*********************** Managed Rack ***********************/ - - public void testListManagedRacks() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(InfrastructureAsyncApi.class, "listManagedRacks", DatacenterDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testCreateManagedRack() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(InfrastructureAsyncApi.class, "createManagedRack", DatacenterDto.class, - UcsRackDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create( - method, - ImmutableList. of(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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testGetManagedRack() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(InfrastructureAsyncApi.class, "getManagedRack", DatacenterDto.class, - Integer.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, NullOnNotFoundOr404.class); - - checkFilters(request); - } - - public void testUpdateManagedRack() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(InfrastructureAsyncApi.class, "updateManagedRack", UcsRackDto.class); - - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testListServiceProfiles() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(InfrastructureAsyncApi.class, "listServiceProfiles", UcsRackDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testListServiceProfilesWithOptions() throws SecurityException, NoSuchMethodException, IOException { - FilterOptions options = FilterOptions.builder().startWith(1).limit(2).build(); - - Invokable method = method(InfrastructureAsyncApi.class, "listServiceProfiles", UcsRackDto.class, - FilterOptions.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(InfrastructureResources.managedRackPut(), options))); - - 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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testListOrganizations() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(InfrastructureAsyncApi.class, "listOrganizations", UcsRackDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testListOrganizationsWithOptions() throws SecurityException, NoSuchMethodException, IOException { - FilterOptions options = FilterOptions.builder().has("org").build(); - - Invokable method = method(InfrastructureAsyncApi.class, "listOrganizations", UcsRackDto.class, - FilterOptions.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(InfrastructureResources.managedRackPut(), options))); - - 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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testListServiceProfileTemplates() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(InfrastructureAsyncApi.class, "listServiceProfileTemplates", UcsRackDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testListServiceProfileTemplatesWithOptions() throws SecurityException, NoSuchMethodException, - IOException { - FilterOptions options = FilterOptions.builder().ascendant(true).build(); - - Invokable method = method(InfrastructureAsyncApi.class, "listServiceProfileTemplates", UcsRackDto.class, - FilterOptions.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(InfrastructureResources.managedRackPut(), options))); - - 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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testAssociateLogicServer() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(InfrastructureAsyncApi.class, "associateLogicServer", UcsRackDto.class, - LogicServerDto.class, OrganizationDto.class, String.class); - GeneratedHttpRequest request = processor.apply(Invocation.create( - method, - ImmutableList. of(InfrastructureResources.managedRackPut(), - InfrastructureResources.logicServerPut(), InfrastructureResources.organizationPut(), "blade"))); - - assertRequestLineEquals( - request, - "POST http://localhost/api/admin/datacenters/1/racks/1/logicservers/associate?bladeDn=blade&lsName=server&org=org-root/org-Finance HTTP/1.1"); - assertNonPayloadHeadersEqual(request, ""); - assertPayloadEquals(request, null, null, false); - - assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testAssociateTemplate() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(InfrastructureAsyncApi.class, "associateTemplate", UcsRackDto.class, - LogicServerDto.class, OrganizationDto.class, String.class, String.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, ImmutableList. of( - InfrastructureResources.managedRackPut(), InfrastructureResources.logicServerPut(), - InfrastructureResources.organizationPut(), "newname", "blade"))); - - assertRequestLineEquals( - request, - "POST http://localhost/api/admin/datacenters/1/racks/1/logicservers/associatetemplate?newName=newname&bladeDn=blade&lsName=server&org=org-root/org-Finance HTTP/1.1"); - assertNonPayloadHeadersEqual(request, ""); - assertPayloadEquals(request, null, null, false); - - assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testCloneAndAssociateLogicServer() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(InfrastructureAsyncApi.class, "cloneAndAssociateLogicServer", UcsRackDto.class, - LogicServerDto.class, OrganizationDto.class, String.class, String.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, ImmutableList. of( - InfrastructureResources.managedRackPut(), InfrastructureResources.logicServerPut(), - InfrastructureResources.organizationPut(), "newname", "blade"))); - - assertRequestLineEquals( - request, - "POST http://localhost/api/admin/datacenters/1/racks/1/logicservers/assocclone?newName=newname&bladeDn=blade&lsName=server&org=org-root/org-Finance HTTP/1.1"); - assertNonPayloadHeadersEqual(request, ""); - assertPayloadEquals(request, null, null, false); - - assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testDissociateLogicServer() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(InfrastructureAsyncApi.class, "dissociateLogicServer", UcsRackDto.class, - LogicServerDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create( - method, - ImmutableList. of(InfrastructureResources.managedRackPut(), - InfrastructureResources.logicServerPut(), InfrastructureResources.organizationPut()))); - - 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); - - assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testCloneLogicServer() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(InfrastructureAsyncApi.class, "cloneLogicServer", UcsRackDto.class, - LogicServerDto.class, OrganizationDto.class, String.class); - GeneratedHttpRequest request = processor.apply(Invocation.create( - method, - ImmutableList. of(InfrastructureResources.managedRackPut(), - InfrastructureResources.logicServerPut(), InfrastructureResources.organizationPut(), "name"))); - - assertRequestLineEquals( - request, - "POST http://localhost/api/admin/datacenters/1/racks/1/logicservers/clone?newName=name&lsName=server&org=org-root/org-Finance HTTP/1.1"); - assertNonPayloadHeadersEqual(request, ""); - assertPayloadEquals(request, null, null, false); - - assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testDeleteLogicServer() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(InfrastructureAsyncApi.class, "deleteLogicServer", UcsRackDto.class, - LogicServerDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create( - method, - ImmutableList. of(InfrastructureResources.managedRackPut(), - InfrastructureResources.logicServerPut()))); - - 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); - - assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testListFsms() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(InfrastructureAsyncApi.class, "listFsms", UcsRackDto.class, String.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - /*********************** Remote Service **********************/ - - public void testListRemoteServices() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(InfrastructureAsyncApi.class, "listRemoteServices", DatacenterDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testCreateRemoteService() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(InfrastructureAsyncApi.class, "createRemoteService", DatacenterDto.class, - RemoteServiceDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create( - method, - ImmutableList. of(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); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testGetRemoteService() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(InfrastructureAsyncApi.class, "getRemoteService", DatacenterDto.class, - RemoteServiceType.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, ImmutableList. of( - 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); - assertFallbackClassEquals(method, NullOnNotFoundOr404.class); - - checkFilters(request); - } - - public void testUpdateRemoteService() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(InfrastructureAsyncApi.class, "updateRemoteService", RemoteServiceDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(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); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testDeleteRemoteService() throws SecurityException, NoSuchMethodException { - Invokable method = method(InfrastructureAsyncApi.class, "deleteRemoteService", RemoteServiceDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(InfrastructureResources.remoteServicePut()))); - - assertRequestLineEquals(request, - "DELETE http://localhost/api/admin/datacenters/1/remoteservices/nodecollector HTTP/1.1"); - assertNonPayloadHeadersEqual(request, ""); - assertPayloadEquals(request, null, null, false); - - assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testIsAvailableRemoteService() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(InfrastructureAsyncApi.class, "isAvailable", RemoteServiceDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(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); - - assertResponseParserClassEquals(method, request, ReturnTrueIf2xx.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, FalseIfNotAvailable.class); - - checkFilters(request); - } - - /*********************** Machine ***********************/ - - public void testDiscoverSingleMachineWithoutOptions() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(InfrastructureAsyncApi.class, "discoverSingleMachine", DatacenterDto.class, - String.class, HypervisorType.class, String.class, String.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, ImmutableList. of( - InfrastructureResources.datacenterPut(), "10.60.1.222", HypervisorType.XENSERVER, "user", "pass"))); - - String baseUrl = "http://localhost/api/admin/datacenters/1/action/discoversingle"; - String query = "ip=10.60.1.222&hypervisor=XENSERVER&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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, PropagateAbiquoExceptionOnNotFoundOr4xx.class); - - checkFilters(request); - } - - public void testDiscoverSingleMachineAllParams() throws SecurityException, NoSuchMethodException { - Invokable method = method(InfrastructureAsyncApi.class, "discoverSingleMachine", DatacenterDto.class, - String.class, HypervisorType.class, String.class, String.class, MachineOptions.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, ImmutableList. of( - 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 = "ip=80.80.80.80&hypervisor=KVM&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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, PropagateAbiquoExceptionOnNotFoundOr4xx.class); - - checkFilters(request); - } - - public void testDiscoverSingleMachineDefaultValues() throws SecurityException, NoSuchMethodException { - Invokable method = method(InfrastructureAsyncApi.class, "discoverSingleMachine", DatacenterDto.class, - String.class, HypervisorType.class, String.class, String.class, MachineOptions.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, ImmutableList. of( - 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 = "ip=80.80.80.80&hypervisor=KVM&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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, PropagateAbiquoExceptionOnNotFoundOr4xx.class); - - checkFilters(request); - } - - public void testDiscoverMultipleMachinesWithoutOptions() throws SecurityException, NoSuchMethodException, - IOException { - Invokable method = method(InfrastructureAsyncApi.class, "discoverMultipleMachines", DatacenterDto.class, - String.class, String.class, HypervisorType.class, String.class, String.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, ImmutableList. of( - 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 = "ipFrom=10.60.1.222&ipTo=10.60.1.250&hypervisor=XENSERVER&user=user&password=pass"; - 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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, PropagateAbiquoExceptionOnNotFoundOr4xx.class); - - checkFilters(request); - } - - public void testDiscoverMultipleMachinesAllParams() throws SecurityException, NoSuchMethodException { - Invokable method = method(InfrastructureAsyncApi.class, "discoverMultipleMachines", DatacenterDto.class, - String.class, String.class, HypervisorType.class, String.class, String.class, MachineOptions.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, ImmutableList. of( - 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 = "ipFrom=80.80.80.80&ipTo=80.80.80.86&hypervisor=KVM&user=user&password=pass&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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, PropagateAbiquoExceptionOnNotFoundOr4xx.class); - - checkFilters(request); - } - - public void testCheckMachineStateWithoutOptions() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(InfrastructureAsyncApi.class, "checkMachineState", DatacenterDto.class, - String.class, HypervisorType.class, String.class, String.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, ImmutableList. of( - InfrastructureResources.datacenterPut(), "10.60.1.222", HypervisorType.XENSERVER, "user", "pass"))); - - String baseUrl = "http://localhost/api/admin/datacenters/1/action/checkmachinestate"; - String query = "ip=10.60.1.222&hypervisor=XENSERVER&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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, PropagateAbiquoExceptionOnNotFoundOr4xx.class); - - checkFilters(request); - } - - public void testCheckMachineStateAllParams() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(InfrastructureAsyncApi.class, "checkMachineState", DatacenterDto.class, - String.class, HypervisorType.class, String.class, String.class, MachineOptions.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, ImmutableList. of( - 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 = "ip=10.60.1.222&hypervisor=XENSERVER&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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, PropagateAbiquoExceptionOnNotFoundOr4xx.class); - - checkFilters(request); - } - - public void testCheckMachineIpmiStateWithoutOptions() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(InfrastructureAsyncApi.class, "checkMachineIpmiState", DatacenterDto.class, - String.class, String.class, String.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(InfrastructureResources.datacenterPut(), "10.60.1.222", "user", "pass"))); - - String baseUrl = "http://localhost/api/admin/datacenters/1/action/checkmachineipmistate"; - String query = "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: " + MachineIpmiStateDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, null, null, false); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, PropagateAbiquoExceptionOnNotFoundOr4xx.class); - - checkFilters(request); - } - - public void testCheckMachineIpmiStateWithALLOptions() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(InfrastructureAsyncApi.class, "checkMachineIpmiState", DatacenterDto.class, - String.class, String.class, String.class, IpmiOptions.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, ImmutableList. of( - 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 = "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: " + MachineIpmiStateDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, null, null, false); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, PropagateAbiquoExceptionOnNotFoundOr4xx.class); - - checkFilters(request); - } - - public void testListMachines() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(InfrastructureAsyncApi.class, "listMachines", RackDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testGetMachine() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(InfrastructureAsyncApi.class, "getMachine", RackDto.class, Integer.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, NullOnNotFoundOr404.class); - - checkFilters(request); - } - - public void testCheckMachineState() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(InfrastructureAsyncApi.class, "checkMachineState", MachineDto.class, - boolean.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(InfrastructureResources.machinePut(), true))); - - 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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testCheckMachineIpmiState() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(InfrastructureAsyncApi.class, "checkMachineIpmiState", MachineDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(InfrastructureResources.machinePut()))); - - 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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testCreateMachine() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(InfrastructureAsyncApi.class, "createMachine", RackDto.class, MachineDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testUpdateMachine() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(InfrastructureAsyncApi.class, "updateMachine", MachineDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testDeleteMachine() throws SecurityException, NoSuchMethodException { - Invokable method = method(InfrastructureAsyncApi.class, "deleteMachine", MachineDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(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); - - assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testReserveMachine() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(InfrastructureAsyncApi.class, "reserveMachine", EnterpriseDto.class, - MachineDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testCancelReservation() throws SecurityException, NoSuchMethodException { - Invokable method = method(InfrastructureAsyncApi.class, "cancelReservation", EnterpriseDto.class, - MachineDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(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); - - assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testListVirtualMachinesByMachine() throws SecurityException, NoSuchMethodException, IOException { - MachineOptions options = MachineOptions.builder().sync(true).build(); - - Invokable method = method(InfrastructureAsyncApi.class, "listVirtualMachinesByMachine", MachineDto.class, - MachineOptions.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(InfrastructureResources.machinePut(), options))); - - 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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testGetVirtualMachineByMachine() throws SecurityException, NoSuchMethodException, IOException { - - Invokable method = method(InfrastructureAsyncApi.class, "getVirtualMachine", MachineDto.class, - Integer.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(InfrastructureResources.machinePut(), 1))); - - 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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, NullOnNotFoundOr404.class); - - checkFilters(request); - } - - /*********************** Blade ***********************/ - - public void testPowerOff() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(InfrastructureAsyncApi.class, "powerOff", MachineDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(InfrastructureResources.machinePut()))); - - 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); - - assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testPowerOn() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(InfrastructureAsyncApi.class, "powerOn", MachineDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(InfrastructureResources.machinePut()))); - - 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); - - assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testGetLogicServer() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(InfrastructureAsyncApi.class, "getLogicServer", MachineDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(InfrastructureResources.machinePut()))); - - 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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testLedOn() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(InfrastructureAsyncApi.class, "ledOn", MachineDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(InfrastructureResources.machinePut()))); - - 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); - - assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testLedOff() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(InfrastructureAsyncApi.class, "ledOff", MachineDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(InfrastructureResources.machinePut()))); - - 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); - - assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testGetLocatorLed() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(InfrastructureAsyncApi.class, "getLocatorLed", MachineDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - /*********************** Storage Device ***********************/ - - public void testListStorageDevices() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(InfrastructureAsyncApi.class, "listStorageDevices", DatacenterDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testListSupportedStorageDevices() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(InfrastructureAsyncApi.class, "listSupportedStorageDevices", DatacenterDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(InfrastructureResources.datacenterPut()))); - - 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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testCreateStorageDevice() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(InfrastructureAsyncApi.class, "createStorageDevice", DatacenterDto.class, - StorageDeviceDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create( - method, - ImmutableList. of(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); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testDeleteStorageDevice() throws SecurityException, NoSuchMethodException { - Invokable method = method(InfrastructureAsyncApi.class, "deleteStorageDevice", StorageDeviceDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(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); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testUpdateStorageDevice() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(InfrastructureAsyncApi.class, "updateStorageDevice", StorageDeviceDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(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()), - StorageDeviceDto.class, StorageDeviceDto.BASE_MEDIA_TYPE, false); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testGetStorageDevice() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(InfrastructureAsyncApi.class, "getStorageDevice", DatacenterDto.class, - Integer.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(InfrastructureResources.datacenterPut(), 1))); - - 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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, NullOnNotFoundOr404.class); - - checkFilters(request); - } - - /*********************** Tier ***********************/ - - public void testListTiers() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(InfrastructureAsyncApi.class, "listTiers", DatacenterDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(InfrastructureResources.datacenterPut()))); - - 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); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testUpdateTier() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(InfrastructureAsyncApi.class, "updateTier", TierDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(InfrastructureResources.tierPut()))); - - 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); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testGetTier() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(InfrastructureAsyncApi.class, "getTier", DatacenterDto.class, Integer.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(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); - assertFallbackClassEquals(method, NullOnNotFoundOr404.class); - - checkFilters(request); - } - - /*********************** StoragePool ***********************/ - - public void testListSyncStoragePools() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(InfrastructureAsyncApi.class, "listStoragePools", StorageDeviceDto.class, - StoragePoolOptions.class); - GeneratedHttpRequest request = processor.apply(Invocation.create( - method, - ImmutableList. of(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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testListStoragePoolsFromTier() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(InfrastructureAsyncApi.class, "listStoragePools", TierDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create( - method, - ImmutableList. of(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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testListStoragePoolsNoParams() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(InfrastructureAsyncApi.class, "listStoragePools", StorageDeviceDto.class, - StoragePoolOptions.class); - GeneratedHttpRequest request = processor - .apply(Invocation.create(method, ImmutableList. of(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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testCreateStoragePool() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(InfrastructureAsyncApi.class, "createStoragePool", StorageDeviceDto.class, - StoragePoolDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create( - method, - ImmutableList. of(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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testUpdateStoragePool() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(InfrastructureAsyncApi.class, "updateStoragePool", StoragePoolDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(InfrastructureResources.storagePoolPut()))); - - 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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testDeleteStoragePool() throws SecurityException, NoSuchMethodException { - Invokable method = method(InfrastructureAsyncApi.class, "deleteStoragePool", StoragePoolDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(InfrastructureResources.storagePoolPut()))); - - assertRequestLineEquals(request, - "DELETE http://localhost/api/admin/datacenters/1/storage/devices/1/pools/tururututu HTTP/1.1"); - assertNonPayloadHeadersEqual(request, ""); - assertPayloadEquals(request, null, null, false); - - assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testGetStoragePool() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(InfrastructureAsyncApi.class, "getStoragePool", StorageDeviceDto.class, - String.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, ImmutableList. of( - InfrastructureResources.storageDevicePut(), InfrastructureResources.storagePoolPut().getIdStorage()))); - - 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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, NullOnNotFoundOr404.class); - - checkFilters(request); - } - - public void testRefreshStoragePool() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(InfrastructureAsyncApi.class, "refreshStoragePool", StoragePoolDto.class, - StoragePoolOptions.class); - GeneratedHttpRequest request = processor.apply(Invocation.create( - method, - ImmutableList. of(InfrastructureResources.storagePoolPut(), StoragePoolOptions.builder().sync(true) - .build()))); - - 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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, MapHttp4xxCodesToExceptions.class); - - checkFilters(request); - } - - /*********************** Network ***********************/ - - public void testListNetworks() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(InfrastructureAsyncApi.class, "listNetworks", DatacenterDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testListNetworksWithOptions() throws SecurityException, NoSuchMethodException, IOException { - NetworkOptions options = NetworkOptions.builder().type(NetworkType.PUBLIC).build(); - - Invokable method = method(InfrastructureAsyncApi.class, "listNetworks", DatacenterDto.class, - NetworkOptions.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testGetNetworks() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(InfrastructureAsyncApi.class, "getNetwork", DatacenterDto.class, Integer.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, NullOnNotFoundOr404.class); - - checkFilters(request); - } - - public void testCreateNetwork() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(InfrastructureAsyncApi.class, "createNetwork", DatacenterDto.class, - VLANNetworkDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testUpdateNetwork() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(InfrastructureAsyncApi.class, "updateNetwork", VLANNetworkDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testDeleteNetwork() throws SecurityException, NoSuchMethodException { - Invokable method = method(InfrastructureAsyncApi.class, "deleteNetwork", VLANNetworkDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(NetworkResources.publicNetworkPut()))); - - 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); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testCheckTagAvailability() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(InfrastructureAsyncApi.class, "checkTagAvailability", DatacenterDto.class, - Integer.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(InfrastructureResources.datacenterPut(), 2))); - - 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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, MapHttp4xxCodesToExceptions.class); - - checkFilters(request); - } - - /*********************** Network IPs ***********************/ - - public void testListPublicIps() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(InfrastructureAsyncApi.class, "listPublicIps", VLANNetworkDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testListPublicIpsWithOptions() throws SecurityException, NoSuchMethodException, IOException { - IpOptions options = IpOptions.builder().startWith(10).build(); - Invokable method = method(InfrastructureAsyncApi.class, "listPublicIps", VLANNetworkDto.class, - IpOptions.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(NetworkResources.publicNetworkPut(), options))); - - 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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testGetPublicIp() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(InfrastructureAsyncApi.class, "getPublicIp", VLANNetworkDto.class, Integer.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testListExternalIps() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(InfrastructureAsyncApi.class, "listExternalIps", VLANNetworkDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(NetworkResources.externalNetworkPut()))); - - 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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testListExternalIpsWithOptions() throws SecurityException, NoSuchMethodException, IOException { - IpOptions options = IpOptions.builder().startWith(10).build(); - Invokable method = method(InfrastructureAsyncApi.class, "listExternalIps", VLANNetworkDto.class, - IpOptions.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(NetworkResources.externalNetworkPut(), options))); - - 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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testGetExternalIp() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(InfrastructureAsyncApi.class, "getExternalIp", VLANNetworkDto.class, - Integer.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(NetworkResources.externalNetworkPut(), 1))); - - 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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testListUnmanagedIps() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(InfrastructureAsyncApi.class, "listUnmanagedIps", VLANNetworkDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(NetworkResources.unmanagedNetworkPut()))); - - 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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testListUnmanagedIpsWithOptions() throws SecurityException, NoSuchMethodException, IOException { - IpOptions options = IpOptions.builder().startWith(10).build(); - Invokable method = method(InfrastructureAsyncApi.class, "listUnmanagedIps", VLANNetworkDto.class, - IpOptions.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(NetworkResources.unmanagedNetworkPut(), options))); - - 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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testGetUnmanagedIp() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(InfrastructureAsyncApi.class, "getUnmanagedIp", VLANNetworkDto.class, - Integer.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(NetworkResources.externalNetworkPut(), 1))); - - 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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } -} diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/features/MissingNamedMethodsTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/features/MissingNamedMethodsTest.java deleted file mode 100644 index fae1a1ab5a..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/features/MissingNamedMethodsTest.java +++ /dev/null @@ -1,75 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.abiquo.features; - -import static com.google.common.collect.Iterables.concat; -import static com.google.common.collect.Iterables.filter; -import static com.google.common.collect.Iterables.isEmpty; -import static com.google.common.collect.Iterables.size; -import static com.google.common.collect.Iterables.transform; -import static org.testng.Assert.fail; - -import java.lang.reflect.Method; -import java.util.Arrays; -import java.util.Collection; - -import javax.inject.Named; - -import org.jclouds.abiquo.config.AbiquoRestClientModule; -import org.testng.annotations.Test; -import org.testng.util.Strings; - -import com.google.common.base.Function; -import com.google.common.base.Joiner; -import com.google.common.base.Predicate; - -/** - * Check that no method in the apis is missing the {@link Named} annotation. - * - * @author Ignasi Barrera - */ -@Test(groups = "unit", testName = "MissingNamedMethodsTest") -public class MissingNamedMethodsTest { - - public void testMissingNamedMethods() { - Collection> apis = AbiquoRestClientModule.DELEGATE_MAP.values(); - - Iterable missing = transform(concat(transform(apis, new Function, Iterable>() { - @Override - public Iterable apply(Class input) { - return filter(Arrays.asList(input.getMethods()), new Predicate() { - @Override - public boolean apply(Method input) { - Named named = input.getAnnotation(Named.class); - return named == null || Strings.isNullOrEmpty(named.value()) || !named.value().matches(".+:.+"); - } - }); - } - })), new Function() { - @Override - public String apply(Method input) { - return input.getDeclaringClass().getSimpleName() + "." + input.getName(); - } - }); - - if (!isEmpty(missing)) { - fail(size(missing) + " methods missing @Named annotation:\n" + Joiner.on('\n').join(missing)); - } - } -} \ No newline at end of file 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 deleted file mode 100644 index 335a46d5ba..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/features/PricingAsyncApiTest.java +++ /dev/null @@ -1,437 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.features; - -import static org.jclouds.abiquo.domain.DomainUtils.withHeader; -import static org.jclouds.reflect.Reflection2.method; - -import java.io.IOException; - -import org.jclouds.Fallbacks.NullOnNotFoundOr404; -import org.jclouds.abiquo.domain.PricingResources; -import org.jclouds.http.functions.ParseXMLWithJAXB; -import org.jclouds.http.functions.ReleasePayloadAndReturn; -import org.jclouds.reflect.Invocation; -import org.jclouds.rest.internal.GeneratedHttpRequest; -import org.testng.annotations.Test; - -import com.abiquo.server.core.pricing.CostCodeCurrenciesDto; -import com.abiquo.server.core.pricing.CostCodeDto; -import com.abiquo.server.core.pricing.CostCodesDto; -import com.abiquo.server.core.pricing.CurrenciesDto; -import com.abiquo.server.core.pricing.CurrencyDto; -import com.abiquo.server.core.pricing.PricingCostCodeDto; -import com.abiquo.server.core.pricing.PricingCostCodesDto; -import com.abiquo.server.core.pricing.PricingTemplateDto; -import com.abiquo.server.core.pricing.PricingTemplatesDto; -import com.abiquo.server.core.pricing.PricingTierDto; -import com.abiquo.server.core.pricing.PricingTiersDto; -import com.google.common.collect.ImmutableList; -import com.google.common.reflect.Invokable; - -/** - * Tests annotation parsing of {@code PricingAsyncApi}. - * - * @author Ignasi Barrera - * @author Susana Acedo - */ -@Test(groups = "unit", singleThreaded = true, testName = "PricingAsyncApiTest") -public class PricingAsyncApiTest extends BaseAbiquoAsyncApiTest { - /*********************** Currency ***********************/ - - public void testListCurrencies() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(PricingAsyncApi.class, "listCurrencies"); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, ImmutableList.of())); - - 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); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testGetCurrency() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(PricingAsyncApi.class, "getCurrency", Integer.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, ImmutableList. of(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); - assertFallbackClassEquals(method, NullOnNotFoundOr404.class); - - checkFilters(request); - } - - public void testCreateCurrency() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(PricingAsyncApi.class, "createCurrency", CurrencyDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(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); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testUpdateCurrency() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(PricingAsyncApi.class, "updateCurrency", CurrencyDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(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); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testDeleteCurrency() throws SecurityException, NoSuchMethodException { - Invokable method = method(PricingAsyncApi.class, "deleteCurrency", CurrencyDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(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); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - /*********************** Cost Code ***********************/ - - public void testListCostCodes() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(PricingAsyncApi.class, "listCostCodes"); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, ImmutableList.of())); - - 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); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testGetCostCode() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(PricingAsyncApi.class, "getCostCode", Integer.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, ImmutableList. of(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); - assertFallbackClassEquals(method, NullOnNotFoundOr404.class); - - checkFilters(request); - } - - public void testCreateCostCode() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(PricingAsyncApi.class, "createCostCode", CostCodeDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(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); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testUpdateCostCode() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(PricingAsyncApi.class, "updateCostCode", CostCodeDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(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); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testDeleteCostCode() throws SecurityException, NoSuchMethodException { - Invokable method = method(PricingAsyncApi.class, "deleteCostCode", CostCodeDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(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); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - /*********************** Pricing Template ***********************/ - - public void testListPricingTemplates() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(PricingAsyncApi.class, "listPricingTemplates"); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, ImmutableList.of())); - - 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); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testGetPricingTemplate() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(PricingAsyncApi.class, "getPricingTemplate", Integer.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, ImmutableList. of(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); - assertFallbackClassEquals(method, NullOnNotFoundOr404.class); - - checkFilters(request); - } - - public void testCreatePricingTemplate() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(PricingAsyncApi.class, "createPricingTemplate", PricingTemplateDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(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); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testUpdatePricingTemplate() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(PricingAsyncApi.class, "updatePricingTemplate", PricingTemplateDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(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); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testDeletePricingTemplate() throws SecurityException, NoSuchMethodException { - Invokable method = method(PricingAsyncApi.class, "deletePricingTemplate", PricingTemplateDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(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); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - /*********************** Cost Code Currency ***********************/ - - public void testGetCostCodeCurrencies() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(PricingAsyncApi.class, "getCostCodeCurrencies", Integer.class, Integer.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, ImmutableList. of(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); - assertFallbackClassEquals(method, NullOnNotFoundOr404.class); - - checkFilters(request); - } - - public void testUpdateCostCodeCurrencies() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(PricingAsyncApi.class, "updateCostCodeCurrencies", Integer.class, - CostCodeCurrenciesDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(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); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - /*********************** Pricing Cost Code ***********************/ - - public void testGetPricingCostCodes() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(PricingAsyncApi.class, "getPricingCostCodes", Integer.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, ImmutableList. of(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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, NullOnNotFoundOr404.class); - - checkFilters(request); - } - - public void testGetPricingCostCode() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(PricingAsyncApi.class, "getPricingCostCode", Integer.class, Integer.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, ImmutableList. of(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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, NullOnNotFoundOr404.class); - - checkFilters(request); - } - - public void testUpdatePricingCostCode() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(PricingAsyncApi.class, "updatePricingCostCode", PricingCostCodeDto.class, - Integer.class, Integer.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - /*********************** Pricing Tier ***************************/ - - public void testGetPricingTiers() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(PricingAsyncApi.class, "getPricingTiers", Integer.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, ImmutableList. of(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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, NullOnNotFoundOr404.class); - - checkFilters(request); - } - - public void testGetPricingTier() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(PricingAsyncApi.class, "getPricingTier", Integer.class, Integer.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, ImmutableList. of(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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, NullOnNotFoundOr404.class); - - checkFilters(request); - } - - public void testUpdatePricingTier() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(PricingAsyncApi.class, "updatePricingTier", PricingTierDto.class, Integer.class, - Integer.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - 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 deleted file mode 100644 index b6930a1ab8..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/features/TaskAsyncApiTest.java +++ /dev/null @@ -1,124 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.features; - -import static org.jclouds.reflect.Reflection2.method; - -import java.io.IOException; - -import org.jclouds.abiquo.AbiquoFallbacks.NullOn303; -import org.jclouds.abiquo.domain.CloudResources; -import org.jclouds.abiquo.domain.TemplateResources; -import org.jclouds.http.functions.ParseXMLWithJAXB; -import org.jclouds.reflect.Invocation; -import org.jclouds.rest.internal.GeneratedHttpRequest; -import org.testng.annotations.Test; - -import com.abiquo.model.rest.RESTLink; -import com.abiquo.model.transport.SingleResourceTransportDto; -import com.abiquo.server.core.task.TaskDto; -import com.abiquo.server.core.task.TasksDto; -import com.google.common.collect.ImmutableList; -import com.google.common.reflect.Invokable; - -/** - * Tests annotation parsing of {@code TaskAsyncApi} - * - * @author Ignasi Barrera - * @author Francesc Montserrat - */ -@Test(groups = "unit", testName = "TaskAsyncApiTest") -public class TaskAsyncApiTest extends BaseAbiquoAsyncApiTest { - /*********************** Task ***********************/ - - public void testGetTaskVirtualMachine() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(TaskAsyncApi.class, "getTask", RESTLink.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(new RESTLink("task", - "http://localhost/api/cloud/virtualdatacenters/1/virtualappliances/1/virtualmachines/1" - + "/tasks/169f1877-5f17-4f62-9563-974001295c54")))); - - 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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, NullOn303.class); - - checkFilters(request); - } - - public void testListTasksVirtualMachine() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(TaskAsyncApi.class, "listTasks", SingleResourceTransportDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(CloudResources.virtualMachinePut()))); - - 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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testGetTaskVirtualMachineTemplate() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(TaskAsyncApi.class, "getTask", RESTLink.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(new RESTLink("task", - "http://localhost/api/admin/enterprises/1/datacenterrepositories/1/virtualmachinetemplates/1/" - + "tasks/169f1877-5f17-4f62-9563-974001295c54")))); - - 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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, NullOn303.class); - - checkFilters(request); - } - - public void testListTasksVirtualMachineTemplate() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(TaskAsyncApi.class, "listTasks", SingleResourceTransportDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(TemplateResources.virtualMachineTemplatePut()))); - - 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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } -} 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 deleted file mode 100644 index 5bcad1100c..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/features/VirtualMachineTemplateAsyncApiTest.java +++ /dev/null @@ -1,258 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.features; - -import static org.jclouds.abiquo.domain.DomainUtils.withHeader; -import static org.jclouds.reflect.Reflection2.method; - -import java.io.IOException; - -import org.jclouds.Fallbacks.NullOnNotFoundOr404; -import org.jclouds.abiquo.domain.TemplateResources; -import org.jclouds.abiquo.domain.cloud.options.ConversionOptions; -import org.jclouds.abiquo.domain.cloud.options.VirtualMachineTemplateOptions; -import org.jclouds.abiquo.functions.ReturnTaskReferenceOrNull; -import org.jclouds.http.functions.ParseXMLWithJAXB; -import org.jclouds.http.functions.ReleasePayloadAndReturn; -import org.jclouds.reflect.Invocation; -import org.jclouds.rest.internal.GeneratedHttpRequest; -import org.testng.annotations.Test; - -import com.abiquo.model.enumerator.ConversionState; -import com.abiquo.model.enumerator.DiskFormatType; -import com.abiquo.model.enumerator.HypervisorType; -import com.abiquo.model.transport.AcceptedRequestDto; -import com.abiquo.server.core.appslibrary.ConversionDto; -import com.abiquo.server.core.appslibrary.ConversionsDto; -import com.abiquo.server.core.appslibrary.VirtualMachineTemplateDto; -import com.abiquo.server.core.appslibrary.VirtualMachineTemplatePersistentDto; -import com.abiquo.server.core.appslibrary.VirtualMachineTemplatesDto; -import com.google.common.collect.ImmutableList; -import com.google.common.reflect.Invokable; - -/** - * Tests annotation parsing of {@code VirtualMachineTemplateAsyncApi} - * - * @author Ignasi Barrera - * @author Francesc Montserrat - */ -@Test(groups = "unit", testName = "VirtualMachineTemplateAsyncApiTest") -public class VirtualMachineTemplateAsyncApiTest extends BaseAbiquoAsyncApiTest { - /*********************** Virtual Machine Template ***********************/ - - public void testListVirtualMachineTemplates() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(VirtualMachineTemplateAsyncApi.class, "listVirtualMachineTemplates", - Integer.class, Integer.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, ImmutableList. of(1, 1))); - - 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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testListVirtualMachineTemplatesWithOptions() throws SecurityException, NoSuchMethodException, - IOException { - Invokable method = method(VirtualMachineTemplateAsyncApi.class, "listVirtualMachineTemplates", - Integer.class, Integer.class, VirtualMachineTemplateOptions.class); - GeneratedHttpRequest request = processor.apply(Invocation.create( - method, - ImmutableList. of( - 1, - 1, - VirtualMachineTemplateOptions.builder().hypervisorType(HypervisorType.XENSERVER) - .categoryName("Firewalls").build()))); - - 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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testGetVirtualMachineTemplate() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(VirtualMachineTemplateAsyncApi.class, "getVirtualMachineTemplate", Integer.class, - Integer.class, Integer.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, ImmutableList. of(1, 1, 1))); - - 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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, NullOnNotFoundOr404.class); - - checkFilters(request); - } - - public void testUpdateVirtualMachineTemplate() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(VirtualMachineTemplateAsyncApi.class, "updateVirtualMachineTemplate", - VirtualMachineTemplateDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(TemplateResources.virtualMachineTemplatePut()))); - - 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()), - VirtualMachineTemplateDto.class, VirtualMachineTemplateDto.BASE_MEDIA_TYPE, false); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testDeleteVirtualMachineTemplate() throws SecurityException, NoSuchMethodException { - Invokable method = method(VirtualMachineTemplateAsyncApi.class, "deleteVirtualMachineTemplate", - VirtualMachineTemplateDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(TemplateResources.virtualMachineTemplatePut()))); - - assertRequestLineEquals(request, "DELETE http://localhost/api/admin/enterprises/1/datacenterrepositories/1/" - + "virtualmachinetemplates/1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, ""); - assertPayloadEquals(request, null, null, false); - - assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testCreatePersistentVirtualMachineTemplate() throws SecurityException, NoSuchMethodException, - IOException { - Invokable method = method(VirtualMachineTemplateAsyncApi.class, "createPersistentVirtualMachineTemplate", - Integer.class, Integer.class, VirtualMachineTemplatePersistentDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(1, 1, TemplateResources.persistentData()))); - - 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()), - VirtualMachineTemplatePersistentDto.BASE_MEDIA_TYPE, false); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - /*********************** Conversions ***********************/ - - public void testRequestConversion() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(VirtualMachineTemplateAsyncApi.class, "requestConversion", - VirtualMachineTemplateDto.class, DiskFormatType.class, ConversionDto.class); - - GeneratedHttpRequest request = processor.apply(Invocation.create(method, ImmutableList. of( - TemplateResources.virtualMachineTemplatePut(), DiskFormatType.VMDK_STREAM_OPTIMIZED, - TemplateResources.conversionPut()))); - - 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()), - ConversionDto.BASE_MEDIA_TYPE, false); - - assertResponseParserClassEquals(method, request, ReturnTaskReferenceOrNull.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testListConversions() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(VirtualMachineTemplateAsyncApi.class, "listConversions", - VirtualMachineTemplateDto.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(TemplateResources.virtualMachineTemplatePut()))); - - 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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testListConversionsWithOptions() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(VirtualMachineTemplateAsyncApi.class, "listConversions", - VirtualMachineTemplateDto.class, ConversionOptions.class); - GeneratedHttpRequest request = processor.apply(Invocation.create( - method, - ImmutableList. of(TemplateResources.virtualMachineTemplatePut(), ConversionOptions.builder() - .hypervisorType(HypervisorType.XENSERVER).conversionState(ConversionState.FINISHED).build()))); - - 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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testGetConversion() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(VirtualMachineTemplateAsyncApi.class, "getConversion", - VirtualMachineTemplateDto.class, DiskFormatType.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, - ImmutableList. of(TemplateResources.virtualMachineTemplatePut(), DiskFormatType.RAW))); - - 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); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, NullOnNotFoundOr404.class); - - checkFilters(request); - } -} 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 deleted file mode 100644 index fcaf2eda6d..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/functions/ReturnTaskReferenceOrNullTest.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.functions; - -import static org.easymock.EasyMock.expect; -import static org.easymock.EasyMock.replay; -import static org.easymock.EasyMock.verify; -import static org.testng.Assert.assertNull; -import static org.testng.Assert.assertTrue; - -import java.io.IOException; - -import javax.ws.rs.core.Response.Status; - -import org.easymock.EasyMock; -import org.jclouds.http.HttpResponse; -import org.jclouds.io.Payload; -import org.jclouds.io.Payloads; -import org.jclouds.xml.internal.JAXBParser; -import org.testng.annotations.Test; - -import com.abiquo.model.transport.AcceptedRequestDto; -import com.google.common.base.Function; -import com.google.inject.TypeLiteral; - -/** - * Unit tests for the {@link ReturnTaskReferenceOrNull} function. - * - * @author Ignasi Barrera - */ -@Test(groups = "unit", testName = "ReturnTaskReferenceOrNullTest") -public class ReturnTaskReferenceOrNullTest { - public void testReturnNullIfNoContent() { - Function> function = new ReturnTaskReferenceOrNull(new JAXBParser( - "false"), createTypeLiteral()); - - HttpResponse response = EasyMock.createMock(HttpResponse.class); - - expect(response.getStatusCode()).andReturn(Status.NO_CONTENT.getStatusCode()); - expect(response.getPayload()).andReturn(null); - - replay(response); - - assertNull(function.apply(response)); - - verify(response); - } - - 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()); - - 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); - - replay(response); - - assertTrue(function.apply(response) instanceof AcceptedRequestDto); - - verify(response); - } - - private static TypeLiteral> createTypeLiteral() { - return new TypeLiteral>() { - }; - } -} 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 deleted file mode 100644 index 5f034ef0b1..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/functions/enterprise/ParseEnterpriseIdTest.java +++ /dev/null @@ -1,61 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.functions.enterprise; - -import static org.testng.Assert.assertEquals; - -import org.testng.annotations.Test; - -import com.abiquo.server.core.enterprise.EnterpriseDto; -import com.google.common.base.Function; - -/** - * Unit tests for the {@link ParseEnterpriseId} 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); - } - - @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()); - } - - public void testValidId() { - Function parser = new ParseEnterpriseId(); - - 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 deleted file mode 100644 index 48aca7b9fc..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/functions/infrastructure/ParseDatacenterIdTest.java +++ /dev/null @@ -1,61 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.functions.infrastructure; - -import static org.testng.Assert.assertEquals; - -import org.testng.annotations.Test; - -import com.abiquo.server.core.infrastructure.DatacenterDto; -import com.google.common.base.Function; - -/** - * Unit tests for the {@link ParseDatacenterId} 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); - } - - @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()); - } - - public void testValidId() { - Function parser = new ParseDatacenterId(); - - 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 deleted file mode 100644 index 27647d8775..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/functions/infrastructure/ParseMachineIdTest.java +++ /dev/null @@ -1,61 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.functions.infrastructure; - -import static org.testng.Assert.assertEquals; - -import org.testng.annotations.Test; - -import com.abiquo.server.core.infrastructure.MachineDto; -import com.google.common.base.Function; - -/** - * Unit tests for the {@link ParseMachineId} 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); - } - - @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()); - } - - public void testValidId() { - Function parser = new ParseMachineId(); - - 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 deleted file mode 100644 index 072e0147f5..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/functions/infrastructure/ParseRemoteServiceTypeTest.java +++ /dev/null @@ -1,52 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.functions.infrastructure; - -import static org.testng.Assert.assertEquals; - -import org.testng.annotations.Test; - -import com.abiquo.model.enumerator.RemoteServiceType; -import com.google.common.base.Function; - -/** - * Unit tests for the {@link ParseRemoteServiceType} functions. - * - * @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); - } - - @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"); - } -} 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 deleted file mode 100644 index 283d690952..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/http/filters/AbiquoAuthenticationLiveApiTest.java +++ /dev/null @@ -1,177 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.http.filters; - -import static com.google.common.base.Preconditions.checkNotNull; -import static org.jclouds.http.HttpUtils.releasePayload; -import static org.jclouds.http.filters.BasicAuthentication.basic; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.fail; - -import java.io.IOException; -import java.net.URI; -import java.util.Collection; -import java.util.Properties; - -import javax.ws.rs.core.Cookie; -import javax.ws.rs.core.HttpHeaders; - -import org.jclouds.ContextBuilder; -import org.jclouds.abiquo.AbiquoApiMetadata; -import org.jclouds.abiquo.AbiquoContext; -import org.jclouds.abiquo.config.AbiquoProperties; -import org.jclouds.http.HttpRequest; -import org.jclouds.http.HttpResponse; -import org.jclouds.logging.slf4j.config.SLF4JLoggingModule; -import org.jclouds.rest.AuthorizationException; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -import com.abiquo.server.core.enterprise.UserDto; -import com.google.common.collect.ImmutableSet; -import com.google.inject.Module; - -/** - * Live tests for the {@link AbiquoAuthentication} filter. - * - * @author Ignasi Barrera - */ -@Test(groups = "api", testName = "AbiquoAuthenticationLiveApiTest") -public class AbiquoAuthenticationLiveApiTest { - private String identity; - - private String credential; - - 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"); - } - - @Test - public void testAuthenticateWithToken() throws IOException { - String token = getAuthtenticationToken(); - - 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()) // - .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(); - } - } - } - - @Test - public void testAuthenticateWithInvalidToken() throws IOException { - String token = getAuthtenticationToken() + "INVALID"; - - 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()) // - .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(); - } - } - - fail("Token authentication should have failed"); - } - - private String getAuthtenticationToken() { - String token = null; - - 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(); - - request = request.toBuilder().replaceHeader(HttpHeaders.AUTHORIZATION, basic(identity, credential)).build(); - - // Execute the request and read the generated token - HttpResponse response = context.utils().http().invoke(request); - assertEquals(response.getStatusCode(), 200); - - token = readAuthenticationToken(response); - assertNotNull(token); - - releasePayload(response); - } finally { - if (context != null) { - context.close(); - } - } - - return token; - } - - 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(); - } - } - - 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 deleted file mode 100644 index 9375d93082..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/http/filters/AbiquoAuthenticationTest.java +++ /dev/null @@ -1,85 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.http.filters; - -import static com.google.common.base.Suppliers.ofInstance; -import static org.jclouds.http.filters.BasicAuthentication.basic; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; - -import java.net.URI; -import java.security.NoSuchAlgorithmException; -import java.security.cert.CertificateException; - -import javax.ws.rs.core.HttpHeaders; - -import org.jclouds.domain.Credentials; -import org.jclouds.http.HttpRequest; -import org.testng.annotations.Test; - -/** - * Unit tests for the {@link AbiquoAuthentication} filter. - * - * @author Ignasi Barrera - */ -@Test(groups = "unit", testName = "AbiquoAuthenticationTest") -public class AbiquoAuthenticationTest { - - public void testBasicAuthentication() throws NoSuchAlgorithmException, CertificateException { - HttpRequest request = HttpRequest.builder().method("GET").endpoint(URI.create("http://foo")).build(); - - AbiquoAuthentication filter = new AbiquoAuthentication(ofInstance(new Credentials("identity", "credential")), false); - HttpRequest filtered = filter.filter(request); - HttpRequest expected = request.toBuilder() - .replaceHeader(HttpHeaders.AUTHORIZATION, basic("identity", "credential")).build(); - - 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(); - - AbiquoAuthentication filter = new AbiquoAuthentication(ofInstance(new Credentials(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(); - - AbiquoAuthentication filter = new AbiquoAuthentication(ofInstance(new Credentials("identity", null)), false); - filter.filter(request); - } - - public void testTokenAuthentication() throws NoSuchAlgorithmException, CertificateException { - HttpRequest request = HttpRequest.builder().method("GET").endpoint(URI.create("http://foo")).build(); - - AbiquoAuthentication filter = new AbiquoAuthentication(ofInstance(new Credentials("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); - } -} 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 deleted file mode 100644 index 73a29dd41c..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/http/filters/AppendApiVersionToMediaTypeTest.java +++ /dev/null @@ -1,274 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.http.filters; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNull; -import static org.testng.Assert.assertTrue; - -import java.net.URI; -import java.util.Collection; - -import javax.ws.rs.core.HttpHeaders; - -import org.jclouds.abiquo.AbiquoAsyncApi; -import org.jclouds.abiquo.functions.AppendApiVersionToAbiquoMimeType; -import org.jclouds.http.HttpRequest; -import org.jclouds.io.Payload; -import org.jclouds.io.Payloads; -import org.testng.annotations.Test; - -import com.google.common.collect.LinkedHashMultimap; -import com.google.common.collect.Multimap; - -/** - * Unit tests for the {@link AppendApiVersionToMediaType} filter. - * - * @author Ignasi Barrera - */ -@Test(groups = "unit", testName = "AppendApiVersionToMediaTypeTest") -public class AppendApiVersionToMediaTypeTest { - - public void testAppendVersionToNonPayloadHeadersWithoutHeaders() { - HttpRequest request = HttpRequest.builder().method("GET").endpoint(URI.create("http://foo")).build(); - - AppendApiVersionToMediaType filter = new AppendApiVersionToMediaType(new AppendApiVersionToAbiquoMimeType( - AbiquoAsyncApi.API_VERSION)); - - HttpRequest filtered = filter.appendVersionToNonPayloadHeaders(request); - - assertTrue(filtered.getHeaders().get(HttpHeaders.ACCEPT).isEmpty()); - } - - 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(); - - AppendApiVersionToMediaType filter = new AppendApiVersionToMediaType(new AppendApiVersionToAbiquoMimeType( - AbiquoAsyncApi.API_VERSION)); - - HttpRequest filtered = filter.appendVersionToNonPayloadHeaders(request); - - 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"); - - HttpRequest request = HttpRequest.builder().method("GET").endpoint(URI.create("http://foo")).headers(headers) - .build(); - - AppendApiVersionToMediaType filter = new AppendApiVersionToMediaType(new AppendApiVersionToAbiquoMimeType( - AbiquoAsyncApi.API_VERSION)); - - 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"); - } - - 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(); - - AppendApiVersionToMediaType filter = new AppendApiVersionToMediaType(new AppendApiVersionToAbiquoMimeType( - AbiquoAsyncApi.API_VERSION)); - - 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); - } - - public void testAppendVersionToPayloadHeadersWithoutPayload() { - HttpRequest request = HttpRequest.builder().method("GET").endpoint(URI.create("http://foo")).build(); - - AppendApiVersionToMediaType filter = new AppendApiVersionToMediaType(new AppendApiVersionToAbiquoMimeType( - AbiquoAsyncApi.API_VERSION)); - - HttpRequest filtered = filter.appendVersionToPayloadHeaders(request); - - assertNull(filtered.getPayload()); - } - - 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(); - - AppendApiVersionToMediaType filter = new AppendApiVersionToMediaType(new AppendApiVersionToAbiquoMimeType( - AbiquoAsyncApi.API_VERSION)); - - HttpRequest filtered = filter.appendVersionToPayloadHeaders(request); - - assertEquals(filtered.getPayload().getContentMetadata().getContentType(), "application/xml"); - } - - public void testAppendVersionToPayloadHeadersWithDefaultPayload() { - Payload payload = Payloads.newByteArrayPayload(new byte[] {}); - - 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/unknown"); - } - - 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"); - } - - 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(), - "application/vnd.abiquo.racks+xml;version=" + AbiquoAsyncApi.API_VERSION); - } - - 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"); - } - - 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(), - "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"); - - 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(); - - 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=1.8.5"); - - 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("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 deleted file mode 100644 index e49b960ec3..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/internal/AsyncMonitorTest.java +++ /dev/null @@ -1,538 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.internal; - -import static org.easymock.EasyMock.anyLong; -import static org.easymock.EasyMock.anyObject; -import static org.easymock.EasyMock.expect; -import static org.easymock.EasyMock.replay; -import static org.easymock.EasyMock.verify; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertNull; -import static org.testng.Assert.assertTrue; - -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.ScheduledFuture; -import java.util.concurrent.TimeUnit; - -import org.easymock.EasyMock; -import org.jclouds.abiquo.events.monitor.MonitorEvent; -import org.jclouds.abiquo.internal.BaseMonitoringService.AsyncMonitor; -import org.jclouds.abiquo.monitor.MonitorStatus; -import org.jclouds.rest.RestContext; -import org.testng.annotations.Test; - -import com.google.common.base.Function; -import com.google.common.eventbus.EventBus; -import com.google.common.eventbus.Subscribe; - -/** - * Unit tests for the {@link AsyncMonitor} class. - * - * @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( - schedulerMock.scheduleWithFixedDelay(anyObject(Runnable.class), anyLong(), anyLong(), - anyObject(TimeUnit.class))).andReturn(mockFuture); - - replay(mockFuture); - replay(schedulerMock); - - AsyncMonitor monitor = mockMonitor(schedulerMock, new Object(), mockFunction(MonitorStatus.DONE), - new EventBus()); - - assertNull(monitor.getFuture()); - assertNull(monitor.getTimeout()); - - monitor.startMonitoring(null, TimeUnit.MILLISECONDS); - - assertNotNull(monitor.getFuture()); - assertNull(monitor.getTimeout()); - - verify(mockFuture); - verify(schedulerMock); - } - - @Test(expectedExceptions = NullPointerException.class, expectedExceptionsMessageRegExp = "timeUnit must not be null when using timeouts") - public void testStartMonitoringWithNullTimeout() { - ScheduledExecutorService schedulerMock = EasyMock.createMock(ScheduledExecutorService.class); - AsyncMonitor monitor = mockMonitor(schedulerMock, new Object(), mockFunction(MonitorStatus.DONE), - new EventBus()); - - monitor.startMonitoring(100L, null); - } - - @SuppressWarnings({ "rawtypes", "unchecked" }) - public void testStartMonitoringWithoutTimeoutAndNullTimeUnit() { - 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); - - replay(mockFuture); - replay(schedulerMock); - - AsyncMonitor monitor = mockMonitor(schedulerMock, new Object(), mockFunction(MonitorStatus.DONE), - new EventBus()); - - assertNull(monitor.getFuture()); - assertNull(monitor.getTimeout()); - - // If the maxWait parameter is null, timeUnit is not required - monitor.startMonitoring(null, null); - - assertNotNull(monitor.getFuture()); - assertNull(monitor.getTimeout()); - - verify(mockFuture); - verify(schedulerMock); - } - - @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); - - replay(mockFuture); - replay(schedulerMock); - - AsyncMonitor monitor = mockMonitor(schedulerMock, new Object(), mockFunction(MonitorStatus.DONE), - new EventBus()); - - assertNull(monitor.getFuture()); - assertNull(monitor.getTimeout()); - - monitor.startMonitoring(100L, TimeUnit.MILLISECONDS); - - assertNotNull(monitor.getFuture()); - assertNotNull(monitor.getTimeout()); - assertTrue(monitor.getTimeout() > 100L); - - verify(mockFuture); - verify(schedulerMock); - } - - @SuppressWarnings({ "rawtypes", "unchecked" }) - public void testStartMonitoringWithTimeoutInMinutes() { - 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); - - replay(mockFuture); - replay(schedulerMock); - - AsyncMonitor monitor = mockMonitor(schedulerMock, new Object(), mockFunction(MonitorStatus.DONE), - new EventBus()); - - assertNull(monitor.getFuture()); - assertNull(monitor.getTimeout()); - - monitor.startMonitoring(1L, TimeUnit.MINUTES); - - assertNotNull(monitor.getFuture()); - assertNotNull(monitor.getTimeout()); - assertTrue(monitor.getTimeout() > TimeUnit.MINUTES.toMillis(1)); - - verify(mockFuture); - verify(schedulerMock); - } - - @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); - - replay(mockFuture); - replay(schedulerMock); - - AsyncMonitor monitor = mockMonitor(schedulerMock, new Object(), mockFunction(MonitorStatus.DONE), - new EventBus()); - - assertNull(monitor.getFuture()); - assertNull(monitor.getTimeout()); - - monitor.startMonitoring(null, TimeUnit.MILLISECONDS); - assertNotNull(monitor.getFuture()); - assertNull(monitor.getTimeout()); - assertFalse(monitor.isTimeout()); - - verify(mockFuture); - verify(schedulerMock); - } - - @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); - - replay(mockFuture); - replay(schedulerMock); - - AsyncMonitor monitor = mockMonitor(schedulerMock, new Object(), mockFunction(MonitorStatus.DONE), - new EventBus()); - - assertNull(monitor.getFuture()); - assertNull(monitor.getTimeout()); - - monitor.startMonitoring(60000L, TimeUnit.MILLISECONDS); - assertNotNull(monitor.getFuture()); - assertNotNull(monitor.getTimeout()); - assertFalse(monitor.isTimeout()); - - 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( - schedulerMock.scheduleWithFixedDelay(anyObject(Runnable.class), anyLong(), anyLong(), - anyObject(TimeUnit.class))).andReturn(mockFuture); - - replay(mockFuture); - replay(schedulerMock); - - AsyncMonitor monitor = mockMonitor(schedulerMock, new Object(), mockFunction(MonitorStatus.DONE), - new EventBus()); - - assertNull(monitor.getFuture()); - assertNull(monitor.getTimeout()); - - monitor.startMonitoring(1L, TimeUnit.MILLISECONDS); - Thread.sleep(2L); - assertNotNull(monitor.getFuture()); - assertNotNull(monitor.getTimeout()); - assertTrue(monitor.isTimeout()); - - verify(mockFuture); - verify(schedulerMock); - } - - @SuppressWarnings({ "rawtypes", "unchecked" }) - public void testStopMonitoringWhenFutureIsCancelled() { - ScheduledFuture mockFuture = EasyMock.createMock(ScheduledFuture.class); - expect(mockFuture.isCancelled()).andReturn(true); - - ScheduledExecutorService schedulerMock = EasyMock.createMock(ScheduledExecutorService.class); - expect( - schedulerMock.scheduleWithFixedDelay(anyObject(Runnable.class), anyLong(), anyLong(), - anyObject(TimeUnit.class))).andReturn(mockFuture); - - replay(mockFuture); - replay(schedulerMock); - - AsyncMonitor monitor = mockMonitor(schedulerMock, new Object(), mockFunction(MonitorStatus.DONE), - new EventBus()); - - assertNull(monitor.getFuture()); - assertNull(monitor.getTimeout()); - - monitor.startMonitoring(null, TimeUnit.MILLISECONDS); - assertNotNull(monitor.getFuture()); - assertNull(monitor.getTimeout()); - - monitor.stopMonitoring(); - - 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); - - ScheduledExecutorService schedulerMock = EasyMock.createMock(ScheduledExecutorService.class); - expect( - schedulerMock.scheduleWithFixedDelay(anyObject(Runnable.class), anyLong(), anyLong(), - anyObject(TimeUnit.class))).andReturn(mockFuture); - - replay(mockFuture); - replay(schedulerMock); - - AsyncMonitor monitor = mockMonitor(schedulerMock, new Object(), mockFunction(MonitorStatus.DONE), - new EventBus()); - - assertNull(monitor.getFuture()); - assertNull(monitor.getTimeout()); - - monitor.startMonitoring(null, TimeUnit.MILLISECONDS); - assertNotNull(monitor.getFuture()); - assertNull(monitor.getTimeout()); - - monitor.stopMonitoring(); - - 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); - - ScheduledExecutorService schedulerMock = EasyMock.createMock(ScheduledExecutorService.class); - expect( - schedulerMock.scheduleWithFixedDelay(anyObject(Runnable.class), anyLong(), anyLong(), - anyObject(TimeUnit.class))).andReturn(mockFuture); - - replay(mockFuture); - replay(schedulerMock); - - AsyncMonitor monitor = mockMonitor(schedulerMock, new Object(), mockFunction(MonitorStatus.DONE), - new EventBus()); - - assertNull(monitor.getFuture()); - assertNull(monitor.getTimeout()); - - monitor.startMonitoring(null, TimeUnit.MILLISECONDS); - assertNotNull(monitor.getFuture()); - assertNull(monitor.getTimeout()); - - monitor.stopMonitoring(); - - verify(mockFuture); - verify(schedulerMock); - } - - @SuppressWarnings({ "rawtypes", "unchecked" }) - public void testMonitorAndDone() { - ScheduledFuture mockFuture = EasyMock.createMock(ScheduledFuture.class); - expect(mockFuture.isCancelled()).andReturn(true); - - ScheduledExecutorService schedulerMock = EasyMock.createMock(ScheduledExecutorService.class); - expect( - schedulerMock.scheduleWithFixedDelay(anyObject(Runnable.class), anyLong(), anyLong(), - anyObject(TimeUnit.class))).andReturn(mockFuture); - - replay(mockFuture); - replay(schedulerMock); - - CoutingEventHandler handler = new CoutingEventHandler(); - EventBus eventBus = new EventBus(); - eventBus.register(handler); - - AsyncMonitor monitor = mockMonitor(schedulerMock, new Object(), mockFunction(MonitorStatus.DONE), - eventBus); - - assertNull(monitor.getFuture()); - assertNull(monitor.getTimeout()); - - monitor.startMonitoring(null, TimeUnit.MILLISECONDS); - assertNotNull(monitor.getFuture()); - assertNull(monitor.getTimeout()); - - monitor.run(); - assertEquals(handler.numCompletes, 1); - assertEquals(handler.numFailures, 0); - assertEquals(handler.numTimeouts, 0); - - verify(mockFuture); - verify(schedulerMock); - } - - @SuppressWarnings({ "rawtypes", "unchecked" }) - public void testMonitorAndFail() { - ScheduledFuture mockFuture = EasyMock.createMock(ScheduledFuture.class); - expect(mockFuture.isCancelled()).andReturn(true); - - ScheduledExecutorService schedulerMock = EasyMock.createMock(ScheduledExecutorService.class); - expect( - schedulerMock.scheduleWithFixedDelay(anyObject(Runnable.class), anyLong(), anyLong(), - anyObject(TimeUnit.class))).andReturn(mockFuture); - - replay(mockFuture); - replay(schedulerMock); - - CoutingEventHandler handler = new CoutingEventHandler(); - EventBus eventBus = new EventBus(); - eventBus.register(handler); - - AsyncMonitor monitor = mockMonitor(schedulerMock, new Object(), mockFunction(MonitorStatus.FAILED), - eventBus); - - assertNull(monitor.getFuture()); - assertNull(monitor.getTimeout()); - - monitor.startMonitoring(null, TimeUnit.MILLISECONDS); - assertNotNull(monitor.getFuture()); - assertNull(monitor.getTimeout()); - - monitor.run(); - assertEquals(handler.numCompletes, 0); - assertEquals(handler.numFailures, 1); - assertEquals(handler.numTimeouts, 0); - - verify(mockFuture); - verify(schedulerMock); - } - - @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); - - replay(mockFuture); - replay(schedulerMock); - - CoutingEventHandler handler = new CoutingEventHandler(); - EventBus eventBus = new EventBus(); - eventBus.register(handler); - - AsyncMonitor monitor = mockMonitor(schedulerMock, new Object(), mockFunction(MonitorStatus.CONTINUE), - eventBus); - - assertNull(monitor.getFuture()); - assertNull(monitor.getTimeout()); - - monitor.startMonitoring(null, TimeUnit.MILLISECONDS); - assertNotNull(monitor.getFuture()); - assertNull(monitor.getTimeout()); - - monitor.run(); - assertEquals(handler.numCompletes, 0); - assertEquals(handler.numFailures, 0); - assertEquals(handler.numTimeouts, 0); - - verify(mockFuture); - verify(schedulerMock); - } - - @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( - schedulerMock.scheduleWithFixedDelay(anyObject(Runnable.class), anyLong(), anyLong(), - anyObject(TimeUnit.class))).andReturn(mockFuture); - - replay(mockFuture); - replay(schedulerMock); - - CoutingEventHandler handler = new CoutingEventHandler(); - EventBus eventBus = new EventBus(); - eventBus.register(handler); - - AsyncMonitor monitor = mockMonitor(schedulerMock, new Object(), mockFunction(MonitorStatus.CONTINUE), - eventBus); - - assertNull(monitor.getFuture()); - assertNull(monitor.getTimeout()); - - monitor.startMonitoring(1L, TimeUnit.MILLISECONDS); - assertNotNull(monitor.getFuture()); - assertNotNull(monitor.getTimeout()); - - Thread.sleep(2L); - monitor.run(); - assertEquals(handler.numCompletes, 0); - assertEquals(handler.numFailures, 0); - assertEquals(handler.numTimeouts, 1); - - 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 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); - - return monitorService.new AsyncMonitor(object, function); - } - - private Function mockFunction(final MonitorStatus status) { - return new Function() { - @Override - public MonitorStatus apply(final Object input) { - return status; - } - }; - } - - static class CoutingEventHandler { - public int numCompletes = 0; - - public int numFailures = 0; - - public int numTimeouts = 0; - - @Subscribe - 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 deleted file mode 100644 index f79211a759..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/internal/BaseAbiquoApiLiveApiTest.java +++ /dev/null @@ -1,89 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.internal; - -import org.jclouds.abiquo.environment.CloudTestEnvironment; -import org.testng.annotations.AfterSuite; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; - -/** - * Base class for live and domain tests. - * - * @author Ignasi Barrera - */ -@Test(groups = "api", testName = "BaseAbiquoApiLiveApiTest", singleThreaded = true) -public abstract class BaseAbiquoApiLiveApiTest extends BaseAbiquoLiveApiTest { - /** The test environment. */ - protected static CloudTestEnvironment env; - - @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(); - } - } - - @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 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); - } - } - } -} 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 deleted file mode 100644 index 1690b0e500..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/internal/BaseAbiquoLiveApiTest.java +++ /dev/null @@ -1,65 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.abiquo.internal; - -import static org.jclouds.reflect.Reflection2.typeToken; - -import java.util.Properties; - -import org.jclouds.abiquo.AbiquoContext; -import org.jclouds.apis.BaseViewLiveTest; -import org.jclouds.logging.config.LoggingModule; -import org.jclouds.logging.slf4j.config.SLF4JLoggingModule; - -import com.google.common.reflect.TypeToken; - -/** - * Base class for Abiquo live tests. - * - * @author Ignasi Barrera - */ -public abstract class BaseAbiquoLiveApiTest extends BaseViewLiveTest { - public BaseAbiquoLiveApiTest() { - provider = "abiquo"; - } - - @Override - protected Properties setupProperties() { - Properties overrides = super.setupProperties(); - // 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 TypeToken viewType() { - return typeToken(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 deleted file mode 100644 index 05e5f47744..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/internal/BaseAdministrationServiceTest.java +++ /dev/null @@ -1,43 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.internal; - -import static org.testng.Assert.assertNotNull; - -import org.jclouds.abiquo.features.services.AdministrationService; -import org.testng.annotations.Test; - -/** - * Unit tests for the {@link BaseAdministrationService} class. - * - * @author Ignasi Barrera - */ -@Test(groups = "unit", testName = "BaseAdministrationServiceTest") -public class BaseAdministrationServiceTest extends BaseInjectionTest { - - public void testAllPropertiesInjected() { - BaseAdministrationService service = (BaseAdministrationService) injector.getInstance(AdministrationService.class); - - assertNotNull(service.context); - assertNotNull(service.listMachines); - 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 deleted file mode 100644 index c1e49628d1..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/internal/BaseCloudServiceTest.java +++ /dev/null @@ -1,43 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.internal; - -import static org.testng.Assert.assertNotNull; - -import org.jclouds.abiquo.features.services.CloudService; -import org.testng.annotations.Test; - -/** - * Unit tests for the {@link BaseCloudService} class. - * - * @author Ignasi Barrera - */ -@Test(groups = "unit", testName = "BaseCloudServiceTest") -public class BaseCloudServiceTest extends BaseInjectionTest { - - public void testAllPropertiesInjected() { - BaseCloudService service = (BaseCloudService) injector.getInstance(CloudService.class); - - 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 deleted file mode 100644 index ea3cb9489c..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/internal/BaseEventServiceTest.java +++ /dev/null @@ -1,39 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.internal; - -import static org.testng.Assert.assertNotNull; - -import org.jclouds.abiquo.features.services.EventService; -import org.testng.annotations.Test; - -/** - * Unit tests for the {@link BaseEventService} class. - * - * @author Vivien Mahé - */ -@Test(groups = "unit", testName = "BaseEventServiceTest") -public class BaseEventServiceTest extends BaseInjectionTest { - public void testAllPropertiesInjected() { - BaseEventService service = (BaseEventService) injector.getInstance(EventService.class); - - assertNotNull(service.context); - } -} 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 deleted file mode 100644 index 23bad0ed4a..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/internal/BaseInjectionTest.java +++ /dev/null @@ -1,66 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.internal; - -import java.util.Properties; - -import org.jclouds.ContextBuilder; -import org.jclouds.abiquo.AbiquoApiMetadata; -import org.jclouds.abiquo.AbiquoContext; -import org.jclouds.lifecycle.Closer; -import org.jclouds.logging.config.NullLoggingModule; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableSet; -import com.google.inject.Injector; -import com.google.inject.Module; - -/** - * Unit tests for the {@link BaseCloudService} class. - * - * @author Ignasi Barrera - */ -@Test(groups = "unit", testName = "BaseEventServiceTest") -public class BaseInjectionTest { - protected Injector injector; - - @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(); - } - - @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 deleted file mode 100644 index 075894805e..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/internal/BaseMonitoringServiceTest.java +++ /dev/null @@ -1,95 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.internal; - -import static org.testng.Assert.assertNotNull; - -import org.jclouds.abiquo.features.services.MonitoringService; -import org.jclouds.abiquo.monitor.MonitorStatus; -import org.testng.annotations.Test; - -import com.google.common.base.Function; - -/** - * Unit tests for the {@link BaseMonitoringService} class. - * - * @author Ignasi Barrera - */ -@Test(groups = "unit", testName = "BaseMonitoringServiceTest") -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); - } - - @Test(expectedExceptions = NullPointerException.class) - public void testAwaitCompletionWithNullFunction() { - monitoringService().awaitCompletion(null, new Object[] {}); - } - - public void testAwaitCompletionWithoutTasks() { - BaseMonitoringService service = monitoringService(); - - 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); - } - - public void testMonitorWithoutTasks() { - monitoringService().monitor(new MockMonitor()); - } - - public void testDelegateToVirtualMachineMonitor() { - assertNotNull(monitoringService().getVirtualMachineMonitor()); - } - - public void testDelegateToVirtualApplianceMonitor() { - assertNotNull(monitoringService().getVirtualApplianceMonitor()); - } - - public void testDelegateToAsyncTaskMonitor() { - assertNotNull(monitoringService().getAsyncTaskMonitor()); - } - - public void testDelegateToConversioMonitor() { - assertNotNull(monitoringService().getConversionMonitor()); - } - - private BaseMonitoringService monitoringService() { - return injector.getInstance(BaseMonitoringService.class); - } - - 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 deleted file mode 100644 index 27f9e15edc..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/internal/BaseSearchServiceTest.java +++ /dev/null @@ -1,40 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.internal; - -import static org.testng.Assert.assertNotNull; - -import org.jclouds.abiquo.features.services.SearchService; -import org.testng.annotations.Test; - -/** - * Unit tests for the {@link BaseSearchService} class. - * - * @author Ignasi Barrera - */ -@Test(groups = "unit", testName = "BaseSearchServiceTest") -public class BaseSearchServiceTest extends BaseInjectionTest { - - public void testAllPropertiesInjected() { - BaseSearchService service = (BaseSearchService) injector.getInstance(SearchService.class); - - 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 deleted file mode 100644 index 90352de997..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/monitor/functions/AsyncTaskStatusMonitorTest.java +++ /dev/null @@ -1,100 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.monitor.functions; - -import static org.testng.Assert.assertEquals; - -import org.easymock.EasyMock; -import org.jclouds.abiquo.domain.task.AsyncTask; -import org.jclouds.abiquo.monitor.MonitorStatus; -import org.jclouds.rest.RestContext; -import org.testng.annotations.Test; - -import com.abiquo.server.core.task.TaskDto; -import com.abiquo.server.core.task.enums.TaskState; -import com.google.common.base.Function; - -/** - * Unit tests for the {@link AsyncTaskStatusMonitor} function. - * - * @author Serafin Sedano - */ -@Test(groups = "unit", testName = "AsyncTaskStatusMonitorTest") -public class AsyncTaskStatusMonitorTest { - - @Test(expectedExceptions = NullPointerException.class) - public void testInvalidNullArgument() { - Function function = new AsyncTaskStatusMonitor(); - function.apply(null); - } - - public void testReturnDone() { - TaskState[] states = { TaskState.FINISHED_SUCCESSFULLY }; - - checkStatesReturn(new MockAsyncTask(), new AsyncTaskStatusMonitor(), states, MonitorStatus.DONE); - } - - public void testReturnFail() { - TaskState[] states = { TaskState.ABORTED, TaskState.FINISHED_UNSUCCESSFULLY }; - - checkStatesReturn(new MockAsyncTask(), new AsyncTaskStatusMonitor(), states, MonitorStatus.FAILED); - } - - public void testReturnContinue() { - TaskState[] states = { TaskState.STARTED, TaskState.PENDING }; - - checkStatesReturn(new MockAsyncTask(), 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 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 - } - - 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"); - } - - } - -} 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 deleted file mode 100644 index 40007eef2d..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/monitor/functions/ConversionStatusMonitorTest.java +++ /dev/null @@ -1,100 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.monitor.functions; - -import static org.testng.Assert.assertEquals; - -import org.easymock.EasyMock; -import org.jclouds.abiquo.domain.cloud.Conversion; -import org.jclouds.abiquo.monitor.MonitorStatus; -import org.jclouds.rest.RestContext; -import org.testng.annotations.Test; - -import com.abiquo.model.enumerator.ConversionState; -import com.abiquo.server.core.appslibrary.ConversionDto; -import com.google.common.base.Function; - -/** - * Unit tests for the {@link ConversionStatusMonitor} function. - * - * @author Sergi Castro - */ -@Test(groups = "unit", testName = "ConversionStatusMonitorTest") -public class ConversionStatusMonitorTest { - - @Test(expectedExceptions = NullPointerException.class) - public void testInvalidNullArgument() { - Function function = new ConversionStatusMonitor(); - function.apply(null); - } - - public void testReturnDone() { - ConversionState[] states = { ConversionState.FINISHED }; - - checkStatesReturn(new MockConversion(), new ConversionStatusMonitor(), states, MonitorStatus.DONE); - } - - public void testReturnFail() { - ConversionState[] states = { ConversionState.FAILED }; - - checkStatesReturn(new MockConversion(), new ConversionStatusMonitor(), states, MonitorStatus.FAILED); - } - - public void testReturnContinue() { - ConversionState[] states = { ConversionState.ENQUEUED }; - - checkStatesReturn(new MockConversion(), 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 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 - } - - 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"); - } - - } - -} 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 deleted file mode 100644 index 31c2831304..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/monitor/functions/VirtualApplianceDeployMonitorTest.java +++ /dev/null @@ -1,104 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.monitor.functions; - -import static org.testng.Assert.assertEquals; - -import org.easymock.EasyMock; -import org.jclouds.abiquo.domain.cloud.VirtualAppliance; -import org.jclouds.abiquo.monitor.MonitorStatus; -import org.jclouds.rest.RestContext; -import org.testng.annotations.Test; - -import com.abiquo.server.core.cloud.VirtualApplianceDto; -import com.abiquo.server.core.cloud.VirtualApplianceState; -import com.google.common.base.Function; - -/** - * Unit tests for the {@link VirtualApplianceDeployMonitor} function. - * - * @author Serafin Sedano - */ -@Test(groups = "unit", testName = "VirtualApplianceDeployMonitorTest") -public class VirtualApplianceDeployMonitorTest { - - @Test(expectedExceptions = NullPointerException.class) - public void testInvalidNullArgument() { - Function function = new VirtualApplianceDeployMonitor(); - function.apply(null); - } - - public void testReturnDone() { - VirtualApplianceState[] states = { VirtualApplianceState.DEPLOYED }; - - checkStatesReturn(new MockVirtualAppliance(), new VirtualApplianceDeployMonitor(), states, MonitorStatus.DONE); - } - - public void testReturnFail() { - VirtualApplianceState[] states = { VirtualApplianceState.NEEDS_SYNC, VirtualApplianceState.UNKNOWN, - VirtualApplianceState.NOT_DEPLOYED }; - - checkStatesReturn(new MockVirtualAppliance(), new VirtualApplianceDeployMonitor(), states, MonitorStatus.FAILED); - } - - public void testReturnContinue() { - VirtualApplianceState[] states = { VirtualApplianceState.LOCKED }; - - checkStatesReturn(new MockVirtualAppliance(), 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 static class MockVirtualAppliance extends VirtualAppliance { - private VirtualApplianceState state; - - @SuppressWarnings("unchecked") - public MockVirtualAppliance() { - super(EasyMock.createMock(RestContext.class), new VirtualApplianceDto()); - } - - @Override - public VirtualApplianceState getState() { - return 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"); - } - - } -} 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 deleted file mode 100644 index c2b9b3ce8d..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/monitor/functions/VirtualApplianceUndeployMonitorTest.java +++ /dev/null @@ -1,105 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.monitor.functions; - -import static org.testng.Assert.assertEquals; - -import org.easymock.EasyMock; -import org.jclouds.abiquo.domain.cloud.VirtualAppliance; -import org.jclouds.abiquo.monitor.MonitorStatus; -import org.jclouds.rest.RestContext; -import org.testng.annotations.Test; - -import com.abiquo.server.core.cloud.VirtualApplianceDto; -import com.abiquo.server.core.cloud.VirtualApplianceState; -import com.google.common.base.Function; - -/** - * Unit tests for the {@link VirtualApplianceUndeployMonitor} function. - * - * @author Serafin Sedano - */ -@Test(groups = "unit", testName = "VirtualApplianceUndeployMonitorTest") -public class VirtualApplianceUndeployMonitorTest { - - @Test(expectedExceptions = NullPointerException.class) - public void testInvalidNullArgument() { - Function function = new VirtualApplianceUndeployMonitor(); - function.apply(null); - } - - public void testReturnDone() { - VirtualApplianceState[] states = { VirtualApplianceState.NOT_DEPLOYED }; - - checkStatesReturn(new MockVirtualAppliance(), new VirtualApplianceUndeployMonitor(), states, MonitorStatus.DONE); - } - - public void testReturnFail() { - VirtualApplianceState[] states = { VirtualApplianceState.DEPLOYED, VirtualApplianceState.NEEDS_SYNC, - VirtualApplianceState.UNKNOWN }; - - checkStatesReturn(new MockVirtualAppliance(), new VirtualApplianceUndeployMonitor(), states, MonitorStatus.FAILED); - } - - public void testReturnContinue() { - VirtualApplianceState[] states = { VirtualApplianceState.LOCKED }; - - checkStatesReturn(new MockVirtualAppliance(), 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 static class MockVirtualAppliance extends VirtualAppliance { - private VirtualApplianceState state; - - @SuppressWarnings("unchecked") - public MockVirtualAppliance() { - super(EasyMock.createMock(RestContext.class), new VirtualApplianceDto()); - } - - @Override - public VirtualApplianceState getState() { - return 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"); - } - - } -} 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 deleted file mode 100644 index 566e91bc13..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/monitor/functions/VirtualMachineDeployMonitorTest.java +++ /dev/null @@ -1,102 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.monitor.functions; - -import static org.testng.Assert.assertEquals; - -import org.easymock.EasyMock; -import org.jclouds.abiquo.domain.cloud.VirtualMachine; -import org.jclouds.abiquo.monitor.MonitorStatus; -import org.jclouds.rest.RestContext; -import org.testng.annotations.Test; - -import com.abiquo.server.core.cloud.VirtualMachineState; -import com.abiquo.server.core.cloud.VirtualMachineWithNodeExtendedDto; -import com.google.common.base.Function; - -/** - * Unit tests for the {@link VirtualMachineDeployMonitor} 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 void testReturnDone() { - VirtualMachineState[] states = { VirtualMachineState.ON }; - - checkStatesReturn(new MockVirtualMachine(), new VirtualMachineDeployMonitor(), states, MonitorStatus.DONE); - } - - public void testReturnFail() { - VirtualMachineState[] states = { VirtualMachineState.NOT_ALLOCATED, VirtualMachineState.UNKNOWN }; - - checkStatesReturn(new MockVirtualMachine(), new VirtualMachineDeployMonitor(), states, MonitorStatus.FAILED); - } - - public void testReturnContinue() { - VirtualMachineState[] states = { VirtualMachineState.ALLOCATED, VirtualMachineState.CONFIGURED, - VirtualMachineState.LOCKED, VirtualMachineState.OFF, VirtualMachineState.PAUSED }; - - checkStatesReturn(new MockVirtualMachine(), 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 static class MockVirtualMachine extends VirtualMachine { - private VirtualMachineState state; - - @SuppressWarnings("unchecked") - public MockVirtualMachine() { - super(EasyMock.createMock(RestContext.class), new VirtualMachineWithNodeExtendedDto()); - } - - @Override - public VirtualMachineState getState() { - return 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"); - } - - } -} 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 deleted file mode 100644 index fdc7e294b6..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/monitor/functions/VirtualMachineStateMonitorTest.java +++ /dev/null @@ -1,104 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.monitor.functions; - -import static org.testng.Assert.assertEquals; - -import org.easymock.EasyMock; -import org.jclouds.abiquo.domain.cloud.VirtualMachine; -import org.jclouds.abiquo.monitor.MonitorStatus; -import org.jclouds.rest.RestContext; -import org.testng.annotations.Test; - -import com.abiquo.server.core.cloud.VirtualMachineState; -import com.abiquo.server.core.cloud.VirtualMachineWithNodeExtendedDto; -import com.google.common.base.Function; - -/** - * Unit tests for the {@link VirtualMachineStateMonitor} function. - * - * @author Ignasi Barrera - */ -@Test(groups = "unit", testName = "VirtualMachineStateMonitorTest") -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); - } - - public void testReturnDone() { - VirtualMachineState[] states = { VirtualMachineState.ON }; - - checkStatesReturn(new MockVirtualMachine(), new VirtualMachineStateMonitor(VirtualMachineState.ON), states, - MonitorStatus.DONE); - } - - public void testReturnContinue() { - VirtualMachineState[] states = { VirtualMachineState.ALLOCATED, VirtualMachineState.CONFIGURED, - VirtualMachineState.LOCKED, VirtualMachineState.OFF, VirtualMachineState.PAUSED, - VirtualMachineState.NOT_ALLOCATED, VirtualMachineState.UNKNOWN }; - - checkStatesReturn(new MockVirtualMachine(), 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 static class MockVirtualMachine extends VirtualMachine { - private VirtualMachineState state; - - @SuppressWarnings("unchecked") - public MockVirtualMachine() { - super(EasyMock.createMock(RestContext.class), new VirtualMachineWithNodeExtendedDto()); - } - - @Override - public VirtualMachineState getState() { - return 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"); - } - - } -} 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 deleted file mode 100644 index 27ce26b8be..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/monitor/functions/VirtualMachineUndeployMonitorTest.java +++ /dev/null @@ -1,103 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.monitor.functions; - -import static org.testng.Assert.assertEquals; - -import org.easymock.EasyMock; -import org.jclouds.abiquo.domain.cloud.VirtualMachine; -import org.jclouds.abiquo.monitor.MonitorStatus; -import org.jclouds.rest.RestContext; -import org.testng.annotations.Test; - -import com.abiquo.server.core.cloud.VirtualMachineState; -import com.abiquo.server.core.cloud.VirtualMachineWithNodeExtendedDto; -import com.google.common.base.Function; - -/** - * Unit tests for the {@link VirtualMachineUndeployMonitor} function. - * - * @author Ignasi Barrera - */ -@Test(groups = "unit", testName = "VirtualMachineUndeployMonitorTest") -public class VirtualMachineUndeployMonitorTest { - - @Test(expectedExceptions = NullPointerException.class) - public void testInvalidNullArgument() { - Function function = new VirtualMachineUndeployMonitor(); - function.apply(null); - } - - public void testReturnDone() { - VirtualMachineState[] states = { VirtualMachineState.NOT_ALLOCATED }; - - checkStatesReturn(new MockVirtualMachine(), new VirtualMachineUndeployMonitor(), states, MonitorStatus.DONE); - } - - public void testReturnFail() { - VirtualMachineState[] states = { VirtualMachineState.ON, VirtualMachineState.CONFIGURED, VirtualMachineState.OFF, - VirtualMachineState.PAUSED, VirtualMachineState.UNKNOWN }; - - checkStatesReturn(new MockVirtualMachine(), new VirtualMachineUndeployMonitor(), states, MonitorStatus.FAILED); - } - - public void testReturnContinue() { - VirtualMachineState[] states = { VirtualMachineState.ALLOCATED, VirtualMachineState.LOCKED }; - - checkStatesReturn(new MockVirtualMachine(), 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 static class MockVirtualMachine extends VirtualMachine { - private VirtualMachineState state; - - @SuppressWarnings("unchecked") - public MockVirtualMachine() { - super(EasyMock.createMock(RestContext.class), new VirtualMachineWithNodeExtendedDto()); - } - - @Override - public VirtualMachineState getState() { - return 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"); - } - - } -} 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 deleted file mode 100644 index af6857bd63..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/monitor/internal/BaseAsyncTaskMonitorTest.java +++ /dev/null @@ -1,41 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.monitor.internal; - -import static org.testng.Assert.assertNotNull; - -import org.jclouds.abiquo.internal.BaseInjectionTest; -import org.jclouds.abiquo.monitor.AsyncTaskMonitor; -import org.testng.annotations.Test; - -/** - * Unit tests for the {@link BaseAsyncTaskMonitor} class. - * - * @author Ignasi Barrera - */ -@Test(groups = "unit", testName = "BaseAsyncTaskMonitorTest") -public class BaseAsyncTaskMonitorTest extends BaseInjectionTest { - - public void testAllPropertiesInjected() { - BaseAsyncTaskMonitor monitor = (BaseAsyncTaskMonitor) injector.getInstance(AsyncTaskMonitor.class); - - 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 deleted file mode 100644 index 6e5e62a1b6..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/monitor/internal/BaseVirtualApplianceMonitorTest.java +++ /dev/null @@ -1,43 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.monitor.internal; - -import static org.testng.Assert.assertNotNull; - -import org.jclouds.abiquo.internal.BaseInjectionTest; -import org.jclouds.abiquo.monitor.VirtualApplianceMonitor; -import org.testng.annotations.Test; - -/** - * Unit tests for the {@link BaseVirtualApplianceMonitor} class. - * - * @author Ignasi Barrera - */ -@Test(groups = "unit", testName = "BaseVirtualApplianceMonitorTest") -public class BaseVirtualApplianceMonitorTest extends BaseInjectionTest { - - public void testAllPropertiesInjected() { - BaseVirtualApplianceMonitor monitor = (BaseVirtualApplianceMonitor) injector - .getInstance(VirtualApplianceMonitor.class); - - 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 deleted file mode 100644 index 6c17a59ada..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/monitor/internal/BaseVirtualMachineMonitorTest.java +++ /dev/null @@ -1,42 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.monitor.internal; - -import static org.testng.Assert.assertNotNull; - -import org.jclouds.abiquo.internal.BaseInjectionTest; -import org.jclouds.abiquo.monitor.VirtualMachineMonitor; -import org.testng.annotations.Test; - -/** - * Unit tests for the {@link BaseVirtualMachineMonitor} class. - * - * @author Ignasi Barrera - */ -@Test(groups = "unit", testName = "BaseVirtualMachineMonitorTest") -public class BaseVirtualMachineMonitorTest extends BaseInjectionTest { - - public void testAllPropertiesInjected() { - BaseVirtualMachineMonitor monitor = (BaseVirtualMachineMonitor) injector.getInstance(VirtualMachineMonitor.class); - - 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 deleted file mode 100644 index b909d9b4d9..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/reference/AbiquoTestConstants.java +++ /dev/null @@ -1,30 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.reference; - -/** - * Configuration constants and properties used in Abiquo tests. - * - * @author Ignasi Barrera - */ -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 deleted file mode 100644 index a855ee973f..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/rest/internal/AbiquoHttpAsyncClientTest.java +++ /dev/null @@ -1,62 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.rest.internal; - -import static org.jclouds.reflect.Reflection2.method; - -import java.io.IOException; - -import org.jclouds.Fallbacks.NullOnNotFoundOr404; -import org.jclouds.abiquo.features.BaseAbiquoAsyncApiTest; -import org.jclouds.functions.IdentityFunction; -import org.jclouds.reflect.Invocation; -import org.jclouds.rest.internal.GeneratedHttpRequest; -import org.testng.annotations.Test; - -import com.abiquo.model.rest.RESTLink; -import com.abiquo.server.core.infrastructure.DatacentersDto; -import com.google.common.collect.ImmutableList; -import com.google.common.reflect.Invokable; - -/** - * Tests annotation parsing of {@code AbiquoHttpAsyncApi}. - * - * @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); - - Invokable method = method(AbiquoHttpAsyncClient.class, "get", RESTLink.class); - GeneratedHttpRequest request = processor.apply(Invocation.create(method, ImmutableList. of(link))); - - 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); - assertFallbackClassEquals(method, NullOnNotFoundOr404.class); - - checkFilters(request); - } -} 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 deleted file mode 100644 index a84bf558e9..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/BaseAbiquoStrategyLiveApiTest.java +++ /dev/null @@ -1,33 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.strategy; - -import org.jclouds.abiquo.internal.BaseAbiquoApiLiveApiTest; -import org.testng.annotations.BeforeClass; - -/** - * Base class for strategy live tests. - * - * @author Ignasi Barrera - */ -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/cloud/ListAttachedNicsLiveApiTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/cloud/ListAttachedNicsLiveApiTest.java deleted file mode 100644 index 4f3bbbb204..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/cloud/ListAttachedNicsLiveApiTest.java +++ /dev/null @@ -1,100 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.strategy.cloud; - -import static com.google.common.collect.Iterables.size; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertNull; - -import org.jclouds.abiquo.domain.network.ExternalIp; -import org.jclouds.abiquo.domain.network.Ip; -import org.jclouds.abiquo.domain.network.PrivateIp; -import org.jclouds.abiquo.domain.network.PublicIp; -import org.jclouds.abiquo.domain.network.UnmanagedNetwork; -import org.jclouds.abiquo.predicates.network.IpPredicates; -import org.jclouds.abiquo.strategy.BaseAbiquoStrategyLiveApiTest; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -import com.google.common.collect.Lists; - -/** - * Live tests for the {@link ListAttachedNics} strategy. - * - * @author Ignasi Barrera - */ -@Test(groups = "api", testName = "ListAttachedNicsLiveApiTest") -public class ListAttachedNicsLiveApiTest extends BaseAbiquoStrategyLiveApiTest { - private ListAttachedNics strategy; - - private PrivateIp privateIp; - - private ExternalIp externalIp; - - private PublicIp publicIp; - - @Override - @BeforeClass(groups = "api") - protected void setupStrategy() { - this.strategy = env.context.getUtils().getInjector().getInstance(ListAttachedNics.class); - - privateIp = env.privateNetwork.listUnusedIps().get(0); - assertNotNull(privateIp); - - 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); - - 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.releasePublicIp(publicIp); - assertNull(env.virtualDatacenter.findPurchasedPublicIp(IpPredicates. address(address))); - } - - public void testExecute() { - Iterable> vapps = strategy.execute(env.virtualMachine); - assertNotNull(vapps); - assertEquals(4, size(vapps)); - } - - 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); - } -} diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/cloud/ListVirtualAppliancesLiveApiTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/cloud/ListVirtualAppliancesLiveApiTest.java deleted file mode 100644 index 981d4c29ac..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/cloud/ListVirtualAppliancesLiveApiTest.java +++ /dev/null @@ -1,67 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.strategy.cloud; - -import static com.google.common.collect.Iterables.size; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertTrue; - -import org.jclouds.abiquo.domain.cloud.VirtualAppliance; -import org.jclouds.abiquo.predicates.cloud.VirtualAppliancePredicates; -import org.jclouds.abiquo.strategy.BaseAbiquoStrategyLiveApiTest; -import org.jclouds.abiquo.strategy.cloud.ListVirtualAppliances; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -/** - * Live tests for the {@link ListVirtualAppliances} strategy. - * - * @author Ignasi Barrera - */ -@Test(groups = "api", testName = "ListVirtualAppliancesLiveApiTest") -public class ListVirtualAppliancesLiveApiTest extends BaseAbiquoStrategyLiveApiTest { - private ListVirtualAppliances strategy; - - @Override - @BeforeClass(groups = "api") - protected void setupStrategy() { - this.strategy = env.context.getUtils().getInjector().getInstance(ListVirtualAppliances.class); - } - - 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 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/ListVirtualDatacentersLiveApiTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/cloud/ListVirtualDatacentersLiveApiTest.java deleted file mode 100644 index f8b1666a4a..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/cloud/ListVirtualDatacentersLiveApiTest.java +++ /dev/null @@ -1,82 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.strategy.cloud; - -import static com.google.common.collect.Iterables.size; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertTrue; - -import org.jclouds.abiquo.domain.cloud.VirtualDatacenter; -import org.jclouds.abiquo.domain.cloud.options.VirtualDatacenterOptions; -import org.jclouds.abiquo.predicates.cloud.VirtualDatacenterPredicates; -import org.jclouds.abiquo.strategy.BaseAbiquoStrategyLiveApiTest; -import org.jclouds.abiquo.strategy.cloud.ListVirtualDatacenters; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -/** - * Live tests for the {@link ListVirtualDatacenters} strategy. - * - * @author Ignasi Barrera - */ -@Test(groups = "api", testName = "ListVirtualDatacentersLiveApiTest") -public class ListVirtualDatacentersLiveApiTest extends BaseAbiquoStrategyLiveApiTest { - private ListVirtualDatacenters strategy; - - @Override - @BeforeClass(groups = "api") - protected void setupStrategy() { - this.strategy = env.context.getUtils().getInjector().getInstance(ListVirtualDatacenters.class); - } - - 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 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 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/ListVirtualMachinesLiveApiTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/cloud/ListVirtualMachinesLiveApiTest.java deleted file mode 100644 index 9b4cc3e4f1..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/cloud/ListVirtualMachinesLiveApiTest.java +++ /dev/null @@ -1,97 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.strategy.cloud; - -import static com.google.common.collect.Iterables.size; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertTrue; - -import java.util.List; - -import com.google.common.collect.Lists; - -import org.jclouds.abiquo.domain.cloud.VirtualMachine; -import org.jclouds.abiquo.predicates.cloud.VirtualMachinePredicates; -import org.jclouds.abiquo.strategy.BaseAbiquoStrategyLiveApiTest; -import org.jclouds.abiquo.strategy.cloud.ListVirtualMachines; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -/** - * Live tests for the {@link ListVirtualMachines} strategy. - * - * @author Ignasi Barrera - */ -@Test(groups = "api", testName = "ListVirtualMachinesLiveApiTest") -public class ListVirtualMachinesLiveApiTest extends BaseAbiquoStrategyLiveApiTest { - private ListVirtualMachines strategy; - - @Override - @BeforeClass(groups = "api") - protected void setupStrategy() { - this.strategy = env.context.getUtils().getInjector().getInstance(ListVirtualMachines.class); - } - - 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 testExecutePredicateWithResults() { - Iterable vms = strategy.execute(VirtualMachinePredicates.internalName(env.virtualMachine - .getInternalName())); - assertNotNull(vms); - assertEquals(size(vms), 1); - } - - public void testExecuteWhenExceedsPagination() { - List vms = Lists.newArrayList(); - - // 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); - } - - try { - Iterable all = strategy.execute(); - - 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/enterprise/ListVirtualMachineTemplatesLiveApiTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/enterprise/ListVirtualMachineTemplatesLiveApiTest.java deleted file mode 100644 index 04d830297d..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/enterprise/ListVirtualMachineTemplatesLiveApiTest.java +++ /dev/null @@ -1,70 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.strategy.enterprise; - -import static com.google.common.collect.Iterables.size; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertTrue; - -import org.jclouds.abiquo.domain.cloud.VirtualMachineTemplate; -import org.jclouds.abiquo.predicates.cloud.VirtualMachineTemplatePredicates; -import org.jclouds.abiquo.strategy.BaseAbiquoStrategyLiveApiTest; -import org.jclouds.abiquo.strategy.cloud.ListVirtualAppliances; -import org.jclouds.abiquo.strategy.enterprise.ListVirtualMachineTemplates; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -/** - * Live tests for the {@link ListVirtualAppliances} strategy. - * - * @author Ignasi Barrera - */ -@Test(groups = "api", testName = "ListVirtualMachineTemplatesLiveApiTest") -public class ListVirtualMachineTemplatesLiveApiTest extends BaseAbiquoStrategyLiveApiTest { - private ListVirtualMachineTemplates strategy; - - @Override - @BeforeClass(groups = "api") - protected void setupStrategy() { - this.strategy = env.context.getUtils().getInjector().getInstance(ListVirtualMachineTemplates.class); - } - - 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 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/ListMachinesLiveApiTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/infrastructure/ListMachinesLiveApiTest.java deleted file mode 100644 index 011ed71784..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/infrastructure/ListMachinesLiveApiTest.java +++ /dev/null @@ -1,66 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.strategy.infrastructure; - -import static com.google.common.collect.Iterables.size; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertTrue; - -import org.jclouds.abiquo.domain.infrastructure.Machine; -import org.jclouds.abiquo.predicates.infrastructure.MachinePredicates; -import org.jclouds.abiquo.strategy.BaseAbiquoStrategyLiveApiTest; -import org.jclouds.abiquo.strategy.infrastructure.ListMachines; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -/** - * Live tests for the {@link ListMachines} strategy. - * - * @author Ignasi Barrera - */ -@Test(groups = "api", testName = "ListMachinesLiveApiTest") -public class ListMachinesLiveApiTest extends BaseAbiquoStrategyLiveApiTest { - private ListMachines strategy; - - @Override - @BeforeClass(groups = "api") - protected void setupStrategy() { - this.strategy = env.context.getUtils().getInjector().getInstance(ListMachines.class); - } - - 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 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 deleted file mode 100644 index dcbf9d8904..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/util/Assert.java +++ /dev/null @@ -1,81 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.util; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; - -import java.io.IOException; - -import javax.ws.rs.core.Response.Status; - -import org.jclouds.abiquo.domain.exception.AbiquoException; -import org.jclouds.io.Payload; -import org.jclouds.xml.XMLParser; -import org.jclouds.xml.internal.JAXBParser; - -import com.abiquo.model.transport.SingleResourceTransportDto; -import com.abiquo.model.transport.error.ErrorDto; - -/** - * Assertion utilities. - * - * @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); - } - - /** - * 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); - } -} 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 deleted file mode 100644 index f2c2eae504..0000000000 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/util/Config.java +++ /dev/null @@ -1,70 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.abiquo.util; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.io.IOException; -import java.util.Properties; - -/** - * Test configuration. - * - * @author Ignasi Barrera - */ -public class Config { - /** The main configuration file. */ - private static final String CONFIG_FILE = "api-live.properties"; - - /** The configuration properties */ - private Properties config; - - /** The singleton configuration instance. */ - private static Config instance; - - 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); - } - } - - 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, 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)); - } - -} diff --git a/labs/abiquo/src/test/resources/api-live.properties b/labs/abiquo/src/test/resources/api-live.properties deleted file mode 100644 index a452389f85..0000000000 --- a/labs/abiquo/src/test/resources/api-live.properties +++ /dev/null @@ -1,20 +0,0 @@ -# Hypervisor configuration -abiquo.hypervisor.type = ${abiquo.hypervisor.type} -abiquo.hypervisor.address = ${abiquo.hypervisor.address} -abiquo.hypervisor.user = ${abiquo.hypervisor.user} -abiquo.hypervisor.pass = ${abiquo.hypervisor.pass} -abiquo.hypervisor.vswitch = ${abiquo.hypervisor.vswitch} -abiquo.hypervisor.datastore = ${abiquo.hypervisor.datastore} - -# Storage configuration -abiquo.storage.type = ${abiquo.storage.type} -abiquo.storage.address = ${abiquo.storage.address} -abiquo.storage.pass = ${abiquo.storage.pass} -abiquo.storage.user = ${abiquo.storage.user} -abiquo.storage.pool = ${abiquo.storage.pool} - -# UCS Rack configuration -abiquo.ucs.address = ${abiquo.ucs.address} -abiquo.ucs.port = ${abiquo.ucs.port} -abiquo.ucs.pass = ${abiquo.ucs.pass} -abiquo.ucs.user = ${abiquo.ucs.user} diff --git a/labs/abiquo/src/test/resources/filters/filters.properties b/labs/abiquo/src/test/resources/filters/filters.properties deleted file mode 100644 index 3cc64956be..0000000000 --- a/labs/abiquo/src/test/resources/filters/filters.properties +++ /dev/null @@ -1,26 +0,0 @@ -# Hypervisor configuration -# This is the Tarantino IT hypervisor. -# Should be replaced with a dedicated ESX asap! - -abiquo.hypervisor.pass=tarantino -abiquo.hypervisor.address=10.60.1.132 -abiquo.hypervisor.datastore=nfs-ds -abiquo.hypervisor.type=VMX_04 -#abiquo.hypervisor.address=10.60.20.62 -#abiquo.hypervisor.pass=temporal -abiquo.hypervisor.user=root -abiquo.hypervisor.vswitch=vSwitch0 -#abiquo.hypervisor.datastore=datastore1 - -# Storage configuration -abiquo.storage.type=LVM -abiquo.storage.address=10.60.12.177 -#abiquo.storage.user= -#abiquo.storage.pass= -abiquo.storage.pool=abiquo - -# UCS Rack configuration -abiquo.ucs.address=10.60.1.45 -abiquo.ucs.port=80 -abiquo.ucs.pass=config -abiquo.ucs.user=config \ No newline at end of file diff --git a/labs/abiquo/src/test/resources/license/expired b/labs/abiquo/src/test/resources/license/expired deleted file mode 100644 index 1db9f513ae..0000000000 --- a/labs/abiquo/src/test/resources/license/expired +++ /dev/null @@ -1 +0,0 @@ -B9cG06GaLHhUlpD9AWxKVkZPd4qPB0OAbm2Blr4374Y6rtPhcukg4MMLNK0uWn5fnsoBSqVX8o0hwQ1I6D3zUbFBSibMaK5xIZQfZmReHf04HPPBg0ZyaPRTBoKy6dCLnWpQIKe8vLemAudZ0w4spdzYMH2jw2TImN+2vd4QDU1qmUItYMsV5Sz+e8YVEGbUVkjRjQCmIUJskVxC+sW47dokgl5Qo8hN+4I6vKgEnXFdOSRFW2cyGgpHVH4Js4hwLG+PS2LXPS4UwvISJXRF6tO7Rgg9iaObcBD/byH5jGmggtSECUtXqI70nesIbMXRHQ1aGHARqbHH3+0Znjcu5g== \ No newline at end of file diff --git a/labs/abiquo/src/test/resources/logback-test.xml b/labs/abiquo/src/test/resources/logback-test.xml deleted file mode 100644 index 70a88e8ba3..0000000000 --- a/labs/abiquo/src/test/resources/logback-test.xml +++ /dev/null @@ -1,94 +0,0 @@ - - - - target/test-data/jclouds-headers.log - true - - TRACE - - - %date %level [%logger] \(%thread\) %msg%n - - - - target/test-data/jclouds-headers.log.%d - 5 - - - - target/test-data/jclouds-payloads.log - true - - TRACE - - - %date %level [%logger] \(%thread\) %msg%n - - - - target/test-data/jclouds-payloads.log.%d - 5 - - - - target/test-data/jclouds-compute.log - true - - TRACE - - - %date %level [%logger] \(%thread\) %msg%n - - - - target/test-data/jclouds-compute.log.%d - 5 - - - - target/test-data/jclouds.log - true - - TRACE - - - %date %level [%logger] \(%thread\) %msg%n - - - - target/test-data/jclouds.log.%d - 5 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/labs/abiquo/src/test/resources/payloads/nst-create.xml b/labs/abiquo/src/test/resources/payloads/nst-create.xml deleted file mode 100644 index aa34c41b11..0000000000 --- a/labs/abiquo/src/test/resources/payloads/nst-create.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - true - Service Network - diff --git a/labs/abiquo/src/test/resources/payloads/nst-edit.xml b/labs/abiquo/src/test/resources/payloads/nst-edit.xml deleted file mode 100644 index 97b1ee6e51..0000000000 --- a/labs/abiquo/src/test/resources/payloads/nst-edit.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - true - 1 - Service Network - diff --git a/labs/abiquo/src/test/resources/payloads/nst-list.xml b/labs/abiquo/src/test/resources/payloads/nst-list.xml deleted file mode 100644 index c818448dac..0000000000 --- a/labs/abiquo/src/test/resources/payloads/nst-list.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - true - 1 - Service Network - - - - false - 2 - Storage Network - - \ No newline at end of file diff --git a/labs/aws-elb/README.txt b/labs/aws-elb/README.txt deleted file mode 100644 index 43661f148a..0000000000 --- a/labs/aws-elb/README.txt +++ /dev/null @@ -1,27 +0,0 @@ -==== - Licensed to jclouds, Inc. (jclouds) under one or more - contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. jclouds licenses this file - to you under the Apache License, Version 2.0 (the - "License"); you may not use this file except in compliance - with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, - software distributed under the License is distributed on an - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - KIND, either express or implied. See the License for the - specific language governing permissions and limitations - under the License. -==== - -# -# The jclouds provider for Amazon's Elastic Load Balancing (http://aws.amazon.com/elasticloadbalancing/). -# -# Expects the jclouds elb API to be present on your application's classpath. -# -# TODO: Implementation status. -# TODO: Supported features. -# TODO: Usage example. diff --git a/labs/aws-elb/pom.xml b/labs/aws-elb/pom.xml deleted file mode 100644 index 9fbfc5429f..0000000000 --- a/labs/aws-elb/pom.xml +++ /dev/null @@ -1,155 +0,0 @@ - - - - 4.0.0 - - org.jclouds.labs - jclouds-labs-project - 1.7.0-SNAPSHOT - ../project/pom.xml - - aws-elb - jclouds Amazon Elastic Load Balancer provider - Elastic Load Balancer implementation targeted to Amazon Web Services - bundle - - - https://elasticloadbalancing.us-east-1.amazonaws.com - 2012-06-01 - - ${test.aws.identity} - ${test.aws.credential} - aws-ec2 - - - - ${test.aws.identity} - ${test.aws.credential} - - - org.jclouds.aws.elb*;version="${project.version}" - - org.jclouds.labs*;version="${project.version}", - org.jclouds*;version="${jclouds.version}", - * - - - - - - org.jclouds.labs - elb - ${project.version} - - - org.jclouds.labs - elb - ${project.version} - test-jar - test - - - org.jclouds - jclouds-core - ${jclouds.version} - test-jar - test - - - org.jclouds - jclouds-loadbalancer - ${jclouds.version} - test-jar - test - - - org.jclouds - jclouds-compute - ${jclouds.version} - test-jar - test - - - org.jclouds.provider - aws-ec2 - ${jclouds.version} - test - - - org.jclouds.driver - jclouds-sshj - ${jclouds.version} - test - - - org.jclouds.driver - jclouds-slf4j - ${jclouds.version} - test - - - ch.qos.logback - logback-classic - test - - - - - - live - - - - org.apache.maven.plugins - maven-surefire-plugin - - - integration - integration-test - - test - - - - ${test.aws-elb.endpoint} - ${test.aws-elb.api-version} - ${test.aws-elb.build-version} - ${test.aws-elb.identity} - ${test.aws-elb.credential} - ${test.aws-elb.compute.provider} - ${test.aws-elb.compute.endpoint} - ${test.aws-elb.compute.build-version} - ${test.aws-elb.compute.api-version} - ${test.aws-elb.compute.identity} - ${test.aws-elb.compute.credential} - ${test.aws-elb.compute.template} - - - - - - - - - - - diff --git a/labs/aws-elb/src/main/java/org/jclouds/aws/elb/AWSELBProviderMetadata.java b/labs/aws-elb/src/main/java/org/jclouds/aws/elb/AWSELBProviderMetadata.java deleted file mode 100644 index 3e04029f28..0000000000 --- a/labs/aws-elb/src/main/java/org/jclouds/aws/elb/AWSELBProviderMetadata.java +++ /dev/null @@ -1,109 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.aws.elb; - -import static org.jclouds.aws.domain.Region.AP_NORTHEAST_1; -import static org.jclouds.aws.domain.Region.AP_SOUTHEAST_1; -import static org.jclouds.aws.domain.Region.AP_SOUTHEAST_2; -import static org.jclouds.aws.domain.Region.EU_WEST_1; -import static org.jclouds.aws.domain.Region.SA_EAST_1; -import static org.jclouds.aws.domain.Region.US_EAST_1; -import static org.jclouds.aws.domain.Region.US_WEST_1; -import static org.jclouds.aws.domain.Region.US_WEST_2; -import static org.jclouds.aws.reference.AWSConstants.PROPERTY_ZONECLIENT_ENDPOINT; -import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGION; - -import java.net.URI; -import java.util.Properties; - -import org.jclouds.aws.domain.Region; -import org.jclouds.elb.ELBApiMetadata; -import org.jclouds.providers.ProviderMetadata; -import org.jclouds.providers.internal.BaseProviderMetadata; - -/** - * Implementation of @ link org.jclouds.types.ProviderMetadata} for Amazon's Elastic Load Balancing - * provider. - * - * @author Adrian Cole - */ -public class AWSELBProviderMetadata extends BaseProviderMetadata { - - public static Builder builder() { - return new Builder(); - } - - @Override - public Builder toBuilder() { - return Builder.class.cast(builder().fromProviderMetadata(this)); - } - - public AWSELBProviderMetadata() { - super(builder()); - } - - public AWSELBProviderMetadata(Builder builder) { - super(builder); - } - - public static Properties defaultProperties() { - Properties properties = new Properties(); - properties.putAll(Region.regionProperties()); - properties.setProperty(PROPERTY_REGION + "." + US_EAST_1 + ".endpoint", - "https://elasticloadbalancing.us-east-1.amazonaws.com"); - properties.setProperty(PROPERTY_REGION + "." + US_WEST_1 + ".endpoint", - "https://elasticloadbalancing.us-west-1.amazonaws.com"); - properties.setProperty(PROPERTY_REGION + "." + US_WEST_2 + ".endpoint", - "https://elasticloadbalancing.us-west-2.amazonaws.com"); - properties.setProperty(PROPERTY_REGION + "." + SA_EAST_1 + ".endpoint", - "https://elasticloadbalancing.sa-east-1.amazonaws.com"); - properties.setProperty(PROPERTY_REGION + "." + EU_WEST_1 + ".endpoint", - "https://elasticloadbalancing.eu-west-1.amazonaws.com"); - properties.setProperty(PROPERTY_REGION + "." + AP_SOUTHEAST_1 + ".endpoint", - "https://elasticloadbalancing.ap-southeast-1.amazonaws.com"); - properties.setProperty(PROPERTY_REGION + "." + AP_SOUTHEAST_2 + ".endpoint", - "https://elasticloadbalancing.ap-southeast-2.amazonaws.com"); - properties.setProperty(PROPERTY_REGION + "." + AP_NORTHEAST_1 + ".endpoint", - "https://elasticloadbalancing.ap-northeast-1.amazonaws.com"); - properties.setProperty(PROPERTY_ZONECLIENT_ENDPOINT, "https://ec2.us-east-1.amazonaws.com"); - return properties; - } - - public static class Builder extends BaseProviderMetadata.Builder { - - protected Builder(){ - id("aws-elb") - .name("Amazon Elastic Load Balancing") - .endpoint("https://elasticloadbalancing.us-east-1.amazonaws.com") - .homepage(URI.create("http://aws.amazon.com/elasticloadbalancing")) - .console(URI.create("https://console.aws.amazon.com/ec2/home")) - .linkedServices("aws-ec2","aws-elb", "aws-cloudwatch", "aws-s3", "aws-simpledb") - .iso3166Codes("US-VA", "US-CA", "BR-SP", "US-OR", "IE", "SG", "AU-NSW", "JP-13") - .apiMetadata(new ELBApiMetadata()) - .defaultProperties(AWSELBProviderMetadata.defaultProperties()); - } - - @Override - public Builder fromProviderMetadata( - ProviderMetadata in) { - super.fromProviderMetadata(in); - return this; - } - } -} diff --git a/labs/aws-elb/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata b/labs/aws-elb/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata deleted file mode 100644 index 6b88bf79db..0000000000 --- a/labs/aws-elb/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata +++ /dev/null @@ -1 +0,0 @@ -org.jclouds.aws.elb.AWSELBProviderMetadata diff --git a/labs/aws-elb/src/test/java/org/jclouds/aws/elb/AWSELBProviderTest.java b/labs/aws-elb/src/test/java/org/jclouds/aws/elb/AWSELBProviderTest.java deleted file mode 100644 index 2d1f4e9df6..0000000000 --- a/labs/aws-elb/src/test/java/org/jclouds/aws/elb/AWSELBProviderTest.java +++ /dev/null @@ -1,36 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.aws.elb; - -import org.jclouds.elb.ELBApiMetadata; -import org.jclouds.providers.internal.BaseProviderMetadataTest; -import org.testng.annotations.Test; - -/** - * The AWSELBProviderTest tests the org.jclouds.providers.AWSELBProvider class. - * - * @author Adrian Cole - */ -@Test(groups = "unit", testName = "AWSELBProviderTest") -public class AWSELBProviderTest extends BaseProviderMetadataTest { - - public AWSELBProviderTest() { - super(new AWSELBProviderMetadata(), new ELBApiMetadata()); - } -} diff --git a/labs/aws-elb/src/test/java/org/jclouds/aws/elb/features/AWSAvailabilityZoneApiLiveTest.java b/labs/aws-elb/src/test/java/org/jclouds/aws/elb/features/AWSAvailabilityZoneApiLiveTest.java deleted file mode 100644 index 77f3b92e89..0000000000 --- a/labs/aws-elb/src/test/java/org/jclouds/aws/elb/features/AWSAvailabilityZoneApiLiveTest.java +++ /dev/null @@ -1,35 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.aws.elb.features; - -import org.jclouds.elb.features.AvailabilityZoneApiLiveTest; -import org.testng.annotations.Test; - -/** - * - * @author Adrian Cole - */ -@Test(groups = "live", testName = "AWSAvailabilityZoneApiLiveTest") -public class AWSAvailabilityZoneApiLiveTest extends AvailabilityZoneApiLiveTest { - - public AWSAvailabilityZoneApiLiveTest() { - provider = "aws-elb"; - } - -} diff --git a/labs/aws-elb/src/test/java/org/jclouds/aws/elb/features/AWSInstanceApiLiveTest.java b/labs/aws-elb/src/test/java/org/jclouds/aws/elb/features/AWSInstanceApiLiveTest.java deleted file mode 100644 index 5f6a7942c0..0000000000 --- a/labs/aws-elb/src/test/java/org/jclouds/aws/elb/features/AWSInstanceApiLiveTest.java +++ /dev/null @@ -1,35 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.aws.elb.features; - -import org.jclouds.elb.features.InstanceApiLiveTest; -import org.testng.annotations.Test; - -/** - * - * @author Adrian Cole - */ -@Test(groups = "live", testName = "AWSInstanceApiLiveTest") -public class AWSInstanceApiLiveTest extends InstanceApiLiveTest { - - public AWSInstanceApiLiveTest() { - provider = "aws-elb"; - } - -} diff --git a/labs/aws-elb/src/test/java/org/jclouds/aws/elb/features/AWSLoadBalancerApiLiveTest.java b/labs/aws-elb/src/test/java/org/jclouds/aws/elb/features/AWSLoadBalancerApiLiveTest.java deleted file mode 100644 index b6ab3f3c58..0000000000 --- a/labs/aws-elb/src/test/java/org/jclouds/aws/elb/features/AWSLoadBalancerApiLiveTest.java +++ /dev/null @@ -1,35 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.aws.elb.features; - -import org.jclouds.elb.features.LoadBalancerApiLiveTest; -import org.testng.annotations.Test; - -/** - * - * @author Adrian Cole - */ -@Test(groups = "live", testName = "AWSLoadBalancerApiLiveTest") -public class AWSLoadBalancerApiLiveTest extends LoadBalancerApiLiveTest { - - public AWSLoadBalancerApiLiveTest() { - provider = "aws-elb"; - } - -} diff --git a/labs/aws-elb/src/test/java/org/jclouds/aws/elb/features/AWSPolicyApiLiveTest.java b/labs/aws-elb/src/test/java/org/jclouds/aws/elb/features/AWSPolicyApiLiveTest.java deleted file mode 100644 index f1bc7429c4..0000000000 --- a/labs/aws-elb/src/test/java/org/jclouds/aws/elb/features/AWSPolicyApiLiveTest.java +++ /dev/null @@ -1,35 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.aws.elb.features; - -import org.jclouds.elb.features.PolicyApiLiveTest; -import org.testng.annotations.Test; - -/** - * - * @author Adrian Cole - */ -@Test(groups = "live", testName = "AWSPolicyApiLiveTest") -public class AWSPolicyApiLiveTest extends PolicyApiLiveTest { - - public AWSPolicyApiLiveTest() { - provider = "aws-elb"; - } - -} diff --git a/labs/aws-elb/src/test/java/org/jclouds/aws/elb/loadbalancer/AWSELBLoadBalancerServiceLiveTest.java b/labs/aws-elb/src/test/java/org/jclouds/aws/elb/loadbalancer/AWSELBLoadBalancerServiceLiveTest.java deleted file mode 100644 index 6e8b85b09e..0000000000 --- a/labs/aws-elb/src/test/java/org/jclouds/aws/elb/loadbalancer/AWSELBLoadBalancerServiceLiveTest.java +++ /dev/null @@ -1,37 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.aws.elb.loadbalancer; - -import org.jclouds.elb.loadbalancer.ELBLoadBalancerServiceLiveTest; -import org.testng.annotations.Test; - -/** - * - * @author Adrian Cole - */ -@Test(groups = "live", singleThreaded = true, testName = "AWSELBLoadBalancerServiceLiveTest") -public class AWSELBLoadBalancerServiceLiveTest extends ELBLoadBalancerServiceLiveTest { - - public AWSELBLoadBalancerServiceLiveTest() { - provider = "aws-elb"; - computeProvider = "aws-ec2"; - group = "elb"; - } - -} diff --git a/labs/aws-iam/pom.xml b/labs/aws-iam/pom.xml deleted file mode 100644 index 9a6d4492e6..0000000000 --- a/labs/aws-iam/pom.xml +++ /dev/null @@ -1,110 +0,0 @@ - - - - 4.0.0 - - org.jclouds.labs - jclouds-labs-project - 1.7.0-SNAPSHOT - ../project/pom.xml - - aws-iam - jclouds Amazon Identity and Access Management (IAM) provider - Identity and Access Management (IAM) to Amazon Web Services - bundle - - - https://iam.amazonaws.com - 2010-05-08 - - ${test.aws.identity} - ${test.aws.credential} - - org.jclouds.aws.iam*;version="${project.version}" - - org.jclouds.labs*;version="${project.version}", - org.jclouds*;version="${jclouds.version}", - * - - - - - - org.jclouds.labs - iam - ${project.version} - - - org.jclouds.labs - iam - ${project.version} - test-jar - test - - - org.jclouds - jclouds-core - ${jclouds.version} - test-jar - test - - - org.jclouds.driver - jclouds-log4j - ${jclouds.version} - test - - - - - - live - - - - org.apache.maven.plugins - maven-surefire-plugin - - - integration - integration-test - - test - - - - ${test.aws-iam.endpoint} - ${test.aws-iam.api-version} - ${test.aws-iam.build-version} - ${test.aws-iam.identity} - ${test.aws-iam.credential} - - - - - - - - - - - diff --git a/labs/aws-iam/src/main/java/org/jclouds/aws/iam/AWSIAMProviderMetadata.java b/labs/aws-iam/src/main/java/org/jclouds/aws/iam/AWSIAMProviderMetadata.java deleted file mode 100644 index 03fa0dcc8c..0000000000 --- a/labs/aws-iam/src/main/java/org/jclouds/aws/iam/AWSIAMProviderMetadata.java +++ /dev/null @@ -1,84 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.aws.iam; - -import java.net.URI; -import java.util.Properties; - -import org.jclouds.iam.IAMApiMetadata; -import org.jclouds.providers.ProviderMetadata; -import org.jclouds.providers.internal.BaseProviderMetadata; - -/** - * Implementation of @ link org.jclouds.types.ProviderMetadata} for Amazon's IAM - * provider. -* -* @author Adrian Cole -*/ -public class AWSIAMProviderMetadata extends BaseProviderMetadata { - - public static Builder builder() { - return new Builder(); - } - - @Override - public Builder toBuilder() { - return builder().fromProviderMetadata(this); - } - - public AWSIAMProviderMetadata() { - super(builder()); - } - - public AWSIAMProviderMetadata(Builder builder) { - super(builder); - } - - public static Properties defaultProperties() { - Properties properties = new Properties(); - return properties; - } - - public static class Builder extends BaseProviderMetadata.Builder { - - protected Builder(){ - id("aws-iam") - .name("Amazon IAM") - .endpoint("https://iam.amazonaws.com") - .homepage(URI.create("http://aws.amazon.com/iam")) - .console(URI.create("https://console.aws.amazon.com/iam/home")) - .linkedServices("aws-ec2","aws-elb", "aws-cloudwatch", "aws-s3", "aws-simpledb") - .iso3166Codes("US-VA", "US-CA", "BR-SP", "US-OR", "IE", "SG", "AU-NSW", "JP-13") - .apiMetadata(new IAMApiMetadata()) - .defaultProperties(AWSIAMProviderMetadata.defaultProperties()); - } - - @Override - public AWSIAMProviderMetadata build() { - return new AWSIAMProviderMetadata(this); - } - - @Override - public Builder fromProviderMetadata(ProviderMetadata in) { - super.fromProviderMetadata(in); - return this; - } - - } -} diff --git a/labs/aws-iam/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata b/labs/aws-iam/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata deleted file mode 100644 index 9f5ac036a9..0000000000 --- a/labs/aws-iam/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata +++ /dev/null @@ -1 +0,0 @@ -org.jclouds.aws.iam.AWSIAMProviderMetadata diff --git a/labs/aws-iam/src/test/java/org/jclouds/aws/iam/AWSIAMApiLiveTest.java b/labs/aws-iam/src/test/java/org/jclouds/aws/iam/AWSIAMApiLiveTest.java deleted file mode 100644 index bb7e73455c..0000000000 --- a/labs/aws-iam/src/test/java/org/jclouds/aws/iam/AWSIAMApiLiveTest.java +++ /dev/null @@ -1,35 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.aws.iam; - -import org.jclouds.iam.IAMApiLiveTest; -import org.testng.annotations.Test; - -/** - * Tests behavior of {@code IAMApi} - * - * @author Adrian Cole - */ -@Test(groups = "live", singleThreaded = true, testName = "AWSIAMApiLiveTest") -public class AWSIAMApiLiveTest extends IAMApiLiveTest { - public AWSIAMApiLiveTest() { - provider = "aws-iam"; - } - -} diff --git a/labs/aws-iam/src/test/java/org/jclouds/aws/iam/AWSIAMProviderTest.java b/labs/aws-iam/src/test/java/org/jclouds/aws/iam/AWSIAMProviderTest.java deleted file mode 100644 index 577a23e9d5..0000000000 --- a/labs/aws-iam/src/test/java/org/jclouds/aws/iam/AWSIAMProviderTest.java +++ /dev/null @@ -1,37 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.aws.iam; - -import org.jclouds.aws.iam.AWSIAMProviderMetadata; -import org.jclouds.iam.IAMApiMetadata; -import org.jclouds.providers.internal.BaseProviderMetadataTest; -import org.testng.annotations.Test; - -/** - * The AWSIAMProviderTest tests the org.jclouds.providers.AWSIAMProvider class. - * - * @author Adrian Cole - */ -@Test(groups = "unit", testName = "AWSIAMProviderTest") -public class AWSIAMProviderTest extends BaseProviderMetadataTest { - - public AWSIAMProviderTest() { - super(new AWSIAMProviderMetadata(), new IAMApiMetadata()); - } -} diff --git a/labs/aws-iam/src/test/java/org/jclouds/aws/iam/features/AWSInstanceProfileApiLiveTest.java b/labs/aws-iam/src/test/java/org/jclouds/aws/iam/features/AWSInstanceProfileApiLiveTest.java deleted file mode 100644 index ae03a87514..0000000000 --- a/labs/aws-iam/src/test/java/org/jclouds/aws/iam/features/AWSInstanceProfileApiLiveTest.java +++ /dev/null @@ -1,32 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.aws.iam.features; - -import org.jclouds.iam.features.InstanceProfileApiLiveTest; -import org.testng.annotations.Test; - -/** - * @author Adrian Cole - */ -@Test(groups = "live", testName = "AWSInstanceProfileApiLiveTest") -public class AWSInstanceProfileApiLiveTest extends InstanceProfileApiLiveTest { - public AWSInstanceProfileApiLiveTest() { - provider = "aws-iam"; - } -} diff --git a/labs/aws-iam/src/test/java/org/jclouds/aws/iam/features/AWSRoleApiLiveTest.java b/labs/aws-iam/src/test/java/org/jclouds/aws/iam/features/AWSRoleApiLiveTest.java deleted file mode 100644 index 5bc3d9b556..0000000000 --- a/labs/aws-iam/src/test/java/org/jclouds/aws/iam/features/AWSRoleApiLiveTest.java +++ /dev/null @@ -1,32 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.aws.iam.features; - -import org.jclouds.iam.features.RoleApiLiveTest; -import org.testng.annotations.Test; - -/** - * @author Adrian Cole - */ -@Test(groups = "live", testName = "AWSRoleApiLiveTest") -public class AWSRoleApiLiveTest extends RoleApiLiveTest { - public AWSRoleApiLiveTest() { - provider = "aws-iam"; - } -} diff --git a/labs/aws-iam/src/test/java/org/jclouds/aws/iam/features/AWSRolePolicyApiLiveTest.java b/labs/aws-iam/src/test/java/org/jclouds/aws/iam/features/AWSRolePolicyApiLiveTest.java deleted file mode 100644 index 2539ebc52e..0000000000 --- a/labs/aws-iam/src/test/java/org/jclouds/aws/iam/features/AWSRolePolicyApiLiveTest.java +++ /dev/null @@ -1,32 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.aws.iam.features; - -import org.jclouds.iam.features.RolePolicyApiLiveTest; -import org.testng.annotations.Test; - -/** - * @author Adrian Cole - */ -@Test(groups = "live", testName = "AWSRolePolicyApiLiveTest") -public class AWSRolePolicyApiLiveTest extends RolePolicyApiLiveTest { - public AWSRolePolicyApiLiveTest() { - provider = "aws-iam"; - } -} diff --git a/labs/aws-iam/src/test/java/org/jclouds/aws/iam/features/AWSUserApiLiveTest.java b/labs/aws-iam/src/test/java/org/jclouds/aws/iam/features/AWSUserApiLiveTest.java deleted file mode 100644 index 0b9bca7451..0000000000 --- a/labs/aws-iam/src/test/java/org/jclouds/aws/iam/features/AWSUserApiLiveTest.java +++ /dev/null @@ -1,32 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.aws.iam.features; - -import org.jclouds.iam.features.UserApiLiveTest; -import org.testng.annotations.Test; - -/** - * @author Adrian Cole - */ -@Test(groups = "live", testName = "AWSUserApiLiveTest") -public class AWSUserApiLiveTest extends UserApiLiveTest { - public AWSUserApiLiveTest() { - provider = "aws-iam"; - } -} diff --git a/labs/aws-rds/pom.xml b/labs/aws-rds/pom.xml deleted file mode 100644 index b5f545d39f..0000000000 --- a/labs/aws-rds/pom.xml +++ /dev/null @@ -1,115 +0,0 @@ - - - - 4.0.0 - - org.jclouds.labs - jclouds-labs-project - 1.7.0-SNAPSHOT - ../project/pom.xml - - aws-rds - jclouds Amazon Relational Database Service provider - Relational Database Service implementation targeted to Amazon Web Services - bundle - - - https://rds.us-east-1.amazonaws.com - 2012-04-23 - - ${test.aws.identity} - ${test.aws.credential} - - org.jclouds.aws.rds*;version="${project.version}" - - org.jclouds.labs*;version="${project.version}", - org.jclouds*;version="${jclouds.version}", - * - - - - - - org.jclouds.labs - rds - ${project.version} - - - org.jclouds.labs - rds - ${project.version} - test-jar - test - - - org.jclouds - jclouds-core - ${jclouds.version} - test-jar - test - - - org.jclouds.driver - jclouds-slf4j - ${jclouds.version} - test - - - ch.qos.logback - logback-classic - test - - - - - - live - - - - org.apache.maven.plugins - maven-surefire-plugin - - - integration - integration-test - - test - - - - ${test.aws-rds.endpoint} - ${test.aws-rds.api-version} - ${test.aws-rds.build-version} - ${test.aws-rds.identity} - ${test.aws-rds.credential} - - - - - - - - - - - diff --git a/labs/aws-rds/src/main/java/org/jclouds/aws/rds/AWSRDSProviderMetadata.java b/labs/aws-rds/src/main/java/org/jclouds/aws/rds/AWSRDSProviderMetadata.java deleted file mode 100644 index 49ed90f76c..0000000000 --- a/labs/aws-rds/src/main/java/org/jclouds/aws/rds/AWSRDSProviderMetadata.java +++ /dev/null @@ -1,109 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.aws.rds; - -import static org.jclouds.aws.domain.Region.AP_NORTHEAST_1; -import static org.jclouds.aws.domain.Region.AP_SOUTHEAST_1; -import static org.jclouds.aws.domain.Region.AP_SOUTHEAST_2; -import static org.jclouds.aws.domain.Region.EU_WEST_1; -import static org.jclouds.aws.domain.Region.SA_EAST_1; -import static org.jclouds.aws.domain.Region.US_EAST_1; -import static org.jclouds.aws.domain.Region.US_WEST_1; -import static org.jclouds.aws.domain.Region.US_WEST_2; -import static org.jclouds.aws.reference.AWSConstants.PROPERTY_ZONECLIENT_ENDPOINT; -import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGION; - -import java.net.URI; -import java.util.Properties; - -import org.jclouds.aws.domain.Region; -import org.jclouds.providers.ProviderMetadata; -import org.jclouds.providers.internal.BaseProviderMetadata; -import org.jclouds.rds.RDSApiMetadata; - -/** - * Implementation of @ link org.jclouds.types.ProviderMetadata} for Amazon's Elastic Load Balancing - * provider. - * - * @author Adrian Cole - */ -public class AWSRDSProviderMetadata extends BaseProviderMetadata { - - public static Builder builder() { - return new Builder(); - } - - @Override - public Builder toBuilder() { - return Builder.class.cast(builder().fromProviderMetadata(this)); - } - - public AWSRDSProviderMetadata() { - super(builder()); - } - - public AWSRDSProviderMetadata(Builder builder) { - super(builder); - } - - public static Properties defaultProperties() { - Properties properties = new Properties(); - properties.putAll(Region.regionProperties()); - properties.setProperty(PROPERTY_REGION + "." + US_EAST_1 + ".endpoint", - "https://rds.us-east-1.amazonaws.com"); - properties.setProperty(PROPERTY_REGION + "." + US_WEST_1 + ".endpoint", - "https://rds.us-west-1.amazonaws.com"); - properties.setProperty(PROPERTY_REGION + "." + US_WEST_2 + ".endpoint", - "https://rds.us-west-2.amazonaws.com"); - properties.setProperty(PROPERTY_REGION + "." + SA_EAST_1 + ".endpoint", - "https://rds.sa-east-1.amazonaws.com"); - properties.setProperty(PROPERTY_REGION + "." + EU_WEST_1 + ".endpoint", - "https://rds.eu-west-1.amazonaws.com"); - properties.setProperty(PROPERTY_REGION + "." + AP_SOUTHEAST_1 + ".endpoint", - "https://rds.ap-southeast-1.amazonaws.com"); - properties.setProperty(PROPERTY_REGION + "." + AP_SOUTHEAST_2 + ".endpoint", - "https://rds.ap-southeast-2.amazonaws.com"); - properties.setProperty(PROPERTY_REGION + "." + AP_NORTHEAST_1 + ".endpoint", - "https://rds.ap-northeast-1.amazonaws.com"); - properties.setProperty(PROPERTY_ZONECLIENT_ENDPOINT, "https://ec2.us-east-1.amazonaws.com"); - return properties; - } - - public static class Builder extends BaseProviderMetadata.Builder { - - protected Builder(){ - id("aws-rds") - .name("Amazon Relational Database Service") - .endpoint("https://rds.us-east-1.amazonaws.com") - .homepage(URI.create("http://aws.amazon.com/rds")) - .console(URI.create("https://console.aws.amazon.com/ec2/home")) - .linkedServices("aws-ec2", "aws-rds", "aws-elb", "aws-iam","aws-cloudwatch", "aws-s3", "aws-simpledb") - .iso3166Codes("US-VA", "US-CA", "BR-SP", "US-OR", "IE", "SG", "AU-NSW", "JP-13") - .apiMetadata(new RDSApiMetadata()) - .defaultProperties(AWSRDSProviderMetadata.defaultProperties()); - } - - @Override - public Builder fromProviderMetadata( - ProviderMetadata in) { - super.fromProviderMetadata(in); - return this; - } - } -} diff --git a/labs/aws-rds/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata b/labs/aws-rds/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata deleted file mode 100644 index 5db1e216dd..0000000000 --- a/labs/aws-rds/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata +++ /dev/null @@ -1 +0,0 @@ -org.jclouds.aws.rds.AWSRDSProviderMetadata diff --git a/labs/aws-rds/src/test/java/org/jclouds/aws/rds/AWSRDSProviderTest.java b/labs/aws-rds/src/test/java/org/jclouds/aws/rds/AWSRDSProviderTest.java deleted file mode 100644 index 506d9fd252..0000000000 --- a/labs/aws-rds/src/test/java/org/jclouds/aws/rds/AWSRDSProviderTest.java +++ /dev/null @@ -1,36 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.aws.rds; - -import org.jclouds.rds.RDSApiMetadata; -import org.jclouds.providers.internal.BaseProviderMetadataTest; -import org.testng.annotations.Test; - -/** - * The AWSRDSProviderTest tests the org.jclouds.providers.AWSRDSProvider class. - * - * @author Adrian Cole - */ -@Test(groups = "unit", testName = "AWSRDSProviderTest") -public class AWSRDSProviderTest extends BaseProviderMetadataTest { - - public AWSRDSProviderTest() { - super(new AWSRDSProviderMetadata(), new RDSApiMetadata()); - } -} diff --git a/labs/aws-rds/src/test/java/org/jclouds/aws/rds/features/AWSInstanceApiLiveTest.java b/labs/aws-rds/src/test/java/org/jclouds/aws/rds/features/AWSInstanceApiLiveTest.java deleted file mode 100644 index b26c2d0541..0000000000 --- a/labs/aws-rds/src/test/java/org/jclouds/aws/rds/features/AWSInstanceApiLiveTest.java +++ /dev/null @@ -1,35 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.aws.rds.features; - -import org.jclouds.rds.features.InstanceApiLiveTest; -import org.testng.annotations.Test; - -/** - * - * @author Adrian Cole - */ -@Test(groups = "live", testName = "AWSInstanceApiLiveTest") -public class AWSInstanceApiLiveTest extends InstanceApiLiveTest { - - public AWSInstanceApiLiveTest() { - provider = "aws-rds"; - } - -} diff --git a/labs/aws-rds/src/test/java/org/jclouds/aws/rds/features/AWSSecurityGroupApiLiveTest.java b/labs/aws-rds/src/test/java/org/jclouds/aws/rds/features/AWSSecurityGroupApiLiveTest.java deleted file mode 100644 index 00da537b0f..0000000000 --- a/labs/aws-rds/src/test/java/org/jclouds/aws/rds/features/AWSSecurityGroupApiLiveTest.java +++ /dev/null @@ -1,35 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.aws.rds.features; - -import org.jclouds.rds.features.SecurityGroupApiLiveTest; -import org.testng.annotations.Test; - -/** - * - * @author Adrian Cole - */ -@Test(groups = "live", testName = "AWSSecurityGroupApiLiveTest") -public class AWSSecurityGroupApiLiveTest extends SecurityGroupApiLiveTest { - - public AWSSecurityGroupApiLiveTest() { - provider = "aws-rds"; - } - -} diff --git a/labs/aws-rds/src/test/java/org/jclouds/aws/rds/features/AWSSubnetGroupApiLiveTest.java b/labs/aws-rds/src/test/java/org/jclouds/aws/rds/features/AWSSubnetGroupApiLiveTest.java deleted file mode 100644 index 7db1c61ced..0000000000 --- a/labs/aws-rds/src/test/java/org/jclouds/aws/rds/features/AWSSubnetGroupApiLiveTest.java +++ /dev/null @@ -1,35 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.aws.rds.features; - -import org.jclouds.rds.features.SubnetGroupApiLiveTest; -import org.testng.annotations.Test; - -/** - * - * @author Adrian Cole - */ -@Test(groups = "live", testName = "AWSSubnetGroupApiLiveTest") -public class AWSSubnetGroupApiLiveTest extends SubnetGroupApiLiveTest { - - public AWSSubnetGroupApiLiveTest() { - provider = "aws-rds"; - } - -} diff --git a/labs/azure-management/.gitignore b/labs/azure-management/.gitignore deleted file mode 100644 index 83c270e296..0000000000 --- a/labs/azure-management/.gitignore +++ /dev/null @@ -1,9 +0,0 @@ -# use glob syntax. -syntax: glob -target -.settings -.classpath -.project -jclouds-azure-management.iml -jclouds-azure-management.ipr -jclouds-azure-management.iws diff --git a/labs/azure-management/README.txt b/labs/azure-management/README.txt deleted file mode 100644 index 4136495517..0000000000 --- a/labs/azure-management/README.txt +++ /dev/null @@ -1,8 +0,0 @@ - How to create the certificate : - - Create the .cer and pfx files using http://www.windowsazure4j.org/learn/labs/Management/index.html or http://msdn.microsoft.com/en-us/library/gg551722 - - Add it to azure : http://msdn.microsoft.com/en-us/library/gg551726 - - Generate the keystore http://stackoverflow.com/questions/4217107/how-to-convert-pfx-file-to-keystore-with-private-key - openssl pkcs12 -in certificate.pfx -out certificate.pem diff --git a/labs/azure-management/pom.xml b/labs/azure-management/pom.xml deleted file mode 100644 index 4e9cc4f121..0000000000 --- a/labs/azure-management/pom.xml +++ /dev/null @@ -1,129 +0,0 @@ - - - - 4.0.0 - - org.jclouds - jclouds-project - 1.7.0-SNAPSHOT - ../../project/pom.xml - - org.jclouds.labs - azure-management - jcloud azure-management api - jclouds components to access an implementation of Azure Management - bundle - - - FIXME_subscription-id - - https://management.core.windows.net/${jclouds.azure.management.subscription-id} - 2012-03-01 - - /path/to/cert.p12 - password to cert - org.jclouds.azure.management*;version="${project.version}" - - org.jclouds.rest.internal;version="${project.version}", - org.jclouds*;version="${project.version}", - * - - - - - - com.jamesmurty.utils - java-xmlbuilder - 0.4 - - - org.jclouds - jclouds-compute - ${project.version} - - - org.jclouds - jclouds-compute - ${project.version} - test-jar - test - - - org.jclouds - jclouds-core - ${project.version} - test-jar - test - - - org.jclouds.driver - jclouds-slf4j - ${project.version} - test - - - org.jclouds.driver - jclouds-sshj - ${project.version} - test - - - ch.qos.logback - logback-classic - test - - - - - - live - - - - org.apache.maven.plugins - maven-surefire-plugin - - - integration - integration-test - - test - - - - ${test.azure-management.endpoint} - ${test.azure-management.api-version} - ${test.azure-management.build-version} - ${test.azure-management.identity} - ${test.azure-management.credential} - ${test.jclouds.azure.management.subscription-id} - - - - - - - - - - - diff --git a/labs/azure-management/src/main/java/org/jclouds/azure/management/AzureManagementApi.java b/labs/azure-management/src/main/java/org/jclouds/azure/management/AzureManagementApi.java deleted file mode 100644 index 2680d9f0d0..0000000000 --- a/labs/azure-management/src/main/java/org/jclouds/azure/management/AzureManagementApi.java +++ /dev/null @@ -1,96 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.azure.management; - -import org.jclouds.azure.management.features.DiskApi; -import org.jclouds.azure.management.features.HostedServiceApi; -import org.jclouds.azure.management.features.LocationApi; -import org.jclouds.azure.management.features.OSImageApi; -import org.jclouds.azure.management.features.OperationApi; -import org.jclouds.azure.management.features.RoleApi; -import org.jclouds.rest.annotations.Delegate; - -/** - * The Windows Azure Service Management API is a REST API for managing your services and - * deployments. - *

- * - * @see AzureManagementAsyncApi - * @see doc - * @author Gerald Pereira, Adrian Cole - */ -public interface AzureManagementApi { - /** - * The Service Management API includes operations for listing the available data center locations - * for a hosted service in your subscription. - * - * @see docs - * @see AzureManagementAsyncApi#getLocationApi() - */ - @Delegate - LocationApi getLocationApi(); - - /** - * The Service Management API includes operations for managing the hosted services beneath your - * subscription. - * - * @see docs - * @see AzureManagementAsyncApi#getHostedServiceApi() - */ - @Delegate - HostedServiceApi getHostedServiceApi(); - - /** - * The Service Management API includes operations for managing the virtual machines in your - * subscription. - * - * @see docs - * @see AzureManagementAsyncApi#getRoleApi() - */ - @Delegate - RoleApi getRoleApi(); - - /** - * The Service Management API includes operations for managing the OS images in your - * subscription. - * - * @see docs - * @see AzureManagementAsyncApi#getOSImageApi() - */ - @Delegate - OSImageApi getOSImageApi(); - - /** - * The Service Management API includes operations for Tracking Asynchronous Service Management Requests. - * - * @see docs - * @see AzureManagementAsyncApi#getOperationApi() - */ - @Delegate - OperationApi getOperationApi(); - - /** - * The Service Management API includes operations for managing Disks in your subscription. - * - * @see docs - * @see AzureManagementAsyncApi#getDiskApi() - */ - @Delegate - DiskApi getDiskApi(); -} diff --git a/labs/azure-management/src/main/java/org/jclouds/azure/management/AzureManagementApiMetadata.java b/labs/azure-management/src/main/java/org/jclouds/azure/management/AzureManagementApiMetadata.java deleted file mode 100644 index 6709ef3021..0000000000 --- a/labs/azure-management/src/main/java/org/jclouds/azure/management/AzureManagementApiMetadata.java +++ /dev/null @@ -1,96 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.azure.management; -import static org.jclouds.azure.management.config.AzureManagementProperties.SUBSCRIPTION_ID; -import static org.jclouds.reflect.Reflection2.typeToken; - -import java.net.URI; -import java.util.Properties; - -import org.jclouds.apis.ApiMetadata; -import org.jclouds.azure.management.compute.config.AzureManagementComputeServiceContextModule; -import org.jclouds.azure.management.config.AzureManagementRestClientModule; -import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.rest.RestContext; -import org.jclouds.rest.internal.BaseRestApiMetadata; - -import com.google.common.collect.ImmutableSet; -import com.google.common.reflect.TypeToken; -import com.google.inject.Module; - -/** - * Implementation of {@link ApiMetadata} for Microsoft Service Management Service API - * - * @author Gerald Pereira - */ -public class AzureManagementApiMetadata extends BaseRestApiMetadata { - - public static final TypeToken> CONTEXT_TOKEN = new TypeToken>() { - private static final long serialVersionUID = 1L; - }; - - private static Builder builder() { - return new Builder(); - } - - @Override - public Builder toBuilder() { - return builder().fromApiMetadata(this); - } - - public AzureManagementApiMetadata() { - this(builder()); - } - - protected AzureManagementApiMetadata(Builder builder) { - super(builder); - } - - public static Properties defaultProperties() { - Properties properties = BaseRestApiMetadata.defaultProperties(); - return properties; - } - - public static class Builder extends BaseRestApiMetadata.Builder { - protected Builder() { - super(AzureManagementApi.class, AzureManagementAsyncApi.class); - id("azure-management") - .name("Microsoft Azure Service Management Service API") - .version("2012-03-01") - .identityName("Path to Management Certificate .p12 file, or PEM string") - .credentialName("Password to Management Certificate") - .defaultEndpoint("https://management.core.windows.net/${" + SUBSCRIPTION_ID + "}") - .endpointName("Service Management Endpoint ending in your Subscription Id") - .documentation(URI.create("http://msdn.microsoft.com/en-us/library/ee460799")) - .defaultProperties(AzureManagementApiMetadata.defaultProperties()) - .view(typeToken(ComputeServiceContext.class)) - .defaultModules(ImmutableSet.> of(AzureManagementComputeServiceContextModule.class, AzureManagementRestClientModule.class)); - } - - @Override - public AzureManagementApiMetadata build() { - return new AzureManagementApiMetadata(this); - } - - @Override - protected Builder self() { - return this; - } - } -} diff --git a/labs/azure-management/src/main/java/org/jclouds/azure/management/AzureManagementAsyncApi.java b/labs/azure-management/src/main/java/org/jclouds/azure/management/AzureManagementAsyncApi.java deleted file mode 100644 index 21e8d5e28d..0000000000 --- a/labs/azure-management/src/main/java/org/jclouds/azure/management/AzureManagementAsyncApi.java +++ /dev/null @@ -1,97 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.azure.management; - -import org.jclouds.azure.management.features.DiskAsyncApi; -import org.jclouds.azure.management.features.HostedServiceAsyncApi; -import org.jclouds.azure.management.features.LocationAsyncApi; -import org.jclouds.azure.management.features.OSImageAsyncApi; -import org.jclouds.azure.management.features.OperationAsyncApi; -import org.jclouds.azure.management.features.RoleAsyncApi; -import org.jclouds.rest.annotations.Delegate; - -/** - * The Windows Azure Service Management API is a REST API for managing your services and - * deployments. - *

- * - * @see AzureManagementApi - * @see doc - * @author Gerald Pereira, Adrian Cole - */ -public interface AzureManagementAsyncApi { - /** - * The Service Management API includes operations for listing the available data center locations - * for a hosted service in your subscription. - * - * @see docs - * @see AzureManagementApi#getLocationApi() - */ - @Delegate - LocationAsyncApi getLocationApi(); - - /** - * The Service Management API includes operations for managing the hosted services beneath your - * subscription. - * - * @see docs - * @see AzureManagementApi#getHostedServiceApi() - */ - @Delegate - HostedServiceAsyncApi getHostedServiceApi(); - - /** - * The Service Management API includes operations for managing the virtual machines in your - * subscription. - * - * @see docs - * @see AzureManagementApi#getRoleApi() - */ - @Delegate - RoleAsyncApi getRoleApi(); - - /** - * The Service Management API includes operations for managing the OS images in your - * subscription. - * - * @see docs - * @see AzureManagementApi#getOSImageApi() - */ - @Delegate - OSImageAsyncApi getOSImageApi(); - - /** - * The Service Management API includes operations for Tracking Asynchronous Service Management Requests. - * - * @see docs - * @see AzureManagementApi#getOperationApi() - */ - @Delegate - OperationAsyncApi getOperationApi(); - - - /** - * The Service Management API includes operations for managing Disks in your subscription. - * - * @see docs - * @see AzureManagementApi#getDiskApi() - */ - @Delegate - DiskAsyncApi getDiskApi(); -} diff --git a/labs/azure-management/src/main/java/org/jclouds/azure/management/AzureManagementProviderMetadata.java b/labs/azure-management/src/main/java/org/jclouds/azure/management/AzureManagementProviderMetadata.java deleted file mode 100644 index 4462aafa04..0000000000 --- a/labs/azure-management/src/main/java/org/jclouds/azure/management/AzureManagementProviderMetadata.java +++ /dev/null @@ -1,84 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.azure.management; - -import static org.jclouds.azure.management.config.AzureManagementProperties.SUBSCRIPTION_ID; - -import java.net.URI; -import java.util.Properties; - -import org.jclouds.providers.ProviderMetadata; -import org.jclouds.providers.internal.BaseProviderMetadata; - -/** - * Implementation of {@link org.jclouds.types.ProviderMetadata} for Microsoft Azure Service - * Management Service. - * - * @author Gerald Pereira - */ -public class AzureManagementProviderMetadata extends BaseProviderMetadata { - - public static Builder builder() { - return new Builder(); - } - - @Override - public Builder toBuilder() { - return builder().fromProviderMetadata(this); - } - - public AzureManagementProviderMetadata() { - super(builder()); - } - - public AzureManagementProviderMetadata(Builder builder) { - super(builder); - } - - public static Properties defaultProperties() { - Properties properties = new Properties(); - return properties; - } - - public static class Builder extends BaseProviderMetadata.Builder { - - protected Builder() { - id("azure-management") - .name("Microsoft Azure Service Management Service") - .apiMetadata(new AzureManagementApiMetadata()) - .endpoint("https://management.core.windows.net/${" + SUBSCRIPTION_ID + "}") - .homepage(URI.create("https://www.windowsazure.com/")) - .console(URI.create("https://windows.azure.com/default.aspx")) - .linkedServices("azureblob", "azurequeue", "azuretable") - .iso3166Codes("US-TX", "US-IL", "IE-D", "SG", "NL-NH", "HK") - .defaultProperties(AzureManagementProviderMetadata.defaultProperties()); - } - - @Override - public AzureManagementProviderMetadata build() { - return new AzureManagementProviderMetadata(this); - } - - @Override - public Builder fromProviderMetadata(ProviderMetadata in) { - super.fromProviderMetadata(in); - return this; - } - } -} diff --git a/labs/azure-management/src/main/java/org/jclouds/azure/management/binders/BindCreateHostedServiceToXmlPayload.java b/labs/azure-management/src/main/java/org/jclouds/azure/management/binders/BindCreateHostedServiceToXmlPayload.java deleted file mode 100644 index e4e06c1575..0000000000 --- a/labs/azure-management/src/main/java/org/jclouds/azure/management/binders/BindCreateHostedServiceToXmlPayload.java +++ /dev/null @@ -1,89 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.azure.management.binders; - -import static com.google.common.base.Charsets.UTF_8; -import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.io.BaseEncoding.base64; - -import java.util.Map; -import java.util.Map.Entry; - -import javax.inject.Singleton; - -import org.jclouds.azure.management.options.CreateHostedServiceOptions; -import org.jclouds.http.HttpRequest; -import org.jclouds.rest.MapBinder; - -import com.google.common.base.Optional; -import com.google.common.base.Throwables; -import com.jamesmurty.utils.XMLBuilder; - -/** - * - * @author Adrian Cole - * - */ -@Singleton -public class BindCreateHostedServiceToXmlPayload implements MapBinder { - - private static final CreateHostedServiceOptions NO_OPTIONS = new CreateHostedServiceOptions(); - - @Override - public R bindToRequest(R request, Map postParams) { - String serviceName = checkNotNull(postParams.get("serviceName"), "serviceName").toString(); - String label = base64().encode(checkNotNull(postParams.get("label"), "label").toString().getBytes(UTF_8)); - - Optional location = Optional.fromNullable((String) postParams.get("location")); - Optional affinityGroup = Optional.fromNullable((String) postParams.get("affinityGroup")); - CreateHostedServiceOptions options = Optional - .fromNullable((CreateHostedServiceOptions) postParams.get("options")).or(NO_OPTIONS); - try { - XMLBuilder createHostedService = XMLBuilder.create("CreateHostedService") - .a("xmlns", "http://schemas.microsoft.com/windowsazure").e("ServiceName").t(serviceName).up() - .e("Label").t(label).up(); - - if (options.getDescription().isPresent()) - createHostedService.e("Description").t(options.getDescription().get()).up(); - - if (location.isPresent()) - createHostedService.e("Location").t(location.get()).up(); - else if (affinityGroup.isPresent()) - createHostedService.e("AffinityGroup").t(affinityGroup.get()).up(); - else - throw new IllegalArgumentException("you must specify either Location or AffinityGroup!"); - - if (options.getExtendedProperties().isPresent() && options.getExtendedProperties().get().size() > 0) { - XMLBuilder extendedProperties = createHostedService.e("ExtendedProperties"); - for (Entry entry : options.getExtendedProperties().get().entrySet()) - extendedProperties.e("ExtendedProperty").e("Name").t(entry.getKey()).up().e("Value").t(entry.getValue()); - } - return (R) request.toBuilder().payload(createHostedService.asString()).build(); - } catch (Exception e) { - throw Throwables.propagate(e); - } - - } - - @Override - public R bindToRequest(R request, Object input) { - throw new IllegalStateException("BindCreateHostedServiceToXmlPayload is needs parameters"); - } - -} diff --git a/labs/azure-management/src/main/java/org/jclouds/azure/management/binders/BindDeploymentParamsToXmlPayload.java b/labs/azure-management/src/main/java/org/jclouds/azure/management/binders/BindDeploymentParamsToXmlPayload.java deleted file mode 100644 index 60b956b425..0000000000 --- a/labs/azure-management/src/main/java/org/jclouds/azure/management/binders/BindDeploymentParamsToXmlPayload.java +++ /dev/null @@ -1,146 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.azure.management.binders; - -import javax.inject.Singleton; - -import org.jclouds.azure.management.domain.DeploymentParams; -import org.jclouds.azure.management.domain.InputEndpoint; -import org.jclouds.azure.management.domain.OSType; -import org.jclouds.http.HttpRequest; -import org.jclouds.rest.Binder; - -import com.google.common.base.Throwables; -import com.jamesmurty.utils.XMLBuilder; - -/** - * - * @author gpereira - * - */ -@Singleton -public class BindDeploymentParamsToXmlPayload implements Binder { - - - @Override - public R bindToRequest(R request, Object input) { - DeploymentParams params = DeploymentParams.class.cast(input); - try { - - XMLBuilder builder = XMLBuilder.create("Deployment").a("xmlns", "http://schemas.microsoft.com/windowsazure") - .e("Name").t(params.getName()).up() - .e("DeploymentSlot").t("Production").up() - .e("Label").t(params.getName()).up() - .e("RoleList") - .e("Role") - .e("RoleName").t(params.getName()).up() - .e("RoleType").t("PersistentVMRole").up() - .e("ConfigurationSets"); - - if (params.getOsType() == OSType.WINDOWS){ - XMLBuilder configBuilder = builder.e("ConfigurationSet"); // Windows - configBuilder.e("ConfigurationSetType").t("WindowsProvisioningConfiguration").up() - .e("ComputerName").t(params.getUsername()).up() - .e("AdminPassword").t(params.getPassword()).up() - .e("ResetPasswordOnFirstLogon").t("false").up() - .e("EnableAutomaticUpdate").t("false").up() - .e("DomainJoin") - .e("Credentials") - .e("Domain").t(params.getName()).up() - .e("Username").t(params.getUsername()).up() - .e("Password").t(params.getPassword()).up() - .up()//Credentials - .e("JoinDomain").t(params.getName()).up() - .up()// Domain Join - .e("StoredCertificateSettings").up() - .up();//Windows ConfigurationSet - }else if (params.getOsType() == OSType.LINUX){ - XMLBuilder configBuilder = builder.e("ConfigurationSet"); // Linux - configBuilder.e("ConfigurationSetType").t("LinuxProvisioningConfiguration").up() - .e("HostName").t(params.getName()).up() - .e("UserName").t(params.getUsername()).up() - .e("UserPassword").t(params.getPassword()).up() - .e("DisableSshPasswordAuthentication").t("false").up() - .e("SSH").up() - .up();//Linux ConfigurationSet - } - - XMLBuilder configBuilder = builder.e("ConfigurationSet"); // Network - configBuilder.e("ConfigurationSetType").t("NetworkConfiguration").up(); - - XMLBuilder inputEndpoints = configBuilder.e("InputEndpoints"); - for (InputEndpoint endpoint : params.getEndpoints()){ - XMLBuilder inputBuilder = inputEndpoints.e("InputEndpoint"); - inputBuilder.e("LocalPort").t(endpoint.getLocalPort().toString()).up() - .e("Name").t(endpoint.getName()).up() - .e("Port").t(endpoint.getExternalPort().toString()).up() - .e("Protocol").t(endpoint.getProtocol().name()).up() - .up();//InputEndpoint - } - - inputEndpoints.up(); - configBuilder.e("SubnetNames").up() - .up(); - - builder.up()//ConfigurationSets - .e("DataVirtualHardDisks").up() - .e("OSVirtualHardDisk") - .e("HostCaching").t("ReadWrite").up() - .e("MediaLink").t("http://"+params.getStorageAccount()+".blob.core.windows.net/disks/"+params.getName()+"/"+params.getSourceImageName()).up() - .e("SourceImageName").t(params.getSourceImageName()).up() - .e("OS").t("Linux").up() - .up()//OSVirtualHardDisk - .e("RoleSize").t(params.getSize().value()).up() - .up()//Role - .up();//RoleList - - -// builder.e("ConfigurationSet") // Network -// .e("ConfigurationSetType").t("NetworkConfiguration").up() -// .e("InputEndpoints"); -// -// -// -// -// -// builder.up()//InputEndpoints -// .e("SubnetNames").up() -// .up()//Network ConfigurationSet -// .up()//ConfigurationSets -// .e("DataVirtualHardDisks").up() -// .e("OSVirtualHardDisk") -// .e("HostCaching").t("ReadWrite").up() -// .e("MediaLink").t("http://"+params.getStorageAccount()+".blob.core.windows.net/disks/"+params.getName()+"/"+params.getSourceImageName()).up() -// .e("SourceImageName").t(params.getSourceImageName()).up() -// .e("OS").t("Linux").up() -// .up()//OSVirtualHardDisk -// .e("RoleSize").t(params.getSize().name()).up() -// .up()//Role -// .up();//RoleList - - - - return (R) request.toBuilder().payload(builder.asString()).build(); - } catch (Exception e) { - throw Throwables.propagate(e); - } - - } - -} diff --git a/labs/azure-management/src/main/java/org/jclouds/azure/management/binders/BindOSImageParamsToXmlPayload.java b/labs/azure-management/src/main/java/org/jclouds/azure/management/binders/BindOSImageParamsToXmlPayload.java deleted file mode 100644 index 0d413bd7bc..0000000000 --- a/labs/azure-management/src/main/java/org/jclouds/azure/management/binders/BindOSImageParamsToXmlPayload.java +++ /dev/null @@ -1,55 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.azure.management.binders; - -import javax.inject.Singleton; - -import org.jclouds.azure.management.domain.OSImageParams; -import org.jclouds.http.HttpRequest; -import org.jclouds.rest.Binder; - -import com.google.common.base.Throwables; -import com.jamesmurty.utils.XMLBuilder; - -/** - * - * @author Adrian Cole - * - */ -@Singleton -public class BindOSImageParamsToXmlPayload implements Binder { - - - @Override - public R bindToRequest(R request, Object input) { - OSImageParams params = OSImageParams.class.cast(input); - try { - return (R) request.toBuilder().payload(XMLBuilder.create("OSImage").a("xmlns", "http://schemas.microsoft.com/windowsazure") - .e("Label").t(params.getLabel()).up() - .e("MediaLink").t(params.getMediaLink().toASCIIString()).up() - .e("Name").t(params.getName()).up() - .e("OS").t(params.getOS().toString()).up() - .up().asString()).build(); - } catch (Exception e) { - throw Throwables.propagate(e); - } - - } - -} diff --git a/labs/azure-management/src/main/java/org/jclouds/azure/management/compute/AzureManagementComputeServiceAdapter.java b/labs/azure-management/src/main/java/org/jclouds/azure/management/compute/AzureManagementComputeServiceAdapter.java deleted file mode 100644 index 176cab0c94..0000000000 --- a/labs/azure-management/src/main/java/org/jclouds/azure/management/compute/AzureManagementComputeServiceAdapter.java +++ /dev/null @@ -1,128 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.azure.management.compute; - -import static com.google.common.base.Preconditions.checkNotNull; - -import javax.annotation.Resource; -import javax.inject.Inject; -import javax.inject.Named; -import javax.inject.Singleton; - -import org.jclouds.azure.management.AzureManagementApi; -import org.jclouds.azure.management.AzureManagementAsyncApi; -import org.jclouds.azure.management.domain.Deployment; -import org.jclouds.azure.management.domain.OSImage; -import org.jclouds.azure.management.domain.RoleSize; -import org.jclouds.compute.ComputeServiceAdapter; -import org.jclouds.compute.domain.Template; -import org.jclouds.compute.reference.ComputeServiceConstants; -import org.jclouds.logging.Logger; - -/** - * defines the connection between the {@link AzureApi} implementation and the - * jclouds {@link ComputeService} - * - */ -@Singleton -public class AzureManagementComputeServiceAdapter implements - ComputeServiceAdapter { - - @Resource - @Named(ComputeServiceConstants.COMPUTE_LOGGER) - protected Logger logger = Logger.NULL; - - private final AzureManagementApi api; - private final AzureManagementAsyncApi aapi; - - @Inject - public AzureManagementComputeServiceAdapter(AzureManagementApi api, - AzureManagementAsyncApi aapi) { - this.api = checkNotNull(api, "api"); - this.aapi = checkNotNull(aapi, "aapi"); - } - - @Override - public org.jclouds.compute.ComputeServiceAdapter.NodeAndInitialCredentials createNodeWithGroupEncodedIntoName( - String group, String name, Template template) { - // TODO Auto-generated method stub - return null; - } - - @Override - public Iterable listHardwareProfiles() { - // TODO Auto-generated method stub - return null; - } - - @Override - public Iterable listImages() { - // TODO Auto-generated method stub - return null; - } - - @Override - public OSImage getImage(String id) { - // TODO Auto-generated method stub - return null; - } - - @Override - public Iterable listLocations() { - // TODO Auto-generated method stub - return null; - } - - @Override - public Deployment getNode(String id) { - // TODO Auto-generated method stub - return null; - } - - @Override - public void destroyNode(String id) { - // TODO Auto-generated method stub - - } - - @Override - public void rebootNode(String id) { - // TODO Auto-generated method stub - - } - - @Override - public void resumeNode(String id) { - // TODO Auto-generated method stub - - } - - @Override - public void suspendNode(String id) { - // TODO Auto-generated method stub - - } - - @Override - public Iterable listNodes() { - // TODO Auto-generated method stub - return null; - } - -} diff --git a/labs/azure-management/src/main/java/org/jclouds/azure/management/compute/config/AzureManagementComputeServiceContextModule.java b/labs/azure-management/src/main/java/org/jclouds/azure/management/compute/config/AzureManagementComputeServiceContextModule.java deleted file mode 100644 index 4e1237a672..0000000000 --- a/labs/azure-management/src/main/java/org/jclouds/azure/management/compute/config/AzureManagementComputeServiceContextModule.java +++ /dev/null @@ -1,58 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.azure.management.compute.config; - -import org.jclouds.azure.management.compute.AzureManagementComputeServiceAdapter; -import org.jclouds.azure.management.compute.functions.DeploymentToNodeMetadata; -import org.jclouds.azure.management.compute.functions.OSImageToImage; -import org.jclouds.azure.management.compute.functions.RoleSizeToHardware; -import org.jclouds.azure.management.domain.Deployment; -import org.jclouds.azure.management.domain.OSImage; -import org.jclouds.azure.management.domain.RoleSize; -import org.jclouds.compute.ComputeServiceAdapter; -import org.jclouds.compute.config.ComputeServiceAdapterContextModule; -import org.jclouds.compute.domain.Hardware; -import org.jclouds.compute.domain.Image; -import org.jclouds.compute.domain.NodeMetadata; - -import com.google.common.base.Function; -import com.google.inject.TypeLiteral; - -/** - * - * @author Gérald Pereira - */ -public class AzureManagementComputeServiceContextModule extends - ComputeServiceAdapterContextModule { - - @Override - protected void configure() { - super.configure(); - bind(new TypeLiteral>() { - }).to(AzureManagementComputeServiceAdapter.class); - bind(new TypeLiteral>() { - }).to(OSImageToImage.class); - bind(new TypeLiteral>() { - }).to(RoleSizeToHardware.class); - bind(new TypeLiteral>() { - }).to(DeploymentToNodeMetadata.class); - - } - -} diff --git a/labs/azure-management/src/main/java/org/jclouds/azure/management/compute/functions/DeploymentToNodeMetadata.java b/labs/azure-management/src/main/java/org/jclouds/azure/management/compute/functions/DeploymentToNodeMetadata.java deleted file mode 100644 index a4052bcd2b..0000000000 --- a/labs/azure-management/src/main/java/org/jclouds/azure/management/compute/functions/DeploymentToNodeMetadata.java +++ /dev/null @@ -1,15 +0,0 @@ -package org.jclouds.azure.management.compute.functions; - -import org.jclouds.azure.management.domain.Deployment; -import org.jclouds.compute.domain.NodeMetadata; - -import com.google.common.base.Function; - -public class DeploymentToNodeMetadata implements Function { - - @Override - public NodeMetadata apply(Deployment input) { - return null; - } - -} diff --git a/labs/azure-management/src/main/java/org/jclouds/azure/management/compute/functions/OSImageToImage.java b/labs/azure-management/src/main/java/org/jclouds/azure/management/compute/functions/OSImageToImage.java deleted file mode 100644 index 5077aa9a64..0000000000 --- a/labs/azure-management/src/main/java/org/jclouds/azure/management/compute/functions/OSImageToImage.java +++ /dev/null @@ -1,15 +0,0 @@ -package org.jclouds.azure.management.compute.functions; - -import org.jclouds.azure.management.domain.OSImage; -import org.jclouds.compute.domain.Image; - -import com.google.common.base.Function; - -public class OSImageToImage implements Function{ - - @Override - public Image apply(OSImage input) { - return null; - } - -} diff --git a/labs/azure-management/src/main/java/org/jclouds/azure/management/compute/functions/RoleSizeToHardware.java b/labs/azure-management/src/main/java/org/jclouds/azure/management/compute/functions/RoleSizeToHardware.java deleted file mode 100644 index 85b5388b62..0000000000 --- a/labs/azure-management/src/main/java/org/jclouds/azure/management/compute/functions/RoleSizeToHardware.java +++ /dev/null @@ -1,15 +0,0 @@ -package org.jclouds.azure.management.compute.functions; - -import org.jclouds.azure.management.domain.RoleSize; -import org.jclouds.compute.domain.Hardware; - -import com.google.common.base.Function; - -public class RoleSizeToHardware implements Function { - - @Override - public Hardware apply(RoleSize input) { - return null; - } - -} diff --git a/labs/azure-management/src/main/java/org/jclouds/azure/management/config/AzureManagementProperties.java b/labs/azure-management/src/main/java/org/jclouds/azure/management/config/AzureManagementProperties.java deleted file mode 100644 index a54917cd7d..0000000000 --- a/labs/azure-management/src/main/java/org/jclouds/azure/management/config/AzureManagementProperties.java +++ /dev/null @@ -1,40 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.azure.management.config; - -/** - * Configuration properties and constants used in Azure Service Management - * connections. - * - * @author Gerald Pereira - */ -public class AzureManagementProperties { - /** - * Every call to the Service Management API must include the subscription ID - * for your subscription. The subscription ID is appended to the base URI, - * as follows: - * - *

-	 * https://management.core.windows.net/${subscriptionId}
-	 * 
- * - * @see docs - */ - public static final String SUBSCRIPTION_ID = "jclouds.azure.management.subscription-id"; -} diff --git a/labs/azure-management/src/main/java/org/jclouds/azure/management/config/AzureManagementRestClientModule.java b/labs/azure-management/src/main/java/org/jclouds/azure/management/config/AzureManagementRestClientModule.java deleted file mode 100644 index 98cce43ac6..0000000000 --- a/labs/azure-management/src/main/java/org/jclouds/azure/management/config/AzureManagementRestClientModule.java +++ /dev/null @@ -1,79 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.azure.management.config; - -import java.security.KeyStore; -import java.util.Map; - -import javax.net.ssl.SSLContext; - -import org.jclouds.azure.management.AzureManagementApi; -import org.jclouds.azure.management.AzureManagementAsyncApi; -import org.jclouds.azure.management.features.DiskApi; -import org.jclouds.azure.management.features.DiskAsyncApi; -import org.jclouds.azure.management.features.HostedServiceApi; -import org.jclouds.azure.management.features.HostedServiceAsyncApi; -import org.jclouds.azure.management.features.LocationApi; -import org.jclouds.azure.management.features.LocationAsyncApi; -import org.jclouds.azure.management.features.OSImageApi; -import org.jclouds.azure.management.features.OSImageAsyncApi; -import org.jclouds.azure.management.features.OperationApi; -import org.jclouds.azure.management.features.OperationAsyncApi; -import org.jclouds.azure.management.features.RoleApi; -import org.jclouds.azure.management.features.RoleAsyncApi; -import org.jclouds.azure.management.suppliers.KeyStoreSupplier; -import org.jclouds.azure.management.suppliers.SSLContextWithKeysSupplier; -import org.jclouds.rest.ConfiguresRestClient; -import org.jclouds.rest.config.RestClientModule; - -import com.google.common.base.Supplier; -import com.google.common.collect.ImmutableMap; -import com.google.inject.TypeLiteral; - -/** - * Configures the Azure Service Management connection. - * - * @author Gerald Pereira - */ -@ConfiguresRestClient -public class AzureManagementRestClientModule extends RestClientModule { - public static final Map, Class> DELEGATE_MAP = ImmutableMap., Class> builder() - .put(LocationApi.class, LocationAsyncApi.class) - .put(RoleApi.class, RoleAsyncApi.class) - .put(HostedServiceApi.class, HostedServiceAsyncApi.class) - .put(OSImageApi.class, OSImageAsyncApi.class) - .put(OperationApi.class, OperationAsyncApi.class) - .put(DiskApi.class, DiskAsyncApi.class).build(); - - public AzureManagementRestClientModule() { - super(DELEGATE_MAP); - } - - @Override - protected void configure() { - super.configure(); - bind(new TypeLiteral>() { - }).to(new TypeLiteral() { - }); - bind(new TypeLiteral>() { - }).to(new TypeLiteral() { - }); - } - -} diff --git a/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/Deployment.java b/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/Deployment.java deleted file mode 100644 index abd09a82e2..0000000000 --- a/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/Deployment.java +++ /dev/null @@ -1,290 +0,0 @@ -package org.jclouds.azure.management.domain; - -import java.net.URI; - -public class Deployment { - - public static Builder builder() { - return new Builder(); - } - - public static class Builder { - private String deploymentName; - private DeploymentSlot deploymentSlot; - private DeploymentStatus deploymentStatus; - private String deploymentLabel; - private URI deploymentURL; - private String roleName; - private String instanceName; - private InstanceStatus instanceStatus; - private String instanceStateDetails; - private String instanceErrorCode; - private RoleSize instanceSize; - private String privateIpAddress; - private String publicIpAddress; - - public Builder deploymentName(final String deploymentName) { - this.deploymentName = deploymentName; - return this; - } - - public Builder deploymentSlot(final DeploymentSlot deploymentSlot) { - this.deploymentSlot = deploymentSlot; - return this; - } - - public Builder deploymentStatus(final DeploymentStatus deploymentStatus) { - this.deploymentStatus = deploymentStatus; - return this; - } - - public Builder deploymentLabel(final String deploymentLabel) { - this.deploymentLabel = deploymentLabel; - return this; - } - - public Builder deploymentURL(final URI deploymentURL) { - this.deploymentURL = deploymentURL; - return this; - } - - public Builder instanceSize(final RoleSize instanceSize) { - this.instanceSize = instanceSize; - return this; - } - - public Builder instanceName(final String instanceName) { - this.instanceName = instanceName; - return this; - } - - public Builder instanceStatus(final InstanceStatus instanceStatus) { - this.instanceStatus = instanceStatus; - return this; - } - - public Builder instanceStateDetails(final String instanceStateDetails) { - this.instanceStateDetails = instanceStateDetails; - return this; - } - - public Builder instanceErrorCode(final String instanceErrorCode) { - this.instanceErrorCode = instanceErrorCode; - return this; - } - - public Builder privateIpAddress(final String privateIpAddress) { - this.privateIpAddress = privateIpAddress; - return this; - } - - public Builder publicIpAddress(final String publicIpAddress) { - this.publicIpAddress = publicIpAddress; - return this; - } - - public Builder roleName(final String roleName) { - this.roleName = roleName; - return this; - } - - public Deployment build() { - return new Deployment(deploymentName, deploymentSlot, - deploymentStatus, deploymentLabel, deploymentURL, roleName, - instanceName, instanceStatus,instanceStateDetails,instanceErrorCode, instanceSize, - privateIpAddress, publicIpAddress); - } - - } - - /** - * The user-supplied name for this deployment. - */ - private final String deploymentName; - /** - * The environment to which the hosted service is deployed, either staging - * or production. - */ - private final DeploymentSlot deploymentSlot; - /** - * The status of the deployment. - */ - private final DeploymentStatus deploymentStatus; - /** - * The user-supplied name of the deployment returned as a base-64 encoded - * string. This name can be used identify the deployment for your tracking - * purposes. - */ - private final String deploymentLabel; - /** - * The URL used to access the hosted service. For example, if the service - * name is MyService you could access the access the service by calling: - * http://MyService.cloudapp.net - */ - private final URI deploymentURL; - - /** - * Specifies the name for the virtual machine. The name must be unique - * within Windows Azure. - */ - private final String roleName; - - /** - * The name of the specific role instance (if any). - */ - private final String instanceName; - /** - * The current status of this instance. - */ - private final InstanceStatus instanceStatus; - /** - * The instance state is returned as an English human-readable string that, - * when present, provides a snapshot of the state of the virtual machine at - * the time the operation was called. - * - * For example, when the instance is first being initialized a - * "Preparing Windows for first use." could be returned. - */ - private final String instanceStateDetails; - /** - * Error code of the latest role or VM start - * - * For VMRoles the error codes are: - * - * WaitTimeout - The virtual machine did not communicate back to Azure - * infrastructure within 25 minutes. Typically this indicates that the - * virtual machine did not start or that the guest agent is not installed. - * - * VhdTooLarge - The VHD image selected was too large for the virtual - * machine hosting the role. - * - * AzureInternalError – An internal error has occurred that has caused to - * virtual machine to fail to start. Contact support for additional - * assistance. - * - * For web and worker roles this field returns an error code that can be provided to Windows Azure support to assist in resolution of errors. Typically this field will be empty. - */ - private final String instanceErrorCode; - - /** - * The size of the role instance - */ - private final RoleSize instanceSize; - private final String privateIpAddress; - private final String publicIpAddress; - - public Deployment(String deploymentName, DeploymentSlot deploymentSlot, - DeploymentStatus deploymentStatus, String deploymentLabel, - URI deploymentURL, String roleName, String instanceName, - InstanceStatus instanceStatus,String instanceStateDetails, String instanceErrorCode, RoleSize instanceSize, - String privateIpAddress, String publicIpAddress) { - super(); - this.deploymentName = deploymentName; - this.deploymentSlot = deploymentSlot; - this.deploymentStatus = deploymentStatus; - this.deploymentLabel = deploymentLabel; - this.deploymentURL = deploymentURL; - this.roleName = roleName; - this.instanceName = instanceName; - this.instanceStatus = instanceStatus; - this.instanceStateDetails = instanceStateDetails; - this.instanceErrorCode = instanceErrorCode; - this.instanceSize = instanceSize; - this.privateIpAddress = privateIpAddress; - this.publicIpAddress = publicIpAddress; - } - - public String getDeploymentName() { - return deploymentName; - } - - public DeploymentSlot getDeploymentSlot() { - return deploymentSlot; - } - - public DeploymentStatus getDeploymentStatus() { - return deploymentStatus; - } - - public String getDeploymentLabel() { - return deploymentLabel; - } - - public URI getDeploymentURL() { - return deploymentURL; - } - - public String getRoleName() { - return roleName; - } - - public String getInstanceName() { - return instanceName; - } - - public InstanceStatus getInstanceStatus() { - return instanceStatus; - } - - public String getInstanceStateDetails() { - return instanceStateDetails; - } - - public String getInstanceErrorCode() { - return instanceErrorCode; - } - - public RoleSize getInstanceSize() { - return instanceSize; - } - - public String getPrivateIpAddress() { - return privateIpAddress; - } - - public String getPublicIpAddress() { - return publicIpAddress; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result - + ((deploymentName == null) ? 0 : deploymentName.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - Deployment other = (Deployment) obj; - if (deploymentName == null) { - if (other.deploymentName != null) - return false; - } else if (!deploymentName.equals(other.deploymentName)) - return false; - return true; - } - - @Override - public String toString() { - return "Deployment [deploymentName=" + deploymentName - + ", deploymentSlot=" + deploymentSlot + ", deploymentStatus=" - + deploymentStatus + ", deploymentLabel=" + deploymentLabel - + ", deploymentURL=" + deploymentURL + ", roleName=" + roleName - + ", instanceName=" + instanceName + ", instanceStatus=" - + instanceStatus + ", instanceStateDetails=" - + instanceStateDetails + ", instanceErrorCode=" - + instanceErrorCode + ", instanceSize=" + instanceSize - + ", privateIpAddress=" + privateIpAddress - + ", publicIpAddress=" + publicIpAddress + "]"; - } - - -} diff --git a/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/DeploymentParams.java b/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/DeploymentParams.java deleted file mode 100644 index 9215f606f1..0000000000 --- a/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/DeploymentParams.java +++ /dev/null @@ -1,208 +0,0 @@ -package org.jclouds.azure.management.domain; - -import java.util.List; - -import com.google.common.base.Objects; -import com.google.common.base.Objects.ToStringHelper; -import com.google.common.collect.Lists; - -/** - * - * To create a new deployment/role - * - * Warning : the OSType must be the one of the source image used to create the VM - * - * @author Gérald Pereira - * - */ -public class DeploymentParams { - - public static Builder builder() { - return new Builder(); - } - - public Builder toBuilder() { - return builder().fromLinuxDeploymentParams(this); - } - - public static class Builder { - - protected String name; - protected String sourceImageName; - protected String username; - protected String password; - protected String storageAccount; - protected OSType osType; - protected RoleSize size = RoleSize.SMALL; - protected List endpoints = Lists.newArrayList(); - - public Builder name(String name) { - this.name = name; - return this; - } - - public Builder sourceImageName(String sourceImageName) { - this.sourceImageName = sourceImageName; - return this; - } - - public Builder username(String username) { - this.username = username; - return this; - } - - public Builder password(String password) { - this.password = password; - return this; - } - - public Builder storageAccount(String storageAccount) { - this.storageAccount = storageAccount; - return this; - } - - public Builder size(RoleSize size) { - this.size = size; - return this; - } - - public Builder osType(OSType osType) { - this.osType = osType; - return this; - } - - public Builder endpoint(InputEndpoint endpoint) { - endpoints.add(endpoint); - return this; - } - - public DeploymentParams build() { - return new DeploymentParams(name, sourceImageName, - username, password, storageAccount, size,osType,endpoints); - } - - public Builder fromLinuxDeploymentParams(DeploymentParams in) { - // TODO Since the roleName should be unique, is it a good idea to - // copy it ? - return this.name(in.getName()) - .sourceImageName(in.getSourceImageName()) - .username(in.getUsername()).password(in.getPassword()) - .size(in.getSize()); - } - } - - protected final String name; - protected final String sourceImageName; - protected final String username; - protected final String password; - protected final String storageAccount; - protected final RoleSize size; - protected final OSType osType; - protected final List endpoints; - - - public DeploymentParams(String name, String sourceImageName, - String username, String password, String storageAccount, - RoleSize size,OSType osType,final List endpoints) { - super(); - this.name = name; - this.sourceImageName = sourceImageName; - this.username = username; - this.password = password; - this.storageAccount = storageAccount; - this.size = size; - this.osType = osType; - this.endpoints = endpoints; - } - - /** - * Specifies the name for the deployment and its virtual machine. The name must be unique - * within Windows Azure. - */ - public String getName() { - return name; - } - - /** - * Specifies the name of an operating system image in the image repository. - */ - public String getSourceImageName() { - return sourceImageName; - } - - /** - * Specifies the name of a user to be created in the sudoer group of the - * virtual machine. User names are ASCII character strings 1 to 32 - * characters in length. - */ - public String getUsername() { - return username; - } - - /** - * Specifies the associated password for the user name. - * PasswoazureManagement are ASCII character strings 6 to 72 characters in - * length. - */ - public String getPassword() { - return password; - } - - public String getStorageAccount() { - return storageAccount; - } - - /** - * The size of the virtual machine to allocate. The default value is Small. - */ - public RoleSize getSize() { - return size; - } - - /** - * Os type of the given sourceImage - */ - public OSType getOsType() { - return osType; - } - - public List getEndpoints() { - return endpoints; - } - - /** - * {@inheritDoc} - */ - @Override - public int hashCode() { - return Objects.hashCode(name); - } - - /** - * {@inheritDoc} - */ - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - DeploymentParams other = (DeploymentParams) obj; - return Objects.equal(this.name, other.name); - } - - /** - * {@inheritDoc} - */ - @Override - public String toString() { - return string().toString(); - } - - protected ToStringHelper string() { - return Objects.toStringHelper(this).add("name", name) - .add("sourceImageName", sourceImageName).add("size", size); - } -} diff --git a/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/DeploymentSlot.java b/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/DeploymentSlot.java deleted file mode 100644 index 1a649456b3..0000000000 --- a/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/DeploymentSlot.java +++ /dev/null @@ -1,27 +0,0 @@ -package org.jclouds.azure.management.domain; - -import static com.google.common.base.Preconditions.checkNotNull; - -import com.google.common.base.CaseFormat; - -public enum DeploymentSlot { - PRODUCTION,STAGING; - - public String value() { - return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, name()); - } - - @Override - public String toString() { - return value(); - } - - public static DeploymentSlot fromValue(String type) { - try { - return valueOf(CaseFormat.UPPER_CAMEL.to( - CaseFormat.UPPER_UNDERSCORE, checkNotNull(type, "type"))); - } catch (IllegalArgumentException e) { - return null; - } - } -} diff --git a/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/DeploymentStatus.java b/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/DeploymentStatus.java deleted file mode 100644 index c57e6d8b71..0000000000 --- a/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/DeploymentStatus.java +++ /dev/null @@ -1,27 +0,0 @@ -package org.jclouds.azure.management.domain; - -import static com.google.common.base.Preconditions.checkNotNull; - -import com.google.common.base.CaseFormat; - -public enum DeploymentStatus { - RUNNING, SUSPENDED, RUNNING_TRANSITIONING, SUSPENDED_TRANSITIONING, STARTING, SUSPENDING, DEPLOYING, DELETING; - - public String value() { - return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, name()); - } - - @Override - public String toString() { - return value(); - } - - public static DeploymentStatus fromValue(String type) { - try { - return valueOf(CaseFormat.UPPER_CAMEL.to( - CaseFormat.UPPER_UNDERSCORE, checkNotNull(type, "type"))); - } catch (IllegalArgumentException e) { - return null; - } - } -} diff --git a/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/DetailedHostedServiceProperties.java b/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/DetailedHostedServiceProperties.java deleted file mode 100644 index 1442f0e534..0000000000 --- a/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/DetailedHostedServiceProperties.java +++ /dev/null @@ -1,188 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.azure.management.domain; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.Date; -import java.util.Map; - -import org.jclouds.azure.management.domain.HostedService.Status; - -import com.google.common.base.Objects.ToStringHelper; -import com.google.common.base.Optional; -import com.google.common.collect.ImmutableMap; - -/** - * - * @author Adrian Cole - */ -public class DetailedHostedServiceProperties extends HostedServiceProperties { - public static Builder builder() { - return new ConcreteBuilder(); - } - - public Builder toBuilder() { - return new ConcreteBuilder().fromDetailedHostedServiceProperties(this); - } - - public abstract static class Builder> extends HostedServiceProperties.Builder { - - protected String rawStatus; - protected Status status; - protected Date created; - protected Date lastModified; - protected ImmutableMap.Builder extendedProperties = ImmutableMap. builder(); - - /** - * @see DetailedHostedServiceProperties#getRawStatus() - */ - public T rawStatus(String rawStatus) { - this.rawStatus = rawStatus; - return self(); - } - - /** - * @see DetailedHostedServiceProperties#getStatus() - */ - public T status(Status status) { - this.status = status; - return self(); - } - - /** - * @see DetailedHostedServiceProperties#getCreated() - */ - public T created(Date created) { - this.created = created; - return self(); - } - - /** - * @see DetailedHostedServiceProperties#getLastModified() - */ - public T lastModified(Date lastModified) { - this.lastModified = lastModified; - return self(); - } - - /** - * @see DetailedHostedServiceProperties#getExtendedProperties() - */ - public T extendedProperties(Map extendedProperties) { - this.extendedProperties.putAll(checkNotNull(extendedProperties, "extendedProperties")); - return self(); - } - - /** - * @see DetailedHostedServiceProperties#getExtendedProperties() - */ - public T addExtendedProperty(String name, String value) { - this.extendedProperties.put(checkNotNull(name, "name"), checkNotNull(value, "value")); - return self(); - } - - public DetailedHostedServiceProperties build() { - return new DetailedHostedServiceProperties(description, location, affinityGroup, label, rawStatus, status, - created, lastModified, extendedProperties.build()); - } - - public T fromDetailedHostedServiceProperties(DetailedHostedServiceProperties in) { - return fromHostedServiceProperties(in).rawStatus(in.getRawStatus()).status(in.getStatus()) - .created(in.getCreated()).lastModified(in.getLastModified()) - .extendedProperties(in.getExtendedProperties()); - } - } - - private static class ConcreteBuilder extends Builder { - @Override - protected ConcreteBuilder self() { - return this; - } - } - - protected final String rawStatus; - protected final Status status; - protected final Date created; - protected final Date lastModified; - protected final Map extendedProperties; - - protected DetailedHostedServiceProperties(Optional description, Optional location, - Optional affinityGroup, String label, String rawStatus, Status status, Date created, - Date lastModified, Map extendedProperties) { - super(description, location, affinityGroup, label); - this.rawStatus = checkNotNull(rawStatus, "rawStatus of %s", description); - this.status = checkNotNull(status, "status of %s", description); - this.created = checkNotNull(created, "created of %s", description); - this.lastModified = checkNotNull(lastModified, "lastModified of %s", description); - this.extendedProperties = ImmutableMap.copyOf(checkNotNull(extendedProperties, "extendedProperties of %s", - description)); - } - - /** - * The status of the hosted service. - */ - public Status getStatus() { - return status; - } - - /** - * The status of the hosted service unparsed. - */ - public String getRawStatus() { - return rawStatus; - } - - /** - * The date that the hosted service was created. - */ - public Date getCreated() { - return created; - } - - /** - * The date that the hosted service was last updated. - */ - public Date getLastModified() { - return lastModified; - } - - /** - * Represents the name of an extended hosted service property. Each extended property must have - * both a defined name and value. You can have a maximum of 50 extended property name/value - * pairs. - * - * The maximum length of the Name element is 64 characters, only alphanumeric characters and - * underscores are valid in the Name, and the name must start with a letter. Each extended - * property value has a maximum length of 255 characters. - */ - public Map getExtendedProperties() { - return extendedProperties; - } - - /** - * {@inheritDoc} - */ - @Override - public ToStringHelper string() { - return super.string().add("status", rawStatus).add("created", created).add("lastModified", lastModified) - .add("extendedProperties", extendedProperties); - } - -} diff --git a/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/Disk.java b/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/Disk.java deleted file mode 100644 index 635d37ece9..0000000000 --- a/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/Disk.java +++ /dev/null @@ -1,465 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.azure.management.domain; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.net.URI; - -import com.google.common.base.Objects; -import com.google.common.base.Objects.ToStringHelper; -import com.google.common.base.Optional; - -/** - * disk in the image repository - * - * @see api - * @author Adrian Cole - */ -public class Disk { - public static class Attachment { - - public static Builder builder() { - return new Builder(); - } - - public Builder toBuilder() { - return builder().fromAttachment(this); - } - - public static class Builder { - - private String hostedService; - private String deployment; - private String role; - - /** - * @see Attachment#getHostedService() - */ - public Builder hostedService(String hostedService) { - this.hostedService = hostedService; - return this; - } - - /** - * @see Attachment#getDeployment() - */ - public Builder deployment(String deployment) { - this.deployment = deployment; - return this; - } - - /** - * @see Attachment#getRole() - */ - public Builder role(String role) { - this.role = role; - return this; - } - - public Attachment build() { - return new Attachment(hostedService, deployment, role); - } - - public Builder fromAttachment(Attachment in) { - return this.hostedService(in.hostedService).deployment(in.deployment).role(in.role); - } - } - - private final String hostedService; - private final String deployment; - private final String role; - - protected Attachment(String hostedService, String deployment, String role) { - this.hostedService = checkNotNull(hostedService, "hostedService"); - this.deployment = checkNotNull(deployment, "deployment"); - this.role = checkNotNull(role, "role"); - } - - /** - * The deployment in which the disk is being used. - */ - public String getDeployment() { - return deployment; - } - - /** - * The hosted service in which the disk is being used. - */ - public String getHostedService() { - return hostedService; - } - - /** - * The virtual machine that the disk is attached to. - */ - public String getRole() { - return role; - } - - /** - * {@inheritDoc} - */ - @Override - public int hashCode() { - return Objects.hashCode(hostedService, deployment, role); - } - - /** - * {@inheritDoc} - */ - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - Attachment other = (Attachment) obj; - return Objects.equal(this.hostedService, other.hostedService) - && Objects.equal(this.deployment, other.deployment) && Objects.equal(this.role, other.role); - } - - /** - * {@inheritDoc} - */ - @Override - public String toString() { - return Objects.toStringHelper(this).omitNullValues().add("deployment", hostedService).add("role", role) - .toString(); - } - - } - - public static Builder builder() { - return new ConcreteBuilder(); - } - - public Builder toBuilder() { - return new ConcreteBuilder().fromHostedService(this); - } - - public abstract static class Builder> { - protected abstract T self(); - - protected Optional attachedTo = Optional.absent(); - protected OSType os; - protected String name; - protected Optional logicalSizeInGB = Optional.absent(); - protected Optional description = Optional.absent(); - protected Optional location = Optional.absent(); - protected Optional affinityGroup = Optional.absent(); - protected Optional mediaLink = Optional.absent(); - protected Optional sourceImage = Optional.absent(); - protected Optional label = Optional.absent(); - protected boolean hasOperatingSystem; - protected boolean isCorrupted; - - /** - * @see Disk#getAttachedTo() - */ - public T attachedTo(Attachment attachedTo) { - this.attachedTo = Optional.fromNullable(attachedTo); - return self(); - } - - /** - * @see Disk#getOS() - */ - public T os(OSType os) { - this.os = os; - return self(); - } - - /** - * @see Disk#getName() - */ - public T name(String name) { - this.name = name; - return self(); - } - - /** - * @see Disk#getDescription() - */ - public T description(String description) { - this.description = Optional.fromNullable(description); - return self(); - } - - /** - * @see Disk#getLogicalSizeInGB() - */ - public T logicalSizeInGB(Integer logicalSizeInGB) { - this.logicalSizeInGB = Optional.fromNullable(logicalSizeInGB); - return self(); - } - - /** - * @see Disk#getLocation() - */ - public T location(String location) { - this.location = Optional.fromNullable(location); - return self(); - } - - /** - * @see Disk#getAffinityGroup() - */ - public T affinityGroup(String affinityGroup) { - this.affinityGroup = Optional.fromNullable(affinityGroup); - return self(); - } - - /** - * @see Disk#getMediaLink() - */ - public T mediaLink(URI mediaLink) { - this.mediaLink = Optional.fromNullable(mediaLink); - return self(); - } - - /** - * @see Disk#getSourceImage() - */ - public T sourceImage(String sourceImage) { - this.sourceImage = Optional.fromNullable(sourceImage); - return self(); - } - - /** - * @see Disk#getLabel() - */ - public T label(String label) { - this.label = Optional.fromNullable(label); - return self(); - } - - /** - * @see Disk#hasOperatingSystem() - */ - public T hasOperatingSystem(boolean hasOperatingSystem) { - this.hasOperatingSystem = hasOperatingSystem; - return self(); - } - - /** - * @see Disk#isCorrupted() - */ - public T isCorrupted(boolean isCorrupted) { - this.isCorrupted = isCorrupted; - return self(); - } - - public Disk build() { - return new Disk(attachedTo, os, name, logicalSizeInGB, description, location, affinityGroup, mediaLink, - sourceImage, label, hasOperatingSystem, isCorrupted); - } - - public T fromHostedService(Disk in) { - return this.attachedTo(in.attachedTo.orNull()).os(in.getOS()).name(in.getName()) - .logicalSizeInGB(in.getLogicalSizeInGB().orNull()).description(in.getDescription().orNull()) - .location(in.getLocation().orNull()).affinityGroup(in.getAffinityGroup().orNull()) - .mediaLink(in.getMediaLink().orNull()).sourceImage(in.getSourceImage().orNull()) - .label(in.getLabel().orNull()).hasOperatingSystem(in.hasOperatingSystem).isCorrupted(in.isCorrupted); - } - } - - private static class ConcreteBuilder extends Builder { - @Override - protected ConcreteBuilder self() { - return this; - } - } - - protected final Optional attachedTo; - protected final OSType os; - protected final String name; - protected final Optional logicalSizeInGB; - protected final Optional description; - protected final Optional location; - protected final Optional affinityGroup; - protected final Optional mediaLink; - protected final Optional sourceImage; - protected final Optional label; - protected final boolean hasOperatingSystem; - protected final boolean isCorrupted; - - protected Disk(Optional attachedTo, OSType os, String name, Optional logicalSizeInGB, - Optional description, Optional location, Optional affinityGroup, - Optional mediaLink, Optional sourceImage, Optional label, boolean hasOperatingSystem, - boolean isCorrupted) { - this.name = checkNotNull(name, "name"); - this.attachedTo = checkNotNull(attachedTo, "attachedTo for %s", name); - this.logicalSizeInGB = checkNotNull(logicalSizeInGB, "logicalSizeInGB for %s", name); - this.description = checkNotNull(description, "description for %s", name); - this.os = checkNotNull(os, "os for %s", name); - this.location = checkNotNull(location, "location for %s", name); - this.affinityGroup = checkNotNull(affinityGroup, "affinityGroup for %s", name); - this.mediaLink = checkNotNull(mediaLink, "mediaLink for %s", name); - this.sourceImage = checkNotNull(sourceImage, "sourceImage for %s", name); - this.label = checkNotNull(label, "label for %s", name); - this.hasOperatingSystem = hasOperatingSystem; - this.isCorrupted = isCorrupted; - } - - /** - * Contains properties that specify a virtual machine that currently using the disk. A disk - * cannot be deleted as long as it is attached to a virtual machine. - */ - public Optional getAttachedTo() { - return attachedTo; - } - - /** - * The operating system type of the OS image. - */ - public OSType getOS() { - return os; - } - - /** - * The name of the disk. This is the name that is used when creating one or more virtual machines - * using the disk. - */ - public String getName() { - return name; - } - - /** - * The size, in GB, of the image. - */ - public Optional getLogicalSizeInGB() { - return logicalSizeInGB; - } - - /** - * The description for the image. - */ - public Optional getDescription() { - return description; - } - - /** - * The geo-location in which this media is located. The Location value is derived from storage - * account that contains the blob in which the media is located. If the storage account belongs - * to an affinity group the value is absent. - */ - public Optional getLocation() { - return location; - } - - /** - * The affinity in which the media is located. The AffinityGroup value is derived from storage - * account that contains the blob in which the media is located. If the storage account does not - * belong to an affinity group the value is absent. - */ - public Optional getAffinityGroup() { - return affinityGroup; - } - - /** - * The location of the blob in the blob store in which the media for the disk is located. The - * blob location belongs to a storage account in the subscription specified by the - * value in the operation call. - * - * Example: - * - * http://example.blob.core.windows.net/disks/mydisk.vhd - */ - public Optional getMediaLink() { - return mediaLink; - } - - /** - * The name of the OS Image from which the disk was created. This property is populated - * automatically when a disk is created from an OS image by calling the Add Role, Create - * Deployment, or Provision Disk operations. - */ - public Optional getSourceImage() { - return sourceImage; - } - - /** - * The description of the image. - */ - public Optional getLabel() { - return label; - } - - /** - * Returns whether this disk contains operation system. Only disks that have an operating system - * installed can be mounted as an OS Drive. - */ - public boolean hasOperatingSystem() { - return hasOperatingSystem; - } - - /** - * Returns whether there is a consistency failure detected with this disk. If a disk fails the - * consistency check, you delete any virtual machines using it, delete the disk, and inspect the - * blob media to see if the content is intact. You can then reregister the media in the blob as a - * disk. - */ - public boolean isCorrupted() { - return isCorrupted; - } - - /** - * {@inheritDoc} - */ - @Override - public int hashCode() { - return Objects.hashCode(name); - } - - /** - * {@inheritDoc} - */ - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - Disk other = (Disk) obj; - return Objects.equal(this.name, other.name); - } - - /** - * {@inheritDoc} - */ - @Override - public String toString() { - return string().toString(); - } - - protected ToStringHelper string() { - return Objects.toStringHelper(this).omitNullValues().add("os", os).add("name", name) - .add("attachedTo", attachedTo.orNull()).add("logicalSizeInGB", logicalSizeInGB.orNull()) - .add("description", description).add("location", location.orNull()) - .add("affinityGroup", affinityGroup.orNull()).add("mediaLink", mediaLink.orNull()) - .add("sourceImage", sourceImage.orNull()).add("label", label.orNull()) - .add("hasOperatingSystem", hasOperatingSystem).add("isCorrupted", isCorrupted); - } - -} diff --git a/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/Error.java b/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/Error.java deleted file mode 100644 index 623446c57a..0000000000 --- a/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/Error.java +++ /dev/null @@ -1,253 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.azure.management.domain; - -import static com.google.common.base.Preconditions.checkNotNull; - -import com.google.common.base.CaseFormat; -import com.google.common.base.Objects; - -/** - * additional error information that is defined by the management service. Th - * - * @see api - * - * @author Adrian Cole - */ -public class Error { - - public static enum Code { - - /** - * Bad Request (400) - * - * The versioning header is not specified or was specified incorrectly. - */ - MISSING_OR_INCORRECT_VERSION_HEADER, - - /** - * Bad Request (400) - * - * The request body’s XML was invalid or not correctly specified. - */ - INVALID_XML_REQUEST, - - /** - * Bad Request (400) - * - * A required query parameter was not specified for this request or was specified incorrectly. - */ - MISSING_OR_INVALID_REQUIRED_QUERY_PARAMETER, - - /** - * Bad Request (400) - * - * The HTTP verb specified was not recognized by the server or isn’t valid for this resource. - */ - INVALID_HTTP_VERB, - - /** - * Forbidden (403) - * - * The server failed to authenticate the request. Verify that the certificate is valid and is - * associated with this subscription. - */ - AUTHENTICATION_FAILED, - - /** - * Not Found (404) - * - * The specified resource does not exist. - */ - RESOURCE_NOT_FOUND, - - /** - * Internal Server Error (500) - * - * The server encountered an internal error. Please retry the request. - */ - INTERNAL_ERROR, - - /** - * Internal Server Error (500) - * - * The operation could not be completed within the permitted time. - */ - OPERATION_TIMED_OUT, - - /** - * Service Unavailable (503) - * - * The server (or an internal component) is currently unavailable to receive requests. Please - * retry your request - */ - SERVER_BUSY, - - /** - * Forbidden (403) - * - * The subscription is in a disabled state. - */ - SUBSCRIPTION_DISABLED, - - /** - * Bad Request (400) - * - * A parameter was incorrect. - */ - BAD_REQUEST, - - /** - * Conflict (409) - * - * A conflict occurred to prevent the operation from completing. - */ - CONFLICT_ERROR, - - UNRECOGNIZED; - - public String value() { - return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, name()); - } - - @Override - public String toString() { - return value(); - } - - public static Code fromValue(String code) { - try { - return valueOf(CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, checkNotNull(code, "code"))); - } catch (IllegalArgumentException e) { - return UNRECOGNIZED; - } - } - } - - public static Builder builder() { - return new Builder(); - } - - public Builder toBuilder() { - return builder().fromError(this); - } - - public static class Builder { - - private String rawCode; - private Code code; - private String message; - - /** - * @see Error#getRawCode() - */ - public Builder rawCode(String rawCode) { - this.rawCode = rawCode; - return this; - } - - /** - * @see Error#getCode() - */ - public Builder code(Code code) { - this.code = code; - return this; - } - - /** - * @see Error#getMessage() - */ - public Builder message(String message) { - this.message = message; - return this; - } - - public Error build() { - return new Error(rawCode, code, message); - } - - public Builder fromError(Error in) { - return this.rawCode(in.rawCode).code(in.code).message(in.message); - } - } - - private final String rawCode; - private final Code code; - private final String message; - - protected Error(String rawCode, Code code, String message) { - this.rawCode = checkNotNull(rawCode, "rawCode for %s", message); - this.code = checkNotNull(code, "code for %s", message); - this.message = checkNotNull(message, "message"); - } - - /** - * Error code - */ - public Code getCode() { - return code; - } - - /** - * Error code, unparsed - */ - public String getRawCode() { - return rawCode; - } - - /** - * User message - */ - public String getMessage() { - return message; - } - - /** - * {@inheritDoc} - */ - @Override - public int hashCode() { - return Objects.hashCode(rawCode, code, message); - } - - /** - * {@inheritDoc} - */ - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - Error other = (Error) obj; - return Objects.equal(this.rawCode, other.rawCode) && Objects.equal(this.code, other.code) - && Objects.equal(this.message, other.message); - } - - /** - * {@inheritDoc} - */ - @Override - public String toString() { - return Objects.toStringHelper(this).omitNullValues().add("code", rawCode).add("message", message).toString(); - } - -} diff --git a/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/HostedService.java b/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/HostedService.java deleted file mode 100644 index 6d3e09ea6f..0000000000 --- a/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/HostedService.java +++ /dev/null @@ -1,197 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.azure.management.domain; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.net.URI; - -import com.google.common.base.CaseFormat; -import com.google.common.base.Objects; -import com.google.common.base.Objects.ToStringHelper; - -/** - * System properties for the specified hosted service - * - * @see api - * @author Adrian Cole - */ -public class HostedService { - public static enum Status { - - CREATING, - - CREATED, - - DELETING, - - DELETED, - - CHANGING, - - RESOLVING_DNS, - - UNRECOGNIZED; - - public String value() { - return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, name()); - } - - @Override - public String toString() { - return value(); - } - - public static Status fromValue(String status) { - try { - return valueOf(CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, checkNotNull(status, "status"))); - } catch (IllegalArgumentException e) { - return UNRECOGNIZED; - } - } - } - - public static Builder builder() { - return new ConcreteBuilder(); - } - - public Builder toBuilder() { - return new ConcreteBuilder().fromHostedService(this); - } - - public abstract static class Builder> { - protected abstract T self(); - - protected URI url; - protected String name; - protected HostedServiceProperties properties; - - /** - * @see HostedService#getUrl() - */ - public T url(URI url) { - this.url = url; - return self(); - } - - /** - * @see HostedService#getName() - */ - public T name(String name) { - this.name = name; - return self(); - } - - /** - * @see HostedService#getProperties() - */ - public T properties(HostedServiceProperties properties) { - this.properties = properties; - return self(); - } - - public HostedService build() { - return new HostedService(url, name, properties); - } - - public T fromHostedService(HostedService in) { - return this.url(in.getUrl()).name(in.getName()).properties(in.getProperties()); - } - } - - private static class ConcreteBuilder extends Builder { - @Override - protected ConcreteBuilder self() { - return this; - } - } - - protected final URI url; - protected final String name; - protected final HostedServiceProperties properties; - - protected HostedService(URI url, String name, HostedServiceProperties properties) { - this.url = checkNotNull(url, "url"); - this.name = checkNotNull(name, "name"); - this.properties = checkNotNull(properties, "properties"); - } - - /** - * The Service Management API request URI used to perform Get Hosted Service Properties requests - * against the hosted service. - */ - public URI getUrl() { - return url; - } - - /** - * The name of the hosted service. This name is the DNS prefix name and can be used to access the - * hosted service. - * - * For example, if the service name is MyService you could access the access the service by - * calling: http://MyService.cloudapp.net - */ - public String getName() { - return name; - } - - /** - * Provides the url of the database properties to be used for this DB HostedService. - */ - public HostedServiceProperties getProperties() { - return properties; - } - - /** - * {@inheritDoc} - */ - @Override - public int hashCode() { - return Objects.hashCode(url); - } - - /** - * {@inheritDoc} - */ - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - HostedService other = (HostedService) obj; - return Objects.equal(this.url, other.url); - } - - /** - * {@inheritDoc} - */ - @Override - public String toString() { - return string().toString(); - } - - protected ToStringHelper string() { - return Objects.toStringHelper(this).omitNullValues().add("url", url).add("name", name) - .add("properties", properties); - } - -} diff --git a/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/HostedServiceProperties.java b/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/HostedServiceProperties.java deleted file mode 100644 index 0a667f1680..0000000000 --- a/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/HostedServiceProperties.java +++ /dev/null @@ -1,182 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.azure.management.domain; - -import static com.google.common.base.Preconditions.checkNotNull; - -import com.google.common.base.Objects; -import com.google.common.base.Objects.ToStringHelper; -import com.google.common.base.Optional; - -/** - * System properties for the specified hosted service. These properties include the service name and - * service type; the name of the affinity group to which the service belongs, or its location if it - * is not part of an affinity group. - * - * @see api - * @author Adrian Cole - */ -public class HostedServiceProperties { - public static Builder builder() { - return new ConcreteBuilder(); - } - - public Builder toBuilder() { - return new ConcreteBuilder().fromHostedServiceProperties(this); - } - - public abstract static class Builder> { - protected abstract T self(); - - protected Optional description = Optional.absent(); - protected Optional location = Optional.absent(); - protected Optional affinityGroup = Optional.absent(); - protected String label; - - /** - * @see HostedServiceProperties#getDescription() - */ - public T description(String description) { - this.description = Optional.fromNullable(description); - return self(); - } - - /** - * @see HostedServiceProperties#getLocation() - */ - public T location(String location) { - this.location = Optional.fromNullable(location); - return self(); - } - - /** - * @see HostedServiceProperties#getAffinityGroup() - */ - public T affinityGroup(String affinityGroup) { - this.affinityGroup = Optional.fromNullable(affinityGroup); - return self(); - } - - /** - * @see HostedServiceProperties#getLabel() - */ - public T label(String label) { - this.label = label; - return self(); - } - - public HostedServiceProperties build() { - return new HostedServiceProperties(description, location, affinityGroup, label); - } - - public T fromHostedServiceProperties(HostedServiceProperties in) { - return this.description(in.getDescription().orNull()).location(in.getLocation().orNull()) - .affinityGroup(in.getAffinityGroup().orNull()).label(in.getLabel()); - } - } - - private static class ConcreteBuilder extends Builder { - @Override - protected ConcreteBuilder self() { - return this; - } - } - - protected final Optional description; - protected final Optional location; - protected final Optional affinityGroup; - protected final String label; - - protected HostedServiceProperties(Optional description, Optional location, - Optional affinityGroup, String label) { - this.description = checkNotNull(description, "description"); - this.location = checkNotNull(location, "location"); - this.affinityGroup = checkNotNull(affinityGroup, "affinityGroup"); - this.label = checkNotNull(label, "label"); - } - - /** - * The description for the hosted service.. - */ - public Optional getDescription() { - return description; - } - - /** - * The geo-location of the hosted service in Windows Azure, if the hosted service is not - * associated with an affinity group. If a location has been specified, the AffinityGroup element - * is not returned. - */ - public Optional getLocation() { - return location; - } - - /** - * The affinity group with which this hosted service is associated, if any. If the service is - * associated with an affinity group, the Location element is not returned. - */ - public Optional getAffinityGroup() { - return affinityGroup; - } - - /** - * The name can be up to 100 characters in length. The name can be used identify the storage account for your tracking purposes. - */ - public String getLabel() { - return label; - } - - /** - * {@inheritDoc} - */ - @Override - public int hashCode() { - return Objects.hashCode(description, location, affinityGroup, label); - } - - /** - * {@inheritDoc} - */ - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - HostedServiceProperties other = (HostedServiceProperties) obj; - return Objects.equal(this.description, other.description) && Objects.equal(this.location, other.location) - && Objects.equal(this.affinityGroup, other.affinityGroup) && Objects.equal(this.label, other.label); - } - - /** - * {@inheritDoc} - */ - @Override - public String toString() { - return string().toString(); - } - - protected ToStringHelper string() { - return Objects.toStringHelper(this).omitNullValues().add("description", description.orNull()) - .add("location", location.orNull()).add("affinityGroup", affinityGroup.orNull()).add("label", label); - } - -} diff --git a/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/HostedServiceWithDetailedProperties.java b/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/HostedServiceWithDetailedProperties.java deleted file mode 100644 index 1642f977e1..0000000000 --- a/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/HostedServiceWithDetailedProperties.java +++ /dev/null @@ -1,71 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.azure.management.domain; - -import java.net.URI; - -/** - * - * @author Adrian Cole - */ -public class HostedServiceWithDetailedProperties extends HostedService { - - public static Builder builder() { - return new ConcreteBuilder(); - } - - public Builder toBuilder() { - return new ConcreteBuilder().fromHostedServiceWithDetailedProperties(this); - } - - public abstract static class Builder> extends HostedService.Builder { - - @Override - public T properties(HostedServiceProperties properties) { - this.properties = DetailedHostedServiceProperties.class.cast(properties); - return self(); - } - - public HostedServiceWithDetailedProperties build() { - return new HostedServiceWithDetailedProperties(url, name, - DetailedHostedServiceProperties.class.cast(properties)); - } - - public T fromHostedServiceWithDetailedProperties(HostedServiceWithDetailedProperties in) { - return fromHostedService(in); - } - } - - private static class ConcreteBuilder extends Builder { - @Override - protected ConcreteBuilder self() { - return this; - } - } - - protected HostedServiceWithDetailedProperties(URI url, String serviceName, DetailedHostedServiceProperties properties) { - super(url, serviceName, properties); - } - - @Override - public DetailedHostedServiceProperties getProperties() { - return DetailedHostedServiceProperties.class.cast(properties); - } - -} diff --git a/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/InputEndpoint.java b/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/InputEndpoint.java deleted file mode 100644 index c3b5b29651..0000000000 --- a/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/InputEndpoint.java +++ /dev/null @@ -1,123 +0,0 @@ -package org.jclouds.azure.management.domain; - -import org.jclouds.azure.management.domain.role.Protocol; - -public class InputEndpoint { - - public static Builder builder() { - return new Builder(); - } - - public static class Builder { - private Integer localPort; - private Integer externalPort; - private String name; - private Protocol protocol; - - public Builder localPort(Integer localPort) { - this.localPort = localPort; - return this; - } - - public Builder externalPort(Integer externalPort) { - this.externalPort = externalPort; - return this; - } - - public Builder name(String name) { - this.name = name; - return this; - } - - public Builder protocol(Protocol protocol) { - this.protocol = protocol; - return this; - } - - public InputEndpoint build(){ - return new InputEndpoint(localPort, externalPort, name, protocol); - } - - } - - private final Integer localPort; - private final Integer externalPort; - private final String name; - private final Protocol protocol; - - public InputEndpoint(Integer localPort, Integer externalPort, String name, - Protocol protocol) { - super(); - this.localPort = localPort; - this.externalPort = externalPort; - this.name = name; - this.protocol = protocol; - } - - public Integer getLocalPort() { - return localPort; - } - - public Integer getExternalPort() { - return externalPort; - } - - public String getName() { - return name; - } - - public Protocol getProtocol() { - return protocol; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result - + ((externalPort == null) ? 0 : externalPort.hashCode()); - result = prime * result - + ((localPort == null) ? 0 : localPort.hashCode()); - result = prime * result + ((name == null) ? 0 : name.hashCode()); - result = prime * result - + ((protocol == null) ? 0 : protocol.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - InputEndpoint other = (InputEndpoint) obj; - if (externalPort == null) { - if (other.externalPort != null) - return false; - } else if (!externalPort.equals(other.externalPort)) - return false; - if (localPort == null) { - if (other.localPort != null) - return false; - } else if (!localPort.equals(other.localPort)) - return false; - if (name == null) { - if (other.name != null) - return false; - } else if (!name.equals(other.name)) - return false; - if (protocol != other.protocol) - return false; - return true; - } - - @Override - public String toString() { - return "InputEndPoint [localPort=" + localPort + ", externalPort=" - + externalPort + ", name=" + name + ", protocol=" + protocol - + "]"; - } - -} diff --git a/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/InstanceStatus.java b/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/InstanceStatus.java deleted file mode 100644 index c375052d4e..0000000000 --- a/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/InstanceStatus.java +++ /dev/null @@ -1,139 +0,0 @@ -package org.jclouds.azure.management.domain; - -import static com.google.common.base.Preconditions.checkNotNull; - -import com.google.common.base.CaseFormat; - -public enum InstanceStatus { - - /** - * The role state is currently unknown. The state should automatically be - * resolved once the role state is detected, so no action is required. - */ - ROLE_STATE_UNKNOWN, - - /** - * The host agent is currently creating resources for the Virtual Machine - * (VM). - */ - CREATING_V_M, - - /** - * The host agent is starting the Virtual Machine. - */ - STARTING_V_M, - - /** - * Windows Azure is creating resources for the role. - */ - CREATING_ROLE, - - /** - * Windows Azure is starting the role. - */ - STARTING_ROLE, - - /** - * The role instance has started and is ready to be used. - */ - READY_ROLE, - - /** - * The role instance is unavailable for requests. This state is usually - * generated while the role is being created or stopped. - */ - BUSY_ROLE, - - /** - * Windows Azure is stopping the role. - */ - STOPPING_ROLE, - - /** - * The host agent is stopping the Virtual Machine. This status also - * indicates that the role has already been stopped. - */ - STOPPING_V_M, - - /** - * The Virtual Machine is being deleted by the host agent. - */ - DELETING_V_M, - - /** - * The Virtual Machine is not running. This is the final state of the - * shutdown process, and no other status messages should be received after - * StoppedVM. - */ - STOPPED_V_M, - - /** - * The role has unexpectedly stopped or has failed to start. This status - * indicates that there is a problem with the role that is causing it to - * crash or preventing it from starting, and must be corrected before the - * role can be started. The InstanceStateDetails and InstanceErrorCode - * fields can hold information about the role error that caused this state, - * which may be useful for identifying and debugging the problem. - */ - RESTARTING_ROLE, - - /** - * The role has continually crashed after being started by Windows Azure. - * This status indicates that there is a problem with the role that prevents - * it from starting, and may be generated after the StartingRole even - * ReadyRole statuses are received. The problem in the role must be found - * and corrected before the role can be started. The InstanceStateDetails - * and InstanceErrorCode fields can hold information about the role error - * that caused this state, which may be useful for identifying and debugging - * the problem. - */ - CYCLING_ROLE, - - /** - * The role has continually failed to start. This status indicates that - * there is a problem with the role that prevents it from starting, and may - * be generated after the process returns StartingRole. The problem in the - * role must be found and corrected before the role can be started. The - * InstanceStateDetails and InstanceErrorCode fields can hold information - * about the role error that caused this state, which may be useful for - * identifying and debugging the problem. - */ - FAILED_STARTING_ROLE, - - /** - * A Windows Azure or container error is preventing the Virtual Machine from - * starting. This status is generated by Windows Azure, and does not - * indicate an error with the role. It may be generated after the - * StartingRole state. - */ - FAILED_STARTING_V_M, - - /** - * The role has timed out before receiving a status message and is not - * responding to requests. - */ - UNRESPONSIVE_ROLE, - - /** - * UNDOCUMENTED BY AZURE - */ - PROVISIONING; - - public String value() { - return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, name()); - } - - @Override - public String toString() { - return value(); - } - - public static InstanceStatus fromValue(String type) { - try { - return valueOf(CaseFormat.UPPER_CAMEL.to( - CaseFormat.UPPER_UNDERSCORE, checkNotNull(type, "type"))); - } catch (IllegalArgumentException e) { - return ROLE_STATE_UNKNOWN; - } - } -} diff --git a/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/Location.java b/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/Location.java deleted file mode 100644 index 47fe0124b5..0000000000 --- a/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/Location.java +++ /dev/null @@ -1,164 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.azure.management.domain; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.Set; - -import com.google.common.base.Objects; -import com.google.common.collect.ImmutableSet; - -/** - * - * A geographical region in which a service or storage account will be hosted. - * - * @see api - * - * @author Adrian Cole - */ -public class Location { - public static Builder builder() { - return new Builder(); - } - - public Builder toBuilder() { - return builder().fromLocation(this); - } - - public static class Builder { - - private String name; - private String displayName; - private ImmutableSet.Builder availableServices = ImmutableSet. builder(); - - /** - * @see Location#getName() - */ - public Builder name(String name) { - this.name = name; - return this; - } - - /** - * @see Location#getDisplayName() - */ - public Builder displayName(String displayName) { - this.displayName = displayName; - return this; - } - - /** - * @see Location#getAvailableServices() - */ - public Builder addAvailableService(String availableService) { - this.availableServices.add(checkNotNull(availableService, "availableService")); - return this; - } - - /** - * @see Location#getAvailableServices() - */ - public Builder availableServices(Iterable availableServices) { - this.availableServices = ImmutableSet. builder().addAll( - checkNotNull(availableServices, "availableServices")); - return this; - } - - public Location build() { - return new Location(name, displayName, availableServices.build()); - } - - public Builder fromLocation(Location in) { - return this.name(in.getName()).displayName(in.getDisplayName()).availableServices(in.getAvailableServices()); - } - } - - private final String name; - private final String displayName; - private final Set availableServices; - - protected Location(String name, String displayName, Iterable availableServices) { - this.name = checkNotNull(name, "name"); - this.displayName = checkNotNull(displayName, "displayName for %s", name); - this.availableServices = ImmutableSet.copyOf(checkNotNull(availableServices, "availableServices for %s", name)); - } - - /** - * - * The name of a data center location that is valid for your subscription. For example: - * {@code West Europe} - */ - public String getName() { - return name; - } - - /** - * The localized name of data center location. - */ - public String getDisplayName() { - return displayName; - } - - /** - * Indicates the services available at a location. - * - * Returned values are none, one, or both of the values listed below. - * - * Compute - * - * Storage - */ - public Set getAvailableServices() { - return availableServices; - } - - /** - * {@inheritDoc} - */ - @Override - public int hashCode() { - return Objects.hashCode(name); - } - - /** - * {@inheritDoc} - */ - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - Location other = (Location) obj; - return Objects.equal(this.name, other.name); - } - - /** - * {@inheritDoc} - */ - @Override - public String toString() { - return Objects.toStringHelper(this).omitNullValues().add("name", name).add("displayName", displayName) - .add("availableServices", availableServices).toString(); - } - -} diff --git a/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/OSImage.java b/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/OSImage.java deleted file mode 100644 index 41203050ad..0000000000 --- a/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/OSImage.java +++ /dev/null @@ -1,308 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.azure.management.domain; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.net.URI; - -import com.google.common.base.Objects; -import com.google.common.base.Objects.ToStringHelper; -import com.google.common.base.Optional; - -/** - * OS images from the image repository - * - * @see api - * @author Adrian Cole - */ -public class OSImage { - public static Builder builder() { - return new ConcreteBuilder(); - } - - public Builder toBuilder() { - return new ConcreteBuilder().fromHostedService(this); - } - - public abstract static class Builder> { - protected abstract T self(); - - protected OSType os; - protected String name; - protected Optional logicalSizeInGB = Optional.absent(); - protected Optional description = Optional.absent(); - protected Optional category = Optional.absent(); - protected Optional location = Optional.absent(); - protected Optional affinityGroup = Optional.absent(); - protected Optional mediaLink = Optional.absent(); - protected Optional eula = Optional.absent(); - protected String label; - - /** - * @see OSImage#getOS() - */ - public T os(OSType os) { - this.os = os; - return self(); - } - - /** - * @see OSImage#getName() - */ - public T name(String name) { - this.name = name; - return self(); - } - - /** - * @see OSImage#getDescription() - */ - public T description(String description) { - this.description = Optional.fromNullable(description); - return self(); - } - - /** - * @see OSImage#getLogicalSizeInGB() - */ - public T logicalSizeInGB(Integer logicalSizeInGB) { - this.logicalSizeInGB = Optional.fromNullable(logicalSizeInGB); - return self(); - } - - /** - * @see OSImage#getCategory() - */ - public T category(String category) { - this.category = Optional.fromNullable(category); - return self(); - } - - /** - * @see OSImage#getLocation() - */ - public T location(String location) { - this.location = Optional.fromNullable(location); - return self(); - } - - /** - * @see OSImage#getAffinityGroup() - */ - public T affinityGroup(String affinityGroup) { - this.affinityGroup = Optional.fromNullable(affinityGroup); - return self(); - } - - /** - * @see OSImage#getMediaLink() - */ - public T mediaLink(URI mediaLink) { - this.mediaLink = Optional.fromNullable(mediaLink); - return self(); - } - - /** - * @see OSImage#getEula() - */ - public T eula(URI eula) { - this.eula = Optional.fromNullable(eula); - return self(); - } - - /** - * @see OSImage#getLabel() - */ - public T label(String label) { - this.label = label; - return self(); - } - - public OSImage build() { - return new OSImage(os, name, logicalSizeInGB, description, category, location, affinityGroup, mediaLink, eula, - label); - } - - public T fromHostedService(OSImage in) { - return this.os(in.getOS()).name(in.getName()).logicalSizeInGB(in.getLogicalSizeInGB().orNull()) - .description(in.getDescription().orNull()).category(in.getCategory().orNull()) - .location(in.getLocation().orNull()).affinityGroup(in.getAffinityGroup().orNull()) - .mediaLink(in.getMediaLink().orNull()).eula(in.getEula().orNull()).label(in.getLabel()); - } - } - - private static class ConcreteBuilder extends Builder { - @Override - protected ConcreteBuilder self() { - return this; - } - } - - protected final OSType os; - protected final String name; - protected final Optional logicalSizeInGB; - protected final Optional description; - protected final Optional category; - protected final Optional location; - protected final Optional affinityGroup; - protected final Optional mediaLink; - protected final Optional eula; - protected final String label; - - protected OSImage(OSType os, String name, Optional logicalSizeInGB, Optional description, - Optional category, Optional location, Optional affinityGroup, - Optional mediaLink, Optional eula, String label) { - this.name = checkNotNull(name, "name"); - this.logicalSizeInGB = checkNotNull(logicalSizeInGB, "logicalSizeInGB for %s", name); - this.description = checkNotNull(description, "description for %s", name); - this.os = checkNotNull(os, "os for %s", name); - this.category = checkNotNull(category, "category for %s", name); - this.location = checkNotNull(location, "location for %s", name); - this.affinityGroup = checkNotNull(affinityGroup, "affinityGroup for %s", name); - this.mediaLink = checkNotNull(mediaLink, "mediaLink for %s", name); - this.eula = checkNotNull(eula, "eula for %s", name); - this.label = checkNotNull(label, "label for %s", name); - } - - /** - * The operating system type of the OS image. - */ - public OSType getOS() { - return os; - } - - /** - * The name of the hosted service. This name is the DNS prefix name and can be used to access the - * hosted service. - * - * For example, if the service name is MyService you could access the access the service by - * calling: http://MyService.cloudapp.net - */ - public String getName() { - return name; - } - - /** - * The size, in GB, of the image. - */ - public Optional getLogicalSizeInGB() { - return logicalSizeInGB; - } - - /** - * The description for the image. - */ - public Optional getDescription() { - return description; - } - - /** - * The repository classification of image. All user images have the category "User", but - * categories for other images could be, for example "Canonical" - */ - public Optional getCategory() { - return category; - } - - /** - * The geo-location in which this media is located. The Location value is derived from storage - * account that contains the blob in which the media is located. If the storage account belongs - * to an affinity group the value is absent. - */ - public Optional getLocation() { - return location; - } - - /** - * The affinity in which the media is located. The AffinityGroup value is derived from storage - * account that contains the blob in which the media is located. If the storage account does not - * belong to an affinity group the value is absent. - */ - public Optional getAffinityGroup() { - return affinityGroup; - } - - /** - * The location of the blob in the blob store in which the media for the image is located. The - * blob location belongs to a storage account in the subscription specified by the - * value in the operation call. - * - * Example: - * - * http://example.blob.core.windows.net/disks/myimage.vhd - */ - public Optional getMediaLink() { - return mediaLink; - } - - /** - * The eula for the image, if available. - */ - public Optional getEula() { - return eula; - } - - /** - * The description of the image. - */ - public String getLabel() { - return label; - } - - /** - * {@inheritDoc} - */ - @Override - public int hashCode() { - return Objects.hashCode(name); - } - - /** - * {@inheritDoc} - */ - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - OSImage other = (OSImage) obj; - return Objects.equal(this.name, other.name); - } - - /** - * {@inheritDoc} - */ - @Override - public String toString() { - return string().toString(); - } - - protected ToStringHelper string() { - return Objects.toStringHelper(this).omitNullValues().add("os", os).add("name", name) - .add("logicalSizeInGB", logicalSizeInGB.orNull()).add("description", description) - .add("category", category.orNull()).add("location", location.orNull()) - .add("affinityGroup", affinityGroup.orNull()).add("mediaLink", mediaLink.orNull()) - .add("eula", eula.orNull()).add("label", label); - } - -} diff --git a/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/OSImageParams.java b/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/OSImageParams.java deleted file mode 100644 index 6c42dc60c1..0000000000 --- a/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/OSImageParams.java +++ /dev/null @@ -1,179 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.azure.management.domain; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.net.URI; - -import com.google.common.base.Objects; -import com.google.common.base.Objects.ToStringHelper; - -/** - * The Add OS Image operation adds an OS image that is currently stored in a storage account in your - * subscription to the image repository. - * - * @see api - * @author Adrian Cole - */ -public class OSImageParams { - - public static Builder builder() { - return new Builder(); - } - - public Builder toBuilder() { - return builder().fromHostedService(this); - } - - public static class Builder { - - protected String label; - protected URI mediaLink; - protected OSType os; - protected String name; - - /** - * @see OSImageParams#getLabel() - */ - public Builder label(String label) { - this.label = label; - return this; - } - - /** - * @see OSImageParams#getMediaLink() - */ - public Builder mediaLink(URI mediaLink) { - this.mediaLink = mediaLink; - return this; - } - - /** - * @see OSImageParams#getName() - */ - public Builder name(String name) { - this.name = name; - return this; - } - - /** - * @see OSImageParams#getOS() - */ - public Builder os(OSType os) { - this.os = os; - return this; - } - - public OSImageParams build() { - return new OSImageParams(label, mediaLink, name, os); - } - - public Builder fromHostedService(OSImageParams in) { - return this.label(in.getLabel()).mediaLink(in.getMediaLink()).name(in.getName()).os(in.getOS()); - } - } - - protected final String label; - protected final URI mediaLink; - protected final String name; - protected final OSType os; - - protected OSImageParams(String label, URI mediaLink, String name, OSType os) { - this.label = checkNotNull(label, "label"); - this.name = checkNotNull(name, "name for %s", label); - this.mediaLink = checkNotNull(mediaLink, "mediaLink for %s", label); - this.os = checkNotNull(os, "os for %s", label); - } - - /** - * The operating system type of the OS image. - */ - public OSType getOS() { - return os; - } - - /** - * The name of the hosted service. This name is the DNS prefix name and can be used to access the - * hosted service. - * - * For example, if the service name is MyService you could access the access the service by - * calling: http://MyService.cloudapp.net - */ - public String getName() { - return name; - } - - /** - * The location of the blob in the blob store in which the media for the image is located. The - * blob location belongs to a storage account in the subscription specified by the - * value in the operation call. - * - * Example: - * - * http://example.blob.core.windows.net/disks/myimage.vhd - */ - public URI getMediaLink() { - return mediaLink; - } - - /** - * The description of the image. - */ - public String getLabel() { - return label; - } - - /** - * {@inheritDoc} - */ - @Override - public int hashCode() { - return Objects.hashCode(name); - } - - /** - * {@inheritDoc} - */ - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - OSImageParams other = (OSImageParams) obj; - return Objects.equal(this.name, other.name); - } - - /** - * {@inheritDoc} - */ - @Override - public String toString() { - return string().toString(); - } - - protected ToStringHelper string() { - return Objects.toStringHelper(this).add("label", label).add("mediaLink", mediaLink).add("name", name) - .add("os", os); - } - -} diff --git a/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/OSType.java b/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/OSType.java deleted file mode 100644 index 2a713ebcc1..0000000000 --- a/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/OSType.java +++ /dev/null @@ -1,49 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.azure.management.domain; - -import static com.google.common.base.Preconditions.checkNotNull; - -import com.google.common.base.CaseFormat; - -public enum OSType { - - LINUX, - - WINDOWS, - - UNRECOGNIZED; - - public String value() { - return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, name()); - } - - @Override - public String toString() { - return value(); - } - - public static OSType fromValue(String type) { - try { - return valueOf(CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, checkNotNull(type, "type"))); - } catch (IllegalArgumentException e) { - return UNRECOGNIZED; - } - } -} diff --git a/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/Operation.java b/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/Operation.java deleted file mode 100644 index 5009e574dd..0000000000 --- a/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/Operation.java +++ /dev/null @@ -1,213 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.azure.management.domain; - -import static com.google.common.base.Preconditions.checkNotNull; - -import com.google.common.base.CaseFormat; -import com.google.common.base.Objects; -import com.google.common.base.Optional; - -/** - * - * Determines whether the operation has succeeded, failed, or is still in progress. - * - * @see api - * - * @author Adrian Cole - */ -public class Operation { - - public static enum Status { - - IN_PROGRESS, - - SUCCEEDED, - - FAILED, - - UNRECOGNIZED; - - public String value() { - return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, name()); - } - - @Override - public String toString() { - return value(); - } - - public static Status fromValue(String status) { - try { - return valueOf(CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, checkNotNull(status, "status"))); - } catch (IllegalArgumentException e) { - return UNRECOGNIZED; - } - } - } - - public static Builder builder() { - return new Builder(); - } - - public Builder toBuilder() { - return builder().fromOperation(this); - } - - public static class Builder { - - private String id; - private String rawStatus; - private Status status; - // When the operation is in progress, no status code is returned - private Optional httpStatusCode = Optional.absent(); - private Optional error = Optional.absent(); - - /** - * @see Operation#getId() - */ - public Builder id(String id) { - this.id = id; - return this; - } - - /** - * @see Operation#getRawStatus() - */ - public Builder rawStatus(String rawStatus) { - this.rawStatus = rawStatus; - return this; - } - - /** - * @see Operation#getStatus() - */ - public Builder status(Status status) { - this.status = status; - return this; - } - - /** - * @see Operation#getHttpStatusCode() - */ - public Builder httpStatusCode(Integer httpStatusCode) { - this.httpStatusCode = Optional.fromNullable(httpStatusCode); - return this; - } - - /** - * @see Operation#getError() - */ - public Builder error(Error error) { - this.error = Optional.fromNullable(error); - return this; - } - - public Operation build() { - return new Operation(id, rawStatus, status, httpStatusCode, error); - } - - public Builder fromOperation(Operation in) { - return this.id(in.id).rawStatus(in.rawStatus).status(in.status).httpStatusCode(in.httpStatusCode.orNull()) - .error(in.error.orNull()); - } - } - - private final String id; - private final String rawStatus; - private final Status status; - private final Optional httpStatusCode; - private final Optional error; - - protected Operation(String id, String rawStatus, Status status, Optional httpStatusCode, Optional error) { - this.id = checkNotNull(id, "id"); - this.rawStatus = checkNotNull(rawStatus, "rawStatus for %s", id); - this.status = checkNotNull(status, "status for %s", id); - this.httpStatusCode = checkNotNull(httpStatusCode, "httpStatusCode for %s", id); - this.error = checkNotNull(error, "error for %s", id); - } - - /** - * The request ID of the asynchronous request. - */ - public String getId() { - return id; - } - - /** - * The status of the asynchronous request. - */ - public Status getStatus() { - return status; - } - - /** - * The status of the asynchronous request, unparsed - */ - public String getRawStatus() { - return rawStatus; - } - - /** - * The HTTP status code for the asynchronous request. - */ - public Optional getHttpStatusCode() { - return httpStatusCode; - } - - /** - * The management service error returned if the asynchronous request failed. - */ - public Optional getError() { - return error; - } - - /** - * {@inheritDoc} - */ - @Override - public int hashCode() { - return Objects.hashCode(id); - } - - /** - * {@inheritDoc} - */ - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - Operation other = (Operation) obj; - return Objects.equal(this.id, other.id); - } - - /** - * {@inheritDoc} - */ - @Override - public String toString() { - return Objects.toStringHelper(this).omitNullValues().add("id", id).add("status", rawStatus) - .add("httpStatusCode", httpStatusCode).add("error", error.orNull()).toString(); - } - -} diff --git a/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/RoleSize.java b/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/RoleSize.java deleted file mode 100644 index 21400d0f40..0000000000 --- a/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/RoleSize.java +++ /dev/null @@ -1,27 +0,0 @@ -package org.jclouds.azure.management.domain; - -import static com.google.common.base.Preconditions.checkNotNull; - -import com.google.common.base.CaseFormat; - -public enum RoleSize { - EXTRA_SMALL, SMALL, MEDIUM, LARGE, EXTRA_LARGE; - - public String value() { - return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, name()); - } - - @Override - public String toString() { - return value(); - } - - public static RoleSize fromValue(String type) { - try { - return valueOf(CaseFormat.UPPER_CAMEL.to( - CaseFormat.UPPER_UNDERSCORE, checkNotNull(type, "type"))); - } catch (IllegalArgumentException e) { - return null; - } - } -} diff --git a/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/hostedservice/CreateDeployment.java b/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/hostedservice/CreateDeployment.java deleted file mode 100644 index 9b826f2685..0000000000 --- a/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/hostedservice/CreateDeployment.java +++ /dev/null @@ -1,198 +0,0 @@ -package org.jclouds.azure.management.domain.hostedservice; - -import java.util.List; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlElementWrapper; -import javax.xml.bind.annotation.XmlRootElement; - -import com.google.common.collect.Lists; - -@XmlRootElement(name = "CreateDeployment") -public class CreateDeployment { - - /** - * The name for the deployment. The deployment name must be unique among other deployments for - * the hosted service. - */ - @XmlElement(required = true, name = "Name") - private String name; - - /** - * A URL that refers to the location of the service package in the Blob service. The service - * package can be located either in a storage account beneath the same subscription or a Shared - * Access Signature (SAS) URI from any storage account. - */ - @XmlElement(required = true, name = "PackageUrl") - private String packageUrl; - - /** - * The base-64 encoded service configuration file for the deployment. - */ - @XmlElement(required = true, name = "Configuration") - private String configuration; - - /** - * A name for the hosted service that is base-64 encoded. The name can be up to 100 characters in - * length. - * - * It is recommended that the label be unique within the subscription. The name can be used - * identify the hosted service for your tracking purposes. - */ - @XmlElement(required = true, name = "Label") - private String label; - - /** - * - * Indicates whether to start the deployment immediately after it is created. The default value - * is false. - * - * If false, the service model is still deployed to the virtual machines but the code is not run - * immediately. Instead, the service is Suspended until you call Update Deployment Status and set - * the status to Running, at which time the service will be started. A deployed service still - * incurs charges, even if it is suspended. - */ - @XmlElement(name = "StartDeployment") - private Boolean startDeployment; - - /** - * - * Optional. Indicates whether to treat package validation warnings as errors. The default value - * is false. If set to true, the Created Deployment operation fails if there are validation - * warnings on the service package. - */ - @XmlElement(name = "TreatWarningsAsError") - private Boolean treatWarningsAsError; - - @XmlElementWrapper(name = "ExtendedProperties") - @XmlElement(required = true, name = "ExtendedProperty") - private List extendedProperties = Lists.newArrayList(); - - public CreateDeployment() { - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getPackageUrl() { - return packageUrl; - } - - public void setPackageUrl(String packageUrl) { - this.packageUrl = packageUrl; - } - - public String getConfiguration() { - return configuration; - } - - public void setConfiguration(String configuration) { - this.configuration = configuration; - } - - public String getLabel() { - return label; - } - - public void setLabel(String label) { - this.label = label; - } - - public Boolean getStartDeployment() { - return startDeployment; - } - - public void setStartDeployment(Boolean startDeployment) { - this.startDeployment = startDeployment; - } - - public Boolean getTreatWarningsAsError() { - return treatWarningsAsError; - } - - public void setTreatWarningsAsError(Boolean treatWarningsAsError) { - this.treatWarningsAsError = treatWarningsAsError; - } - - public List getExtendedProperties() { - return extendedProperties; - } - - public void setExtendedProperties(List extendedProperties) { - this.extendedProperties = extendedProperties; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((configuration == null) ? 0 : configuration.hashCode()); - result = prime * result + ((extendedProperties == null) ? 0 : extendedProperties.hashCode()); - result = prime * result + ((label == null) ? 0 : label.hashCode()); - result = prime * result + ((name == null) ? 0 : name.hashCode()); - result = prime * result + ((packageUrl == null) ? 0 : packageUrl.hashCode()); - result = prime * result + ((startDeployment == null) ? 0 : startDeployment.hashCode()); - result = prime * result + ((treatWarningsAsError == null) ? 0 : treatWarningsAsError.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - CreateDeployment other = (CreateDeployment) obj; - if (configuration == null) { - if (other.configuration != null) - return false; - } else if (!configuration.equals(other.configuration)) - return false; - if (extendedProperties == null) { - if (other.extendedProperties != null) - return false; - } else if (!extendedProperties.equals(other.extendedProperties)) - return false; - if (label == null) { - if (other.label != null) - return false; - } else if (!label.equals(other.label)) - return false; - if (name == null) { - if (other.name != null) - return false; - } else if (!name.equals(other.name)) - return false; - if (packageUrl == null) { - if (other.packageUrl != null) - return false; - } else if (!packageUrl.equals(other.packageUrl)) - return false; - if (startDeployment == null) { - if (other.startDeployment != null) - return false; - } else if (!startDeployment.equals(other.startDeployment)) - return false; - if (treatWarningsAsError == null) { - if (other.treatWarningsAsError != null) - return false; - } else if (!treatWarningsAsError.equals(other.treatWarningsAsError)) - return false; - return true; - } - - @Override - public String toString() { - return "CreateDeployment [name=" + name + ", packageUrl=" + packageUrl + ", configuration=" + configuration - + ", label=" + label + ", startDeployment=" + startDeployment + ", treatWarningsAsError=" - + treatWarningsAsError + ", extendedProperties=" + extendedProperties + "]"; - } - -} diff --git a/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/hostedservice/ExtendedProperty.java b/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/hostedservice/ExtendedProperty.java deleted file mode 100644 index ad13d717e5..0000000000 --- a/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/hostedservice/ExtendedProperty.java +++ /dev/null @@ -1,86 +0,0 @@ -package org.jclouds.azure.management.domain.hostedservice; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; - -@XmlRootElement(name = "ExtendedProperty") -public class ExtendedProperty { - - /** - * Represents the name of an extended hosted service property. Each extended property must have - * both a defined name and value. You can have a maximum of 50 extended property name/value - * pairs. - * - * The maximum length of the Name element is 64 characters, only alphanumeric characters and - * underscores are valid in the Name, and the name must start with a letter. Attempting to use - * other characters, starting the Name with a non-letter character, or entering a name that is - * identical to that of another extended property owned by the same hosted service, will result - * in a status code 400 (Bad Request) error. - */ - @XmlElement(name = "Name") - private String name; - - /** - * Represents the value of an extended hosted service property. Each extended property must have - * both a defined name and value. You can have a maximum of 50 extended property name/value - * pairs, and each extended property value has a maximum length of 255 characters. - */ - @XmlElement(name = "Value") - private String value; - - public ExtendedProperty() { - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getValue() { - return value; - } - - public void setValue(String value) { - this.value = value; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((name == null) ? 0 : name.hashCode()); - result = prime * result + ((value == null) ? 0 : value.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - ExtendedProperty other = (ExtendedProperty) obj; - if (name == null) { - if (other.name != null) - return false; - } else if (!name.equals(other.name)) - return false; - if (value == null) { - if (other.value != null) - return false; - } else if (!value.equals(other.value)) - return false; - return true; - } - - @Override - public String toString() { - return "ExtendedProperty [name=" + name + ", value=" + value + "]"; - } - -} diff --git a/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/hostedservice/package-info.java b/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/hostedservice/package-info.java deleted file mode 100644 index 157ed360bc..0000000000 --- a/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/hostedservice/package-info.java +++ /dev/null @@ -1,26 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -@XmlSchema(namespace = "http://schemas.microsoft.com/windowsazure", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED) -@XmlAccessorType(XmlAccessType.FIELD) -package org.jclouds.azure.management.domain.hostedservice; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlSchema; - diff --git a/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/role/AbstractRole.java b/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/role/AbstractRole.java deleted file mode 100644 index 92216fdc69..0000000000 --- a/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/role/AbstractRole.java +++ /dev/null @@ -1,127 +0,0 @@ -package org.jclouds.azure.management.domain.role; - -import java.util.List; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlElementWrapper; - -import com.google.common.collect.Lists; - -import org.jclouds.azure.management.domain.role.conf.ConfigurationSet; - -//@XmlRootElement(name = "PersistentVMRole") -public abstract class AbstractRole { - - /** - * Specifies the name for the virtual machine. The name must be unique within Windows Azure. - */ - @XmlElement(required = true, name = "RoleName") - private String roleName; - - /** - * The type of the role for the virtual machine. The only supported value is PersistentVMRole. - */ - @XmlElement(required = true, name = "RoleType") - private String roleType; - - /** - * Required. You must specify either a WindowsProvisioningConfigurationSet or - * LinuxProvisioningConfigurationSet configuration set. - * - * Optional. You can specify a NetworkConfigurationSet which contains the metadata required to - * create the virtual network configuration for a virtual machine. - */ - @XmlElementWrapper(name = "ConfigurationSets") - @XmlElement(name = "ConfigurationSet") - private List configurationSets = Lists.newArrayListWithCapacity(0); - - /** - * Specifies the name of an availability set to which to add the virtual machine. This value - * controls the virtual machine allocation in the Windows Azure environment. Virtual machines - * specified in the same availability set are allocated to different nodes to maximize - * availability. - */ - @XmlElement(name = "AvailabilitySetName") - private String availabilitySetName; - - @XmlElementWrapper(name = "DataVirtualHardDisks") - @XmlElement(name = "DataVirtualHardDisk") - private List dataVirtualHardDisks = Lists.newArrayListWithCapacity(0); - - @XmlElement(name = "OSVirtualHardDisk") - private OSVirtualHardDisk osVirtualHardDisk; - - /** - * The size of the virtual machine to allocate. The default value is Small. - */ - @XmlElement(name = "RoleSize") - private RoleSize roleSize; - - public AbstractRole() { - super(); - } - - public String getRoleName() { - return roleName; - } - - public String getRoleType() { - return roleType; - } - - public String getAvailabilitySetName() { - return availabilitySetName; - } - - public RoleSize getRoleSize() { - return roleSize; - } - - public void setRoleName(String roleName) { - this.roleName = roleName; - } - - public void setRoleType(String roleType) { - this.roleType = roleType; - } - - public void setAvailabilitySetName(String availabilitySetName) { - this.availabilitySetName = availabilitySetName; - } - - public void setRoleSize(RoleSize roleSize) { - this.roleSize = roleSize; - } - - public void setOsVirtualHardDisk(OSVirtualHardDisk osVirtualHardDisk) { - this.osVirtualHardDisk = osVirtualHardDisk; - } - - public OSVirtualHardDisk getOsVirtualHardDisk() { - return osVirtualHardDisk; - } - - public List getConfigurationSets() { - return configurationSets; - } - - public void setConfigurationSets(List configurationSets) { - this.configurationSets = configurationSets; - } - - public List getDataVirtualHardDisks() { - return dataVirtualHardDisks; - } - - public void setDataVirtualHardDisks(List dataVirtualHardDisks) { - this.dataVirtualHardDisks = dataVirtualHardDisks; - } - - @Override - public String toString() { - return "Role [roleName=" + roleName + ", roleType=" + roleType + ", availabilitySetName=" + availabilitySetName - + ", roleSize=" + roleSize + ", osVirtualHardDisk=" + osVirtualHardDisk + ", configurationSets=" - + configurationSets + ", dataVirtualHardDisks=" + dataVirtualHardDisks + "]"; - } - -} diff --git a/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/role/DNS.java b/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/role/DNS.java deleted file mode 100644 index fdaec370e3..0000000000 --- a/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/role/DNS.java +++ /dev/null @@ -1,62 +0,0 @@ -package org.jclouds.azure.management.domain.role; - -import java.util.List; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlElementWrapper; -import javax.xml.bind.annotation.XmlRootElement; - -import com.google.common.collect.Lists; - -@XmlRootElement(name = "Dns") -public class DNS { - /** - * Contains the parameters specifying the DNS servers to use for the virtual machine. - */ - @XmlElementWrapper(required = true, name = "DnsServers") - @XmlElement(name = "DnsServer") - private List dnsServers = Lists.newArrayList(); - - public DNS() { - super(); - } - - public List getDnsServers() { - return dnsServers; - } - - public void setDnsServers(List dnsServers) { - this.dnsServers = dnsServers; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((dnsServers == null) ? 0 : dnsServers.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - DNS other = (DNS) obj; - if (dnsServers == null) { - if (other.dnsServers != null) - return false; - } else if (!dnsServers.equals(other.dnsServers)) - return false; - return true; - } - - @Override - public String toString() { - return "DNS [dnsServers=" + dnsServers + "]"; - } - -} diff --git a/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/role/DNSServer.java b/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/role/DNSServer.java deleted file mode 100644 index d65dd490e2..0000000000 --- a/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/role/DNSServer.java +++ /dev/null @@ -1,77 +0,0 @@ -package org.jclouds.azure.management.domain.role; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; - -@XmlRootElement(name = "DnsServer") -public class DNSServer { - - /** - * Specifies the name of the DNS server. - */ - @XmlElement(required = true, name = "Name") - private String name; - - /** - * Specifies the IP address of the DNS server. - */ - @XmlElement(required = true, name = "Address") - private String address; - - public DNSServer() { - super(); - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getAddress() { - return address; - } - - public void setAddress(String address) { - this.address = address; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((address == null) ? 0 : address.hashCode()); - result = prime * result + ((name == null) ? 0 : name.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - DNSServer other = (DNSServer) obj; - if (address == null) { - if (other.address != null) - return false; - } else if (!address.equals(other.address)) - return false; - if (name == null) { - if (other.name != null) - return false; - } else if (!name.equals(other.name)) - return false; - return true; - } - - @Override - public String toString() { - return "DNSServer [name=" + name + ", address=" + address + "]"; - } - -} diff --git a/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/role/DataVirtualHardDisk.java b/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/role/DataVirtualHardDisk.java deleted file mode 100644 index 333992f264..0000000000 --- a/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/role/DataVirtualHardDisk.java +++ /dev/null @@ -1,41 +0,0 @@ -package org.jclouds.azure.management.domain.role; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; - -@XmlRootElement(name = "DataVirtualHardDisk") -public class DataVirtualHardDisk extends VirtualHardDisk { - - @XmlElement(name = "Lun") - private Integer lun; - - @XmlElement(name = "LogicalDiskSizeInGB") - private Integer logicalDiskSizeInGB; - - public DataVirtualHardDisk() { - - } - - public Integer getLun() { - return lun; - } - - public void setLun(Integer lun) { - this.lun = lun; - } - - public Integer getLogicalDiskSizeInGB() { - return logicalDiskSizeInGB; - } - - public void setLogicalDiskSizeInGB(Integer logicalDiskSizeInGB) { - this.logicalDiskSizeInGB = logicalDiskSizeInGB; - } - - @Override - public String toString() { - return "DataVirtualHardDisk [lun=" + lun + ", logicalDiskSizeInGB=" + logicalDiskSizeInGB + ", hostCaching=" - + hostCaching + ", diskLabel=" + diskLabel + ", diskName=" + diskName + ", mediaLink=" + mediaLink + "]"; - } - -} diff --git a/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/role/Deployment.java b/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/role/Deployment.java deleted file mode 100644 index 2ce2973f32..0000000000 --- a/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/role/Deployment.java +++ /dev/null @@ -1,169 +0,0 @@ -package org.jclouds.azure.management.domain.role; - -import java.util.List; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlElementWrapper; -import javax.xml.bind.annotation.XmlRootElement; - -import com.google.common.collect.Lists; - -@XmlRootElement(name = "Deployment") -public class Deployment { - - /** - * A name for the deployment. The deployment name must be unique among other deployments for the - * hosted service. - */ - @XmlElement(required = true, name = "Name") - private String name; - - /** - * Specifies the environment in which to deploy the virtual machine. - * - * Possible values are: Staging Production - */ - @XmlElement(required = true, name = "DeploymentSlot") - private String deploymentSlot; - - /** - * A name for the hosted service that is base-64 encoded. The name can be up to 100 characters in - * length. - * - * It is recommended that the label be unique within the subscription. The name can be used - * identify the hosted service for tracking purposes. - */ - @XmlElement(required = true, name = "Label") - private String label; - - @XmlElementWrapper(required = true, name = "RoleList") - @XmlElement(required = true, name = "Role") - private List roleList = Lists.newArrayList(); - - /** - * Specifies the name of an existing virtual network to which the deployment will belong. - * - * Virtual networks are created by calling the Set Network Configuration operation. - */ - @XmlElement(required = true, name = "VirtualNetworkName") - private String virtualNetworkName; - - /** - * Contains a list of DNS servers to associate with the machine. - */ - @XmlElement(required = true, name = "Dns") - private DNS dns; - - public Deployment() { - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getDeploymentSlot() { - return deploymentSlot; - } - - public void setDeploymentSlot(String deploymentSlot) { - this.deploymentSlot = deploymentSlot; - } - - public String getLabel() { - return label; - } - - public void setLabel(String label) { - this.label = label; - } - - public List getRoleList() { - return roleList; - } - - public void setRoleList(List roleList) { - this.roleList = roleList; - } - - public String getVirtualNetworkName() { - return virtualNetworkName; - } - - public void setVirtualNetworkName(String virtualNetworkName) { - this.virtualNetworkName = virtualNetworkName; - } - - public DNS getDns() { - return dns; - } - - public void setDns(DNS dns) { - this.dns = dns; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((deploymentSlot == null) ? 0 : deploymentSlot.hashCode()); - result = prime * result + ((dns == null) ? 0 : dns.hashCode()); - result = prime * result + ((label == null) ? 0 : label.hashCode()); - result = prime * result + ((name == null) ? 0 : name.hashCode()); - result = prime * result + ((roleList == null) ? 0 : roleList.hashCode()); - result = prime * result + ((virtualNetworkName == null) ? 0 : virtualNetworkName.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - Deployment other = (Deployment) obj; - if (deploymentSlot == null) { - if (other.deploymentSlot != null) - return false; - } else if (!deploymentSlot.equals(other.deploymentSlot)) - return false; - if (dns == null) { - if (other.dns != null) - return false; - } else if (!dns.equals(other.dns)) - return false; - if (label == null) { - if (other.label != null) - return false; - } else if (!label.equals(other.label)) - return false; - if (name == null) { - if (other.name != null) - return false; - } else if (!name.equals(other.name)) - return false; - if (roleList == null) { - if (other.roleList != null) - return false; - } else if (!roleList.equals(other.roleList)) - return false; - if (virtualNetworkName == null) { - if (other.virtualNetworkName != null) - return false; - } else if (!virtualNetworkName.equals(other.virtualNetworkName)) - return false; - return true; - } - - @Override - public String toString() { - return "Deployment [name=" + name + ", deploymentSlot=" + deploymentSlot + ", label=" + label + ", roleList=" - + roleList + ", virtualNetworkName=" + virtualNetworkName + ", dns=" + dns + "]"; - } - -} diff --git a/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/role/HostCaching.java b/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/role/HostCaching.java deleted file mode 100644 index 0cb9cfa5db..0000000000 --- a/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/role/HostCaching.java +++ /dev/null @@ -1,13 +0,0 @@ -package org.jclouds.azure.management.domain.role; - -import javax.xml.bind.annotation.XmlEnum; -import javax.xml.bind.annotation.XmlEnumValue; -import javax.xml.bind.annotation.XmlType; - -@XmlType(name = "HostCaching") -@XmlEnum -public enum HostCaching { - @XmlEnumValue("ReadOnly") - ReadOnly, @XmlEnumValue("ReadWrite") - ReadWrite; -} diff --git a/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/role/OSVirtualHardDisk.java b/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/role/OSVirtualHardDisk.java deleted file mode 100644 index 96eb9e7897..0000000000 --- a/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/role/OSVirtualHardDisk.java +++ /dev/null @@ -1,53 +0,0 @@ -package org.jclouds.azure.management.domain.role; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; - -/** - * Contains the parameters Windows Azure uses to create the operating system - * disk for the virtual machine. - * - * @author gpereira - * - */ -@XmlRootElement(name = "OSVirtualHardDisk") -public class OSVirtualHardDisk extends VirtualHardDisk { - - /** - * Specifies the name of the disk image to use to create the virtual - * machine. - */ - @XmlElement(name = "SourceImageName") - private String sourceImageName; - - @XmlElement(name = "OS") - private String os; - - public OSVirtualHardDisk() { - - } - - public String getSourceImageName() { - return sourceImageName; - } - - public void setSourceImageName(String sourceImageName) { - this.sourceImageName = sourceImageName; - } - - public void setOs(String os) { - this.os = os; - } - - public String getOs() { - return os; - } - - @Override - public String toString() { - return "OSVirtualHardDisk [hostCaching=" + hostCaching + ", diskLabel=" - + diskLabel + ", diskName=" + diskName + ", mediaLink=" - + mediaLink + ", sourceImageName=" + sourceImageName + "]"; - } - -} diff --git a/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/role/PersistentVMRole.java b/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/role/PersistentVMRole.java deleted file mode 100644 index 94ff8e1fa4..0000000000 --- a/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/role/PersistentVMRole.java +++ /dev/null @@ -1,8 +0,0 @@ -package org.jclouds.azure.management.domain.role; - -import javax.xml.bind.annotation.XmlRootElement; - -@XmlRootElement(name = "PersistentVMRole") -public class PersistentVMRole extends AbstractRole { - -} diff --git a/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/role/Protocol.java b/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/role/Protocol.java deleted file mode 100644 index a7cba7a4d1..0000000000 --- a/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/role/Protocol.java +++ /dev/null @@ -1,15 +0,0 @@ -package org.jclouds.azure.management.domain.role; - -import javax.xml.bind.annotation.XmlEnum; -import javax.xml.bind.annotation.XmlEnumValue; -import javax.xml.bind.annotation.XmlType; - -@XmlType(name = "Protocol") -@XmlEnum -public enum Protocol { - @XmlEnumValue("tcp") - TCP, @XmlEnumValue("http") - HTTP, @XmlEnumValue("udp") - UDP; - -} diff --git a/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/role/Role.java b/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/role/Role.java deleted file mode 100644 index 5cec3d007e..0000000000 --- a/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/role/Role.java +++ /dev/null @@ -1,8 +0,0 @@ -package org.jclouds.azure.management.domain.role; - -import javax.xml.bind.annotation.XmlRootElement; - -@XmlRootElement(name = "Role") -public class Role extends AbstractRole { - -} diff --git a/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/role/RoleSize.java b/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/role/RoleSize.java deleted file mode 100644 index c56b70fd27..0000000000 --- a/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/role/RoleSize.java +++ /dev/null @@ -1,20 +0,0 @@ -package org.jclouds.azure.management.domain.role; - -import javax.xml.bind.annotation.XmlEnum; -import javax.xml.bind.annotation.XmlEnumValue; -import javax.xml.bind.annotation.XmlType; - -@XmlType(name = "RoleSize") -@XmlEnum -public enum RoleSize { - @XmlEnumValue("ExtraSmall") - ExtraSmall, - @XmlEnumValue("Small") - Small, - @XmlEnumValue("Medium") - Medium, - @XmlEnumValue("Large") - Large, - @XmlEnumValue("ExtraLarge") - ExtraLarge; -} diff --git a/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/role/VirtualHardDisk.java b/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/role/VirtualHardDisk.java deleted file mode 100644 index 078708809b..0000000000 --- a/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/role/VirtualHardDisk.java +++ /dev/null @@ -1,72 +0,0 @@ -package org.jclouds.azure.management.domain.role; - -import javax.xml.bind.annotation.XmlElement; - -public class VirtualHardDisk { - - /** - * Specifies whether the OS disk can be cached for greater efficiency during writes. This setting - * impacts the consistency and performance of the OS disk. The default value is ReadWrite. - */ - @XmlElement(name = "HostCaching") - protected HostCaching hostCaching; - /** - * Specifies the friendly name of the disk containing the guest OS image in the image repository. - */ - @XmlElement(name = "DiskLabel") - protected String diskLabel; - /** - * Specifies the name of an operating system image in the image repository. - */ - @XmlElement(name = "DiskName") - protected String diskName; - /** - * Specifies the URI for a blob in a Windows Azure storage account that contains the OS image to - * use to create the OS disk. - */ - @XmlElement(name = "MediaLink") - protected String mediaLink; - - public VirtualHardDisk() { - - } - - public HostCaching getHostCaching() { - return hostCaching; - } - - public void setHostCaching(HostCaching hostCaching) { - this.hostCaching = hostCaching; - } - - public String getDiskLabel() { - return diskLabel; - } - - public void setDiskLabel(String diskLabel) { - this.diskLabel = diskLabel; - } - - public String getDiskName() { - return diskName; - } - - public void setDiskName(String diskName) { - this.diskName = diskName; - } - - public String getMediaLink() { - return mediaLink; - } - - public void setMediaLink(String mediaLink) { - this.mediaLink = mediaLink; - } - - @Override - public String toString() { - return "VirtualHardDisk [hostCaching=" + hostCaching + ", diskLabel=" + diskLabel + ", diskName=" + diskName - + ", mediaLink=" + mediaLink + "]"; - } - -} diff --git a/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/role/conf/CertificateSetting.java b/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/role/conf/CertificateSetting.java deleted file mode 100644 index 150b6c1ef6..0000000000 --- a/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/role/conf/CertificateSetting.java +++ /dev/null @@ -1,62 +0,0 @@ -package org.jclouds.azure.management.domain.role.conf; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; - -@XmlRootElement(name = "CertificateSetting") -public class CertificateSetting { - - /** - * Specifies the name of the certificate store from which retrieve certificate. - */ - @XmlElement(required = true, name = "StoreLocation") - private String StoreLocation; - /** - * Specifies the target certificate store location on the virtual machine. - * - * The only supported value is LocalMachine. - */ - @XmlElement(required = true, name = "StoreName") - private String StoreName; - /** - * Specifies the thumbprint of the certificate to be provisioned. The thumbprint must specify an - * existing service certificate. - */ - @XmlElement(required = true, name = "Thumbprint") - private String Thumbprint; - - public CertificateSetting() { - super(); - } - - public String getStoreLocation() { - return StoreLocation; - } - - public void setStoreLocation(String storeLocation) { - StoreLocation = storeLocation; - } - - public String getStoreName() { - return StoreName; - } - - public void setStoreName(String storeName) { - StoreName = storeName; - } - - public String getThumbprint() { - return Thumbprint; - } - - public void setThumbprint(String thumbprint) { - Thumbprint = thumbprint; - } - - @Override - public String toString() { - return "CertificateSetting [StoreLocation=" + StoreLocation + ", StoreName=" + StoreName + ", Thumbprint=" - + Thumbprint + "]"; - } - -} diff --git a/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/role/conf/ConfigurationSet.java b/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/role/conf/ConfigurationSet.java deleted file mode 100644 index 911d4abca8..0000000000 --- a/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/role/conf/ConfigurationSet.java +++ /dev/null @@ -1,31 +0,0 @@ -package org.jclouds.azure.management.domain.role.conf; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; - -@XmlJavaTypeAdapter(ConfigurationSetAdapter.class) -public abstract class ConfigurationSet { - - /** - * Specifies the configuration set type. - */ - @XmlElement(required = true, name = "ConfigurationSetType") - protected String configurationSetType; - - public ConfigurationSet() { - } - - public String getConfigurationSetType() { - return configurationSetType; - } - - public void setConfigurationSetType(String configurationSetType) { - this.configurationSetType = configurationSetType; - } - - @Override - public String toString() { - return "ConfigurationSet [configurationSetType=" + configurationSetType + "]"; - } - -} diff --git a/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/role/conf/ConfigurationSetAdapter.java b/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/role/conf/ConfigurationSetAdapter.java deleted file mode 100644 index 64c1e01234..0000000000 --- a/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/role/conf/ConfigurationSetAdapter.java +++ /dev/null @@ -1,134 +0,0 @@ -package org.jclouds.azure.management.domain.role.conf; - -import java.util.List; -import java.util.TimeZone; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlElementWrapper; -import javax.xml.bind.annotation.adapters.XmlAdapter; - -import com.google.common.collect.Lists; - -public class ConfigurationSetAdapter extends - XmlAdapter { - - @Override - public ConfigurationSet unmarshal(AdaptedConfigurationSet adapted) throws Exception { - - final String type = adapted.configurationSetType; - if (NetworkConfiguration.ID.equals(type)) { - NetworkConfiguration network = new NetworkConfiguration(); - network.setConfigurationSetType(NetworkConfiguration.ID); - network.setInputEndpoints(adapted.inputEndpoints); - network.setSubnetNames(adapted.subnetNames); - return network; - } else if (LinuxProvisioningConfiguration.ID.equals(type)) { - LinuxProvisioningConfiguration linux = new LinuxProvisioningConfiguration(); - linux.setConfigurationSetType(LinuxProvisioningConfiguration.ID); - linux.setDisableSshPasswordAuthentication(adapted.disableSshPasswordAuthentication); - linux.setHostName(adapted.hostName); - linux.setSsh(adapted.ssh); - linux.setUserName(adapted.userName); - linux.setUserPassword(adapted.userPassword); - return linux; - } else if (WindowsProvisioningConfiguration.ID.equals(type)) { - WindowsProvisioningConfiguration windows = new WindowsProvisioningConfiguration(); - windows.setConfigurationSetType(WindowsProvisioningConfiguration.ID); - windows.setAdminPassword(adapted.adminPassword); - windows.setComputerName(adapted.computerName); - windows.setDomainJoin(adapted.domainJoin); - windows.setEnableAutomaticUpdates(adapted.enableAutomaticUpdates); - windows.setResetPasswordOnFirstLogon(adapted.resetPasswordOnFirstLogon); - windows.setStoredCertificateSettings(adapted.storedCertificateSettings); - windows.setTimeZone(adapted.timeZone); - return windows; - } - - return null; - } - - @Override - public AdaptedConfigurationSet marshal(ConfigurationSet configSet) throws Exception { - if (configSet == null) { - return null; - } - - AdaptedConfigurationSet adapted = new AdaptedConfigurationSet(); - adapted.configurationSetType = configSet.getConfigurationSetType(); - - if (configSet instanceof NetworkConfiguration) { - NetworkConfiguration network = (NetworkConfiguration) configSet; - adapted.inputEndpoints = network.getInputEndpoints(); - adapted.subnetNames = network.getSubnetNames(); - } else if (configSet instanceof LinuxProvisioningConfiguration) { - LinuxProvisioningConfiguration linux = (LinuxProvisioningConfiguration) configSet; - adapted.disableSshPasswordAuthentication = linux.getDisableSshPasswordAuthentication(); - adapted.hostName = linux.getHostName(); - adapted.ssh = linux.getSsh(); - adapted.userName = linux.getUserName(); - adapted.userPassword = linux.getUserPassword(); - } else if (configSet instanceof WindowsProvisioningConfiguration) { - WindowsProvisioningConfiguration windows = (WindowsProvisioningConfiguration) configSet; - adapted.adminPassword = windows.getAdminPassword(); - adapted.computerName = windows.getComputerName(); - adapted.domainJoin = windows.getDomainJoin(); - adapted.enableAutomaticUpdates = windows.getEnableAutomaticUpdates(); - adapted.resetPasswordOnFirstLogon = windows.getResetPasswordOnFirstLogon(); - adapted.storedCertificateSettings = windows.getStoredCertificateSettings(); - adapted.timeZone = windows.getTimeZone(); - } - - return adapted; - } - - public static class AdaptedConfigurationSet { - @XmlElement(required = true, name = "ConfigurationSetType") - public String configurationSetType; - - @XmlElement(required = true, name = "HostName") - public String hostName; - - @XmlElement(required = true, name = "UserName") - public String userName; - - @XmlElement(required = true, name = "UserPassword") - public String userPassword; - - @XmlElement(name = "DisableSshPasswordAuthentication") - public Boolean disableSshPasswordAuthentication; - - @XmlElement(name = "SSH") - public SSH ssh; - - @XmlElement(name = "ComputerName") - public String computerName; - - @XmlElement(required = true, name = "AdminPassword") - public String adminPassword; - - @XmlElement(required = true, name = "ResetPasswordOnFirstLogon") - public Boolean resetPasswordOnFirstLogon; - - @XmlElement(name = "EnableAutomaticUpdates") - public Boolean enableAutomaticUpdates; - - @XmlElement(name = "TimeZone") - public TimeZone timeZone; - - @XmlElement(name = "DomainJoin") - public DomainJoin domainJoin; - - @XmlElementWrapper(required = true, name = "StoredCertificateSettings") - @XmlElement(name = "CertificateSetting") - public List storedCertificateSettings = Lists.newArrayList(); - - @XmlElementWrapper(name = "InputEndpoints") - @XmlElement(name = "InputEndpoint") - public List inputEndpoints = Lists.newArrayListWithCapacity(0); - - @XmlElementWrapper(name = "SubnetNames") - @XmlElement(name = "SubnetName") - public List subnetNames = Lists.newArrayListWithCapacity(0); - } - -} diff --git a/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/role/conf/Credentials.java b/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/role/conf/Credentials.java deleted file mode 100644 index b229f23754..0000000000 --- a/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/role/conf/Credentials.java +++ /dev/null @@ -1,59 +0,0 @@ -package org.jclouds.azure.management.domain.role.conf; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; - -@XmlRootElement(name = "Credentials") -public class Credentials { - - /** - * Specifies the name of the domain used to authenticate an account. The value is a fully - * qualified DNS domain. - */ - @XmlElement(name = "Domain") - private String domain; - /** - * Specifies a user name in the domain that can be used to join the domain. - */ - @XmlElement(required = true, name = "Username") - private String username; - /** - * Specifies the password to use to join the domain. - */ - @XmlElement(name = "Password") - private String password; - - public Credentials() { - super(); - } - - public String getDomain() { - return domain; - } - - public void setDomain(String domain) { - this.domain = domain; - } - - public String getUsername() { - return username; - } - - public void setUsername(String username) { - this.username = username; - } - - public String getPassword() { - return password; - } - - public void setPassword(String password) { - this.password = password; - } - - @Override - public String toString() { - return "Credentials [domain=" + domain + ", username=" + username + ", password=" + password + "]"; - } - -} diff --git a/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/role/conf/DomainJoin.java b/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/role/conf/DomainJoin.java deleted file mode 100644 index fd9a7f070c..0000000000 --- a/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/role/conf/DomainJoin.java +++ /dev/null @@ -1,62 +0,0 @@ -package org.jclouds.azure.management.domain.role.conf; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; - -@XmlRootElement(name = "DomainJoin") -public class DomainJoin { - - /** - * Specifies the domain to join. - */ - @XmlElement(name = "JoinDomain") - private String joinDomain; - /** - * Specifies the Lightweight Directory Access Protocol (LDAP) X 500-distinguished name of the - * organizational unit (OU) in which the computer account is created. This account is in Active - * Directory on a domain controller in the domain to which the computer is being joined. - */ - @XmlElement(name = "MachineObjectOU") - private String machineObjectOU; - /** - * Specifies the Domain, Password, and Username values to use to join the virtual machine to the - * domain. - */ - @XmlElement(name = "Credentials") - private Credentials credentials; - - public DomainJoin() { - super(); - } - - public String getJoinDomain() { - return joinDomain; - } - - public void setJoinDomain(String joinDomain) { - this.joinDomain = joinDomain; - } - - public String getMachineObjectOU() { - return machineObjectOU; - } - - public void setMachineObjectOU(String machineObjectOU) { - this.machineObjectOU = machineObjectOU; - } - - public Credentials getCredentials() { - return credentials; - } - - public void setCredentials(Credentials credentials) { - this.credentials = credentials; - } - - @Override - public String toString() { - return "DomainJoin [joinDomain=" + joinDomain + ", machineObjectOU=" + machineObjectOU + ", credentials=" - + credentials + "]"; - } - -} diff --git a/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/role/conf/InputEndpoint.java b/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/role/conf/InputEndpoint.java deleted file mode 100644 index ea685892c1..0000000000 --- a/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/role/conf/InputEndpoint.java +++ /dev/null @@ -1,125 +0,0 @@ -package org.jclouds.azure.management.domain.role.conf; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; - -import org.jclouds.azure.management.domain.role.Protocol; - -@XmlRootElement(name = "InputEndpoint") -public class InputEndpoint { - - /** - * - */ - @XmlElement(name = "EnableDirectServerReturn") - private Boolean enableDirectServerReturn; - - /** - * Specifies a name for a set of load-balanced endpoints. Specifying this element for a given - * endpoint adds it to the set. - */ - @XmlElement(required = true, name = "LoadBalancedEndpointSetName") - private String loadBalancedEndpointSetName; - - /** - * Specifies the internal port on which the virtual machine is listening to serve the endpoint. - */ - @XmlElement(required = true, name = "LocalPort") - private Integer localPort; - - /** - * Specifies the name for the external endpoint. - */ - @XmlElement(required = true, name = "Name") - private String name; - - /** - * Specifies the external port to use for the endpoint. - */ - @XmlElement(required = true, name = "Port") - private Integer port; - - @XmlElement(name = "LoadBalancerProbe") - private LoadBalancerProbe loadBalancerProbe; - - @XmlElement(name = "Protocol") - private Protocol protocol; - - @XmlElement(name = "Vip") - private String vip; - - public InputEndpoint() { - } - - public Boolean getEnableDirectServerReturn() { - return enableDirectServerReturn; - } - - public void setEnableDirectServerReturn(Boolean enableDirectServerReturn) { - this.enableDirectServerReturn = enableDirectServerReturn; - } - - public String getLoadBalancedEndpointSetName() { - return loadBalancedEndpointSetName; - } - - public void setLoadBalancedEndpointSetName(String loadBalancedEndpointSetName) { - this.loadBalancedEndpointSetName = loadBalancedEndpointSetName; - } - - public Integer getLocalPort() { - return localPort; - } - - public void setLocalPort(Integer localPort) { - this.localPort = localPort; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public Integer getPort() { - return port; - } - - public void setPort(Integer port) { - this.port = port; - } - - public LoadBalancerProbe getLoadBalancerProbe() { - return loadBalancerProbe; - } - - public void setLoadBalancerProbe(LoadBalancerProbe loadBalancerProbe) { - this.loadBalancerProbe = loadBalancerProbe; - } - - public Protocol getProtocol() { - return protocol; - } - - public void setProtocol(Protocol protocol) { - this.protocol = protocol; - } - - public String getVip() { - return vip; - } - - public void setVip(String vip) { - this.vip = vip; - } - - @Override - public String toString() { - return "InputEndpoint [enableDirectServerReturn=" + enableDirectServerReturn + ", loadBalancedEndpointSetName=" - + loadBalancedEndpointSetName + ", localPort=" + localPort + ", name=" + name + ", port=" + port - + ", loadBalancerProbe=" + loadBalancerProbe + ", protocol=" + protocol + ", vip=" + vip + "]"; - } - -} diff --git a/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/role/conf/KeyPair.java b/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/role/conf/KeyPair.java deleted file mode 100644 index 319b82ed88..0000000000 --- a/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/role/conf/KeyPair.java +++ /dev/null @@ -1,16 +0,0 @@ -package org.jclouds.azure.management.domain.role.conf; - -import javax.xml.bind.annotation.XmlRootElement; - -@XmlRootElement(name = "KeyPair") -public class KeyPair extends SSHKey { - - public KeyPair() { - } - - @Override - public String toString() { - return "KeyPair [fingerPrint=" + fingerPrint + ", path=" + path + "]"; - } - -} diff --git a/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/role/conf/LinuxProvisioningConfiguration.java b/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/role/conf/LinuxProvisioningConfiguration.java deleted file mode 100644 index 74a87c0e15..0000000000 --- a/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/role/conf/LinuxProvisioningConfiguration.java +++ /dev/null @@ -1,89 +0,0 @@ -package org.jclouds.azure.management.domain.role.conf; - - -public class LinuxProvisioningConfiguration extends ConfigurationSet { - - public static final String ID = "LinuxProvisioningConfiguration"; - - /** - * Specifies the host name for the VM. Host names are ASCII character strings 1 to 64 characters - * in length. - */ - // @XmlElement(required = true,name = "HostName") - private String hostName; - /** - * Specifies the name of a user to be created in the sudoer group of the virtual machine. User - * names are ASCII character strings 1 to 32 characters in length. - */ - // @XmlElement(required = true,name = "UserName") - private String userName; - /** - * Specifies the associated password for the user name. PasswoazureManagement are ASCII character - * strings 6 to 72 characters in length. - */ - // @XmlElement(required = true,name = "UserPassword") - private String userPassword; - /** - * Specifies whether or not SSH password authentication is disabled. By default this value is set - * to true. - */ - // @XmlElement(name = "DisableSshPasswordAuthentication") - private Boolean disableSshPasswordAuthentication; - /** - * Specifies the SSH public keys and key pairs to populate in the image during provisioning. - */ - // @XmlElement(name = "SSH") - private SSH ssh; - - public LinuxProvisioningConfiguration() { - - } - - public String getHostName() { - return hostName; - } - - public void setHostName(String hostName) { - this.hostName = hostName; - } - - public String getUserName() { - return userName; - } - - public void setUserName(String userName) { - this.userName = userName; - } - - public String getUserPassword() { - return userPassword; - } - - public void setUserPassword(String userPassword) { - this.userPassword = userPassword; - } - - public Boolean getDisableSshPasswordAuthentication() { - return disableSshPasswordAuthentication; - } - - public void setDisableSshPasswordAuthentication(Boolean disableSshPasswordAuthentication) { - this.disableSshPasswordAuthentication = disableSshPasswordAuthentication; - } - - public SSH getSsh() { - return ssh; - } - - public void setSsh(SSH ssh) { - this.ssh = ssh; - } - - @Override - public String toString() { - return "LinuxProvisioningConfigurationSet [hostName=" + hostName + ", userName=" + userName + ", userPassword=" - + userPassword + ", disableSshPasswordAuthentication=" + disableSshPasswordAuthentication + ", ssh=" - + ssh + "]"; - } - -} diff --git a/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/role/conf/LoadBalancerProbe.java b/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/role/conf/LoadBalancerProbe.java deleted file mode 100644 index f7cb194ea6..0000000000 --- a/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/role/conf/LoadBalancerProbe.java +++ /dev/null @@ -1,68 +0,0 @@ -package org.jclouds.azure.management.domain.role.conf; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; - -import org.jclouds.azure.management.domain.role.Protocol; - -/** - * Contains properties that specify the endpoint settings which the Windows Azure load balancer uses - * to monitor the availability of this virtual machine before forwarding traffic to the endpoint. - * - * @author gpereira - * - */ -@XmlRootElement(name = "LoadBalancerProbe") -public class LoadBalancerProbe { - - /** - * Specifies the relative path name to inspect to determine the virtual machine availability - * status. If Protocol is set to TCP, this value must be NULL. - */ - @XmlElement(name = "Path") - private String path; - /** - * Specifies the port to use to inspect the virtual machine availability status. - */ - @XmlElement(name = "Port") - private Integer port; - /** - * Specifies the protocol to use to inspect the virtual machine availability status. - */ - @XmlElement(name = "Protocol") - private Protocol protocol; - - public LoadBalancerProbe() { - super(); - } - - public String getPath() { - return path; - } - - public void setPath(String path) { - this.path = path; - } - - public Integer getPort() { - return port; - } - - public void setPort(Integer port) { - this.port = port; - } - - public Protocol getProtocol() { - return protocol; - } - - public void setProtocol(Protocol protocol) { - this.protocol = protocol; - } - - @Override - public String toString() { - return "LoadBalancerProbe [path=" + path + ", port=" + port + ", protocol=" + protocol + "]"; - } - -} diff --git a/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/role/conf/NetworkConfiguration.java b/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/role/conf/NetworkConfiguration.java deleted file mode 100644 index 66cd310228..0000000000 --- a/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/role/conf/NetworkConfiguration.java +++ /dev/null @@ -1,52 +0,0 @@ -package org.jclouds.azure.management.domain.role.conf; - -import java.util.List; - -import com.google.common.collect.Lists; - -//@XmlRootElement(name = "ConfigurationSet") -public class NetworkConfiguration extends ConfigurationSet { - - public static final String ID = "NetworkConfiguration"; - - /** - * Contains a collection of external endpoints for the virtual machine. - */ - // @XmlElementWrapper(name = "InputEndpoints") - // @XmlElement(name = "InputEndpoint") - private List inputEndpoints = Lists.newArrayListWithCapacity(0); - - /** - * Specifies the name of a subnet to which the virtual machine belongs. - */ - // @XmlElementWrapper(name = "SubnetNames") - // @XmlElement(name = "SubnetName") - private List subnetNames = Lists.newArrayListWithCapacity(0); - - public NetworkConfiguration() { - setConfigurationSetType(ID); - } - - public List getInputEndpoints() { - return inputEndpoints; - } - - public void setInputEndpoints(List inputEndpoints) { - this.inputEndpoints = inputEndpoints; - } - - public List getSubnetNames() { - return subnetNames; - } - - public void setSubnetNames(List subnetNames) { - this.subnetNames = subnetNames; - } - - @Override - public String toString() { - return "NetworkConfigurationSet [configurationSetType=" + configurationSetType + ", InputEndpoints=" - + inputEndpoints + ", SubnetNames=" + subnetNames + "]"; - } - -} diff --git a/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/role/conf/PublicKey.java b/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/role/conf/PublicKey.java deleted file mode 100644 index 0a49e91eb9..0000000000 --- a/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/role/conf/PublicKey.java +++ /dev/null @@ -1,16 +0,0 @@ -package org.jclouds.azure.management.domain.role.conf; - -import javax.xml.bind.annotation.XmlRootElement; - -@XmlRootElement(name = "PublicKey") -public class PublicKey extends SSHKey { - - public PublicKey() { - } - - @Override - public String toString() { - return "PublicKey [fingerPrint=" + fingerPrint + ", path=" + path + "]"; - } - -} diff --git a/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/role/conf/SSH.java b/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/role/conf/SSH.java deleted file mode 100644 index b40ec701a0..0000000000 --- a/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/role/conf/SSH.java +++ /dev/null @@ -1,51 +0,0 @@ -package org.jclouds.azure.management.domain.role.conf; - -import java.util.List; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlElementWrapper; -import javax.xml.bind.annotation.XmlRootElement; - -import com.google.common.collect.Lists; - -@XmlRootElement(name = "SSH") -public class SSH { - - /** - * Specifies the collection of SSH public keys. - */ - @XmlElementWrapper(name = "PublicKeys") - @XmlElement(name = "PublicKey") - private List publicKeys = Lists.newArrayListWithCapacity(0); - - /** - * Specifies the public key. - */ - @XmlElementWrapper(name = "KeyPairs") - @XmlElement(name = "KeyPair") - private List keyPairs = Lists.newArrayListWithCapacity(0); - - public SSH() { - } - - public List getPublicKeys() { - return publicKeys; - } - - public void setPublicKeys(List publicKeys) { - this.publicKeys = publicKeys; - } - - public List getKeyPairs() { - return keyPairs; - } - - public void setKeyPairs(List keyPairs) { - this.keyPairs = keyPairs; - } - - @Override - public String toString() { - return "SSH [publicKeys=" + publicKeys + ", keyPairs=" + keyPairs + "]"; - } -} diff --git a/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/role/conf/SSHKey.java b/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/role/conf/SSHKey.java deleted file mode 100644 index 83c617fd9b..0000000000 --- a/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/role/conf/SSHKey.java +++ /dev/null @@ -1,39 +0,0 @@ -package org.jclouds.azure.management.domain.role.conf; - -import javax.xml.bind.annotation.XmlElement; - -public class SSHKey { - - /** - * Specifies the SHA1 fingerprint of an X509 certificate associated with the hosted service that - * includes the SSH public key. - */ - @XmlElement(required = true, name = "FingerPrint") - protected String fingerPrint; - - /** - * Specifies the full path of a file, on the virtual machine, which stores the SSH public key. If - * the file already exists, the specified key is appended to the file. - */ - @XmlElement(required = true, name = "Path") - protected String path; - - public SSHKey() { - } - - public String getFingerPrint() { - return fingerPrint; - } - - public void setFingerPrint(String fingerPrint) { - this.fingerPrint = fingerPrint; - } - - public String getPath() { - return path; - } - - public void setPath(String path) { - this.path = path; - } -} diff --git a/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/role/conf/WindowsProvisioningConfiguration.java b/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/role/conf/WindowsProvisioningConfiguration.java deleted file mode 100644 index ab33232d69..0000000000 --- a/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/role/conf/WindowsProvisioningConfiguration.java +++ /dev/null @@ -1,124 +0,0 @@ -package org.jclouds.azure.management.domain.role.conf; - -import java.util.List; -import java.util.TimeZone; - -import com.google.common.collect.Lists; - -//@XmlRootElement(name = "ConfigurationSet") -public class WindowsProvisioningConfiguration extends ConfigurationSet { - - public static final String ID = "WindowsProvisioningConfiguration"; - - /** - * Specifies the computer name for the virtual machine - * - * Computer names must be 1 to 15 characters in length. - */ - // @XmlElement(name = "ComputerName") - private String computerName; - /** - * Specifies the base-64 encoded string representing the administrator password to use for the - * virtual machine. - */ - // @XmlElement(required = true, name = "AdminPassword") - private String adminPassword; - /** - * Specifies whether the user must change the administrator password on first logon. The default - * value is false. - */ - // @XmlElement(required = true, name = "ResetPasswordOnFirstLogon") - private Boolean resetPasswordOnFirstLogon; - /** - * Specifies whether automatic updates are enabled for the virtual machine. The default value is - * true. - */ - // @XmlElement(name = "EnableAutomaticUpdates") - private Boolean enableAutomaticUpdates; - /** - * Specifies the time zone for the virtual machine. - */ - // @XmlElement(name = "TimeZone") - private TimeZone timeZone; - /** - * Contains properties that specify a domain to which the virtual machine will be joined. The - * DomainJoin node contains either credentials or provisioning information. - */ - // @XmlElement(name = "DomainJoin") - private DomainJoin domainJoin; - /** - * Contains a list of service certificates with which to provision to the new virtual machine. - */ - // @XmlElementWrapper(required = true, name = "StoredCertificateSettings") - // @XmlElement(name = "CertificateSetting") - private List storedCertificateSettings = Lists.newArrayList(); - - public WindowsProvisioningConfiguration() { - - } - - public String getComputerName() { - return computerName; - } - - public void setComputerName(String computerName) { - this.computerName = computerName; - } - - public String getAdminPassword() { - return adminPassword; - } - - public void setAdminPassword(String adminPassword) { - this.adminPassword = adminPassword; - } - - public Boolean getResetPasswordOnFirstLogon() { - return resetPasswordOnFirstLogon; - } - - public void setResetPasswordOnFirstLogon(Boolean resetPasswordOnFirstLogon) { - this.resetPasswordOnFirstLogon = resetPasswordOnFirstLogon; - } - - public Boolean getEnableAutomaticUpdates() { - return enableAutomaticUpdates; - } - - public void setEnableAutomaticUpdates(Boolean enableAutomaticUpdates) { - this.enableAutomaticUpdates = enableAutomaticUpdates; - } - - public TimeZone getTimeZone() { - return timeZone; - } - - public void setTimeZone(TimeZone timeZone) { - this.timeZone = timeZone; - } - - public DomainJoin getDomainJoin() { - return domainJoin; - } - - public void setDomainJoin(DomainJoin domainJoin) { - this.domainJoin = domainJoin; - } - - public List getStoredCertificateSettings() { - return storedCertificateSettings; - } - - public void setStoredCertificateSettings(List storedCertificateSettings) { - this.storedCertificateSettings = storedCertificateSettings; - } - - @Override - public String toString() { - return "WindowsProvisioningConfigurationSet [computerName=" + computerName + ", adminPassword=" + adminPassword - + ", resetPasswordOnFirstLogon=" + resetPasswordOnFirstLogon + ", enableAutomaticUpdates=" - + enableAutomaticUpdates + ", timeZone=" + timeZone + ", domainJoin=" + domainJoin - + ", storedCertificateSettings=" + storedCertificateSettings + "]"; - } - -} diff --git a/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/role/conf/package-info.java b/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/role/conf/package-info.java deleted file mode 100644 index 2c8810bf46..0000000000 --- a/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/role/conf/package-info.java +++ /dev/null @@ -1,27 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -@XmlSchema(namespace = "http://schemas.microsoft.com/windowsazure", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED) -@XmlAccessorType(XmlAccessType.FIELD) -//@XmlJavaTypeAdapters({@XmlJavaTypeAdapter(NetworkConfigurationSetAdapter.class),@XmlJavaTypeAdapter(LinuxProvisioningConfigurationSetAdapter.class)}) -package org.jclouds.azure.management.domain.role.conf; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlSchema; - diff --git a/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/role/package-info.java b/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/role/package-info.java deleted file mode 100644 index b6367ef396..0000000000 --- a/labs/azure-management/src/main/java/org/jclouds/azure/management/domain/role/package-info.java +++ /dev/null @@ -1,27 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -@XmlSchema(namespace = "http://schemas.microsoft.com/windowsazure", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED) -@XmlAccessorType(XmlAccessType.FIELD) -//@XmlJavaTypeAdapters({@XmlJavaTypeAdapter(NetworkConfigurationSetAdapter.class),@XmlJavaTypeAdapter(LinuxProvisioningConfigurationSetAdapter.class)}) -package org.jclouds.azure.management.domain.role; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlSchema; - diff --git a/labs/azure-management/src/main/java/org/jclouds/azure/management/features/DiskApi.java b/labs/azure-management/src/main/java/org/jclouds/azure/management/features/DiskApi.java deleted file mode 100644 index a0fd5530f2..0000000000 --- a/labs/azure-management/src/main/java/org/jclouds/azure/management/features/DiskApi.java +++ /dev/null @@ -1,46 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.azure.management.features; - -import java.util.Set; -import org.jclouds.azure.management.domain.Disk; - -/** - * The Service Management API includes operations for managing the disks in your subscription. - * - * @see docs - * @see DiskAsyncApi - * @author Gerald Pereira - */ -public interface DiskApi { - - /** - * The List Disks operation retrieves a list of the disks in your image repository. - */ - Set list(); - - /** - * The Delete Disk operation deletes the specified data or operating system disk from your image - * repository. - * - * @return request id or null, if not found - * - */ - String delete(String diskName); -} diff --git a/labs/azure-management/src/main/java/org/jclouds/azure/management/features/DiskAsyncApi.java b/labs/azure-management/src/main/java/org/jclouds/azure/management/features/DiskAsyncApi.java deleted file mode 100644 index bc00dd97ae..0000000000 --- a/labs/azure-management/src/main/java/org/jclouds/azure/management/features/DiskAsyncApi.java +++ /dev/null @@ -1,74 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.azure.management.features; - -import java.util.Set; - -import javax.inject.Named; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.core.MediaType; - -import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404; -import org.jclouds.Fallbacks.NullOnNotFoundOr404; -import org.jclouds.azure.management.domain.Disk; -import org.jclouds.azure.management.functions.ParseRequestIdHeader; -import org.jclouds.azure.management.xml.ListDisksHandler; -import org.jclouds.rest.annotations.Fallback; -import org.jclouds.rest.annotations.Headers; -import org.jclouds.rest.annotations.ResponseParser; -import org.jclouds.rest.annotations.XMLResponseParser; - -import com.google.common.util.concurrent.ListenableFuture; - -/** - * The Service Management API includes operations for managing the virtual machines Disk in your - * subscription. - * - * @see docs - * @see DiskApi - * @author Gerald Pereira - */ -@Headers(keys = "x-ms-version", values = "2012-03-01") -public interface DiskAsyncApi { - - /** - * @see DiskApi#list() - */ - @Named("ListDisks") - @GET - @Path("/services/disks") - @XMLResponseParser(ListDisksHandler.class) - @Fallback(EmptySetOnNotFoundOr404.class) - @Consumes(MediaType.APPLICATION_XML) - ListenableFuture> list(); - - /** - * @see DiskApi#delete - */ - @Named("DeleteDisk") - @DELETE - @Path("/services/disks/{diskName}") - @Fallback(NullOnNotFoundOr404.class) - @ResponseParser(ParseRequestIdHeader.class) - ListenableFuture delete(@PathParam("diskName") String imageName); -} diff --git a/labs/azure-management/src/main/java/org/jclouds/azure/management/features/HostedServiceApi.java b/labs/azure-management/src/main/java/org/jclouds/azure/management/features/HostedServiceApi.java deleted file mode 100644 index 50d9121e64..0000000000 --- a/labs/azure-management/src/main/java/org/jclouds/azure/management/features/HostedServiceApi.java +++ /dev/null @@ -1,139 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.azure.management.features; - -import java.util.Set; -import org.jclouds.azure.management.domain.Deployment; -import org.jclouds.azure.management.domain.HostedService; -import org.jclouds.azure.management.domain.HostedServiceWithDetailedProperties; -import org.jclouds.azure.management.options.CreateHostedServiceOptions; - -/** - * The Service Management API includes operations for managing the hosted services beneath your - * subscription. - * - * @see docs - * @see HostedServiceAsyncApi - * @author Gerald Pereira, Adrian Cole - */ -public interface HostedServiceApi { - - /** - * The List Hosted Services operation lists the hosted services available under the current - * subscription. - * - * @return the response object - */ - Set list(); - - /** - * The Create Hosted Service operation creates a new hosted service in Windows Azure. - * - * @param serviceName - * A name for the hosted service that is unique within Windows Azure. This name is the - * DNS prefix name and can be used to access the hosted service. - * - * For example: http://ServiceName.cloudapp.net// - * @param label - * The name can be used identify the storage account for your tracking purposes. The - * name can be up to 100 characters in length. - * @param location - * The location where the hosted service will be created. - * @return the requestId to track this async request progress - * - * @see docs - */ - String createServiceWithLabelInLocation(String serviceName, String label, String location); - - /** - * same as {@link #createServiceWithLabelInLocation(String, String, String)} , except you can - * specify optional parameters such as extended properties or a description. - * - * @param options - * parameters such as extended properties or a description. - */ - String createServiceWithLabelInLocation(String serviceName, String label, String location, - CreateHostedServiceOptions options); - - /** - * The Get Hosted Service Properties operation retrieves system properties for the specified - * hosted service. These properties include the service name and service type; the name of the - * affinity group to which the service belongs, or its location if it is not part of an affinity - * group. - * - * @param serviceName - * the unique DNS Prefix value in the Windows Azure Management Portal - */ - HostedService get(String serviceName); - - /** - * like {@link #get(String)}, except additional data such as status and deployment information is - * returned. - * - * @param serviceName - * the unique DNS Prefix value in the Windows Azure Management Portal - */ - HostedServiceWithDetailedProperties getDetails(String serviceName); - - /** - * The Delete Hosted Service operation deletes the specified hosted service from Windows Azure. - * - * @param serviceName - * the unique DNS Prefix value in the Windows Azure Management Portal - * - * @return request id or null, if not found - */ - String delete(String serviceName); - - /** - * http://msdn.microsoft.com/en-us/library/ee460813 - * - * @param serviceName - * the unique DNS Prefix value in the Windows Azure Management Portal - * @param deploymentSlotName - * "staging" or "production", depending on where you wish to deploy your service - * package - * @param createDeployment - * the deployment to create - */ - // This is a PaaS REST service ! -// void createDeployment(String serviceName, String deploymentSlotName, CreateDeployment createDeployment); - - /** - * The Delete Deployment operation deletes the specified deployment from Windows Azure. - * - * @param serviceName - * the unique DNS Prefix value in the Windows Azure Management Portal - * @param deploymentName - * the unique DNS Prefix value in the Windows Azure Management Portal - */ - String deleteDeployment(String serviceName, String deploymentName); - - - /** - * The Get Deployment operation returns the specified deployment from Windows Azure. - * - * @param serviceName - * the unique DNS Prefix value in the Windows Azure Management Portal - * @param deploymentName - * the unique DNS Prefix value in the Windows Azure Management Portal - */ - Deployment getDeployment(String serviceName, String deploymentName); - -} diff --git a/labs/azure-management/src/main/java/org/jclouds/azure/management/features/HostedServiceAsyncApi.java b/labs/azure-management/src/main/java/org/jclouds/azure/management/features/HostedServiceAsyncApi.java deleted file mode 100644 index 0175c6f552..0000000000 --- a/labs/azure-management/src/main/java/org/jclouds/azure/management/features/HostedServiceAsyncApi.java +++ /dev/null @@ -1,158 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.azure.management.features; - -import java.util.Set; - -import javax.inject.Named; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.core.MediaType; - -import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404; -import org.jclouds.Fallbacks.NullOnNotFoundOr404; -import org.jclouds.Fallbacks.VoidOnNotFoundOr404; -import org.jclouds.azure.management.binders.BindCreateHostedServiceToXmlPayload; -import org.jclouds.azure.management.domain.Deployment; -import org.jclouds.azure.management.domain.HostedService; -import org.jclouds.azure.management.domain.HostedServiceWithDetailedProperties; -import org.jclouds.azure.management.functions.ParseRequestIdHeader; -import org.jclouds.azure.management.options.CreateHostedServiceOptions; -import org.jclouds.azure.management.xml.DeploymentHandler; -import org.jclouds.azure.management.xml.HostedServiceHandler; -import org.jclouds.azure.management.xml.HostedServiceWithDetailedPropertiesHandler; -import org.jclouds.azure.management.xml.ListHostedServicesHandler; -import org.jclouds.rest.annotations.Fallback; -import org.jclouds.rest.annotations.Headers; -import org.jclouds.rest.annotations.MapBinder; -import org.jclouds.rest.annotations.PayloadParam; -import org.jclouds.rest.annotations.QueryParams; -import org.jclouds.rest.annotations.ResponseParser; -import org.jclouds.rest.annotations.XMLResponseParser; - -import com.google.common.util.concurrent.ListenableFuture; - -/** - * The Service Management API includes operations for managing the hosted services beneath your - * subscription. - * - * @see docs - * @see HostedServiceApi - * @author Gerald Pereira, Adrian Cole - */ -@Headers(keys = "x-ms-version", values = "2012-03-01") -public interface HostedServiceAsyncApi { - - /** - * @see HostedServiceApi#list() - */ - @Named("ListHostedServices") - @GET - @Path("/services/hostedservices") - @XMLResponseParser(ListHostedServicesHandler.class) - @Fallback(EmptySetOnNotFoundOr404.class) - @Consumes(MediaType.APPLICATION_XML) - ListenableFuture> list(); - - /** - * @see HostedServiceApi#createServiceWithLabelInLocation(String, String, String) - */ - @Named("CreateHostedService") - @POST - @Path("/services/hostedservices") - @MapBinder(BindCreateHostedServiceToXmlPayload.class) - @Produces(MediaType.APPLICATION_XML) - @ResponseParser(ParseRequestIdHeader.class) - ListenableFuture createServiceWithLabelInLocation(@PayloadParam("serviceName") String serviceName, - @PayloadParam("label") String label, @PayloadParam("location") String location); - - /** - * @see HostedServiceApi#createServiceWithLabelInLocation(String, String, String, - * CreateHostedServiceOptions) - */ - @Named("CreateHostedService") - @POST - @Path("/services/hostedservices") - @MapBinder(BindCreateHostedServiceToXmlPayload.class) - @Produces(MediaType.APPLICATION_XML) - @ResponseParser(ParseRequestIdHeader.class) - ListenableFuture createServiceWithLabelInLocation(@PayloadParam("serviceName") String serviceName, - @PayloadParam("label") String label, @PayloadParam("location") String location, - @PayloadParam("options") CreateHostedServiceOptions options); - - /** - * @see HostedServiceApi#get(String) - */ - @Named("GetHostedServiceProperties") - @GET - @Path("/services/hostedservices/{serviceName}") - @XMLResponseParser(HostedServiceHandler.class) - @Fallback(NullOnNotFoundOr404.class) - @Consumes(MediaType.APPLICATION_XML) - ListenableFuture get(@PathParam("serviceName") String serviceName); - - /** - * @see HostedServiceApi#getDetails(String) - */ - @Named("GetHostedServiceProperties") - @GET - @Path("/services/hostedservices/{serviceName}") - @QueryParams(keys = "embed-detail", values = "true") - @XMLResponseParser(HostedServiceWithDetailedPropertiesHandler.class) - @Fallback(NullOnNotFoundOr404.class) - @Consumes(MediaType.APPLICATION_XML) - ListenableFuture getDetails(@PathParam("serviceName") String serviceName); - - /** - * @see HostedServiceApi#delete(String) - */ - @Named("DeleteHostedService") - @DELETE - @Path("/services/hostedservices/{serviceName}") - @Fallback(NullOnNotFoundOr404.class) - @ResponseParser(ParseRequestIdHeader.class) - ListenableFuture delete(@PathParam("serviceName") String serviceName); - - /** - * @see HostedServiceApi#deleteDeployment(String, String) - */ - @Named("DeleteDeployment") - @DELETE - @Path("/services/hostedservices/{serviceName}/deployments/{deploymentName}") - @Fallback(VoidOnNotFoundOr404.class) - @ResponseParser(ParseRequestIdHeader.class) - ListenableFuture deleteDeployment(@PathParam("serviceName") String serviceName, - @PathParam("deploymentName") String deploymentName); - - /** - * @see HostedServiceApi#get(String,String) - */ - @Named("GetDeployment") - @GET - @Path("/services/hostedservices/{serviceName}/deployments/{deploymentName}") - @XMLResponseParser(DeploymentHandler.class) - @Fallback(VoidOnNotFoundOr404.class) - @Consumes(MediaType.APPLICATION_XML) - ListenableFuture getDeployment(@PathParam("serviceName") String serviceName, @PathParam("deploymentName") String deploymentName); -} diff --git a/labs/azure-management/src/main/java/org/jclouds/azure/management/features/LocationApi.java b/labs/azure-management/src/main/java/org/jclouds/azure/management/features/LocationApi.java deleted file mode 100644 index b624ebfb8c..0000000000 --- a/labs/azure-management/src/main/java/org/jclouds/azure/management/features/LocationApi.java +++ /dev/null @@ -1,43 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.azure.management.features; - -import java.util.Set; -import org.jclouds.azure.management.domain.Location; - -/** - * The Service Management API includes operations for listing the available data center locations - * for a hosted service in your subscription. - *

- * - * @see - * @see LocationAsyncApi - * @author Adrian Cole - */ -public interface LocationApi { - - /** - * The List Locations operation lists all of the data center locations that are valid for your - * subscription. - * - * @return the response object - */ - Set list(); - -} diff --git a/labs/azure-management/src/main/java/org/jclouds/azure/management/features/LocationAsyncApi.java b/labs/azure-management/src/main/java/org/jclouds/azure/management/features/LocationAsyncApi.java deleted file mode 100644 index 8e7ed057f6..0000000000 --- a/labs/azure-management/src/main/java/org/jclouds/azure/management/features/LocationAsyncApi.java +++ /dev/null @@ -1,61 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.azure.management.features; - -import java.util.Set; - -import javax.inject.Named; -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.core.MediaType; - -import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404; -import org.jclouds.azure.management.domain.Location; -import org.jclouds.azure.management.xml.ListLocationsHandler; -import org.jclouds.rest.annotations.Fallback; -import org.jclouds.rest.annotations.Headers; -import org.jclouds.rest.annotations.XMLResponseParser; - -import com.google.common.util.concurrent.ListenableFuture; - -/** - * The Service Management API includes operations for listing the available data center locations - * for a hosted service in your subscription. - *

- * - * @see - * @see LocationApi - * @author Adrian Cole - */ -@Headers(keys = "x-ms-version", values = "2012-03-01") -public interface LocationAsyncApi { - - /** - * @see LocationApi#list() - */ - @Named("ListLocations") - @GET - @Path("/locations") - @XMLResponseParser(ListLocationsHandler.class) - @Fallback(EmptySetOnNotFoundOr404.class) - @Consumes(MediaType.APPLICATION_XML) - ListenableFuture> list(); - -} diff --git a/labs/azure-management/src/main/java/org/jclouds/azure/management/features/OSImageApi.java b/labs/azure-management/src/main/java/org/jclouds/azure/management/features/OSImageApi.java deleted file mode 100644 index 1695ee6d52..0000000000 --- a/labs/azure-management/src/main/java/org/jclouds/azure/management/features/OSImageApi.java +++ /dev/null @@ -1,66 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.azure.management.features; - -import java.util.Set; -import org.jclouds.azure.management.domain.OSImage; -import org.jclouds.azure.management.domain.OSImageParams; - -/** - * The Service Management API includes operations for managing the OS images in your subscription. - * - * @see docs - * @see OSImageAsyncApi - * @author Gerald Pereira, Adrian Cole - */ -public interface OSImageApi { - - /** - * The List Hosted Services operation lists the hosted services available under the current - * subscription. - * - * @return the response object - */ - Set list(); - - /** - * The Add OS Image operation adds an OS image that is currently stored in a storage account in your subscription to the image repository. - * - * @param params - * the required parameters needed to add an image - */ - void add(OSImageParams params); - - /** - * The Update OS Image operation updates an OS image that in your image repository. - * - * @param params - * the required parameters needed to update an image - */ - void update(OSImageParams params); - - /** - * The Delete Hosted Service operation deletes the specified hosted service from Windows Azure. - * - * @param imageName - * the unique DNS Prefix value in the Windows Azure Management Portal - */ - void delete(String imageName); - -} diff --git a/labs/azure-management/src/main/java/org/jclouds/azure/management/features/OSImageAsyncApi.java b/labs/azure-management/src/main/java/org/jclouds/azure/management/features/OSImageAsyncApi.java deleted file mode 100644 index 28084b83e2..0000000000 --- a/labs/azure-management/src/main/java/org/jclouds/azure/management/features/OSImageAsyncApi.java +++ /dev/null @@ -1,98 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.azure.management.features; - -import java.util.Set; - -import javax.inject.Named; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.core.MediaType; - -import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404; -import org.jclouds.Fallbacks.VoidOnNotFoundOr404; -import org.jclouds.azure.management.binders.BindOSImageParamsToXmlPayload; -import org.jclouds.azure.management.domain.OSImage; -import org.jclouds.azure.management.domain.OSImageParams; -import org.jclouds.azure.management.functions.OSImageParamsName; -import org.jclouds.azure.management.xml.ListOSImagesHandler; -import org.jclouds.rest.annotations.BinderParam; -import org.jclouds.rest.annotations.Fallback; -import org.jclouds.rest.annotations.Headers; -import org.jclouds.rest.annotations.ParamParser; -import org.jclouds.rest.annotations.XMLResponseParser; - -import com.google.common.util.concurrent.ListenableFuture; - -/** - * The Service Management API includes operations for managing the OS images in your subscription. - * - * @see docs - * @see OSImageApi - * @author Gerald Pereira, Adrian Cole - */ -@Headers(keys = "x-ms-version", values = "2012-03-01") -public interface OSImageAsyncApi { - - /** - * @see OSImageApi#list() - */ - @Named("ListOsImages") - @GET - @Path("/services/images") - @XMLResponseParser(ListOSImagesHandler.class) - @Fallback(EmptySetOnNotFoundOr404.class) - @Consumes(MediaType.APPLICATION_XML) - ListenableFuture> list(); - - /** - * @see OSImageApi#add(String) - */ - @Named("AddOsImage") - @POST - @Path("/services/images") - @Produces(MediaType.APPLICATION_XML) - ListenableFuture add(@BinderParam(BindOSImageParamsToXmlPayload.class) OSImageParams params); - - /** - * @see OSImageApi#update(String) - */ - @Named("UpdateOsImage") - @PUT - @Path("/services/images/{imageName}") - @Produces(MediaType.APPLICATION_XML) - ListenableFuture update( - @PathParam("imageName") @ParamParser(OSImageParamsName.class) @BinderParam(BindOSImageParamsToXmlPayload.class) OSImageParams params); - - /** - * @see OSImageApi#delete(String) - */ - @Named("DeleteOsImage") - @DELETE - @Path("/services/images/{imageName}") - @Fallback(VoidOnNotFoundOr404.class) - ListenableFuture delete(@PathParam("imageName") String imageName); - -} diff --git a/labs/azure-management/src/main/java/org/jclouds/azure/management/features/OperationApi.java b/labs/azure-management/src/main/java/org/jclouds/azure/management/features/OperationApi.java deleted file mode 100644 index cf81d1689b..0000000000 --- a/labs/azure-management/src/main/java/org/jclouds/azure/management/features/OperationApi.java +++ /dev/null @@ -1,34 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.azure.management.features; - -import org.jclouds.azure.management.domain.Operation; - -/** - * The Service Management API includes one operation for tracking the progress of asynchronous requests. - * - * @see docs - * @see OperationAsyncApi - * @author Gerald Pereira - */ -public interface OperationApi { - - Operation get(String requestId); - -} diff --git a/labs/azure-management/src/main/java/org/jclouds/azure/management/features/OperationAsyncApi.java b/labs/azure-management/src/main/java/org/jclouds/azure/management/features/OperationAsyncApi.java deleted file mode 100644 index 621fd18b01..0000000000 --- a/labs/azure-management/src/main/java/org/jclouds/azure/management/features/OperationAsyncApi.java +++ /dev/null @@ -1,58 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.azure.management.features; - -import javax.inject.Named; -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.core.MediaType; - -import org.jclouds.Fallbacks.NullOnNotFoundOr404; -import org.jclouds.azure.management.domain.Operation; -import org.jclouds.azure.management.xml.OperationHandler; -import org.jclouds.rest.annotations.Fallback; -import org.jclouds.rest.annotations.Headers; -import org.jclouds.rest.annotations.XMLResponseParser; - -import com.google.common.util.concurrent.ListenableFuture; - -/** - * The Service Management API includes one operation for tracking the progress - * of asynchronous requests. - * - * @see docs - * @see OperationApi - * @author Gerald Pereira - */ -@Headers(keys = "x-ms-version", values = "2012-03-01") -public interface OperationAsyncApi { - - /** - * @see OperationApi#get(String) - */ - @Named("GetOperation") - @GET - @Path("/operations/{request-id}") - @XMLResponseParser(OperationHandler.class) - @Fallback(NullOnNotFoundOr404.class) - @Consumes(MediaType.APPLICATION_XML) - ListenableFuture get(@PathParam("request-id") String requestId); -} diff --git a/labs/azure-management/src/main/java/org/jclouds/azure/management/features/RoleApi.java b/labs/azure-management/src/main/java/org/jclouds/azure/management/features/RoleApi.java deleted file mode 100644 index a388995f03..0000000000 --- a/labs/azure-management/src/main/java/org/jclouds/azure/management/features/RoleApi.java +++ /dev/null @@ -1,75 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.azure.management.features; - -import org.jclouds.azure.management.domain.DeploymentParams; -import org.jclouds.azure.management.domain.role.PersistentVMRole; - -/** - * The Service Management API includes operations for managing the virtual - * machines in your subscription. - * - * @see docs - * @see RoleAsyncApi - * @author Gerald Pereira, Adrian Cole - */ -public interface RoleApi { - - // TODO: this is not the good REST call !!! Use getDeployment instead :@ - PersistentVMRole getRole(String serviceName, String deploymentName, String roleName); - - String restartRole(String serviceName, String deploymentName, String roleName); - - /** - * http://msdn.microsoft.com/en-us/library/jj157194 - * - * @param serviceName - * @param deploymentParams - * @return - */ - String createDeployment(String serviceName, DeploymentParams deploymentParams); - - /** - * http://msdn.microsoft.com/en-us/library/jj157201 - * - * @return - */ - String captureRole(String serviceName, String deploymentName, String roleName, String imageName, String imageLabel); - - /** - * http://msdn.microsoft.com/en-us/library/jj157195 - * - * @param serviceName - * @param deploymentName - * @param roleName - * @return - */ - String shutdownRole(String serviceName, String deploymentName, String roleName); - - /** - * http://msdn.microsoft.com/en-us/library/jj157189 - * - * @param serviceName - * @param deploymentName - * @param roleName - * @return - */ - String startRole(String serviceName, String deploymentName, String roleName); - -} diff --git a/labs/azure-management/src/main/java/org/jclouds/azure/management/features/RoleAsyncApi.java b/labs/azure-management/src/main/java/org/jclouds/azure/management/features/RoleAsyncApi.java deleted file mode 100644 index 2f452cc65b..0000000000 --- a/labs/azure-management/src/main/java/org/jclouds/azure/management/features/RoleAsyncApi.java +++ /dev/null @@ -1,140 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.azure.management.features; - -import javax.inject.Named; -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.core.MediaType; - -import org.jclouds.Fallbacks.NullOnNotFoundOr404; -import org.jclouds.azure.management.binders.BindDeploymentParamsToXmlPayload; -import org.jclouds.azure.management.domain.DeploymentParams; -import org.jclouds.azure.management.domain.role.PersistentVMRole; -import org.jclouds.azure.management.functions.ParseRequestIdHeader; -import org.jclouds.rest.annotations.BinderParam; -import org.jclouds.rest.annotations.Fallback; -import org.jclouds.rest.annotations.Headers; -import org.jclouds.rest.annotations.JAXBResponseParser; -import org.jclouds.rest.annotations.Payload; -import org.jclouds.rest.annotations.PayloadParam; -import org.jclouds.rest.annotations.ResponseParser; - -import com.google.common.util.concurrent.ListenableFuture; - -/** - * The Service Management API includes operations for managing the virtual - * machines in your subscription. - * - * @see docs - * @see RoleApi - * @author Gerald Pereira, Adrian Cole - */ -@Headers(keys = "x-ms-version", values = "2012-03-01") -public interface RoleAsyncApi { - - /** - * @see RoleApi#getRole(String, String, String) - */ - @Named("GetRole") - @GET - @Path("/services/hostedservices/{serviceName}/deployments/{deploymentName}/roles/{roleName}") - @Consumes(MediaType.APPLICATION_ATOM_XML) - @JAXBResponseParser - @Fallback(NullOnNotFoundOr404.class) - ListenableFuture getRole(@PathParam("serviceName") String serviceName, - @PathParam("deploymentName") String deploymentName, @PathParam("roleName") String roleName); - - /** - * @see RoleApi#restartRole(String, String, String) - */ - @Named("RestartRole") - @POST - // Warning : the url in the documentation is WRONG ! @see - // http://social.msdn.microsoft.com/Forums/pl-PL/WAVirtualMachinesforWindows/thread/7ba2367b-e450-49e0-89e4-46c240e9d213 - @Path("/services/hostedservices/{serviceName}/deployments/{deploymentName}/roleInstances/{roleName}/Operations") - @Consumes(MediaType.APPLICATION_ATOM_XML) - @Produces(MediaType.APPLICATION_ATOM_XML) - @Fallback(NullOnNotFoundOr404.class) - @ResponseParser(ParseRequestIdHeader.class) - @Payload(value = "RestartRoleOperation") - ListenableFuture restartRole(@PathParam("serviceName") String serviceName, - @PathParam("deploymentName") String deploymentName, @PathParam("roleName") String roleName); - - /** - * @see RoleApi#createDeployment(String, DeploymentParams) - */ - @Named("CreateVirtualMachineDeployment") - @POST - @Path("/services/hostedservices/{serviceName}/deployments") - @Produces(MediaType.APPLICATION_ATOM_XML) - @Consumes(MediaType.APPLICATION_ATOM_XML) - @Fallback(NullOnNotFoundOr404.class) - @ResponseParser(ParseRequestIdHeader.class) - ListenableFuture createDeployment(@PathParam("serviceName") String serviceName, - @BinderParam(BindDeploymentParamsToXmlPayload.class) DeploymentParams deploymentParams); - - /** - * @see RoleApi#captureRole(String, String, String, String, String) - */ - @Named("CaptureRole") - @POST - @Path("/services/hostedservices/{serviceName}/deployments/{deploymentName}/roleInstances/{roleName}/Operations") - @Consumes(MediaType.APPLICATION_ATOM_XML) - @Produces(MediaType.APPLICATION_ATOM_XML) - @Fallback(NullOnNotFoundOr404.class) - @ResponseParser(ParseRequestIdHeader.class) - @Payload(value = "CaptureRoleOperationDelete{imageLabel}{imageName}") - ListenableFuture captureRole(@PathParam("serviceName") String serviceName, - @PathParam("deploymentName") String deploymentName, @PathParam("roleName") String roleName, - @PayloadParam("imageName") String imageName, @PayloadParam("imageLabel") String imageLabel); - - /** - * @see RoleApi#shutdownRole(String, String, String) - */ - @Named("ShutdownRole") - @POST - @Path("/services/hostedservices/{serviceName}/deployments/{deploymentName}/roleInstances/{roleName}/Operations") - @Consumes(MediaType.APPLICATION_ATOM_XML) - @Produces(MediaType.APPLICATION_ATOM_XML) - @Fallback(NullOnNotFoundOr404.class) - @ResponseParser(ParseRequestIdHeader.class) - @Payload(value = "ShutdownRoleOperation") - ListenableFuture shutdownRole(@PathParam("serviceName") String serviceName, - @PathParam("deploymentName") String deploymentName, @PathParam("roleName") String roleName); - - /** - * @see RoleApi#startRole(String, String, String) - */ - @Named("StartRole") - @POST - @Path("/services/hostedservices/{serviceName}/deployments/{deploymentName}/roleInstances/{roleName}/Operations") - @Consumes(MediaType.APPLICATION_ATOM_XML) - @Produces(MediaType.APPLICATION_ATOM_XML) - @Fallback(NullOnNotFoundOr404.class) - @ResponseParser(ParseRequestIdHeader.class) - @Payload(value = "StartRoleOperation") - ListenableFuture startRole(@PathParam("serviceName") String serviceName, - @PathParam("deploymentName") String deploymentName, @PathParam("roleName") String roleName); - -} diff --git a/labs/azure-management/src/main/java/org/jclouds/azure/management/functions/OSImageParamsName.java b/labs/azure-management/src/main/java/org/jclouds/azure/management/functions/OSImageParamsName.java deleted file mode 100644 index e0d018efd8..0000000000 --- a/labs/azure-management/src/main/java/org/jclouds/azure/management/functions/OSImageParamsName.java +++ /dev/null @@ -1,43 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.azure.management.functions; - -import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.base.Preconditions.checkNotNull; - -import javax.inject.Singleton; - -import org.jclouds.azure.management.domain.OSImageParams; - -import com.google.common.base.Function; - -/** - * - * @author Adrian Cole - */ -@Singleton -public class OSImageParamsName implements Function { - @Override - public String apply(Object input) { - checkArgument(checkNotNull(input, "input") instanceof OSImageParams, - "this function is only valid for OSImageParams!"); - return checkNotNull(OSImageParams.class.cast(input), "OSImageParams").getName(); - } - -} diff --git a/labs/azure-management/src/main/java/org/jclouds/azure/management/functions/ParseRequestIdHeader.java b/labs/azure-management/src/main/java/org/jclouds/azure/management/functions/ParseRequestIdHeader.java deleted file mode 100644 index b2278d2dfa..0000000000 --- a/labs/azure-management/src/main/java/org/jclouds/azure/management/functions/ParseRequestIdHeader.java +++ /dev/null @@ -1,50 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.azure.management.functions; - -import static org.jclouds.http.HttpUtils.releasePayload; - -import javax.inject.Singleton; - -import org.jclouds.http.HttpResponse; - -import com.google.common.base.Function; - -/** - * Parses an x-ms-request-id the header - * - * A value that uniquely identifies a request made against the management service. For an - * asynchronous operation, you can call get operation status with the value of the header to - * determine whether the operation is complete, has failed, or is still in progress. - * - * @author Gerald Pereira - */ -@Singleton -public class ParseRequestIdHeader implements Function { - - public String apply(HttpResponse from) { - releasePayload(from); - String requestId = from.getFirstHeaderOrNull("x-ms-request-id"); - if (requestId != null) { - return requestId; - } - throw new IllegalStateException("did not receive RequestId in: " + from); - } - -} diff --git a/labs/azure-management/src/main/java/org/jclouds/azure/management/options/CreateHostedServiceOptions.java b/labs/azure-management/src/main/java/org/jclouds/azure/management/options/CreateHostedServiceOptions.java deleted file mode 100644 index 75e9c61535..0000000000 --- a/labs/azure-management/src/main/java/org/jclouds/azure/management/options/CreateHostedServiceOptions.java +++ /dev/null @@ -1,129 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.azure.management.options; - -import java.util.Map; - -import com.google.common.base.Objects; -import com.google.common.base.Optional; - -/** - * Optional parameters for creating a hosted service - * - * @see docs - * - * @author Adrian Cole - */ -public class CreateHostedServiceOptions implements Cloneable { - - private Optional description = Optional.absent(); - private Optional> extendedProperties = Optional.absent(); - - /** - * @see CreateHostedServiceOptions#getDescription() - */ - public CreateHostedServiceOptions description(String description) { - this.description = Optional.fromNullable(description); - return this; - } - - /** - * @see CreateHostedServiceOptions#getExtendedProperties() - */ - public CreateHostedServiceOptions extendedProperties(Map extendedProperties) { - this.extendedProperties = Optional.fromNullable(extendedProperties); - return this; - } - - /** - * A description for the hosted service. The description can be up to 1024 characters in length. - */ - public Optional getDescription() { - return description; - } - - /** - * Represents the name of an extended hosted service property. Each extended property must have - * both a defined name and value. You can have a maximum of 50 extended property name/value - * pairs. - * - * The maximum length of the Name element is 64 characters, only alphanumeric characters and - * underscores are valid in the Name, and the name must start with a letter. Each extended - * property value has a maximum length of 255 characters. - */ - public Optional> getExtendedProperties() { - return extendedProperties; - } - - public static class Builder { - - /** - * @see CreateHostedServiceOptions#getDescription() - */ - public static CreateHostedServiceOptions description(String description) { - return new CreateHostedServiceOptions().description(description); - } - - /** - * @see CreateHostedServiceOptions#getExtendedProperties() - */ - public static CreateHostedServiceOptions extendedProperties(Map extendedProperties) { - return new CreateHostedServiceOptions().extendedProperties(extendedProperties); - } - } - - /** - * {@inheritDoc} - */ - @Override - public int hashCode() { - return Objects.hashCode(description, extendedProperties); - } - - @Override - public CreateHostedServiceOptions clone() { - return new CreateHostedServiceOptions().description(description.orNull()).extendedProperties( - extendedProperties.orNull()); - } - - /** - * {@inheritDoc} - */ - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - CreateHostedServiceOptions other = CreateHostedServiceOptions.class.cast(obj); - return Objects.equal(this.description, other.description) - && Objects.equal(this.extendedProperties, other.extendedProperties); - } - - /** - * {@inheritDoc} - */ - @Override - public String toString() { - return Objects.toStringHelper("").omitNullValues().add("description", description.orNull()) - .add("extendedProperties", extendedProperties.orNull()).toString(); - } -} diff --git a/labs/azure-management/src/main/java/org/jclouds/azure/management/suppliers/KeyStoreSupplier.java b/labs/azure-management/src/main/java/org/jclouds/azure/management/suppliers/KeyStoreSupplier.java deleted file mode 100644 index db7f220318..0000000000 --- a/labs/azure-management/src/main/java/org/jclouds/azure/management/suppliers/KeyStoreSupplier.java +++ /dev/null @@ -1,134 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.azure.management.suppliers; - -import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.base.Throwables.propagate; - -import java.io.ByteArrayInputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.security.KeyStore; -import java.security.KeyStoreException; -import java.security.NoSuchAlgorithmException; -import java.security.PrivateKey; -import java.security.cert.Certificate; -import java.security.cert.CertificateException; -import java.security.cert.CertificateFactory; -import java.security.spec.InvalidKeySpecException; -import java.security.spec.KeySpec; -import java.util.Collection; - -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jclouds.crypto.Crypto; -import org.jclouds.crypto.Pems; -import org.jclouds.domain.Credentials; -import org.jclouds.io.InputSuppliers; -import org.jclouds.location.Provider; - -import com.google.common.base.Charsets; -import com.google.common.base.Supplier; - -/** - * TODO this code needs to be completely refactored. It needs to stop using KeyStore of at all possible and definitely - * the local filesystem. Please look at oauth for examples on how to do this via PEMs. - */ -@Deprecated -@Singleton -public class KeyStoreSupplier implements Supplier { - private final Crypto crypto; - private final Supplier creds; - - @Inject - KeyStoreSupplier(Crypto crypto, @Provider Supplier creds) { - this.crypto = crypto; - this.creds = creds; - } - - @Override - public KeyStore get() { - Credentials currentCreds = checkNotNull(creds.get(), "credential supplier returned null"); - String cert = checkNotNull(currentCreds.identity, "credential supplier returned null identity (should be cert)"); - String keyStorePassword = checkNotNull(currentCreds.credential, - "credential supplier returned null credential (should be keyStorePassword)"); - try { - KeyStore keyStore = KeyStore.getInstance("PKCS12"); - - File certFile = new File(checkNotNull(cert)); - if (certFile.isFile()) { // cert is path to pkcs12 file - FileInputStream stream = new FileInputStream(certFile); - try { - keyStore.load(stream, keyStorePassword.toCharArray()); - } finally { - stream.close(); - } - } else { // cert is PEM encoded, containing private key and certs - - // split in private key and certs - int privateKeyBeginIdx = cert.indexOf("-----BEGIN PRIVATE KEY"); - int privateKeyEndIdx = cert.indexOf("-----END PRIVATE KEY"); - String pemPrivateKey = cert.substring(privateKeyBeginIdx, privateKeyEndIdx + 26); - - StringBuilder pemCerts = new StringBuilder(); - int certsBeginIdx = 0; - - do { - certsBeginIdx = cert.indexOf("-----BEGIN CERTIFICATE", certsBeginIdx); - - if (certsBeginIdx >= 0) { - int certsEndIdx = cert.indexOf("-----END CERTIFICATE", certsBeginIdx) + 26; - pemCerts.append(cert.substring(certsBeginIdx, certsEndIdx)); - certsBeginIdx = certsEndIdx; - } - } while (certsBeginIdx != -1); - - // parse private key - KeySpec keySpec = Pems.privateKeySpec(InputSuppliers.of(pemPrivateKey)); - PrivateKey privateKey = crypto.rsaKeyFactory().generatePrivate(keySpec); - - // populate keystore with private key and certs - CertificateFactory cf = CertificateFactory.getInstance("X.509"); - @SuppressWarnings("unchecked") - Collection certs = (Collection) cf.generateCertificates(new ByteArrayInputStream( - pemCerts.toString().getBytes(Charsets.UTF_8))); - keyStore.load(null); - keyStore.setKeyEntry("dummy", privateKey, keyStorePassword.toCharArray(), - certs.toArray(new java.security.cert.Certificate[0])); - - } - return keyStore; - } catch (NoSuchAlgorithmException e) { - throw propagate(e); - } catch (KeyStoreException e) { - throw propagate(e); - } catch (CertificateException e) { - throw propagate(e); - } catch (FileNotFoundException e) { - throw propagate(e); - } catch (IOException e) { - throw propagate(e); - } catch (InvalidKeySpecException e) { - throw propagate(e); - } - } -} diff --git a/labs/azure-management/src/main/java/org/jclouds/azure/management/suppliers/SSLContextWithKeysSupplier.java b/labs/azure-management/src/main/java/org/jclouds/azure/management/suppliers/SSLContextWithKeysSupplier.java deleted file mode 100644 index f7bc63b489..0000000000 --- a/labs/azure-management/src/main/java/org/jclouds/azure/management/suppliers/SSLContextWithKeysSupplier.java +++ /dev/null @@ -1,85 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.azure.management.suppliers; - -import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.base.Throwables.propagate; - -import java.security.KeyManagementException; -import java.security.KeyStore; -import java.security.KeyStoreException; -import java.security.NoSuchAlgorithmException; -import java.security.SecureRandom; -import java.security.UnrecoverableKeyException; - -import javax.inject.Inject; -import javax.inject.Singleton; -import javax.net.ssl.KeyManagerFactory; -import javax.net.ssl.SSLContext; -import javax.net.ssl.TrustManager; - -import org.jclouds.domain.Credentials; -import org.jclouds.http.HttpUtils; -import org.jclouds.http.config.SSLModule.TrustAllCerts; -import org.jclouds.location.Provider; - -import com.google.common.base.Supplier; - -/** - * TODO this code needs to be completely refactored. It needs to stop using KeyStore of at all possible and definitely - * the local filesystem. Please look at oauth for examples on how to do this via PEMs. - */ -@Deprecated -@Singleton -public class SSLContextWithKeysSupplier implements Supplier { - private final Supplier keyStore; - private final TrustManager[] trustManager; - private final Supplier creds; - - @Inject - SSLContextWithKeysSupplier(Supplier keyStore, @Provider Supplier creds, HttpUtils utils, - TrustAllCerts trustAllCerts) { - this.keyStore = keyStore; - this.trustManager = utils.trustAllCerts() ? new TrustManager[] { trustAllCerts } : null; - this.creds = creds; - } - - @Override - public SSLContext get() { - Credentials currentCreds = checkNotNull(creds.get(), "credential supplier returned null"); - String keyStorePassword = checkNotNull(currentCreds.credential, - "credential supplier returned null credential (should be keyStorePassword)"); - KeyManagerFactory kmf; - try { - kmf = KeyManagerFactory.getInstance("SunX509"); - kmf.init(keyStore.get(), keyStorePassword.toCharArray()); - SSLContext sc = SSLContext.getInstance("TLS"); - sc.init(kmf.getKeyManagers(), trustManager, new SecureRandom()); - return sc; - } catch (NoSuchAlgorithmException e) { - throw propagate(e); - } catch (UnrecoverableKeyException e) { - throw propagate(e); - } catch (KeyStoreException e) { - throw propagate(e); - } catch (KeyManagementException e) { - throw propagate(e); - } - } -} diff --git a/labs/azure-management/src/main/java/org/jclouds/azure/management/xml/AttachmentHandler.java b/labs/azure-management/src/main/java/org/jclouds/azure/management/xml/AttachmentHandler.java deleted file mode 100644 index 4b5494f7ae..0000000000 --- a/labs/azure-management/src/main/java/org/jclouds/azure/management/xml/AttachmentHandler.java +++ /dev/null @@ -1,71 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.azure.management.xml; - -import org.jclouds.azure.management.domain.Disk.Attachment; -import org.jclouds.http.functions.ParseSax; -import org.jclouds.util.SaxUtils; -import org.xml.sax.SAXException; - -/** - * @see api - * - * @author Adrian Cole - */ -public class AttachmentHandler extends ParseSax.HandlerForGeneratedRequestWithResult { - - private StringBuilder currentText = new StringBuilder(); - private Attachment.Builder builder = Attachment.builder(); - - /** - * {@inheritDoc} - */ - @Override - public Attachment getResult() { - try { - return builder.build(); - } finally { - builder = Attachment.builder(); - } - } - - /** - * {@inheritDoc} - */ - @Override - public void endElement(String uri, String name, String qName) throws SAXException { - if (qName.equals("HostedServiceName")) { - builder.hostedService(SaxUtils.currentOrNull(currentText)); - } else if (qName.equals("DeploymentName")) { - builder.deployment(SaxUtils.currentOrNull(currentText)); - } else if (qName.equals("RoleName")) { - builder.role(SaxUtils.currentOrNull(currentText)); - } - currentText = new StringBuilder(); - } - - /** - * {@inheritDoc} - */ - @Override - public void characters(char ch[], int start, int length) { - currentText.append(ch, start, length); - } - -} diff --git a/labs/azure-management/src/main/java/org/jclouds/azure/management/xml/DeploymentHandler.java b/labs/azure-management/src/main/java/org/jclouds/azure/management/xml/DeploymentHandler.java deleted file mode 100644 index 9ad6e6ea38..0000000000 --- a/labs/azure-management/src/main/java/org/jclouds/azure/management/xml/DeploymentHandler.java +++ /dev/null @@ -1,129 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.azure.management.xml; - -import static com.google.common.base.Charsets.UTF_8; -import static com.google.common.io.BaseEncoding.base64; -import static org.jclouds.util.SaxUtils.currentOrNull; -import static org.jclouds.util.SaxUtils.equalsOrSuffix; - -import java.net.URI; -import java.util.List; - -import org.jclouds.azure.management.domain.Deployment; -import org.jclouds.azure.management.domain.DeploymentSlot; -import org.jclouds.azure.management.domain.DeploymentStatus; -import org.jclouds.azure.management.domain.InstanceStatus; -import org.jclouds.azure.management.domain.RoleSize; -import org.jclouds.http.functions.ParseSax; -import org.xml.sax.Attributes; -import org.xml.sax.SAXException; - -import com.google.common.collect.Lists; - -/** - * @see api - * @author Gérald Pereira - */ -public class DeploymentHandler extends - ParseSax.HandlerForGeneratedRequestWithResult { - - private List elements = Lists.newArrayList(); - protected StringBuilder currentText = new StringBuilder(); - private Deployment.Builder builder = Deployment.builder(); - - /** - * {@inheritDoc} - */ - @Override - public Deployment getResult() { - try { - return builder.build(); - } finally { - builder = Deployment.builder(); - } - } - - - @Override - public void startElement(String uri, String localName, String qName, - Attributes attributes) throws SAXException { - elements.add(qName); - } - - /** - * {@inheritDoc} - */ - @Override - public void endElement(String uri, String name, String qName) - throws SAXException { - if (equalsOrSuffix(qName, "Name") && "Deployment".equals(elements.get(elements.size()-2))) { - builder.deploymentName(currentOrNull(currentText)); - } else if (equalsOrSuffix(qName, "DeploymentSlot")) { - final String dpltSlot = currentOrNull(currentText); - if (dpltSlot != null) - builder.deploymentSlot(DeploymentSlot.fromValue(dpltSlot)); - } else if (equalsOrSuffix(qName, "Status")) { - String deploymentStatus = currentOrNull(currentText); - if (deploymentStatus != null) - builder.deploymentStatus(DeploymentStatus - .fromValue(deploymentStatus)); - } else if (equalsOrSuffix(qName, "Label")) { - String label = currentOrNull(currentText); - if (label != null) - builder.deploymentLabel(new String(base64().decode(label), UTF_8)); - } else if (equalsOrSuffix(qName, "Url")) { - final String url = currentOrNull(currentText); - if (url != null) - builder.deploymentURL(URI.create(url)); - } else if (equalsOrSuffix(qName, "RoleName")) { - builder.roleName(currentOrNull(currentText)); - } else if (equalsOrSuffix(qName, "InstanceName")) { - builder.instanceName(currentOrNull(currentText)); - } else if (equalsOrSuffix(qName, "InstanceStatus")) { - String instanceStatus = currentOrNull(currentText); - if (instanceStatus != null) - builder.instanceStatus(InstanceStatus.fromValue(instanceStatus)); - } else if (equalsOrSuffix(qName, "InstanceStateDetails")) { - builder.instanceStateDetails(currentOrNull(currentText)); - } else if (equalsOrSuffix(qName, "InstanceErrorCode")) { - builder.instanceErrorCode(currentOrNull(currentText)); - } else if (equalsOrSuffix(qName, "InstanceSize")) { - String instanceSize = currentOrNull(currentText); - if (instanceSize != null) - builder.instanceSize(RoleSize.fromValue(instanceSize)); - } else if (equalsOrSuffix(qName, "IpAddress")) { - builder.privateIpAddress(currentOrNull(currentText)); - } else if (equalsOrSuffix(qName, "Vip")) { - builder.publicIpAddress(currentOrNull(currentText)); - } - - currentText = new StringBuilder(); - elements.remove(elements.size()-1); - } - - /** - * {@inheritDoc} - */ - @Override - public void characters(char ch[], int start, int length) { - currentText.append(ch, start, length); - } - -} diff --git a/labs/azure-management/src/main/java/org/jclouds/azure/management/xml/DetailedHostedServicePropertiesHandler.java b/labs/azure-management/src/main/java/org/jclouds/azure/management/xml/DetailedHostedServicePropertiesHandler.java deleted file mode 100644 index df3b9f53f2..0000000000 --- a/labs/azure-management/src/main/java/org/jclouds/azure/management/xml/DetailedHostedServicePropertiesHandler.java +++ /dev/null @@ -1,84 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.azure.management.xml; - -import static org.jclouds.util.SaxUtils.currentOrNull; -import static org.jclouds.util.SaxUtils.equalsOrSuffix; - -import javax.inject.Inject; - -import org.jclouds.azure.management.domain.DetailedHostedServiceProperties; -import org.jclouds.azure.management.domain.HostedService.Status; -import org.jclouds.date.DateService; -import org.xml.sax.SAXException; - -/** - * @see api - * @author Adrian Cole - */ -public class DetailedHostedServicePropertiesHandler extends HostedServicePropertiesHandler { - - protected final DateService dateService; - - @Inject - protected DetailedHostedServicePropertiesHandler(DateService dateService) { - this.dateService = dateService; - } - - private DetailedHostedServiceProperties.Builder builder = DetailedHostedServiceProperties.builder(); - - private String name; - - /** - * {@inheritDoc} - */ - @Override - public DetailedHostedServiceProperties getResult() { - try { - return builder.fromHostedServiceProperties(super.getResult()).build(); - } finally { - builder = DetailedHostedServiceProperties.builder(); - } - } - - /** - * {@inheritDoc} - */ - @Override - public void endElement(String uri, String name, String qName) throws SAXException { - if (equalsOrSuffix(qName, "DateCreated")) { - builder.created(dateService.iso8601SecondsDateParse(currentOrNull(currentText))); - } else if (equalsOrSuffix(qName, "DateLastModified")) { - builder.lastModified(dateService.iso8601SecondsDateParse(currentOrNull(currentText))); - } else if (equalsOrSuffix(qName, "Status")) { - String rawStatus = currentOrNull(currentText); - builder.rawStatus(rawStatus); - builder.status(Status.fromValue(rawStatus)); - } else if (equalsOrSuffix(qName, "Name")) { - this.name = currentOrNull(currentText); - } else if (equalsOrSuffix(qName, "Value")) { - builder.addExtendedProperty(this.name, currentOrNull(currentText)); - this.name = null; - } else { - super.endElement(uri, name, qName); - } - currentText = new StringBuilder(); - } - -} diff --git a/labs/azure-management/src/main/java/org/jclouds/azure/management/xml/DiskHandler.java b/labs/azure-management/src/main/java/org/jclouds/azure/management/xml/DiskHandler.java deleted file mode 100644 index c6c6523381..0000000000 --- a/labs/azure-management/src/main/java/org/jclouds/azure/management/xml/DiskHandler.java +++ /dev/null @@ -1,122 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.azure.management.xml; - -import static org.jclouds.util.SaxUtils.currentOrNull; -import static org.jclouds.util.SaxUtils.equalsOrSuffix; - -import java.net.URI; - -import javax.inject.Inject; - -import org.jclouds.azure.management.domain.Disk; -import org.jclouds.azure.management.domain.OSType; -import org.jclouds.http.functions.ParseSax; -import org.xml.sax.Attributes; -import org.xml.sax.SAXException; - -/** - * @see api - * @author Adrian Cole - */ -public class DiskHandler extends - ParseSax.HandlerForGeneratedRequestWithResult { - - protected final AttachmentHandler attachmentHandler; - - @Inject - protected DiskHandler(AttachmentHandler attachmentHandler) { - this.attachmentHandler = attachmentHandler; - } - - protected StringBuilder currentText = new StringBuilder(); - private Disk.Builder builder = Disk.builder(); - - protected boolean inAttachment; - - /** - * {@inheritDoc} - */ - @Override - public Disk getResult() { - try { - return builder.build(); - } finally { - builder = Disk.builder(); - } - } - - @Override - public void startElement(String uri, String localName, String qName, - Attributes attributes) throws SAXException { - if (equalsOrSuffix(qName, "AttachedTo")) { - inAttachment = true; - } - } - - /** - * {@inheritDoc} - */ - @Override - public void endElement(String uri, String name, String qName) - throws SAXException { - if (equalsOrSuffix(qName, "AttachedTo")) { - builder.attachedTo(attachmentHandler.getResult()); - inAttachment = false; - } else if (inAttachment) { - attachmentHandler.endElement(uri, name, qName); - } else if (equalsOrSuffix(qName, "OS")) { - builder.os(OSType.fromValue(currentOrNull(currentText))); - } else if (equalsOrSuffix(qName, "Name")) { - builder.name(currentOrNull(currentText)); - } else if (equalsOrSuffix(qName, "LogicalDiskSizeInGB")) { - String gb = currentOrNull(currentText); - if (gb != null) - builder.logicalSizeInGB(Integer.parseInt(gb)); - } else if (equalsOrSuffix(qName, "Description")) { - builder.description(currentOrNull(currentText)); - } else if (equalsOrSuffix(qName, "Location")) { - builder.location(currentOrNull(currentText)); - } else if (equalsOrSuffix(qName, "AffinityGroup")) { - builder.affinityGroup(currentOrNull(currentText)); - } else if (equalsOrSuffix(qName, "MediaLink")) { - String link = currentOrNull(currentText); - if (link != null) - builder.mediaLink(URI.create(link)); - } else if (equalsOrSuffix(qName, "SourceImageName")) { - builder.sourceImage(currentOrNull(currentText)); - } else if (equalsOrSuffix(qName, "Label")) { - builder.label(currentOrNull(currentText)); - } - currentText = new StringBuilder(); - } - - /** - * {@inheritDoc} - */ - @Override - public void characters(char ch[], int start, int length) { - if (inAttachment) { - attachmentHandler.characters(ch, start, length); - } else { - currentText.append(ch, start, length); - } - } - -} diff --git a/labs/azure-management/src/main/java/org/jclouds/azure/management/xml/ErrorHandler.java b/labs/azure-management/src/main/java/org/jclouds/azure/management/xml/ErrorHandler.java deleted file mode 100644 index 1d5d360907..0000000000 --- a/labs/azure-management/src/main/java/org/jclouds/azure/management/xml/ErrorHandler.java +++ /dev/null @@ -1,72 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.azure.management.xml; - -import org.jclouds.azure.management.domain.Error; -import org.jclouds.azure.management.domain.Error.Code; -import org.jclouds.http.functions.ParseSax; -import org.jclouds.util.SaxUtils; -import org.xml.sax.SAXException; - -/** - * @see api - * - * @author Adrian Cole - */ -public class ErrorHandler extends ParseSax.HandlerForGeneratedRequestWithResult { - - private StringBuilder currentText = new StringBuilder(); - private Error.Builder builder = Error.builder(); - - /** - * {@inheritDoc} - */ - @Override - public Error getResult() { - try { - return builder.build(); - } finally { - builder = Error.builder(); - } - } - - /** - * {@inheritDoc} - */ - @Override - public void endElement(String uri, String name, String qName) throws SAXException { - if (qName.equals("Code")) { - String rawCode = SaxUtils.currentOrNull(currentText); - builder.rawCode(rawCode); - builder.code(Code.fromValue(rawCode)); - } else if (qName.equals("Message")) { - builder.message(SaxUtils.currentOrNull(currentText)); - } - currentText = new StringBuilder(); - } - - /** - * {@inheritDoc} - */ - @Override - public void characters(char ch[], int start, int length) { - currentText.append(ch, start, length); - } - -} diff --git a/labs/azure-management/src/main/java/org/jclouds/azure/management/xml/HostedServiceHandler.java b/labs/azure-management/src/main/java/org/jclouds/azure/management/xml/HostedServiceHandler.java deleted file mode 100644 index 807813ed10..0000000000 --- a/labs/azure-management/src/main/java/org/jclouds/azure/management/xml/HostedServiceHandler.java +++ /dev/null @@ -1,112 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.azure.management.xml; - -import static org.jclouds.util.SaxUtils.currentOrNull; -import static org.jclouds.util.SaxUtils.equalsOrSuffix; - -import java.net.URI; - -import javax.inject.Inject; - -import org.jclouds.azure.management.domain.HostedService; -import org.jclouds.azure.management.domain.HostedService.Builder; -import org.jclouds.http.functions.ParseSax; -import org.xml.sax.Attributes; -import org.xml.sax.SAXException; - -/** - * @see api - * @author Adrian Cole - */ -public class HostedServiceHandler extends ParseSax.HandlerForGeneratedRequestWithResult { - - protected final HostedServicePropertiesHandler hostedServicePropertiesHandler; - - @Inject - protected HostedServiceHandler(HostedServicePropertiesHandler hostedServicePropertiesHandler) { - this.hostedServicePropertiesHandler = hostedServicePropertiesHandler; - } - - protected StringBuilder currentText = new StringBuilder(); - protected HostedService.Builder builder = builder(); - - protected Builder builder() { - return HostedService.builder(); - } - - protected boolean inHostedServiceProperties; - - /** - * {@inheritDoc} - */ - @Override - public HostedService getResult() { - try { - return builder.build(); - } finally { - builder = builder(); - } - } - - /** - * {@inheritDoc} - */ - @Override - public void startElement(String url, String name, String qName, Attributes attributes) throws SAXException { - if (equalsOrSuffix(qName, "HostedServiceProperties")) { - inHostedServiceProperties = true; - } - if (inHostedServiceProperties) { - hostedServicePropertiesHandler.startElement(url, name, qName, attributes); - } - } - - /** - * {@inheritDoc} - */ - @Override - public void endElement(String uri, String name, String qName) throws SAXException { - - if (equalsOrSuffix(qName, "HostedServiceProperties")) { - builder.properties(hostedServicePropertiesHandler.getResult()); - inHostedServiceProperties = false; - } else if (inHostedServiceProperties) { - hostedServicePropertiesHandler.endElement(uri, name, qName); - } else if (equalsOrSuffix(qName, "Url")) { - builder.url(URI.create(currentOrNull(currentText))); - } else if (equalsOrSuffix(qName, "ServiceName")) { - builder.name(currentOrNull(currentText)); - } - currentText = new StringBuilder(); - } - - /** - * {@inheritDoc} - */ - @Override - public void characters(char ch[], int start, int length) { - if (inHostedServiceProperties) { - hostedServicePropertiesHandler.characters(ch, start, length); - } else { - currentText.append(ch, start, length); - } - } - -} diff --git a/labs/azure-management/src/main/java/org/jclouds/azure/management/xml/HostedServicePropertiesHandler.java b/labs/azure-management/src/main/java/org/jclouds/azure/management/xml/HostedServicePropertiesHandler.java deleted file mode 100644 index 2f4cf750f9..0000000000 --- a/labs/azure-management/src/main/java/org/jclouds/azure/management/xml/HostedServicePropertiesHandler.java +++ /dev/null @@ -1,77 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.azure.management.xml; - -import static com.google.common.base.Charsets.UTF_8; -import static com.google.common.io.BaseEncoding.base64; -import static org.jclouds.util.SaxUtils.currentOrNull; -import static org.jclouds.util.SaxUtils.equalsOrSuffix; - -import org.jclouds.azure.management.domain.HostedServiceProperties; -import org.jclouds.http.functions.ParseSax; -import org.xml.sax.SAXException; - -/** - * @see api - * @author Adrian Cole - */ -public class HostedServicePropertiesHandler extends - ParseSax.HandlerForGeneratedRequestWithResult { - - protected StringBuilder currentText = new StringBuilder(); - private HostedServiceProperties.Builder builder = HostedServiceProperties.builder(); - - /** - * {@inheritDoc} - */ - @Override - public HostedServiceProperties getResult() { - try { - return builder.build(); - } finally { - builder = HostedServiceProperties.builder(); - } - } - - /** - * {@inheritDoc} - */ - @Override - public void endElement(String uri, String name, String qName) throws SAXException { - if (equalsOrSuffix(qName, "Description")) { - builder.description(currentOrNull(currentText)); - } else if (equalsOrSuffix(qName, "Location")) { - builder.location(currentOrNull(currentText)); - } else if (equalsOrSuffix(qName, "AffinityGroup")) { - builder.affinityGroup(currentOrNull(currentText)); - } else if (equalsOrSuffix(qName, "Label")) { - builder.label(new String(base64().decode(currentOrNull(currentText)), UTF_8)); - } - currentText = new StringBuilder(); - } - - /** - * {@inheritDoc} - */ - @Override - public void characters(char ch[], int start, int length) { - currentText.append(ch, start, length); - } - -} diff --git a/labs/azure-management/src/main/java/org/jclouds/azure/management/xml/HostedServiceWithDetailedPropertiesHandler.java b/labs/azure-management/src/main/java/org/jclouds/azure/management/xml/HostedServiceWithDetailedPropertiesHandler.java deleted file mode 100644 index 09cbfb7874..0000000000 --- a/labs/azure-management/src/main/java/org/jclouds/azure/management/xml/HostedServiceWithDetailedPropertiesHandler.java +++ /dev/null @@ -1,32 +0,0 @@ -package org.jclouds.azure.management.xml; - -import javax.inject.Inject; - -import org.jclouds.azure.management.domain.HostedServiceWithDetailedProperties; - -/** - * - * @author Adrian Cole - */ -public class HostedServiceWithDetailedPropertiesHandler extends HostedServiceHandler { - - @Inject - protected HostedServiceWithDetailedPropertiesHandler( - DetailedHostedServicePropertiesHandler hostedServicePropertiesHandler) { - super(hostedServicePropertiesHandler); - } - - @Override - protected HostedServiceWithDetailedProperties.Builder builder() { - return HostedServiceWithDetailedProperties.builder(); - } - - @Override - public HostedServiceWithDetailedProperties getResult() { - try { - return HostedServiceWithDetailedProperties.class.cast(builder.build()); - } finally { - builder = builder(); - } - } -} diff --git a/labs/azure-management/src/main/java/org/jclouds/azure/management/xml/ListDisksHandler.java b/labs/azure-management/src/main/java/org/jclouds/azure/management/xml/ListDisksHandler.java deleted file mode 100644 index 591f2e9d85..0000000000 --- a/labs/azure-management/src/main/java/org/jclouds/azure/management/xml/ListDisksHandler.java +++ /dev/null @@ -1,93 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.azure.management.xml; - -import java.util.Set; - -import org.jclouds.azure.management.domain.Disk; -import org.jclouds.http.functions.ParseSax; -import org.jclouds.util.SaxUtils; -import org.xml.sax.Attributes; -import org.xml.sax.SAXException; - -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.ImmutableSet.Builder; -import com.google.inject.Inject; - -/** - * @author Gerald Pereira - */ -public class ListDisksHandler extends ParseSax.HandlerForGeneratedRequestWithResult> { - - private final DiskHandler diskHandler; - - private Builder disks = ImmutableSet. builder(); - - private boolean inDisk; - - @Inject - public ListDisksHandler(final DiskHandler diskHandler) { - this.diskHandler = diskHandler; - } - - /** - * {@inheritDoc} - */ - @Override - public Set getResult() { - return disks.build(); - } - - /** - * {@inheritDoc} - */ - @Override - public void startElement(String url, String name, String qName, Attributes attributes) throws SAXException { - if (SaxUtils.equalsOrSuffix(qName, "Disk")) { - inDisk = true; - } - if (inDisk) { - diskHandler.startElement(url, name, qName, attributes); - } - } - - /** - * {@inheritDoc} - */ - @Override - public void endElement(String uri, String name, String qName) throws SAXException { - if (qName.equals("Disk")) { - inDisk = false; - disks.add(diskHandler.getResult()); - } else if (inDisk) { - diskHandler.endElement(uri, name, qName); - } - } - - /** - * {@inheritDoc} - */ - @Override - public void characters(char ch[], int start, int length) { - if (inDisk) { - diskHandler.characters(ch, start, length); - } - } - -} diff --git a/labs/azure-management/src/main/java/org/jclouds/azure/management/xml/ListHostedServicesHandler.java b/labs/azure-management/src/main/java/org/jclouds/azure/management/xml/ListHostedServicesHandler.java deleted file mode 100644 index 6c6ccffa75..0000000000 --- a/labs/azure-management/src/main/java/org/jclouds/azure/management/xml/ListHostedServicesHandler.java +++ /dev/null @@ -1,97 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.azure.management.xml; - -import java.util.Set; - -import org.jclouds.azure.management.domain.HostedServiceWithDetailedProperties; -import org.jclouds.http.functions.ParseSax; -import org.jclouds.util.SaxUtils; -import org.xml.sax.Attributes; -import org.xml.sax.SAXException; - -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.ImmutableSet.Builder; -import com.google.inject.Inject; - -/** - * @see doc - * - * @author Adrian Cole - */ -public class ListHostedServicesHandler extends - ParseSax.HandlerForGeneratedRequestWithResult> { - - private final HostedServiceWithDetailedPropertiesHandler hostedServiceHandler; - - private Builder hostedServices = ImmutableSet - . builder(); - - private boolean inHostedService; - - @Inject - public ListHostedServicesHandler(HostedServiceWithDetailedPropertiesHandler hostedServiceHandler) { - this.hostedServiceHandler = hostedServiceHandler; - } - - /** - * {@inheritDoc} - */ - @Override - public Set getResult() { - return hostedServices.build(); - } - - /** - * {@inheritDoc} - */ - @Override - public void startElement(String url, String name, String qName, Attributes attributes) throws SAXException { - if (SaxUtils.equalsOrSuffix(qName, "HostedService")) { - inHostedService = true; - } - if (inHostedService) { - hostedServiceHandler.startElement(url, name, qName, attributes); - } - } - - /** - * {@inheritDoc} - */ - @Override - public void endElement(String uri, String name, String qName) throws SAXException { - if (qName.equals("HostedService")) { - inHostedService = false; - hostedServices.add(hostedServiceHandler.getResult()); - } else if (inHostedService) { - hostedServiceHandler.endElement(uri, name, qName); - } - } - - /** - * {@inheritDoc} - */ - @Override - public void characters(char ch[], int start, int length) { - if (inHostedService) { - hostedServiceHandler.characters(ch, start, length); - } - } - -} diff --git a/labs/azure-management/src/main/java/org/jclouds/azure/management/xml/ListLocationsHandler.java b/labs/azure-management/src/main/java/org/jclouds/azure/management/xml/ListLocationsHandler.java deleted file mode 100644 index e2fe9a1a17..0000000000 --- a/labs/azure-management/src/main/java/org/jclouds/azure/management/xml/ListLocationsHandler.java +++ /dev/null @@ -1,93 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.azure.management.xml; - -import java.util.Set; - -import org.jclouds.azure.management.domain.Location; -import org.jclouds.http.functions.ParseSax; -import org.jclouds.util.SaxUtils; -import org.xml.sax.Attributes; -import org.xml.sax.SAXException; - -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.ImmutableSet.Builder; -import com.google.inject.Inject; - -/** - * @author Adrian Cole - */ -public class ListLocationsHandler extends ParseSax.HandlerForGeneratedRequestWithResult> { - - private final LocationHandler locationHandler; - - private Builder locations = ImmutableSet. builder(); - - private boolean inLocation; - - @Inject - public ListLocationsHandler(LocationHandler locationHandler) { - this.locationHandler = locationHandler; - } - - /** - * {@inheritDoc} - */ - @Override - public Set getResult() { - return locations.build(); - } - - /** - * {@inheritDoc} - */ - @Override - public void startElement(String url, String name, String qName, Attributes attributes) throws SAXException { - if (SaxUtils.equalsOrSuffix(qName, "Location")) { - inLocation = true; - } - if (inLocation) { - locationHandler.startElement(url, name, qName, attributes); - } - } - - /** - * {@inheritDoc} - */ - @Override - public void endElement(String uri, String name, String qName) throws SAXException { - if (qName.equals("Location")) { - inLocation = false; - locations.add(locationHandler.getResult()); - } else if (inLocation) { - locationHandler.endElement(uri, name, qName); - } - } - - /** - * {@inheritDoc} - */ - @Override - public void characters(char ch[], int start, int length) { - if (inLocation) { - locationHandler.characters(ch, start, length); - } - } - -} diff --git a/labs/azure-management/src/main/java/org/jclouds/azure/management/xml/ListOSImagesHandler.java b/labs/azure-management/src/main/java/org/jclouds/azure/management/xml/ListOSImagesHandler.java deleted file mode 100644 index 471b2ff2b2..0000000000 --- a/labs/azure-management/src/main/java/org/jclouds/azure/management/xml/ListOSImagesHandler.java +++ /dev/null @@ -1,93 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.azure.management.xml; - -import java.util.Set; - -import org.jclouds.azure.management.domain.OSImage; -import org.jclouds.http.functions.ParseSax; -import org.jclouds.util.SaxUtils; -import org.xml.sax.Attributes; -import org.xml.sax.SAXException; - -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.ImmutableSet.Builder; -import com.google.inject.Inject; - -/** - * @author Adrian Cole - */ -public class ListOSImagesHandler extends ParseSax.HandlerForGeneratedRequestWithResult> { - - private final OSImageHandler locationHandler; - - private Builder locations = ImmutableSet. builder(); - - private boolean inOSImage; - - @Inject - public ListOSImagesHandler(OSImageHandler locationHandler) { - this.locationHandler = locationHandler; - } - - /** - * {@inheritDoc} - */ - @Override - public Set getResult() { - return locations.build(); - } - - /** - * {@inheritDoc} - */ - @Override - public void startElement(String url, String name, String qName, Attributes attributes) throws SAXException { - if (SaxUtils.equalsOrSuffix(qName, "OSImage")) { - inOSImage = true; - } - if (inOSImage) { - locationHandler.startElement(url, name, qName, attributes); - } - } - - /** - * {@inheritDoc} - */ - @Override - public void endElement(String uri, String name, String qName) throws SAXException { - if (qName.equals("OSImage")) { - inOSImage = false; - locations.add(locationHandler.getResult()); - } else if (inOSImage) { - locationHandler.endElement(uri, name, qName); - } - } - - /** - * {@inheritDoc} - */ - @Override - public void characters(char ch[], int start, int length) { - if (inOSImage) { - locationHandler.characters(ch, start, length); - } - } - -} diff --git a/labs/azure-management/src/main/java/org/jclouds/azure/management/xml/LocationHandler.java b/labs/azure-management/src/main/java/org/jclouds/azure/management/xml/LocationHandler.java deleted file mode 100644 index 34ee7aa57a..0000000000 --- a/labs/azure-management/src/main/java/org/jclouds/azure/management/xml/LocationHandler.java +++ /dev/null @@ -1,71 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.azure.management.xml; - -import org.jclouds.azure.management.domain.Location; -import org.jclouds.http.functions.ParseSax; -import org.jclouds.util.SaxUtils; -import org.xml.sax.SAXException; - -/** - * @see api - * - * @author Adrian Cole - */ -public class LocationHandler extends ParseSax.HandlerForGeneratedRequestWithResult { - - private StringBuilder currentText = new StringBuilder(); - private Location.Builder builder = Location.builder(); - - /** - * {@inheritDoc} - */ - @Override - public Location getResult() { - try { - return builder.build(); - } finally { - builder = Location.builder(); - } - } - - /** - * {@inheritDoc} - */ - @Override - public void endElement(String uri, String name, String qName) throws SAXException { - if (qName.equals("Name")) { - builder.name(SaxUtils.currentOrNull(currentText)); - } else if (qName.equals("DisplayName")) { - builder.displayName(SaxUtils.currentOrNull(currentText)); - } else if (qName.equals("AvailableService")) { - builder.addAvailableService(SaxUtils.currentOrNull(currentText)); - } - currentText = new StringBuilder(); - } - - /** - * {@inheritDoc} - */ - @Override - public void characters(char ch[], int start, int length) { - currentText.append(ch, start, length); - } - -} diff --git a/labs/azure-management/src/main/java/org/jclouds/azure/management/xml/OSImageHandler.java b/labs/azure-management/src/main/java/org/jclouds/azure/management/xml/OSImageHandler.java deleted file mode 100644 index dae17df27a..0000000000 --- a/labs/azure-management/src/main/java/org/jclouds/azure/management/xml/OSImageHandler.java +++ /dev/null @@ -1,95 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.azure.management.xml; - -import static org.jclouds.util.SaxUtils.currentOrNull; -import static org.jclouds.util.SaxUtils.equalsOrSuffix; - -import java.net.URI; - -import org.jclouds.azure.management.domain.OSImage; -import org.jclouds.azure.management.domain.OSType; -import org.jclouds.http.functions.ParseSax; -import org.xml.sax.SAXException; - -/** - * @see api - * @author Adrian Cole - */ -public class OSImageHandler extends ParseSax.HandlerForGeneratedRequestWithResult { - - protected StringBuilder currentText = new StringBuilder(); - private OSImage.Builder builder = OSImage.builder(); - - /** - * {@inheritDoc} - */ - @Override - public OSImage getResult() { - try { - return builder.build(); - } finally { - builder = OSImage.builder(); - } - } - - /** - * {@inheritDoc} - */ - @Override - public void endElement(String uri, String name, String qName) throws SAXException { - if (equalsOrSuffix(qName, "OS")) { - builder.os(OSType.fromValue(currentOrNull(currentText))); - } else if (equalsOrSuffix(qName, "Name")) { - builder.name(currentOrNull(currentText)); - } else if (equalsOrSuffix(qName, "LogicalSizeInGB")) { - String gb = currentOrNull(currentText); - if (gb != null) - builder.logicalSizeInGB(Integer.parseInt(gb)); - } else if (equalsOrSuffix(qName, "Description")) { - builder.description(currentOrNull(currentText)); - } else if (equalsOrSuffix(qName, "Category")) { - builder.category(currentOrNull(currentText)); - } else if (equalsOrSuffix(qName, "Location")) { - builder.location(currentOrNull(currentText)); - } else if (equalsOrSuffix(qName, "AffinityGroup")) { - builder.affinityGroup(currentOrNull(currentText)); - } else if (equalsOrSuffix(qName, "MediaLink")) { - String link = currentOrNull(currentText); - if (link != null) - builder.mediaLink(URI.create(link)); - } else if (equalsOrSuffix(qName, "Eula")) { - String eula = currentOrNull(currentText); - if (eula != null) - builder.eula(URI.create(eula)); - } else if (equalsOrSuffix(qName, "Label")) { - builder.label(currentOrNull(currentText)); - } - currentText = new StringBuilder(); - } - - /** - * {@inheritDoc} - */ - @Override - public void characters(char ch[], int start, int length) { - currentText.append(ch, start, length); - } - -} diff --git a/labs/azure-management/src/main/java/org/jclouds/azure/management/xml/OperationHandler.java b/labs/azure-management/src/main/java/org/jclouds/azure/management/xml/OperationHandler.java deleted file mode 100644 index 98efb3c793..0000000000 --- a/labs/azure-management/src/main/java/org/jclouds/azure/management/xml/OperationHandler.java +++ /dev/null @@ -1,114 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.azure.management.xml; - -import static org.jclouds.util.SaxUtils.currentOrNull; -import static org.jclouds.util.SaxUtils.equalsOrSuffix; - -import javax.inject.Inject; - -import org.jclouds.azure.management.domain.Operation; -import org.jclouds.azure.management.domain.Operation.Builder; -import org.jclouds.azure.management.domain.Operation.Status; -import org.jclouds.http.functions.ParseSax; -import org.xml.sax.Attributes; -import org.xml.sax.SAXException; - -/** - * @see api - * @author Adrian Cole - */ -public class OperationHandler extends ParseSax.HandlerForGeneratedRequestWithResult { - - protected final ErrorHandler errorHandler; - - @Inject - protected OperationHandler(ErrorHandler errorHandler) { - this.errorHandler = errorHandler; - } - - protected StringBuilder currentText = new StringBuilder(); - protected Operation.Builder builder = builder(); - - protected Builder builder() { - return Operation.builder(); - } - - protected boolean inError; - - /** - * {@inheritDoc} - */ - @Override - public Operation getResult() { - try { - return builder.build(); - } finally { - builder = builder(); - } - } - - /** - * {@inheritDoc} - */ - @Override - public void startElement(String url, String name, String qName, Attributes attributes) throws SAXException { - if (equalsOrSuffix(qName, "Error")) { - inError = true; - } - if (inError) { - errorHandler.startElement(url, name, qName, attributes); - } - } - - /** - * {@inheritDoc} - */ - @Override - public void endElement(String uri, String name, String qName) throws SAXException { - if (equalsOrSuffix(qName, "Error")) { - builder.error(errorHandler.getResult()); - inError = false; - } else if (inError) { - errorHandler.endElement(uri, name, qName); - } else if (equalsOrSuffix(qName, "ID")) { - builder.id(currentOrNull(currentText)); - } else if (qName.equals("Status")) { - String rawStatus = currentOrNull(currentText); - builder.rawStatus(rawStatus); - builder.status(Status.fromValue(rawStatus)); - } else if (equalsOrSuffix(qName, "HttpStatusCode")) { - builder.httpStatusCode(Integer.parseInt(currentOrNull(currentText))); - } - currentText = new StringBuilder(); - } - - /** - * {@inheritDoc} - */ - @Override - public void characters(char ch[], int start, int length) { - if (inError) { - errorHandler.characters(ch, start, length); - } else { - currentText.append(ch, start, length); - } - } - -} diff --git a/labs/azure-management/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata b/labs/azure-management/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata deleted file mode 100644 index 03fb1dbc63..0000000000 --- a/labs/azure-management/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata +++ /dev/null @@ -1 +0,0 @@ -org.jclouds.azure.management.AzureManagementProviderMetadata diff --git a/labs/azure-management/src/test/java/org/jclouds/azure/management/AzureManagementProviderMetadataTest.java b/labs/azure-management/src/test/java/org/jclouds/azure/management/AzureManagementProviderMetadataTest.java deleted file mode 100644 index dda540896d..0000000000 --- a/labs/azure-management/src/test/java/org/jclouds/azure/management/AzureManagementProviderMetadataTest.java +++ /dev/null @@ -1,34 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not computee this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.azure.management; - -import org.jclouds.providers.internal.BaseProviderMetadataTest; -import org.testng.annotations.Test; - -/** - * - * @author Adrian Cole - */ -@Test(groups = "unit", testName = "AzureManagementProviderMetadataTest") -public class AzureManagementProviderMetadataTest extends BaseProviderMetadataTest { - - public AzureManagementProviderMetadataTest() { - super(new AzureManagementProviderMetadata(), new AzureManagementApiMetadata()); - } -} diff --git a/labs/azure-management/src/test/java/org/jclouds/azure/management/features/DiskApiExpectTest.java b/labs/azure-management/src/test/java/org/jclouds/azure/management/features/DiskApiExpectTest.java deleted file mode 100644 index be3aafbe79..0000000000 --- a/labs/azure-management/src/test/java/org/jclouds/azure/management/features/DiskApiExpectTest.java +++ /dev/null @@ -1,86 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unles required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either expres or implied. See the License for the - * specific language governing permisions and limitations - * under the License. - */ -package org.jclouds.azure.management.features; - -import static org.testng.Assert.assertEquals; - -import org.jclouds.azure.management.AzureManagementApi; -import org.jclouds.azure.management.internal.BaseAzureManagementApiExpectTest; -import org.jclouds.azure.management.parse.ListDisksTest; -import org.jclouds.http.HttpRequest; -import org.jclouds.http.HttpResponse; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableSet; - -/** - * @author Gérald Pereira - */ -@Test(groups = "unit", testName = "DiskApiExpectTest") -public class DiskApiExpectTest extends BaseAzureManagementApiExpectTest { - - private static final String DISK_NAME = "mydisk"; - - HttpRequest list = HttpRequest.builder().method("GET") - .endpoint("https://management.core.windows.net/" + subscriptionId + "/services/disks") - .addHeader("x-ms-version", "2012-03-01") - .addHeader("Accept", "application/xml").build(); - - public void testListWhenResponseIs2xx() throws Exception { - - HttpResponse listResponse = HttpResponse.builder().statusCode(200) - .payload(payloadFromResourceWithContentType("/disks.xml", "application/xml")).build(); - - AzureManagementApi apiWhenExist = requestSendsResponse( - list, listResponse); - - assertEquals(apiWhenExist.getDiskApi().list().toString(), new ListDisksTest().expected().toString()); - } - - public void testListWhenResponseIs404() throws Exception { - - HttpResponse listResponse = HttpResponse.builder().statusCode(404).build(); - - AzureManagementApi apiWhenDontExist = requestSendsResponse( - list, listResponse); - - assertEquals(apiWhenDontExist.getDiskApi().list(), ImmutableSet.of()); - } - - HttpRequest delete = HttpRequest.builder().method("DELETE") - .endpoint("https://management.core.windows.net/" + subscriptionId + "/services/disks/" + DISK_NAME) - .addHeader("x-ms-version", "2012-03-01") - .build(); - - public void testDeleteWhenResponseIs2xx() throws Exception { - HttpResponse deleteResponse = HttpResponse.builder().statusCode(200).addHeader("x-ms-request-id", "fakerequestid").build(); - - AzureManagementApi apiWhenExist = requestSendsResponse(delete, deleteResponse); - - apiWhenExist.getDiskApi().delete(DISK_NAME); - } - - public void testDeleteWhenResponseIs404() throws Exception { - HttpResponse deleteResponse = HttpResponse.builder().statusCode(404).build(); - - AzureManagementApi apiWhenDontExist = requestSendsResponse(delete, deleteResponse); - - apiWhenDontExist.getDiskApi().delete(DISK_NAME); - } -} diff --git a/labs/azure-management/src/test/java/org/jclouds/azure/management/features/DiskApiLiveTest.java b/labs/azure-management/src/test/java/org/jclouds/azure/management/features/DiskApiLiveTest.java deleted file mode 100644 index 4055c01aa6..0000000000 --- a/labs/azure-management/src/test/java/org/jclouds/azure/management/features/DiskApiLiveTest.java +++ /dev/null @@ -1,127 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.azure.management.features; - -import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.collect.Iterables.transform; -import static org.testng.Assert.assertNotEquals; -import static org.testng.Assert.assertTrue; - -import java.util.Set; - -import org.jclouds.azure.management.domain.Disk; -import org.jclouds.azure.management.domain.Location; -import org.jclouds.azure.management.domain.OSImage; -import org.jclouds.azure.management.domain.OSType; -import org.jclouds.azure.management.internal.BaseAzureManagementApiLiveTest; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -import com.google.common.base.Function; -import com.google.common.collect.ImmutableSet; - -/** - * @author Adrian Cole - */ -@Test(groups = "live", testName = "DiskApiLiveTest") -public class DiskApiLiveTest extends BaseAzureManagementApiLiveTest { - - private ImmutableSet locations; - private ImmutableSet images; - - @BeforeClass(groups = { "integration", "live" }) - public void setupContext() { - super.initializeContext(); - - locations = ImmutableSet.copyOf(transform(context.getApi().getLocationApi().list(), - new Function() { - @Override - public String apply(Location in) { - return in.getName(); - } - })); - images = ImmutableSet.copyOf(transform(context.getApi().getOSImageApi().list(), new Function() { - @Override - public String apply(OSImage in) { - return in.getName(); - } - })); - } - - @Test - protected void testList() { - Set response = api().list(); - - for (Disk disk : response) { - checkDisk(disk); - } - } - - private void checkDisk(Disk disk) { - checkNotNull(disk.getName(), "Name cannot be null for Disk %s", disk.getLabel()); - checkNotNull(disk.getOS(), "OS cannot be null for Disk: %s", disk); - assertNotEquals(disk.getOS(), OSType.UNRECOGNIZED, "Status cannot be UNRECOGNIZED for Disk: " + disk); - - checkNotNull(disk.getAttachedTo(), "While AttachedTo can be null for Disk, its Optional wrapper cannot: %s", disk); - if (disk.getAttachedTo().isPresent()) { - // TODO: verify you can lookup the role - } - - checkNotNull(disk.getLogicalSizeInGB(), - "While LogicalSizeInGB can be null for Disk, its Optional wrapper cannot: %s", disk); - - if (disk.getLogicalSizeInGB().isPresent()) - assertTrue(disk.getLogicalSizeInGB().get() > 0, "LogicalSizeInGB should be positive, if set" + disk.toString()); - - checkNotNull(disk.getMediaLink(), "While MediaLink can be null for Disk, its Optional wrapper cannot: %s", disk); - - if (disk.getMediaLink().isPresent()) - assertTrue(ImmutableSet.of("http", "https").contains(disk.getMediaLink().get().getScheme()), - "MediaLink should be an http(s) url" + disk.toString()); - - checkNotNull(disk.getLabel(), "While Label can be null for Disk, its Optional wrapper cannot: %s", - disk); - - checkNotNull(disk.getDescription(), "While Description can be null for Disk, its Optional wrapper cannot: %s", - disk); - - checkNotNull(disk.getLocation(), "While Location can be null for Disk, its Optional wrapper cannot: %s", disk); - if (disk.getLocation().isPresent()) { - assertTrue(locations.contains(disk.getLocation().get()), - "Location not in " + locations + " :" + disk.toString()); - } - - checkNotNull(disk.getSourceImage(), "While SourceImage can be null for Disk, its Optional wrapper cannot: %s", - disk); - if (disk.getSourceImage().isPresent()) { - assertTrue(images.contains(disk.getSourceImage().get()), - "SourceImage not in " + images + " :" + disk.toString()); - } - - checkNotNull(disk.getAffinityGroup(), - "While AffinityGroup can be null for Disk, its Optional wrapper cannot: %s", disk); - if (disk.getAffinityGroup().isPresent()) { - // TODO: list getAffinityGroups and check if there - } - } - - protected DiskApi api() { - return context.getApi().getDiskApi(); - } -} diff --git a/labs/azure-management/src/test/java/org/jclouds/azure/management/features/HostedServiceApiExpectTest.java b/labs/azure-management/src/test/java/org/jclouds/azure/management/features/HostedServiceApiExpectTest.java deleted file mode 100644 index 2c35936891..0000000000 --- a/labs/azure-management/src/test/java/org/jclouds/azure/management/features/HostedServiceApiExpectTest.java +++ /dev/null @@ -1,173 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unles required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either expres or implied. See the License for the - * specific language governing permisions and limitations - * under the License. - */ -package org.jclouds.azure.management.features; - -import static org.jclouds.azure.management.options.CreateHostedServiceOptions.Builder.description; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNull; - -import org.jclouds.azure.management.AzureManagementApi; -import org.jclouds.azure.management.internal.BaseAzureManagementApiExpectTest; -import org.jclouds.azure.management.parse.GetHostedServiceDetailsTest; -import org.jclouds.azure.management.parse.GetHostedServiceTest; -import org.jclouds.azure.management.parse.ListHostedServicesTest; -import org.jclouds.http.HttpRequest; -import org.jclouds.http.HttpResponse; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; - -/** - * @author Adrian Cole - */ -@Test(groups = "unit", testName = "HostedServiceApiExpectTest") -public class HostedServiceApiExpectTest extends BaseAzureManagementApiExpectTest { - - private static final String SERVICE_NAME = "myservice"; - HttpRequest list = HttpRequest.builder().method("GET") - .endpoint("https://management.core.windows.net/" + subscriptionId + "/services/hostedservices") - .addHeader("x-ms-version", "2012-03-01") - .addHeader("Accept", "application/xml").build(); - - public void testListWhenResponseIs2xx() throws Exception { - - HttpResponse listResponse = HttpResponse.builder().statusCode(200) - .payload(payloadFromResourceWithContentType("/hostedservices.xml", "application")).build(); - - AzureManagementApi apiWhenExist = requestSendsResponse( - list, listResponse); - - assertEquals(apiWhenExist.getHostedServiceApi().list().toString(), new ListHostedServicesTest().expected().toString()); - } - - public void testListWhenResponseIs404() throws Exception { - - HttpResponse listResponse = HttpResponse.builder().statusCode(404).build(); - - AzureManagementApi apiWhenDontExist = requestSendsResponse( - list, listResponse); - - assertEquals(apiWhenDontExist.getHostedServiceApi().list(), ImmutableSet.of()); - } - - - public void testCreateServiceWithLabelInLocationWhenResponseIs2xx() throws Exception { - HttpRequest create = HttpRequest.builder().method("POST") - .endpoint("https://management.core.windows.net/" + subscriptionId + "/services/hostedservices") - .addHeader("x-ms-version", "2012-03-01") - .payload(payloadFromResourceWithContentType("/create_hostedservice_location.xml", "application/xml")).build(); - - HttpResponse createResponse = HttpResponse.builder() - .addHeader("x-ms-request-id", "171f77920784404db208200702e59227") - .statusCode(201).build(); - - AzureManagementApi apiWhenExist = requestSendsResponse(create, createResponse); - - assertEquals( - apiWhenExist.getHostedServiceApi().createServiceWithLabelInLocation(SERVICE_NAME, "service mine", - "West US"), "171f77920784404db208200702e59227"); - } - - public void testCreateWithOptionalParamsWhenResponseIs2xx() throws Exception { - HttpRequest create = HttpRequest.builder().method("POST") - .endpoint("https://management.core.windows.net/" + subscriptionId + "/services/hostedservices") - .addHeader("x-ms-version", "2012-03-01") - .payload(payloadFromResourceWithContentType("/create_hostedservice_location_options.xml", "application/xml")).build(); - - HttpResponse createResponse = HttpResponse.builder() - .addHeader("x-ms-request-id", "171f77920784404db208200702e59227") - .statusCode(201).build(); - - AzureManagementApi apiWhenExist = requestSendsResponse(create, createResponse); - - assertEquals( - apiWhenExist.getHostedServiceApi().createServiceWithLabelInLocation(SERVICE_NAME, "service mine", - "West US", - description("my description").extendedProperties(ImmutableMap.of("Role", "Production"))), - "171f77920784404db208200702e59227"); - } - - HttpRequest get = HttpRequest.builder().method("GET") - .endpoint("https://management.core.windows.net/" + subscriptionId + "/services/hostedservices/" + SERVICE_NAME) - .addHeader("x-ms-version", "2012-03-01") - .addHeader("Accept", "application/xml").build(); - - public void testGetWhenResponseIs2xx() throws Exception { - HttpResponse getResponse = HttpResponse.builder().statusCode(200) - .payload(payloadFromResourceWithContentType("/hostedservice.xml", "application")).build(); - - AzureManagementApi apiWhenExist = requestSendsResponse(get, getResponse); - - assertEquals(apiWhenExist.getHostedServiceApi().get(SERVICE_NAME).toString(), new GetHostedServiceTest().expected().toString()); - } - - public void testGetWhenResponseIs404() throws Exception { - HttpResponse getResponse = HttpResponse.builder().statusCode(404).build(); - - AzureManagementApi apiWhenDontExist = requestSendsResponse(get, getResponse); - - assertNull(apiWhenDontExist.getHostedServiceApi().get(SERVICE_NAME)); - } - - HttpRequest getDetails = HttpRequest.builder().method("GET") - .endpoint("https://management.core.windows.net/" + subscriptionId + "/services/hostedservices/" + SERVICE_NAME + "?embed-detail=true") - .addHeader("x-ms-version", "2012-03-01") - .addHeader("Accept", "application/xml").build(); - - public void testGetDetailsWhenResponseIs2xx() throws Exception { - HttpResponse getResponse = HttpResponse.builder().statusCode(200) - .payload(payloadFromResourceWithContentType("/hostedservice_details.xml", "application")).build(); - - AzureManagementApi apiWhenExist = requestSendsResponse(getDetails, getResponse); - - assertEquals(apiWhenExist.getHostedServiceApi().getDetails(SERVICE_NAME).toString(), new GetHostedServiceDetailsTest().expected().toString()); - } - - public void testGetDetailsWhenResponseIs404() throws Exception { - HttpResponse getResponse = HttpResponse.builder().statusCode(404).build(); - - AzureManagementApi apiWhenDontExist = requestSendsResponse(getDetails, getResponse); - - assertNull(apiWhenDontExist.getHostedServiceApi().getDetails(SERVICE_NAME)); - } - - HttpRequest delete = HttpRequest.builder().method("DELETE") - .endpoint("https://management.core.windows.net/" + subscriptionId + "/services/hostedservices/" + SERVICE_NAME) - .addHeader("x-ms-version", "2012-03-01") - .build(); - - public void testDeleteWhenResponseIs2xx() throws Exception { - HttpResponse deleteResponse = HttpResponse.builder() - .addHeader("x-ms-request-id", "171f77920784404db208200702e59227") - .statusCode(200).build(); - - AzureManagementApi apiWhenExist = requestSendsResponse(delete, deleteResponse); - - assertEquals(apiWhenExist.getHostedServiceApi().delete(SERVICE_NAME), "171f77920784404db208200702e59227"); - } - - public void testDeleteWhenResponseIs404() throws Exception { - HttpResponse deleteResponse = HttpResponse.builder().statusCode(404).build(); - - AzureManagementApi apiWhenDontExist = requestSendsResponse(delete, deleteResponse); - - assertNull(apiWhenDontExist.getHostedServiceApi().delete(SERVICE_NAME)); - } -} diff --git a/labs/azure-management/src/test/java/org/jclouds/azure/management/features/HostedServiceApiLiveTest.java b/labs/azure-management/src/test/java/org/jclouds/azure/management/features/HostedServiceApiLiveTest.java deleted file mode 100644 index 596cafdc59..0000000000 --- a/labs/azure-management/src/test/java/org/jclouds/azure/management/features/HostedServiceApiLiveTest.java +++ /dev/null @@ -1,176 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.azure.management.features; - -import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.base.Preconditions.checkState; -import static java.util.concurrent.TimeUnit.SECONDS; -import static org.jclouds.util.Predicates2.retry; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotEquals; -import static org.testng.Assert.assertTrue; - -import java.util.Set; -import java.util.logging.Logger; - -import org.jclouds.azure.management.domain.DetailedHostedServiceProperties; -import org.jclouds.azure.management.domain.HostedService; -import org.jclouds.azure.management.domain.HostedService.Status; -import org.jclouds.azure.management.domain.HostedServiceWithDetailedProperties; -import org.jclouds.azure.management.domain.Operation; -import org.jclouds.azure.management.internal.BaseAzureManagementApiLiveTest; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -import com.google.common.base.Predicate; -import com.google.common.collect.Iterables; - -/** - * @author Adrian Cole - */ -@Test(groups = "live", testName = "HostedServiceApiLiveTest") -public class HostedServiceApiLiveTest extends BaseAzureManagementApiLiveTest { - - public static final String HOSTED_SERVICE = (System.getProperty("user.name") + "-jclouds-hostedService") - .toLowerCase(); - - private Predicate operationSucceeded; - private Predicate hostedServiceCreated; - private Predicate hostedServiceGone; - - private String location; - - @BeforeClass(groups = "live") - @Override - public void setupContext() { - super.setupContext(); - // TODO: filter locations on those who have compute - location = Iterables.get(context.getApi().getLocationApi().list(), 0).getName(); - operationSucceeded = retry(new Predicate() { - public boolean apply(String input) { - return context.getApi().getOperationApi().get(input).getStatus() == Operation.Status.SUCCEEDED; - } - }, 600, 5, 5, SECONDS); - hostedServiceCreated = retry(new Predicate() { - public boolean apply(HostedServiceWithDetailedProperties input) { - return api().getDetails(input.getName()).getProperties().getStatus() == Status.CREATED; - } - }, 600, 5, 5, SECONDS); - hostedServiceGone = retry(new Predicate() { - public boolean apply(HostedService input) { - return api().get(input.getName()) == null; - } - }, 600, 5, 5, SECONDS); - } - - private HostedServiceWithDetailedProperties hostedService; - - public void testCreateHostedService() { - - String requestId = api().createServiceWithLabelInLocation(HOSTED_SERVICE, HOSTED_SERVICE, location); - assertTrue(operationSucceeded.apply(requestId), requestId); - Logger.getAnonymousLogger().info("operation succeeded: " + requestId); - - hostedService = api().getDetails(HOSTED_SERVICE); - Logger.getAnonymousLogger().info("created hostedService: " + hostedService); - - assertEquals(hostedService.getName(), HOSTED_SERVICE); - - checkHostedService(hostedService); - - assertTrue(hostedServiceCreated.apply(hostedService), hostedService.toString()); - hostedService = api().getDetails(hostedService.getName()); - Logger.getAnonymousLogger().info("hostedService available: " + hostedService); - - } - - @Test(dependsOnMethods = "testCreateHostedService") - public void testDeleteHostedService() { - String requestId = api().delete(hostedService.getName()); - assertTrue(operationSucceeded.apply(requestId), requestId); - Logger.getAnonymousLogger().info("operation succeeded: " + requestId); - - assertTrue(hostedServiceGone.apply(hostedService), hostedService.toString()); - Logger.getAnonymousLogger().info("hostedService deleted: " + hostedService); - } - - @Override - @AfterClass(groups = "live") - protected void tearDownContext() { - String requestId = api().delete(HOSTED_SERVICE); - if (requestId != null) - operationSucceeded.apply(requestId); - - super.tearDownContext(); - } - - @Test - protected void testList() { - Set response = api().list(); - - for (HostedServiceWithDetailedProperties hostedService : response) { - checkHostedService(hostedService); - } - - if (response.size() > 0) { - HostedService hostedService = response.iterator().next(); - Assert.assertEquals(api().getDetails(hostedService.getName()), hostedService); - } - } - - private void checkHostedService(HostedServiceWithDetailedProperties hostedService) { - checkNotNull(hostedService.getUrl(), "Url cannot be null for a HostedService."); - checkNotNull(hostedService.getName(), "ServiceName cannot be null for HostedService %s", hostedService.getUrl()); - checkNotNull(hostedService.getProperties(), "Properties cannot be null for HostedService %s", - hostedService.getUrl()); - checkProperties(hostedService.getProperties()); - } - - private void checkProperties(DetailedHostedServiceProperties hostedService) { - checkNotNull(hostedService.getDescription(), - "While Description can be null for DetailedHostedServiceProperties, its Optional wrapper cannot: %s", - hostedService); - checkNotNull(hostedService.getLocation(), - "While Location can be null for DetailedHostedServiceProperties, its Optional wrapper cannot: %s", - hostedService); - checkNotNull(hostedService.getAffinityGroup(), - "While AffinityGroup can be null for DetailedHostedServiceProperties, its Optional wrapper cannot: %s", - hostedService); - checkState(hostedService.getLocation().isPresent() || hostedService.getAffinityGroup().isPresent(), - "Location or AffinityGroup must be present for DetailedHostedServiceProperties: %s", hostedService); - checkNotNull(hostedService.getLabel(), "Label cannot be null for HostedService %s", hostedService); - - checkNotNull(hostedService.getStatus(), "Status cannot be null for DetailedHostedServiceProperties: %s", - hostedService); - assertNotEquals(hostedService.getStatus(), Status.UNRECOGNIZED, - "Status cannot be UNRECOGNIZED for DetailedHostedServiceProperties: " + hostedService); - checkNotNull(hostedService.getCreated(), "Created cannot be null for DetailedHostedServiceProperties %s", - hostedService); - checkNotNull(hostedService.getLastModified(), - "LastModified cannot be null for DetailedHostedServiceProperties %s", hostedService); - checkNotNull(hostedService.getExtendedProperties(), - "ExtendedProperties cannot be null for DetailedHostedServiceProperties %s", hostedService); - } - - protected HostedServiceApi api() { - return context.getApi().getHostedServiceApi(); - } -} diff --git a/labs/azure-management/src/test/java/org/jclouds/azure/management/features/LocationApiExpectTest.java b/labs/azure-management/src/test/java/org/jclouds/azure/management/features/LocationApiExpectTest.java deleted file mode 100644 index 6ec2ff50a3..0000000000 --- a/labs/azure-management/src/test/java/org/jclouds/azure/management/features/LocationApiExpectTest.java +++ /dev/null @@ -1,64 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unles required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either expres or implied. See the License for the - * specific language governing permisions and limitations - * under the License. - */ -package org.jclouds.azure.management.features; - -import static org.testng.Assert.assertEquals; - -import org.jclouds.azure.management.AzureManagementApi; -import org.jclouds.azure.management.internal.BaseAzureManagementApiExpectTest; -import org.jclouds.azure.management.parse.ListLocationsTest; -import org.jclouds.http.HttpRequest; -import org.jclouds.http.HttpResponse; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableSet; - -/** - * @author Adrian Cole - */ -@Test(groups = "unit", testName = "LocationApiExpectTest") -public class LocationApiExpectTest extends BaseAzureManagementApiExpectTest { - - HttpRequest list = HttpRequest.builder() - .method("GET") - .endpoint("https://management.core.windows.net/" + subscriptionId + "/locations") - .addHeader("x-ms-version", "2012-03-01") - .addHeader("Accept", "application/xml").build(); - - public void testListWhenResponseIs2xx() throws Exception { - - HttpResponse listResponse = HttpResponse.builder().statusCode(200) - .payload(payloadFromResourceWithContentType("/locations.xml", "application")).build(); - - AzureManagementApi apiWhenExist = requestSendsResponse( - list, listResponse); - - assertEquals(apiWhenExist.getLocationApi().list().toString(), new ListLocationsTest().expected().toString()); - } - - public void testListWhenResponseIs404() throws Exception { - - HttpResponse listResponse = HttpResponse.builder().statusCode(404).build(); - - AzureManagementApi apiWhenDontExist = requestSendsResponse( - list, listResponse); - - assertEquals(apiWhenDontExist.getLocationApi().list(), ImmutableSet.of()); - } -} diff --git a/labs/azure-management/src/test/java/org/jclouds/azure/management/features/LocationApiLiveTest.java b/labs/azure-management/src/test/java/org/jclouds/azure/management/features/LocationApiLiveTest.java deleted file mode 100644 index fb3d810434..0000000000 --- a/labs/azure-management/src/test/java/org/jclouds/azure/management/features/LocationApiLiveTest.java +++ /dev/null @@ -1,66 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.azure.management.features; - -import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.base.Preconditions.checkState; - -import java.util.Set; - -import org.jclouds.azure.management.domain.Location; -import org.jclouds.azure.management.internal.BaseAzureManagementApiLiveTest; -import org.testng.annotations.Test; - -import com.google.common.base.Predicate; -import com.google.common.base.Predicates; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Iterables; - -/** - * @author Adrian Cole - */ -@Test(groups = "live", testName = "LocationApiLiveTest") -public class LocationApiLiveTest extends BaseAzureManagementApiLiveTest { - - @Test - protected void testList() { - Set response = api().list(); - - for (Location location : response) { - checkLocation(location); - } - - } - - protected Predicate knownServices = Predicates.in(ImmutableSet.of("Compute", "Storage", "PersistentVMRole")); - - private void checkLocation(Location location) { - checkNotNull(location.getName(), "Name cannot be null for a Location."); - checkNotNull(location.getDisplayName(), "DisplayName cannot be null for Location %s", location.getName()); - checkNotNull(location.getAvailableServices(), "AvailableServices cannot be null for Location %s", - location.getName()); - checkState(Iterables.all(location.getAvailableServices(), knownServices), - "AvailableServices in Location %s didn't match %s: %s", location.getName(), knownServices, - location.getAvailableServices()); - } - - protected LocationApi api() { - return context.getApi().getLocationApi(); - } -} diff --git a/labs/azure-management/src/test/java/org/jclouds/azure/management/features/OSImageApiExpectTest.java b/labs/azure-management/src/test/java/org/jclouds/azure/management/features/OSImageApiExpectTest.java deleted file mode 100644 index 7431b7e428..0000000000 --- a/labs/azure-management/src/test/java/org/jclouds/azure/management/features/OSImageApiExpectTest.java +++ /dev/null @@ -1,120 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unles required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either expres or implied. See the License for the - * specific language governing permisions and limitations - * under the License. - */ -package org.jclouds.azure.management.features; - -import static org.testng.Assert.assertEquals; - -import java.net.URI; - -import org.jclouds.azure.management.AzureManagementApi; -import org.jclouds.azure.management.domain.OSImageParams; -import org.jclouds.azure.management.domain.OSType; -import org.jclouds.azure.management.internal.BaseAzureManagementApiExpectTest; -import org.jclouds.azure.management.parse.ListOSImagesTest; -import org.jclouds.http.HttpRequest; -import org.jclouds.http.HttpResponse; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableSet; - -/** - * @author Adrian Cole - */ -@Test(groups = "unit", testName = "OSImageApiExpectTest") -public class OSImageApiExpectTest extends BaseAzureManagementApiExpectTest { - - private static final String IMAGE_NAME = "myimage"; - - HttpRequest list = HttpRequest.builder().method("GET") - .endpoint("https://management.core.windows.net/" + subscriptionId + "/services/images") - .addHeader("x-ms-version", "2012-03-01") - .addHeader("Accept", "application/xml").build(); - - public void testListWhenResponseIs2xx() throws Exception { - - HttpResponse listResponse = HttpResponse.builder().statusCode(200) - .payload(payloadFromResourceWithContentType("/images.xml", "application/xml")).build(); - - AzureManagementApi apiWhenExist = requestSendsResponse( - list, listResponse); - - assertEquals(apiWhenExist.getOSImageApi().list().toString(), new ListOSImagesTest().expected().toString()); - } - - public void testListWhenResponseIs404() throws Exception { - - HttpResponse listResponse = HttpResponse.builder().statusCode(404).build(); - - AzureManagementApi apiWhenDontExist = requestSendsResponse( - list, listResponse); - - assertEquals(apiWhenDontExist.getOSImageApi().list(), ImmutableSet.of()); - } - - HttpRequest add = HttpRequest.builder().method("POST") - .endpoint("https://management.core.windows.net/" + subscriptionId + "/services/images") - .addHeader("x-ms-version", "2012-03-01") - .payload(payloadFromResourceWithContentType("/imageparams.xml", "application/xml")).build(); - - public void testAddWhenResponseIs2xx() throws Exception { - HttpResponse addResponse = HttpResponse.builder().statusCode(200).build(); - - AzureManagementApi apiWhenExist = requestSendsResponse(add, addResponse); - - OSImageParams params = OSImageParams.builder().name(IMAGE_NAME).label("foo").os(OSType.LINUX) - .mediaLink(URI.create("http://example.blob.core.windows.net/disks/mydisk.vhd")).build(); - apiWhenExist.getOSImageApi().add(params); - } - - HttpRequest update = HttpRequest.builder().method("PUT") - .endpoint("https://management.core.windows.net/" + subscriptionId + "/services/images/" + IMAGE_NAME) - .addHeader("x-ms-version", "2012-03-01") - .payload(payloadFromResourceWithContentType("/imageparams.xml", "application/xml")).build(); - - public void testUpdateWhenResponseIs2xx() throws Exception { - HttpResponse updateResponse = HttpResponse.builder().statusCode(200).build(); - - AzureManagementApi apiWhenExist = requestSendsResponse(update, updateResponse); - - OSImageParams params = OSImageParams.builder().name(IMAGE_NAME).label("foo").os(OSType.LINUX) - .mediaLink(URI.create("http://example.blob.core.windows.net/disks/mydisk.vhd")).build(); - apiWhenExist.getOSImageApi().update(params); - } - - HttpRequest delete = HttpRequest.builder().method("DELETE") - .endpoint("https://management.core.windows.net/" + subscriptionId + "/services/images/" + IMAGE_NAME) - .addHeader("x-ms-version", "2012-03-01") - .build(); - - public void testDeleteWhenResponseIs2xx() throws Exception { - HttpResponse deleteResponse = HttpResponse.builder().statusCode(200).build(); - - AzureManagementApi apiWhenExist = requestSendsResponse(delete, deleteResponse); - - apiWhenExist.getOSImageApi().delete(IMAGE_NAME); - } - - public void testDeleteWhenResponseIs404() throws Exception { - HttpResponse deleteResponse = HttpResponse.builder().statusCode(404).build(); - - AzureManagementApi apiWhenDontExist = requestSendsResponse(delete, deleteResponse); - - apiWhenDontExist.getOSImageApi().delete(IMAGE_NAME); - } -} diff --git a/labs/azure-management/src/test/java/org/jclouds/azure/management/features/OSImageApiLiveTest.java b/labs/azure-management/src/test/java/org/jclouds/azure/management/features/OSImageApiLiveTest.java deleted file mode 100644 index bd24459cd5..0000000000 --- a/labs/azure-management/src/test/java/org/jclouds/azure/management/features/OSImageApiLiveTest.java +++ /dev/null @@ -1,121 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.azure.management.features; - -import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.collect.Iterables.transform; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertNotEquals; -import static org.testng.Assert.assertTrue; - -import java.util.Set; - -import org.jclouds.azure.management.domain.Location; -import org.jclouds.azure.management.domain.OSImage; -import org.jclouds.azure.management.domain.OSType; -import org.jclouds.azure.management.internal.BaseAzureManagementApiLiveTest; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -import com.google.common.base.Function; -import com.google.common.collect.ImmutableSet; - -/** - * @author Adrian Cole - */ -@Test(groups = "live", testName = "OSImageApiLiveTest") -public class OSImageApiLiveTest extends BaseAzureManagementApiLiveTest { - - private ImmutableSet locations; - - @BeforeClass(groups = { "integration", "live" }) - public void setupContext() { - super.initializeContext(); - - locations = ImmutableSet.copyOf(transform(context.getApi().getLocationApi().list(), - new Function() { - @Override - public String apply(Location in) { - return in.getName(); - } - })); - } - - @Test - protected void testList() { - Set response = api().list(); - - for (OSImage image : response) { - checkOSImage(image); - } - } - - private void checkOSImage(OSImage image) { - checkNotNull(image.getLabel(), "Label cannot be null for OSImage %s", image); - checkNotNull(image.getName(), "Name cannot be null for OSImage %s", image.getLabel()); - checkNotNull(image.getOS(), "OS cannot be null for OSImage: %s", image); - assertNotEquals(image.getOS(), OSType.UNRECOGNIZED, "Status cannot be UNRECOGNIZED for OSImage: " + image); - - checkNotNull(image.getCategory(), "While Category can be null for OSImage, its Optional wrapper cannot: %s", - image); - if (image.getCategory().isPresent()) - assertNotEquals("", image.getCategory().get().trim(), "Invalid Category: " + image.toString()); - - checkNotNull(image.getLogicalSizeInGB(), - "While LogicalSizeInGB can be null for OSImage, its Optional wrapper cannot: %s", image); - - if (image.getLogicalSizeInGB().isPresent()) - assertTrue(image.getLogicalSizeInGB().get() > 0, - "LogicalSizeInGB should be positive, if set" + image.toString()); - - checkNotNull(image.getMediaLink(), "While MediaLink can be null for OSImage, its Optional wrapper cannot: %s", - image); - - if (image.getMediaLink().isPresent()) - assertTrue(ImmutableSet.of("http", "https").contains(image.getMediaLink().get().getScheme()), - "MediaLink should be an http(s) url" + image.toString()); - - checkNotNull(image.getDescription(), - "While Description can be null for OSImage, its Optional wrapper cannot: %s", image); - - checkNotNull(image.getLocation(), "While Location can be null for OSImage, its Optional wrapper cannot: %s", - image); - if (image.getLocation().isPresent()) { - assertTrue(locations.contains(image.getLocation().get()), - "Location not in " + locations + " :" + image.toString()); - } - - checkNotNull(image.getEula(), "While Eula can be null for OSImage, its Optional wrapper cannot: %s", - image); - if (image.getEula().isPresent()) { - assertTrue(ImmutableSet.of("http", "https").contains(image.getEula().get().getScheme()), - "Eula should be an http(s) url" + image.toString()); - } - - checkNotNull(image.getAffinityGroup(), - "While AffinityGroup can be null for OSImage, its Optional wrapper cannot: %s", image); - if (image.getAffinityGroup().isPresent()) { - // TODO: list getAffinityGroups and check if there - } - } - - protected OSImageApi api() { - return context.getApi().getOSImageApi(); - } -} diff --git a/labs/azure-management/src/test/java/org/jclouds/azure/management/features/OperationApiExpectTest.java b/labs/azure-management/src/test/java/org/jclouds/azure/management/features/OperationApiExpectTest.java deleted file mode 100644 index f9ab43e783..0000000000 --- a/labs/azure-management/src/test/java/org/jclouds/azure/management/features/OperationApiExpectTest.java +++ /dev/null @@ -1,60 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unles required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either expres or implied. See the License for the - * specific language governing permisions and limitations - * under the License. - */ -package org.jclouds.azure.management.features; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNull; - -import org.jclouds.azure.management.AzureManagementApi; -import org.jclouds.azure.management.internal.BaseAzureManagementApiExpectTest; -import org.jclouds.azure.management.parse.GetOperationTest; -import org.jclouds.http.HttpRequest; -import org.jclouds.http.HttpResponse; -import org.testng.annotations.Test; - -/** - * @author Adrian Cole - */ -@Test(groups = "unit", testName = "OperationApiExpectTest") -public class OperationApiExpectTest extends BaseAzureManagementApiExpectTest { - private static final String REQUEST_ID ="request-id"; - - HttpRequest get = HttpRequest.builder().method("GET") - .endpoint("https://management.core.windows.net/" + subscriptionId + "/operations/" + REQUEST_ID) - .addHeader("x-ms-version", "2012-03-01") - .addHeader("Accept", "application/xml").build(); - - public void testGetWhenResponseIs2xx() throws Exception { - HttpResponse getResponse = HttpResponse.builder().statusCode(200) - .payload(payloadFromResourceWithContentType("/operation.xml", "application")).build(); - - AzureManagementApi apiWhenExist = requestSendsResponse(get, getResponse); - - assertEquals(apiWhenExist.getOperationApi().get(REQUEST_ID).toString(), new GetOperationTest().expected().toString()); - } - - public void testGetWhenResponseIs404() throws Exception { - HttpResponse getResponse = HttpResponse.builder().statusCode(404).build(); - - AzureManagementApi apiWhenDontExist = requestSendsResponse(get, getResponse); - - assertNull(apiWhenDontExist.getOperationApi().get(REQUEST_ID)); - } - -} diff --git a/labs/azure-management/src/test/java/org/jclouds/azure/management/features/RoleApiExpectTest.java b/labs/azure-management/src/test/java/org/jclouds/azure/management/features/RoleApiExpectTest.java deleted file mode 100644 index 8626b88e93..0000000000 --- a/labs/azure-management/src/test/java/org/jclouds/azure/management/features/RoleApiExpectTest.java +++ /dev/null @@ -1,178 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unles required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either expres or implied. See the License for the - * specific language governing permisions and limitations - * under the License. - */ -package org.jclouds.azure.management.features; - -import org.jclouds.azure.management.AzureManagementApi; -import org.jclouds.azure.management.domain.DeploymentParams; -import org.jclouds.azure.management.domain.OSType; -import org.jclouds.azure.management.domain.RoleSize; -import org.jclouds.azure.management.internal.BaseAzureManagementApiExpectTest; -import org.jclouds.http.HttpRequest; -import org.jclouds.http.HttpResponse; -import org.testng.annotations.Test; - -/** - * @author Gérald Pereira - */ -@Test(groups = "unit", testName = "RoleApiExpectTest") -public class RoleApiExpectTest extends BaseAzureManagementApiExpectTest { - - private static final String DEPLOYMENT_NAME = "mydeployment"; - private static final String IMAGE_NAME = "myImageName"; - private static final String IMAGE_LABEL = "myImageLabel"; - - HttpRequest add = HttpRequest - .builder() - .method("POST") - .endpoint( - "https://management.core.windows.net/" + subscriptionId - + "/services/hostedservices/" + DEPLOYMENT_NAME - + "/deployments") - .addHeader("x-ms-version", "2012-03-01") - .addHeader("Accept", "application/atom+xml") - .payload( - payloadFromResourceWithContentType("/deploymentparams.xml", - "application/atom+xml")).build(); - - public void testAddWhenResponseIs2xx() throws Exception { - HttpResponse addResponse = HttpResponse.builder().statusCode(200) - .addHeader("x-ms-request-id", "fakerequestid").build(); - - AzureManagementApi apiWhenExist = requestSendsResponse(add, addResponse); - DeploymentParams params = DeploymentParams - .builder() - .osType(OSType.LINUX) - .name(DEPLOYMENT_NAME) - .username("username") - .password("testpwd") - .size(RoleSize.MEDIUM) - .sourceImageName( - "OpenLogic__OpenLogic-CentOS-62-20120531-en-us-30GB.vhd") - .storageAccount("portalvhds0g7xhnq2x7t21").build(); - - apiWhenExist.getRoleApi().createDeployment(DEPLOYMENT_NAME, params); - } - - HttpRequest start = HttpRequest - .builder() - .method("POST") - .endpoint( - "https://management.core.windows.net/" + subscriptionId - + "/services/hostedservices/" + DEPLOYMENT_NAME - + "/deployments/" + DEPLOYMENT_NAME - + "/roleInstances/" + DEPLOYMENT_NAME - + "/Operations") - .addHeader("x-ms-version", "2012-03-01") - .addHeader("Accept", "application/atom+xml") - .payload( - payloadFromResourceWithContentType("/startrolepayload.xml", - "application/atom+xml")).build(); - - public void testStartWhenResponseIs2xx() throws Exception { - HttpResponse addResponse = HttpResponse.builder().statusCode(200) - .addHeader("x-ms-request-id", "fakerequestid").build(); - - AzureManagementApi apiWhenExist = requestSendsResponse(start, - addResponse); - - apiWhenExist.getRoleApi().startRole(DEPLOYMENT_NAME, DEPLOYMENT_NAME, - DEPLOYMENT_NAME); - } - - HttpRequest shutdown = HttpRequest - .builder() - .method("POST") - .endpoint( - "https://management.core.windows.net/" + subscriptionId - + "/services/hostedservices/" + DEPLOYMENT_NAME - + "/deployments/" + DEPLOYMENT_NAME - + "/roleInstances/" + DEPLOYMENT_NAME - + "/Operations") - .addHeader("x-ms-version", "2012-03-01") - .addHeader("Accept", "application/atom+xml") - .payload( - payloadFromResourceWithContentType( - "/shutdownrolepayload.xml", "application/atom+xml")) - .build(); - - public void testShutdownWhenResponseIs2xx() throws Exception { - HttpResponse addResponse = HttpResponse.builder().statusCode(200) - .addHeader("x-ms-request-id", "fakerequestid").build(); - - AzureManagementApi apiWhenExist = requestSendsResponse(shutdown, - addResponse); - - apiWhenExist.getRoleApi().shutdownRole(DEPLOYMENT_NAME, - DEPLOYMENT_NAME, DEPLOYMENT_NAME); - } - - HttpRequest restart = HttpRequest - .builder() - .method("POST") - .endpoint( - "https://management.core.windows.net/" + subscriptionId - + "/services/hostedservices/" + DEPLOYMENT_NAME - + "/deployments/" + DEPLOYMENT_NAME - + "/roleInstances/" + DEPLOYMENT_NAME - + "/Operations") - .addHeader("x-ms-version", "2012-03-01") - .addHeader("Accept", "application/atom+xml") - .payload( - payloadFromResourceWithContentType( - "/restartrolepayload.xml", "application/atom+xml")) - .build(); - - public void testRestartWhenResponseIs2xx() throws Exception { - HttpResponse addResponse = HttpResponse.builder().statusCode(200) - .addHeader("x-ms-request-id", "fakerequestid").build(); - - AzureManagementApi apiWhenExist = requestSendsResponse(restart, - addResponse); - - apiWhenExist.getRoleApi().restartRole(DEPLOYMENT_NAME, DEPLOYMENT_NAME, - DEPLOYMENT_NAME); - } - - HttpRequest capture = HttpRequest - .builder() - .method("POST") - .endpoint( - "https://management.core.windows.net/" + subscriptionId - + "/services/hostedservices/" + DEPLOYMENT_NAME - + "/deployments/" + DEPLOYMENT_NAME - + "/roleInstances/" + DEPLOYMENT_NAME - + "/Operations") - .addHeader("x-ms-version", "2012-03-01") - .addHeader("Accept", "application/atom+xml") - .payload( - payloadFromResourceWithContentType( - "/capturerolepayload.xml", "application/atom+xml")) - .build(); - - public void testCaptureWhenResponseIs2xx() throws Exception { - HttpResponse addResponse = HttpResponse.builder().statusCode(200) - .addHeader("x-ms-request-id", "fakerequestid").build(); - - AzureManagementApi apiWhenExist = requestSendsResponse(capture, - addResponse); - - apiWhenExist.getRoleApi().captureRole(DEPLOYMENT_NAME, DEPLOYMENT_NAME, - DEPLOYMENT_NAME, IMAGE_NAME, IMAGE_LABEL); - } -} diff --git a/labs/azure-management/src/test/java/org/jclouds/azure/management/internal/BaseAzureManagementApiExpectTest.java b/labs/azure-management/src/test/java/org/jclouds/azure/management/internal/BaseAzureManagementApiExpectTest.java deleted file mode 100644 index b5522f4726..0000000000 --- a/labs/azure-management/src/test/java/org/jclouds/azure/management/internal/BaseAzureManagementApiExpectTest.java +++ /dev/null @@ -1,29 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.azure.management.internal; - -import org.jclouds.azure.management.AzureManagementApi; - -/** - * - * @author Adrian Cole - */ -public class BaseAzureManagementApiExpectTest extends BaseAzureManagementExpectTest { - -} diff --git a/labs/azure-management/src/test/java/org/jclouds/azure/management/internal/BaseAzureManagementApiLiveTest.java b/labs/azure-management/src/test/java/org/jclouds/azure/management/internal/BaseAzureManagementApiLiveTest.java deleted file mode 100644 index 649c28a4b6..0000000000 --- a/labs/azure-management/src/test/java/org/jclouds/azure/management/internal/BaseAzureManagementApiLiveTest.java +++ /dev/null @@ -1,57 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.azure.management.internal; - -import java.util.Properties; - -import org.jclouds.apis.BaseContextLiveTest; -import org.jclouds.azure.management.AzureManagementApi; -import org.jclouds.azure.management.AzureManagementApiMetadata; -import org.jclouds.azure.management.AzureManagementAsyncApi; -import org.jclouds.azure.management.config.AzureManagementProperties; -import org.jclouds.rest.RestContext; - -import com.google.common.reflect.TypeToken; - -/** - * - * @author Adrian Cole - */ -public class BaseAzureManagementApiLiveTest extends - BaseContextLiveTest> { - - protected String subscriptionId; - - public BaseAzureManagementApiLiveTest() { - provider = "azure-management"; - } - - @Override - protected Properties setupProperties() { - Properties props = super.setupProperties(); - subscriptionId = setIfTestSystemPropertyPresent(props, AzureManagementProperties.SUBSCRIPTION_ID); - return props; - } - - @Override - protected TypeToken> contextType() { - return AzureManagementApiMetadata.CONTEXT_TOKEN; - } - -} diff --git a/labs/azure-management/src/test/java/org/jclouds/azure/management/internal/BaseAzureManagementAsyncApiExpectTest.java b/labs/azure-management/src/test/java/org/jclouds/azure/management/internal/BaseAzureManagementAsyncApiExpectTest.java deleted file mode 100644 index f939374ef3..0000000000 --- a/labs/azure-management/src/test/java/org/jclouds/azure/management/internal/BaseAzureManagementAsyncApiExpectTest.java +++ /dev/null @@ -1,38 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.azure.management.internal; - -import java.util.Properties; - -import org.jclouds.azure.management.AzureManagementAsyncApi; -import org.jclouds.http.HttpRequest; -import org.jclouds.http.HttpResponse; - -import com.google.common.base.Function; -import com.google.inject.Module; - -/** - * - * @author Adrian Cole - */ -public class BaseAzureManagementAsyncApiExpectTest extends BaseAzureManagementExpectTest { - public AzureManagementAsyncApi createApi(Function fn, Module module, Properties props) { - return createInjector(fn, module, props).getInstance(AzureManagementAsyncApi.class); - } -} diff --git a/labs/azure-management/src/test/java/org/jclouds/azure/management/internal/BaseAzureManagementExpectTest.java b/labs/azure-management/src/test/java/org/jclouds/azure/management/internal/BaseAzureManagementExpectTest.java deleted file mode 100644 index a6112cb58b..0000000000 --- a/labs/azure-management/src/test/java/org/jclouds/azure/management/internal/BaseAzureManagementExpectTest.java +++ /dev/null @@ -1,61 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.azure.management.internal; - -import java.util.Properties; - -import org.jclouds.azure.management.config.AzureManagementProperties; -import org.jclouds.azure.management.config.AzureManagementRestClientModule; -import org.jclouds.rest.ConfiguresRestClient; -import org.jclouds.rest.internal.BaseRestApiExpectTest; - -import com.google.inject.Module; - -/** - * - * @author Adrian Cole - */ -public class BaseAzureManagementExpectTest extends BaseRestApiExpectTest { - protected String subscriptionId = "a01234b5c-d6e7-8f9g-h0123-4567i890j1k"; - - public BaseAzureManagementExpectTest() { - provider = "azure-management"; - // self-signed dummy cert: - // keytool -genkey -alias test -keyalg RSA -keysize 1024 -validity 5475 -dname "CN=localhost" -keystore azure-test.p12 -storepass azurepass -storetype pkcs12 - identity = this.getClass().getResource("/azure-test.p12").getFile(); - credential = "azurepass"; - } - - @Override - protected Properties setupProperties() { - Properties props = super.setupProperties(); - props.put(AzureManagementProperties.SUBSCRIPTION_ID, subscriptionId); - return props; - } - - @ConfiguresRestClient - private static final class TestAzureManagementRestClientModule extends AzureManagementRestClientModule { - - } - - @Override - protected Module createModule() { - return new TestAzureManagementRestClientModule(); - } -} diff --git a/labs/azure-management/src/test/java/org/jclouds/azure/management/parse/ErrorTest.java b/labs/azure-management/src/test/java/org/jclouds/azure/management/parse/ErrorTest.java deleted file mode 100644 index a36c1dca76..0000000000 --- a/labs/azure-management/src/test/java/org/jclouds/azure/management/parse/ErrorTest.java +++ /dev/null @@ -1,57 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.azure.management.parse; - -import static org.testng.Assert.assertEquals; - -import java.io.InputStream; - -import org.jclouds.azure.management.domain.Error; -import org.jclouds.azure.management.domain.Error.Code; -import org.jclouds.azure.management.xml.ErrorHandler; -import org.jclouds.http.functions.BaseHandlerTest; -import org.testng.annotations.Test; - -/** - * @author Adrian Cole - */ -// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire -@Test(groups = "unit", testName = "ErrorTest") -public class ErrorTest extends BaseHandlerTest { - - public void test() { - InputStream is = getClass().getResourceAsStream("/error.xml"); - - Error expected = expected(); - - ErrorHandler handler = injector.getInstance(ErrorHandler.class); - Error result = factory.create(handler).parse(is); - - assertEquals(result.toString(), expected.toString()); - - } - - public Error expected() { - return Error.builder() - .rawCode("MissingOrInvalidRequiredQueryParameter") - .code(Code.MISSING_OR_INVALID_REQUIRED_QUERY_PARAMETER) - .message("A required query parameter was not specified for this request or was specified incorrectly.") - .build(); - } -} diff --git a/labs/azure-management/src/test/java/org/jclouds/azure/management/parse/GetDeploymentTest.java b/labs/azure-management/src/test/java/org/jclouds/azure/management/parse/GetDeploymentTest.java deleted file mode 100644 index 5380203b62..0000000000 --- a/labs/azure-management/src/test/java/org/jclouds/azure/management/parse/GetDeploymentTest.java +++ /dev/null @@ -1,70 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.azure.management.parse; - -import static org.testng.Assert.assertEquals; - -import java.io.InputStream; -import java.net.URI; - -import org.jclouds.azure.management.domain.Deployment; -import org.jclouds.azure.management.domain.DeploymentSlot; -import org.jclouds.azure.management.domain.DeploymentStatus; -import org.jclouds.azure.management.domain.InstanceStatus; -import org.jclouds.azure.management.domain.RoleSize; -import org.jclouds.azure.management.xml.DeploymentHandler; -import org.jclouds.http.functions.BaseHandlerTest; -import org.testng.annotations.Test; - -/** - * @author Gérald Pereira - */ -// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire -@Test(groups = "unit", testName = "GetDeploymentTest") -public class GetDeploymentTest extends BaseHandlerTest { - - public void test() { - InputStream is = getClass().getResourceAsStream("/deployment.xml"); - - Deployment expected = expected(); - - DeploymentHandler handler = injector.getInstance(DeploymentHandler.class); - Deployment result = factory.create(handler).parse(is); - - assertEquals(result.toString(), expected.toString()); - - } - - public Deployment expected() { - return Deployment.builder() - .deploymentName("neotysss") - .deploymentSlot(DeploymentSlot.PRODUCTION) - .deploymentStatus(DeploymentStatus.RUNNING) - .deploymentLabel("neotysss") - .deploymentURL(URI.create("http://neotysss.cloudapp.net/")) - .roleName("neotysss") - .instanceName("neotysss") - .instanceStatus(InstanceStatus.READY_ROLE) - .instanceSize(RoleSize.MEDIUM) - .privateIpAddress("10.59.244.162") - .publicIpAddress("168.63.27.148") - .build(); - } - -} diff --git a/labs/azure-management/src/test/java/org/jclouds/azure/management/parse/GetHostedServiceDetailsTest.java b/labs/azure-management/src/test/java/org/jclouds/azure/management/parse/GetHostedServiceDetailsTest.java deleted file mode 100644 index 2a076da973..0000000000 --- a/labs/azure-management/src/test/java/org/jclouds/azure/management/parse/GetHostedServiceDetailsTest.java +++ /dev/null @@ -1,72 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.azure.management.parse; - -import static org.testng.Assert.assertEquals; - -import java.io.InputStream; -import java.net.URI; - -import org.jclouds.azure.management.domain.DetailedHostedServiceProperties; -import org.jclouds.azure.management.domain.HostedService; -import org.jclouds.azure.management.domain.HostedService.Status; -import org.jclouds.azure.management.domain.HostedServiceWithDetailedProperties; -import org.jclouds.azure.management.xml.HostedServiceWithDetailedPropertiesHandler; -import org.jclouds.date.DateService; -import org.jclouds.date.internal.SimpleDateFormatDateService; -import org.jclouds.http.functions.BaseHandlerTest; -import org.testng.annotations.Test; - -/** - * @author Adrian Cole - */ -// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire -@Test(groups = "unit", testName = "DetailedHostedServiceProperties") -public class GetHostedServiceDetailsTest extends BaseHandlerTest { - - public void test() { - InputStream is = getClass().getResourceAsStream("/hostedservice_details.xml"); - - HostedService expected = expected(); - - HostedServiceWithDetailedPropertiesHandler handler = injector.getInstance(HostedServiceWithDetailedPropertiesHandler.class); - HostedServiceWithDetailedProperties result = HostedServiceWithDetailedProperties.class.cast(factory.create(handler).parse(is)); - - assertEquals(result.toString(), expected.toString()); - - } - - protected final DateService dateService = new SimpleDateFormatDateService(); - - public HostedServiceWithDetailedProperties expected() { - return HostedServiceWithDetailedProperties.builder() - .url(URI.create("https://management.core.windows.net/eb0347c3-68d4-4550-9b39-5e7e0f92f7db/services/hostedservices/neotys")) - .name("neotys") - .properties(DetailedHostedServiceProperties.builder() - .description("Implicitly created hosted service2012-08-06 14:55") - .location("West Europe") - .label("neotys") - .rawStatus("Created") - .status(Status.CREATED) - .created(dateService.iso8601SecondsDateParse("2012-08-06T14:55:17Z")) - .lastModified(dateService.iso8601SecondsDateParse("2012-08-06T15:50:34Z")) - .build()) - .build(); - } -} diff --git a/labs/azure-management/src/test/java/org/jclouds/azure/management/parse/GetHostedServiceTest.java b/labs/azure-management/src/test/java/org/jclouds/azure/management/parse/GetHostedServiceTest.java deleted file mode 100644 index 9dc835a077..0000000000 --- a/labs/azure-management/src/test/java/org/jclouds/azure/management/parse/GetHostedServiceTest.java +++ /dev/null @@ -1,62 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.azure.management.parse; - -import static org.testng.Assert.assertEquals; - -import java.io.InputStream; -import java.net.URI; - -import org.jclouds.azure.management.domain.HostedService; -import org.jclouds.azure.management.domain.HostedServiceProperties; -import org.jclouds.azure.management.xml.HostedServiceHandler; -import org.jclouds.http.functions.BaseHandlerTest; -import org.testng.annotations.Test; - -/** - * @author Adrian Cole - */ -// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire -@Test(groups = "unit", testName = "GetHostedServiceTest") -public class GetHostedServiceTest extends BaseHandlerTest { - - public void test() { - InputStream is = getClass().getResourceAsStream("/hostedservice.xml"); - - HostedService expected = expected(); - - HostedServiceHandler handler = injector.getInstance(HostedServiceHandler.class); - HostedService result = factory.create(handler).parse(is); - - assertEquals(result.toString(), expected.toString()); - - } - - public HostedService expected() { - return HostedService.builder() - .url(URI.create("https://management.core.windows.net/eb0347c3-68d4-4550-9b39-5e7e0f92f7db/services/hostedservices/neotys")) - .name("neotys") - .properties(HostedServiceProperties.builder() - .description("Implicitly created hosted service2012-08-06 14:55") - .location("West Europe") - .label("neotys") - .build()) - .build(); - } -} diff --git a/labs/azure-management/src/test/java/org/jclouds/azure/management/parse/GetOperationTest.java b/labs/azure-management/src/test/java/org/jclouds/azure/management/parse/GetOperationTest.java deleted file mode 100644 index d0bcc76ef3..0000000000 --- a/labs/azure-management/src/test/java/org/jclouds/azure/management/parse/GetOperationTest.java +++ /dev/null @@ -1,65 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.azure.management.parse; - -import static org.testng.Assert.assertEquals; - -import java.io.InputStream; - -import org.jclouds.azure.management.domain.Error; -import org.jclouds.azure.management.domain.Error.Code; -import org.jclouds.azure.management.domain.Operation; -import org.jclouds.azure.management.domain.Operation.Status; -import org.jclouds.azure.management.xml.OperationHandler; -import org.jclouds.http.functions.BaseHandlerTest; -import org.testng.annotations.Test; - -/** - * @author Adrian Cole - */ -// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire -@Test(groups = "unit", testName = "GetOperationTest") -public class GetOperationTest extends BaseHandlerTest { - - public void test() { - InputStream is = getClass().getResourceAsStream("/operation.xml"); - - Operation expected = expected(); - - OperationHandler handler = injector.getInstance(OperationHandler.class); - Operation result = factory.create(handler).parse(is); - - assertEquals(result.toString(), expected.toString()); - - } - - public Operation expected() { - return Operation.builder() - .id("request-id") - .rawStatus("Failed") - .status(Status.FAILED) - .httpStatusCode(400) - .error(Error.builder() - .rawCode("MissingOrInvalidRequiredQueryParameter") - .code(Code.MISSING_OR_INVALID_REQUIRED_QUERY_PARAMETER) - .message("A required query parameter was not specified for this request or was specified incorrectly.") - .build()) - .build(); - } -} diff --git a/labs/azure-management/src/test/java/org/jclouds/azure/management/parse/ListDisksTest.java b/labs/azure-management/src/test/java/org/jclouds/azure/management/parse/ListDisksTest.java deleted file mode 100644 index 2a843110f1..0000000000 --- a/labs/azure-management/src/test/java/org/jclouds/azure/management/parse/ListDisksTest.java +++ /dev/null @@ -1,78 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.azure.management.parse; - -import static org.testng.Assert.assertEquals; - -import java.io.InputStream; -import java.net.URI; -import java.util.Set; - -import org.jclouds.azure.management.domain.Disk; -import org.jclouds.azure.management.domain.Disk.Attachment; -import org.jclouds.azure.management.domain.OSType; -import org.jclouds.azure.management.xml.ListDisksHandler; -import org.jclouds.http.functions.BaseHandlerTest; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableSet; - -/** - * @author Gérald Pereira - */ -// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire -@Test(groups = "unit", testName = "ListDisksTest") -public class ListDisksTest extends BaseHandlerTest { - - public void test() { - InputStream is = getClass().getResourceAsStream("/disks.xml"); - - Set expected = expected(); - - ListDisksHandler handler = injector.getInstance(ListDisksHandler.class); - Set result = factory.create(handler).parse(is); - - assertEquals(result.toString(), expected.toString()); - - } - - public Set expected() { - - return ImmutableSet.builder() - .add(Disk.builder() - .os(OSType.LINUX) - .location("West Europe") - .logicalSizeInGB(30) - .mediaLink(URI.create("http://neotysbucket1.blob.core.windows.net/vhds/testimage2-testimage2-2012-08-17.vhd")) - .name("testimage2-testimage2-0-20120817095145") - .sourceImage("OpenLogic__OpenLogic-CentOS-62-20120531-en-us-30GB.vhd") - .build()) - .add(Disk.builder() - .attachedTo(Attachment.builder().deployment("neotysss").hostedService("neotysss").role("neotysss").build()) - .os(OSType.WINDOWS) - .location("West Europe") - .logicalSizeInGB(30) - .mediaLink(URI.create("http://portalvhds0g7xhnq2x7t21.blob.core.windows.net/disks/neotysss/MSFT__Win2K8R2SP1-120612-1520-121206-01-en-us-30GB.vhd")) - .name("neotysss-neotysss-0-20120824091357") - .sourceImage("MSFT__Win2K8R2SP1-120612-1520-121206-01-en-us-30GB.vhd") - .build()) - .build(); - } - -} diff --git a/labs/azure-management/src/test/java/org/jclouds/azure/management/parse/ListHostedServicesTest.java b/labs/azure-management/src/test/java/org/jclouds/azure/management/parse/ListHostedServicesTest.java deleted file mode 100644 index e827862fae..0000000000 --- a/labs/azure-management/src/test/java/org/jclouds/azure/management/parse/ListHostedServicesTest.java +++ /dev/null @@ -1,87 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.azure.management.parse; - -import static org.testng.Assert.assertEquals; - -import java.io.InputStream; -import java.net.URI; -import java.util.Set; - -import org.jclouds.azure.management.domain.DetailedHostedServiceProperties; -import org.jclouds.azure.management.domain.HostedService.Status; -import org.jclouds.azure.management.domain.HostedServiceWithDetailedProperties; -import org.jclouds.azure.management.xml.ListHostedServicesHandler; -import org.jclouds.date.DateService; -import org.jclouds.date.internal.SimpleDateFormatDateService; -import org.jclouds.http.functions.BaseHandlerTest; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableSet; - -/** - * @author Adrian Cole - */ -// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire -@Test(groups = "unit", testName = "ListHostedServicesTest") -public class ListHostedServicesTest extends BaseHandlerTest { - - public void test() { - InputStream is = getClass().getResourceAsStream("/hostedservices.xml"); - - Set expected = expected(); - - ListHostedServicesHandler handler = injector.getInstance(ListHostedServicesHandler.class); - Set result = factory.create(handler).parse(is); - - assertEquals(result.toString(), expected.toString()); - - } - - protected final DateService dateService = new SimpleDateFormatDateService(); - - public Set expected() { - return ImmutableSet.builder() - .add(HostedServiceWithDetailedProperties.builder() - .url(URI.create("https://management.core.windows.net/eb0347c3-68d4-4550-9b39-5e7e0f92f7db/services/hostedservices/neotys")) - .name("neotys") - .properties(DetailedHostedServiceProperties.builder() - .description("Implicitly created hosted service2012-08-06 14:55") - .location("West Europe") - .label("neotys") - .rawStatus("Created") - .status(Status.CREATED) - .created(dateService.iso8601SecondsDateParse("2012-08-06T14:55:17Z")) - .lastModified(dateService.iso8601SecondsDateParse("2012-08-06T15:50:34Z")) - .build()) - .build()) - .add(HostedServiceWithDetailedProperties.builder() - .url(URI.create("https://management.core.windows.net/eb0347c3-68d4-4550-9b39-5e7e0f92f7db/services/hostedservices/neotys3")) - .name("neotys3") - .properties(DetailedHostedServiceProperties.builder() - .location("West Europe") - .label("neotys3") - .rawStatus("Created") - .status(Status.CREATED) - .created(dateService.iso8601SecondsDateParse("2012-08-07T09:00:02Z")) - .lastModified(dateService.iso8601SecondsDateParse("2012-08-07T09:00:02Z")) - .build()) - .build()).build(); - } -} diff --git a/labs/azure-management/src/test/java/org/jclouds/azure/management/parse/ListLocationsTest.java b/labs/azure-management/src/test/java/org/jclouds/azure/management/parse/ListLocationsTest.java deleted file mode 100644 index b8c04f5d0f..0000000000 --- a/labs/azure-management/src/test/java/org/jclouds/azure/management/parse/ListLocationsTest.java +++ /dev/null @@ -1,87 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.azure.management.parse; - -import static org.testng.Assert.assertEquals; - -import java.io.InputStream; -import java.util.Set; - -import org.jclouds.azure.management.domain.Location; -import org.jclouds.azure.management.xml.ListLocationsHandler; -import org.jclouds.http.functions.BaseHandlerTest; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableSet; - -/** - * @author Adrian Cole - */ -// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire -@Test(groups = "unit", testName = "LocationsTest") -public class ListLocationsTest extends BaseHandlerTest { - - public void test() { - InputStream is = getClass().getResourceAsStream("/locations.xml"); - - Set expected = expected(); - - ListLocationsHandler handler = injector.getInstance(ListLocationsHandler.class); - Set result = factory.create(handler).parse(is); - - assertEquals(result.toString(), expected.toString()); - - } - - public Set expected() { - Set availableServices = ImmutableSet.of("Compute", "Storage","PersistentVMRole"); - return ImmutableSet.builder() - .add(Location.builder() - .name("West US") - .displayName("West US") - .availableServices(availableServices) - .build()) - .add(Location.builder() - .name("East US") - .displayName("East US") - .availableServices(availableServices) - .build()) - .add(Location.builder() - .name("East Asia") - .displayName("East Asia") - .availableServices(availableServices) - .build()) - .add(Location.builder() - .name("Southeast Asia") - .displayName("Southeast Asia") - .availableServices(availableServices) - .build()) - .add(Location.builder() - .name("North Europe") - .displayName("North Europe") - .availableServices(availableServices) - .build()) - .add(Location.builder() - .name("West Europe") - .displayName("West Europe") - .availableServices(availableServices) - .build()).build(); - } - -} diff --git a/labs/azure-management/src/test/java/org/jclouds/azure/management/parse/ListOSImagesTest.java b/labs/azure-management/src/test/java/org/jclouds/azure/management/parse/ListOSImagesTest.java deleted file mode 100644 index 7bc3aaf3d0..0000000000 --- a/labs/azure-management/src/test/java/org/jclouds/azure/management/parse/ListOSImagesTest.java +++ /dev/null @@ -1,127 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.azure.management.parse; - -import static org.testng.Assert.assertEquals; - -import java.io.InputStream; -import java.net.URI; -import java.util.Set; - -import org.jclouds.azure.management.domain.OSImage; -import org.jclouds.azure.management.domain.OSType; -import org.jclouds.azure.management.xml.ListOSImagesHandler; -import org.jclouds.http.functions.BaseHandlerTest; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableSet; - -/** - * @author Adrian Cole - */ -// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire -@Test(groups = "unit", testName = "ListOSImagesTest") -public class ListOSImagesTest extends BaseHandlerTest { - - public void test() { - InputStream is = getClass().getResourceAsStream("/images.xml"); - - Set expected = expected(); - - ListOSImagesHandler handler = injector.getInstance(ListOSImagesHandler.class); - Set result = factory.create(handler).parse(is); - - assertEquals(result.toString(), expected.toString()); - - } - - public Set expected() { - return ImmutableSet.builder() - .add(OSImage.builder() - .category("Canonical") - .label("Ubuntu Server 12.04 LTS") - .logicalSizeInGB(30) - .name("CANONICAL__Canonical-Ubuntu-12-04-amd64-server-20120528.1.3-en-us-30GB.vhd") - .os(OSType.LINUX) - .eula(URI.create("http://www.ubuntu.com/project/about-ubuntu/licensing")) - .description("Ubuntu Server 12.04 LTS amd64 20120528 Cloud Image") - .build()) - .add(OSImage.builder() - .category("Microsoft") - .label("Windows Server 2008 R2 SP1, June 2012") - .logicalSizeInGB(30) - .name("MSFT__Win2K8R2SP1-120612-1520-121206-01-en-us-30GB.vhd") - .os(OSType.WINDOWS) - .description("Windows Server 2008 R2 is a multi-purpose server.") - .build()) - .add(OSImage.builder() - .category("Microsoft") - .label("Microsoft SQL Server 2012 Evaluation Edition") - .logicalSizeInGB(30) - .name("MSFT__Sql-Server-11EVAL-11.0.2215.0-05152012-en-us-30GB.vhd") - .os(OSType.WINDOWS) - .eula(URI.create("http://go.microsoft.com/fwlink/?LinkID=251820;http://go.microsoft.com/fwlink/?LinkID=131004")) - .description("SQL Server 2012 Evaluation Edition (64-bit).") - .build()) - .add(OSImage.builder() - .category("Microsoft") - .label("Windows Server 2012 Release Candidate, July 2012") - .logicalSizeInGB(30) - .name("MSFT__Win2K12RC-Datacenter-201207.02-en.us-30GB.vhd") - .os(OSType.WINDOWS) - .description("Windows Server 2012 incorporates Microsoft's experience building.") - .build()) - .add(OSImage.builder() - .category("Microsoft") - .label("Windows Server 2008 R2 SP1, July 2012") - .logicalSizeInGB(30) - .name("MSFT__Win2K8R2SP1-Datacenter-201207.01-en.us-30GB.vhd") - .os(OSType.WINDOWS) - .description("Windows Server 2008 R2 is a multi-purpose server.") - .build()) - .add(OSImage.builder() - .category("OpenLogic") - .label("OpenLogic CentOS 6.2") - .logicalSizeInGB(30) - .name("OpenLogic__OpenLogic-CentOS-62-20120531-en-us-30GB.vhd") - .os(OSType.LINUX) - .eula(URI.create("http://www.openlogic.com/azure/service-agreement/")) - .description("This distribution of Linux is based on CentOS.") - .build()) - .add(OSImage.builder() - .category("SUSE") - .label("openSUSE 12.1") - .logicalSizeInGB(30) - .name("SUSE__openSUSE-12-1-20120603-en-us-30GB.vhd") - .os(OSType.LINUX) - .eula(URI.create("http://opensuse.org/")) - .description("openSUSE is a free and Linux-based operating system!") - .build()) - .add(OSImage.builder() - .category("SUSE") - .label("SUSE Linux Enterprise Server") - .logicalSizeInGB(30) - .name("SUSE__SUSE-Linux-Enterprise-Server-11SP2-20120601-en-us-30GB.vhd") - .os(OSType.LINUX) - .eula(URI.create("http://www.novell.com/licensing/eula/")) - .description("SUSE Linux Enterprise Server is a highly reliable value.") - .build()).build(); - } - -} diff --git a/labs/azure-management/src/test/resources/azure-test.p12 b/labs/azure-management/src/test/resources/azure-test.p12 deleted file mode 100644 index 5250dd6ec2..0000000000 Binary files a/labs/azure-management/src/test/resources/azure-test.p12 and /dev/null differ diff --git a/labs/azure-management/src/test/resources/capturerolepayload.xml b/labs/azure-management/src/test/resources/capturerolepayload.xml deleted file mode 100644 index 9414c5271c..0000000000 --- a/labs/azure-management/src/test/resources/capturerolepayload.xml +++ /dev/null @@ -1 +0,0 @@ -CaptureRoleOperationDeletemyImageLabelmyImageName \ No newline at end of file diff --git a/labs/azure-management/src/test/resources/create_hostedservice_location.xml b/labs/azure-management/src/test/resources/create_hostedservice_location.xml deleted file mode 100644 index 076f562734..0000000000 --- a/labs/azure-management/src/test/resources/create_hostedservice_location.xml +++ /dev/null @@ -1 +0,0 @@ -myserviceWest US \ No newline at end of file diff --git a/labs/azure-management/src/test/resources/create_hostedservice_location_options.xml b/labs/azure-management/src/test/resources/create_hostedservice_location_options.xml deleted file mode 100644 index 9f7f8f0568..0000000000 --- a/labs/azure-management/src/test/resources/create_hostedservice_location_options.xml +++ /dev/null @@ -1 +0,0 @@ -myservicemy descriptionWest USRoleProduction \ No newline at end of file diff --git a/labs/azure-management/src/test/resources/deployment.xml b/labs/azure-management/src/test/resources/deployment.xml deleted file mode 100644 index 94cebc9019..0000000000 --- a/labs/azure-management/src/test/resources/deployment.xml +++ /dev/null @@ -1,70 +0,0 @@ - - neotysss - Production - 05aa8ec5d8ee4215894431c7db401b31 - Running - - http://neotysss.cloudapp.net/ - PFNlcnZpY2VDb25maWd1cmF0aW9uIHhtbG5zOnhzaT0iaHR0cDovL3d3dy53My5vcmcvMjAwMS9YTUxTY2hlbWEtaW5zdGFuY2UiIHhtbG5zOnhzZD0iaHR0cDovL3d3dy53My5vcmcvMjAwMS9YTUxTY2hlbWEiIHhtbG5zPSJodHRwOi8vc2NoZW1hcy5taWNyb3NvZnQuY29tL1NlcnZpY2VIb3N0aW5nLzIwMDgvMTAvU2VydmljZUNvbmZpZ3VyYXRpb24iPg0KICA8Um9sZSBuYW1lPSJuZW90eXNzcyI+DQogICAgPEluc3RhbmNlcyBjb3VudD0iMSIgLz4NCiAgPC9Sb2xlPg0KPC9TZXJ2aWNlQ29uZmlndXJhdGlvbj4= - - - neotysss - neotysss - ReadyRole - 0 - 0 - Medium - - 10.59.244.162 - - - SSH - 168.63.27.148 - 22 - 22 - tcp - - - Started - neotys - - - 1 - - - neotysss - - PersistentVMRole - - - NetworkConfiguration - - - 22 - SSH - 22 - tcp - 168.63.27.148 - - - - - - - - ReadWrite - neotysss-neotysss-0-20120824091357 - http://portalvhds0g7xhnq2x7t21.blob.core.windows.net/disks/neotysss/MSFT__Win2K8R2SP1-120612-1520-121206-01-en-us-30GB.vhd - MSFT__Win2K8R2SP1-120612-1520-121206-01-en-us-30GB.vhd - Windows - - Medium - - - - false - false - 2012-08-24T09:13:53Z - 2012-08-27T08:55:13Z - - \ No newline at end of file diff --git a/labs/azure-management/src/test/resources/deploymentparams.xml b/labs/azure-management/src/test/resources/deploymentparams.xml deleted file mode 100644 index fadaff12ea..0000000000 --- a/labs/azure-management/src/test/resources/deploymentparams.xml +++ /dev/null @@ -1 +0,0 @@ -mydeploymentProductionmydeploymentPersistentVMRoleLinuxProvisioningConfigurationmydeploymentusernametestpwdfalseNetworkConfigurationReadWritehttp://portalvhds0g7xhnq2x7t21.blob.core.windows.net/disks/mydeployment/OpenLogic__OpenLogic-CentOS-62-20120531-en-us-30GB.vhdOpenLogic__OpenLogic-CentOS-62-20120531-en-us-30GB.vhdLinuxMedium \ No newline at end of file diff --git a/labs/azure-management/src/test/resources/disks.xml b/labs/azure-management/src/test/resources/disks.xml deleted file mode 100644 index 9290a9af4d..0000000000 --- a/labs/azure-management/src/test/resources/disks.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - Linux - West Europe - 30 - http://neotysbucket1.blob.core.windows.net/vhds/testimage2-testimage2-2012-08-17.vhd - testimage2-testimage2-0-20120817095145 - OpenLogic__OpenLogic-CentOS-62-20120531-en-us-30GB.vhd - - - - neotysss - neotysss - neotysss - - Windows - West Europe - 30 - http://portalvhds0g7xhnq2x7t21.blob.core.windows.net/disks/neotysss/MSFT__Win2K8R2SP1-120612-1520-121206-01-en-us-30GB.vhd - neotysss-neotysss-0-20120824091357 - MSFT__Win2K8R2SP1-120612-1520-121206-01-en-us-30GB.vhd - - diff --git a/labs/azure-management/src/test/resources/error.xml b/labs/azure-management/src/test/resources/error.xml deleted file mode 100644 index a9f9b2f4fe..0000000000 --- a/labs/azure-management/src/test/resources/error.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - MissingOrInvalidRequiredQueryParameter - A required query parameter was not specified for this request or was specified incorrectly. - \ No newline at end of file diff --git a/labs/azure-management/src/test/resources/hostedservice.xml b/labs/azure-management/src/test/resources/hostedservice.xml deleted file mode 100644 index 625aeb3044..0000000000 --- a/labs/azure-management/src/test/resources/hostedservice.xml +++ /dev/null @@ -1,10 +0,0 @@ - - https://management.core.windows.net/eb0347c3-68d4-4550-9b39-5e7e0f92f7db/services/hostedservices/neotys - neotys - - Implicitly created hosted service2012-08-06 14:55 - - West Europe - - - \ No newline at end of file diff --git a/labs/azure-management/src/test/resources/hostedservice_details.xml b/labs/azure-management/src/test/resources/hostedservice_details.xml deleted file mode 100644 index d730cc7fe3..0000000000 --- a/labs/azure-management/src/test/resources/hostedservice_details.xml +++ /dev/null @@ -1,13 +0,0 @@ - - https://management.core.windows.net/eb0347c3-68d4-4550-9b39-5e7e0f92f7db/services/hostedservices/neotys - neotys - - Implicitly created hosted service2012-08-06 14:55 - West Europe - - Created - 2012-08-06T14:55:17Z - 2012-08-06T15:50:34Z - - - \ No newline at end of file diff --git a/labs/azure-management/src/test/resources/hostedservices.xml b/labs/azure-management/src/test/resources/hostedservices.xml deleted file mode 100644 index 66b7589e14..0000000000 --- a/labs/azure-management/src/test/resources/hostedservices.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - https://management.core.windows.net/eb0347c3-68d4-4550-9b39-5e7e0f92f7db/services/hostedservices/neotys - neotys - - Implicitly created hosted service2012-08-06 14:55 - West Europe - - Created - 2012-08-06T14:55:17Z - 2012-08-06T15:50:34Z - - - - - https://management.core.windows.net/eb0347c3-68d4-4550-9b39-5e7e0f92f7db/services/hostedservices/neotys3 - neotys3 - - - West Europe - - Created - 2012-08-07T09:00:02Z - 2012-08-07T09:00:02Z - - - - \ No newline at end of file diff --git a/labs/azure-management/src/test/resources/imageparams.xml b/labs/azure-management/src/test/resources/imageparams.xml deleted file mode 100644 index d3279baa06..0000000000 --- a/labs/azure-management/src/test/resources/imageparams.xml +++ /dev/null @@ -1 +0,0 @@ -http://example.blob.core.windows.net/disks/mydisk.vhdmyimageLinux \ No newline at end of file diff --git a/labs/azure-management/src/test/resources/images.xml b/labs/azure-management/src/test/resources/images.xml deleted file mode 100644 index aa6efca6cb..0000000000 --- a/labs/azure-management/src/test/resources/images.xml +++ /dev/null @@ -1,75 +0,0 @@ - - - Canonical - - 30 - CANONICAL__Canonical-Ubuntu-12-04-amd64-server-20120528.1.3-en-us-30GB.vhd - Linux - http://www.ubuntu.com/project/about-ubuntu/licensing - Ubuntu Server 12.04 LTS amd64 20120528 Cloud Image - - - Microsoft - - 30 - MSFT__Win2K8R2SP1-120612-1520-121206-01-en-us-30GB.vhd - Windows - - Windows Server 2008 R2 is a multi-purpose server. - - - Microsoft - - 30 - MSFT__Sql-Server-11EVAL-11.0.2215.0-05152012-en-us-30GB.vhd - Windows - http://go.microsoft.com/fwlink/?LinkID=251820;http://go.microsoft.com/fwlink/?LinkID=131004 - SQL Server 2012 Evaluation Edition (64-bit). - - - Microsoft - - 30 - MSFT__Win2K12RC-Datacenter-201207.02-en.us-30GB.vhd - Windows - - Windows Server 2012 incorporates Microsoft's experience building. - - - Microsoft - - 30 - MSFT__Win2K8R2SP1-Datacenter-201207.01-en.us-30GB.vhd - Windows - - Windows Server 2008 R2 is a multi-purpose server. - - - OpenLogic - - 30 - OpenLogic__OpenLogic-CentOS-62-20120531-en-us-30GB.vhd - Linux - http://www.openlogic.com/azure/service-agreement/ - This distribution of Linux is based on CentOS. - - - SUSE - - 30 - SUSE__openSUSE-12-1-20120603-en-us-30GB.vhd - Linux - http://opensuse.org/ - openSUSE is a free and Linux-based operating system! - - - SUSE - - 30 - SUSE__SUSE-Linux-Enterprise-Server-11SP2-20120601-en-us-30GB.vhd - Linux - http://www.novell.com/licensing/eula/ - SUSE Linux Enterprise Server is a highly reliable value. - - \ No newline at end of file diff --git a/labs/azure-management/src/test/resources/locations.xml b/labs/azure-management/src/test/resources/locations.xml deleted file mode 100644 index 1c7dcc861a..0000000000 --- a/labs/azure-management/src/test/resources/locations.xml +++ /dev/null @@ -1,57 +0,0 @@ - - - - West US - West US - - Compute - Storage - PersistentVMRole - - - - East US - East US - - Compute - Storage - PersistentVMRole - - - - East Asia - East Asia - - Compute - Storage - PersistentVMRole - - - - Southeast Asia - Southeast Asia - - Compute - Storage - PersistentVMRole - - - - North Europe - North Europe - - Compute - Storage - PersistentVMRole - - - - West Europe - West Europe - - Compute - Storage - PersistentVMRole - - - \ No newline at end of file diff --git a/labs/azure-management/src/test/resources/operation.xml b/labs/azure-management/src/test/resources/operation.xml deleted file mode 100644 index 498d1f0037..0000000000 --- a/labs/azure-management/src/test/resources/operation.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - request-id - Failed - 400 - - MissingOrInvalidRequiredQueryParameter - A required query parameter was not specified for this request or was specified incorrectly. - - diff --git a/labs/azure-management/src/test/resources/restartrolepayload.xml b/labs/azure-management/src/test/resources/restartrolepayload.xml deleted file mode 100644 index 4eca508070..0000000000 --- a/labs/azure-management/src/test/resources/restartrolepayload.xml +++ /dev/null @@ -1 +0,0 @@ -RestartRoleOperation \ No newline at end of file diff --git a/labs/azure-management/src/test/resources/shutdownrolepayload.xml b/labs/azure-management/src/test/resources/shutdownrolepayload.xml deleted file mode 100644 index 27beee8d25..0000000000 --- a/labs/azure-management/src/test/resources/shutdownrolepayload.xml +++ /dev/null @@ -1 +0,0 @@ -ShutdownRoleOperation \ No newline at end of file diff --git a/labs/azure-management/src/test/resources/startrolepayload.xml b/labs/azure-management/src/test/resources/startrolepayload.xml deleted file mode 100644 index 4e8202273f..0000000000 --- a/labs/azure-management/src/test/resources/startrolepayload.xml +++ /dev/null @@ -1 +0,0 @@ -StartRoleOperation \ No newline at end of file diff --git a/labs/carrenza-vcloud-director/pom.xml b/labs/carrenza-vcloud-director/pom.xml deleted file mode 100644 index 49b326df06..0000000000 --- a/labs/carrenza-vcloud-director/pom.xml +++ /dev/null @@ -1,140 +0,0 @@ - - - - 4.0.0 - - org.jclouds - jclouds-project - 1.7.0-SNAPSHOT - ../../project/pom.xml - - org.jclouds.labs - carrenza-vcloud-director - jclouds Carrenza vCloud Director provider - vCloud Director implementation targeted to Carrenza - bundle - - - https://myvdc.carrenza.net/api - 1.5 - 464915 - FIXME_IDENTITY - FIXME_CREDENTIAL - - - - - - - - - org.jclouds.carrenza.vcloud.director*;version="${project.version}" - - org.jclouds.compute.internal;version="${project.version}", - org.jclouds.rest.internal;version="${project.version}", - org.jclouds*;version="${project.version}", - * - - - - - - org.jclouds.labs - vcloud-director - ${project.version} - - - org.jclouds.labs - vcloud-director - ${project.version} - test-jar - test - - - org.jclouds - jclouds-core - ${project.version} - test-jar - test - - - org.jclouds - jclouds-compute - ${project.version} - test-jar - test - - - org.jclouds.driver - jclouds-log4j - ${project.version} - test - - - org.jclouds.driver - jclouds-sshj - ${project.version} - test - - - - - - live - - - - org.apache.maven.plugins - maven-surefire-plugin - - - integration - integration-test - - test - - - - ${test.carrenza-vcloud-director.endpoint} - ${test.carrenza-vcloud-director.api-version} - ${test.carrenza-vcloud-director.build-version} - ${test.carrenza-vcloud-director.identity} - ${test.carrenza-vcloud-director.credential} - ${test.carrenza-vcloud-director.template} - ${test.carrenza-vcloud-director.catalog-id} - ${test.carrenza-vcloud-director.media-id} - ${test.carrenza-vcloud-director.vapptemplate-id} - ${test.carrenza-vcloud-director.network-id} - ${test.carrenza-vcloud-director.vdc-id} - ${test.carrenza-vcloud-director.user-id} - - - - - - - - - - - - diff --git a/labs/carrenza-vcloud-director/src/main/java/org/jclouds/carrenza/vcloud/director/CarrenzaVCloudDirectorProviderMetadata.java b/labs/carrenza-vcloud-director/src/main/java/org/jclouds/carrenza/vcloud/director/CarrenzaVCloudDirectorProviderMetadata.java deleted file mode 100644 index 0c75de1d95..0000000000 --- a/labs/carrenza-vcloud-director/src/main/java/org/jclouds/carrenza/vcloud/director/CarrenzaVCloudDirectorProviderMetadata.java +++ /dev/null @@ -1,97 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.carrenza.vcloud.director; - -import static org.jclouds.Constants.PROPERTY_BUILD_VERSION; -import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.PROPERTY_VCLOUD_DIRECTOR_DEFAULT_NETWORK; - -import java.net.URI; -import java.util.Properties; - -import org.jclouds.carrenza.vcloud.director.config.CarrenzaVCloudDirectorComputeServiceContextModule; -import org.jclouds.carrenza.vcloud.director.config.CarrenzaVCloudDirectorRestClientModule; -import org.jclouds.providers.ProviderMetadata; -import org.jclouds.providers.internal.BaseProviderMetadata; -import org.jclouds.vcloud.director.v1_5.VCloudDirectorApiMetadata; - -import com.google.common.collect.ImmutableSet; -import com.google.inject.Module; - -/** - * Implementation of {@link org.jclouds.types.ProviderMetadata} for Carrenza vCloud hosting - * - * @author Adrian Cole - * @author grkvlt@apache.org - */ -@SuppressWarnings("serial") -public class CarrenzaVCloudDirectorProviderMetadata extends BaseProviderMetadata { - - public static Builder builder() { - return new Builder(); - } - - @Override - public Builder toBuilder() { - return builder().fromProviderMetadata(this); - } - - public CarrenzaVCloudDirectorProviderMetadata() { - super(builder()); - } - - public CarrenzaVCloudDirectorProviderMetadata(Builder builder) { - super(builder); - } - - public static Properties defaultProperties() { - Properties properties = new Properties(); - properties.setProperty(PROPERTY_BUILD_VERSION, "1.5.0.464915"); - properties.setProperty(PROPERTY_VCLOUD_DIRECTOR_DEFAULT_NETWORK, "orgNet-.*-External"); - return properties; - } - - public static class Builder extends BaseProviderMetadata.Builder { - - protected Builder() { - id("carrenza-vcloud-director") - .name("Carrenza vCloud Director") - .apiMetadata(new VCloudDirectorApiMetadata().toBuilder() - .buildVersion("1.5.0.464915") - .defaultModules(ImmutableSet.>of(CarrenzaVCloudDirectorRestClientModule.class, CarrenzaVCloudDirectorComputeServiceContextModule.class)) - .build()) - .homepage(URI.create("http://carrenza.com/")) - .console(URI.create("https://myvdc.carrenza.net/cloud/org/YOUR_ORG_HERE")) - .iso3166Codes("GB-LND") - .endpoint("https://myvdc.carrenza.net/api") - .defaultProperties(CarrenzaVCloudDirectorProviderMetadata.defaultProperties()); - } - - @Override - public CarrenzaVCloudDirectorProviderMetadata build() { - return new CarrenzaVCloudDirectorProviderMetadata(this); - } - - @Override - public Builder fromProviderMetadata( - ProviderMetadata in) { - super.fromProviderMetadata(in); - return this; - } - } -} diff --git a/labs/carrenza-vcloud-director/src/main/java/org/jclouds/carrenza/vcloud/director/config/CarrenzaVCloudDirectorComputeServiceContextModule.java b/labs/carrenza-vcloud-director/src/main/java/org/jclouds/carrenza/vcloud/director/config/CarrenzaVCloudDirectorComputeServiceContextModule.java deleted file mode 100644 index d7be2dd140..0000000000 --- a/labs/carrenza-vcloud-director/src/main/java/org/jclouds/carrenza/vcloud/director/config/CarrenzaVCloudDirectorComputeServiceContextModule.java +++ /dev/null @@ -1,41 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.carrenza.vcloud.director.config; - -import com.google.inject.AbstractModule; - - -/** - * per docs, we are to use pool mode. - * - * @author danikov - */ -public class CarrenzaVCloudDirectorComputeServiceContextModule extends AbstractModule { - - @Override - protected void configure() { - - } // FIXME: enable when compute service done -//extends VCloudDirectorComputeServiceContextModule { -// -// @Override -// protected TemplateOptions provideTemplateOptions(Injector injector, TemplateOptions options) { -// return options.as(VCloudDirectorTemplateOptions.class).ipAddressAllocationMode(IpAddressAllocationMode.POOL); -// } -} diff --git a/labs/carrenza-vcloud-director/src/main/java/org/jclouds/carrenza/vcloud/director/config/CarrenzaVCloudDirectorRestClientModule.java b/labs/carrenza-vcloud-director/src/main/java/org/jclouds/carrenza/vcloud/director/config/CarrenzaVCloudDirectorRestClientModule.java deleted file mode 100644 index da74a8fea6..0000000000 --- a/labs/carrenza-vcloud-director/src/main/java/org/jclouds/carrenza/vcloud/director/config/CarrenzaVCloudDirectorRestClientModule.java +++ /dev/null @@ -1,32 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.carrenza.vcloud.director.config; - -import org.jclouds.rest.ConfiguresRestClient; -import org.jclouds.vcloud.director.v1_5.config.VCloudDirectorRestClientModule; - -/** - * Configures the VCloud authentication service connection, including logging and http transport. - * - * @author danikov - */ -@ConfiguresRestClient -public class CarrenzaVCloudDirectorRestClientModule extends VCloudDirectorRestClientModule { - -} diff --git a/labs/carrenza-vcloud-director/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata b/labs/carrenza-vcloud-director/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata deleted file mode 100644 index b59c68cff5..0000000000 --- a/labs/carrenza-vcloud-director/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata +++ /dev/null @@ -1 +0,0 @@ -org.jclouds.carrenza.vcloud.director.CarrenzaVCloudDirectorProviderMetadata diff --git a/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/CarrenzaVCloudDirectorProviderTest.java b/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/CarrenzaVCloudDirectorProviderTest.java deleted file mode 100644 index ed936665da..0000000000 --- a/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/CarrenzaVCloudDirectorProviderTest.java +++ /dev/null @@ -1,35 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.carrenza.vcloud.director; - -import org.jclouds.providers.internal.BaseProviderMetadataTest; -import org.jclouds.vcloud.director.v1_5.VCloudDirectorApiMetadata; -import org.testng.annotations.Test; - -/** - * - * @author danikov - */ -@Test(groups = "unit", testName = "CarrenzaVCloudDirectorProviderTest") -public class CarrenzaVCloudDirectorProviderTest extends BaseProviderMetadataTest { - - public CarrenzaVCloudDirectorProviderTest() { - super(new CarrenzaVCloudDirectorProviderMetadata(), new VCloudDirectorApiMetadata()); - } -} diff --git a/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/compute/CarrenzaVCloudDirectorComputeServiceLiveTest.java b/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/compute/CarrenzaVCloudDirectorComputeServiceLiveTest.java deleted file mode 100644 index 7c40c1fdc2..0000000000 --- a/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/compute/CarrenzaVCloudDirectorComputeServiceLiveTest.java +++ /dev/null @@ -1,36 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.carrenza.vcloud.director.compute; - -import org.testng.annotations.Test; - -/** - * {@inheritDoc} - * - * @author danikov - * @author grkvlt - */ -@Test(groups = { "live", "compute" }, singleThreaded = true, testName = "CarrenzaVCloudDirectorComputeServiceLiveTest") -public class CarrenzaVCloudDirectorComputeServiceLiveTest { // FIXME: enable when compute service done -// extends VCloudDirectorComputeServiceLiveTest { -// -// public CarrenzaVCloudDirectorComputeServiceLiveTest() { -// provider = "carrenza-vcloud-director"; -// } -} diff --git a/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/compute/CarrenzaVCloudDirectorTemplateBuilderLiveTest.java b/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/compute/CarrenzaVCloudDirectorTemplateBuilderLiveTest.java deleted file mode 100644 index 8f290c24df..0000000000 --- a/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/compute/CarrenzaVCloudDirectorTemplateBuilderLiveTest.java +++ /dev/null @@ -1,36 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.carrenza.vcloud.director.compute; - -import org.testng.annotations.Test; - -/** - * {@inheritDoc} - * - * @author danikov - * @author grkvlt - */ -@Test(groups = { "live", "compute" }, testName = "CarrenzaVCloudDirectorTemplateBuilderLiveTest") -public class CarrenzaVCloudDirectorTemplateBuilderLiveTest { -// BaseTemplateBuilderLiveTest { -// -// public CarrenzaVCloudDirectorTemplateBuilderLiveTest() { -// provider = "carrenza-vcloud-director"; -// } -} diff --git a/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorCatalogApiLiveTest.java b/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorCatalogApiLiveTest.java deleted file mode 100644 index e6776858b8..0000000000 --- a/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorCatalogApiLiveTest.java +++ /dev/null @@ -1,36 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.carrenza.vcloud.director.features; - -import org.jclouds.vcloud.director.v1_5.features.CatalogApiLiveTest; -import org.testng.annotations.Test; - -/** - * {@inheritDoc} - * - * @author danikov - * @author grkvlt - */ -@Test(groups = { "live", "user" }, singleThreaded = true, testName = "CarrenzaVCloudDirectorCatalogApiLiveTest") -public class CarrenzaVCloudDirectorCatalogApiLiveTest extends CatalogApiLiveTest { - - public CarrenzaVCloudDirectorCatalogApiLiveTest() { - provider = "carrenza-vcloud-director"; - } -} diff --git a/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorMediaApiLiveTest.java b/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorMediaApiLiveTest.java deleted file mode 100644 index a305dcb100..0000000000 --- a/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorMediaApiLiveTest.java +++ /dev/null @@ -1,36 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.carrenza.vcloud.director.features; - -import org.jclouds.vcloud.director.v1_5.features.MediaApiLiveTest; -import org.testng.annotations.Test; - -/** - * {@inheritDoc} - * - * @author danikov - * @author grkvlt - */ -@Test(groups = { "live", "user" }, singleThreaded = true, testName = "CarrenzaVCloudDirectorMediaApiLiveTest") -public class CarrenzaVCloudDirectorMediaApiLiveTest extends MediaApiLiveTest { - - public CarrenzaVCloudDirectorMediaApiLiveTest() { - provider = "carrenza-vcloud-director"; - } -} diff --git a/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorNetworkApiLiveTest.java b/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorNetworkApiLiveTest.java deleted file mode 100644 index c4088aa26b..0000000000 --- a/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorNetworkApiLiveTest.java +++ /dev/null @@ -1,36 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.carrenza.vcloud.director.features; - -import org.jclouds.vcloud.director.v1_5.features.NetworkApiLiveTest; -import org.testng.annotations.Test; - -/** - * {@inheritDoc} - * - * @author danikov - * @author grkvlt - */ -@Test(groups = { "live", "user" }, singleThreaded = true, testName = "CarrenzaVCloudDirectorNetworkApiLiveTest") -public class CarrenzaVCloudDirectorNetworkApiLiveTest extends NetworkApiLiveTest { - - public CarrenzaVCloudDirectorNetworkApiLiveTest() { - provider = "carrenza-vcloud-director"; - } -} diff --git a/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorOrgApiLiveTest.java b/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorOrgApiLiveTest.java deleted file mode 100644 index c8f19000ed..0000000000 --- a/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorOrgApiLiveTest.java +++ /dev/null @@ -1,36 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.carrenza.vcloud.director.features; - -import org.jclouds.vcloud.director.v1_5.features.OrgApiLiveTest; -import org.testng.annotations.Test; - -/** - * {@inheritDoc} - * - * @author danikov - * @author grkvlt - */ -@Test(groups = { "live", "user" }, singleThreaded = true, testName = "CarrenzaVCloudDirectorOrgApiLiveTest") -public class CarrenzaVCloudDirectorOrgApiLiveTest extends OrgApiLiveTest { - - public CarrenzaVCloudDirectorOrgApiLiveTest() { - provider = "carrenza-vcloud-director"; - } -} diff --git a/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorQueryApiLiveTest.java b/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorQueryApiLiveTest.java deleted file mode 100644 index d766ed2195..0000000000 --- a/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorQueryApiLiveTest.java +++ /dev/null @@ -1,36 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.carrenza.vcloud.director.features; - -import org.jclouds.vcloud.director.v1_5.features.QueryApiLiveTest; -import org.testng.annotations.Test; - -/** - * {@inheritDoc} - * - * @author danikov - * @author grkvlt - */ -@Test(groups = { "live", "user" }, singleThreaded = true, testName = "CarrenzaVCloudDirectorQueryApiLiveTest") -public class CarrenzaVCloudDirectorQueryApiLiveTest extends QueryApiLiveTest { - - public CarrenzaVCloudDirectorQueryApiLiveTest() { - provider = "carrenza-vcloud-director"; - } -} diff --git a/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorTaskApiLiveTest.java b/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorTaskApiLiveTest.java deleted file mode 100644 index fe407565d7..0000000000 --- a/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorTaskApiLiveTest.java +++ /dev/null @@ -1,36 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.carrenza.vcloud.director.features; - -import org.jclouds.vcloud.director.v1_5.features.TaskApiLiveTest; -import org.testng.annotations.Test; - -/** - * {@inheritDoc} - * - * @author danikov - * @author grkvlt - */ -@Test(groups = { "live", "user" }, singleThreaded = true, testName = "CarrenzaVCloudDirectorTaskApiLiveTest") -public class CarrenzaVCloudDirectorTaskApiLiveTest extends TaskApiLiveTest { - - public CarrenzaVCloudDirectorTaskApiLiveTest() { - provider = "carrenza-vcloud-director"; - } -} diff --git a/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorUploadApiLiveTest.java b/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorUploadApiLiveTest.java deleted file mode 100644 index c4132a6a79..0000000000 --- a/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorUploadApiLiveTest.java +++ /dev/null @@ -1,36 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.carrenza.vcloud.director.features; - -import org.jclouds.vcloud.director.v1_5.features.UploadApiLiveTest; -import org.testng.annotations.Test; - -/** - * {@inheritDoc} - * - * @author danikov - * @author grkvlt - */ -@Test(groups = { "live", "user" }, singleThreaded = true, testName = "CarrenzaVCloudDirectorUploadApiLiveTest") -public class CarrenzaVCloudDirectorUploadApiLiveTest extends UploadApiLiveTest { - - public CarrenzaVCloudDirectorUploadApiLiveTest() { - provider = "carrenza-vcloud-director"; - } -} diff --git a/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorVAppApiLiveTest.java b/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorVAppApiLiveTest.java deleted file mode 100644 index cb2d4b2f23..0000000000 --- a/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorVAppApiLiveTest.java +++ /dev/null @@ -1,36 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.carrenza.vcloud.director.features; - -import org.jclouds.vcloud.director.v1_5.features.VAppApiLiveTest; -import org.testng.annotations.Test; - -/** - * {@inheritDoc} - * - * @author danikov - * @author grkvlt - */ -@Test(groups = { "live", "user" }, singleThreaded = true, testName = "CarrenzaVCloudDirectorVAppApiLiveTest") -public class CarrenzaVCloudDirectorVAppApiLiveTest extends VAppApiLiveTest { - - public CarrenzaVCloudDirectorVAppApiLiveTest() { - provider = "carrenza-vcloud-director"; - } -} diff --git a/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorVAppTemplateApiLiveTest.java b/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorVAppTemplateApiLiveTest.java deleted file mode 100644 index 9aaffb3d7f..0000000000 --- a/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorVAppTemplateApiLiveTest.java +++ /dev/null @@ -1,36 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.carrenza.vcloud.director.features; - -import org.jclouds.vcloud.director.v1_5.features.VAppTemplateApiLiveTest; -import org.testng.annotations.Test; - -/** - * {@inheritDoc} - * - * @author danikov - * @author grkvlt - */ -@Test(groups = { "live", "user" }, singleThreaded = true, testName = "CarrenzaVCloudDirectorVAppTemplateApiLiveTest") -public class CarrenzaVCloudDirectorVAppTemplateApiLiveTest extends VAppTemplateApiLiveTest { - - public CarrenzaVCloudDirectorVAppTemplateApiLiveTest() { - provider = "carrenza-vcloud-director"; - } -} diff --git a/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorVdcApiLiveTest.java b/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorVdcApiLiveTest.java deleted file mode 100644 index 78d050ff31..0000000000 --- a/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/CarrenzaVCloudDirectorVdcApiLiveTest.java +++ /dev/null @@ -1,36 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.carrenza.vcloud.director.features; - -import org.jclouds.vcloud.director.v1_5.features.VdcApiLiveTest; -import org.testng.annotations.Test; - -/** - * {@inheritDoc} - * - * @author danikov - * @author grkvlt - */ -@Test(groups = { "live", "user" }, singleThreaded = true, testName = "CarrenzaVCloudDirectorVDCApiLiveTest") -public class CarrenzaVCloudDirectorVdcApiLiveTest extends VdcApiLiveTest { - - public CarrenzaVCloudDirectorVdcApiLiveTest() { - provider = "carrenza-vcloud-director"; - } -} diff --git a/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/admin/CarrenzaVCloudDirectorAdminCatalogApiLiveTest.java b/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/admin/CarrenzaVCloudDirectorAdminCatalogApiLiveTest.java deleted file mode 100644 index aff054b7e6..0000000000 --- a/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/admin/CarrenzaVCloudDirectorAdminCatalogApiLiveTest.java +++ /dev/null @@ -1,36 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.carrenza.vcloud.director.features.admin; - -import org.jclouds.vcloud.director.v1_5.features.admin.AdminCatalogApiLiveTest; -import org.testng.annotations.Test; - -/** - * {@inheritDoc} - * - * @author danikov - * @author grkvlt - */ -@Test(groups = { "live", "admin" }, singleThreaded = true, testName = "CarrenzaVCloudDirectorAdminCatalogApiLiveTest") -public class CarrenzaVCloudDirectorAdminCatalogApiLiveTest extends AdminCatalogApiLiveTest { - - public CarrenzaVCloudDirectorAdminCatalogApiLiveTest() { - provider = "carrenza-vcloud-director"; - } -} diff --git a/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/admin/CarrenzaVCloudDirectorAdminNetworkApiLiveTest.java b/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/admin/CarrenzaVCloudDirectorAdminNetworkApiLiveTest.java deleted file mode 100644 index d7185dbff6..0000000000 --- a/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/admin/CarrenzaVCloudDirectorAdminNetworkApiLiveTest.java +++ /dev/null @@ -1,36 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.carrenza.vcloud.director.features.admin; - -import org.jclouds.vcloud.director.v1_5.features.admin.AdminNetworkApiLiveTest; -import org.testng.annotations.Test; - -/** - * {@inheritDoc} - * - * @author danikov - * @author grkvlt - */ -@Test(groups = { "live", "admin" }, singleThreaded = true, testName = "CarrenzaVCloudDirectorAdminNetworkApiLiveTest") -public class CarrenzaVCloudDirectorAdminNetworkApiLiveTest extends AdminNetworkApiLiveTest { - - public CarrenzaVCloudDirectorAdminNetworkApiLiveTest() { - provider = "carrenza-vcloud-director"; - } -} diff --git a/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/admin/CarrenzaVCloudDirectorAdminOrgApiLiveTest.java b/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/admin/CarrenzaVCloudDirectorAdminOrgApiLiveTest.java deleted file mode 100644 index a29adb8415..0000000000 --- a/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/admin/CarrenzaVCloudDirectorAdminOrgApiLiveTest.java +++ /dev/null @@ -1,36 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.carrenza.vcloud.director.features.admin; - -import org.jclouds.vcloud.director.v1_5.features.admin.AdminOrgApiLiveTest; -import org.testng.annotations.Test; - -/** - * {@inheritDoc} - * - * @author danikov - * @author grkvlt - */ -@Test(groups = { "live", "admin" }, singleThreaded = true, testName = "CarrenzaVCloudDirectorOrgApiLiveTest") -public class CarrenzaVCloudDirectorAdminOrgApiLiveTest extends AdminOrgApiLiveTest { - - public CarrenzaVCloudDirectorAdminOrgApiLiveTest() { - provider = "carrenza-vcloud-director"; - } -} diff --git a/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/admin/CarrenzaVCloudDirectorAdminQueryApiLiveTest.java b/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/admin/CarrenzaVCloudDirectorAdminQueryApiLiveTest.java deleted file mode 100644 index b50caaf3dd..0000000000 --- a/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/admin/CarrenzaVCloudDirectorAdminQueryApiLiveTest.java +++ /dev/null @@ -1,36 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.carrenza.vcloud.director.features.admin; - -import org.jclouds.vcloud.director.v1_5.features.admin.AdminQueryApiLiveTest; -import org.testng.annotations.Test; - -/** - * {@inheritDoc} - * - * @author danikov - * @author grkvlt - */ -@Test(groups = { "live", "admin" }, singleThreaded = true, testName = "CarrenzaVCloudDirectorAdminQueryApiLiveTest") -public class CarrenzaVCloudDirectorAdminQueryApiLiveTest extends AdminQueryApiLiveTest { - - public CarrenzaVCloudDirectorAdminQueryApiLiveTest() { - provider = "carrenza-vcloud-director"; - } -} diff --git a/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/admin/CarrenzaVCloudDirectorAdminVdcApiLiveTest.java b/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/admin/CarrenzaVCloudDirectorAdminVdcApiLiveTest.java deleted file mode 100644 index e6387bd794..0000000000 --- a/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/admin/CarrenzaVCloudDirectorAdminVdcApiLiveTest.java +++ /dev/null @@ -1,36 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.carrenza.vcloud.director.features.admin; - -import org.jclouds.vcloud.director.v1_5.features.admin.AdminVdcApiLiveTest; -import org.testng.annotations.Test; - -/** - * {@inheritDoc} - * - * @author danikov - * @author grkvlt - */ -@Test(groups = { "live", "admin" }, singleThreaded = true, testName = "CarrenzaVCloudDirectorAdminVdcApiLiveTest") -public class CarrenzaVCloudDirectorAdminVdcApiLiveTest extends AdminVdcApiLiveTest { - - public CarrenzaVCloudDirectorAdminVdcApiLiveTest() { - provider = "carrenza-vcloud-director"; - } -} diff --git a/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/admin/CarrenzaVCloudDirectorGroupApiLiveTest.java b/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/admin/CarrenzaVCloudDirectorGroupApiLiveTest.java deleted file mode 100644 index a77d3cca41..0000000000 --- a/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/admin/CarrenzaVCloudDirectorGroupApiLiveTest.java +++ /dev/null @@ -1,36 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.carrenza.vcloud.director.features.admin; - -import org.jclouds.vcloud.director.v1_5.features.admin.GroupApiLiveTest; -import org.testng.annotations.Test; - -/** - * {@inheritDoc} - * - * @author danikov - * @author grkvlt - */ -@Test(groups = { "live", "admin" }, singleThreaded = true, testName = "CarrenzaVCloudDirectorGroupApiLiveTest") -public class CarrenzaVCloudDirectorGroupApiLiveTest extends GroupApiLiveTest { - - public CarrenzaVCloudDirectorGroupApiLiveTest() { - provider = "carrenza-vcloud-director"; - } -} diff --git a/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/admin/CarrenzaVCloudDirectorUserApiLiveTest.java b/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/admin/CarrenzaVCloudDirectorUserApiLiveTest.java deleted file mode 100644 index bd82f22de6..0000000000 --- a/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/features/admin/CarrenzaVCloudDirectorUserApiLiveTest.java +++ /dev/null @@ -1,36 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.carrenza.vcloud.director.features.admin; - -import org.jclouds.vcloud.director.v1_5.features.admin.UserApiLiveTest; -import org.testng.annotations.Test; - -/** - * {@inheritDoc} - * - * @author danikov - * @author grkvlt - */ -@Test(groups = { "live", "admin" }, singleThreaded = true, testName = "CarrenzaVCloudDirectorUserApiLiveTest") -public class CarrenzaVCloudDirectorUserApiLiveTest extends UserApiLiveTest { - - public CarrenzaVCloudDirectorUserApiLiveTest() { - provider = "carrenza-vcloud-director"; - } -} diff --git a/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/login/CarrenzaVCloudDirectorSessionApiLiveTest.java b/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/login/CarrenzaVCloudDirectorSessionApiLiveTest.java deleted file mode 100644 index 75ee8f0333..0000000000 --- a/labs/carrenza-vcloud-director/src/test/java/org/jclouds/carrenza/vcloud/director/login/CarrenzaVCloudDirectorSessionApiLiveTest.java +++ /dev/null @@ -1,36 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.carrenza.vcloud.director.login; - -import org.jclouds.vcloud.director.v1_5.login.SessionApiLiveTest; -import org.testng.annotations.Test; - -/** - * {@inheritDoc} - * - * @author danikov - * @author grkvlt - */ -@Test(groups = { "live", "user" }, singleThreaded = true, testName = "CarrenzaVCloudDirectorSessionApiLiveTest") -public class CarrenzaVCloudDirectorSessionApiLiveTest extends SessionApiLiveTest { - - public CarrenzaVCloudDirectorSessionApiLiveTest() { - provider = "carrenza-vcloud-director"; - } -} diff --git a/labs/carrenza-vcloud-director/src/test/resources/log4j.xml b/labs/carrenza-vcloud-director/src/test/resources/log4j.xml deleted file mode 100644 index daefa0e832..0000000000 --- a/labs/carrenza-vcloud-director/src/test/resources/log4j.xml +++ /dev/null @@ -1,157 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/labs/cdmi/pom.xml b/labs/cdmi/pom.xml deleted file mode 100644 index a7a518cb4f..0000000000 --- a/labs/cdmi/pom.xml +++ /dev/null @@ -1,121 +0,0 @@ - - - - 4.0.0 - - org.jclouds.labs - jclouds-labs-project - 1.7.0-SNAPSHOT - ../project/pom.xml - - cdmi - jcloud cdmi api - jclouds components to access an implementation of SNIA CDMI - bundle - - - http://localhost:8080 - 1.0.1 - - tenantId:IDENTITY - FIXME_CREDENTIALS - FIXME_HTTPURL - FIXME_HTTPMD5 - - org.jclouds.snia.cdmi.v1*;version="${project.version}" - - org.jclouds.blobstore.internal;version="${jclouds.version}", - org.jclouds.rest.internal;version="${jclouds.version}", - org.jclouds.labs*;version="${project.version}", - org.jclouds*;version="${jclouds.version}", - * - - - - - - org.jclouds - jclouds-blobstore - ${jclouds.version} - - - org.jclouds - jclouds-core - ${jclouds.version} - test-jar - test - - - org.jclouds - jclouds-blobstore - ${jclouds.version} - test-jar - test - - - org.jclouds.driver - jclouds-slf4j - ${jclouds.version} - test - - - ch.qos.logback - logback-classic - test - - - - - - live - - - - org.apache.maven.plugins - maven-surefire-plugin - - - integration - integration-test - - test - - - - ${test.cdmi.endpoint} - ${test.cdmi.api-version} - ${test.cdmi.build-version} - ${test.cdmi.identity} - ${test.cdmi.credential} - ${jclouds.blobstore.httpstream.url} - ${jclouds.blobstore.httpstream.md5} - - - - - - - - - - - diff --git a/labs/cdmi/src/main/java/org/jclouds/snia/cdmi/v1/CDMIApi.java b/labs/cdmi/src/main/java/org/jclouds/snia/cdmi/v1/CDMIApi.java deleted file mode 100644 index b82b190013..0000000000 --- a/labs/cdmi/src/main/java/org/jclouds/snia/cdmi/v1/CDMIApi.java +++ /dev/null @@ -1,66 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.snia.cdmi.v1; - -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; - -import org.jclouds.rest.annotations.Delegate; -import org.jclouds.snia.cdmi.v1.features.ContainerApi; -import org.jclouds.snia.cdmi.v1.features.DataApi; -import org.jclouds.snia.cdmi.v1.features.DataNonCDMIContentTypeApi; -import org.jclouds.snia.cdmi.v1.features.DomainApi; - -/** - * Provides synchronous access to CDMI. - *

- * - * @see CDMIAsyncApi - * @see api doc - * @author Adrian Cole - */ -public interface CDMIApi { - - /** - * Provides synchronous access to Domain Object Resource Operations. - */ - @Delegate - DomainApi getDomainApi(); - - /** - * Provides synchronous access to Container Object Resource Operations. - */ - @Delegate - ContainerApi getApi(); - - /** - * Provides synchronous access to Data Object Resource Operations. - */ - @Delegate - @Path("/{containerName}") - DataApi getDataApiForContainer(@PathParam("containerName") String containerName); - - /** - * Provides synchronous access to Data Object Resource Operations. - */ - @Delegate - @Path("/{containerName}") - DataNonCDMIContentTypeApi getDataNonCDMIContentTypeApiForContainer(@PathParam("containerName") String containerName); - -} diff --git a/labs/cdmi/src/main/java/org/jclouds/snia/cdmi/v1/CDMIApiMetadata.java b/labs/cdmi/src/main/java/org/jclouds/snia/cdmi/v1/CDMIApiMetadata.java deleted file mode 100644 index 28ce50d29a..0000000000 --- a/labs/cdmi/src/main/java/org/jclouds/snia/cdmi/v1/CDMIApiMetadata.java +++ /dev/null @@ -1,82 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.snia.cdmi.v1; - -import java.net.URI; -import java.util.Properties; - -import org.jclouds.apis.ApiMetadata; -import org.jclouds.rest.RestContext; -import org.jclouds.rest.internal.BaseRestApiMetadata; -import org.jclouds.snia.cdmi.v1.config.CDMIRestClientModule; - -import com.google.common.collect.ImmutableSet; -import com.google.common.reflect.TypeToken; -import com.google.inject.Module; - -/** - * Implementation of {@link ApiMetadata} for CDMI 1.0.1 API - * - * @author Adrian Cole - */ -public class CDMIApiMetadata extends BaseRestApiMetadata { - - public static final TypeToken> CONTEXT_TOKEN = new TypeToken>() { - private static final long serialVersionUID = 1L; - }; - - @Override - public Builder toBuilder() { - return new Builder().fromApiMetadata(this); - } - - public CDMIApiMetadata() { - this(new Builder()); - } - - protected CDMIApiMetadata(Builder builder) { - super(builder); - } - - public static Properties defaultProperties() { - Properties properties = BaseRestApiMetadata.defaultProperties(); - return properties; - } - - public static class Builder extends BaseRestApiMetadata.Builder { - - protected Builder() { - super(CDMIApi.class, CDMIAsyncApi.class); - id("cdmi").name("SNIA CDMI API").identityName("tenantId:user").credentialName("password") - .documentation(URI.create("http://www.snia.org/cdmi")).version("1.0.1") - .defaultEndpoint("http://localhost:8080").defaultProperties(CDMIApiMetadata.defaultProperties()) - .defaultModules(ImmutableSet.> of(CDMIRestClientModule.class)); - } - - @Override - public CDMIApiMetadata build() { - return new CDMIApiMetadata(this); - } - - @Override - protected Builder self() { - return this; - } - } -} diff --git a/labs/cdmi/src/main/java/org/jclouds/snia/cdmi/v1/CDMIAsyncApi.java b/labs/cdmi/src/main/java/org/jclouds/snia/cdmi/v1/CDMIAsyncApi.java deleted file mode 100644 index 8be45e56bd..0000000000 --- a/labs/cdmi/src/main/java/org/jclouds/snia/cdmi/v1/CDMIAsyncApi.java +++ /dev/null @@ -1,67 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.snia.cdmi.v1; - -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; - -import org.jclouds.rest.annotations.Delegate; -import org.jclouds.snia.cdmi.v1.features.ContainerAsyncApi; -import org.jclouds.snia.cdmi.v1.features.DataAsyncApi; -import org.jclouds.snia.cdmi.v1.features.DataNonCDMIContentTypeAsyncApi; -import org.jclouds.snia.cdmi.v1.features.DomainAsyncApi; - -/** - * Provides asynchronous access to CDMI via their REST API. - *

- * - * @see CDMIApi - * @see api doc - * @author Adrian Cole - */ -public interface CDMIAsyncApi { - - /** - * Provides asynchronous access to Domain Object Resource Operations. - */ - @Delegate - DomainAsyncApi getDomainApi(); - - /** - * Provides asynchronous access to Container Object Resource Operations. - */ - @Delegate - ContainerAsyncApi getApi(); - - /** - * Provides asynchronous access to Data Object Resource Operations. - */ - @Delegate - @Path("/{containerName}") - DataAsyncApi getDataApiForContainer(@PathParam("containerName") String containerName); - - /** - * Provides asynchronous access to Data Object Resource Operations. - */ - @Delegate - @Path("/{containerName}") - DataNonCDMIContentTypeAsyncApi getDataNonCDMIContentTypeApiForContainer( - @PathParam("containerName") String containerName); - -} diff --git a/labs/cdmi/src/main/java/org/jclouds/snia/cdmi/v1/ObjectTypes.java b/labs/cdmi/src/main/java/org/jclouds/snia/cdmi/v1/ObjectTypes.java deleted file mode 100644 index d79f33e278..0000000000 --- a/labs/cdmi/src/main/java/org/jclouds/snia/cdmi/v1/ObjectTypes.java +++ /dev/null @@ -1,29 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.snia.cdmi.v1; - -/** - * Object Types used in CDMI. - * - */ -public interface ObjectTypes { - - public static final String CONTAINER = "application/cdmi-container"; - public static final String DATAOBJECT = "application/cdmi-object"; -} diff --git a/labs/cdmi/src/main/java/org/jclouds/snia/cdmi/v1/binders/BindQueryParmsToSuffix.java b/labs/cdmi/src/main/java/org/jclouds/snia/cdmi/v1/binders/BindQueryParmsToSuffix.java deleted file mode 100644 index 3ea4fa8539..0000000000 --- a/labs/cdmi/src/main/java/org/jclouds/snia/cdmi/v1/binders/BindQueryParmsToSuffix.java +++ /dev/null @@ -1,47 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.snia.cdmi.v1.binders; - -import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.base.Preconditions.checkNotNull; - -import javax.inject.Singleton; - -import org.jclouds.http.HttpRequest; -import org.jclouds.rest.Binder; -import org.jclouds.snia.cdmi.v1.queryparams.CDMIObjectQueryParams; - -/** - * This binding solves the problem jax-rs encoding ? ; : which some servers can not handle - * - * @author Kenneth Nagin - */ -@Singleton -public class BindQueryParmsToSuffix implements Binder { - @SuppressWarnings("unchecked") - @Override - public R bindToRequest(R request, Object input) { - checkArgument(checkNotNull(input, "input") instanceof CDMIObjectQueryParams, - "this binder is only valid for CDMIObjectQueryParams!"); - checkNotNull(request, "request"); - String queryParams = input.toString(); - return (R) request.toBuilder().endpoint(request.getEndpoint() + "?" + queryParams).build(); - } - -} diff --git a/labs/cdmi/src/main/java/org/jclouds/snia/cdmi/v1/config/CDMIProperties.java b/labs/cdmi/src/main/java/org/jclouds/snia/cdmi/v1/config/CDMIProperties.java deleted file mode 100644 index 77beee510e..0000000000 --- a/labs/cdmi/src/main/java/org/jclouds/snia/cdmi/v1/config/CDMIProperties.java +++ /dev/null @@ -1,28 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.snia.cdmi.v1.config; - -/** - * Configuration properties and constants used in SNIA CDMI connections. - * - * @author Adrian Cole - */ -public class CDMIProperties { - -} diff --git a/labs/cdmi/src/main/java/org/jclouds/snia/cdmi/v1/config/CDMIRestClientModule.java b/labs/cdmi/src/main/java/org/jclouds/snia/cdmi/v1/config/CDMIRestClientModule.java deleted file mode 100644 index 161951f66b..0000000000 --- a/labs/cdmi/src/main/java/org/jclouds/snia/cdmi/v1/config/CDMIRestClientModule.java +++ /dev/null @@ -1,66 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.snia.cdmi.v1.config; - -import java.util.Map; - -import org.jclouds.http.HttpErrorHandler; -import org.jclouds.http.annotation.ClientError; -import org.jclouds.http.annotation.Redirection; -import org.jclouds.http.annotation.ServerError; -import org.jclouds.rest.ConfiguresRestClient; -import org.jclouds.rest.config.RestClientModule; -import org.jclouds.snia.cdmi.v1.CDMIApi; -import org.jclouds.snia.cdmi.v1.CDMIAsyncApi; -import org.jclouds.snia.cdmi.v1.features.ContainerApi; -import org.jclouds.snia.cdmi.v1.features.ContainerAsyncApi; -import org.jclouds.snia.cdmi.v1.features.DataApi; -import org.jclouds.snia.cdmi.v1.features.DataAsyncApi; -import org.jclouds.snia.cdmi.v1.features.DataNonCDMIContentTypeApi; -import org.jclouds.snia.cdmi.v1.features.DataNonCDMIContentTypeAsyncApi; -import org.jclouds.snia.cdmi.v1.features.DomainApi; -import org.jclouds.snia.cdmi.v1.features.DomainAsyncApi; -import org.jclouds.snia.cdmi.v1.handlers.CDMIErrorHandler; - -import com.google.common.collect.ImmutableMap; - -/** - * Configures the CDMI connection. - * - * @author Adrian Cole - */ -@ConfiguresRestClient -public class CDMIRestClientModule extends RestClientModule { - - public static final Map, Class> DELEGATE_MAP = ImmutableMap., Class> builder() - .put(DomainApi.class, DomainAsyncApi.class).put(ContainerApi.class, ContainerAsyncApi.class) - .put(DataApi.class, DataAsyncApi.class) - .put(DataNonCDMIContentTypeApi.class, DataNonCDMIContentTypeAsyncApi.class).build(); - - public CDMIRestClientModule() { - super(DELEGATE_MAP); - } - - @Override - protected void bindErrorHandlers() { - bind(HttpErrorHandler.class).annotatedWith(Redirection.class).to(CDMIErrorHandler.class); - bind(HttpErrorHandler.class).annotatedWith(ClientError.class).to(CDMIErrorHandler.class); - bind(HttpErrorHandler.class).annotatedWith(ServerError.class).to(CDMIErrorHandler.class); - } -} diff --git a/labs/cdmi/src/main/java/org/jclouds/snia/cdmi/v1/domain/CDMIObject.java b/labs/cdmi/src/main/java/org/jclouds/snia/cdmi/v1/domain/CDMIObject.java deleted file mode 100644 index d422e28d0d..0000000000 --- a/labs/cdmi/src/main/java/org/jclouds/snia/cdmi/v1/domain/CDMIObject.java +++ /dev/null @@ -1,289 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.snia.cdmi.v1.domain; - -import static com.google.common.base.Objects.equal; -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -import org.jclouds.domain.JsonBall; -import org.jclouds.javax.annotation.Nullable; - -import com.google.common.base.Objects; -import com.google.common.base.Objects.ToStringHelper; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.Lists; -import com.google.common.collect.Maps; - -/** - * The base type for all objects in the CDMI model. - * - * @author Kenneth Nagin - */ -public class CDMIObject { - - public static Builder builder() { - return new ConcreteBuilder(); - } - - public Builder toBuilder() { - return builder().fromCDMIObject(this); - } - - private static class ConcreteBuilder extends Builder { - } - - public abstract static class Builder> { - private String objectID; - private String objectType; - private String objectName; - private String parentURI; - - private Map metadata = Maps.newHashMap(); - - /** - * @see DataObject#getMetadata() - */ - public B metadata(Map metadata) { - this.metadata = ImmutableMap.copyOf(checkNotNull(metadata, "metadata")); - return self(); - } - - @SuppressWarnings("unchecked") - protected B self() { - return (B) this; - } - - /** - * @see CDMIObject#getObjectID() - */ - public B objectID(String objectID) { - this.objectID = objectID; - return self(); - } - - /** - * @see CDMIObject#getObjectType() - */ - public B objectType(String objectType) { - this.objectType = objectType; - return self(); - } - - /** - * @see CDMIObject#getObjectName() - */ - public B objectName(String objectName) { - this.objectName = objectName; - return self(); - } - - /** - * @see CDMIObject#getParentURI() - */ - public B parentURI(String parentURI) { - this.parentURI = parentURI; - return self(); - } - - public CDMIObject build() { - return new CDMIObject(this); - } - - protected B fromCDMIObject(CDMIObject in) { - return objectID(in.getObjectID()).objectType(in.getObjectType()).objectName(in.getObjectName()) - .parentURI(in.getParentURI()).metadata(in.getMetadata()); - } - } - - private final String objectID; - private final String objectType; - private final String objectName; - private String parentURI; - private final Map metadata; - private Map userMetaDataIn; - private Map systemMetaDataIn; - private List> aclMetaDataIn; - - protected CDMIObject(Builder builder) { - this.objectID = checkNotNull(builder.objectID, "objectID"); - this.objectType = checkNotNull(builder.objectType, "objectType"); - this.objectName = builder.objectName; - this.parentURI = checkNotNull(builder.parentURI, "parentURI"); - this.metadata = ImmutableMap.copyOf(checkNotNull(builder.metadata, "metadata")); - } - - /** - * Object ID of the object
- * Every object stored within a CDMI-compliant system shall have a globally unique object - * identifier (ID) assigned at creation time. The CDMI object ID is a string with requirements - * for how it is generated and how it obtains its uniqueness. Each offering that implements CDMI - * is able to produce these identifiers without conflicting with other offerings. - * - * note: CDMI Servers do not always support ObjectID tags, however downstream jclouds code does - * not handle null so we return a empty String instead. - */ - public String getObjectID() { - return (objectID == null) ? "" : objectID; - } - - /** - * - * type of the object - */ - public String getObjectType() { - return objectType; - } - - /** - * For objects in a container, the objectName field shall be returned. For objects not in a - * container (objects that are only accessible by ID), the objectName field shall not be - * returned. - * - * Name of the object - */ - @Nullable - public String getObjectName() { - return (objectName == null) ? "" : objectName; - } - - /** - * - * parent URI - */ - public String getParentURI() { - return parentURI; - } - - /** - * Metadata for the CDMI object. This field includes any user and system metadata specified in - * the request body metadata field, along with storage system metadata generated by the cloud - * storage system. - */ - public Map getMetadata() { - return metadata; - } - - /** - * Parse Metadata for the container object from the original JsonBall. System metadata data is - * prefixed with cdmi. System ACL metadata data is prefixed with cdmi_acl - * - */ - private void parseMetadata() { - userMetaDataIn = Maps.newHashMap(); - systemMetaDataIn = Maps.newHashMap(); - aclMetaDataIn = Lists.newArrayList(); - for (Map.Entry entry : metadata.entrySet()) { - String key = entry.getKey(); - JsonBall value = entry.getValue(); - if (key.startsWith("cdmi")) { - if (key.matches("cdmi_acl")) { - String[] cdmi_acl_array = value.toString().split("[{}]"); - for (int i = 0; i < cdmi_acl_array.length; i++) { - if (!(cdmi_acl_array[i].startsWith("[") || cdmi_acl_array[i].startsWith("]") || cdmi_acl_array[i] - .startsWith(","))) { - Map aclMap = Maps.newHashMap(); - String[] cdmi_acl_member = cdmi_acl_array[i].split(","); - for (String s : cdmi_acl_member) { - String cdmi_acl_key = s.substring(0, s.indexOf(":")); - String cdmi_acl_value = s.substring(s.indexOf(":") + 1); - cdmi_acl_value = cdmi_acl_value.replace('"', ' ').trim(); - aclMap.put(cdmi_acl_key, cdmi_acl_value); - } - aclMetaDataIn.add(aclMap); - } - } - } else { - systemMetaDataIn.put(key, value.toString().replace('"', ' ').trim()); - } - } else { - userMetaDataIn.put(key, value.toString().replace('"', ' ').trim()); - } - } - } - - /** - * Get User Metadata for the container object. This field includes any user metadata - */ - public Map getUserMetadata() { - if (userMetaDataIn == null) { - parseMetadata(); - } - return userMetaDataIn; - } - - /** - * Get System Metadata for the container object excluding ACL related metadata - */ - public Map getSystemMetadata() { - if (systemMetaDataIn == null) { - parseMetadata(); - } - return systemMetaDataIn; - } - - /** - * Get System Metadata for the container object excluding ACL related metadata - */ - public List> getACLMetadata() { - if (aclMetaDataIn == null) { - parseMetadata(); - } - return aclMetaDataIn; - } - - @Override - public boolean equals(Object o) { - if (this == o) - return true; - if (o == null || getClass() != o.getClass()) - return false; - CDMIObject that = CDMIObject.class.cast(o); - return equal(this.objectID, that.objectID) && equal(this.objectName, that.objectName) - && equal(this.objectType, that.objectType) && equal(this.parentURI, that.parentURI) - && equal(this.metadata, that.metadata); - } - - public boolean clone(Object o) { - if (this == o) - return false; - if (o == null || getClass() != o.getClass()) - return false; - CDMIObject that = CDMIObject.class.cast(o); - return equal(this.objectType, that.objectType); - } - - @Override - public int hashCode() { - return Objects.hashCode(objectID, objectName, objectType, parentURI, metadata); - } - - @Override - public String toString() { - return string().toString(); - } - - protected ToStringHelper string() { - return Objects.toStringHelper("").add("objectID", objectID).add("objectName", objectName) - .add("objectType", objectType).add("parentURI", parentURI).add("metadata", metadata); - } -} diff --git a/labs/cdmi/src/main/java/org/jclouds/snia/cdmi/v1/domain/Container.java b/labs/cdmi/src/main/java/org/jclouds/snia/cdmi/v1/domain/Container.java deleted file mode 100644 index 852a34aa0b..0000000000 --- a/labs/cdmi/src/main/java/org/jclouds/snia/cdmi/v1/domain/Container.java +++ /dev/null @@ -1,112 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.snia.cdmi.v1.domain; - -import static com.google.common.base.Objects.equal; -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.Set; - -import com.google.common.base.Objects; -import com.google.common.base.Objects.ToStringHelper; -import com.google.common.collect.ImmutableSet; - -/** - * - * @author Kenneth Nagin - */ -public class Container extends CDMIObject { - - public static Builder builder() { - return new ConcreteBuilder(); - } - - @Override - public Builder toBuilder() { - return builder().fromContainer(this); - } - - public static class Builder> extends CDMIObject.Builder { - - private Set children = ImmutableSet.of(); - - /** - * @see Container#getChildren() - */ - public B children(String... children) { - return children(ImmutableSet.copyOf(checkNotNull(children, "children"))); - } - - /** - * @see Container#getChildren() - */ - public B children(Set children) { - this.children = ImmutableSet.copyOf(checkNotNull(children, "children")); - return self(); - } - - @Override - public Container build() { - return new Container(this); - } - - public B fromContainer(Container in) { - return fromCDMIObject(in).children(in.getChildren()); - // .metadata(in.getMetadata()); - } - } - - private static class ConcreteBuilder extends Builder { - } - - private final Set children; - - protected Container(Builder builder) { - super(builder); - this.children = ImmutableSet.copyOf(checkNotNull(builder.children, "children")); - } - - /** - * Names of the children objects in the container object. Child container objects end with "/". - */ - public Set getChildren() { - return children; - } - - @Override - public boolean equals(Object o) { - if (this == o) - return true; - if (o == null || getClass() != o.getClass()) - return false; - Container that = Container.class.cast(o); - return super.equals(that) && equal(this.children, that.children); - } - - @Override - public int hashCode() { - return Objects.hashCode(super.hashCode(), children); - } - - @Override - public ToStringHelper string() { - return super.string().add("children", children); - } - -} diff --git a/labs/cdmi/src/main/java/org/jclouds/snia/cdmi/v1/domain/DataObject.java b/labs/cdmi/src/main/java/org/jclouds/snia/cdmi/v1/domain/DataObject.java deleted file mode 100644 index bb98edbd70..0000000000 --- a/labs/cdmi/src/main/java/org/jclouds/snia/cdmi/v1/domain/DataObject.java +++ /dev/null @@ -1,193 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.snia.cdmi.v1.domain; - -import static com.google.common.base.Objects.equal; -import static com.google.common.base.Preconditions.checkNotNull; - -import java.io.ByteArrayInputStream; -import java.io.File; -import java.io.IOException; -import java.nio.charset.Charset; - -import com.google.common.base.Charsets; -import com.google.common.base.Objects; -import com.google.common.base.Objects.ToStringHelper; -import com.google.common.io.ByteStreams; -import com.google.common.io.Files; -import com.google.common.io.InputSupplier; - -/** - * - * @author Kenneth Nagin - */ -public class DataObject extends CDMIObject { - - public static Builder builder() { - return new ConcreteBuilder(); - } - - @Override - public Builder toBuilder() { - return builder().fromDataObject(this); - } - - public static class Builder> extends CDMIObject.Builder { - private String mimetype = ""; - private String value = ""; - - /** - * @see DataObject#getMimetype() - */ - public B mimetype(String mimetype) { - this.mimetype = mimetype; - return self(); - } - - /** - * @see DataObject#getValueAsString() - */ - public B value(String value) { - this.value = value; - return self(); - } - - @Override - public DataObject build() { - return new DataObject(this); - } - - public B fromDataObject(DataObject in) { - return fromCDMIObject(in).mimetype(in.getMimetype()); - } - } - - private static class ConcreteBuilder extends Builder { - } - - private final String mimetype; - private final String value; - - protected DataObject(Builder builder) { - super(builder); - this.mimetype = checkNotNull(builder.mimetype, "mimetype"); - this.value = checkNotNull(builder.value, "value"); - } - - /** - * get dataObject's mimetype. - */ - public String getMimetype() { - return mimetype; - } - - /** - * get dataObject's value as a String - */ - public String getValueAsString() { - return value; - } - - /** - * get dataObject's value as a InputStream value character set is Charsets.UTF_8 - * - * @return value - */ - public InputSupplier getValueAsInputSupplier() { - return ByteStreams.newInputStreamSupplier(value.getBytes(Charsets.UTF_8)); - } - - /** - * get dataObject's value as a InputStream - * - * @param charset - * value character set - * @return value - */ - public InputSupplier getValueAsInputSupplier(Charset charset) { - return ByteStreams.newInputStreamSupplier(value.getBytes(charset)); - } - - /** - * get dataObject's value as a ByteArray value character set is Charsets.UTF_8 - * - * @return value - */ - public byte[] getValueAsByteArray() { - return value.getBytes(Charsets.UTF_8); - } - - /** - * get dataObject's value as a InputStream - * - * @param charset - * value character set - * @return value - */ - public byte[] getValueAsByteArray(Charset charset) { - return value.getBytes(charset); - } - - /** - * get dataObject's value as a File value character set is Charsets.UTF_8 - * - * @param destDir - * destination directory - * @return value - */ - public File getValueAsFile(File destDir) throws IOException { - File fileOut = new File(destDir, this.getObjectName()); - Files.copy(getValueAsInputSupplier(), fileOut); - return fileOut; - } - - /** - * get dataObject's value as a File - * - * @param charset - * value character set - * @return value - */ - public File getValueAsFile(File destDir, Charset charset) throws IOException { - File fileOut = new File(destDir, this.getObjectName()); - Files.copy(getValueAsInputSupplier(charset), fileOut); - return fileOut; - } - - @Override - public boolean equals(Object o) { - if (this == o) - return true; - if (o == null || getClass() != o.getClass()) - return false; - DataObject that = DataObject.class.cast(o); - return super.equals(that) && equal(this.mimetype, that.mimetype) && equal(this.value, that.value); - } - - @Override - public int hashCode() { - return Objects.hashCode(super.hashCode(), mimetype, value); - } - - @Override - public ToStringHelper string() { - return super.string().add("mimetype", mimetype); - } - -} diff --git a/labs/cdmi/src/main/java/org/jclouds/snia/cdmi/v1/features/ContainerApi.java b/labs/cdmi/src/main/java/org/jclouds/snia/cdmi/v1/features/ContainerApi.java deleted file mode 100644 index 0ba1efa270..0000000000 --- a/labs/cdmi/src/main/java/org/jclouds/snia/cdmi/v1/features/ContainerApi.java +++ /dev/null @@ -1,113 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.snia.cdmi.v1.features; - -import org.jclouds.snia.cdmi.v1.domain.Container; -import org.jclouds.snia.cdmi.v1.options.CreateContainerOptions; -import org.jclouds.snia.cdmi.v1.queryparams.ContainerQueryParams; - -/** - * CDMI Container Object Resource Operations - * - * @see ContainerAsyncApi - * @author Kenneth Nagin - * @see api doc - */ -public interface ContainerApi { - - /** - * get CDMI Container - * - * @param containerName - * containerName must end with a forward slash, /. - * @return Container - * - *

-    *  Examples: 
-    *  {@code
-    *  container = get("myContainer/");
-    *  container = get("parentContainer/childContainer/");
-    * }
-    * 
-    *         
-    */
-   Container get(String containerName);
-
-   /**
-    * get CDMI Container
-    * 
-    * @param containerName
-    * @param queryParams
-    *           enables getting only certain fields, metadata, children range
-    * @return Container
-    * 
-    *         
-    * Examples: 
-    * {@code
-    * container = get("myContainer/",ContainerQueryParams.Builder.mimetype("text/plain").field("objectName"))
-    * container = get("myContainer/",ContainerQueryParams.Builder.metadata().field("objectName"))
-    * }
-    * 
- * @see ContainerQueryParams - */ - Container get(String containerName, ContainerQueryParams queryParams); - - /** - * Create CDMI Container - * - * @param containerName - * containerName must end with a forward slash, /. - * @return Container - * - *
-    *  Examples: 
-    *  {@code
-    *  container = create("myContainer/");
-    *  container = create("parentContainer/childContainer/");
-    *  }
-    * 
- */ - Container create(String containerName); - - /** - * Create CDMI Container - * - * @param containerName - * @param options - * enables adding metadata - * @return Container - * - *
-    *  Examples: 
-    *  {@code
-    *  container = create("myContainer/",CreateContainerOptions.Builder..metadata(metaDataIn));
-    *  }
-    * 
- * @see CreateContainerOptions - */ - Container create(String containerName, CreateContainerOptions... options); - - /** - * Delete CDMI Container - * - * @param containerName - */ - void delete(String containerName); - -} diff --git a/labs/cdmi/src/main/java/org/jclouds/snia/cdmi/v1/features/ContainerAsyncApi.java b/labs/cdmi/src/main/java/org/jclouds/snia/cdmi/v1/features/ContainerAsyncApi.java deleted file mode 100644 index f2fd1a09b2..0000000000 --- a/labs/cdmi/src/main/java/org/jclouds/snia/cdmi/v1/features/ContainerAsyncApi.java +++ /dev/null @@ -1,159 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.snia.cdmi.v1.features; - -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.core.MediaType; - -import org.jclouds.Fallbacks.NullOnNotFoundOr404; -import org.jclouds.rest.annotations.BinderParam; -import org.jclouds.rest.annotations.Fallback; -import org.jclouds.rest.annotations.Headers; -import org.jclouds.rest.annotations.RequestFilters; -import org.jclouds.snia.cdmi.v1.ObjectTypes; -import org.jclouds.snia.cdmi.v1.binders.BindQueryParmsToSuffix; -import org.jclouds.snia.cdmi.v1.domain.Container; -import org.jclouds.snia.cdmi.v1.filters.BasicAuthenticationAndTenantId; -import org.jclouds.snia.cdmi.v1.filters.StripExtraAcceptHeader; -import org.jclouds.snia.cdmi.v1.options.CreateContainerOptions; -import org.jclouds.snia.cdmi.v1.queryparams.ContainerQueryParams; - -import com.google.common.util.concurrent.ListenableFuture; - -/** - * CDMI Container Object Resource Operations - * - * @see ContainerApi - * @author Kenneth Nagin - * @see api doc - */ -@RequestFilters({ BasicAuthenticationAndTenantId.class, StripExtraAcceptHeader.class }) -@Headers(keys = "X-CDMI-Specification-Version", values = "{jclouds.api-version}") -public interface ContainerAsyncApi { - - /** - * get CDMI Container - * - * @param containerName - * containerName must end with a forward slash, /. - * @return Container - * - *
-    *  Examples: 
-    *  {@code
-    *  container = get("myContainer/");
-    *  container = get("parentContainer/childContainer/");
-    * }
-    * 
-    *         
-    */
-   @GET
-   @Consumes({ ObjectTypes.CONTAINER, MediaType.APPLICATION_JSON })
-   @Fallback(NullOnNotFoundOr404.class)
-   @Path("/{containerName}")
-   ListenableFuture get(@PathParam("containerName") String containerName);
-
-   /**
-    * get CDMI Container
-    * 
-    * @param containerName
-    * @param queryParams
-    *           enables getting only certain fields, metadata, children range
-    * @return Container
-    * 
-    *         
-    * Examples: 
-    * {@code
-    * container = get("myContainer/",ContainerQueryParams.Builder.field("parentURI").field("objectName"))
-    * container = get("myContainer/",ContainerQueryParams.Builder.metadata().field("objectName"))
-    * }
-    * 
- * @see ContainerQueryParams - */ - @GET - @Consumes({ ObjectTypes.CONTAINER, MediaType.APPLICATION_JSON }) - @Fallback(NullOnNotFoundOr404.class) - @Path("/{containerName}") - ListenableFuture get(@PathParam("containerName") String containerName, - @BinderParam(BindQueryParmsToSuffix.class) ContainerQueryParams queryParams); - - /** - * Create CDMI Container - * - * @param containerName - * containerName must end with a forward slash, /. - * @return Container - * - *
-    *  Examples: 
-    *  {@code
-    *  container = create("myContainer/");
-    *  container = create("parentContainer/childContainer/");
-    *  }
-    * 
- */ - @PUT - @Consumes({ ObjectTypes.CONTAINER, MediaType.APPLICATION_JSON }) - @Produces({ ObjectTypes.CONTAINER }) - @Fallback(NullOnNotFoundOr404.class) - @Path("/{containerName}") - ListenableFuture create(@PathParam("containerName") String containerName); - - /** - * Create CDMI Container - * - * @param containerName - * @param options - * enables adding metadata - * @return Container - * - *
-    *  Examples: 
-    *  {@code
-    *  container = create("myContainer/",CreateContainerOptions.Builder..metadata(metaDataIn));
-    *  }
-    * 
- * @see CreateContainerOptions - */ - @PUT - @Consumes({ ObjectTypes.CONTAINER, MediaType.APPLICATION_JSON }) - @Produces({ ObjectTypes.CONTAINER }) - @Fallback(NullOnNotFoundOr404.class) - @Path("/{containerName}") - ListenableFuture create(@PathParam("containerName") String containerName, - CreateContainerOptions... options); - - /** - * Delete Container - * - * @param containerName - */ - @DELETE - @Consumes(MediaType.APPLICATION_JSON) - @Fallback(NullOnNotFoundOr404.class) - @Path("/{containerName}") - ListenableFuture delete(@PathParam("containerName") String containerName); - -} diff --git a/labs/cdmi/src/main/java/org/jclouds/snia/cdmi/v1/features/DataApi.java b/labs/cdmi/src/main/java/org/jclouds/snia/cdmi/v1/features/DataApi.java deleted file mode 100644 index e7ebea1b28..0000000000 --- a/labs/cdmi/src/main/java/org/jclouds/snia/cdmi/v1/features/DataApi.java +++ /dev/null @@ -1,115 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.snia.cdmi.v1.features; - -import org.jclouds.snia.cdmi.v1.domain.DataObject; -import org.jclouds.snia.cdmi.v1.options.CreateDataObjectOptions; -import org.jclouds.snia.cdmi.v1.queryparams.DataObjectQueryParams; - -/** - * Data Object Resource Operations - * - * @see DataAsyncApi - * @author Kenneth Nagin - * @see api doc - */ -public interface DataApi { - /** - * get CDMI Data object - * - * - * @param dataObjectName - * dataObjectName must not end with a forward slash, /. - * @return DataObject - * - *
-    *  Examples: 
-    *  {@code
-    *  dataObject = get("myDataObject");
-    *  dataObject = get("parentContainer/childContainer","myDataObject");
-    * }
-    * 
-    *         
-    */
-   DataObject get(String dataObjectName);
-
-   /**
-    * get CDMI Data object
-    * 
-    * 
-    * @param dataObjectName
-    *           dataObjectName must not end with a forward slash, /.
-    * @param queryParams
-    *           enables getting only certain fields, metadata, value range
-    * @return DataObject
-    * 
-    *         
-    *  Examples: 
-    *  {@code
-    *  dataObject = get("myDataObject",ContainerQueryParams.Builder.field("parentURI").field("objectName"));
-    *  dataObject = get("myDataObject",ContainerQueryParams.Builder.value(0,10));
-    * }
-    * 
-    *         
-    */
-   DataObject get(String dataObjectName, DataObjectQueryParams queryParams);
-
-   /**
-    * create CDMI Data object
-    * 
-    * 
-    * @param dataObjectName
-    *           dataObjectName must not end with a forward slash, /.
-    * @param options
-    *           enables defining the body i.e. metadata, mimetype, value
-    * @return DataObject
-    * 
-    *         
-    *  Examples: 
-    *  {@code
-    *  dataObject = create(
-    *                                "myDataObject",
-    *                                CreateDataObjectOptions.Builder
-    *                                                    .value(value)
-    *                                                    .mimetype("text/plain")
-    *                                                    .metadata(pDataObjectMetaDataIn);
-    * }
-    * 
-    *         
-    */
-   DataObject create(String dataObjectName, CreateDataObjectOptions... options);
-
-   /**
-    * delete CDMI Data object
-    * 
-    * 
-    * @param dataObjectName
-    *           dataObjectName must not end with a forward slash, /.
-    * 
-    *           
-    *  Examples: 
-    *  {@code
-    *  delete("myDataObject");
-    * }
-    * 
-    *           
-    */
-   void delete(String dataObjectName);
-
-}
diff --git a/labs/cdmi/src/main/java/org/jclouds/snia/cdmi/v1/features/DataAsyncApi.java b/labs/cdmi/src/main/java/org/jclouds/snia/cdmi/v1/features/DataAsyncApi.java
deleted file mode 100644
index 8a1ec07764..0000000000
--- a/labs/cdmi/src/main/java/org/jclouds/snia/cdmi/v1/features/DataAsyncApi.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/**
- * Licensed to jclouds, Inc. (jclouds) under one or more
- * contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  jclouds licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.jclouds.snia.cdmi.v1.features;
-
-import javax.ws.rs.Consumes;
-import javax.ws.rs.DELETE;
-import javax.ws.rs.GET;
-import javax.ws.rs.PUT;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.core.MediaType;
-
-import org.jclouds.Fallbacks.NullOnNotFoundOr404;
-import org.jclouds.rest.annotations.BinderParam;
-import org.jclouds.rest.annotations.Fallback;
-import org.jclouds.rest.annotations.Headers;
-import org.jclouds.rest.annotations.RequestFilters;
-import org.jclouds.snia.cdmi.v1.ObjectTypes;
-import org.jclouds.snia.cdmi.v1.binders.BindQueryParmsToSuffix;
-import org.jclouds.snia.cdmi.v1.domain.DataObject;
-import org.jclouds.snia.cdmi.v1.filters.BasicAuthenticationAndTenantId;
-import org.jclouds.snia.cdmi.v1.filters.StripExtraAcceptHeader;
-import org.jclouds.snia.cdmi.v1.options.CreateDataObjectOptions;
-import org.jclouds.snia.cdmi.v1.queryparams.DataObjectQueryParams;
-
-import com.google.common.util.concurrent.ListenableFuture;
-
-/**
- * Data Object Resource Operations
- * 
- * @see DataApi
- * @author Kenneth Nagin
- * @see api doc
- */
-@RequestFilters({ BasicAuthenticationAndTenantId.class, StripExtraAcceptHeader.class })
-@Headers(keys = "X-CDMI-Specification-Version", values = "{jclouds.api-version}")
-public interface DataAsyncApi {
-   /**
-    * @see DataApi#get(String dataObjectName)
-    */
-   @GET
-   @Consumes({ ObjectTypes.DATAOBJECT, MediaType.APPLICATION_JSON })
-   @Fallback(NullOnNotFoundOr404.class)
-   @Path("/{dataObjectName}")
-   ListenableFuture get(@PathParam("dataObjectName") String dataObjectName);
-
-   /**
-    * @see DataApi#get(String dataObjectName, DataObjectQueryParams queryParams)
-    */
-   @GET
-   @Consumes({ ObjectTypes.DATAOBJECT, MediaType.APPLICATION_JSON })
-   @Fallback(NullOnNotFoundOr404.class)
-   @Path("/{dataObjectName}")
-   ListenableFuture get(@PathParam("dataObjectName") String dataObjectName,
-            @BinderParam(BindQueryParmsToSuffix.class) DataObjectQueryParams queryParams);
-
-   /**
-    * @see DataApi#create(String dataObjectName, CreateDataObjectOptions... options)
-    */
-   @PUT
-   @Consumes({ ObjectTypes.DATAOBJECT, MediaType.APPLICATION_JSON })
-   @Produces({ ObjectTypes.DATAOBJECT })
-   @Fallback(NullOnNotFoundOr404.class)
-   @Path("/{dataObjectName}")
-   ListenableFuture create(@PathParam("dataObjectName") String dataObjectName,
-            CreateDataObjectOptions... options);
-
-   /**
-    * @see DataApi#delete(String dataObjectName)
-    */
-   @DELETE
-   @Consumes(MediaType.TEXT_PLAIN)
-   // note: MediaType.APPLICATION_JSON work also, however without consumes
-   // jclouds throws null exception
-   @Fallback(NullOnNotFoundOr404.class)
-   @Path("/{dataObjectName}")
-   ListenableFuture delete(@PathParam("dataObjectName") String dataObjectName);
-
-}
diff --git a/labs/cdmi/src/main/java/org/jclouds/snia/cdmi/v1/features/DataNonCDMIContentTypeApi.java b/labs/cdmi/src/main/java/org/jclouds/snia/cdmi/v1/features/DataNonCDMIContentTypeApi.java
deleted file mode 100644
index cd3a4586b4..0000000000
--- a/labs/cdmi/src/main/java/org/jclouds/snia/cdmi/v1/features/DataNonCDMIContentTypeApi.java
+++ /dev/null
@@ -1,192 +0,0 @@
-/**
- * Licensed to jclouds, Inc. (jclouds) under one or more
- * contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  jclouds licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.jclouds.snia.cdmi.v1.features;
-
-import org.jclouds.io.Payload;
-import org.jclouds.snia.cdmi.v1.domain.DataObject;
-import org.jclouds.snia.cdmi.v1.queryparams.DataObjectQueryParams;
-
-/**
- * Data Object Resource Operations
- * 
- * @see DataNonCDMIContentTypeAsyncApi
- * @author Kenneth Nagin
- * @see api doc
- */
-public interface DataNonCDMIContentTypeApi {
-   /**
-    * get CDMI Data object
-    * 
-    * @param containerName
-    *           containerName must end with a forward slash, /.
-    * @param dataObjectName
-    *           dataObjectName must not end with a forward slash, /.
-    * @return DataObjectNonCDMIContentType
-    * 
-    *         
-    *  Examples: 
-    *  {@code
-    *  dataObject = get("myDataObject");
-    *  dataObject = get("parentContainer/childContainer/","myDataObject");
-    * }
-    * 
-    * 
-    * @see DataNonCDMIContentTypeAsyncApi#getValue(String dataObjectName)
-    */
-   Payload getValue(String dataObjectName);
-
-   /**
-    * get CDMI Data object
-    * 
-    * @param containerName
-    *           containerName must end with a forward slash, /.
-    * @param dataObjectName
-    *           dataObjectName must not end with a forward slash, /.
-    * @param range
-    *           a valid ranges-specifier (see RFC2616 Section 14.35.1)
-    * @return DataObjectNonCDMIContentType
-    * 
-    *         
-    *  Examples: 
-    *  {@code
-    *  dataObject = get("myDataObject","bytes=0-10");
-    * }
-    * 
-    *         
-    */
-   Payload getValue(String dataObjectName, String range);
-
-   /**
-    * get CDMI Data object
-    * 
-    * @param containerName
-    *           containerName must end with a forward slash, /.
-    * @param dataObjectName
-    *           dataObjectName must not end with a forward slash, /.
-    * @param queryParams
-    *           enables getting only certain fields, metadata, value range
-    * @return DataObject
-    * 
-    *         
-    *  Examples: 
-    *  {@code
-    *  dataObject = get("myDataObject",ContainerQueryParams.Builder.field("parentURI").field("objectName"));
-    *  dataObject = get("myDataObject",ContainerQueryParams.Builder.value(0,10));
-    * }
-    * 
-    *         
-    */
-   DataObject get(String dataObjectName, DataObjectQueryParams queryParams);
-
-   /**
-    * create CDMI Data object Non CDMI Content Type
-    * 
-    * @param containerName
-    *           containerName must end with a forward slash, /.
-    * @param dataObjectName
-    *           dataObjectName must not end with a forward slash, /.
-    * @param payload
-    *           enables defining the body's payload i.e. file, inputStream, String, ByteArray
-    * 
-    *           
-    *  Examples: 
-    *  {@code
-    *  create("myDataObject",new StringPayload("value");
-    *  create("myDataObject",new ByteArrayPayload(bytes);
-    *  create("myDataObject",new FilePayload(myFileIn);
-    *  create("myDataObject",new InputStreamPayload(is);
-    *  
-    *  File f = new File("yellow-flowers.jpg");
-    *  payloadIn = new InputStreamPayload(new FileInputStream(f));
-    *  payloadIn.setContentMetadata(BaseMutableContentMetadata.fromContentMetadata(
-    *            payloadIn.getContentMetadata().toBuilder()
-    *            .contentType(MediaType.JPEG.toString())
-    *            .contentLength(new Long(inFile.length()))
-    *            .build()));
-    *  dataNonCDMIContentTypeApi.create(containerName, f.getName(),
-    * 					payloadIn);
-    * }
-    * 
-    *           
-    */
-   void create(String dataObjectName, Payload payload);
-
-   /**
-    * create CDMI Data object partial Non CDMI Content Type Only part of the object is contained in
-    * the payload and the X-CDMI-Partial header flag is set to true
-    * 
-    * 
-    * 
-    * @param dataObjectName
-    *           dataObjectName must not end with a forward slash, /.
-    * @param payload
-    *           enables defining the body's payload i.e. file, inputStream, String, ByteArray
-    * 
-    *           
-    *  Examples: 
-    *  {@code
-    *  createPartial("myDataObject",new StringPayload("value");
-    *  createPartial("myDataObject",new ByteArrayPayload(bytes);
-    *  createPartial("myDataObject",new FilePayload(myFileIn);
-    *  createPartial("myDataObject",new InputStreamPayload(is);
-    * }
-    * 
-    *           
-    */
-   void createPartial(String dataObjectName, Payload payload);
-
-   /**
-    * create CDMI Data object Non CDMI Content Type
-    * 
-    * @param containerName
-    *           containerName must end with a forward slash, /.
-    * @param dataObjectName
-    *           dataObjectName must not end with a forward slash, /.
-    * @param inputString
-    *           simple string input
-    * 
-    *           
-    *  Examples: 
-    *  {@code
-    *  create("myDataObject",new String("value");
-    * }
-    * 
-    *           
-    */
-   void create(String dataObjectName, String inputString);
-
-   /**
-    * delete CDMI Data object
-    * 
-    * @param containerName
-    *           containerName must end with a forward slash, /.
-    * @param dataObjectName
-    *           dataObjectName must not end with a forward slash, /.
-    * 
-    *           
-    *  Examples: 
-    *  {@code
-    *  delete("myDataObject");
-    * }
-    * 
-    *           
-    */
-   void delete(String dataObjectName);
-
-}
diff --git a/labs/cdmi/src/main/java/org/jclouds/snia/cdmi/v1/features/DataNonCDMIContentTypeAsyncApi.java b/labs/cdmi/src/main/java/org/jclouds/snia/cdmi/v1/features/DataNonCDMIContentTypeAsyncApi.java
deleted file mode 100644
index 91fab00cf0..0000000000
--- a/labs/cdmi/src/main/java/org/jclouds/snia/cdmi/v1/features/DataNonCDMIContentTypeAsyncApi.java
+++ /dev/null
@@ -1,131 +0,0 @@
-/**
- * Licensed to jclouds, Inc. (jclouds) under one or more
- * contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  jclouds licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.jclouds.snia.cdmi.v1.features;
-
-import javax.ws.rs.Consumes;
-import javax.ws.rs.DELETE;
-import javax.ws.rs.GET;
-import javax.ws.rs.HeaderParam;
-import javax.ws.rs.PUT;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.core.MediaType;
-
-import org.jclouds.Fallbacks.NullOnNotFoundOr404;
-import org.jclouds.rest.annotations.BinderParam;
-import org.jclouds.rest.annotations.Fallback;
-import org.jclouds.rest.annotations.Headers;
-import org.jclouds.rest.annotations.Payload;
-import org.jclouds.rest.annotations.PayloadParam;
-import org.jclouds.rest.annotations.RequestFilters;
-import org.jclouds.rest.annotations.ResponseParser;
-import org.jclouds.snia.cdmi.v1.binders.BindQueryParmsToSuffix;
-import org.jclouds.snia.cdmi.v1.domain.DataObject;
-import org.jclouds.snia.cdmi.v1.filters.BasicAuthenticationAndTenantId;
-import org.jclouds.snia.cdmi.v1.filters.StripExtraAcceptHeader;
-import org.jclouds.snia.cdmi.v1.functions.ParseObjectFromHeadersAndHttpContent;
-import org.jclouds.snia.cdmi.v1.queryparams.DataObjectQueryParams;
-
-import com.google.common.util.concurrent.ListenableFuture;
-
-/**
- * Non CDMI Content Type Data Object Resource Operations
- * 
- * @see DataNonCDMIContentTypeApi
- * @see DataAsyncApi
- * @author Kenneth Nagin
- * @see api doc
- */
-@RequestFilters({ BasicAuthenticationAndTenantId.class, StripExtraAcceptHeader.class })
-public interface DataNonCDMIContentTypeAsyncApi {
-   /**
-    * @see DataNonCDMIContentTypeApi#getValue(String dataObjectName)
-    */
-   @GET
-   @Consumes(MediaType.MEDIA_TYPE_WILDCARD)
-   @ResponseParser(ParseObjectFromHeadersAndHttpContent.class)
-   @Fallback(NullOnNotFoundOr404.class)
-   @Path("/{dataObjectName}")
-   ListenableFuture getValue(@PathParam("dataObjectName") String dataObjectName);
-
-   /**
-    * @see DataNonCDMIContentTypeApi#getValue(String dataObjectName, String range )
-    */
-
-   @GET
-   @Consumes(MediaType.MEDIA_TYPE_WILDCARD)
-   @ResponseParser(ParseObjectFromHeadersAndHttpContent.class)
-   @Fallback(NullOnNotFoundOr404.class)
-   @Path("/{dataObjectName}")
-   ListenableFuture getValue(@PathParam("dataObjectName") String dataObjectName,
-            @HeaderParam("Range") String range);
-
-   /**
-    * @see DataNonCDMIContentTypeApi#get(String dataObjectName, DataObjectQueryParams queryParams )
-    */
-   @GET
-   @Consumes(MediaType.APPLICATION_JSON)
-   @Fallback(NullOnNotFoundOr404.class)
-   @Path("/{dataObjectName}")
-   ListenableFuture get(@PathParam("dataObjectName") String dataObjectName,
-            @BinderParam(BindQueryParmsToSuffix.class) DataObjectQueryParams queryParams);
-
-   /**
-    * @see DataNonCDMIContentTypeApi#create(String dataObjectName, org.jclouds.io.Payload payload )
-    */
-   @PUT
-   @Consumes(MediaType.MEDIA_TYPE_WILDCARD)
-   @Fallback(NullOnNotFoundOr404.class)
-   @Path("/{dataObjectName}")
-   ListenableFuture create(@PathParam("dataObjectName") String dataObjectName, org.jclouds.io.Payload payload);
-
-   /**
-    * @see DataNonCDMIContentTypeApi#createPartial(String dataObjectName, org.jclouds.io.Payload
-    *      payload )
-    */
-   @PUT
-   @Consumes(MediaType.MEDIA_TYPE_WILDCARD)
-   @Fallback(NullOnNotFoundOr404.class)
-   @Path("/{dataObjectName}")
-   @Headers(keys = "X-CDMI-Partial", values = "true")
-   ListenableFuture createPartial(@PathParam("dataObjectName") String dataObjectName,
-            org.jclouds.io.Payload payload);
-
-   /**
-    * @see DataNonCDMIContentTypeApi#create(String dataObjectName, String input )
-    */
-   @PUT
-   @Consumes(MediaType.MEDIA_TYPE_WILDCARD)
-   @Produces(MediaType.TEXT_PLAIN)
-   @Fallback(NullOnNotFoundOr404.class)
-   @Path("/{dataObjectName}")
-   @Payload("{input}")
-   ListenableFuture create(@PathParam("dataObjectName") String dataObjectName, @PayloadParam("input") String input);
-
-   /**
-    * @see DataNonCDMIContentTypeApi#delete(String dataObjectName)
-    */
-   @DELETE
-   @Consumes(MediaType.MEDIA_TYPE_WILDCARD)
-   @Fallback(NullOnNotFoundOr404.class)
-   @Path("/{dataObjectName}")
-   ListenableFuture delete(@PathParam("dataObjectName") String dataObjectName);
-
-}
diff --git a/labs/cdmi/src/main/java/org/jclouds/snia/cdmi/v1/features/DomainApi.java b/labs/cdmi/src/main/java/org/jclouds/snia/cdmi/v1/features/DomainApi.java
deleted file mode 100644
index 55b88ebff8..0000000000
--- a/labs/cdmi/src/main/java/org/jclouds/snia/cdmi/v1/features/DomainApi.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/**
- * Licensed to jclouds, Inc. (jclouds) under one or more
- * contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  jclouds licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.jclouds.snia.cdmi.v1.features;
-
-/**
- * Domain Object Resource Operations
- * 
- * @see DomainAsyncApi
- * @author Adrian Cole
- * @see api doc
- */
-public interface DomainApi {
-
-}
diff --git a/labs/cdmi/src/main/java/org/jclouds/snia/cdmi/v1/features/DomainAsyncApi.java b/labs/cdmi/src/main/java/org/jclouds/snia/cdmi/v1/features/DomainAsyncApi.java
deleted file mode 100644
index bd43b025b3..0000000000
--- a/labs/cdmi/src/main/java/org/jclouds/snia/cdmi/v1/features/DomainAsyncApi.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/**
- * Licensed to jclouds, Inc. (jclouds) under one or more
- * contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  jclouds licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.jclouds.snia.cdmi.v1.features;
-
-import org.jclouds.rest.annotations.Headers;
-import org.jclouds.rest.annotations.RequestFilters;
-import org.jclouds.snia.cdmi.v1.filters.BasicAuthenticationAndTenantId;
-import org.jclouds.snia.cdmi.v1.filters.StripExtraAcceptHeader;
-
-/**
- * Domain Object Resource Operations
- * 
- * @see DomainApi
- * @author Adrian Cole
- * @see api doc
- */
-@RequestFilters({ BasicAuthenticationAndTenantId.class, StripExtraAcceptHeader.class })
-@Headers(keys = "X-CDMI-Specification-Version", values = "{jclouds.api-version}")
-public interface DomainAsyncApi {
-
-}
diff --git a/labs/cdmi/src/main/java/org/jclouds/snia/cdmi/v1/filters/BasicAuthenticationAndTenantId.java b/labs/cdmi/src/main/java/org/jclouds/snia/cdmi/v1/filters/BasicAuthenticationAndTenantId.java
deleted file mode 100644
index 7c974fee51..0000000000
--- a/labs/cdmi/src/main/java/org/jclouds/snia/cdmi/v1/filters/BasicAuthenticationAndTenantId.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/**
- * Licensed to jclouds, Inc. (jclouds) under one or more
- * contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  jclouds licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.jclouds.snia.cdmi.v1.filters;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.net.HttpHeaders.AUTHORIZATION;
-import static org.jclouds.http.filters.BasicAuthentication.basic;
-
-import javax.inject.Inject;
-import javax.inject.Singleton;
-
-import org.jclouds.domain.Credentials;
-import org.jclouds.http.HttpException;
-import org.jclouds.http.HttpRequest;
-import org.jclouds.http.HttpRequestFilter;
-import org.jclouds.location.Provider;
-import org.jclouds.rest.AuthorizationException;
-
-import com.google.common.base.Supplier;
-
-/**
- * Uses Basic Authentication to sign the request, and adds the {@code TID} header.
- * 
- * @see 
- * @author Adrian Cole
- * 
- */
-@Singleton
-public class BasicAuthenticationAndTenantId implements HttpRequestFilter {
-   private final Supplier creds;
-
-   @Inject
-   public BasicAuthenticationAndTenantId(@Provider Supplier creds) {
-      this.creds = checkNotNull(creds, "creds");
-   }
-
-   @Override
-   public HttpRequest filter(HttpRequest request) throws HttpException {
-      Credentials currentCreds = checkNotNull(creds.get(), "credential supplier returned null");
-      if (currentCreds.identity.indexOf(':') == -1) {
-         throw new AuthorizationException(String.format("Identity %s does not match format tenantId:username",
-               currentCreds.identity), null);
-      }
-      String tenantId = currentCreds.identity.substring(0, currentCreds.identity.indexOf(':'));
-      String username = currentCreds.identity.substring(currentCreds.identity.indexOf(':') + 1);
-      return request.toBuilder().replaceHeader("TID", tenantId)
-            .replaceHeader(AUTHORIZATION, basic(username, currentCreds.credential)).build();
-   }
-}
diff --git a/labs/cdmi/src/main/java/org/jclouds/snia/cdmi/v1/filters/StripExtraAcceptHeader.java b/labs/cdmi/src/main/java/org/jclouds/snia/cdmi/v1/filters/StripExtraAcceptHeader.java
deleted file mode 100644
index 7380d17768..0000000000
--- a/labs/cdmi/src/main/java/org/jclouds/snia/cdmi/v1/filters/StripExtraAcceptHeader.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/**
- * Licensed to jclouds, Inc. (jclouds) under one or more
- * contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  jclouds licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.jclouds.snia.cdmi.v1.filters;
-
-import javax.inject.Singleton;
-
-import org.jclouds.http.HttpException;
-import org.jclouds.http.HttpRequest;
-import org.jclouds.http.HttpRequestFilter;
-
-/**
- * current CDMI spec doesn't indicate the form of the response. It would be nice, if it could take 2
- * {@code Accept} headers. Until then, let's strip off the mediaType header, which we use to ensure
- * responses are parsed with json.
- * 
- * @author Adrian Cole
- * 
- */
-@Singleton
-public class StripExtraAcceptHeader implements HttpRequestFilter {
-
-   @Override
-   public HttpRequest filter(HttpRequest request) throws HttpException {
-      return request.toBuilder().replaceHeader("Accept", request.getFirstHeaderOrNull("Accept")).build();
-   }
-}
diff --git a/labs/cdmi/src/main/java/org/jclouds/snia/cdmi/v1/functions/ParseObjectFromHeadersAndHttpContent.java b/labs/cdmi/src/main/java/org/jclouds/snia/cdmi/v1/functions/ParseObjectFromHeadersAndHttpContent.java
deleted file mode 100644
index 21b52e3853..0000000000
--- a/labs/cdmi/src/main/java/org/jclouds/snia/cdmi/v1/functions/ParseObjectFromHeadersAndHttpContent.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/**
- * Licensed to jclouds, Inc. (jclouds) under one or more
- * contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  jclouds licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.jclouds.snia.cdmi.v1.functions;
-
-import org.jclouds.http.HttpRequest;
-import org.jclouds.http.HttpResponse;
-import org.jclouds.io.Payload;
-import org.jclouds.rest.InvocationContext;
-
-import com.google.common.base.Function;
-
-/**
- * Parses payload from HTTP response .
- * 
- * @author Kenneth Nagin
- */
-public class ParseObjectFromHeadersAndHttpContent implements Function,
-         InvocationContext {
-
-   public Payload apply(HttpResponse from) {
-      Payload object = from.getPayload();
-      return object;
-   }
-
-   @Override
-   public ParseObjectFromHeadersAndHttpContent setContext(HttpRequest request) {
-      return this;
-   }
-}
diff --git a/labs/cdmi/src/main/java/org/jclouds/snia/cdmi/v1/handlers/CDMIErrorHandler.java b/labs/cdmi/src/main/java/org/jclouds/snia/cdmi/v1/handlers/CDMIErrorHandler.java
deleted file mode 100644
index 30f51c0758..0000000000
--- a/labs/cdmi/src/main/java/org/jclouds/snia/cdmi/v1/handlers/CDMIErrorHandler.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/**
- * Licensed to jclouds, Inc. (jclouds) under one or more
- * contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  jclouds licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.jclouds.snia.cdmi.v1.handlers;
-
-import static org.jclouds.http.HttpUtils.closeClientButKeepContentStream;
-
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import javax.inject.Singleton;
-
-import org.jclouds.blobstore.ContainerNotFoundException;
-import org.jclouds.blobstore.KeyNotFoundException;
-import org.jclouds.http.HttpCommand;
-import org.jclouds.http.HttpErrorHandler;
-import org.jclouds.http.HttpResponse;
-import org.jclouds.http.HttpResponseException;
-import org.jclouds.rest.AuthorizationException;
-
-/**
- * This will parse and set an appropriate exception on the command data.
- * 
- * @author Adrian Cole
- * 
- */
-// TODO: is there error spec someplace? let's type errors, etc.
-@Singleton
-public class CDMIErrorHandler implements HttpErrorHandler {
-   public static final String PREFIX = "^/v[0-9][^/]*/[a-zA-Z]+_[^/]+/";
-   public static final Pattern CONTAINER_PATH = Pattern.compile(PREFIX + "([^/]+)$");
-   public static final Pattern CONTAINER_KEY_PATH = Pattern.compile(PREFIX + "([^/]+)/(.*)");
-
-   public void handleError(HttpCommand command, HttpResponse response) {
-      // it is important to always read fully and close streams
-      byte[] data = closeClientButKeepContentStream(response);
-      String message = data != null ? new String(data) : null;
-
-      Exception exception = message != null ? new HttpResponseException(command, response, message)
-               : new HttpResponseException(command, response);
-      message = message != null ? message : String.format("%s -> %s", command.getCurrentRequest().getRequestLine(),
-               response.getStatusLine());
-      switch (response.getStatusCode()) {
-         case 401:
-            exception = new AuthorizationException(exception.getMessage(), exception);
-            break;
-         case 404:
-            if (!command.getCurrentRequest().getMethod().equals("DELETE")) {
-               String path = command.getCurrentRequest().getEndpoint().getPath();
-               Matcher matcher = CONTAINER_PATH.matcher(path);
-               Exception oldException = exception;
-               if (matcher.find()) {
-                  exception = new ContainerNotFoundException(matcher.group(1), message);
-                  exception.initCause(oldException);
-               } else {
-                  matcher = CONTAINER_KEY_PATH.matcher(path);
-                  if (matcher.find()) {
-                     exception = new KeyNotFoundException(matcher.group(1), matcher.group(2), message);
-                     exception.initCause(oldException);
-                  }
-               }
-            }
-            break;
-      }
-      command.setException(exception);
-   }
-}
diff --git a/labs/cdmi/src/main/java/org/jclouds/snia/cdmi/v1/options/CreateCDMIObjectOptions.java b/labs/cdmi/src/main/java/org/jclouds/snia/cdmi/v1/options/CreateCDMIObjectOptions.java
deleted file mode 100644
index 7fcdfc37b3..0000000000
--- a/labs/cdmi/src/main/java/org/jclouds/snia/cdmi/v1/options/CreateCDMIObjectOptions.java
+++ /dev/null
@@ -1,39 +0,0 @@
-package org.jclouds.snia.cdmi.v1.options;
-
-import java.util.Map;
-import java.util.Map.Entry;
-
-import org.jclouds.http.options.BaseHttpRequestOptions;
-
-import com.google.gson.JsonObject;
-
-/**
- * Contains options supported in the REST API for the CREATE container operation. 

- * - * @author Kenneth Nagin - */ -public class CreateCDMIObjectOptions extends BaseHttpRequestOptions { - protected JsonObject jsonObjectBody = new JsonObject(); - - /** - * A name-value pair to associate with the container as metadata. - */ - public CreateCDMIObjectOptions metadata(Map metadata) { - JsonObject jsonObjectMetadata = new JsonObject(); - if (metadata != null) { - for (Entry entry : metadata.entrySet()) { - jsonObjectMetadata.addProperty(entry.getKey(), entry.getValue()); - } - } - jsonObjectBody.add("metadata", jsonObjectMetadata); - this.payload = jsonObjectBody.toString(); - return this; - } - - public static class Builder { - public static CreateCDMIObjectOptions withMetadata(Map metadata) { - CreateCDMIObjectOptions options = new CreateCDMIObjectOptions(); - return (CreateCDMIObjectOptions) options.metadata(metadata); - } - } -} diff --git a/labs/cdmi/src/main/java/org/jclouds/snia/cdmi/v1/options/CreateContainerOptions.java b/labs/cdmi/src/main/java/org/jclouds/snia/cdmi/v1/options/CreateContainerOptions.java deleted file mode 100644 index de76fe4461..0000000000 --- a/labs/cdmi/src/main/java/org/jclouds/snia/cdmi/v1/options/CreateContainerOptions.java +++ /dev/null @@ -1,26 +0,0 @@ -package org.jclouds.snia.cdmi.v1.options; - -import java.util.Map; - -/** - * Optional Create CDMI Contain options - * - * @author Kenneth Nagin - */ -public class CreateContainerOptions extends CreateCDMIObjectOptions { - /** - * A name-value pair to associate with the container as metadata. - */ - public CreateContainerOptions metadata(Map metadata) { - super.metadata(metadata); - return this; - - } - - public static class Builder { - public static CreateContainerOptions metadata(Map metadata) { - CreateContainerOptions options = new CreateContainerOptions(); - return (CreateContainerOptions) options.metadata(metadata); - } - } -} diff --git a/labs/cdmi/src/main/java/org/jclouds/snia/cdmi/v1/options/CreateDataObjectNonCDMIOptions.java b/labs/cdmi/src/main/java/org/jclouds/snia/cdmi/v1/options/CreateDataObjectNonCDMIOptions.java deleted file mode 100644 index 2e0575072f..0000000000 --- a/labs/cdmi/src/main/java/org/jclouds/snia/cdmi/v1/options/CreateDataObjectNonCDMIOptions.java +++ /dev/null @@ -1,26 +0,0 @@ -package org.jclouds.snia.cdmi.v1.options; - -import org.jclouds.http.options.BaseHttpRequestOptions; - -/** - * Contains options supported in the REST API for the CREATE container operation.

- * - * @author Kenneth Nagin - */ -public class CreateDataObjectNonCDMIOptions extends BaseHttpRequestOptions { - /** - * A name-value pair to associate with the container as metadata. - */ - public CreateDataObjectNonCDMIOptions withStringPayload(String value) { - this.payload = value; - return this; - } - - public static class Builder { - public static CreateDataObjectNonCDMIOptions withStringPayload(String value) { - CreateDataObjectNonCDMIOptions options = new CreateDataObjectNonCDMIOptions(); - return (CreateDataObjectNonCDMIOptions) options.withStringPayload(value); - } - - } -} diff --git a/labs/cdmi/src/main/java/org/jclouds/snia/cdmi/v1/options/CreateDataObjectOptions.java b/labs/cdmi/src/main/java/org/jclouds/snia/cdmi/v1/options/CreateDataObjectOptions.java deleted file mode 100644 index a3f39673b0..0000000000 --- a/labs/cdmi/src/main/java/org/jclouds/snia/cdmi/v1/options/CreateDataObjectOptions.java +++ /dev/null @@ -1,194 +0,0 @@ -package org.jclouds.snia.cdmi.v1.options; - -import java.io.ByteArrayInputStream; -import java.io.DataInputStream; -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.nio.charset.Charset; -import java.util.Map; - -import com.google.common.base.Charsets; -import com.google.common.io.CharStreams; -import com.google.common.io.Files; - -/** - * CreateDataObjectOptions options supported in the REST API for the CREATE CDMI Data Object - * operation.

- * - * @author Kenneth Nagin - */ -public class CreateDataObjectOptions extends CreateCDMIObjectOptions { - - public CreateDataObjectOptions() { - jsonObjectBody.addProperty("value", ""); - } - - /** - * Create CDMI data object with metadata - * - * @param metadata - * @return CreateDataObjectOptions - */ - public CreateDataObjectOptions metadata(Map metadata) { - super.metadata(metadata); - return this; - } - - /** - * Create CDMI data object with mimetype - * - * @param mimetype - * @return CreateDataObjectOptions - */ - public CreateDataObjectOptions mimetype(String mimetype) { - jsonObjectBody.addProperty("mimetype", mimetype); - this.payload = jsonObjectBody.toString(); - return this; - } - - /** - * Create CDMI data object with value equal to empty string - * - * @return CreateDataObjectOptions - */ - public CreateDataObjectOptions value() { - this.payload = jsonObjectBody.toString(); - return this; - } - - /** - * Create CDMI data object with String value - * - * @param value - * String value - * @return CreateDataObjectOptions - */ - public CreateDataObjectOptions value(String value) { - jsonObjectBody.addProperty("value", (value == null) ? "" : value); - this.payload = jsonObjectBody.toString(); - return this; - } - - /** - * Create CDMI data object with byte array value - * - * @param value - * byte array value byte array is converted to a String value - * @return CreateDataObjectOptions - */ - public CreateDataObjectOptions value(byte[] value) throws IOException { - jsonObjectBody.addProperty("value", (value == null) ? "" : new DataInputStream( - new ByteArrayInputStream(value)).readUTF()); - this.payload = jsonObjectBody.toString(); - return this; - } - - /** - * Create CDMI data object with file value - * - * @param value - * File File is converted to a String value with charset UTF_8 - * @return CreateDataObjectOptions - */ - public CreateDataObjectOptions value(File value) throws IOException { - jsonObjectBody.addProperty("value", (value == null) ? "" : Files.toString(value, Charsets.UTF_8)); - this.payload = jsonObjectBody.toString(); - return this; - } - - /** - * Create CDMI data object with file value - * - * @param value - * File - * @param charset - * character set of file File is converted to a String value - * @return CreateDataObjectOptions - */ - public CreateDataObjectOptions value(File value, Charset charset) throws IOException { - jsonObjectBody.addProperty("value", (value == null) ? "" : Files.toString(value, charset)); - this.payload = jsonObjectBody.toString(); - return this; - } - - /** - * Create CDMI data object with InputStream value - * - * @param value - * InputSteam InputSteam is converted to a String value with charset UTF_8 - * @return CreateDataObjectOptions - */ - public CreateDataObjectOptions value(InputStream value) throws IOException { - jsonObjectBody.addProperty("value", - (value == null) ? "" : CharStreams.toString(new InputStreamReader(value, Charsets.UTF_8))); - this.payload = jsonObjectBody.toString(); - return this; - } - - /** - * Create CDMI data object with InputStream value - * - * @param value - * InputSteam - * @param charset - * character set of input stream InputSteam is converted to a String value with charset - * UTF_8 - * @return CreateDataObjectOptions - */ - public CreateDataObjectOptions value(InputStream value, Charset charset) throws IOException { - jsonObjectBody.addProperty("value", - (value == null) ? "" : CharStreams.toString(new InputStreamReader(value, charset))); - this.payload = jsonObjectBody.toString(); - return this; - } - - public static class Builder { - public static CreateDataObjectOptions metadata(Map metadata) { - CreateDataObjectOptions options = new CreateDataObjectOptions(); - return (CreateDataObjectOptions) options.metadata(metadata); - } - - public static CreateDataObjectOptions mimetype(String mimetype) { - CreateDataObjectOptions options = new CreateDataObjectOptions(); - return (CreateDataObjectOptions) options.mimetype(mimetype); - } - - public static CreateDataObjectOptions value() { - CreateDataObjectOptions options = new CreateDataObjectOptions(); - return (CreateDataObjectOptions) options.value(); - } - - public static CreateDataObjectOptions value(String value) { - CreateDataObjectOptions options = new CreateDataObjectOptions(); - return (CreateDataObjectOptions) options.value(value); - } - - public static CreateDataObjectOptions value(byte[] value) throws IOException { - CreateDataObjectOptions options = new CreateDataObjectOptions(); - return (CreateDataObjectOptions) options.value(value); - } - - public static CreateDataObjectOptions value(File value) throws IOException { - CreateDataObjectOptions options = new CreateDataObjectOptions(); - return (CreateDataObjectOptions) options.value(value); - } - - public static CreateDataObjectOptions value(File value, Charset charset) throws IOException { - CreateDataObjectOptions options = new CreateDataObjectOptions(); - return (CreateDataObjectOptions) options.value(value, charset); - } - - public static CreateDataObjectOptions value(InputStream value) throws IOException { - CreateDataObjectOptions options = new CreateDataObjectOptions(); - return (CreateDataObjectOptions) options.value(value); - } - - public static CreateDataObjectOptions value(InputStream value, Charset charset) throws IOException { - CreateDataObjectOptions options = new CreateDataObjectOptions(); - return (CreateDataObjectOptions) options.value(value, charset); - } - - } -} diff --git a/labs/cdmi/src/main/java/org/jclouds/snia/cdmi/v1/options/GetCDMIObjectOptions.java b/labs/cdmi/src/main/java/org/jclouds/snia/cdmi/v1/options/GetCDMIObjectOptions.java deleted file mode 100644 index 5cc4519570..0000000000 --- a/labs/cdmi/src/main/java/org/jclouds/snia/cdmi/v1/options/GetCDMIObjectOptions.java +++ /dev/null @@ -1,79 +0,0 @@ -package org.jclouds.snia.cdmi.v1.options; - -import org.jclouds.http.options.BaseHttpRequestOptions; - -/** - * Optional get CDMI object options Note: We use BaseHttpRequestOptions.pathSuffix to include the - * CDMI query parameters rather than queryParam because the CDMI specification is not - * following the standard usage. This is the summary of the CDMI specification: To read one or more - * requested fields from an existing CDMI container object, one of the following requests shall be - * performed: GET ///?;;... GET - * ///?children:;... GET ///?metadata:;... - * - * For example: GET /MyContainer/?parentURI;children HTTP/1.1 GET - * /MyContainer/?childrenrange;children:0-2 HTTP/1.1 - * - * To read one or more requested fields from an existing data object, one of the following requests - * shall be performed: GET //?;;... - * GET //?value:;... GET //?metadata:;... - * - * @author Kenneth Nagin - */ -public class GetCDMIObjectOptions extends BaseHttpRequestOptions { - - public GetCDMIObjectOptions() { - this.pathSuffix = "?"; - } - - /** - * Get CDMI data object's field - * - * @param fieldname - * @return this - */ - public GetCDMIObjectOptions field(String fieldname) { - this.pathSuffix = this.pathSuffix + fieldname + ";"; - return this; - } - - /** - * Get CDMI data object's metadata - * - * @return this - */ - public GetCDMIObjectOptions metadata() { - this.pathSuffix = this.pathSuffix + "metadata;"; - return this; - } - - /** - * Get CDMI data object's metadata - * - * @param prefix - * @return this - */ - public GetCDMIObjectOptions metadata(String prefix) { - this.pathSuffix = this.pathSuffix + "metadata:" + prefix + ";"; - return this; - } - - public static class Builder { - public static GetCDMIObjectOptions field(String fieldname) { - GetCDMIObjectOptions options = new GetCDMIObjectOptions(); - return (GetCDMIObjectOptions) options.field(fieldname); - } - - public static GetCDMIObjectOptions metadata() { - GetCDMIObjectOptions options = new GetCDMIObjectOptions(); - return (GetCDMIObjectOptions) options.metadata(); - } - - public static GetCDMIObjectOptions metadata(String prefix) { - GetCDMIObjectOptions options = new GetCDMIObjectOptions(); - return (GetCDMIObjectOptions) options.metadata(prefix); - } - - } -} diff --git a/labs/cdmi/src/main/java/org/jclouds/snia/cdmi/v1/options/GetContainerOptions.java b/labs/cdmi/src/main/java/org/jclouds/snia/cdmi/v1/options/GetContainerOptions.java deleted file mode 100644 index ab96e678e3..0000000000 --- a/labs/cdmi/src/main/java/org/jclouds/snia/cdmi/v1/options/GetContainerOptions.java +++ /dev/null @@ -1,95 +0,0 @@ -package org.jclouds.snia.cdmi.v1.options; - -/** - * Optional get CDMI container operations - * - * @author Kenneth Nagin - */ -public class GetContainerOptions extends GetCDMIObjectOptions { - - public GetContainerOptions() { - super(); - } - - /** - * Get CDMI container's field - * - * @param fieldname - * @return this - */ - public GetContainerOptions field(String fieldname) { - super.field(fieldname); - return this; - } - - /** - * Get CDMI container's metadata - * - * @return this - */ - public GetContainerOptions metadata() { - super.metadata(); - return this; - } - - /** - * Get CDMI container's metadata - * - * @param prefix - * @return this - */ - public GetContainerOptions metadata(String prefix) { - super.metadata(prefix); - return this; - } - - /** - * Get CDMI container's children - * - * @return this - */ - public GetContainerOptions children() { - this.pathSuffix = this.pathSuffix + "children;"; - return this; - } - - /** - * Get CDMI container's children in range - * - * @param from - * @param to - * @return this - */ - public GetContainerOptions children(int from, int to) { - this.pathSuffix = this.pathSuffix + "children:" + from + "-" + to + ";"; - return this; - } - - public static class Builder { - public static GetContainerOptions field(String fieldname) { - GetContainerOptions options = new GetContainerOptions(); - return (GetContainerOptions) options.field(fieldname); - } - - public static GetContainerOptions metadata() { - GetContainerOptions options = new GetContainerOptions(); - return (GetContainerOptions) options.metadata(); - } - - public static GetContainerOptions metadata(String prefix) { - GetContainerOptions options = new GetContainerOptions(); - return (GetContainerOptions) options.metadata(prefix); - } - - public static GetContainerOptions children() { - GetContainerOptions options = new GetContainerOptions(); - return (GetContainerOptions) options.children(); - } - - public static GetContainerOptions children(int from, int to) { - GetContainerOptions options = new GetContainerOptions(); - return (GetContainerOptions) options.children(from, to); - } - - } -} diff --git a/labs/cdmi/src/main/java/org/jclouds/snia/cdmi/v1/options/ListContainersOptions.java b/labs/cdmi/src/main/java/org/jclouds/snia/cdmi/v1/options/ListContainersOptions.java deleted file mode 100644 index 6aa1b48aab..0000000000 --- a/labs/cdmi/src/main/java/org/jclouds/snia/cdmi/v1/options/ListContainersOptions.java +++ /dev/null @@ -1,78 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.snia.cdmi.v1.options; - -import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.base.Preconditions.checkState; - -import org.jclouds.http.options.BaseHttpRequestOptions; - -/** - * Contains options supported in the REST API for the GET container operation.

- */ -public class ListContainersOptions extends BaseHttpRequestOptions { - public static final ListContainersOptions NONE = new ListContainersOptions(); - - /** - * Given a string value x, return data names greater in value than the specified marker. - */ - public ListContainersOptions marker(String marker) { - queryParameters.put("marker", checkNotNull(marker, "marker")); - return this; - } - - public String getMarker() { - return getFirstQueryOrNull("marker"); - } - - /** - * For an integer value n, limits the number of results to n values. - */ - public ListContainersOptions limit(int limit) { - checkState(limit >= 0, "limit must be >= 0"); - checkState(limit <= 10000, "limit must be <= 10000"); - queryParameters.put("limit", Integer.toString(limit)); - return this; - } - - public int getLimit() { - String val = getFirstQueryOrNull("limit"); - return val != null ? Integer.valueOf(val) : 10000; - } - - public static class Builder { - - /** - * @see ListContainersOptions#marker(String) - */ - public static ListContainersOptions marker(String marker) { - ListContainersOptions options = new ListContainersOptions(); - return options.marker(marker); - } - - /** - * @see ListContainersOptions#limit(int) - */ - public static ListContainersOptions limit(int limit) { - ListContainersOptions options = new ListContainersOptions(); - return options.limit(limit); - } - - } -} diff --git a/labs/cdmi/src/main/java/org/jclouds/snia/cdmi/v1/queryparams/CDMIObjectQueryParams.java b/labs/cdmi/src/main/java/org/jclouds/snia/cdmi/v1/queryparams/CDMIObjectQueryParams.java deleted file mode 100644 index cfd9f9b153..0000000000 --- a/labs/cdmi/src/main/java/org/jclouds/snia/cdmi/v1/queryparams/CDMIObjectQueryParams.java +++ /dev/null @@ -1,68 +0,0 @@ -package org.jclouds.snia.cdmi.v1.queryparams; - -/** - * Generate CDMI object query parameters Note: The preferred implementation would use jax-rs - * queryParam. However, the CDMI query parameters specification does not conform to jax-rs - * queryParam of key=value separated by &. Rather it follows the form: ?;;.... - * ?metadata:;... ?children:-;... ?value:-;... - * - * @author Kenneth Nagin - */ -public class CDMIObjectQueryParams { - - protected String queryParams = ""; - - public CDMIObjectQueryParams() { - super(); - } - - /** - * Get CDMI data object's field value - * - * @param fieldname - * @return this - */ - public CDMIObjectQueryParams field(String fieldname) { - queryParams = queryParams + fieldname + ";"; - return this; - } - - /** - * Get CDMI data object's metadata - * - * @return this - */ - public CDMIObjectQueryParams metadata() { - queryParams = queryParams + "metadata;"; - return this; - } - - /** - * Get CDMI data object's metadata associated with prefix - * - * @param prefix - * @return this - */ - public CDMIObjectQueryParams metadata(String prefix) { - queryParams = queryParams + "metadata:" + prefix + ";"; - return this; - } - - public static class Builder { - public static CDMIObjectQueryParams field(String fieldname) { - CDMIObjectQueryParams options = new CDMIObjectQueryParams(); - return (CDMIObjectQueryParams) options.field(fieldname); - } - - public static CDMIObjectQueryParams metadata(String prefix) { - CDMIObjectQueryParams options = new CDMIObjectQueryParams(); - return (CDMIObjectQueryParams) options.metadata(prefix); - } - - } - - public String toString() { - return queryParams; - } - -} diff --git a/labs/cdmi/src/main/java/org/jclouds/snia/cdmi/v1/queryparams/ContainerQueryParams.java b/labs/cdmi/src/main/java/org/jclouds/snia/cdmi/v1/queryparams/ContainerQueryParams.java deleted file mode 100644 index fe7a1f045e..0000000000 --- a/labs/cdmi/src/main/java/org/jclouds/snia/cdmi/v1/queryparams/ContainerQueryParams.java +++ /dev/null @@ -1,98 +0,0 @@ -package org.jclouds.snia.cdmi.v1.queryparams; - -/** - * Generate CDMI container query parameters Example: container = - * containerApi.get(containerName,ContainerQueryParams.Builder.field("parentURI")); container = - * containerApi.get(containerName,ContainerQueryParams.Builder.children(0,3)); - * - * @author Kenneth Nagin - */ -public class ContainerQueryParams extends CDMIObjectQueryParams { - - public ContainerQueryParams() { - super(); - } - - /** - * Get CDMI container's field value - * - * @param fieldname - * @return this - */ - public ContainerQueryParams field(String fieldname) { - super.field(fieldname); - return this; - } - - /** - * Get CDMI container's metadata - * - * @return this - */ - public ContainerQueryParams metadata() { - super.metadata(); - return this; - } - - /** - * Get CDMI container's metadata associated with prefix - * - * @param prefix - * @return this - */ - public ContainerQueryParams metadata(String prefix) { - super.metadata(prefix); - return this; - } - - /** - * Get CDMI container's children - * - * @return this - */ - public ContainerQueryParams children() { - queryParams = queryParams + "children;"; - return this; - } - - /** - * Get CDMI container's children within range - * - * @param from - * @param to - * @return this - */ - public ContainerQueryParams children(int from, int to) { - queryParams = queryParams + "children:" + from + "-" + to + ";"; - return this; - } - - public static class Builder { - public static ContainerQueryParams field(String fieldname) { - ContainerQueryParams options = new ContainerQueryParams(); - return (ContainerQueryParams) options.field(fieldname); - } - - public static ContainerQueryParams metadata() { - ContainerQueryParams options = new ContainerQueryParams(); - return (ContainerQueryParams) options.metadata(); - } - - public static ContainerQueryParams metadata(String prefix) { - ContainerQueryParams options = new ContainerQueryParams(); - return (ContainerQueryParams) options.metadata(prefix); - } - - public static ContainerQueryParams children() { - ContainerQueryParams options = new ContainerQueryParams(); - return (ContainerQueryParams) options.children(); - } - - public static ContainerQueryParams children(int from, int to) { - ContainerQueryParams options = new ContainerQueryParams(); - return (ContainerQueryParams) options.children(from, to); - } - - } - -} diff --git a/labs/cdmi/src/main/java/org/jclouds/snia/cdmi/v1/queryparams/DataObjectQueryParams.java b/labs/cdmi/src/main/java/org/jclouds/snia/cdmi/v1/queryparams/DataObjectQueryParams.java deleted file mode 100644 index f7e8fa1823..0000000000 --- a/labs/cdmi/src/main/java/org/jclouds/snia/cdmi/v1/queryparams/DataObjectQueryParams.java +++ /dev/null @@ -1,98 +0,0 @@ -package org.jclouds.snia.cdmi.v1.queryparams; - -/** - * Generate CDMI data object query parameters Example: dataObject = - * dataApi.get(containerName,dataObjectNameIn,DataObjectQueryParams.Builder.field("parentURI")); - * dataObject = dataApi.get(containerName,dataObjectNameIn,DataObjectQueryParams.Builder.value()); - * - * @author Kenneth Nagin - */ -public class DataObjectQueryParams extends CDMIObjectQueryParams { - - public DataObjectQueryParams() { - super(); - } - - /** - * Get CDMI data object's field value - * - * @param fieldname - * @return this - */ - public DataObjectQueryParams field(String fieldname) { - super.field(fieldname); - return this; - } - - /** - * Get CDMI data object's metadata - * - * @return this - */ - public DataObjectQueryParams metadata() { - super.metadata(); - return this; - } - - /** - * Get CDMI data object's metadata associated with prefix - * - * @param prefix - * @return this - */ - public DataObjectQueryParams metadata(String prefix) { - super.metadata(prefix); - return this; - } - - /** - * Get CDMI data object's value with range - * - * @return this - */ - public DataObjectQueryParams value() { - queryParams = queryParams + "value;"; - return this; - } - - /** - * Get CDMI data object's value within range - * - * @param from - * @param to - * @return this - */ - public DataObjectQueryParams value(int from, int to) { - queryParams = queryParams + "value:" + from + "-" + to + ";"; - return this; - } - - public static class Builder { - public static DataObjectQueryParams field(String fieldname) { - DataObjectQueryParams options = new DataObjectQueryParams(); - return (DataObjectQueryParams) options.field(fieldname); - } - - public static DataObjectQueryParams metadata() { - DataObjectQueryParams options = new DataObjectQueryParams(); - return (DataObjectQueryParams) options.metadata(); - } - - public static DataObjectQueryParams metadata(String prefix) { - DataObjectQueryParams options = new DataObjectQueryParams(); - return (DataObjectQueryParams) options.metadata(prefix); - } - - public static DataObjectQueryParams value() { - DataObjectQueryParams options = new DataObjectQueryParams(); - return (DataObjectQueryParams) options.value(); - } - - public static DataObjectQueryParams value(int from, int to) { - DataObjectQueryParams options = new DataObjectQueryParams(); - return (DataObjectQueryParams) options.value(from, to); - } - - } - -} diff --git a/labs/cdmi/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata b/labs/cdmi/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata deleted file mode 100644 index 19b5767f88..0000000000 --- a/labs/cdmi/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata +++ /dev/null @@ -1 +0,0 @@ -org.jclouds.snia.cdmi.v1.CDMIApiMetadata diff --git a/labs/cdmi/src/test/java/org/jclouds/snia/cdmi/v1/CDMIApiMetadataTest.java b/labs/cdmi/src/test/java/org/jclouds/snia/cdmi/v1/CDMIApiMetadataTest.java deleted file mode 100644 index 3a967e51ad..0000000000 --- a/labs/cdmi/src/test/java/org/jclouds/snia/cdmi/v1/CDMIApiMetadataTest.java +++ /dev/null @@ -1,38 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.snia.cdmi.v1; - -import org.jclouds.View; -import org.jclouds.apis.internal.BaseApiMetadataTest; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableSet; -import com.google.common.reflect.TypeToken; - -/** - * - * @author Adrian Cole - */ -@Test(groups = "unit", testName = "CDMIApiMetadataTest") -// public class CDMIApiMetadataTest extends BaseBlobStoreApiMetadataTest { -public class CDMIApiMetadataTest extends BaseApiMetadataTest { - public CDMIApiMetadataTest() { - super(new CDMIApiMetadata(), ImmutableSet.> of()); - } -} diff --git a/labs/cdmi/src/test/java/org/jclouds/snia/cdmi/v1/CDMIErrorHandlerTest.java b/labs/cdmi/src/test/java/org/jclouds/snia/cdmi/v1/CDMIErrorHandlerTest.java deleted file mode 100644 index 6f8acbce5c..0000000000 --- a/labs/cdmi/src/test/java/org/jclouds/snia/cdmi/v1/CDMIErrorHandlerTest.java +++ /dev/null @@ -1,118 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.snia.cdmi.v1; - -import static org.easymock.EasyMock.createMock; -import static org.easymock.EasyMock.expect; -import static org.easymock.EasyMock.replay; -import static org.easymock.EasyMock.reportMatcher; -import static org.easymock.EasyMock.verify; - -import java.net.URI; - -import org.easymock.IArgumentMatcher; -import org.jclouds.blobstore.ContainerNotFoundException; -import org.jclouds.blobstore.KeyNotFoundException; -import org.jclouds.http.HttpCommand; -import org.jclouds.http.HttpRequest; -import org.jclouds.http.HttpResponse; -import org.jclouds.snia.cdmi.v1.handlers.CDMIErrorHandler; -import org.testng.annotations.Test; - -/** - * - * @author Adrian Cole - */ -@Test(groups = "unit", testName = "CDMIErrorHandlerTest") -public class CDMIErrorHandlerTest { - - @Test - public void test404SetsKeyNotFoundExceptionMosso() { - assertCodeMakes("HEAD", - URI.create("http://host/v1/MossoCloudFS_7064cdb1d49d4dcba3c899ac33e8409d/adriancole-blobstore1/key"), - 404, "Not Found", "", KeyNotFoundException.class); - } - - @Test - public void test404SetsKeyNotFoundExceptionCDMI() { - assertCodeMakes( - "HEAD", - URI.create("http://67.202.39.175:8080/v1/AUTH_7064cdb1d49d4dcba3c899ac33e8409d/adriancole-blobstore1/key"), - 404, "Not Found", "", KeyNotFoundException.class); - } - - @Test - public void test404SetsContainerNotFoundExceptionMosso() { - assertCodeMakes("HEAD", - URI.create("http://host/v1/MossoCloudFS_7064cdb1d49d4dcba3c899ac33e8409d/adriancole-blobstore1"), 404, - "Not Found", "", ContainerNotFoundException.class); - } - - @Test - public void test404SetsContainerNotFoundExceptionCDMI() { - assertCodeMakes("HEAD", - URI.create("http://67.202.39.175:8080/v1/AUTH_7064cdb1d49d4dcba3c899ac33e8409d/adriancole-blobstore1"), - 404, "Not Found", "", ContainerNotFoundException.class); - } - - private void assertCodeMakes(String method, URI uri, int statusCode, String message, String content, - Class expected) { - assertCodeMakes(method, uri, statusCode, message, "text/plain", content, expected); - } - - private void assertCodeMakes(String method, URI uri, int statusCode, String message, String contentType, - String content, Class expected) { - - CDMIErrorHandler function = new CDMIErrorHandler(); - - HttpCommand command = createMock(HttpCommand.class); - HttpRequest request = HttpRequest.builder().method(method).endpoint(uri).build(); - HttpResponse response = HttpResponse.builder().statusCode(statusCode).message(message).payload(content).build(); - response.getPayload().getContentMetadata().setContentType(contentType); - - expect(command.getCurrentRequest()).andReturn(request).atLeastOnce(); - command.setException(classEq(expected)); - - replay(command); - - function.handleError(command, response); - - verify(command); - } - - public static Exception classEq(final Class in) { - reportMatcher(new IArgumentMatcher() { - - @Override - public void appendTo(StringBuffer buffer) { - buffer.append("classEq("); - buffer.append(in); - buffer.append(")"); - } - - @Override - public boolean matches(Object arg) { - return arg.getClass() == in; - } - - }); - return null; - } - -} diff --git a/labs/cdmi/src/test/java/org/jclouds/snia/cdmi/v1/features/ContainerApiExpectTest.java b/labs/cdmi/src/test/java/org/jclouds/snia/cdmi/v1/features/ContainerApiExpectTest.java deleted file mode 100644 index 053e8443e7..0000000000 --- a/labs/cdmi/src/test/java/org/jclouds/snia/cdmi/v1/features/ContainerApiExpectTest.java +++ /dev/null @@ -1,60 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.snia.cdmi.v1.features; - -import static com.google.common.base.Charsets.UTF_8; -import static com.google.common.io.BaseEncoding.base64; -import static org.testng.Assert.assertEquals; - -import org.jclouds.http.HttpRequest; -import org.jclouds.http.HttpResponse; -import org.jclouds.snia.cdmi.v1.CDMIApi; -import org.jclouds.snia.cdmi.v1.internal.BaseCDMIApiExpectTest; -import org.jclouds.snia.cdmi.v1.parse.ParseContainerTest; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableMultimap; - -/** - * - * @author Adrian Cole - */ -@Test(groups = "unit", testName = "ContainerAsyncApiTest") -public class ContainerApiExpectTest extends BaseCDMIApiExpectTest { - - public void testGetContainerWhenResponseIs2xx() throws Exception { - - HttpRequest get = HttpRequest - .builder() - .method("GET") - .endpoint("http://localhost:8080/MyContainer/") - .headers(ImmutableMultimap. builder().put("X-CDMI-Specification-Version", "1.0.1") - .put("TID", "tenantId") - .put("Authorization", "Basic " + base64().encode("username:password".getBytes(UTF_8))) - .put("Accept", "application/cdmi-container").build()).build(); - - HttpResponse getResponse = HttpResponse.builder().statusCode(200).payload(payloadFromResource("/container.json")) - .build(); - - CDMIApi apiWhenContainersExist = requestSendsResponse(get, getResponse); - - assertEquals(apiWhenContainersExist.getApi().get("MyContainer/"), new ParseContainerTest().expected()); - } - -} diff --git a/labs/cdmi/src/test/java/org/jclouds/snia/cdmi/v1/features/ContainerApiLiveTest.java b/labs/cdmi/src/test/java/org/jclouds/snia/cdmi/v1/features/ContainerApiLiveTest.java deleted file mode 100644 index 641200b81d..0000000000 --- a/labs/cdmi/src/test/java/org/jclouds/snia/cdmi/v1/features/ContainerApiLiveTest.java +++ /dev/null @@ -1,256 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.snia.cdmi.v1.features; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; - -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.logging.Logger; - -import com.google.common.collect.Maps; - -import org.jclouds.domain.JsonBall; -import org.jclouds.snia.cdmi.v1.ObjectTypes; -import org.jclouds.snia.cdmi.v1.domain.Container; -import org.jclouds.snia.cdmi.v1.internal.BaseCDMIApiLiveTest; -import org.jclouds.snia.cdmi.v1.options.CreateContainerOptions; -import org.jclouds.snia.cdmi.v1.queryparams.ContainerQueryParams; -import org.testng.annotations.Test; - -/** - * - * @author Kenneth Nagin - */ - -@Test(groups = "live", testName = "ContainerApiLiveTest") -public class ContainerApiLiveTest extends BaseCDMIApiLiveTest { - - @Test - public void testCreateContainer() throws Exception { - String pContainerName = "MyContainer" + System.currentTimeMillis() + "/"; - Map pContainerMetaDataIn = Maps.newHashMap(); - pContainerMetaDataIn.put("containerkey1", "value1"); - pContainerMetaDataIn.put("containerkey2", "value2"); - pContainerMetaDataIn.put("containerkey3", "value3"); - - CreateContainerOptions pCreateContainerOptions = CreateContainerOptions.Builder.metadata(pContainerMetaDataIn); - ContainerApi api = cdmiContext.getApi().getApi(); - - Logger.getAnonymousLogger().info("create: " + pContainerName); - - Container container = api.create(pContainerName, pCreateContainerOptions); - assertNotNull(container); - try { - System.out.println(container); - Logger.getAnonymousLogger().info("get: " + pContainerName); - container = api.get(pContainerName); - assertNotNull(container); - System.out.println(container); - assertEquals(container.getObjectType(), ObjectTypes.CONTAINER); - assertNotNull(container.getObjectID()); - assertNotNull(container.getObjectName()); - assertEquals(container.getObjectName(), pContainerName); - assertEquals(container.getParentURI(), "/"); - assertNotNull(container.getChildren()); - assertEquals(container.getChildren().isEmpty(), true); - System.out.println("Children: " + container.getChildren()); - assertNotNull(container.getMetadata()); - System.out.println("Raw metadata: " + container.getMetadata()); - for (Map.Entry entry : container.getMetadata().entrySet()) { - System.out.println(entry.getKey() + ":" + entry.getValue()); - } - assertNotNull(container.getUserMetadata()); - Map pContainerMetaDataOut = container.getUserMetadata(); - for (Map.Entry entry : pContainerMetaDataIn.entrySet()) { - String key = entry.getKey(); - assertEquals(pContainerMetaDataOut.containsKey(key), true); - assertEquals(pContainerMetaDataOut.get(key), entry.getValue()); - } - System.out.println("UserMetaData: " + container.getUserMetadata()); - assertNotNull(container.getSystemMetadata()); - System.out.println("SystemMetaData: " + container.getSystemMetadata()); - assertNotNull(container.getACLMetadata()); - assertEquals(container.getACLMetadata().size(), 3); - List> aclMetadataOut = container.getACLMetadata(); - System.out.println("ACLMetaData: "); - for (Map aclMap : aclMetadataOut) { - System.out.println(aclMap); - } - container = api.get("/"); - System.out.println("root container: " + container); - assertEquals(container.getChildren().contains(pContainerName), true); - System.out.println("adding containers to container"); - String firstParentURI = api.get(pContainerName).getObjectName(); - for (int i = 0; i < 10; i++) { - // container = api.create(firstParentURI+"childcontainer"+i+"/"); - container = api.create(pContainerName + "childcontainer" + i + "/"); - assertNotNull(container); - System.out.println(container); - assertEquals(container.getParentURI(), pContainerName); - assertEquals(container.getObjectName(), "childcontainer" + i + "/"); - container = api.create(container.getParentURI() + container.getObjectName() + "grandchild/"); - assertEquals(container.getParentURI(), pContainerName + "childcontainer" + i + "/"); - assertEquals(container.getObjectName(), "grandchild/"); - System.out.println(container); - } - container = api.get(pContainerName); - assertNotNull(container); - assertNotNull(container.getChildren()); - assertEquals(container.getChildren().size(), 10); - - } finally { - Logger.getAnonymousLogger().info("delete: " + pContainerName); - api.delete(pContainerName); - container = api.get("/"); - System.out.println("root container: " + container); - assertEquals(container.getChildren().contains(pContainerName), false); - } - - } - - @Test - public void testGetContainer() throws Exception { - String pContainerName = "MyContainer" + System.currentTimeMillis() + "/"; - Map pContainerMetaDataIn = Maps.newHashMap(); - pContainerMetaDataIn.put("containerkey1", "value1"); - pContainerMetaDataIn.put("containerkey2", "value2"); - pContainerMetaDataIn.put("containerkey3", "value3"); - CreateContainerOptions pCreateContainerOptions = CreateContainerOptions.Builder.metadata(pContainerMetaDataIn); - ContainerApi api = cdmiContext.getApi().getApi(); - - Logger.getAnonymousLogger().info("create: " + pContainerName); - - Container container = api.create(pContainerName, pCreateContainerOptions); - assertNotNull(container); - try { - System.out.println(container); - Logger.getAnonymousLogger().info("get: " + pContainerName); - container = api.get(pContainerName); - assertNotNull(container); - System.out.println(container); - assertEquals(container.getObjectType(), ObjectTypes.CONTAINER); - assertNotNull(container.getObjectID()); - assertNotNull(container.getObjectName()); - assertEquals(container.getObjectName(), pContainerName); - assertEquals(container.getParentURI(), "/"); - assertNotNull(container.getChildren()); - assertEquals(container.getChildren().isEmpty(), true); - System.out.println("Children: " + container.getChildren()); - assertNotNull(container.getMetadata()); - System.out.println("Raw metadata: " + container.getMetadata()); - for (Map.Entry entry : container.getMetadata().entrySet()) { - System.out.println(entry.getKey() + ":" + entry.getValue()); - } - assertNotNull(container.getUserMetadata()); - Map pContainerMetaDataOut = container.getUserMetadata(); - for (Map.Entry entry : pContainerMetaDataIn.entrySet()) { - String key = entry.getKey(); - assertEquals(pContainerMetaDataOut.containsKey(key), true); - assertEquals(pContainerMetaDataOut.get(key), entry.getValue()); - } - System.out.println("UserMetaData: " + container.getUserMetadata()); - assertNotNull(container.getSystemMetadata()); - System.out.println("SystemMetaData: " + container.getSystemMetadata()); - assertNotNull(container.getACLMetadata()); - List> aclMetadataOut = container.getACLMetadata(); - System.out.println("ACLMetaData: "); - for (Map aclMap : aclMetadataOut) { - System.out.println(aclMap); - } - container = api.get("/"); - System.out.println("root container: " + container); - assertEquals(container.getChildren().contains(pContainerName), true); - container = api.get(pContainerName, ContainerQueryParams.Builder.field("parentURI")); - assertNotNull(container); - assertEquals(container.getParentURI(), "/"); - System.out.println(container); - - container = api.get(pContainerName, ContainerQueryParams.Builder.field("parentURI").field("objectName")); - assertNotNull(container); - assertEquals(container.getParentURI(), "/"); - assertEquals(container.getObjectName(), pContainerName); - - container = api.get(pContainerName, ContainerQueryParams.Builder.metadata()); - assertNotNull(container); - pContainerMetaDataOut = container.getUserMetadata(); - for (Map.Entry entry : pContainerMetaDataIn.entrySet()) { - String key = entry.getKey(); - assertEquals(pContainerMetaDataOut.containsKey(key), true); - assertEquals(pContainerMetaDataOut.get(key), entry.getValue()); - } - System.out.println(container); - - System.out.println("GetContainerOptions.Builder.metadata(cdmi_acl)"); - container = api.get(pContainerName, ContainerQueryParams.Builder.metadata("cdmi_acl")); - assertNotNull(container); - System.out.println(container); - assertNotNull(container.getACLMetadata()); - assertEquals(container.getACLMetadata().size(), 3); - - System.out.println("adding containers to container"); - String firstParentURI = api.get(pContainerName).getObjectName(); - for (int i = 0; i < 10; i++) { - container = api.create(firstParentURI + "childcontainer" + i + "/"); - assertNotNull(container); - assertEquals(container.getParentURI(), pContainerName); - assertEquals(container.getObjectName(), "childcontainer" + i + "/"); - container = api.create(container.getParentURI() + container.getObjectName() + "grandchild/", - pCreateContainerOptions); - assertEquals(container.getParentURI(), pContainerName + "childcontainer" + i + "/"); - assertEquals(container.getObjectName(), "grandchild" + "/"); - container = api.get(container.getParentURI(), ContainerQueryParams.Builder.children()); - assertEquals(container.getChildren().contains("grandchild" + "/"), true); - } - container = api.get(pContainerName, ContainerQueryParams.Builder.children()); - assertNotNull(container); - assertNotNull(container.getChildren()); - assertEquals(container.getChildren().size(), 10); - container = api.get(pContainerName, ContainerQueryParams.Builder.children(0, 3)); - assertNotNull(container); - assertNotNull(container.getChildren()); - assertEquals(container.getChildren().size(), 4); - - container = api.get(pContainerName, ContainerQueryParams.Builder.field("parentURI").field("objectName") - .children().metadata()); - assertNotNull(container); - assertNotNull(container.getChildren()); - assertEquals(container.getChildren().size(), 10); - assertEquals(container.getParentURI(), "/"); - assertEquals(container.getObjectName(), pContainerName); - assertEquals(container.getParentURI(), "/"); - assertEquals(container.getACLMetadata().size(), 3); - for (String childName : container.getChildren()) { - api.delete(container.getObjectName() + childName); - } - assertEquals(api.get(pContainerName, ContainerQueryParams.Builder.children()).getChildren().isEmpty(), true); - - } finally { - Logger.getAnonymousLogger().info("delete: " + pContainerName); - api.delete(pContainerName); - container = api.get("/"); - System.out.println("root container: " + container); - assertEquals(container.getChildren().contains(pContainerName), false); - } - - } - -} diff --git a/labs/cdmi/src/test/java/org/jclouds/snia/cdmi/v1/features/DataApiExpectTest.java b/labs/cdmi/src/test/java/org/jclouds/snia/cdmi/v1/features/DataApiExpectTest.java deleted file mode 100644 index 8d522b2dce..0000000000 --- a/labs/cdmi/src/test/java/org/jclouds/snia/cdmi/v1/features/DataApiExpectTest.java +++ /dev/null @@ -1,30 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.snia.cdmi.v1.features; - -import org.jclouds.snia.cdmi.v1.internal.BaseCDMIApiExpectTest; -import org.testng.annotations.Test; - -/** - * @author Adrian Cole - */ -@Test(groups = "unit", testName = "DataAsyncApiTest") -public class DataApiExpectTest extends BaseCDMIApiExpectTest { - -} diff --git a/labs/cdmi/src/test/java/org/jclouds/snia/cdmi/v1/features/DataApiLiveTest.java b/labs/cdmi/src/test/java/org/jclouds/snia/cdmi/v1/features/DataApiLiveTest.java deleted file mode 100644 index 35c14b5287..0000000000 --- a/labs/cdmi/src/test/java/org/jclouds/snia/cdmi/v1/features/DataApiLiveTest.java +++ /dev/null @@ -1,595 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.snia.cdmi.v1.features; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.DataOutputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.InputStream; -import java.util.Iterator; -import java.util.Map; -import java.util.logging.Logger; - -import org.jclouds.snia.cdmi.v1.domain.Container; -import org.jclouds.snia.cdmi.v1.domain.DataObject; -import org.jclouds.snia.cdmi.v1.internal.BaseCDMIApiLiveTest; -import org.jclouds.snia.cdmi.v1.options.CreateContainerOptions; -import org.jclouds.snia.cdmi.v1.options.CreateDataObjectOptions; -import org.jclouds.snia.cdmi.v1.queryparams.DataObjectQueryParams; -import org.testng.annotations.Test; - -import com.google.common.base.Charsets; -import com.google.common.collect.Maps; -import com.google.common.io.CharStreams; -import com.google.common.io.Files; - -/** - * @author Kenneth Nagin - */ -@Test(groups = "live", testName = "DataApiLiveTest") -public class DataApiLiveTest extends BaseCDMIApiLiveTest { - @Test - public void testCreateDataObjects() throws Exception { - - String containerName = "MyContainer" + System.currentTimeMillis() + "/"; - String dataObjectNameIn = "dataobject08121.txt"; - File tmpFileIn = new File("temp.txt"); - String value; - InputStream is; - File tmpFileOut; - File inFile; - Files.touch(tmpFileIn); - ByteArrayOutputStream bos = new ByteArrayOutputStream(); - DataOutputStream out = new DataOutputStream(bos); - byte[] bytes; - - CreateDataObjectOptions pCreateDataObjectOptions; - DataObject dataObject; - Map dataObjectMetaDataOut; - Map pContainerMetaDataIn = Maps.newHashMap(); - Map pDataObjectMetaDataIn = Maps.newLinkedHashMap(); - pDataObjectMetaDataIn.put("dataObjectkey1", "value1"); - pDataObjectMetaDataIn.put("dataObjectkey2", "value2"); - pDataObjectMetaDataIn.put("dataObjectkey3", "value3"); - - CreateContainerOptions pCreateContainerOptions = CreateContainerOptions.Builder.metadata(pContainerMetaDataIn); - ContainerApi containerApi = cdmiContext.getApi().getApi(); - DataApi dataApi = cdmiContext.getApi().getDataApiForContainer(containerName); - Logger.getAnonymousLogger().info("create: " + containerName); - Container container = containerApi.create(containerName, pCreateContainerOptions); - try { - assertNotNull(container); - System.out.println(container); - container = containerApi.get(containerName); - assertNotNull(container); - assertNotNull(container.getChildren()); - assertEquals(container.getChildren().isEmpty(), true); - - // exercise create data object with value mimetype and metadata - value = "Hello CDMI data object with value mimetype and metadata"; - pCreateDataObjectOptions = CreateDataObjectOptions.Builder.value(value).mimetype("text/plain") - .metadata(pDataObjectMetaDataIn); - dataObject = dataApi.create(dataObjectNameIn, pCreateDataObjectOptions); - assertNotNull(dataObject); - dataObject = dataApi.get(dataObjectNameIn); - assertNotNull(dataObject); - System.out.println(dataObject); - System.out.println("value: " + dataObject.getValueAsString()); - assertEquals(dataObject.getMimetype(), "text/plain"); - assertEquals(dataObject.getValueAsString(), value); - dataObjectMetaDataOut = dataObject.getUserMetadata(); - assertNotNull(dataObjectMetaDataOut); - for (Map.Entry entry : pDataObjectMetaDataIn.entrySet()) { - String key = entry.getKey(); - assertEquals(dataObjectMetaDataOut.containsKey(key), true); - assertEquals(dataObjectMetaDataOut.get(key), entry.getValue()); - } - assertEquals(Integer.parseInt(dataObject.getSystemMetadata().get("cdmi_size")), value.length()); - assertEquals(dataObject.getObjectName(), dataObjectNameIn); - assertEquals(dataObject.getObjectType(), "application/cdmi-object"); - assertEquals(dataObject.getParentURI(), "/" + containerName); - assertEquals(containerApi.get(containerName).getChildren().contains(dataObjectNameIn), true); - - dataApi.delete(dataObjectNameIn); - assertEquals(containerApi.get(containerName).getChildren().contains(dataObjectNameIn), false); - - // verify that options order does not matter - value = "Hello CDMI World3"; - pCreateDataObjectOptions = CreateDataObjectOptions.Builder.metadata(pDataObjectMetaDataIn) - .mimetype("text/plain").value(value); - dataObject = dataApi.create(dataObjectNameIn, pCreateDataObjectOptions); - assertNotNull(dataObject); - dataObject = dataApi.get(dataObjectNameIn); - assertNotNull(dataObject); - System.out.println(dataObject); - System.out.println("value: " + dataObject.getValueAsString()); - assertEquals(dataObject.getMimetype(), "text/plain"); - assertEquals(dataObject.getValueAsString(), value); - dataObjectMetaDataOut = dataObject.getUserMetadata(); - assertNotNull(dataObjectMetaDataOut); - for (Map.Entry entry : pDataObjectMetaDataIn.entrySet()) { - String key = entry.getKey(); - assertEquals(dataObjectMetaDataOut.containsKey(key), true); - assertEquals(dataObjectMetaDataOut.get(key), entry.getValue()); - } - assertEquals(Integer.parseInt(dataObject.getSystemMetadata().get("cdmi_size")), value.length()); - assertEquals(dataObject.getObjectName(), dataObjectNameIn); - assertEquals(dataObject.getObjectType(), "application/cdmi-object"); - assertEquals(dataObject.getParentURI(), "/" + containerName); - assertEquals(containerApi.get(containerName).getChildren().contains(dataObjectNameIn), true); - dataApi.delete(dataObjectNameIn); - assertEquals(containerApi.get(containerName).getChildren().contains(dataObjectNameIn), false); - - // exercise create data object with empty metadata - value = "Hello CDMI World4"; - pDataObjectMetaDataIn.clear(); - pCreateDataObjectOptions = CreateDataObjectOptions.Builder.value(value).mimetype("text/plain") - .metadata(pDataObjectMetaDataIn); - dataObject = dataApi.create(dataObjectNameIn, pCreateDataObjectOptions); - assertNotNull(dataObject); - dataObject = dataApi.get(dataObjectNameIn); - assertNotNull(dataObject); - System.out.println(dataObject); - System.out.println("value: " + dataObject.getValueAsString()); - assertEquals(dataObject.getMimetype(), "text/plain"); - assertEquals(dataObject.getValueAsString(), value); - dataObjectMetaDataOut = dataObject.getUserMetadata(); - assertNotNull(dataObjectMetaDataOut); - assertEquals(dataObjectMetaDataOut.isEmpty(), true); - assertEquals(Integer.parseInt(dataObject.getSystemMetadata().get("cdmi_size")), value.length()); - assertEquals(dataObject.getObjectName(), dataObjectNameIn); - assertEquals(dataObject.getObjectType(), "application/cdmi-object"); - assertEquals(dataObject.getParentURI(), "/" + containerName); - assertEquals(containerApi.get(containerName).getChildren().contains(dataObjectNameIn), true); - dataApi.delete(dataObjectNameIn); - assertEquals(containerApi.get(containerName).getChildren().contains(dataObjectNameIn), false); - - // exercise create data object with null metadata - value = "Hello CDMI World5"; - pCreateDataObjectOptions = CreateDataObjectOptions.Builder.value(value).mimetype("text/plain"); - dataObject = dataApi.create(dataObjectNameIn, pCreateDataObjectOptions); - assertNotNull(dataObject); - dataObject = dataApi.get(dataObjectNameIn); - assertNotNull(dataObject); - System.out.println(dataObject); - System.out.println("value: " + dataObject.getValueAsString()); - assertEquals(dataObject.getMimetype(), "text/plain"); - assertEquals(dataObject.getValueAsString(), value); - dataObjectMetaDataOut = dataObject.getUserMetadata(); - assertNotNull(dataObjectMetaDataOut); - assertEquals(true, dataObjectMetaDataOut.isEmpty()); - assertEquals(Integer.parseInt(dataObject.getSystemMetadata().get("cdmi_size")), value.length()); - assertEquals(dataObject.getObjectName(), dataObjectNameIn); - assertEquals(dataObject.getObjectType(), "application/cdmi-object"); - assertEquals(dataObject.getParentURI(), "/" + containerName); - assertEquals(containerApi.get(containerName).getChildren().contains(dataObjectNameIn), true); - dataApi.delete(dataObjectNameIn); - assertEquals(containerApi.get(containerName).getChildren().contains(dataObjectNameIn), false); - - // exercise create data object with only value - value = "Hello CDMI World6"; - pCreateDataObjectOptions = CreateDataObjectOptions.Builder.value(value); - dataObject = dataApi.create(dataObjectNameIn, pCreateDataObjectOptions); - assertNotNull(dataObject); - dataObject = dataApi.get(dataObjectNameIn); - assertNotNull(dataObject); - System.out.println(dataObject); - System.out.println("value: " + dataObject.getValueAsString()); - assertEquals(dataObject.getValueAsString(), value); - dataObjectMetaDataOut = dataObject.getUserMetadata(); - assertNotNull(dataObjectMetaDataOut); - assertEquals(dataObjectMetaDataOut.isEmpty(), true); - assertEquals(Integer.parseInt(dataObject.getSystemMetadata().get("cdmi_size")), value.length()); - assertEquals(dataObject.getObjectName(), dataObjectNameIn); - assertEquals(dataObject.getObjectType(), "application/cdmi-object"); - assertEquals(dataObject.getParentURI(), "/" + containerName); - assertEquals(containerApi.get(containerName).getChildren().contains(dataObjectNameIn), true); - dataApi.delete(dataObjectNameIn); - assertEquals(containerApi.get(containerName).getChildren().contains(dataObjectNameIn), false); - - // exercise create data object with empty mimetype only - value = ""; - pCreateDataObjectOptions = CreateDataObjectOptions.Builder.mimetype(new String()); - dataObject = dataApi.create(dataObjectNameIn, pCreateDataObjectOptions); - assertNotNull(dataObject); - dataObject = dataApi.get(dataObjectNameIn); - assertNotNull(dataObject); - System.out.println(dataObject); - System.out.println("value: " + dataObject.getValueAsString()); - // assertEquals(dataObject.getMimetype(), ""); - assertEquals(dataObject.getValueAsString(), ""); - dataObjectMetaDataOut = dataObject.getUserMetadata(); - assertNotNull(dataObjectMetaDataOut); - // assertEquals(dataObjectMetaDataOut.isEmpty(),true); - - dataApi.delete(dataObjectNameIn); - - // exercise create data object with no value - value = ""; - pCreateDataObjectOptions = CreateDataObjectOptions.Builder.value(); - dataObject = dataApi.create(dataObjectNameIn, pCreateDataObjectOptions); - assertNotNull(dataObject); - dataObject = dataApi.get(dataObjectNameIn); - assertNotNull(dataObject); - System.out.println(dataObject); - System.out.println("value: " + dataObject.getValueAsString()); - assertEquals(dataObject.getValueAsString(), ""); - dataObjectMetaDataOut = dataObject.getUserMetadata(); - assertNotNull(dataObjectMetaDataOut); - assertEquals(dataObjectMetaDataOut.isEmpty(), true); - assertEquals(Integer.parseInt(dataObject.getSystemMetadata().get("cdmi_size")), value.length()); - assertEquals(dataObject.getObjectName(), dataObjectNameIn); - assertEquals(dataObject.getObjectType(), "application/cdmi-object"); - assertEquals(dataObject.getParentURI(), "/" + containerName); - assertEquals(containerApi.get(containerName).getChildren().contains(dataObjectNameIn), true); - dataApi.delete(dataObjectNameIn); - assertEquals(containerApi.get(containerName).getChildren().contains(dataObjectNameIn), false); - - // exercise create data object with byte array - value = "Hello CDMI World 7"; - out.writeUTF(value); - out.close(); - bytes = bos.toByteArray(); - // String.getBytes causes an exception CreateDataObjectOptions need to investigate byte - // arrays - // bytes = value.getBytes(Charsets.UTF_8); - pCreateDataObjectOptions = CreateDataObjectOptions.Builder.value(bytes); - dataObject = dataApi.create(dataObjectNameIn, pCreateDataObjectOptions); - assertNotNull(dataObject); - dataObject = dataApi.get(dataObjectNameIn); - assertNotNull(dataObject); - System.out.println(dataObject); - System.out.println("value: " + dataObject.getValueAsString()); - assertEquals(dataObject.getValueAsString(), value); - assertEquals(new String(dataObject.getValueAsByteArray()), value); - assertEquals(Integer.parseInt(dataObject.getSystemMetadata().get("cdmi_size")), value.length()); - assertEquals(dataObject.getObjectName(), dataObjectNameIn); - assertEquals(dataObject.getObjectType(), "application/cdmi-object"); - assertEquals(dataObject.getParentURI(), "/" + containerName); - assertEquals(containerApi.get(containerName).getChildren().contains(dataObjectNameIn), true); - dataApi.delete(dataObjectNameIn); - assertEquals(containerApi.get(containerName).getChildren().contains(dataObjectNameIn), false); - - // exercise create data object with an existing file - inFile = new File(System.getProperty("user.dir") + "/src/test/resources/container.json"); - assertEquals(true, inFile.isFile()); - pCreateDataObjectOptions = CreateDataObjectOptions.Builder.value(inFile); - dataObject = dataApi.create(dataObjectNameIn, pCreateDataObjectOptions); - assertNotNull(dataObject); - dataObject = dataApi.get(dataObjectNameIn); - assertNotNull(dataObject); - System.out.println(dataObject); - System.out.println("value: " + dataObject.getValueAsString()); - tmpFileOut = dataObject.getValueAsFile(Files.createTempDir()); - assertEquals(true, Files.equal(tmpFileOut, inFile)); - tmpFileOut.delete(); - assertEquals(Integer.parseInt(dataObject.getSystemMetadata().get("cdmi_size")), - Files.toString(inFile, Charsets.UTF_8).length()); - assertEquals(dataObject.getObjectName(), dataObjectNameIn); - assertEquals(dataObject.getObjectType(), "application/cdmi-object"); - assertEquals(dataObject.getParentURI(), "/" + containerName); - assertEquals(containerApi.get(containerName).getChildren().contains(dataObjectNameIn), true); - dataApi.delete(dataObjectNameIn); - assertEquals(containerApi.get(containerName).getChildren().contains(dataObjectNameIn), false); - - // exercise create data object with a temporary file that we create - // on the fly - // with default Charset - value = "Hello CDMI World 10"; - Files.write(value, tmpFileIn, Charsets.UTF_8); - pCreateDataObjectOptions = CreateDataObjectOptions.Builder.value(tmpFileIn); - dataObject = dataApi.create(dataObjectNameIn, pCreateDataObjectOptions); - assertNotNull(dataObject); - dataObject = dataApi.get(dataObjectNameIn); - assertNotNull(dataObject); - System.out.println(dataObject); - System.out.println("value: " + dataObject.getValueAsString()); - assertEquals(dataObject.getValueAsString(), value); - tmpFileOut = dataObject.getValueAsFile(Files.createTempDir()); - assertEquals(true, Files.equal(tmpFileOut, tmpFileIn)); - tmpFileOut.delete(); - assertEquals(Integer.parseInt(dataObject.getSystemMetadata().get("cdmi_size")), value.length()); - assertEquals(dataObject.getObjectName(), dataObjectNameIn); - assertEquals(dataObject.getObjectType(), "application/cdmi-object"); - assertEquals(dataObject.getParentURI(), "/" + containerName); - assertEquals(containerApi.get(containerName).getChildren().contains(dataObjectNameIn), true); - dataApi.delete(dataObjectNameIn); - assertEquals(containerApi.get(containerName).getChildren().contains(dataObjectNameIn), false); - - // exercise create data object with a temporary file that we create - // on the fly - // specify charset UTF_8 - Files.write(value, tmpFileIn, Charsets.UTF_8); - pCreateDataObjectOptions = CreateDataObjectOptions.Builder.value(tmpFileIn, Charsets.UTF_8); - dataObject = dataApi.create(dataObjectNameIn, pCreateDataObjectOptions); - assertNotNull(dataObject); - dataObject = dataApi.get(dataObjectNameIn); - assertNotNull(dataObject); - System.out.println(dataObject); - System.out.println("value: " + dataObject.getValueAsString()); - assertEquals(dataObject.getValueAsString(), value); - tmpFileOut = dataObject.getValueAsFile(Files.createTempDir()); - assertEquals(true, Files.equal(tmpFileOut, tmpFileIn)); - tmpFileOut.delete(); - assertEquals(Integer.parseInt(dataObject.getSystemMetadata().get("cdmi_size")), value.length()); - assertEquals(dataObject.getObjectName(), dataObjectNameIn); - assertEquals(dataObject.getObjectType(), "application/cdmi-object"); - assertEquals(dataObject.getParentURI(), "/" + containerName); - assertEquals(containerApi.get(containerName).getChildren().contains(dataObjectNameIn), true); - dataApi.delete(dataObjectNameIn); - assertEquals(containerApi.get(containerName).getChildren().contains(dataObjectNameIn), false); - - // exercise create data object with a temporary file that we create - // on the fly - // specify charset US_ASCII - Files.write(value, tmpFileIn, Charsets.US_ASCII); - pCreateDataObjectOptions = CreateDataObjectOptions.Builder.value(tmpFileIn, Charsets.US_ASCII); - dataObject = dataApi.create(dataObjectNameIn, pCreateDataObjectOptions); - assertNotNull(dataObject); - dataObject = dataApi.get(dataObjectNameIn); - assertNotNull(dataObject); - System.out.println(dataObject); - System.out.println("value: " + dataObject.getValueAsString()); - assertEquals(dataObject.getValueAsString(), value); - tmpFileOut = dataObject.getValueAsFile(Files.createTempDir()); - assertEquals(true, Files.equal(tmpFileOut, tmpFileIn)); - tmpFileOut.delete(); - assertEquals(Integer.parseInt(dataObject.getSystemMetadata().get("cdmi_size")), value.length()); - assertEquals(dataObject.getObjectName(), dataObjectNameIn); - assertEquals(dataObject.getObjectType(), "application/cdmi-object"); - assertEquals(dataObject.getParentURI(), "/" + containerName); - assertEquals(containerApi.get(containerName).getChildren().contains(dataObjectNameIn), true); - dataApi.delete(dataObjectNameIn); - assertEquals(containerApi.get(containerName).getChildren().contains(dataObjectNameIn), false); - - // exercise create data object with a temporary file with multiple - // lines - // with default Charset - Files.write("line1", tmpFileIn, Charsets.UTF_8); - Files.append("\nline2", tmpFileIn, Charsets.UTF_8); - Files.append("\nline3", tmpFileIn, Charsets.UTF_8); - pCreateDataObjectOptions = CreateDataObjectOptions.Builder.value(tmpFileIn); - dataObject = dataApi.create(dataObjectNameIn, pCreateDataObjectOptions); - assertNotNull(dataObject); - dataObject = dataApi.get(dataObjectNameIn); - assertNotNull(dataObject); - System.out.println(dataObject); - System.out.println("value: " + dataObject.getValueAsString()); - assertEquals(dataObject.getValueAsString(), "line1\nline2\nline3"); - tmpFileOut = dataObject.getValueAsFile(Files.createTempDir()); - assertEquals(true, Files.equal(tmpFileOut, tmpFileIn)); - tmpFileOut.delete(); - assertEquals(Integer.parseInt(dataObject.getSystemMetadata().get("cdmi_size")), - Files.toString(tmpFileIn, Charsets.UTF_8).length()); - assertEquals(dataObject.getObjectName(), dataObjectNameIn); - assertEquals(dataObject.getObjectType(), "application/cdmi-object"); - assertEquals(dataObject.getParentURI(), "/" + containerName); - assertEquals(containerApi.get(containerName).getChildren().contains(dataObjectNameIn), true); - dataApi.delete(dataObjectNameIn); - assertEquals(containerApi.get(containerName).getChildren().contains(dataObjectNameIn), false); - - // exercise create data object with a temporary file with multiple - // lines - // with Charset UTF_8 - Files.write("line1", tmpFileIn, Charsets.UTF_8); - Files.append("\nline2", tmpFileIn, Charsets.UTF_8); - Files.append("\nline3", tmpFileIn, Charsets.UTF_8); - pCreateDataObjectOptions = CreateDataObjectOptions.Builder.value(new FileInputStream(tmpFileIn)); - dataObject = dataApi.create(dataObjectNameIn, pCreateDataObjectOptions); - assertNotNull(dataObject); - dataObject = dataApi.get(dataObjectNameIn); - assertNotNull(dataObject); - System.out.println(dataObject); - System.out.println("value: " + dataObject.getValueAsString()); - assertEquals(dataObject.getValueAsString(), "line1\nline2\nline3"); - tmpFileOut = dataObject.getValueAsFile(Files.createTempDir()); - assertEquals(true, Files.equal(tmpFileOut, tmpFileIn)); - tmpFileOut.delete(); - assertEquals(Integer.parseInt(dataObject.getSystemMetadata().get("cdmi_size")), - Files.toString(tmpFileIn, Charsets.UTF_8).length()); - assertEquals(dataObject.getObjectName(), dataObjectNameIn); - assertEquals(dataObject.getObjectType(), "application/cdmi-object"); - assertEquals(dataObject.getParentURI(), "/" + containerName); - assertEquals(containerApi.get(containerName).getChildren().contains(dataObjectNameIn), true); - dataApi.delete(dataObjectNameIn); - assertEquals(containerApi.get(containerName).getChildren().contains(dataObjectNameIn), false); - - // exercise create data object with a temporary file with multiple - // lines - // with Charset ISO_8859_1 - Files.write("line1", tmpFileIn, Charsets.ISO_8859_1); - Files.append("\nline2", tmpFileIn, Charsets.ISO_8859_1); - Files.append("\nline3", tmpFileIn, Charsets.ISO_8859_1); - pCreateDataObjectOptions = CreateDataObjectOptions.Builder.value(new FileInputStream(tmpFileIn), - Charsets.ISO_8859_1); - dataObject = dataApi.create(dataObjectNameIn, pCreateDataObjectOptions); - assertNotNull(dataObject); - dataObject = dataApi.get(dataObjectNameIn); - assertNotNull(dataObject); - System.out.println(dataObject); - System.out.println("value: " + dataObject.getValueAsString()); - assertEquals(dataObject.getValueAsString(), "line1\nline2\nline3"); - tmpFileOut = dataObject.getValueAsFile(Files.createTempDir()); - assertEquals(true, Files.equal(tmpFileOut, tmpFileIn)); - tmpFileOut.delete(); - assertEquals(Integer.parseInt(dataObject.getSystemMetadata().get("cdmi_size")), - Files.toString(tmpFileIn, Charsets.ISO_8859_1).length()); - assertEquals(dataObject.getObjectName(), dataObjectNameIn); - assertEquals(dataObject.getObjectType(), "application/cdmi-object"); - assertEquals(dataObject.getParentURI(), "/" + containerName); - assertEquals(containerApi.get(containerName).getChildren().contains(dataObjectNameIn), true); - dataApi.delete(dataObjectNameIn); - assertEquals(containerApi.get(containerName).getChildren().contains(dataObjectNameIn), false); - - // exercise create data object with an inputstream - is = new ByteArrayInputStream(value.getBytes()); - pCreateDataObjectOptions = CreateDataObjectOptions.Builder.value(is); - dataObject = dataApi.create(dataObjectNameIn, pCreateDataObjectOptions); - assertNotNull(dataObject); - dataObject = dataApi.get(dataObjectNameIn); - assertNotNull(dataObject); - System.out.println(dataObject); - System.out.println("value: " + dataObject.getValueAsString()); - assertEquals(dataObject.getValueAsString(), value); - assertNotNull(dataObject.getValueAsInputSupplier()); - assertEquals(CharStreams.toString(CharStreams.newReaderSupplier( - dataObject.getValueAsInputSupplier(Charsets.UTF_8), Charsets.UTF_8)), value); - assertEquals(Integer.parseInt(dataObject.getSystemMetadata().get("cdmi_size")), value.length()); - assertEquals(dataObject.getObjectName(), dataObjectNameIn); - assertEquals(dataObject.getObjectType(), "application/cdmi-object"); - assertEquals(dataObject.getParentURI(), "/" + containerName); - assertEquals(containerApi.get(containerName).getChildren().contains(dataObjectNameIn), true); - dataApi.delete(dataObjectNameIn); - assertEquals(containerApi.get(containerName).getChildren().contains(dataObjectNameIn), false); - } finally { - tmpFileIn.delete(); - containerApi.delete(containerName); - - } - - } - - @Test - public void testGetDataObjects() throws Exception { - - String containerName = "MyContainer" + System.currentTimeMillis() + "/"; - String dataObjectNameIn = "dataobject08121.txt"; - File tmpFileIn = new File("temp.txt"); - String value; - Files.touch(tmpFileIn); - - CreateDataObjectOptions pCreateDataObjectOptions; - DataObject dataObject; - Map dataObjectMetaDataOut; - Map pContainerMetaDataIn = Maps.newHashMap(); - Map pDataObjectMetaDataIn = Maps.newLinkedHashMap(); - pDataObjectMetaDataIn.put("dataObjectkey1", "value1"); - pDataObjectMetaDataIn.put("dataObjectkey2", "value2"); - pDataObjectMetaDataIn.put("dataObjectkey3", "value3"); - - CreateContainerOptions pCreateContainerOptions = CreateContainerOptions.Builder.metadata(pContainerMetaDataIn); - ContainerApi containerApi = cdmiContext.getApi().getApi(); - DataApi dataApi = cdmiContext.getApi().getDataApiForContainer(containerName); - Logger.getAnonymousLogger().info("create: " + containerName); - Container container = containerApi.create(containerName, pCreateContainerOptions); - try { - assertNotNull(container); - System.out.println(container); - container = containerApi.get(containerName); - assertNotNull(container); - assertNotNull(container.getChildren()); - assertEquals(container.getChildren().isEmpty(), true); - - // exercise create data object with value mimetype and metadata - value = "Hello CDMI data object with value mimetype and metadata"; - pCreateDataObjectOptions = CreateDataObjectOptions.Builder.value(value).mimetype("text/plain") - .metadata(pDataObjectMetaDataIn); - dataObject = dataApi.create(dataObjectNameIn, pCreateDataObjectOptions); - assertNotNull(dataObject); - dataObject = dataApi.get(dataObjectNameIn); - assertNotNull(dataObject); - System.out.println(dataObject); - System.out.println("value: " + dataObject.getValueAsString()); - assertEquals(dataObject.getMimetype(), "text/plain"); - assertEquals(dataObject.getValueAsString(), value); - dataObjectMetaDataOut = dataObject.getUserMetadata(); - assertNotNull(dataObjectMetaDataOut); - for (Map.Entry entry : pDataObjectMetaDataIn.entrySet()) { - String key = entry.getKey(); - assertEquals(dataObjectMetaDataOut.containsKey(key), true); - assertEquals(dataObjectMetaDataOut.get(key), entry.getValue()); - } - assertEquals(Integer.parseInt(dataObject.getSystemMetadata().get("cdmi_size")), value.length()); - assertEquals(dataObject.getObjectName(), dataObjectNameIn); - assertEquals(dataObject.getObjectType(), "application/cdmi-object"); - assertEquals(dataObject.getParentURI(), "/" + containerName); - assertEquals(containerApi.get(containerName).getChildren().contains(dataObjectNameIn), true); - - dataObject = dataApi.get(dataObjectNameIn, DataObjectQueryParams.Builder.field("parentURI")); - assertNotNull(dataObject); - System.out.println(dataObject); - assertEquals(dataObject.getParentURI(), container.getParentURI() + container.getObjectName()); - - dataObject = dataApi.get(dataObjectNameIn, DataObjectQueryParams.Builder.field("parentURI") - .field("objectName")); - assertNotNull(dataObject); - System.out.println(dataObject); - assertEquals(dataObject.getParentURI(), container.getParentURI() + container.getObjectName()); - assertEquals(dataObject.getObjectName(), dataObjectNameIn); - - dataObject = dataApi.get(dataObjectNameIn, DataObjectQueryParams.Builder.field("parentURI") - .field("objectName").field("mimetype")); - assertNotNull(dataObject); - System.out.println(dataObject); - assertEquals(dataObject.getParentURI(), container.getParentURI() + container.getObjectName()); - assertEquals(dataObject.getObjectName(), dataObjectNameIn); - assertEquals(dataObject.getMimetype(), "text/plain"); - - dataObject = dataApi.get(dataObjectNameIn, DataObjectQueryParams.Builder.field("parentURI") - .field("objectName").field("mimetype").metadata()); - assertNotNull(dataObject); - System.out.println(dataObject); - assertEquals(dataObject.getParentURI(), container.getParentURI() + container.getObjectName()); - assertEquals(dataObject.getObjectName(), dataObjectNameIn); - assertEquals(dataObject.getMimetype(), "text/plain"); - dataObjectMetaDataOut = dataObject.getUserMetadata(); - assertNotNull(dataObjectMetaDataOut); - for (Map.Entry entry : pDataObjectMetaDataIn.entrySet()) { - String key = entry.getKey(); - assertEquals(dataObjectMetaDataOut.containsKey(key), true); - assertEquals(dataObjectMetaDataOut.get(key), entry.getValue()); - } - assertEquals(Integer.parseInt(dataObject.getSystemMetadata().get("cdmi_size")), value.length()); - - dataObject = dataApi.get(dataObjectNameIn, DataObjectQueryParams.Builder.metadata("cdmi_size")); - assertNotNull(dataObject); - System.out.println(dataObject); - assertEquals(Integer.parseInt(dataObject.getSystemMetadata().get("cdmi_size")), value.length()); - - dataObject = dataApi.get(dataObjectNameIn, DataObjectQueryParams.Builder.field("mimetype").value()); - assertNotNull(dataObject); - System.out.println(dataObject); - System.out.println(dataObject.getValueAsString()); - assertEquals(dataObject.getMimetype(), "text/plain"); - assertEquals(dataObject.getValueAsString(), value); - - dataObject = dataApi.get(dataObjectNameIn, DataObjectQueryParams.Builder.field("mimetype").value(0, 3)); - assertNotNull(dataObject); - System.out.println(dataObject); - System.out.println(dataObject.getValueAsString()); - assertEquals(dataObject.getMimetype(), "text/plain"); - // value is SGVsbA==. This needs investigating to determine if this - // is problem with CDMI server or the jcloud client or must understanding of spec - - dataApi.delete(dataObjectNameIn); - assertEquals(containerApi.get(containerName).getChildren().contains(dataObjectNameIn), false); - } finally { - tmpFileIn.delete(); - containerApi.delete(containerName); - - } - - } - -} diff --git a/labs/cdmi/src/test/java/org/jclouds/snia/cdmi/v1/features/DataNonCDMIContentTypeApiLiveTest.java b/labs/cdmi/src/test/java/org/jclouds/snia/cdmi/v1/features/DataNonCDMIContentTypeApiLiveTest.java deleted file mode 100644 index 5495926c5c..0000000000 --- a/labs/cdmi/src/test/java/org/jclouds/snia/cdmi/v1/features/DataNonCDMIContentTypeApiLiveTest.java +++ /dev/null @@ -1,340 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.snia.cdmi.v1.features; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; - -import java.io.ByteArrayInputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.util.Map; -import java.util.logging.Logger; - -import org.jclouds.io.Payload; -import org.jclouds.io.payloads.BaseMutableContentMetadata; -import org.jclouds.io.payloads.ByteArrayPayload; -import org.jclouds.io.payloads.FilePayload; -import org.jclouds.io.payloads.InputStreamPayload; -import org.jclouds.io.payloads.StringPayload; -import org.jclouds.snia.cdmi.v1.domain.Container; -import org.jclouds.snia.cdmi.v1.domain.DataObject; -import org.jclouds.snia.cdmi.v1.internal.BaseCDMIApiLiveTest; -import org.jclouds.snia.cdmi.v1.options.CreateContainerOptions; -import org.jclouds.snia.cdmi.v1.queryparams.DataObjectQueryParams; -import org.jclouds.util.Strings2; -import org.testng.annotations.Test; - -import com.google.common.base.Charsets; -import com.google.common.collect.Maps; -import com.google.common.io.CharStreams; -import com.google.common.io.Files; -import com.google.common.net.MediaType; - -/** - * @author Kenneth Nagin - */ -@Test(groups = "live", testName = "DataNonCDMIContentTypeApiLiveTest") -public class DataNonCDMIContentTypeApiLiveTest extends BaseCDMIApiLiveTest { - @Test - public void testCreateDataObjectsNonCDMI() throws Exception { - - String containerName = "MyContainer" + System.currentTimeMillis() + "/"; - String dataObjectNameIn = "dataobject.txt"; - File tmpFileIn = new File("temp.txt"); - String value; - InputStream is; - File tmpFileOut; - File inFile; - Files.touch(tmpFileIn); - byte[] bytes; - DataObject dataObject; - Map pContainerMetaDataIn = Maps.newHashMap(); - Map pDataObjectMetaDataIn = Maps.newLinkedHashMap(); - pDataObjectMetaDataIn.put("dataObjectkey1", "value1"); - pDataObjectMetaDataIn.put("dataObjectkey2", "value2"); - pDataObjectMetaDataIn.put("dataObjectkey3", "value3"); - - Payload payloadIn; - Payload payloadOut; - - CreateContainerOptions pCreateContainerOptions = CreateContainerOptions.Builder.metadata(pContainerMetaDataIn); - ContainerApi containerApi = cdmiContext.getApi().getApi(); - DataApi dataApi = cdmiContext.getApi().getDataApiForContainer(containerName); - DataNonCDMIContentTypeApi dataNonCDMIContentTypeApi = cdmiContext.getApi() - .getDataNonCDMIContentTypeApiForContainer(containerName); - Logger.getAnonymousLogger().info("create: " + containerName); - Container container = containerApi.create(containerName, pCreateContainerOptions); - try { - - assertNotNull(container); - System.out.println(container); - container = containerApi.get(containerName); - assertNotNull(container); - assertNotNull(container.getChildren()); - assertEquals(container.getChildren().isEmpty(), true); - - // exercise create data object with none cdmi put with payload string. - value = "Hello CDMI World non-cdmi String"; - dataNonCDMIContentTypeApi.create(dataObjectNameIn, value); - payloadOut = dataNonCDMIContentTypeApi.getValue(dataObjectNameIn); - assertNotNull(payloadOut); - assertEquals(Strings2.toString(payloadOut), value); - - payloadIn = new StringPayload(value); - payloadIn.setContentMetadata(BaseMutableContentMetadata.fromContentMetadata(payloadIn.getContentMetadata() - .toBuilder().contentType(MediaType.PLAIN_TEXT_UTF_8.toString()).build())); - dataNonCDMIContentTypeApi.create(dataObjectNameIn, payloadIn); - - payloadOut = dataNonCDMIContentTypeApi.getValue(dataObjectNameIn); - assertNotNull(payloadOut); - assertEquals(Strings2.toString(payloadOut), value); - - dataObject = dataNonCDMIContentTypeApi.get(dataObjectNameIn, DataObjectQueryParams.Builder.field("parentURI")); - assertNotNull(dataObject); - System.out.println(dataObject); - assertEquals(dataObject.getParentURI(), "/" + containerName); - dataObject = dataNonCDMIContentTypeApi.get(dataObjectNameIn, - DataObjectQueryParams.Builder.metadata().field("parentURI").field("objectName").field("objectType") - .field("mimetype")); - assertEquals(Integer.parseInt(dataObject.getSystemMetadata().get("cdmi_size")), value.length()); - assertEquals(dataObject.getObjectName(), dataObjectNameIn); - assertEquals(dataObject.getObjectType(), "application/cdmi-object"); - assertEquals(dataObject.getParentURI(), "/" + containerName); - assertEquals(dataObject.getMimetype(), MediaType.PLAIN_TEXT_UTF_8.toString()); - - dataNonCDMIContentTypeApi.delete(dataObjectNameIn); - assertEquals(containerApi.get(containerName).getChildren().contains(dataObjectNameIn), false); - - // exercise create data object with none cdmi put with payload byte array. - value = "Hello CDMI World non-cdmi byte array"; - bytes = value.getBytes(Charsets.UTF_8); - payloadIn = new ByteArrayPayload(bytes); - payloadIn.setContentMetadata(BaseMutableContentMetadata.fromContentMetadata(payloadIn.getContentMetadata() - .toBuilder().contentType(MediaType.PLAIN_TEXT_UTF_8.toString()).build())); - dataNonCDMIContentTypeApi.create(dataObjectNameIn, payloadIn); - System.out.println(containerApi.get(containerName)); - dataObject = dataApi.get(dataObjectNameIn); - assertNotNull(dataObject); - System.out.println(dataObject); - System.out.println("value: " + dataObject.getValueAsString()); - assertEquals(dataObject.getValueAsString(), value); - assertEquals(new String(dataObject.getValueAsByteArray()), value); - assertEquals(dataObject.getUserMetadata().isEmpty(), true); - assertEquals(Integer.parseInt(dataObject.getSystemMetadata().get("cdmi_size")), value.length()); - assertEquals(dataObject.getObjectName(), dataObjectNameIn); - assertEquals(dataObject.getObjectType(), "application/cdmi-object"); - assertEquals(dataObject.getParentURI(), "/" + containerName); - assertEquals(containerApi.get(containerName).getChildren().contains(dataObjectNameIn), true); - payloadOut = dataNonCDMIContentTypeApi.getValue(dataObjectNameIn); - assertNotNull(payloadOut); - assertEquals(Strings2.toString(payloadOut), value); - - dataNonCDMIContentTypeApi.delete(dataObjectNameIn); - assertEquals(containerApi.get(containerName).getChildren().contains(dataObjectNameIn), false); - - // exercise create data object with none cdmi put with payload file. - value = "Hello CDMI World non-cdmi File"; - Files.write(value, tmpFileIn, Charsets.UTF_8); - payloadIn = new FilePayload(tmpFileIn); - payloadIn.setContentMetadata(BaseMutableContentMetadata.fromContentMetadata(payloadIn.getContentMetadata() - .toBuilder().contentType(MediaType.PLAIN_TEXT_UTF_8.toString()).build())); - - dataNonCDMIContentTypeApi.create(dataObjectNameIn, payloadIn); - System.out.println(containerApi.get(containerName)); - dataObject = dataApi.get(dataObjectNameIn); - assertNotNull(dataObject); - System.out.println(dataObject); - System.out.println("value: " + dataObject.getValueAsString()); - assertEquals(dataObject.getValueAsString(), value); - tmpFileOut = dataObject.getValueAsFile(Files.createTempDir()); - assertEquals(true, Files.equal(tmpFileOut, tmpFileIn)); - tmpFileOut.delete(); - assertEquals(dataObject.getUserMetadata().isEmpty(), true); - System.out.println("My Metadata: " + dataObject.getUserMetadata()); - assertEquals(Integer.parseInt(dataObject.getSystemMetadata().get("cdmi_size")), value.length()); - assertEquals(dataObject.getObjectName(), dataObjectNameIn); - assertEquals(dataObject.getObjectType(), "application/cdmi-object"); - assertEquals(dataObject.getParentURI(), "/" + containerName); - assertEquals(containerApi.get(containerName).getChildren().contains(dataObjectNameIn), true); - - payloadOut = dataNonCDMIContentTypeApi.getValue(dataObjectNameIn); - assertNotNull(payloadOut); - // assertEquals(Strings2.toString(payloadOut), value); - // byte[] _bytes = ByteStreams.toByteArray(payloadOut); - tmpFileOut = new File(Files.createTempDir(), "temp.txt"); - Files.copy(payloadOut, tmpFileOut); - assertEquals(Files.equal(tmpFileOut, tmpFileIn), true); - tmpFileOut.delete(); - - dataNonCDMIContentTypeApi.delete(dataObjectNameIn); - assertEquals(containerApi.get(containerName).getChildren().contains(dataObjectNameIn), false); - - // exercise create data object with none cdmi put with text file payload file. - inFile = new File(System.getProperty("user.dir") + "/src/test/resources/container.json"); - assertEquals(true, inFile.isFile()); - payloadIn = new FilePayload(inFile); - payloadIn.setContentMetadata(BaseMutableContentMetadata.fromContentMetadata(payloadIn.getContentMetadata() - .toBuilder().contentType(MediaType.JSON_UTF_8.toString()).build())); - - dataNonCDMIContentTypeApi.create(inFile.getName(), payloadIn); - System.out.println(containerApi.get(containerName)); - dataObject = dataApi.get(inFile.getName()); - assertNotNull(dataObject); - System.out.println(dataObject); - // System.out.println("value: " + dataObject.getValueAsString()); - // assertEquals(dataObject.getValueAsString(), value); - tmpFileOut = dataObject.getValueAsFile(Files.createTempDir()); - assertEquals(true, Files.equal(tmpFileOut, inFile)); - tmpFileOut.delete(); - assertEquals(dataObject.getUserMetadata().isEmpty(), true); - // System.out.println("My Metadata: "+dataObject.getUserMetadata()); - assertEquals(Integer.parseInt(dataObject.getSystemMetadata().get("cdmi_size")), inFile.length()); - assertEquals(dataObject.getObjectName(), inFile.getName()); - assertEquals(dataObject.getObjectType(), "application/cdmi-object"); - assertEquals(dataObject.getParentURI(), "/" + containerName); - assertEquals(containerApi.get(containerName).getChildren().contains(inFile.getName()), true); - dataApi.delete(inFile.getName()); - assertEquals(containerApi.get(containerName).getChildren().contains(dataObjectNameIn), false); - - // exercise create data object with none cdmi put with text file payload file. - // inFile = new File(System.getProperty("user.dir") - // + "/src/test/resources/Jellyfish.jpg"); // takes too long when working from home - inFile = new File(System.getProperty("user.dir") + "/src/test/resources/yellow-flowers.jpg"); - assertEquals(true, inFile.isFile()); - payloadIn = new FilePayload(inFile); - payloadIn.setContentMetadata(BaseMutableContentMetadata.fromContentMetadata(payloadIn.getContentMetadata() - .toBuilder().contentType(MediaType.JPEG.toString()).build())); - dataNonCDMIContentTypeApi.create(inFile.getName(), payloadIn); - System.out.println(containerApi.get(containerName)); - // note dataApi.get when the data object is not a string - payloadOut = dataNonCDMIContentTypeApi.getValue(inFile.getName()); - assertNotNull(payloadOut); - tmpFileOut = new File(Files.createTempDir(), "temp.jpg"); - Files.copy(payloadOut, tmpFileOut); - assertEquals(Files.equal(tmpFileOut, inFile), true); - tmpFileOut.delete(); - - assertEquals(containerApi.get(containerName).getChildren().contains(inFile.getName()), true); - dataApi.delete(inFile.getName()); - assertEquals(containerApi.get(containerName).getChildren().contains(inFile.getName()), false); - - // exercise create data object with none cdmi put with payload inputStream riginating from - // string. - value = "Hello CDMI World non-cdmi inputStream originating from string"; - is = new ByteArrayInputStream(value.getBytes()); - payloadIn = new InputStreamPayload(is); - payloadIn.setContentMetadata(BaseMutableContentMetadata.fromContentMetadata(payloadIn.getContentMetadata() - .toBuilder().contentType(MediaType.PLAIN_TEXT_UTF_8.toString()) - .contentLength(new Long(value.length())).build())); - dataNonCDMIContentTypeApi.create(dataObjectNameIn, payloadIn); - System.out.println(containerApi.get(containerName)); - dataObject = dataApi.get(dataObjectNameIn); - assertNotNull(dataObject); - System.out.println(dataObject); - System.out.println("value: " + dataObject.getValueAsString()); - assertEquals(dataObject.getValueAsString(), value); - assertNotNull(dataObject.getValueAsInputSupplier()); - assertEquals(CharStreams.toString(CharStreams.newReaderSupplier( - dataObject.getValueAsInputSupplier(Charsets.UTF_8), Charsets.UTF_8)), value); - assertEquals(dataObject.getUserMetadata().isEmpty(), true); - System.out.println("My Metadata: " + dataObject.getUserMetadata()); - assertEquals(Integer.parseInt(dataObject.getSystemMetadata().get("cdmi_size")), value.length()); - assertEquals(dataObject.getObjectName(), dataObjectNameIn); - assertEquals(dataObject.getObjectType(), "application/cdmi-object"); - assertEquals(dataObject.getParentURI(), "/" + containerName); - assertEquals(containerApi.get(containerName).getChildren().contains(dataObjectNameIn), true); - dataNonCDMIContentTypeApi.delete(dataObjectNameIn); - assertEquals(containerApi.get(containerName).getChildren().contains(dataObjectNameIn), false); - - // exercise create data object with none cdmi put with payload inputStream originating from - // jpeg file. - inFile = new File(System.getProperty("user.dir") + "/src/test/resources/yellow-flowers.jpg"); - assertEquals(true, inFile.isFile()); - FileInputStream fileInputStream = new FileInputStream(inFile); - payloadIn = new InputStreamPayload(fileInputStream); - payloadIn.setContentMetadata(BaseMutableContentMetadata.fromContentMetadata(payloadIn.getContentMetadata() - .toBuilder().contentType(MediaType.JPEG.toString()).contentLength(new Long(inFile.length())).build())); - dataNonCDMIContentTypeApi.create(inFile.getName(), payloadIn); - System.out.println(containerApi.get(containerName)); - payloadOut = dataNonCDMIContentTypeApi.getValue(inFile.getName()); - assertNotNull(payloadOut); - tmpFileOut = new File(Files.createTempDir(), "temp.jpg"); - Files.copy(payloadOut, tmpFileOut); - assertEquals(Files.equal(tmpFileOut, inFile), true); - tmpFileOut.delete(); - - assertEquals(containerApi.get(containerName).getChildren().contains(inFile.getName()), true); - dataApi.delete(inFile.getName()); - assertEquals(containerApi.get(containerName).getChildren().contains(inFile.getName()), false); - - // exercise get with none cdmi get range. - value = "Hello CDMI World non-cdmi String"; - payloadIn = new StringPayload(value); - payloadIn.setContentMetadata(BaseMutableContentMetadata.fromContentMetadata(payloadIn.getContentMetadata() - .toBuilder().contentType(MediaType.PLAIN_TEXT_UTF_8.toString()).build())); - dataNonCDMIContentTypeApi.create(dataObjectNameIn, payloadIn); - - payloadOut = dataNonCDMIContentTypeApi.getValue(dataObjectNameIn, "bytes=0-10"); - assertNotNull(payloadOut); - assertEquals(Strings2.toString(payloadOut), value.substring(0, 11)); - assertEquals(payloadOut.getContentMetadata().getContentLength(), new Long(11)); - - payloadOut = dataNonCDMIContentTypeApi.getValue(dataObjectNameIn, "bytes=11-20"); - assertNotNull(payloadOut); - assertEquals(Strings2.toString(payloadOut), value.substring(11, 21)); - assertEquals(payloadOut.getContentMetadata().getContentLength(), new Long(10)); - - dataNonCDMIContentTypeApi.delete(dataObjectNameIn); - assertEquals(containerApi.get(containerName).getChildren().contains(dataObjectNameIn), false); - - // exercise create data object with none cdmi partial. - // server does not actually support cdmi partial but - // trace allows me to see that request was constructed properly - value = "Hello CDMI World non-cdmi String"; - payloadIn = new StringPayload(value); - payloadIn.setContentMetadata(BaseMutableContentMetadata.fromContentMetadata(payloadIn.getContentMetadata() - .toBuilder().contentType(MediaType.PLAIN_TEXT_UTF_8.toString()).build())); - dataNonCDMIContentTypeApi.createPartial(dataObjectNameIn, payloadIn); - payloadOut = dataNonCDMIContentTypeApi.getValue(dataObjectNameIn); - assertNotNull(payloadOut); - System.out.println("payload " + payloadOut); - - dataNonCDMIContentTypeApi.createPartial(dataObjectNameIn, payloadIn); - payloadOut = dataNonCDMIContentTypeApi.getValue(dataObjectNameIn); - assertNotNull(payloadOut); - System.out.println("payload " + payloadOut); - - dataNonCDMIContentTypeApi.create(dataObjectNameIn, payloadIn); - - payloadOut = dataNonCDMIContentTypeApi.getValue(dataObjectNameIn); - assertNotNull(payloadOut); - System.out.println("payload " + payloadOut); - - } finally { - tmpFileIn.delete(); - containerApi.delete(containerName); - - } - - } - -} diff --git a/labs/cdmi/src/test/java/org/jclouds/snia/cdmi/v1/features/DomainApiExpectTest.java b/labs/cdmi/src/test/java/org/jclouds/snia/cdmi/v1/features/DomainApiExpectTest.java deleted file mode 100644 index 39891a0aaf..0000000000 --- a/labs/cdmi/src/test/java/org/jclouds/snia/cdmi/v1/features/DomainApiExpectTest.java +++ /dev/null @@ -1,30 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unles required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either expres or implied. See the License for the - * specific language governing permisions and limitations - * under the License. - */ -package org.jclouds.snia.cdmi.v1.features; - -import org.jclouds.snia.cdmi.v1.internal.BaseCDMIApiExpectTest; -import org.testng.annotations.Test; - -/** - * @author Adrian Cole - */ -@Test(groups = "unit", testName = "DomainApiExpectTest") -public class DomainApiExpectTest extends BaseCDMIApiExpectTest { - -} diff --git a/labs/cdmi/src/test/java/org/jclouds/snia/cdmi/v1/features/DomainApiLiveTest.java b/labs/cdmi/src/test/java/org/jclouds/snia/cdmi/v1/features/DomainApiLiveTest.java deleted file mode 100644 index 9fa884edd5..0000000000 --- a/labs/cdmi/src/test/java/org/jclouds/snia/cdmi/v1/features/DomainApiLiveTest.java +++ /dev/null @@ -1,30 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.snia.cdmi.v1.features; - -import org.jclouds.snia.cdmi.v1.internal.BaseCDMIApiLiveTest; -import org.testng.annotations.Test; - -/** - * @author Adrian Cole - */ -@Test(groups = "live", testName = "ContainerApiLiveTest") -public class DomainApiLiveTest extends BaseCDMIApiLiveTest { - -} diff --git a/labs/cdmi/src/test/java/org/jclouds/snia/cdmi/v1/internal/BaseCDMIApiExpectTest.java b/labs/cdmi/src/test/java/org/jclouds/snia/cdmi/v1/internal/BaseCDMIApiExpectTest.java deleted file mode 100644 index 76ea968b82..0000000000 --- a/labs/cdmi/src/test/java/org/jclouds/snia/cdmi/v1/internal/BaseCDMIApiExpectTest.java +++ /dev/null @@ -1,30 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.snia.cdmi.v1.internal; - -import org.jclouds.snia.cdmi.v1.CDMIApi; - -/** - * Base class for writing KeyStone Rest Api Expect tests - * - * @author Adrian Cole - */ -public class BaseCDMIApiExpectTest extends BaseCDMIExpectTest { - -} diff --git a/labs/cdmi/src/test/java/org/jclouds/snia/cdmi/v1/internal/BaseCDMIApiLiveTest.java b/labs/cdmi/src/test/java/org/jclouds/snia/cdmi/v1/internal/BaseCDMIApiLiveTest.java deleted file mode 100644 index aeca8530f0..0000000000 --- a/labs/cdmi/src/test/java/org/jclouds/snia/cdmi/v1/internal/BaseCDMIApiLiveTest.java +++ /dev/null @@ -1,57 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.snia.cdmi.v1.internal; - -import org.jclouds.apis.BaseContextLiveTest; -import org.jclouds.rest.RestContext; -import org.jclouds.snia.cdmi.v1.CDMIApi; -import org.jclouds.snia.cdmi.v1.CDMIApiMetadata; -import org.jclouds.snia.cdmi.v1.CDMIAsyncApi; -import org.testng.annotations.BeforeGroups; -import org.testng.annotations.Test; - -import com.google.common.reflect.TypeToken; - -/** - * Tests behavior of {@code CDMIApi} - * - * @author Adrian Cole - */ -@Test(groups = "live") -public class BaseCDMIApiLiveTest extends BaseContextLiveTest> { - - public BaseCDMIApiLiveTest() { - provider = "cdmi"; - } - - protected RestContext cdmiContext; - - @BeforeGroups(groups = { "integration", "live" }) - @Override - public void setupContext() { - super.setupContext(); - cdmiContext = context; - } - - @Override - protected TypeToken> contextType() { - return CDMIApiMetadata.CONTEXT_TOKEN; - } - -} diff --git a/labs/cdmi/src/test/java/org/jclouds/snia/cdmi/v1/internal/BaseCDMIAsyncApiExpectTest.java b/labs/cdmi/src/test/java/org/jclouds/snia/cdmi/v1/internal/BaseCDMIAsyncApiExpectTest.java deleted file mode 100644 index 25f4c2a9a7..0000000000 --- a/labs/cdmi/src/test/java/org/jclouds/snia/cdmi/v1/internal/BaseCDMIAsyncApiExpectTest.java +++ /dev/null @@ -1,39 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.snia.cdmi.v1.internal; - -import java.util.Properties; - -import org.jclouds.http.HttpRequest; -import org.jclouds.http.HttpResponse; -import org.jclouds.snia.cdmi.v1.CDMIAsyncApi; - -import com.google.common.base.Function; -import com.google.inject.Module; - -/** - * Base class for writing KeyStone Rest Api Expect tests - * - * @author Adrian Cole - */ -public class BaseCDMIAsyncApiExpectTest extends BaseCDMIExpectTest { - public CDMIAsyncApi createClient(Function fn, Module module, Properties props) { - return createInjector(fn, module, props).getInstance(CDMIAsyncApi.class); - } -} diff --git a/labs/cdmi/src/test/java/org/jclouds/snia/cdmi/v1/internal/BaseCDMIExpectTest.java b/labs/cdmi/src/test/java/org/jclouds/snia/cdmi/v1/internal/BaseCDMIExpectTest.java deleted file mode 100644 index 3c7d876704..0000000000 --- a/labs/cdmi/src/test/java/org/jclouds/snia/cdmi/v1/internal/BaseCDMIExpectTest.java +++ /dev/null @@ -1,36 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.snia.cdmi.v1.internal; - -import org.jclouds.rest.internal.BaseRestApiExpectTest; - -/** - * Base class for writing CDMI Expect tests - * - * @author Adrian Cole - */ -public class BaseCDMIExpectTest extends BaseRestApiExpectTest { - - public BaseCDMIExpectTest() { - provider = "cdmi"; - // now, createContext arg will need tenant prefix - identity = "tenantId:username"; - credential = "password"; - } -} diff --git a/labs/cdmi/src/test/java/org/jclouds/snia/cdmi/v1/options/ListContainersOptionsTest.java b/labs/cdmi/src/test/java/org/jclouds/snia/cdmi/v1/options/ListContainersOptionsTest.java deleted file mode 100644 index d533ebfd3f..0000000000 --- a/labs/cdmi/src/test/java/org/jclouds/snia/cdmi/v1/options/ListContainersOptionsTest.java +++ /dev/null @@ -1,97 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.snia.cdmi.v1.options; - -import static org.jclouds.snia.cdmi.v1.options.ListContainersOptions.Builder.limit; -import static org.jclouds.snia.cdmi.v1.options.ListContainersOptions.Builder.marker; -import static org.testng.Assert.assertEquals; - -import com.google.common.collect.ImmutableList; - -import org.jclouds.http.options.HttpRequestOptions; -import org.testng.annotations.Test; - -/** - * Tests possible uses of ListContainerOptions and ListContainerOptions.Builder.* - * - * @author Adrian Cole - */ -@Test(testName = "ListContainersOptionsTest") -public class ListContainersOptionsTest { - - @Test - public void testAssignability() { - assert HttpRequestOptions.class.isAssignableFrom(ListContainersOptions.class); - assert !String.class.isAssignableFrom(ListContainersOptions.class); - } - - @Test - public void testNoOptionsQueryString() { - HttpRequestOptions options = new ListContainersOptions(); - assertEquals(options.buildQueryParameters().size(), 0); - } - - @Test - public void testMarker() { - ListContainersOptions options = new ListContainersOptions(); - options.marker("test"); - assertEquals(options.buildQueryParameters().get("marker"), ImmutableList.of("test")); - } - - @Test - public void testNullMarker() { - ListContainersOptions options = new ListContainersOptions(); - assertEquals(options.buildQueryParameters().get("marker"), ImmutableList.of()); - } - - @Test - public void testMarkerStatic() { - ListContainersOptions options = marker("test"); - assertEquals(options.buildQueryParameters().get("marker"), ImmutableList.of("test")); - } - - @Test(expectedExceptions = NullPointerException.class) - public void testMarkerNPE() { - marker(null); - } - - @Test - public void testLimit() { - ListContainersOptions options = new ListContainersOptions(); - options.limit(1000); - assertEquals(options.buildQueryParameters().get("limit"), ImmutableList.of("1000")); - } - - @Test - public void testNullLimit() { - ListContainersOptions options = new ListContainersOptions(); - assertEquals(options.buildQueryParameters().get("limit"), ImmutableList.of()); - } - - @Test - public void testLimitStatic() { - ListContainersOptions options = limit(1000); - assertEquals(options.buildQueryParameters().get("limit"), ImmutableList.of("1000")); - } - - @Test(expectedExceptions = IllegalStateException.class) - public void testLimitNegative() { - limit(-1); - } -} diff --git a/labs/cdmi/src/test/java/org/jclouds/snia/cdmi/v1/parse/ParseContainerTest.java b/labs/cdmi/src/test/java/org/jclouds/snia/cdmi/v1/parse/ParseContainerTest.java deleted file mode 100644 index af43df3fd3..0000000000 --- a/labs/cdmi/src/test/java/org/jclouds/snia/cdmi/v1/parse/ParseContainerTest.java +++ /dev/null @@ -1,52 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.snia.cdmi.v1.parse; - -import javax.ws.rs.Consumes; -import javax.ws.rs.core.MediaType; - -import org.jclouds.domain.JsonBall; -import org.jclouds.json.BaseItemParserTest; -import org.jclouds.snia.cdmi.v1.domain.Container; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; - -/** - * - * @author Kenneth Nagin - */ -@Test(groups = "unit", testName = "ParseContainerTest") -public class ParseContainerTest extends BaseItemParserTest { - - @Override - public String resource() { - return "/container.json"; - } - - @Override - @Consumes(MediaType.APPLICATION_JSON) - public Container expected() { - return Container.builder().objectType("application/cdmi-container").objectID("00007E7F00102E230ED82694DAA975D2") - .objectName("MyContainer/").parentURI("/") - .metadata(ImmutableMap. builder().put("cdmi_size", new JsonBall("\"83\"")).build()) - .children(ImmutableSet. builder().add("MyDataObject.txt").build()).build(); - } -} diff --git a/labs/cdmi/src/test/resources/Jellyfish.jpg b/labs/cdmi/src/test/resources/Jellyfish.jpg deleted file mode 100644 index fa4fd41106..0000000000 Binary files a/labs/cdmi/src/test/resources/Jellyfish.jpg and /dev/null differ diff --git a/labs/cdmi/src/test/resources/container.json b/labs/cdmi/src/test/resources/container.json deleted file mode 100644 index 601a54d529..0000000000 --- a/labs/cdmi/src/test/resources/container.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "objectType" : "application/cdmi-container", - "objectID" : "00007E7F00102E230ED82694DAA975D2", - "objectName" : "MyContainer/", - "parentURI" : "/", - "parentID" : "00007E7F0010128E42D87EE34F5A6560", - "domainURI" : "/cdmi_domains/MyDomain/", - "capabilitiesURI" : "/cdmi_capabilities/container/", - "completionStatus" : "Complete", - "metadata" : { - "cdmi_size" : "83" - }, - "childrenrange" : "0-0", - "children" : [ - "MyDataObject.txt" - ] -} \ No newline at end of file diff --git a/labs/cdmi/src/test/resources/logback.xml b/labs/cdmi/src/test/resources/logback.xml deleted file mode 100644 index bd89efb8c0..0000000000 --- a/labs/cdmi/src/test/resources/logback.xml +++ /dev/null @@ -1,51 +0,0 @@ - - - - target/test-data/jclouds.log - - - %d %-5p [%c] [%thread] %m%n - - - - - target/test-data/jclouds-wire.log - - - %d %-5p [%c] [%thread] %m%n - - - - - target/test-data/jclouds-blobstore.log - - - %d %-5p [%c] [%thread] %m%n - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/labs/cdmi/src/test/resources/yellow-flowers.jpg b/labs/cdmi/src/test/resources/yellow-flowers.jpg deleted file mode 100644 index 810b7c3a00..0000000000 Binary files a/labs/cdmi/src/test/resources/yellow-flowers.jpg and /dev/null differ diff --git a/labs/cloudstack-ec2/pom.xml b/labs/cloudstack-ec2/pom.xml deleted file mode 100644 index f349a7f14e..0000000000 --- a/labs/cloudstack-ec2/pom.xml +++ /dev/null @@ -1,129 +0,0 @@ - - - - 4.0.0 - - org.jclouds - jclouds-project - 1.7.0-SNAPSHOT - ../../project/pom.xml - - org.jclouds.labs - cloudstack-ec2 - jclouds CloudStack EC2 api - EC2 implementation based on CloudStack - bundle - - - http://localhost:8090/bridge/rest/AmazonEC2 - 2010-11-15 - - FIXME_IDENTITY - FIXME_CREDENTIAL - imageId=fixme-region/ami-fixme - imageId=fixme-region/ami-fixmeebs - org.jclouds.cloudstack.ec2*;version="${project.version}" - - org.jclouds.compute.internal;version="${project.version}", - org.jclouds.rest.internal;version="${project.version}", - org.jclouds*;version="${project.version}", - * - - - - - - org.jclouds.api - ec2 - ${project.version} - - - org.jclouds.api - ec2 - ${project.version} - test-jar - test - - - org.jclouds - jclouds-core - ${project.version} - test-jar - test - - - org.jclouds - jclouds-compute - ${project.version} - test-jar - test - - - org.jclouds.driver - jclouds-log4j - ${project.version} - test - - - org.jclouds.driver - jclouds-sshj - ${project.version} - test - - - - - - live - - - - org.apache.maven.plugins - maven-surefire-plugin - - - integration - integration-test - - test - - - - ${test.cloudstack-ec2.endpoint} - ${test.cloudstack-ec2.api-version} - ${test.cloudstack-ec2.build-version} - ${test.cloudstack-ec2.identity} - ${test.cloudstack-ec2.credential} - ${test.cloudstack-ec2.template} - ${test.cloudstack-ec2.ebs-template} - - - - - - - - - - - - diff --git a/labs/cloudstack-ec2/src/main/java/org/jclouds/cloudstack/ec2/CloudStackEC2ApiMetadata.java b/labs/cloudstack-ec2/src/main/java/org/jclouds/cloudstack/ec2/CloudStackEC2ApiMetadata.java deleted file mode 100644 index 13aa8ab54a..0000000000 --- a/labs/cloudstack-ec2/src/main/java/org/jclouds/cloudstack/ec2/CloudStackEC2ApiMetadata.java +++ /dev/null @@ -1,86 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.cloudstack.ec2; - -import java.net.URI; -import java.util.Properties; - -import org.jclouds.apis.ApiMetadata; -import org.jclouds.cloudstack.ec2.config.CloudStackEC2RestClientModule; -import org.jclouds.ec2.EC2ApiMetadata; -import org.jclouds.ec2.EC2AsyncClient; -import org.jclouds.ec2.EC2Client; -import org.jclouds.ec2.compute.config.EC2ComputeServiceContextModule; -import org.jclouds.ec2.compute.config.EC2ResolveImagesModule; - -import com.google.common.collect.ImmutableSet; -import com.google.inject.Module; - -/** - * Implementation of {@link ApiMetadata} for the CloudStack's EC2-clone API - * - * @author Adrian Cole - */ -public class CloudStackEC2ApiMetadata extends EC2ApiMetadata { - - @Override - public Builder toBuilder() { - return new Builder().fromApiMetadata(this); - } - - public CloudStackEC2ApiMetadata() { - this(new Builder()); - } - - protected CloudStackEC2ApiMetadata(Builder builder) { - super(builder); - } - - public static Properties defaultProperties() { - Properties properties = EC2ApiMetadata.defaultProperties(); - return properties; - } - - public static class Builder extends EC2ApiMetadata.Builder { - protected Builder(){ - super(EC2Client.class, EC2AsyncClient.class); - id("cloudstack-ec2") - .name("CloudBridge (EC2 clone) API") - .version("2010-11-15") - .defaultEndpoint("http://localhost:8090/bridge/rest/AmazonEC2") - .documentation(URI.create("http://docs.cloudstack.org/CloudBridge_Documentation")) - .defaultProperties(CloudStackEC2ApiMetadata.defaultProperties()) - .context(CONTEXT_TOKEN) - .defaultModules(ImmutableSet.>builder() - .add(CloudStackEC2RestClientModule.class) - .add(EC2ResolveImagesModule.class) - .add(EC2ComputeServiceContextModule.class).build()); - } - - @Override - public CloudStackEC2ApiMetadata build() { - return new CloudStackEC2ApiMetadata(this); - } - - @Override - protected Builder self() { - return this; - } - } -} diff --git a/labs/cloudstack-ec2/src/main/java/org/jclouds/cloudstack/ec2/config/CloudStackEC2RestClientModule.java b/labs/cloudstack-ec2/src/main/java/org/jclouds/cloudstack/ec2/config/CloudStackEC2RestClientModule.java deleted file mode 100644 index 606aca3d01..0000000000 --- a/labs/cloudstack-ec2/src/main/java/org/jclouds/cloudstack/ec2/config/CloudStackEC2RestClientModule.java +++ /dev/null @@ -1,41 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.cloudstack.ec2.config; - -import org.jclouds.ec2.EC2AsyncClient; -import org.jclouds.ec2.EC2Client; -import org.jclouds.ec2.config.EC2RestClientModule; -import org.jclouds.rest.ConfiguresRestClient; - -/** - * - * @author Adrian Cole - */ -@ConfiguresRestClient -public class CloudStackEC2RestClientModule extends EC2RestClientModule { - - @Override - protected void configure() { - super.configure(); - // override parsers, etc. here - // ex. - // bind(DescribeImagesResponseHandler.class).to(CloudStackDescribeImagesResponseHandler.class); - } - -} diff --git a/labs/cloudstack-ec2/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata b/labs/cloudstack-ec2/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata deleted file mode 100644 index f68f5ccf6e..0000000000 --- a/labs/cloudstack-ec2/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata +++ /dev/null @@ -1 +0,0 @@ -org.jclouds.cloudstack.ec2.CloudStackEC2ApiMetadata diff --git a/labs/cloudstack-ec2/src/test/java/org/jclouds/cloudstack/ec2/CloudStackEC2ApiMetadataTest.java b/labs/cloudstack-ec2/src/test/java/org/jclouds/cloudstack/ec2/CloudStackEC2ApiMetadataTest.java deleted file mode 100644 index a62ad5f193..0000000000 --- a/labs/cloudstack-ec2/src/test/java/org/jclouds/cloudstack/ec2/CloudStackEC2ApiMetadataTest.java +++ /dev/null @@ -1,34 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.cloudstack.ec2; - -import org.jclouds.compute.internal.BaseComputeServiceApiMetadataTest; -import org.testng.annotations.Test; - -/** - * - * @author Adrian Cole - */ -@Test(groups = "unit", testName = "CloudStackEC2ApiMetadataTest") -public class CloudStackEC2ApiMetadataTest extends BaseComputeServiceApiMetadataTest { - - public CloudStackEC2ApiMetadataTest() { - super(new CloudStackEC2ApiMetadata()); - } -} diff --git a/labs/cloudstack-ec2/src/test/java/org/jclouds/cloudstack/ec2/features/CloudStackSubnetApiLiveTest.java b/labs/cloudstack-ec2/src/test/java/org/jclouds/cloudstack/ec2/features/CloudStackSubnetApiLiveTest.java deleted file mode 100644 index 93e5c707b0..0000000000 --- a/labs/cloudstack-ec2/src/test/java/org/jclouds/cloudstack/ec2/features/CloudStackSubnetApiLiveTest.java +++ /dev/null @@ -1,33 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.cloudstack.ec2.features; - -import org.jclouds.ec2.features.SubnetApiLiveTest; -import org.testng.annotations.Test; - -/** - * - * @author Adrian Cole - */ -@Test(groups = "live", testName = "CloudStackSubnetApiLiveTest") -public class CloudStackSubnetApiLiveTest extends SubnetApiLiveTest { - public CloudStackSubnetApiLiveTest() { - provider = "cloudstack-ec2"; - } -} diff --git a/labs/cloudstack-ec2/src/test/java/org/jclouds/cloudstack/ec2/internal/BaseCloudStackEC2RestClientExpectTest.java b/labs/cloudstack-ec2/src/test/java/org/jclouds/cloudstack/ec2/internal/BaseCloudStackEC2RestClientExpectTest.java deleted file mode 100644 index 431eb42ab7..0000000000 --- a/labs/cloudstack-ec2/src/test/java/org/jclouds/cloudstack/ec2/internal/BaseCloudStackEC2RestClientExpectTest.java +++ /dev/null @@ -1,54 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.cloudstack.ec2.internal; - -import org.jclouds.cloudstack.ec2.config.CloudStackEC2RestClientModule; -import org.jclouds.date.DateService; -import org.jclouds.ec2.EC2Client; -import org.jclouds.rest.ConfiguresRestClient; -import org.jclouds.rest.internal.BaseRestClientExpectTest; - -import com.google.inject.Module; -import com.google.inject.Provides; - -/** - * - * @author Adrian Cole - */ -public abstract class BaseCloudStackEC2RestClientExpectTest extends BaseRestClientExpectTest { - protected static final String CONSTANT_DATE = "2012-04-16T15:54:08.897Z"; - - public BaseCloudStackEC2RestClientExpectTest() { - provider = "cloudstack-ec2"; - } - - @ConfiguresRestClient - private static final class TestCloudStackEC2RestClientModule extends CloudStackEC2RestClientModule { - @Override - @Provides - protected String provideTimeStamp(DateService dateService) { - return CONSTANT_DATE; - } - } - - @Override - protected Module createModule() { - return new TestCloudStackEC2RestClientModule(); - } -} diff --git a/labs/cloudstack-ec2/src/test/java/org/jclouds/cloudstack/ec2/services/CloudStackEC2AMIClientLiveTest.java b/labs/cloudstack-ec2/src/test/java/org/jclouds/cloudstack/ec2/services/CloudStackEC2AMIClientLiveTest.java deleted file mode 100644 index 3855c924b5..0000000000 --- a/labs/cloudstack-ec2/src/test/java/org/jclouds/cloudstack/ec2/services/CloudStackEC2AMIClientLiveTest.java +++ /dev/null @@ -1,34 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.cloudstack.ec2.services; - -import org.jclouds.ec2.services.AMIClientLiveTest; -import org.testng.annotations.Test; - -/** - * - * @author Adrian Cole - */ -@Test(groups = "live", singleThreaded = true, testName = "CloudStackEC2AMIClientLiveTest") -public class CloudStackEC2AMIClientLiveTest extends AMIClientLiveTest { - public CloudStackEC2AMIClientLiveTest() { - provider = "cloudstack-ec2"; - } - -} diff --git a/labs/cloudstack-ec2/src/test/java/org/jclouds/cloudstack/ec2/services/CloudStackEC2AvailabilityZoneAndRegionClientLiveTest.java b/labs/cloudstack-ec2/src/test/java/org/jclouds/cloudstack/ec2/services/CloudStackEC2AvailabilityZoneAndRegionClientLiveTest.java deleted file mode 100644 index ee031cec02..0000000000 --- a/labs/cloudstack-ec2/src/test/java/org/jclouds/cloudstack/ec2/services/CloudStackEC2AvailabilityZoneAndRegionClientLiveTest.java +++ /dev/null @@ -1,34 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.cloudstack.ec2.services; - -import org.jclouds.ec2.services.AvailabilityZoneAndRegionClientLiveTest; -import org.testng.annotations.Test; - -/** - * - * @author Adrian Cole - */ -@Test(groups = "live", singleThreaded = true, testName = "CloudStackEC2AvailabilityZoneAndRegionClientLiveTest") -public class CloudStackEC2AvailabilityZoneAndRegionClientLiveTest extends AvailabilityZoneAndRegionClientLiveTest { - public CloudStackEC2AvailabilityZoneAndRegionClientLiveTest() { - provider = "cloudstack-ec2"; - } - -} diff --git a/labs/cloudstack-ec2/src/test/java/org/jclouds/cloudstack/ec2/services/CloudStackEC2ElasticBlockStoreClientLiveTest.java b/labs/cloudstack-ec2/src/test/java/org/jclouds/cloudstack/ec2/services/CloudStackEC2ElasticBlockStoreClientLiveTest.java deleted file mode 100644 index a7f571414c..0000000000 --- a/labs/cloudstack-ec2/src/test/java/org/jclouds/cloudstack/ec2/services/CloudStackEC2ElasticBlockStoreClientLiveTest.java +++ /dev/null @@ -1,34 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.cloudstack.ec2.services; - -import org.jclouds.ec2.services.ElasticBlockStoreClientLiveTest; -import org.testng.annotations.Test; - -/** - * - * @author Adrian Cole - */ -@Test(groups = "live", singleThreaded = true, testName = "CloudStackEC2ElasticBlockStoreClientLiveTest") -public class CloudStackEC2ElasticBlockStoreClientLiveTest extends ElasticBlockStoreClientLiveTest { - public CloudStackEC2ElasticBlockStoreClientLiveTest() { - provider = "cloudstack-ec2"; - } - -} diff --git a/labs/cloudstack-ec2/src/test/java/org/jclouds/cloudstack/ec2/services/CloudStackEC2ElasticIPAddressClientLiveTest.java b/labs/cloudstack-ec2/src/test/java/org/jclouds/cloudstack/ec2/services/CloudStackEC2ElasticIPAddressClientLiveTest.java deleted file mode 100644 index 4d46dab289..0000000000 --- a/labs/cloudstack-ec2/src/test/java/org/jclouds/cloudstack/ec2/services/CloudStackEC2ElasticIPAddressClientLiveTest.java +++ /dev/null @@ -1,34 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.cloudstack.ec2.services; - -import org.jclouds.ec2.services.ElasticIPAddressClientLiveTest; -import org.testng.annotations.Test; - -/** - * - * @author Adrian Cole - */ -@Test(groups = "live", singleThreaded = true, testName = "CloudStackEC2ElasticIPAddressClientLiveTest") -public class CloudStackEC2ElasticIPAddressClientLiveTest extends ElasticIPAddressClientLiveTest { - public CloudStackEC2ElasticIPAddressClientLiveTest() { - provider = "cloudstack-ec2"; - } - -} diff --git a/labs/cloudstack-ec2/src/test/java/org/jclouds/cloudstack/ec2/services/CloudStackEC2InstanceClientLiveTest.java b/labs/cloudstack-ec2/src/test/java/org/jclouds/cloudstack/ec2/services/CloudStackEC2InstanceClientLiveTest.java deleted file mode 100644 index 9671981f1f..0000000000 --- a/labs/cloudstack-ec2/src/test/java/org/jclouds/cloudstack/ec2/services/CloudStackEC2InstanceClientLiveTest.java +++ /dev/null @@ -1,34 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.cloudstack.ec2.services; - -import org.jclouds.ec2.services.InstanceClientLiveTest; -import org.testng.annotations.Test; - -/** - * - * @author Adrian Cole - */ -@Test(groups = "live", singleThreaded = true, testName = "CloudStackInstanceClientLiveTest") -public class CloudStackEC2InstanceClientLiveTest extends InstanceClientLiveTest { - public CloudStackEC2InstanceClientLiveTest() { - provider = "cloudstack-ec2"; - } - -} diff --git a/labs/cloudstack-ec2/src/test/java/org/jclouds/cloudstack/ec2/services/CloudStackEC2KeyPairClientLiveTest.java b/labs/cloudstack-ec2/src/test/java/org/jclouds/cloudstack/ec2/services/CloudStackEC2KeyPairClientLiveTest.java deleted file mode 100644 index 8a9f4a9c4b..0000000000 --- a/labs/cloudstack-ec2/src/test/java/org/jclouds/cloudstack/ec2/services/CloudStackEC2KeyPairClientLiveTest.java +++ /dev/null @@ -1,34 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.cloudstack.ec2.services; - -import org.jclouds.ec2.services.KeyPairClientLiveTest; -import org.testng.annotations.Test; - -/** - * - * @author Adrian Cole - */ -@Test(groups = "live", singleThreaded = true, testName = "CloudStackEC2KeyPairClientLiveTest") -public class CloudStackEC2KeyPairClientLiveTest extends KeyPairClientLiveTest { - public CloudStackEC2KeyPairClientLiveTest() { - provider = "cloudstack-ec2"; - } - -} diff --git a/labs/cloudstack-ec2/src/test/java/org/jclouds/cloudstack/ec2/services/CloudStackEC2SecurityGroupClientLiveTest.java b/labs/cloudstack-ec2/src/test/java/org/jclouds/cloudstack/ec2/services/CloudStackEC2SecurityGroupClientLiveTest.java deleted file mode 100644 index bbd1f3e530..0000000000 --- a/labs/cloudstack-ec2/src/test/java/org/jclouds/cloudstack/ec2/services/CloudStackEC2SecurityGroupClientLiveTest.java +++ /dev/null @@ -1,34 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.cloudstack.ec2.services; - -import org.jclouds.ec2.services.SecurityGroupClientLiveTest; -import org.testng.annotations.Test; - -/** - * - * @author Adrian Cole - */ -@Test(groups = "live", singleThreaded = true, testName = "CloudStackEC2SecurityGroupClientLiveTest") -public class CloudStackEC2SecurityGroupClientLiveTest extends SecurityGroupClientLiveTest { - public CloudStackEC2SecurityGroupClientLiveTest() { - provider = "cloudstack-ec2"; - } - -} diff --git a/labs/dmtf/pom.xml b/labs/dmtf/pom.xml deleted file mode 100644 index 1e301253f1..0000000000 --- a/labs/dmtf/pom.xml +++ /dev/null @@ -1,52 +0,0 @@ - - - - 4.0.0 - - org.jclouds.labs - jclouds-labs-project - 1.7.0-SNAPSHOT - ../project/pom.xml - - dmtf - jclouds dmtf domain objects - jclouds implementation of DMTF OVF and CIM domain objects - bundle - - - org.jclouds.dmtf.*;version="${project.version}" - - org.jclouds.labs*;version="${project.version}", - org.jclouds*;version="${jclouds.version}", - * - - - - - - org.jclouds - jclouds-compute - ${jclouds.version} - - - - diff --git a/labs/dmtf/src/main/java/org/jclouds/dmtf/CIMPredicates.java b/labs/dmtf/src/main/java/org/jclouds/dmtf/CIMPredicates.java deleted file mode 100644 index 485877b765..0000000000 --- a/labs/dmtf/src/main/java/org/jclouds/dmtf/CIMPredicates.java +++ /dev/null @@ -1,59 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.dmtf; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.Set; - -import org.jclouds.dmtf.cim.ResourceAllocationSettingData; -import org.jclouds.dmtf.cim.ResourceAllocationSettingData.ResourceType; - -import com.google.common.base.Predicate; -import com.google.common.collect.ImmutableSet; - -/** - * - * @author danikov - */ -public class CIMPredicates { - - /** - * Return resource allocations of the specific type. - * - * @param type - * type to match the items - * @return predicate - */ - public static Predicate resourceTypeIn(final ResourceType... types) { - checkNotNull(types, "resourceTypes"); - final Set resourceTypes = ImmutableSet.copyOf(types); - return new Predicate() { - @Override - public boolean apply(ResourceAllocationSettingData in) { - return resourceTypes.contains(in.getResourceType()); - } - - @Override - public String toString() { - return "resourceTypeIn(" + resourceTypes + ")"; - } - }; - } -} diff --git a/labs/dmtf/src/main/java/org/jclouds/dmtf/DMTFConstants.java b/labs/dmtf/src/main/java/org/jclouds/dmtf/DMTFConstants.java deleted file mode 100644 index decf84dbb6..0000000000 --- a/labs/dmtf/src/main/java/org/jclouds/dmtf/DMTFConstants.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.dmtf; - -/** - * Constants used by DMTF. - * - * @author grkvlt@apache.org - */ -public class DMTFConstants { - - public static final String OVF_NS = "http://schemas.dmtf.org/ovf/envelope/1"; - - public static final String OVF_ENV_NS = "http://schemas.dmtf.org/ovf/environment/1"; - - public static final String CIM_NS = "http://schemas.dmtf.org/wbem/wscim/1/common"; - - public static final String CIM_VSSD_NS = "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData"; - - public static final String CIM_RASD_NS = "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData"; -} diff --git a/labs/dmtf/src/main/java/org/jclouds/dmtf/cim/CimAnySimpleType.java b/labs/dmtf/src/main/java/org/jclouds/dmtf/cim/CimAnySimpleType.java deleted file mode 100644 index 10dd2a72df..0000000000 --- a/labs/dmtf/src/main/java/org/jclouds/dmtf/cim/CimAnySimpleType.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.dmtf.cim; - -import static org.jclouds.dmtf.DMTFConstants.CIM_NS; - -import java.util.Map; - -import javax.xml.bind.annotation.XmlAnyAttribute; -import javax.xml.bind.annotation.XmlSchemaType; -import javax.xml.bind.annotation.XmlType; -import javax.xml.bind.annotation.XmlValue; -import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; -import javax.xml.namespace.QName; - -import com.google.common.collect.Maps; - -/** - *

Java class for cimAnySimpleType complex type. - * - *

- * <complexType name="cimAnySimpleType" />
- * 
- */ -@XmlType(name = "cimAnySimpleType", namespace = CIM_NS) -public class CimAnySimpleType { - - @XmlValue - @XmlJavaTypeAdapter(CimAnySimpleTypeAdapter.class) - @XmlSchemaType(name = "anySimpleType") - protected String value; - @XmlAnyAttribute - private Map otherAttributes = Maps.newHashMap(); - - /** - * Gets the value of the value property. - */ - public String getValue() { - return value; - } - - /** - * Sets the value of the value property. - */ - public void setValue(String value) { - this.value = value; - } - - /** - * Gets a map that contains attributes that aren't bound to any typed property on this class. - */ - public Map getOtherAttributes() { - return otherAttributes; - } -} diff --git a/labs/dmtf/src/main/java/org/jclouds/dmtf/cim/CimAnySimpleTypeAdapter.java b/labs/dmtf/src/main/java/org/jclouds/dmtf/cim/CimAnySimpleTypeAdapter.java deleted file mode 100644 index 9e51410c8c..0000000000 --- a/labs/dmtf/src/main/java/org/jclouds/dmtf/cim/CimAnySimpleTypeAdapter.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.dmtf.cim; - -import javax.xml.bind.annotation.adapters.XmlAdapter; - -public class CimAnySimpleTypeAdapter extends XmlAdapter { - - @Override - public String unmarshal(String value) { - return javax.xml.bind.DatatypeConverter.parseAnySimpleType(value); - } - - @Override - public String marshal(String value) { - if (value == null) { - return null; - } - return javax.xml.bind.DatatypeConverter.printAnySimpleType(value); - } - -} diff --git a/labs/dmtf/src/main/java/org/jclouds/dmtf/cim/CimBoolean.java b/labs/dmtf/src/main/java/org/jclouds/dmtf/cim/CimBoolean.java deleted file mode 100644 index 3102938697..0000000000 --- a/labs/dmtf/src/main/java/org/jclouds/dmtf/cim/CimBoolean.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.dmtf.cim; - -import static org.jclouds.dmtf.DMTFConstants.CIM_NS; - -import java.util.Map; - -import javax.xml.bind.annotation.XmlAnyAttribute; -import javax.xml.bind.annotation.XmlType; -import javax.xml.bind.annotation.XmlValue; -import javax.xml.namespace.QName; - -import com.google.common.collect.Maps; - -/** - * Java class for cimBoolean complex type. - * - *
- * <complexType name="cimBoolean" />
- * 
- */ -@XmlType(name = "cimBoolean", namespace = CIM_NS) -public class CimBoolean { - - @XmlValue - protected boolean value; - @XmlAnyAttribute - private Map otherAttributes = Maps.newHashMap(); - - /** - * Gets the value of the value property. - * - */ - public boolean isValue() { - return value; - } - - /** - * Sets the value of the value property. - * - */ - public void setValue(boolean value) { - this.value = value; - } - - /** - * Gets a map that contains attributes that aren't bound to any typed property on this class. - * - *

- * the map is keyed by the name of the attribute and - * the value is the string value of the attribute. - * - * the map returned by this method is live, and you can add new attribute - * by updating the map directly. Because of this design, there's no setter. - * - * - * @return - * always non-null - */ - public Map getOtherAttributes() { - return otherAttributes; - } - -} diff --git a/labs/dmtf/src/main/java/org/jclouds/dmtf/cim/CimReference.java b/labs/dmtf/src/main/java/org/jclouds/dmtf/cim/CimReference.java deleted file mode 100644 index 88689b912d..0000000000 --- a/labs/dmtf/src/main/java/org/jclouds/dmtf/cim/CimReference.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.dmtf.cim; - -import static org.jclouds.dmtf.DMTFConstants.CIM_NS; - -import java.util.List; -import java.util.Map; - -import javax.xml.bind.annotation.XmlAnyAttribute; -import javax.xml.bind.annotation.XmlAnyElement; -import javax.xml.bind.annotation.XmlType; -import javax.xml.namespace.QName; - -import com.google.common.collect.Lists; -import com.google.common.collect.Maps; - -/** - * Java class for cimReference complex type. - * - *

- * <complexType name="cimReference" />
- * 
- */ -@XmlType(name = "cimReference", namespace = CIM_NS) -public class CimReference { - - @XmlAnyElement(lax = true) - protected List any; - @XmlAnyAttribute - private Map otherAttributes = Maps.newHashMap(); - - /** - * Gets the value of the any property. - * - *

- * This accessor method returns a reference to the live list, - * not a snapshot. Therefore any modification you make to the - * returned list will be present inside the JAXB object. - * This is why there is not a set method for the any property. - * - *

- * For example, to add a new item, do as follows: - *

-     *    getAny().add(newItem);
-     * 
- * - * - *

- * Objects of the following type(s) are allowed in the list - * {@link Object } - * {@link Element } - * - * - */ - public List getAny() { - if (any == null) { - any = Lists.newArrayList(); - } - return this.any; - } - - /** - * Gets a map that contains attributes that aren't bound to any typed property on this class. - * - *

- * the map is keyed by the name of the attribute and - * the value is the string value of the attribute. - * - * the map returned by this method is live, and you can add new attribute - * by updating the map directly. Because of this design, there's no setter. - * - * - * @return - * always non-null - */ - public Map getOtherAttributes() { - return otherAttributes; - } - -} diff --git a/labs/dmtf/src/main/java/org/jclouds/dmtf/cim/CimString.java b/labs/dmtf/src/main/java/org/jclouds/dmtf/cim/CimString.java deleted file mode 100644 index 749b7b93e3..0000000000 --- a/labs/dmtf/src/main/java/org/jclouds/dmtf/cim/CimString.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.dmtf.cim; - -import static com.google.common.base.Objects.equal; - -import java.util.Map; - -import javax.xml.bind.annotation.XmlAnyAttribute; -import javax.xml.bind.annotation.XmlType; -import javax.xml.bind.annotation.XmlValue; -import javax.xml.namespace.QName; - -import com.google.common.base.Objects; -import com.google.common.collect.Maps; - -/** - * Java class for cimString complex type. - * - *

- * <complexType name="cimString" />
- * 
- */ -@XmlType(name = "cimString") -public class CimString { - - public CimString() { - // JAXB - } - - public CimString(String value) { - this.value = value; - } - - @XmlValue - protected String value; - @XmlAnyAttribute - private Map otherAttributes = Maps.newHashMap(); - - /** - * Gets the value of the value property. - */ - public String getValue() { - return value; - } - - public void setValue(String value) { - this.value = value; - } - - /** - * Gets a map that contains attributes that aren't bound to any typed property on this class. - */ - public Map getOtherAttributes() { - return otherAttributes; - } - - @Override - public int hashCode() { - return Objects.hashCode(value); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - CimString that = CimString.class.cast(obj); - return equal(this.value, that.value); - } - - @Override - public String toString() { - return Objects.toStringHelper("").add("value", value).toString(); - } - -} diff --git a/labs/dmtf/src/main/java/org/jclouds/dmtf/cim/CimUnsignedInt.java b/labs/dmtf/src/main/java/org/jclouds/dmtf/cim/CimUnsignedInt.java deleted file mode 100644 index 48375acc3c..0000000000 --- a/labs/dmtf/src/main/java/org/jclouds/dmtf/cim/CimUnsignedInt.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.dmtf.cim; - -import java.util.Map; - -import javax.xml.bind.annotation.XmlAnyAttribute; -import javax.xml.bind.annotation.XmlSchemaType; -import javax.xml.bind.annotation.XmlType; -import javax.xml.bind.annotation.XmlValue; -import javax.xml.namespace.QName; - -import com.google.common.collect.Maps; - -/** - * Java class for cimUnsignedInt complex type. - * - *
- * <complexType name="cimUnsignedInt" />
- * 
- */ -@XmlType(name = "cimUnsignedInt", namespace = "http://schemas.dmtf.org/wbem/wscim/1/common") -public class CimUnsignedInt { - - @XmlValue - @XmlSchemaType(name = "unsignedInt") - protected long value; - @XmlAnyAttribute - private Map otherAttributes = Maps.newHashMap(); - - /** - * Gets the value of the value property. - * - */ - public long getValue() { - return value; - } - - /** - * Sets the value of the value property. - * - */ - public void setValue(long value) { - this.value = value; - } - - /** - * Gets a map that contains attributes that aren't bound to any typed property on this class. - * - *

- * the map is keyed by the name of the attribute and - * the value is the string value of the attribute. - * - * the map returned by this method is live, and you can add new attribute - * by updating the map directly. Because of this design, there's no setter. - * - * - * @return - * always non-null - */ - public Map getOtherAttributes() { - return otherAttributes; - } - -} diff --git a/labs/dmtf/src/main/java/org/jclouds/dmtf/cim/CimUnsignedLong.java b/labs/dmtf/src/main/java/org/jclouds/dmtf/cim/CimUnsignedLong.java deleted file mode 100644 index 9572d9d079..0000000000 --- a/labs/dmtf/src/main/java/org/jclouds/dmtf/cim/CimUnsignedLong.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.dmtf.cim; - -import java.math.BigInteger; -import java.util.Map; - -import javax.xml.bind.annotation.XmlAnyAttribute; -import javax.xml.bind.annotation.XmlSchemaType; -import javax.xml.bind.annotation.XmlType; -import javax.xml.bind.annotation.XmlValue; -import javax.xml.namespace.QName; - -import com.google.common.collect.Maps; - -/** - * Java class for cimUnsignedLong complex type. - * - *

- * <complexType name="cimUnsignedLong" />
- * 
- */ -@XmlType(name = "cimUnsignedLong", namespace = "http://schemas.dmtf.org/wbem/wscim/1/common") -public class CimUnsignedLong { - - @XmlValue - @XmlSchemaType(name = "unsignedLong") - protected BigInteger value; - @XmlAnyAttribute - private Map otherAttributes = Maps.newHashMap(); - - /** - * Gets the value of the value property. - * - * @return - * possible object is - * {@link BigInteger } - * - */ - public BigInteger getValue() { - return value; - } - - /** - * Sets the value of the value property. - * - * @param value - * allowed object is - * {@link BigInteger } - * - */ - public void setValue(BigInteger value) { - this.value = value; - } - - /** - * Gets a map that contains attributes that aren't bound to any typed property on this class. - * - *

- * the map is keyed by the name of the attribute and - * the value is the string value of the attribute. - * - * the map returned by this method is live, and you can add new attribute - * by updating the map directly. Because of this design, there's no setter. - * - * - * @return - * always non-null - */ - public Map getOtherAttributes() { - return otherAttributes; - } - -} diff --git a/labs/dmtf/src/main/java/org/jclouds/dmtf/cim/CimUnsignedShort.java b/labs/dmtf/src/main/java/org/jclouds/dmtf/cim/CimUnsignedShort.java deleted file mode 100644 index 928215af0a..0000000000 --- a/labs/dmtf/src/main/java/org/jclouds/dmtf/cim/CimUnsignedShort.java +++ /dev/null @@ -1,79 +0,0 @@ -// -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 -// See http://java.sun.com/xml/jaxb -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2012.02.08 at 02:47:44 PM GMT -// - - -package org.jclouds.dmtf.cim; - -import java.util.Map; - -import javax.xml.bind.annotation.XmlAnyAttribute; -import javax.xml.bind.annotation.XmlSchemaType; -import javax.xml.bind.annotation.XmlType; -import javax.xml.bind.annotation.XmlValue; -import javax.xml.namespace.QName; - -import com.google.common.collect.Maps; - -/** - *

Java class for cimUnsignedShort complex type. - * - *

The following schema fragment specifies the expected content contained within this class. - * - *

- * <complexType name="cimUnsignedShort">
- *   <simpleContent>
- *     <extension base="<http://www.w3.org/2001/XMLSchema>unsignedShort">
- *       <anyAttribute processContents='lax'/>
- *     </extension>
- *   </simpleContent>
- * </complexType>
- * 
- */ -@XmlType(name = "cimUnsignedShort", namespace = "http://schemas.dmtf.org/wbem/wscim/1/common") -public class CimUnsignedShort { - - @XmlValue - @XmlSchemaType(name = "unsignedShort") - protected int value; - @XmlAnyAttribute - private Map otherAttributes = Maps.newHashMap(); - - /** - * Gets the value of the value property. - * - */ - public int getValue() { - return value; - } - - /** - * Sets the value of the value property. - * - */ - public void setValue(int value) { - this.value = value; - } - - /** - * Gets a map that contains attributes that aren't bound to any typed property on this class. - * - *

- * the map is keyed by the name of the attribute and - * the value is the string value of the attribute. - * - * the map returned by this method is live, and you can add new attribute - * by updating the map directly. Because of this design, there's no setter. - * - * - * @return - * always non-null - */ - public Map getOtherAttributes() { - return otherAttributes; - } - -} diff --git a/labs/dmtf/src/main/java/org/jclouds/dmtf/cim/OSType.java b/labs/dmtf/src/main/java/org/jclouds/dmtf/cim/OSType.java deleted file mode 100644 index ae6af4231e..0000000000 --- a/labs/dmtf/src/main/java/org/jclouds/dmtf/cim/OSType.java +++ /dev/null @@ -1,201 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.dmtf.cim; - -import org.jclouds.compute.domain.OsFamily; - -/** - * Operating system based on DMTF CIM model. - * - * @author Adrian Cole - * @see - */ -public enum OSType { - - /** Other */ - OTHER(1, "Other", OsFamily.UNRECOGNIZED, false), - - /** MACOS */ - MACOS(2, "MACOS", OsFamily.DARWIN, false), - - /** Solaris */ - SOLARIS(29, "Solaris", OsFamily.SOLARIS, false), - - /** LINUX */ - LINUX(36, "LINUX", OsFamily.LINUX, false), - - /** FreeBSD */ - FREEBSD(42, "FreeBSD", OsFamily.FREEBSD, false), - - /** NetBSD */ - NETBSD(43, "NetBSD", OsFamily.NETBSD, false), - - /** OpenBSD */ - OPENBSD(65, "OpenBSD", OsFamily.OPENBSD, false), - - /** Not Applicable */ - NOT_APPLICABLE(66, "Not Applicable", OsFamily.UNRECOGNIZED, false), - - /** Microsoft Windows Server 2003 */ - WINDOWS_SERVER_2003(69, "Microsoft Windows Server 2003", OsFamily.WINDOWS, false), - - /** Microsoft Windows Server 2003 64-Bit */ - WINDOWS_SERVER_2003_64(70, "Microsoft Windows Server 2003 64-Bit", OsFamily.WINDOWS, true), - - /** Microsoft Windows Server 2008 */ - WINDOWS_SERVER_2008(76, "Microsoft Windows Server 2008", OsFamily.WINDOWS, false), - - /** Microsoft Windows Server 2008 64-Bit */ - WINDOWS_SERVER_2008_64(77, "Microsoft Windows Server 2008 64-Bit", OsFamily.WINDOWS, true), - - /** FreeBSD 64-Bit */ - FREEBSD_64(78, "FreeBSD 64-Bit", OsFamily.FREEBSD, true), - - /** RedHat Enterprise Linux */ - RHEL(79, "RedHat Enterprise Linux", OsFamily.RHEL, false), - - /** RedHat Enterprise Linux 64-Bit */ - RHEL_64(80, "RedHat Enterprise Linux 64-Bit", OsFamily.RHEL, true), - - /** Solaris 64-Bit */ - SOLARIS_64(81, "Solaris 64-Bit", OsFamily.SOLARIS, true), - - /** SUSE */ - SUSE(82, "SUSE", OsFamily.SUSE, false), - - /** SUSE 64-Bit */ - SUSE_64(83, "SUSE 64-Bit", OsFamily.SUSE, true), - - /** SLES */ - SLES(84, "SLES", OsFamily.SUSE, false), - - /** SLES 64-Bit */ - SLES_64(85, "SLES 64-Bit", OsFamily.SUSE, true), - - /** Novell OES */ - NOVELL_OES(86, "Novell OES", OsFamily.SUSE, true), - - /** Mandriva */ - MANDRIVA(89, "Mandriva", OsFamily.MANDRIVA, false), - - /** Mandriva 64-Bit */ - MANDRIVA_64(90, "Mandriva 64-Bit", OsFamily.MANDRIVA, true), - - /** TurboLinux */ - TURBOLINUX(91, "TurboLinux", OsFamily.TURBOLINUX, false), - - /** TurboLinux 64-Bit */ - TURBOLINUX_64(92, "TurboLinux 64-Bit", OsFamily.TURBOLINUX, true), - - /** Ubuntu */ - UBUNTU(93, "Ubuntu", OsFamily.UBUNTU, false), - - /** Ubuntu 64-Bit */ - UBUNTU_64(94, "Ubuntu 64-Bit", OsFamily.UBUNTU, true), - - /** Debian */ - DEBIAN(95, "Debian", OsFamily.DEBIAN, false), - - /** Debian 64-Bit */ - DEBIAN_64(96, "Debian 64-Bit", OsFamily.DEBIAN, false), - - /** Linux 2.4.x */ - LINUX_2_4(97, "Linux 2.4.x", OsFamily.LINUX, false), - - /** Linux 2.4.x 64-Bi */ - LINUX_2_4_64(98, "Linux 2.4.x 64-Bit", OsFamily.LINUX, true), - - /** Linux 2.6.x */ - LINUX_2_6(99, "Linux 2.6.x", OsFamily.LINUX, false), - - /** Linux 2.6.x 64-Bit */ - LINUX_2_6_64(100, "Linux 2.6.x 64-Bit", OsFamily.LINUX, true), - - /** Linux 64-Bit */ - LINUX_64(101, "Linux 64-Bit", OsFamily.LINUX, true), - - /** Other 64-Bit */ - OTHER_64(102, "Other 64-Bit", OsFamily.UNRECOGNIZED, true), - - /** Microsoft Windows Server 2008 R2 */ - WINDOWS_SERVER_2008_R2(103, "Microsoft Windows Server 2008 R2", OsFamily.WINDOWS, true), - - /** VMware ESXi */ - ESXI(104, "VMware ESXi", OsFamily.ESX, true), - - /** Microsoft Windows 7 */ - WINDOWS_7(105, "Microsoft Windows 7", OsFamily.WINDOWS, false), - - /** CentOS 32-bit */ - CENTOS(106, "CentOS 32-bit", OsFamily.CENTOS, false), - - /** CentOS 64-bit */ - CENTOS_64(107, "CentOS 64-bit", OsFamily.CENTOS, true), - - /** Oracle Enterprise Linux 32-bit */ - ORACLE_ENTERPRISE_LINUX(108, "Oracle Enterprise Linux 32-bit", OsFamily.OEL, false), - - /** Oracle Enterprise Linux 64-bit */ - ORACLE_ENTERPRISE_LINUX_64(109, "Oracle Enterprise Linux 64-bit", OsFamily.OEL, true), - - /** eComStation 32-bitx */ - ECOMSTATION_32(109, "eComStation 32-bitx", OsFamily.UNRECOGNIZED, false), - - UNRECOGNIZED(Integer.MAX_VALUE, "UNRECOGNIZED", null, true); - - private final int code; - - public int getCode() { - return code; - } - - public String getValue() { - return value; - } - - public OsFamily getFamily() { - return family; - } - - public boolean is64Bit() { - return is64Bit; - } - - private final String value; - private final OsFamily family; - private final boolean is64Bit; - - OSType(int code, String value, OsFamily family, boolean is64Bit) { - this.code = code; - this.value = value; - this.family = family; - this.is64Bit = is64Bit; - } - - public static OSType fromValue(int code) { - for (OSType type : values()) { - if (type.code == code) - return type; - } - return UNRECOGNIZED; - } - -} diff --git a/labs/dmtf/src/main/java/org/jclouds/dmtf/cim/ResourceAllocationCaption.java b/labs/dmtf/src/main/java/org/jclouds/dmtf/cim/ResourceAllocationCaption.java deleted file mode 100644 index c2067437ee..0000000000 --- a/labs/dmtf/src/main/java/org/jclouds/dmtf/cim/ResourceAllocationCaption.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.dmtf.cim; - -import javax.xml.bind.annotation.XmlType; - -/** - * Java class for anonymous complex type. - */ -@XmlType(name = "") -public class ResourceAllocationCaption extends CimString { - - -} diff --git a/labs/dmtf/src/main/java/org/jclouds/dmtf/cim/ResourceAllocationChangeableType.java b/labs/dmtf/src/main/java/org/jclouds/dmtf/cim/ResourceAllocationChangeableType.java deleted file mode 100644 index 787313a9e6..0000000000 --- a/labs/dmtf/src/main/java/org/jclouds/dmtf/cim/ResourceAllocationChangeableType.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.dmtf.cim; - -import javax.xml.bind.annotation.XmlType; - -/** - * Java class for anonymous complex type. - */ -@XmlType(name = "") -public class ResourceAllocationChangeableType extends CimUnsignedShort { - - -} diff --git a/labs/dmtf/src/main/java/org/jclouds/dmtf/cim/ResourceAllocationSettingData.java b/labs/dmtf/src/main/java/org/jclouds/dmtf/cim/ResourceAllocationSettingData.java deleted file mode 100644 index db6eea1906..0000000000 --- a/labs/dmtf/src/main/java/org/jclouds/dmtf/cim/ResourceAllocationSettingData.java +++ /dev/null @@ -1,906 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.dmtf.cim; - -import static com.google.common.base.Objects.equal; -import static com.google.common.base.Preconditions.checkNotNull; -import static org.jclouds.dmtf.DMTFConstants.CIM_RASD_NS; -import static org.jclouds.dmtf.DMTFConstants.OVF_NS; - -import java.math.BigInteger; -import java.util.Map; -import java.util.Set; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlEnum; -import javax.xml.bind.annotation.XmlEnumValue; -import javax.xml.bind.annotation.XmlType; - -import com.google.common.base.Function; -import com.google.common.base.Objects; -import com.google.common.base.Objects.ToStringHelper; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Maps; -import com.google.common.collect.Sets; - -/** - * The ResourceAllocationSettingData class represents settings specifically - * related to an allocated resource that are outside the scope of the CIM class - * typically used to represent the resource itself. - * - * These settings include information specific to the allocation that may not - * be visible to the consumer of the resource itself. For example, a virtual - * processor may look like a 2 GHz processor to the consumer (virtual computer - * system), however the virtualization system may use time-slicing to schedule - * the the virtual processor to only allow it to use 1 GHz. - * - * @author Adrian Cole - * @author grkvlt@apache.org - * @see CIM_ResourceAllocationSettingData - */ -@XmlType(name = "CIM_ResourceAllocationSettingData_Type", namespace = OVF_NS, - propOrder = { - "address", - "addressOnParent", - "allocationUnits", - "automaticAllocation", - "automaticDeallocation", - "caption", - "connections", - "consumerVisibility", - "description", - "elementName", - "hostResources", - "instanceID", - "limit", - "mappingBehavior", - "otherResourceType", - "parent", - "poolID", - "reservation", - "resourceSubType", - "resourceType", - "virtualQuantity", - "virtualQuantityUnits", - "weight" - } -) -public class ResourceAllocationSettingData { - - public static Builder builder() { - return new ConcreteBuilder(); - } - - public Builder toBuilder() { - return builder().fromResourceAllocationSettingData(this); - } - - private static class ConcreteBuilder extends Builder { - } - - public static class Builder> { - - private String elementName; - private String instanceID; - private String caption; - private String description; - private String address; - private String addressOnParent; - private String allocationUnits; - private Boolean automaticAllocation; - private Boolean automaticDeallocation; - private ConsumerVisibility consumerVisibility; - private BigInteger limit; - private MappingBehavior mappingBehavior; - private String otherResourceType; - private String parent; - private String poolID; - private BigInteger reservation; - private String resourceSubType; - private ResourceType resourceType; - private BigInteger virtualQuantity; - private String virtualQuantityUnits; - private Long weight; - private Set connections = Sets.newLinkedHashSet(); - private Set hostResources = Sets.newLinkedHashSet(); - - @SuppressWarnings("unchecked") - protected B self() { - return (B) this; - } - - /** - * @see ResourceAllocationSettingData#getElementName() - */ - public B elementName(String elementName) { - this.elementName = elementName; - return self(); - } - - /** - *@see ResourceAllocationSettingData#getInstanceId() - */ - public B instanceID(String instanceID) { - this.instanceID = instanceID; - return self(); - } - - /** - * @see ResourceAllocationSettingData#getCaption() - */ - public B caption(String caption) { - this.caption = caption; - return self(); - } - - /** - * @see ResourceAllocationSettingData#getDescription() - */ - public B description(String description) { - this.description = description; - return self(); - } - - /** - * @see ResourceAllocationSettingData#getAddress - */ - public B address(String address) { - this.address = address; - return self(); - } - - /** - * @see ResourceAllocationSettingData#getAddressOnParent - */ - public B addressOnParent(String addressOnParent) { - this.addressOnParent = addressOnParent; - return self(); - } - - /** - * @see ResourceAllocationSettingData#getAllocationUnits - */ - public B allocationUnits(String allocationUnits) { - this.allocationUnits = allocationUnits; - return self(); - } - - /** - * @see ResourceAllocationSettingData#isAutomaticAllocation() - */ - public B automaticAllocation(Boolean automaticAllocation) { - this.automaticAllocation = automaticAllocation; - return self(); - } - - /** - * @see ResourceAllocationSettingData#isAutomaticDeallocation() - */ - public B automaticDeallocation(Boolean automaticDeallocation) { - this.automaticDeallocation = automaticDeallocation; - return self(); - } - - /** - * @see ResourceAllocationSettingData#getConsumerVisibility - */ - public B consumerVisibility(ConsumerVisibility consumerVisibility) { - this.consumerVisibility = consumerVisibility; - return self(); - } - - /** - * @see ResourceAllocationSettingData#getLimit - */ - public B limit(BigInteger limit) { - this.limit = limit; - return self(); - } - - /** - * @see ResourceAllocationSettingData#getMappingBehavior - */ - public B mappingBehavior(MappingBehavior mappingBehavior) { - this.mappingBehavior = mappingBehavior; - return self(); - } - - /** - * @see ResourceAllocationSettingData#getOtherResourceType - */ - public B otherResourceType(String otherResourceType) { - this.otherResourceType = otherResourceType; - return self(); - } - - /** - * @see ResourceAllocationSettingData#getParent - */ - public B parent(String parent) { - this.parent = parent; - return self(); - } - - /** - * @see ResourceAllocationSettingData#getPoolID - */ - public B poolID(String poolID) { - this.poolID = poolID; - return self(); - } - - /** - * @see ResourceAllocationSettingData#getReservation - */ - public B reservation(BigInteger reservation) { - this.reservation = reservation; - return self(); - } - - /** - * @see ResourceAllocationSettingData#getResourceSubType - */ - public B resourceSubType(String resourceSubType) { - this.resourceSubType = resourceSubType; - return self(); - } - - /** - * @see ResourceAllocationSettingData#getResourceType - */ - public B resourceType(ResourceType resourceType) { - this.resourceType = resourceType; - return self(); - } - - /** - * @see ResourceAllocationSettingData#getVirtualQuantity - */ - public B virtualQuantity(BigInteger virtualQuantity) { - this.virtualQuantity = virtualQuantity; - return self(); - } - - /** - * @see ResourceAllocationSettingData#getVirtualQuantityUnits - */ - public B virtualQuantityUnits(String virtualQuantityUnits) { - this.virtualQuantityUnits = virtualQuantityUnits; - return self(); - } - - /** - * @see ResourceAllocationSettingData#getWeight - */ - public B weight(Long weight) { - this.weight = weight; - return self(); - } - - /** - * @see ResourceAllocationSettingData#getConnections() - */ - public B connection(CimString connection) { - this.connections.add(checkNotNull(connection, "connection")); - return self(); - } - - /** - * @see ResourceAllocationSettingData#getConnections - */ - public B connections(Iterable connections) { - this.connections = Sets.newLinkedHashSet(checkNotNull(connections, "connections")); - return self(); - } - - /** - * @see ResourceAllocationSettingData#getHostResources() - */ - public B hostResource(CimString hostResource) { - this.hostResources.add(checkNotNull(hostResource, "hostResource")); - return self(); - } - - /** - * @see ResourceAllocationSettingData#getHostResources - */ - public B hostResources(Iterable hostResources) { - this.hostResources = Sets.newLinkedHashSet(checkNotNull(hostResources, "hostResources")); - return self(); - } - - public ResourceAllocationSettingData build() { - return new ResourceAllocationSettingData(this); - } - - public B fromResourceAllocationSettingData(ResourceAllocationSettingData in) { - return elementName(in.getElementName()) - .instanceID(in.getInstanceID()) - .caption(in.getCaption()) - .description(in.getDescription()) - .address(in.getAddress()) - .addressOnParent(in.getAddressOnParent()) - .allocationUnits(in.getAllocationUnits()) - .automaticAllocation(in.isAutomaticAllocation()) - .automaticDeallocation(in.isAutomaticDeallocation()) - .consumerVisibility(in.getConsumerVisibility()) - .limit(in.getLimit()) - .mappingBehavior(in.getMappingBehavior()) - .otherResourceType(in.getOtherResourceType()) - .parent(in.getParent()) - .poolID(in.getPoolID()) - .reservation(in.getReservation()) - .resourceSubType(in.getResourceSubType()) - .resourceType(in.getResourceType()) - .virtualQuantity(in.getVirtualQuantity()) - .virtualQuantityUnits(in.getVirtualQuantityUnits()) - .weight(in.getWeight()) - .connections(in.getConnections()) - .hostResources(in.getHostResources()); - } - } - - /** - * The type of resource this allocation setting represents. - */ - @XmlType - @XmlEnum(Integer.class) - public static enum ResourceType { - @XmlEnumValue("1") OTHER(1), - @XmlEnumValue("2") COMPUTER_SYSTEM(2), - @XmlEnumValue("3") PROCESSOR(3), - @XmlEnumValue("4") MEMORY(4), - @XmlEnumValue("5") IDE_CONTROLLER(5), - @XmlEnumValue("6") PARALLEL_SCSI_HBA(6), - @XmlEnumValue("7") FC_HBA(7), - @XmlEnumValue("8") ISCSI_HBA(8), - @XmlEnumValue("9") IB_HCA(9), - @XmlEnumValue("10") ETHERNET_ADAPTER(10), - @XmlEnumValue("11") OTHER_NETWORK_ADAPTER(11), - @XmlEnumValue("12") IO_SLOT(12), - @XmlEnumValue("13") IO_DEVICE(13), - @XmlEnumValue("14") FLOPPY_DRIVE(14), - @XmlEnumValue("15") CD_DRIVE(15), - @XmlEnumValue("16") DVD_DRIVE(16), - @XmlEnumValue("17") DISK_DRIVE(17), - @XmlEnumValue("18") TAPE_DRIVE(18), - @XmlEnumValue("19") STORAGE_EXTENT(19), - @XmlEnumValue("20") OTHER_STORAGE_DEVICE(20), - @XmlEnumValue("21") SERIAL_PORT(21), - @XmlEnumValue("22") PARALLEL_PORT(22), - @XmlEnumValue("23") USB_CONTROLLER(23), - @XmlEnumValue("24") GRAPHICS_CONTROLLER(24), - @XmlEnumValue("25") IEEE_1394_CONTROLLER(25), - @XmlEnumValue("26") PARTITIONABLE_UNIT(26), - @XmlEnumValue("27") BASE_PARTITIONABLE_UNIT(27), - @XmlEnumValue("28") POWER(28), - @XmlEnumValue("29") COOLING_CAPACITY(29), - @XmlEnumValue("30") ETHERNET_SWITCH_PORT(30), - @XmlEnumValue("31") LOGICAL_DISK(31), - @XmlEnumValue("32") STORAGE_VOLUME(32), - @XmlEnumValue("33") ETHERNET_CONNECTION(33), - @XmlEnumValue("32768") DMTF_RESERVED(Integer.valueOf("8000", 16)), - @XmlEnumValue("65535") VENDOR_RESERVED(Integer.valueOf("FFFF", 16)); - - protected final int code; - - ResourceType(int code) { - this.code = code; - } - - public String value() { - return Integer.toString(code); - } - - protected static final Map RESOURCE_TYPE_BY_ID = Maps.uniqueIndex( - ImmutableSet.copyOf(ResourceType.values()), new Function() { - @Override - public Integer apply(ResourceType input) { - return input.code; - } - }); - - public static ResourceType fromValue(String type) { - return RESOURCE_TYPE_BY_ID.get(Integer.valueOf(checkNotNull(type, "type"))); - } - } - - /** - * Describes the consumers visibility to the allocated resource. - */ - @XmlType - @XmlEnum(Integer.class) - public static enum ConsumerVisibility { - @XmlEnumValue("0") UNKNOWN(0), - - /** - * indicates the underlying or host resource is utilized and passed - * through to the consumer, possibly using partitioning. At least one item - * shall be present in the HostResource property. - */ - @XmlEnumValue("2") PASSED_THROUGH(2), - - /** - * indicates the resource is virtualized and may not map directly to an - * underlying/host resource. Some implementations may support specific - * assignment for virtualized resources, in which case the host - * resource(s) are exposed using the HostResource property. - */ - @XmlEnumValue("3") VIRTUALIZED(3), - - /** - * indicates a representation of the resource does not exist within the - * context of the resource consumer. - */ - @XmlEnumValue("4") NOT_REPRESENTED(4), - @XmlEnumValue("32768") DMTF_RESERVED(Integer.valueOf("8000", 16)), - @XmlEnumValue("65535") VENDOR_RESERVED(Integer.valueOf("FFFF", 16)); - - protected final int code; - - ConsumerVisibility(int code) { - this.code = code; - } - - public String value() { - return Integer.toString(code); - } - - protected static final Map MAPPING_BEHAVIOR_BY_ID = Maps.uniqueIndex( - ImmutableSet.copyOf(ConsumerVisibility.values()), new Function() { - @Override - public Integer apply(ConsumerVisibility input) { - return input.code; - } - }); - - public static ConsumerVisibility fromValue(String behavior) { - return MAPPING_BEHAVIOR_BY_ID.get(Integer.valueOf(checkNotNull(behavior, "behavior"))); - } - } - - /** - * Specifies how this resource maps to underlying resourcesIf the - * HostResource array contains any entries, this property reflects how the - * resource maps to those specific resources. - */ - @XmlType - @XmlEnum(Integer.class) - public static enum MappingBehavior { - @XmlEnumValue("0") UNKNOWN(0), - @XmlEnumValue("2") NOT_SUPPORTED(2), - @XmlEnumValue("3") DEDICATED(3), - @XmlEnumValue("4") SOFT_AFFINITY(4), - @XmlEnumValue("5") HARD_AFFINITY(5), - @XmlEnumValue("32768") DMTF_RESERVED(Integer.valueOf("8000", 16)), - @XmlEnumValue("65535") VENDOR_RESERVED(Integer.valueOf("FFFF", 16)); - - protected final int code; - - MappingBehavior(int code) { - this.code = code; - } - - public String value() { - return Integer.toString(code); - } - - protected static final Map MAPPING_BEHAVIOR_BY_ID = Maps.uniqueIndex( - ImmutableSet.copyOf(MappingBehavior.values()), new Function() { - @Override - public Integer apply(MappingBehavior input) { - return input.code; - } - }); - - public static MappingBehavior fromValue(String behavior) { - return MAPPING_BEHAVIOR_BY_ID.get(Integer.valueOf(checkNotNull(behavior, "behavior"))); - } - } - - @XmlElement(name = "ElementName", namespace = CIM_RASD_NS) - private String elementName; - @XmlElement(name = "InstanceID", namespace = CIM_RASD_NS) - private String instanceID; - @XmlElement(name = "Caption", namespace = CIM_RASD_NS) - private String caption; - @XmlElement(name = "Description", namespace = CIM_RASD_NS) - private String description; - @XmlElement(name = "Address", namespace = CIM_RASD_NS) - private String address; - @XmlElement(name = "AddressOnParent", namespace = CIM_RASD_NS) - private String addressOnParent; - @XmlElement(name = "AllocationUnits", namespace = CIM_RASD_NS) - private String allocationUnits; - @XmlElement(name = "AutomaticAllocation", namespace = CIM_RASD_NS) - private Boolean automaticAllocation; - @XmlElement(name = "AutomaticDeallocation", namespace = CIM_RASD_NS) - private Boolean automaticDeallocation; - @XmlElement(name = "ConsumerVisibility", namespace = CIM_RASD_NS) - private ConsumerVisibility consumerVisibility; - @XmlElement(name = "Limit", namespace = CIM_RASD_NS) - private BigInteger limit; - @XmlElement(name = "MappingBehavior", namespace = CIM_RASD_NS) - private MappingBehavior mappingBehavior; - @XmlElement(name = "OtherResourceType", namespace = CIM_RASD_NS) - private String otherResourceType; - @XmlElement(name = "Parent", namespace = CIM_RASD_NS) - private String parent; - @XmlElement(name = "PoolID", namespace = CIM_RASD_NS) - private String poolID; - @XmlElement(name = "Reservation", namespace = CIM_RASD_NS) - private BigInteger reservation; - @XmlElement(name = "ResourceSubType", namespace = CIM_RASD_NS) - private String resourceSubType; - @XmlElement(name = "ResourceType", namespace = CIM_RASD_NS) - private ResourceType resourceType; - @XmlElement(name = "VirtualQuantity", namespace = CIM_RASD_NS) - private BigInteger virtualQuantity; - @XmlElement(name = "VirtualQuantityUnits", namespace = CIM_RASD_NS) - private String virtualQuantityUnits; - @XmlElement(name = "Weight", namespace = CIM_RASD_NS) - private Long weight; - @XmlElement(name = "Connection", namespace = CIM_RASD_NS) - private Set connections = Sets.newLinkedHashSet(); - @XmlElement(name = "HostResource", namespace = CIM_RASD_NS) - private Set hostResources = Sets.newLinkedHashSet(); - - protected ResourceAllocationSettingData(Builder builder) { - this.elementName = builder.elementName; - this.instanceID = builder.instanceID; - this.caption = builder.caption; - this.description = builder.description; - this.address = builder.address; - this.addressOnParent = builder.addressOnParent; - this.allocationUnits = builder.allocationUnits; - this.automaticAllocation = builder.automaticAllocation; - this.automaticDeallocation = builder.automaticDeallocation; - this.consumerVisibility = builder.consumerVisibility; - this.limit = builder.limit; - this.mappingBehavior = builder.mappingBehavior; - this.otherResourceType = builder.otherResourceType; - this.parent = builder.parent; - this.poolID = builder.poolID; - this.reservation = builder.reservation; - this.resourceSubType = builder.resourceSubType; - this.resourceType = builder.resourceType; - this.virtualQuantity = builder.virtualQuantity; - this.virtualQuantityUnits = builder.virtualQuantityUnits; - this.weight = builder.weight; - this.connections = builder.connections != null ? ImmutableSet.copyOf(builder.connections) : ImmutableSet.of(); - this.hostResources = builder.hostResources != null ? ImmutableSet.copyOf(builder.hostResources) : ImmutableSet.of(); - } - - protected ResourceAllocationSettingData() { - // for JAXB - } - - /** - * The user-friendly name for this instance of SettingData. In addition, the user-friendly name - * can be used as an index property for a search or query. (Note: The name does not have to be - * unique within a namespace.) - */ - public String getElementName() { - return elementName; - } - - /** - * Within the scope of the instantiating Namespace, InstanceID opaquely and uniquely identifies - * an instance of this class. - */ - public String getInstanceID() { - return instanceID; - } - - /** - * The Caption property is a short textual description (one- line string) of the object. - */ - public String getCaption() { - return caption; - } - - /** - * The Description property provides a textual description of the object. - */ - public String getDescription() { - return description; - } - - /** - * The address of the resource. For example, the MAC address of a Ethernet - * port. - */ - public String getAddress() { - return address; - } - - /** - * Describes the address of this resource in the context of the Parent. The - * Parent/AddressOnParent properties are used to describe the controller - * relationship as well the ordering of devices on a controller.For example, - * if the parent is a PCI Controller, this property would specify the PCI - * slot of this child device. - */ - public String getAddressOnParent() { - return addressOnParent; - } - - /** - * This property specifies the units of allocation used by the Reservation - * and Limit properties. For example, when ResourceType=Processor, - * AllocationUnits may be set to hertz*10^6 or percent. When - * ResourceType=Memory, AllocationUnits may be set to bytes*10^3. It is - * expected that profiles constrain the units that apply in context of - * particular resource types. The value of this property shall be a legal - * value of the Programmatic Units qualifier as defined in Annex C.1 of - * DSP0004 V2.5 or later. - */ - public String getAllocationUnits() { - return allocationUnits; - } - - /** - * This property specifies if the resource will be automatically allocated. - * For example when set to true, when the consuming virtual computer system - * is powered on, this resource would be allocated. A value of false - * indicates the resource must be explicitly allocated. For example, the - * setting may represent removable media (cdrom, floppy, etc.) where at power - * on time, the media is not present. An explicit operation is required to - * allocate the resource. - */ - public Boolean isAutomaticAllocation() { - return automaticAllocation; - } - - /** - * This property specifies if the resource will be automatically - * de-allocated. For example, when set to true, when the consuming virtual - * computer system is powered off, this resource would be de-allocated. When - * set to false, the resource will remain allocated and must be explicitly - * de-allocated. - */ - public Boolean isAutomaticDeallocation() { - return automaticDeallocation; - } - - /** - * Describes the consumers visibility to the allocated resource. - */ - public ConsumerVisibility getConsumerVisibility() { - return consumerVisibility; - } - - /** - * This property specifies the upper bound, or maximum amount of resource - * that will be granted for this allocation. For example, a system which - * supports memory paging may support setting the Limit of a Memory - * allocation below that of the VirtualQuantity, thus forcing paging to occur - * for this allocation. The value of the Limit property is expressed in the - * unit specified by the value of the AllocationUnits property. - */ - public BigInteger getLimit() { - return limit; - } - - /** - * Specifies how this resource maps to underlying resourcesIf the - * HostResource array contains any entries, this property reflects how the - * resource maps to those specific resources. - */ - public MappingBehavior getMappingBehavior() { - return mappingBehavior; - } - - /** - * A string that describes the resource type when a well defined value is not - * available and ResourceType has the value "Other". - */ - public String getOtherResourceType() { - return otherResourceType; - } - - /** - * The Parent of the resource. For example, a controller for the current - * allocation - */ - public String getParent() { - return parent; - } - - /** - * This property specifies which ResourcePool the resource is currently - * allocated from, or which ResourcePool the resource will be allocated from - * when the allocation occurs. - */ - public String getPoolID() { - return poolID; - } - - /** - * This property specifies the amount of resource guaranteed to be available - * for this allocation. On system which support over-commitment of resources, - * this value is typically used for admission control to prevent an an - * allocation from being accepted thus preventing starvation. The value of - * the Reservation property is expressed in the unit specified by the value - * of the AllocationUnits property. - */ - public BigInteger getReservation() { - return reservation; - } - - /** - * A string describing an implementation specific sub-type for this resource. - */ - public String getResourceSubType() { - return resourceSubType; - } - - /** - * The type of resource this allocation setting represents. - */ - public ResourceType getResourceType() { - return resourceType; - } - - /** - * This property specifies the quantity of resources presented to the - * consumer. For example, when ResourceType=Processor, this property would - * reflect the number of discrete Processors presented to the virtual - * computer system. When ResourceType=Memory, this property could reflect the - * number of MB reported to the virtual computer system. The value of the - * VirtualQuantity property should be expressed in units as defined by the - * value of the VirtualQuantityUnits property. - */ - public BigInteger getVirtualQuantity() { - return virtualQuantity; - } - - /** - * This property specifies the units used by the VirtualQuantity property. - * For example - if ResourceType=Processor, the value of the - * VirtualQuantityUnits property may be set to "count", indicating that the - * value of the VirtualQuantity property is expressed as a count. - if - * ResourceType=Memory, the value of the VirtualQuantityUnits property may be - * set to "bytes*10^3", indicating that the value of the VirtualQuantity - * property is expressed in kilobyte. It is expected that profiles constrain - * the units that apply in context of particular resource types. The value of - * this property shall be a legal value of the Programmatic Units qualifier - * as defined in Annex C.1 of DSP0004 V2.5 or later. - */ - public String getVirtualQuantityUnits() { - return virtualQuantityUnits; - } - - /** - * This property specifies a relative priority for this allocation in - * relation to other allocations from the same ResourcePool. This property - * has no unit of measure, and is only relevant when compared to other - * allocations vying for the same host resources. - */ - public Long getWeight() { - return weight; - } - - /** - * The thing to which this resource is connected. For example, a named - * network or switch port. - */ - public Set getConnections() { - return ImmutableSet.copyOf(connections); - } - - /** - * This property exposes specific assignment of resources. Each non-null - * value of the HostResource property shall be formatted as a URI per RFC3986. - * If this resource is modeled then a value should be a WBEM URI (DSP0207). - * If the resource is not modeled then see the appropriate profile. Profiles - * may further constrain the type of URI. A NULL value or empty array - * requests the implementation decide the kind of host resource. If the - * virtual resource is mapped to more than one underlying resource, this - * property may be left NULL. If NULL, the DeviceAllocatedFromPool or - * ResourceAllocationFromPool associations may be used to determine the pool - * of host resources this virtual resource may use. If specific assignment is - * utilized, all underlying resources used by this virtual resource should be - * listed.The kind of dependency is specified by the ConsumerVisibility and - * the MappingBehavior properties. Typically the array contains one item, - * however multiple host resources may be specified. A client may set the - * value(s) to indicate that the requested virtual resource allocation be - * based on host resources that are identified by element values. - */ - public Set getHostResources() { - return ImmutableSet.copyOf(hostResources); - } - - @Override - public String toString() { - return string().toString(); - } - - public ToStringHelper string() { - return Objects.toStringHelper("") - .add("elementName", elementName) - .add("instanceID", instanceID) - .add("caption", caption) - .add("description", description) - .add("address", address) - .add("addressOnParent", addressOnParent) - .add("allocationUnits", allocationUnits) - .add("automaticAllocation", automaticAllocation) - .add("automaticDeallocation", automaticDeallocation) - .add("connections", connections) - .add("consumerVisibility", consumerVisibility) - .add("hostResources", hostResources) - .add("limit", limit) - .add("mappingBehavior", mappingBehavior) - .add("otherResourceType", otherResourceType) - .add("parent", parent) - .add("poolID", poolID) - .add("reservation", reservation) - .add("resourceSubType", resourceSubType) - .add("resourceType", resourceType) - .add("virtualQuantity", virtualQuantity) - .add("virtualQuantityUnits", virtualQuantityUnits) - .add("weight", weight); - } - - @Override - public int hashCode() { - return Objects.hashCode(elementName, instanceID, caption, description, - address, addressOnParent, allocationUnits, - automaticAllocation, automaticDeallocation, connections, - consumerVisibility, hostResources, limit, mappingBehavior, - otherResourceType, parent, poolID, reservation, resourceSubType, - resourceType, virtualQuantity, virtualQuantityUnits, weight); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - ResourceAllocationSettingData that = ResourceAllocationSettingData.class.cast(obj); - return equal(this.elementName, that.elementName) && - equal(this.instanceID, that.instanceID) && - equal(this.caption, that.caption) && - equal(this.description, that.description) && - equal(this.address, that.address) && - equal(this.addressOnParent, that.addressOnParent) && - equal(this.allocationUnits, that.allocationUnits) && - equal(this.automaticAllocation, that.automaticAllocation) && - equal(this.automaticDeallocation, that.automaticDeallocation) && - equal(this.connections, that.connections) && - equal(this.consumerVisibility, that.consumerVisibility) && - equal(this.hostResources, that.hostResources) && - equal(this.limit, that.limit) && - equal(this.mappingBehavior, that.mappingBehavior) && - equal(this.otherResourceType, that.otherResourceType) && - equal(this.parent, that.parent) && - equal(this.poolID, that.poolID) && - equal(this.reservation, that.reservation) && - equal(this.resourceSubType, that.resourceSubType) && - equal(this.resourceType, that.resourceType) && - equal(this.virtualQuantity, that.virtualQuantity) && - equal(this.virtualQuantityUnits, that.virtualQuantityUnits) && - equal(this.weight, that.weight); - } - -} diff --git a/labs/dmtf/src/main/java/org/jclouds/dmtf/cim/VirtualSystemCaption.java b/labs/dmtf/src/main/java/org/jclouds/dmtf/cim/VirtualSystemCaption.java deleted file mode 100644 index 3a469d780c..0000000000 --- a/labs/dmtf/src/main/java/org/jclouds/dmtf/cim/VirtualSystemCaption.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.dmtf.cim; - -import javax.xml.bind.annotation.XmlType; - -/** - *

Java class for anonymous complex type. - */ -@XmlType(name = "") -public class VirtualSystemCaption extends CimString { - - -} diff --git a/labs/dmtf/src/main/java/org/jclouds/dmtf/cim/VirtualSystemChangeableType.java b/labs/dmtf/src/main/java/org/jclouds/dmtf/cim/VirtualSystemChangeableType.java deleted file mode 100644 index b5fd366e1b..0000000000 --- a/labs/dmtf/src/main/java/org/jclouds/dmtf/cim/VirtualSystemChangeableType.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.dmtf.cim; - -import javax.xml.bind.annotation.XmlType; - -/** - * Java class for anonymous complex type. - */ -@XmlType(name = "") -public class VirtualSystemChangeableType extends CimUnsignedShort { - - -} diff --git a/labs/dmtf/src/main/java/org/jclouds/dmtf/cim/VirtualSystemSettingData.java b/labs/dmtf/src/main/java/org/jclouds/dmtf/cim/VirtualSystemSettingData.java deleted file mode 100644 index 83afcb4846..0000000000 --- a/labs/dmtf/src/main/java/org/jclouds/dmtf/cim/VirtualSystemSettingData.java +++ /dev/null @@ -1,723 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.dmtf.cim; - -import static com.google.common.base.Objects.equal; -import static com.google.common.base.Preconditions.checkNotNull; -import static org.jclouds.dmtf.DMTFConstants.CIM_VSSD_NS; -import static org.jclouds.dmtf.DMTFConstants.OVF_NS; - -import java.math.BigInteger; -import java.util.Date; -import java.util.Map; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlEnum; -import javax.xml.bind.annotation.XmlEnumValue; -import javax.xml.bind.annotation.XmlType; - -import com.google.common.base.Function; -import com.google.common.base.Objects; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Maps; - -/** - * VirtualSystemSettingData defines the virtual aspects of a virtual system through a set of - * virtualization specific properties. - * - * VirtualSystemSettingData is also used as the top level class of virtual system configurations. - * Virtual system configurations model configuration information about virtual systems and their - * components. A virtual system configuration consists of one top-level instance of class - * VirtualSystemSettingData that aggregates a number of instances of class - * {@link ResourceAllocationSettingData}, using association {@link ConcreteComponent). - *

- * Virtual system configurations may for example be used to reflect configurations of: - *

    - *
  • virtual systems that are defined at a virtualization platform - *
  • virtual systems that are currently active - *
  • input requests to create new virtual systems - *
  • input requests to modify existing virtual systems - *
  • snapshots of virtual systems - *
- * - * @author Adrian Cole - * @author grkvlt@apache.org - * @see CIM_VirtualSystemSettingData - */ -@XmlType(name = "CIM_VirtualSystemSettingData_Type", namespace = OVF_NS, - propOrder = { - "automaticRecoveryAction", - "automaticShutdownAction", - "automaticStartupAction", - "automaticStartupActionDelay", - "automaticStartupActionSequenceNumber", - "caption", - "configurationDataRoot", - "configurationFile", - "configurationID", - "creationTime", - "description", - "elementName", - "instanceID", - "logDataRoot", - "notes", - "recoveryFile", - "snapshotDataRoot", - "suspendDataRoot", - "swapFileDataRoot", - "virtualSystemIdentifier", - "virtualSystemType" - } -) -public class VirtualSystemSettingData { - - public static Builder builder() { - return new ConcreteBuilder(); - } - - public Builder toBuilder() { - return builder().fromVirtualSystemSettingData(this); - } - - private static class ConcreteBuilder extends Builder { - } - - public static class Builder> { - - private String elementName; - private String instanceID; - private String caption; - private String description; - private AutomaticRecoveryAction automaticRecoveryAction; - private AutomaticShutdownAction automaticShutdownAction; - private AutomaticStartupAction automaticStartupAction; - private BigInteger automaticStartupActionDelay; - private Long automaticStartupActionSequenceNumber; - private String configurationDataRoot; - private String configurationFile; - private String configurationID; - private Date creationTime; - private String logDataRoot; - private String recoveryFile; - private String snapshotDataRoot; - private String suspendDataRoot; - private String swapFileDataRoot; - private String virtualSystemIdentifier; - private String virtualSystemType; - private String notes; - - @SuppressWarnings("unchecked") - protected B self() { - return (B) this; - } - - public B elementName(String elementName) { - this.elementName = elementName; - return self(); - } - - public B instanceID(String instanceID) { - this.instanceID = instanceID; - return self(); - } - - public B caption(String caption) { - this.caption = caption; - return self(); - } - - public B description(String description) { - this.description = description; - return self(); - } - - public B automaticRecoveryAction(AutomaticRecoveryAction automaticRecoveryAction) { - this.automaticRecoveryAction = automaticRecoveryAction; - return self(); - } - - public B automaticShutdownAction(AutomaticShutdownAction automaticShutdownAction) { - this.automaticShutdownAction = automaticShutdownAction; - return self(); - } - - public B automaticStartupAction(AutomaticStartupAction automaticStartupAction) { - this.automaticStartupAction = automaticStartupAction; - return self(); - } - - public B automaticStartupActionDelay(BigInteger automaticStartupActionDelay) { - this.automaticStartupActionDelay = automaticStartupActionDelay; - return self(); - } - - public B automaticStartupActionSequenceNumber(Long automaticStartupActionSequenceNumber) { - this.automaticStartupActionSequenceNumber = automaticStartupActionSequenceNumber; - return self(); - } - - public B configurationDataRoot(String configurationDataRoot) { - this.configurationDataRoot = configurationDataRoot; - return self(); - } - - public B configurationFile(String configurationFile) { - this.configurationFile = configurationFile; - return self(); - } - - public B configurationID(String configurationID) { - this.configurationID = configurationID; - return self(); - } - - public B creationTime(Date creationTime) { - this.creationTime = creationTime; - return self(); - } - - public B logDataRoot(String logDataRoot) { - this.logDataRoot = logDataRoot; - return self(); - } - - public B recoveryFile(String recoveryFile) { - this.recoveryFile = recoveryFile; - return self(); - } - - public B snapshotDataRoot(String snapshotDataRoot) { - this.snapshotDataRoot = snapshotDataRoot; - return self(); - } - - public B suspendDataRoot(String suspendDataRoot) { - this.suspendDataRoot = suspendDataRoot; - return self(); - } - - public B swapFileDataRoot(String swapFileDataRoot) { - this.swapFileDataRoot = swapFileDataRoot; - return self(); - } - - public B virtualSystemIdentifier(String virtualSystemIdentifier) { - this.virtualSystemIdentifier = virtualSystemIdentifier; - return self(); - } - - public B virtualSystemType(String virtualSystemType) { - this.virtualSystemType = virtualSystemType; - return self(); - } - - public B notes(String notes) { - this.notes = notes; - return self(); - } - - public VirtualSystemSettingData build() { - return new VirtualSystemSettingData(this); - } - - public B fromVirtualSystemSettingData(VirtualSystemSettingData in) { - return elementName(in.getElementName()) - .instanceID(in.getInstanceID()) - .caption(in.getCaption()) - .description(in.getDescription()) - .automaticRecoveryAction(in.getAutomaticRecoveryAction()) - .automaticShutdownAction(in.getAutomaticShutdownAction()) - .automaticStartupAction(in.getAutomaticStartupAction()) - .automaticStartupActionDelay(in.getAutomaticStartupActionDelay()) - .automaticStartupActionSequenceNumber(in.getAutomaticStartupActionSequenceNumber()) - .configurationDataRoot(in.getConfigurationDataRoot()) - .configurationFile(in.getConfigurationFile()) - .configurationID(in.getConfigurationID()) - .creationTime(in.getCreationTime()) - .logDataRoot(in.getLogDataRoot()) - .recoveryFile(in.getRecoveryFile()) - .snapshotDataRoot(in.getSnapshotDataRoot()) - .suspendDataRoot(in.getSuspendDataRoot()) - .swapFileDataRoot(in.getSwapFileDataRoot()) - .virtualSystemIdentifier(in.getVirtualSystemIdentifier()) - .virtualSystemType(in.getVirtualSystemType()) - .notes(in.getNotes()); - } - - } - - /** - * Action to take for the virtual system when the software executed by the virtual system fails. - * - * Failures in this case means a failure that is detectable by the host platform, such as a - * non-interruptible wait state condition. - */ - @XmlType - @XmlEnum(Integer.class) - public static enum AutomaticRecoveryAction { - - @XmlEnumValue("2") NONE(2), - @XmlEnumValue("3") RESTART(3), - @XmlEnumValue("4") REVERT_TO_SNAPSHOT(4); - - protected final int code; - - AutomaticRecoveryAction(int code) { - this.code = code; - } - - public String value() { - return Integer.toString(code); - } - - protected static final Map AUTOMATIC_RECOVERY_ACTION_BY_ID = Maps.uniqueIndex( - ImmutableSet.copyOf(AutomaticRecoveryAction.values()), new Function() { - @Override - public Integer apply(AutomaticRecoveryAction input) { - return input.code; - } - }); - - public static AutomaticRecoveryAction fromValue(String automaticRecoveryAction) { - return AUTOMATIC_RECOVERY_ACTION_BY_ID.get(Integer.valueOf(checkNotNull(automaticRecoveryAction, "automaticRecoveryAction"))); - } - } - - /** - * Action to take for the virtual system when the host is shut down. - */ - @XmlType - @XmlEnum(Integer.class) - public static enum AutomaticShutdownAction { - - @XmlEnumValue("2") TURN_OFF(2), - @XmlEnumValue("3") SAVE_STATE(3), - @XmlEnumValue("4") SHUTDOWN(4); - - protected final int code; - - AutomaticShutdownAction(int code) { - this.code = code; - } - - public String value() { - return Integer.toString(code); - } - - protected static final Map AUTOMATIC_SHUTDOWN_ACTION_BY_ID = Maps.uniqueIndex( - ImmutableSet.copyOf(AutomaticShutdownAction.values()), new Function() { - @Override - public Integer apply(AutomaticShutdownAction input) { - return input.code; - } - }); - - public static AutomaticShutdownAction fromValue(String automaticShutdownAction) { - return AUTOMATIC_SHUTDOWN_ACTION_BY_ID.get(Integer.valueOf(checkNotNull(automaticShutdownAction, "automaticShutdownAction"))); - } - } - - /** - * Action to take for the virtual system when the host is started. - */ - @XmlType - @XmlEnum(Integer.class) - public static enum AutomaticStartupAction { - - @XmlEnumValue("2") NONE(2), - @XmlEnumValue("3") RESTART_IF_PREVIOUSLY_ACTIVE(3), - @XmlEnumValue("4") ALWAYS_STARTUP(4); - - protected final int code; - - AutomaticStartupAction(int code) { - this.code = code; - } - - public String value() { - return Integer.toString(code); - } - - protected static final Map AUTOMATIC_STARTUP_ACTION_BY_ID = Maps.uniqueIndex( - ImmutableSet.copyOf(AutomaticStartupAction.values()), new Function() { - @Override - public Integer apply(AutomaticStartupAction input) { - return input.code; - } - }); - - public static AutomaticStartupAction fromValue(String automaticStartupAction) { - return AUTOMATIC_STARTUP_ACTION_BY_ID.get(Integer.valueOf(checkNotNull(automaticStartupAction, "automaticStartupAction"))); - } - } - - @XmlElement(name = "ElementName", namespace = CIM_VSSD_NS) - private String elementName; - @XmlElement(name = "InstanceID", namespace = CIM_VSSD_NS) - private String instanceID; - @XmlElement(name = "Caption", namespace = CIM_VSSD_NS) - private String caption; - @XmlElement(name = "Description", namespace = CIM_VSSD_NS) - private String description; - @XmlElement(name = "VirtualSystemIdentifier", namespace = CIM_VSSD_NS) - private String virtualSystemIdentifier; - @XmlElement(name = "VirtualSystemType", namespace = CIM_VSSD_NS) - private String virtualSystemType; - @XmlElement(name = "AutomaticRecoveryAction", namespace = CIM_VSSD_NS) - private AutomaticRecoveryAction automaticRecoveryAction; - @XmlElement(name = "AutomaticShutdownAction", namespace = CIM_VSSD_NS) - private AutomaticShutdownAction automaticShutdownAction; - @XmlElement(name = "AutomaticStartupAction", namespace = CIM_VSSD_NS) - private AutomaticStartupAction automaticStartupAction; - @XmlElement(name = "AutomaticStartupActionDelay", namespace = CIM_VSSD_NS) - private BigInteger automaticStartupActionDelay; - @XmlElement(name = "AutomaticStartupActionSequenceNumber", namespace = CIM_VSSD_NS) - private Long automaticStartupActionSequenceNumber; - @XmlElement(name = "ConfigurationDataRoot", namespace = CIM_VSSD_NS) - private String configurationDataRoot; - @XmlElement(name = "ConfigurationFile", namespace = CIM_VSSD_NS) - private String configurationFile; - @XmlElement(name = "ConfigurationID", namespace = CIM_VSSD_NS) - private String configurationID; - @XmlElement(name = "CreationTime", namespace = CIM_VSSD_NS) - private Date creationTime; - @XmlElement(name = "LogDataRoot", namespace = CIM_VSSD_NS) - private String logDataRoot; - @XmlElement(name = "RecoveryFile", namespace = CIM_VSSD_NS) - private String recoveryFile; - @XmlElement(name = "SnapshotDataRoot", namespace = CIM_VSSD_NS) - private String snapshotDataRoot; - @XmlElement(name = "SuspendDataRoot", namespace = CIM_VSSD_NS) - private String suspendDataRoot; - @XmlElement(name = "SwapFileDataRoot", namespace = CIM_VSSD_NS) - private String swapFileDataRoot; - @XmlElement(name = "Notes", namespace = CIM_VSSD_NS) - private String notes; - - private VirtualSystemSettingData(Builder builder) { - this.elementName = builder.elementName; - this.instanceID = builder.instanceID; - this.caption = builder.caption; - this.description = builder.description; - this.automaticRecoveryAction = builder.automaticRecoveryAction; - this.automaticShutdownAction = builder.automaticShutdownAction; - this.automaticStartupAction = builder.automaticStartupAction; - this.automaticStartupActionDelay = builder.automaticStartupActionDelay; - this.automaticStartupActionSequenceNumber = builder.automaticStartupActionSequenceNumber; - this.configurationDataRoot = builder.configurationDataRoot; - this.configurationFile = builder.configurationFile; - this.configurationID = builder.configurationID; - this.creationTime = builder.creationTime; - this.logDataRoot = builder.logDataRoot; - this.recoveryFile = builder.recoveryFile; - this.snapshotDataRoot = builder.snapshotDataRoot; - this.suspendDataRoot = builder.suspendDataRoot; - this.swapFileDataRoot = builder.swapFileDataRoot; - this.virtualSystemIdentifier = builder.virtualSystemIdentifier; - this.virtualSystemType = builder.virtualSystemType; - this.notes = builder.notes; - } - - private VirtualSystemSettingData(String elementName, String instanceID, String caption, String description, - AutomaticRecoveryAction automaticRecoveryAction, AutomaticShutdownAction automaticShutdownAction, - AutomaticStartupAction automaticStartupAction, BigInteger automaticStartupActionDelay, - Long automaticStartupActionSequenceNumber, String configurationDataRoot, String configurationFile, - String configurationID, Date creationTime, String logDataRoot, String recoveryFile, String snapshotDataRoot, - String suspendDataRoot, String swapFileDataRoot, String virtualSystemIdentifier, - String virtualSystemType, String notes) { - this.elementName = elementName; - this.instanceID = instanceID; - this.caption = caption; - this.description = description; - this.automaticRecoveryAction = automaticRecoveryAction; - this.automaticShutdownAction = automaticShutdownAction; - this.automaticStartupAction = automaticStartupAction; - this.automaticStartupActionDelay = automaticStartupActionDelay; - this.automaticStartupActionSequenceNumber = automaticStartupActionSequenceNumber; - this.configurationDataRoot = configurationDataRoot; - this.configurationFile = configurationFile; - this.configurationID = configurationID; - this.creationTime = creationTime; - this.logDataRoot = logDataRoot; - this.recoveryFile = recoveryFile; - this.snapshotDataRoot = snapshotDataRoot; - this.suspendDataRoot = suspendDataRoot; - this.swapFileDataRoot = swapFileDataRoot; - this.virtualSystemIdentifier = virtualSystemIdentifier; - this.virtualSystemType = virtualSystemType; - this.notes = notes; - } - - private VirtualSystemSettingData() { - // for JAXB - } - - /** - * The user-friendly name for this instance of SettingData. In addition, the user-friendly name - * can be used as an index property for a search or query. (Note: The name does not have to be - * unique within a namespace.) - */ - public String getElementName() { - return elementName; - } - - /** - * Within the scope of the instantiating Namespace, InstanceID opaquely and uniquely identifies - * an instance of this class. - */ - public String getInstanceID() { - return instanceID; - } - - /** - * The Caption property is a short textual description (one- line string) of the object. - */ - public String getCaption() { - return caption; - } - - /** - * The Description property provides a textual description of the object. - */ - public String getDescription() { - return description; - } - - /** - * Action to take for the virtual system when the software executed by the virtual system fails. - * Failures in this case means a failure that is detectable by the host platform, such as a - * non-interruptible wait state condition. - */ - public AutomaticRecoveryAction getAutomaticRecoveryAction() { - return automaticRecoveryAction; - } - - /** - * Action to take for the virtual system when the host is shut down. - */ - public AutomaticShutdownAction getAutomaticShutdownAction() { - return automaticShutdownAction; - } - - /** - * Action to take for the virtual system when the host is started. - */ - public AutomaticStartupAction getAutomaticStartupAction() { - return automaticStartupAction; - } - - /** - * Delay applicable to startup action. The value shall be in the interval variant of the datetime - * datatype. - */ - public BigInteger getAutomaticStartupActionDelay() { - return automaticStartupActionDelay; - } - - /** - * Number indicating the relative sequence of virtual system activation when the host system is - * started. A lower number indicates earlier activation. If one or more configurations show the - * same value, the sequence is implementation dependent. A value of 0 indicates that the sequence - * is implementation dependent. - */ - public Long getAutomaticStartupActionSequenceNumber() { - return automaticStartupActionSequenceNumber; - } - - /** - * Filepath of a directory where information about the virtual system configuration is - * stored. - * - * Format shall be String based on RFC-2079. - */ - public String getConfigurationDataRoot() { - return configurationDataRoot; - } - - /** - * Filepath of a file where information about the virtual system configuration is stored. - * - * A relative path appends to the value of the {@link #getConfigurationDataRoot()} property. - *

- * Format shall be String based on RFC-2079. - */ - public String getConfigurationFile() { - return configurationFile; - } - - /** - * Unique id of the virtual system configuration. Note that the ConfigurationID is different from - * the InstanceID as it is assigned by the implementation to a virtual system or a virtual system - * configuration. It is not a key, and the same value may occur within more than one instance. - */ - public String getConfigurationID() { - return configurationID; - } - - /** - * Time when the virtual system configuration was created. - */ - public Date getCreationTime() { - return creationTime; - } - - /** - * Filepath of a directory where log information about the virtual system is stored. - * - * A relative path appends to the value of the {@link #getConfigurationDataRoot()} property. - *

- * Format shall be String based on RFC-2079. - */ - public String getLogDataRoot() { - return logDataRoot; - } - - /** - * Filepath of a file where recovery related information of the virtual system is stored. - * - * Format shall be String based on RFC-2079. - */ - public String getRecoveryFile() { - return recoveryFile; - } - - /** - * Filepath of a directory where information about virtual system snapshots is stored. - * - * A relative path appends to the value of the {@link #getConfigurationDataRoot()} property. - *

- * Format shall be String based on RFC-2079. - */ - public String getSnapshotDataRoot() { - return snapshotDataRoot; - } - - /** - * Filepath of a directory where suspend related information about the virtual system is stored. - * - * A relative path appends to the value of the {@link #getConfigurationDataRoot()} property. - *

- * Format shall be String based on RFC-2079. - */ - public String getSuspendDataRoot() { - return suspendDataRoot; - } - - /** - * Filepath of a directory where swapfiles of the virtual system are stored. - * - * A relative path appends to the value of the {@link #getConfigurationDataRoot()} property. - *

- * Format shall be String based on RFC-2079. - */ - public String getSwapFileDataRoot() { - return swapFileDataRoot; - } - - /** - * VirtualSystemIdentifier shall reflect a unique name for the system as it is used within the - * virtualization platform. - * - * Note that the VirtualSystemIdentifier is not the hostname assigned to - * the operating system instance running within the virtual system, nor is it an IP address or - * MAC address assigned to any of its network ports. On create requests VirtualSystemIdentifier - * may contain implementation specific rules (like simple patterns or regular expression) that - * may be interpreted by the implementation when assigning a VirtualSystemIdentifier. - */ - public String getVirtualSystemIdentifier() { - return virtualSystemIdentifier; - } - - /** - * VirtualSystemType shall reflect a particular type of virtual system. - */ - public String getVirtualSystemType() { - return virtualSystemType; - } - - /** - * End-user supplied notes that are related to the virtual system. - */ - public String getNotes() { - return notes; - } - - @Override - public int hashCode() { - return Objects.hashCode(elementName, instanceID, caption, description, virtualSystemIdentifier, virtualSystemType); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - VirtualSystemSettingData that = VirtualSystemSettingData.class.cast(obj); - return equal(this.elementName, that.elementName) - && equal(this.instanceID, that.instanceID) - && equal(this.caption, that.caption) - && equal(this.description, that.description) - && equal(this.automaticRecoveryAction, that.automaticRecoveryAction) - && equal(this.automaticShutdownAction, that.automaticShutdownAction) - && equal(this.automaticStartupAction, that.automaticStartupAction) - && equal(this.automaticStartupActionDelay, that.automaticStartupActionDelay) - && equal(this.automaticStartupActionSequenceNumber, that.automaticStartupActionSequenceNumber) - && equal(this.configurationDataRoot, that.configurationDataRoot) - && equal(this.configurationFile, that.configurationFile) - && equal(this.configurationID, that.configurationID) - && equal(this.creationTime, that.creationTime) - && equal(this.logDataRoot, that.logDataRoot) - && equal(this.recoveryFile, that.recoveryFile) - && equal(this.snapshotDataRoot, that.snapshotDataRoot) - && equal(this.suspendDataRoot, that.suspendDataRoot) - && equal(this.swapFileDataRoot, that.swapFileDataRoot) - && equal(this.virtualSystemIdentifier, that.virtualSystemIdentifier) - && equal(this.virtualSystemType, that.virtualSystemType); - } - - @Override - public String toString() { - return Objects.toStringHelper("") - .add("elementName", elementName) - .add("instanceID", instanceID) - .add("caption", caption) - .add("description", description) - .add("automaticRecoveryAction", automaticRecoveryAction) - .add("automaticShutdownAction", automaticShutdownAction) - .add("automaticStartupAction", automaticStartupAction) - .add("automaticStartupActionDelay", automaticStartupActionDelay) - .add("automaticStartupActionSequenceNumber", automaticStartupActionSequenceNumber) - .add("configurationDataRoot", configurationDataRoot) - .add("configurationFile", configurationFile) - .add("configurationID", configurationID) - .add("creationTime", creationTime) - .add("logDataRoot", logDataRoot) - .add("recoveryFile", recoveryFile) - .add("snapshotDataRoot", snapshotDataRoot) - .add("suspendDataRoot", suspendDataRoot) - .add("swapFileDataRoot", swapFileDataRoot) - .add("virtualSystemIdentifier", virtualSystemIdentifier) - .add("virtualSystemType", virtualSystemType) - .toString(); - } - -} diff --git a/labs/dmtf/src/main/java/org/jclouds/dmtf/cim/functions/HardwareBuilderFromResourceAllocations.java b/labs/dmtf/src/main/java/org/jclouds/dmtf/cim/functions/HardwareBuilderFromResourceAllocations.java deleted file mode 100644 index 7b760e0d40..0000000000 --- a/labs/dmtf/src/main/java/org/jclouds/dmtf/cim/functions/HardwareBuilderFromResourceAllocations.java +++ /dev/null @@ -1,75 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.dmtf.cim.functions; - -import static com.google.common.collect.Iterables.filter; -import static com.google.common.collect.Iterables.find; -import static com.google.common.collect.Iterables.transform; - -import javax.inject.Singleton; - -import org.jclouds.compute.domain.HardwareBuilder; -import org.jclouds.compute.domain.Processor; -import org.jclouds.compute.domain.Volume; -import org.jclouds.compute.domain.internal.VolumeImpl; -import org.jclouds.dmtf.CIMPredicates; -import org.jclouds.dmtf.cim.ResourceAllocationSettingData; -import org.jclouds.dmtf.cim.ResourceAllocationSettingData.ResourceType; - -import com.google.common.base.Function; - -/** - * @author Adrian Cole - */ -@Singleton -public class HardwareBuilderFromResourceAllocations implements - Function, HardwareBuilder> { - @Override - public HardwareBuilder apply(Iterable from) { - HardwareBuilder builder = new HardwareBuilder(); - builder.volumes(transform(filter(from, CIMPredicates.resourceTypeIn(ResourceType.DISK_DRIVE, - ResourceType.BASE_PARTITIONABLE_UNIT, ResourceType.PARTITIONABLE_UNIT)), - new Function() { - - @Override - public Volume apply(ResourceAllocationSettingData from) { - return HardwareBuilderFromResourceAllocations.this.apply(from); - } - - })); - - builder.ram((int) find(from, CIMPredicates.resourceTypeIn(ResourceType.MEMORY)).getVirtualQuantity().longValue()); - - builder.processors(transform(filter(from, CIMPredicates.resourceTypeIn(ResourceType.PROCESSOR)), - new Function() { - - @Override - public Processor apply(ResourceAllocationSettingData arg0) { - return new Processor(arg0.getVirtualQuantity().longValue(), 1); - } - })); - return builder; - } - - public Volume apply(ResourceAllocationSettingData from) { - return new VolumeImpl(from.getAddressOnParent() + "", Volume.Type.LOCAL, from.getVirtualQuantity() == null ? null - : from.getVirtualQuantity().longValue() / (float) (1024 * 1024), null, "0".equals(from.getAddressOnParent()) - || ResourceType.BASE_PARTITIONABLE_UNIT.equals(from.getResourceType()), true); - } -} diff --git a/labs/dmtf/src/main/java/org/jclouds/dmtf/cim/package-info.java b/labs/dmtf/src/main/java/org/jclouds/dmtf/cim/package-info.java deleted file mode 100644 index 99b3064a1c..0000000000 --- a/labs/dmtf/src/main/java/org/jclouds/dmtf/cim/package-info.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -@XmlSchema(namespace = CIM_NS, elementFormDefault = XmlNsForm.QUALIFIED, - xmlns = { - @XmlNs(prefix = "cim", namespaceURI = CIM_NS), - @XmlNs(prefix = "ovf", namespaceURI = OVF_NS), - @XmlNs(prefix = "vssd", namespaceURI = CIM_VSSD_NS), - @XmlNs(prefix = "rasd", namespaceURI = CIM_RASD_NS) - } -) -@XmlAccessorType(XmlAccessType.FIELD) -package org.jclouds.dmtf.cim; - -import static org.jclouds.dmtf.DMTFConstants.CIM_NS; -import static org.jclouds.dmtf.DMTFConstants.CIM_RASD_NS; -import static org.jclouds.dmtf.DMTFConstants.CIM_VSSD_NS; -import static org.jclouds.dmtf.DMTFConstants.OVF_NS; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlNs; -import javax.xml.bind.annotation.XmlNsForm; -import javax.xml.bind.annotation.XmlSchema; - - diff --git a/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/Configuration.java b/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/Configuration.java deleted file mode 100644 index a2483a27ad..0000000000 --- a/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/Configuration.java +++ /dev/null @@ -1,152 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.dmtf.ovf; - -import static org.jclouds.dmtf.DMTFConstants.OVF_NS; - -import javax.xml.bind.annotation.XmlAttribute; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlType; - -import com.google.common.base.Objects; - -/** - * @author Adrian Cole - * @author Adam Lowe - */ -@XmlType(name = "Configuration", namespace = OVF_NS, propOrder = { - "label", "description" -}) -public class Configuration { - public static Builder builder() { - return new Builder(); - } - - public static class Builder { - private String id; - private boolean isDefault; - private String label; - private String description; - - /** - * @see Configuration#getId - */ - public Builder id(String id) { - this.id = id; - return this; - } - - /** - * @see Configuration#getLabel - */ - public Builder label(String label) { - this.label = label; - return this; - } - - /** - * @see Configuration#getDescription - */ - public Builder description(String description) { - this.description = description; - return this; - } - - /** - * @see Configuration#isDefault - */ - public Builder isDefault(boolean isDefault) { - this.isDefault = isDefault; - return this; - } - - public Configuration build() { - return new Configuration(id, isDefault, label, description); - } - - public Builder fromConfiguration(Configuration in) { - return id(in.getId()).description(in.getDescription()).label(in.getLabel()); - } - } - - @XmlAttribute - private String id; - @XmlAttribute(name = "default") - private boolean isDefault; - @XmlElement(name = "Label") - private String label; - @XmlElement(name = "Description") - private String description; - - public Configuration(String id, boolean isDefault, String label, String description) { - this.id = id; - this.label = label; - this.description = description; - this.isDefault = isDefault; - } - - public Configuration() { - // for JAXB - } - - @Override - public int hashCode() { - return Objects.hashCode(id, label, description); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - Configuration other = (Configuration) obj; - return Objects.equal(id, other.id) - && Objects.equal(label, other.label) - && Objects.equal(description, other.description); - } - - - @Override - public String toString() { - return string().toString(); - } - - protected Objects.ToStringHelper string() { - return Objects.toStringHelper("").add("id", id).add("default", isDefault).add("label", label).add("description", description); - } - - public String getId() { - return id; - } - - public String getDescription() { - return description; - } - - public String getLabel() { - return label; - } - - public boolean isDefault() { - return isDefault; - } -} diff --git a/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/DeploymentOptionSection.java b/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/DeploymentOptionSection.java deleted file mode 100644 index ffb54d3666..0000000000 --- a/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/DeploymentOptionSection.java +++ /dev/null @@ -1,126 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.dmtf.ovf; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.Collections; -import java.util.Set; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlType; - -import com.google.common.base.Objects; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Sets; - -/** - * The DeploymentOptionSection specifies a discrete set of intended resource configurations. The - * author of an OVF package can include sizing metadata for different configurations. A consumer of - * the OVF shall select a configuration, for example, by prompting the user. The selected - * configuration is visible in the OVF environment, enabling guest software to adapt to the selected - * configuration. - * - * @author Adrian Cole - * @author Adam Lowe - */ -@XmlRootElement(name = "DeploymentOptionSection") -@XmlType(name = "DeploymentOptionSection_Type") -public class DeploymentOptionSection extends SectionType { - - public static Builder builder() { - return new ConcreteBuilder(); - } - - public Builder toBuilder() { - return builder().fromDeploymentOptionSection(this); - } - - private static class ConcreteBuilder extends Builder { - } - - public static class Builder> extends SectionType.Builder { - private Set configurations = Sets.newLinkedHashSet(); - - /** - * @see DeploymentOptionSection#getConfigurations - */ - public B configuration(Configuration configuration) { - this.configurations.add(checkNotNull(configuration, "configuration")); - return self(); - } - - /** - * @see DeploymentOptionSection#getConfigurations - */ - public B configurations(Iterable configurations) { - this.configurations = ImmutableSet.copyOf(checkNotNull(configurations, "configurations")); - return self(); - } - - /** - * {@inheritDoc} - */ - @Override - public DeploymentOptionSection build() { - return new DeploymentOptionSection(this); - } - - public B fromDeploymentOptionSection(DeploymentOptionSection in) { - return fromSectionType(in).configurations(in.getConfigurations()); - } - } - - @XmlElement(name = "Configuration") - protected Set configurations; - - private DeploymentOptionSection(Builder builder) { - super(builder); - this.configurations = ImmutableSet.copyOf(builder.configurations); - } - - private DeploymentOptionSection() { - // For JAXB - } - - public Set getConfigurations() { - return Collections.unmodifiableSet(configurations); - } - - @Override - public int hashCode() { - return Objects.hashCode(super.hashCode(), configurations); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (!super.equals(obj)) return false; - if (getClass() != obj.getClass()) return false; - - DeploymentOptionSection other = (DeploymentOptionSection) obj; - return super.equals(other) && Objects.equal(configurations, other.configurations); - } - - @Override - protected Objects.ToStringHelper string() { - return super.string().add("configurations", configurations); - } -} diff --git a/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/Disk.java b/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/Disk.java deleted file mode 100644 index a08852414b..0000000000 --- a/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/Disk.java +++ /dev/null @@ -1,243 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.dmtf.ovf; - -import java.net.URI; - -import javax.xml.bind.annotation.XmlRootElement; - -/** - * @author Adrian Cole - * @author Adam Lowe - */ -@XmlRootElement(name = "Disk") -public class Disk implements Comparable{ - public static Builder builder() { - return new Builder(); - } - - public static class Builder { - private String id; - private Long capacity; - private String parentRef; - private String fileRef; - private URI format; - private Long populatedSize; - private String capacityAllocationUnits; - - /** - * @see Disk#getId - */ - public Builder id(String id) { - this.id = id; - return this; - } - - /** - * @see Disk#getCapacity - */ - public Builder capacity(Long capacity) { - this.capacity = capacity; - return this; - } - - /** - * @see Disk#getParentRef - */ - public Builder parentRef(String parentRef) { - this.parentRef = parentRef; - return this; - } - - /** - * @see Disk#getFileRef - */ - public Builder fileRef(String fileRef) { - this.fileRef = fileRef; - return this; - } - - /** - * @see Disk#getFormat - */ - public Builder format(URI format) { - this.format = format; - return this; - } - - /** - * @see Disk#getPopulatedSize - */ - public Builder populatedSize(Long populatedSize) { - this.populatedSize = populatedSize; - return this; - } - - /** - * @see Disk#getCapacityAllocationUnits - */ - public Builder capacityAllocationUnits(String capacityAllocationUnits) { - this.capacityAllocationUnits = capacityAllocationUnits; - return this; - } - - public Disk build() { - return new Disk(id, capacity, parentRef, fileRef, format, populatedSize, capacityAllocationUnits); - } - - public Builder fromDisk(Disk in) { - return id(in.getId()).capacity(in.getCapacity()).parentRef(in.getParentRef()).fileRef(in.getFileRef()).format( - in.getFormat()).populatedSize(in.getPopulatedSize()).capacityAllocationUnits( - in.getCapacityAllocationUnits()); - } - } - - private String id; - private Long capacity; - private String parentRef; - private String fileRef; - private URI format; - private Long populatedSize; - private String capacityAllocationUnits; - - private Disk(String id, Long capacity, String parentRef, String fileRef, URI format, Long populatedSize, - String capacityAllocationUnits) { - this.id = id; - this.capacity = capacity; - this.parentRef = parentRef; - this.fileRef = fileRef; - this.format = format; - this.populatedSize = populatedSize; - this.capacityAllocationUnits = capacityAllocationUnits; - } - - private Disk() { - // For Jaxb - } - - /** - * Each virtual disk is represented by a Disk element that shall be given a identifier using the - * {@code id} attribute, the identifier shall be unique within the {@link DiskSection}. - */ - public String getId() { - return id; - } - - /** - * The capacity of a virtual disk shall be specified by the {@code capacity} attribute with an - * xs:long integer value. The default unit of allocation shall be bytes. - */ - public Long getCapacity() { - return capacity; - } - - /** - * OVF allows a disk image to be represented as a set of modified blocks in comparison to a - * parent image. The use of parent disks can often significantly reduce the size of an OVF - * package, if it contains multiple disks with similar content. For a Disk element, a parent disk - * may optionally be specified using the {@code parentRef} attribute, which shall contain a valid - * ovf:id reference to a different Disk element. If a disk block does not exist locally, lookup - * for that disk block then occurs in the parent disk. In {@link DiskSection}, parent Disk - * elements shall occur before child Disk elements that refer to them. - */ - public String getParentRef() { - return parentRef; - } - - /** - * The ovf:fileRef attribute denotes the virtual disk content by identifying an existing File - * element in the References element, the File element is identified by matching its {@code id} - * attribute value with the {@code fileRef} attribute value. Omitting the {@code fileRef} - * attribute shall indicate an empty disk. In this case, the disk shall be created and the entire - * disk content zeroed at installation time. The guest software will typically format empty disks - * in some file system format. - */ - public String getFileRef() { - return fileRef; - } - - /** - * The format URI of a non-empty virtual disk shall be specified by the {@code format} attribute. - */ - public URI getFormat() { - return format; - } - - /** - * For non-empty disks, the actual used size of the disk may optionally be specified using the - * {@code populatedSize} attribute. The unit of this attribute is always bytes. {@code - * populatedSize} is allowed to be an estimate of used disk size but shall not be larger than - * {@code capacity}. - */ - public Long getPopulatedSize() { - return populatedSize; - } - - /** - * The optional string attribute {@code ovf:capacityAllocationUnits} may be used to specify a - * particular unit of allocation. Values for {@code ovf:capacityAllocationUnits} shall match the - * format for programmatic units defined in DSP0004. - */ - public String getCapacityAllocationUnits() { - return capacityAllocationUnits; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((id == null) ? 0 : id.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - Disk other = (Disk) obj; - if (id == null) { - if (other.id != null) - return false; - } else if (!id.equals(other.id)) - return false; - return true; - } - - @Override - public String toString() { - return String - .format( - "[id=%s, capacity=%s, capacityAllocationUnits=%s, fileRef=%s, format=%s, parentRef=%s, populatedSize=%s]", - id, capacity, capacityAllocationUnits, fileRef, format, parentRef, populatedSize); - } - - /** - * {@inheritDoc} - */ - @Override - public int compareTo(Disk o) { - if (id == null) - return -1; - return (this == o) ? 0 : id.compareTo(o.id); - } -} diff --git a/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/DiskSection.java b/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/DiskSection.java deleted file mode 100644 index cc6ecd4e68..0000000000 --- a/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/DiskSection.java +++ /dev/null @@ -1,131 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.dmtf.ovf; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.Set; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlType; - -import com.google.common.base.Objects; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Sets; - -/** - * A DiskSection describes meta-information about virtual disks in the OVF package. Virtual disks - * and their metadata are described outside the virtual hardware to facilitate sharing between - * virtual machines within an OVF package. - * - * @author Adrian Cole - * @author Adam Lowe - */ -@XmlRootElement(name = "DiskSection") -@XmlType(propOrder = { - "disks" -}) -public class DiskSection extends SectionType { - - public static Builder builder() { - return new ConcreteBuilder(); - } - - public Builder toBuilder() { - return builder().fromDiskSection(this); - } - - private static class ConcreteBuilder extends Builder { - } - - public static class Builder> extends SectionType.Builder { - private Set disks = Sets.newLinkedHashSet(); - - /** - * @see DiskSection#getDisks - */ - public B disk(Disk disk) { - this.disks.add(checkNotNull(disk, "disk")); - return self(); - } - - /** - * @see DiskSection#getDisks - */ - public B disks(Iterable disks) { - this.disks = ImmutableSet.copyOf(checkNotNull(disks, "disks")); - return self(); - } - - /** - * {@inheritDoc} - */ - @Override - public DiskSection build() { - return new DiskSection(this); - } - - public B fromDiskSection(DiskSection in) { - return disks(in.getDisks()).info(in.getInfo()); - } - } - - @XmlElement(name = "Disk") - private Set disks; - - protected DiskSection(Builder builder) { - super(builder); - this.disks = ImmutableSet.copyOf(checkNotNull(builder.disks, "disks")); - } - - protected DiskSection() { - // for JAXB - } - - /** - * All disks referred to from Connection elements in all {@link VirtualHardwareSection} elements - * shall be defined in the DiskSection. - * - * @return - */ - public Set getDisks() { - return disks; - } - - @Override - public int hashCode() { - return Objects.hashCode(super.hashCode(), disks); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null) return false; - if (getClass() != obj.getClass()) return false; - - DiskSection other = (DiskSection) obj; - return super.equals(other) && Objects.equal(disks, other.disks); - } - - @Override - protected Objects.ToStringHelper string() { - return super.string().add("disks", disks); - } -} diff --git a/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/Item.java b/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/Item.java deleted file mode 100644 index efff81d1d5..0000000000 --- a/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/Item.java +++ /dev/null @@ -1,194 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.dmtf.ovf; - -import static com.google.common.base.Objects.equal; - -import java.util.Map; - -import javax.xml.bind.annotation.XmlAnyAttribute; -import javax.xml.bind.annotation.XmlAttribute; -import javax.xml.bind.annotation.XmlSchemaType; -import javax.xml.bind.annotation.XmlSeeAlso; -import javax.xml.bind.annotation.XmlType; -import javax.xml.namespace.QName; - -import com.google.common.base.Objects; -import com.google.common.collect.Maps; - -/** - * Java class for anonymous complex type. - * - *

- * <complexType>
- *   <complexContent>
- *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- *       <attribute name="id" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
- *       <attribute name="order" use="required" type="{http://www.w3.org/2001/XMLSchema}unsignedShort" />
- *       <attribute name="startDelay" type="{http://www.w3.org/2001/XMLSchema}unsignedShort" default="0" />
- *       <attribute name="waitingForGuest" type="{http://www.w3.org/2001/XMLSchema}boolean" default="false" />
- *       <attribute name="stopDelay" type="{http://www.w3.org/2001/XMLSchema}unsignedShort" default="0" />
- *       <attribute name="startAction" type="{http://www.w3.org/2001/XMLSchema}string" default="powerOn" />
- *       <attribute name="stopAction" type="{http://www.w3.org/2001/XMLSchema}string" default="powerOff" />
- *       <anyAttribute processContents='lax'/>
- *     </restriction>
- *   </complexContent>
- * </complexType>
- * 
- */ -@XmlType -@XmlSeeAlso({ - StartupSectionItem.class -}) -public class Item { - - // TODO Builder - - @XmlAttribute(required = true) - protected String id; - @XmlAttribute(required = true) - @XmlSchemaType(name = "unsignedShort") - protected int order; - @XmlAttribute - @XmlSchemaType(name = "unsignedShort") - protected Integer startDelay; - @XmlAttribute - protected Boolean waitingForGuest; - @XmlAttribute - @XmlSchemaType(name = "unsignedShort") - protected Integer stopDelay; - @XmlAttribute - protected String startAction; - @XmlAttribute - protected String stopAction; - @XmlAnyAttribute - private Map otherAttributes = Maps.newHashMap(); - - /** - * Gets the value of the id property. - */ - public String getId() { - return id; - } - - /** - * Gets the value of the order property. - */ - public int getOrder() { - return order; - } - - /** - * Gets the value of the startDelay property. - */ - public int getStartDelay() { - if (startDelay == null) { - return 0; - } else { - return startDelay; - } - } - - /** - * Gets the value of the waitingForGuest property. - */ - public boolean isWaitingForGuest() { - if (waitingForGuest == null) { - return false; - } else { - return waitingForGuest; - } - } - - /** - * Gets the value of the stopDelay property. - */ - public int getStopDelay() { - if (stopDelay == null) { - return 0; - } else { - return stopDelay; - } - } - - /** - * Gets the value of the startAction property. - */ - public String getStartAction() { - if (startAction == null) { - return "powerOn"; - } else { - return startAction; - } - } - - /** - * Gets the value of the stopAction property. - */ - public String getStopAction() { - if (stopAction == null) { - return "powerOff"; - } else { - return stopAction; - } - } - - /** - * Gets a map that contains attributes that aren't bound to any typed property on this class. - */ - public Map getOtherAttributes() { - return otherAttributes; - } - - @Override - public int hashCode() { - return Objects.hashCode(id, order, startDelay, waitingForGuest, stopDelay, startAction, stopAction); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - Item that = Item.class.cast(obj); - return equal(this.id, that.id) && - equal(this.order, that.order) && - equal(this.startDelay, that.startDelay) && - equal(this.waitingForGuest, that.waitingForGuest) && - equal(this.stopDelay, that.stopDelay) && - equal(this.startAction, that.startAction) && - equal(this.stopAction, that.stopAction); - } - - @Override - public String toString() { - return Objects.toStringHelper("") - .add("id", id) - .add("order", order) - .add("startDelay", startDelay) - .add("waitingForGuest", waitingForGuest) - .add("stopDelay", stopDelay) - .add("startAction", startAction) - .add("stopAction", stopAction) - .toString(); - } -} diff --git a/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/MsgType.java b/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/MsgType.java deleted file mode 100644 index 0db4de2004..0000000000 --- a/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/MsgType.java +++ /dev/null @@ -1,145 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.dmtf.ovf; - -import static com.google.common.base.Objects.equal; - -import javax.xml.bind.annotation.XmlAttribute; -import javax.xml.bind.annotation.XmlType; -import javax.xml.bind.annotation.XmlValue; - -import com.google.common.base.Objects; - - -/** - * Type for localizable string. - * - * Default string value - * - *
- * <complexType name="Msg_Type" />
- * 
- * - * @author grkvlt@apache.org - */ -@XmlType(name = "Msg_Type") -public class MsgType { - - public static Builder builder() { - return new ConcreteBuilder(); - } - - public Builder toBuilder() { - return builder().fromMsgType(this); - } - - private static class ConcreteBuilder extends Builder { - } - - public abstract static class Builder> { - - protected String value; - protected String msgid; - - @SuppressWarnings("unchecked") - protected B self() { - return (B) this; - } - - /** - * @see MsgType#getValue() - */ - public B value(String value) { - this.value = value; - return self(); - } - - /** - * @see MsgType#getMsgid() - */ - public B msgid(String msgid) { - this.msgid = msgid; - return self(); - } - - public MsgType build() { - return new MsgType(this); - } - - public B fromMsgType(MsgType in) { - return value(in.getValue()).msgid(in.getMsgid()); - } - } - - @XmlValue - protected String value; - @XmlAttribute - protected String msgid; - - private MsgType() { - // JAXB - } - - private MsgType(Builder builder) { - this.value = builder.value; - this.msgid = builder.msgid; - } - - /** - * Gets the value of the value property. - */ - public String getValue() { - return value; - } - - /** - * Gets the value of the msgid property. - */ - public String getMsgid() { - if (msgid == null) { - return ""; - } else { - return msgid; - } - } - - @Override - public int hashCode() { - return Objects.hashCode(value, msgid); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - MsgType that = MsgType.class.cast(obj); - return equal(this.value, that.value) && - equal(this.msgid, that.msgid); - } - - @Override - public String toString() { - return Objects.toStringHelper("") - .add("value", value).add("msgid", msgid).toString(); - } -} diff --git a/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/Network.java b/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/Network.java deleted file mode 100644 index 8d33b552f2..0000000000 --- a/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/Network.java +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.dmtf.ovf; - -import javax.xml.bind.annotation.XmlRootElement; - -/** - * @author Adrian Cole - * @author Adam Lowe - */ -@XmlRootElement(name = "Network") -public class Network { - public static Builder builder() { - return new Builder(); - } - - public static class Builder { - protected String name; - protected String description; - - /** - * @see Network#getName - */ - public Builder name(String name) { - this.name = name; - return this; - } - - /** - * @see Network#getDescription - */ - public Builder description(String description) { - this.description = description; - return this; - } - - public Network build() { - return new Network(name, description); - } - - public Builder fromNetwork(Network in) { - return name(in.getName()).description(in.getDescription()); - } - } - - private String name; - private String description; - - protected Network(String name, String description) { - this.name = name; - this.description = description; - } - - protected Network() { - // for JAXB - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((description == null) ? 0 : description.hashCode()); - result = prime * result + ((name == null) ? 0 : name.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - Network other = (Network) obj; - if (description == null) { - if (other.description != null) - return false; - } else if (!description.equals(other.description)) - return false; - if (name == null) { - if (other.name != null) - return false; - } else if (!name.equals(other.name)) - return false; - return true; - } - - @Override - public String toString() { - return "[name=" + name + ", description=" + description + "]"; - } - - public String getName() { - return name; - } - - public String getDescription() { - return description; - } -} diff --git a/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/NetworkSection.java b/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/NetworkSection.java deleted file mode 100644 index 11fbc021fc..0000000000 --- a/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/NetworkSection.java +++ /dev/null @@ -1,128 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.dmtf.ovf; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.Set; - -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlType; - -import com.google.common.base.Objects; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Sets; - -/** - * The NetworkSection element shall list all logical networks used in the OVF package. - * - * @author Adrian Cole - * @author Adam Lowe - */ -@XmlRootElement(name = "NetworkSection") -@XmlType(name = "NetworkSection_Type") -public class NetworkSection extends SectionType { - - public static Builder builder() { - return new ConcreteBuilder(); - } - - public Builder toBuilder() { - return builder().fromNetworkSection(this); - } - - private static class ConcreteBuilder extends Builder { - } - - public static class Builder> extends SectionType.Builder { - protected Set networks = Sets.newLinkedHashSet(); - - /** - * @see NetworkSection#getNetworks - */ - public B network(Network network) { - this.networks.add(checkNotNull(network, "network")); - return self(); - } - - /** - * @see NetworkSection#getNetworks - */ - public B networks(Iterable networks) { - this.networks = ImmutableSet. copyOf(checkNotNull(networks, "networks")); - return self(); - } - - /** - * {@inheritDoc} - */ - @Override - public NetworkSection build() { - return new NetworkSection(this); - } - - public B fromNetworkSection(NetworkSection in) { - return networks(in.getNetworks()).info(in.getInfo()); - } - } - - private Set networks; - - private NetworkSection(Builder builder) { - super(builder); - this.networks = ImmutableSet.copyOf(checkNotNull(networks, "networks")); - } - - private NetworkSection() { - // for JAXB - } - - /** - * All networks referred to from Connection elements in all {@link VirtualHardwareSection} - * elements shall be defined in the NetworkSection. - */ - public Set getNetworks() { - return networks; - } - - @Override - public int hashCode() { - return Objects.hashCode(super.hashCode(), networks); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - NetworkSection other = (NetworkSection) obj; - return super.equals(other) - && Objects.equal(networks, other.networks); - } - - @Override - protected Objects.ToStringHelper string() { - return super.string() - .add("networks", networks); - } - -} diff --git a/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/OperatingSystemSection.java b/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/OperatingSystemSection.java deleted file mode 100644 index 3bbae733bd..0000000000 --- a/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/OperatingSystemSection.java +++ /dev/null @@ -1,160 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.dmtf.ovf; - -import static com.google.common.base.Objects.equal; -import static org.jclouds.dmtf.DMTFConstants.OVF_NS; - -import javax.xml.bind.annotation.XmlAttribute; -import javax.xml.bind.annotation.XmlElement; - -import com.google.common.base.Objects; - -/** - * An OperatingSystemSection specifies the operating system installed on a virtual machine. - * - * @author Adrian Cole - * @author Adam Lowe - */ -public class OperatingSystemSection extends SectionType { - - public static Builder builder() { - return new ConcreteBuilder(); - } - - public Builder toBuilder() { - return builder().fromOperatingSystemSection(this); - } - - private static class ConcreteBuilder extends Builder { - } - - public static class Builder> extends SectionType.Builder { - - private int id; - private String description; - private String version; - - /** - * @see OperatingSystemSection#getId() - */ - public B id(int id) { - this.id = id; - return self(); - } - - /** - * @see OperatingSystemSection#getVersion() - */ - public B version(String version) { - this.version = version; - return self(); - } - - /** - * @see OperatingSystemSection#getDescription - */ - public B description(String description) { - this.description = description; - return self(); - } - - /** - * {@inheritDoc} - */ - @Override - public OperatingSystemSection build() { - return new OperatingSystemSection(this); - } - - public B fromOperatingSystemSection(OperatingSystemSection in) { - return fromSectionType(in) - .id(in.getId()) - .version(in.getVersion()) - .description(in.getDescription()); - } - } - - @XmlAttribute(namespace = OVF_NS, required = true) - protected int id; - @XmlAttribute(namespace = OVF_NS) - protected String version; - @XmlElement(name = "Description") - protected String description; - - public OperatingSystemSection(Builder builder) { - super(builder); - this.id = builder.id; - this.description = builder.description; - this.version = builder.version; - } - - protected OperatingSystemSection() { - // For Builders and JAXB - } - - /** - * Gets the OVF id - * - * @see org.jclouds.vcloud.director.v1_5.domain.cim.OSType#getCode() - */ - public int getId() { - return id; - } - - /** - * Gets the version - */ - public String getVersion() { - return version; - } - - /** - * Gets the description or null - */ - public String getDescription() { - return description; - } - - @Override - public int hashCode() { - return Objects.hashCode(super.hashCode(), id, version, description); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null) return false; - if (getClass() != obj.getClass()) return false; - - OperatingSystemSection that = (OperatingSystemSection) obj; - return super.equals(that) - && equal(this.id, that.id) - && equal(this.version, that.version) - && equal(this.description, that.description); - } - - @Override - protected Objects.ToStringHelper string() { - return super.string() - .add("id", id) - .add("version", version) - .add("description", description); - } -} diff --git a/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/ProductSection.java b/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/ProductSection.java deleted file mode 100644 index 090dd74bf5..0000000000 --- a/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/ProductSection.java +++ /dev/null @@ -1,305 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.dmtf.ovf; - -import static com.google.common.base.Objects.equal; -import static com.google.common.base.Preconditions.checkNotNull; -import static org.jclouds.dmtf.DMTFConstants.CIM_NS; - -import java.util.Set; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlType; - -import org.jclouds.dmtf.cim.CimString; - -import com.google.common.base.Objects; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Sets; - -/** - * The ProductSection element specifies product-information for an appliance, such as product name, - * version, and vendor. - * - * @author Adrian Cole - * @author Adam Lowe - * @author grkvlt@apache.org - */ -@XmlRootElement(name = "ProductSection") -@XmlType(name = "ProductSection_Type") -public class ProductSection extends SectionType { - - public static Builder builder() { - return new ConcreteBuilder(); - } - - public Builder toBuilder() { - return builder().fromProductSection(this); - } - - private static class ConcreteBuilder extends Builder { - } - - public static class Builder> extends SectionType.Builder { - - private MsgType product; - private MsgType vendor; - private CimString version; - private CimString fullVersion; - private CimString productUrl; - private CimString vendorUrl; - private CimString appUrl; - protected Set properties = Sets.newLinkedHashSet(); - - @Override - @SuppressWarnings("unchecked") - protected B self() { - return (B) this; - } - - /** - * @see ProductSection#getProduct() - */ - public B product(MsgType product) { - this.product = product; - return self(); - } - - /** - * @see ProductSection#getVendor() - */ - public B vendor(MsgType vendor) { - this.vendor = vendor; - return self(); - } - - /** - * @see ProductSection#getVersion() - */ - public B version(CimString version) { - this.version = version; - return self(); - } - - /** - * @see ProductSection#geFullVersion() - */ - public B fullVersion(CimString fullVersion) { - this.fullVersion = fullVersion; - return self(); - } - - /** - * @see ProductSection#getProductUrl() - */ - public B productUrl(CimString productUrl) { - this.productUrl = productUrl; - return self(); - } - - /** - * @see ProductSection#getProductUrl() - */ - public B productUrl(String productUrl) { - this.productUrl = new CimString(productUrl); - return self(); - } - - /** - * @see ProductSection#getVendorUrl() - */ - public B vendorUrl(CimString vendorUrl) { - this.vendorUrl = vendorUrl; - return self(); - } - - /** - * @see ProductSection#getAppUrl() - */ - public B appUrl(CimString appUrl) { - this.appUrl = appUrl; - return self(); - } - - /** - * @see ProductSection#getProperties() - */ - public B property(ProductSectionProperty property) { - this.properties.add(checkNotNull(property, "property")); - return self(); - } - - /** - * @see ProductSection#getProperties - */ - public B properties(Iterable properties) { - this.properties = ImmutableSet.copyOf(checkNotNull(properties, "properties")); - return self(); - } - - /** - * {@inheritDoc} - */ - @Override - public ProductSection build() { - return new ProductSection(this); - } - - public B fromProductSection(ProductSection in) { - return fromSectionType(in) - .product(in.getProduct()) - .vendor(in.getVendor()) - .version(in.getVersion()) - .fullVersion(in.getFullVersion()) - .productUrl(in.getProductUrl()) - .vendorUrl(in.getVendorUrl()) - .appUrl(in.getAppUrl()) - .properties(Sets.newLinkedHashSet(in.getProperties())); - } - } - - private ProductSection(Builder builder) { - super(builder); - this.product = builder.product; - this.vendor = builder.vendor; - this.version = builder.version; - this.fullVersion = builder.fullVersion; - this.productUrl = builder.productUrl; - this.vendorUrl = builder.vendorUrl; - this.appUrl = builder.appUrl; - this.properties = builder.properties != null ? ImmutableSet.copyOf(checkNotNull(builder.properties, "properties")) : ImmutableSet.of(); - } - - private ProductSection() { - // For JAXB - } - - @XmlElement(name = "Product") - private MsgType product; - @XmlElement(name = "Vendor") - private MsgType vendor; - @XmlElement(name = "Version", namespace = CIM_NS) - private CimString version; - @XmlElement(name = "FullVersion", namespace = CIM_NS) - private CimString fullVersion; - @XmlElement(name = "ProductUrl", namespace = CIM_NS) - private CimString productUrl; - @XmlElement(name = "VendorUrl", namespace = CIM_NS) - private CimString vendorUrl; - @XmlElement(name = "AppUrl", namespace = CIM_NS) - private CimString appUrl; - @XmlElement(name = "Property") - private Set properties = Sets.newLinkedHashSet(); - - /** - * Name of product. - */ - public MsgType getProduct() { - return product; - } - - /** - * Name of product vendor. - */ - public MsgType getVendor() { - return vendor; - } - - /** - * Product version, short form. - */ - public CimString getVersion() { - return version; - } - - /** - * Product version, long form. - */ - public CimString getFullVersion() { - return fullVersion; - } - - /** - * URL resolving to product description. - */ - public CimString getProductUrl() { - return productUrl; - } - - /** - * URL resolving to vendor description. - */ - public CimString getVendorUrl() { - return vendorUrl; - } - - /** - * Experimental: URL resolving to deployed product instance. - */ - public CimString getAppUrl() { - return appUrl; - } - - // TODO Set - - /** - * Properties for application-level customization. - */ - public Set getProperties() { - return properties; - } - - @Override - public int hashCode() { - return Objects.hashCode(super.hashCode(), product, vendor, version, fullVersion, productUrl, vendorUrl, appUrl, properties); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (!super.equals(obj)) return false; - if (getClass() != obj.getClass()) return false; - - ProductSection that = ProductSection.class.cast(obj); - return super.equals(that) && - equal(this.product, that.product) && - equal(this.vendor, that.vendor) && - equal(this.version, that.version) && - equal(this.fullVersion, that.fullVersion) && - equal(this.productUrl, that.productUrl) && - equal(this.vendorUrl, that.vendorUrl) && - equal(this.appUrl, that.appUrl) && - equal(this.properties, that.properties); - } - - @Override - protected Objects.ToStringHelper string() { - return super.string() - .add("product", product) - .add("vendor", vendor) - .add("version", version) - .add("fullVersion", fullVersion) - .add("productUrl", productUrl) - .add("vendorUrl", vendorUrl) - .add("appUrl", appUrl) - .add("properties", properties); - } - -} diff --git a/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/ProductSectionProperty.java b/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/ProductSectionProperty.java deleted file mode 100644 index 22f04cbcfa..0000000000 --- a/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/ProductSectionProperty.java +++ /dev/null @@ -1,38 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.dmtf.ovf; - -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlType; - - -/** - * Property element - * - *
- * <element name="Property" />
- * 
- * - * @author grkvlt@apache.org - */ -@XmlType(name = "") -@XmlRootElement(name = "Property") -public class ProductSectionProperty extends Property { - // TODO hashCode, equals, toString -} diff --git a/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/Property.java b/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/Property.java deleted file mode 100644 index 72a076207e..0000000000 --- a/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/Property.java +++ /dev/null @@ -1,308 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.dmtf.ovf; - -import static com.google.common.base.Objects.equal; -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.Set; - -import javax.xml.bind.annotation.XmlAttribute; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlSeeAlso; -import javax.xml.bind.annotation.XmlType; - -import com.google.common.base.Joiner; -import com.google.common.base.Objects; -import com.google.common.collect.Sets; - -/** - * @author Adrian Cole - * @author Adam Lowe - * @author grkvlt@apache.org - */ -@XmlType(name = "Property") -@XmlSeeAlso({ ProductSectionProperty.class }) -public class Property { - - public static Builder builder() { - return new ConcreteBuilder(); - } - - public Builder toBuilder() { - return builder().fromProperty(this); - } - - private static class ConcreteBuilder extends Builder { - } - - public abstract static class Builder> { - - protected String key; - protected Set values = Sets.newLinkedHashSet(); - protected MsgType label; - protected MsgType description; - protected String type; - protected String qualifiers; - protected Boolean userConfigurable; - protected String defaultValue = ""; - - @SuppressWarnings("unchecked") - protected B self() { - return (B) this; - } - - /** - * @see Property#getKey() - */ - public B key(String key) { - this.key = key; - return self(); - } - - /** - * @see Property#getValues() - */ - public B values(Set values) { - this.values = checkNotNull(values, "values"); - return self(); - } - - /** - * @see Property#getValues() - */ - public B value(PropertyConfigurationValueType value) { - this.values.add(checkNotNull(value, "value")); - return self(); - } - - /** - * @see Property#getLabel() - */ - public B label(MsgType label) { - this.label = label; - return self(); - } - - /** - * @see Property#getDescription() - */ - public B description(MsgType description) { - this.description = description; - return self(); - } - - /** - * @see Property#getType() - */ - public B type(String type) { - this.type = type; - return self(); - } - - /** - * @see Property#getQualifiers() - */ - public B qualifiers(String qualifiers) { - this.qualifiers = qualifiers; - return self(); - } - - /** - * @see Property#getQualifiers() - */ - public B qualifiers(Iterable qualifiers) { - this.qualifiers = Joiner.on(',').join(qualifiers); - return self(); - } - - /** - * @see Property#getQualifiers() - */ - public B qualifiers(String...qualifiers) { - this.qualifiers = Joiner.on(',').join(qualifiers); - return self(); - } - - /** - * @see Property#isUserConfigurable() - */ - public B isUserConfigurable(Boolean userConfigurable) { - this.userConfigurable = userConfigurable; - return self(); - } - - /** - * @see Property#isUserConfigurable() - */ - public B userConfigurable() { - this.userConfigurable = Boolean.TRUE; - return self(); - } - - /** - * @see Property#isUserConfigurable() - */ - public B notUserConfigurable() { - this.userConfigurable = Boolean.FALSE; - return self(); - } - - /** - * @see Property#getDefaultValue() - */ - public B defaultValue(String defaultValue) { - this.defaultValue = defaultValue; - return self(); - } - - public Property build() { - return new Property(this); - } - - public B fromProperty(Property in) { - return key(in.getKey()).values(in.getValues()).description(in.getDescription()).label(in.getLabel()) - .type(in.getType()).qualifiers(in.getQualifiers()).isUserConfigurable(in.isUserConfigurable()).defaultValue(in.getDefaultValue()); - } - } - - @XmlAttribute - private String key; - @XmlElement(name = "Value") - private Set values; - @XmlElement(name = "Label") - private MsgType label; - @XmlElement(name = "Description") - private MsgType description; - @XmlAttribute(required = true) - private String type; - @XmlAttribute(required = true) - private String qualifiers; - @XmlAttribute - private Boolean userConfigurable; - @XmlAttribute(name = "value") - private String defaultValue; - - protected Property(Builder builder) { - this.key = builder.key; - this.values = builder.values; - this.label = builder.label; - this.description = builder.description; - this.type = builder.type; - this.qualifiers = builder.qualifiers; - this.userConfigurable = builder.userConfigurable; - this.defaultValue = builder.defaultValue; - } - - protected Property() { - // for JAXB - } - - /** - * Property identifier. - */ - public String getKey() { - return key; - } - - /** - * Description of property. - */ - public MsgType getDescription() { - return description; - } - - /** - * Short description of property. - */ - public MsgType getLabel() { - return label; - } - - /** - * Alternative default property values for different configuration - */ - public Set getValues() { - return values; - } - - /** - * Property type. - */ - public String getType() { - return type; - } - - /** - * A comma-separated set of type qualifiers. - */ - public String getQualifiers() { - return qualifiers; - } - - /** - * Determines whether the property value is configurable during installation. - */ - public Boolean isUserConfigurable() { - return userConfigurable; - } - - /** - * A Default value for property. - */ - public String getDefaultValue() { - if (defaultValue == null) { - return ""; - } else { - return defaultValue; - } - } - - @Override - public int hashCode() { - return Objects.hashCode(key, values, label, description, type, qualifiers, userConfigurable, defaultValue); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - Property that = Property.class.cast(obj); - return equal(this.key, that.key) && - equal(this.values, that.values) && - equal(this.label, that.label) && - equal(this.description, that.description) && - equal(this.type, that.type) && - equal(this.qualifiers, that.qualifiers) && - equal(this.userConfigurable, that.userConfigurable) && - equal(this.defaultValue, that.defaultValue); - } - - @Override - public String toString() { - return Objects.toStringHelper("") - .add("key", key).add("values", values).add("label", label).add("description", description) - .add("type", type).add("qualifiers", qualifiers).add("userConfigurable", userConfigurable).add("defaultValue", defaultValue) - .toString(); - } -} diff --git a/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/PropertyConfigurationValueType.java b/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/PropertyConfigurationValueType.java deleted file mode 100644 index 19d1bbe924..0000000000 --- a/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/PropertyConfigurationValueType.java +++ /dev/null @@ -1,58 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.dmtf.ovf; - -import javax.xml.bind.annotation.XmlAttribute; -import javax.xml.bind.annotation.XmlType; - -/** - * Type for alternative default values for properties when DeploymentOptionSection is used - * - *
- * <complexType name="PropertyConfigurationValue_Type">
- * 
- * - * @author grkvlt@apache.org - */ -@XmlType(name = "PropertyConfigurationValue_Type") -public class PropertyConfigurationValueType { - - // TODO Builder - - @XmlAttribute(namespace = "http://schemas.dmtf.org/ovf/envelope/1", required = true) - protected String value; - @XmlAttribute(namespace = "http://schemas.dmtf.org/ovf/envelope/1") - protected String configuration; - - /** - * Gets the value of the value property. - */ - public String getValue() { - return value; - } - - /** - * Gets the value of the configuration property. - */ - public String getConfiguration() { - return configuration; - } - - // TODO hashCode, equals, toString -} diff --git a/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/SectionType.java b/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/SectionType.java deleted file mode 100644 index ff887e62c7..0000000000 --- a/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/SectionType.java +++ /dev/null @@ -1,147 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.dmtf.ovf; - -import static com.google.common.base.Objects.equal; -import static org.jclouds.dmtf.DMTFConstants.OVF_NS; - -import javax.xml.bind.annotation.XmlAttribute; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlType; - -import com.google.common.base.Objects; - -/** - * Metadata about a virtual machine or grouping of them. - * - * Base type for Sections, subclassing this is the most common form of extensibility. Subtypes define more specific elements. - * - * @author Adrian Cole - * @author Adam Lowe - * @author grkvlt@apache.org - */ -@XmlType(name = "Section_Type") -public abstract class SectionType { - - public abstract static class Builder> { - private String info; - private Boolean required; - - @SuppressWarnings("unchecked") - protected B self() { - return (B) this; - } - - public abstract SectionType build(); - - /** - * @see SectionType#getInfo() - */ - public B info(String info) { - this.info = info; - return self(); - } - - /** - * @see SectionType#isRequired() - */ - public B required(Boolean required) { - this.required = required; - return self(); - } - - /** - * @see SectionType#isRequired() - */ - public B required() { - this.required = Boolean.TRUE; - return self(); - } - - /** - * @see SectionType#isRequired() - */ - public B notRequired() { - this.required = Boolean.FALSE; - return self(); - } - - public B fromSectionType(SectionType in) { - return info(in.getInfo()).required(in.isRequired()); - } - } - - @XmlElement(name = "Info", required = true) - private String info; - @XmlAttribute(namespace = OVF_NS) - private Boolean required; - - protected SectionType(Builder builder) { - this.info = builder.info; - this.required = builder.required; - } - - protected SectionType() { - // For JAXB - } - - /** - * Info element describes the meaning of the Section, this is typically shown if the Section is not understood by an application - * - * @return ovf info - */ - public String getInfo() { - return info; - } - - public void setInfo(String info) { - this.info = info; - } - - public Boolean isRequired() { - return required; - } - - @Override - public int hashCode() { - return Objects.hashCode(info, required); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - SectionType other = (SectionType) obj; - return equal(this.info, other.info) && equal(this.required, other.required); - } - - @Override - public String toString() { - return string().toString(); - } - - protected Objects.ToStringHelper string() { - return Objects.toStringHelper("").add("info", info).add("required", required); - } - -} diff --git a/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/StartupSection.java b/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/StartupSection.java deleted file mode 100644 index cf3799f96c..0000000000 --- a/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/StartupSection.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.dmtf.ovf; - -import static com.google.common.base.Objects.equal; -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.List; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlType; - -import com.google.common.base.Objects; -import com.google.common.base.Objects.ToStringHelper; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.Lists; - -/** - * Specifies the order in which entities in a VirtualSystemCollection are powered on and shut down - * - *
- * <complexType name="StartupSection_Type" />
- * 
- */ -@XmlRootElement(name = "StartupSection") -@XmlType(name = "StartupSection_Type") -public class StartupSection extends SectionType { - - public static Builder builder() { - return new ConcreteBuilder(); - } - - public Builder toBuilder() { - return builder().fromStartupSection(this); - } - - private static class ConcreteBuilder extends Builder { - } - - public static class Builder> extends SectionType.Builder { - - private List items = Lists.newArrayList(); - - /** - * @see StartupSection#getItem() - */ - public B items(List items) { - this.items = checkNotNull(items, "items"); - return self(); - } - - /** - * @see StartupSection#getItem() - */ - public B item(StartupSectionItem item) { - this.items.add(checkNotNull(item, "item")); - return self(); - } - - @Override - public StartupSection build() { - return new StartupSection(this); - } - - public B fromStartupSection(StartupSection in) { - return fromSectionType(in).items(in.getItems()); - } - } - - @XmlElement(name = "Item") - private List items = Lists.newArrayList(); - - protected StartupSection() { - // For JAXB - } - - public StartupSection(Builder builder) { - super(builder); - this.items = (items != null) ? ImmutableList.copyOf(builder.items) : ImmutableList.of(); - } - - /** - * Gets the value of the item property. - */ - public List getItems() { - return items; - } - - @Override - public boolean equals(Object o) { - if (this == o) - return true; - if (o == null || getClass() != o.getClass()) - return false; - StartupSection that = StartupSection.class.cast(o); - return super.equals(that) && equal(this.items, that.items); - } - - @Override - public int hashCode() { - return Objects.hashCode(super.hashCode(), items); - } - - @Override - public ToStringHelper string() { - return super.string().add("items", items); - } -} diff --git a/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/StartupSectionItem.java b/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/StartupSectionItem.java deleted file mode 100644 index ca2c716ab1..0000000000 --- a/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/StartupSectionItem.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.dmtf.ovf; - -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlType; - -/** - * Java class for Item element declaration. - * - *
- * <element name="Item">
- *   <complexType>
- *     <complexContent>
- *       <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- *         <attribute name="id" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
- *         <attribute name="order" use="required" type="{http://www.w3.org/2001/XMLSchema}unsignedShort" />
- *         <attribute name="startDelay" type="{http://www.w3.org/2001/XMLSchema}unsignedShort" default="0" />
- *         <attribute name="waitingForGuest" type="{http://www.w3.org/2001/XMLSchema}boolean" default="false" />
- *         <attribute name="stopDelay" type="{http://www.w3.org/2001/XMLSchema}unsignedShort" default="0" />
- *         <attribute name="startAction" type="{http://www.w3.org/2001/XMLSchema}string" default="powerOn" />
- *         <attribute name="stopAction" type="{http://www.w3.org/2001/XMLSchema}string" default="powerOff" />
- *         <anyAttribute processContents='lax'/>
- *       </restriction>
- *     </complexContent>
- *   </complexType>
- * </element>
- * 
- */ -@XmlType -@XmlRootElement(name = "Item") -public class StartupSectionItem extends Item { - - // TODO Builder - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - StartupSectionItem that = StartupSectionItem.class.cast(obj); - return super.equals(that); - } - -} diff --git a/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/VirtualHardwareSection.java b/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/VirtualHardwareSection.java deleted file mode 100644 index 6bc67ea370..0000000000 --- a/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/VirtualHardwareSection.java +++ /dev/null @@ -1,204 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.dmtf.ovf; - -import static com.google.common.base.Objects.equal; -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.Set; - -import javax.xml.bind.annotation.XmlAttribute; -import javax.xml.bind.annotation.XmlElement; - -import org.jclouds.dmtf.cim.ResourceAllocationSettingData; -import org.jclouds.dmtf.cim.VirtualSystemSettingData; - -import com.google.common.base.Joiner; -import com.google.common.base.Objects; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Sets; - -/** - * The virtual hardware required by a virtual machine is specified in VirtualHardwareSection. - * - * This specification supports abstract or incomplete hardware descriptions in which only the major - * devices are described. The hypervisor is allowed to create additional virtual hardware - * controllers and devices, as long as the required devices listed in the descriptor are realized. - * - * @author Adrian Cole - * @author Adam Lowe - * @author grkvlt@apache.org - */ -public class VirtualHardwareSection extends SectionType { - - public static Builder builder() { - return new ConcreteBuilder(); - } - - public Builder toBuilder() { - return builder().fromVirtualHardwareSection(this); - } - - private static class ConcreteBuilder extends Builder { - } - - public static class Builder> extends SectionType.Builder { - - private VirtualSystemSettingData virtualSystem; - private String transport; - private Set items = Sets.newLinkedHashSet(); - - /** - * @see VirtualHardwareSection#getSystem() - */ - public B system(VirtualSystemSettingData virtualSystem) { - this.virtualSystem = virtualSystem; - return self(); - } - - /** - * @see VirtualHardwareSection#getTransport() - */ - public B transport(String transport) { - this.transport = transport; - return self(); - } - - /** - * @see VirtualHardwareSection#getTransport() - */ - public B transport(Iterable transports) { - this.transport = Joiner.on(',').join(transports); - return self(); - } - - /** - * @see VirtualHardwareSection#getTransport() - */ - public B transport(String...transports) { - this.transport = Joiner.on(',').join(transports); - return self(); - } - - /** - * @see VirtualHardwareSection#getItems() - */ - public B item(ResourceAllocationSettingData item) { - this.items.add(checkNotNull(item, "item")); - return self(); - } - - /** - * @see VirtualHardwareSection#getItems() - */ - public B items(Iterable items) { - this.items = Sets.newLinkedHashSet(checkNotNull(items, "items")); - return self(); - } - - /** - * {@inheritDoc} - */ - @Override - public VirtualHardwareSection build() { - return new VirtualHardwareSection(this); - } - - public B fromVirtualHardwareSection(VirtualHardwareSection in) { - return fromSectionType(in) - .items(in.getItems()) - .transport(in.getTransport()) - .system(in.getSystem()); - } - } - - @XmlElement(name = "System") - protected VirtualSystemSettingData virtualSystem; - @XmlAttribute(name = "transport") - protected String transport; - @XmlElement(name = "Item") - protected Set items = Sets.newLinkedHashSet(); - - protected VirtualHardwareSection(Builder builder) { - super(builder); - this.virtualSystem = builder.virtualSystem; - this.transport = builder.transport; - this.items = builder.items != null ? ImmutableSet.copyOf(builder.items) : Sets.newLinkedHashSet(); - } - - protected VirtualHardwareSection() { - // For JAXB - } - - /** - * Comma-separated list of supported transports types for the OVF descriptor. - * - * Transport types define methods by which the environment document is communicated from the - * deployment platform to the guest software. - *

- * To enable interoperability, this specification defines an "iso" transport type which all - * implementations that support CD-ROM devices are required to support. The iso transport - * communicates the environment 1346 document by making a dynamically generated ISO image - * available to the guest software. To support the iso transport type, prior to booting a virtual - * machine, an implementation shall make an ISO 9660 read-only disk image available as backing - * for a disconnected CD-ROM. If the iso transport is selected for a VirtualHardwareSection, at - * least one disconnected CD-ROM device shall be present in this section. - *

- * Support for the "iso" transport type is not a requirement for virtual hardware architectures - * or guest 1351 operating systems which do not have CD-ROM device support. - * - * @return - */ - public String getTransport() { - return transport; - } - - public VirtualSystemSettingData getSystem() { - return virtualSystem; - } - - public Set getItems() { - return ImmutableSet.copyOf(items); - } - - @Override - public int hashCode() { - return Objects.hashCode(super.hashCode(), transport, virtualSystem, items); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null) return false; - if (getClass() != obj.getClass()) return false; - VirtualHardwareSection that = VirtualHardwareSection.class.cast(obj); - return super.equals(that) - && equal(this.transport, that.transport) - && equal(this.virtualSystem, that.virtualSystem) - && equal(this.items, that.items); - } - - @Override - protected Objects.ToStringHelper string() { - return super.string() - .add("transport", transport) - .add("virtualSystem", virtualSystem) - .add("items", items); - } -} diff --git a/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/environment/EntityType.java b/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/environment/EntityType.java deleted file mode 100644 index 57d38e238a..0000000000 --- a/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/environment/EntityType.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.dmtf.ovf.environment; - -import static org.jclouds.dmtf.DMTFConstants.OVF_ENV_NS; - -import java.util.Map; -import java.util.Set; - -import javax.xml.bind.annotation.XmlAnyAttribute; -import javax.xml.bind.annotation.XmlAnyElement; -import javax.xml.bind.annotation.XmlAttribute; -import javax.xml.bind.annotation.XmlElementRef; -import javax.xml.bind.annotation.XmlType; -import javax.xml.namespace.QName; - -import com.google.common.collect.Maps; -import com.google.common.collect.Sets; - -/** - * Container of sections for a specific entity - * - *

- * <complexType name="Entity_Type">
- *   <complexContent>
- *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- *       <sequence>
- *         <element ref="{http://schemas.dmtf.org/ovf/environment/1}Section" maxOccurs="unbounded" minOccurs="0"/>
- *         <any processContents='lax' namespace='##other' maxOccurs="unbounded" minOccurs="0"/>
- *       </sequence>
- *       <attribute name="id" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
- *       <anyAttribute processContents='lax'/>
- *     </restriction>
- *   </complexContent>
- * </complexType>
- * 
- */ -@XmlType(name = "Entity_Type") -public class EntityType { - - @XmlElementRef(name = "Section", namespace = OVF_ENV_NS) - protected Set> sections = Sets.newLinkedHashSet(); - @XmlAnyElement(lax = true) - protected Set any = Sets.newLinkedHashSet(); - @XmlAttribute(namespace = OVF_ENV_NS, required = true) - protected String id; - @XmlAnyAttribute - private Map otherAttributes = Maps.newLinkedHashMap(); - - /** - * Gets the value of the sections property. - */ - public Set> getSection() { - return sections; - } - - /** - * Gets the value of the any property. - */ - public Set getAny() { - return any; - } - - /** - * Gets the value of the id property. - */ - public String getId() { - return id; - } - - /** - * Gets a map that contains attributes that aren't bound to any typed property on this class. - */ - public Map getOtherAttributes() { - return otherAttributes; - } -} diff --git a/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/environment/EnvironmentType.java b/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/environment/EnvironmentType.java deleted file mode 100644 index 75127666a9..0000000000 --- a/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/environment/EnvironmentType.java +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.dmtf.ovf.environment; - -import static org.jclouds.dmtf.DMTFConstants.OVF_ENV_NS; - -import java.util.Map; -import java.util.Set; - -import javax.xml.bind.annotation.XmlAnyAttribute; -import javax.xml.bind.annotation.XmlAnyElement; -import javax.xml.bind.annotation.XmlAttribute; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlElementRef; -import javax.xml.bind.annotation.XmlType; -import javax.xml.namespace.QName; - -import com.google.common.collect.Maps; -import com.google.common.collect.Sets; - -/** - * Type for root OVF environment - * - *
- * <complexType name="Environment_Type">
- *   <complexContent>
- *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- *       <sequence>
- *         <element ref="{http://schemas.dmtf.org/ovf/environment/1}Section" maxOccurs="unbounded" minOccurs="0"/>
- *         <element name="Entity" type="{http://schemas.dmtf.org/ovf/environment/1}Entity_Type" maxOccurs="unbounded" minOccurs="0"/>
- *         <any processContents='lax' namespace='##other' maxOccurs="unbounded" minOccurs="0"/>
- *       </sequence>
- *       <attribute name="id" type="{http://www.w3.org/2001/XMLSchema}string" default="" />
- *       <anyAttribute processContents='lax'/>
- *     </restriction>
- *   </complexContent>
- * </complexType>
- * 
- */ -@XmlType(name = "Environment_Type") -public class EnvironmentType { - - @XmlElementRef(name = "Section", namespace = OVF_ENV_NS) - protected Set> sections = Sets.newLinkedHashSet(); - @XmlElement(name = "Entity") - protected Set entities = Sets.newLinkedHashSet(); - @XmlAnyElement(lax = true) - protected Set any = Sets.newLinkedHashSet(); - @XmlAttribute(namespace = OVF_ENV_NS) - protected String id; - @XmlAnyAttribute - private Map otherAttributes = Maps.newLinkedHashMap(); - - /** - * Entity independent meta-data sections Gets the value of the sections property. - */ - public Set> getSections() { - return sections; - } - - /** - * Gets the value of the entities property. - */ - public Set getEntities() { - return entities; - } - - /** - * Gets the value of the any property. - */ - public Set getAny() { - return any; - } - - /** - * Gets the value of the id property. - */ - public String getId() { - if (id == null) { - return ""; - } else { - return id; - } - } - - /** - * Sets the value of the id property. - */ - public void setId(String value) { - this.id = value; - } - - /** - * Gets a map that contains attributes that aren't bound to any typed property on this class. - */ - public Map getOtherAttributes() { - return otherAttributes; - } - -} diff --git a/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/environment/PlatformSectionType.java b/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/environment/PlatformSectionType.java deleted file mode 100644 index 026bbac131..0000000000 --- a/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/environment/PlatformSectionType.java +++ /dev/null @@ -1,142 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.dmtf.ovf.environment; - -import java.util.Set; - -import javax.xml.bind.annotation.XmlAnyElement; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlType; - -import org.jclouds.dmtf.cim.CimString; - -import com.google.common.base.Objects; -import com.google.common.collect.Sets; - -/** - * Information about deployment platform - * - *
- * <complexType name="PlatformSection_Type">
- *   <complexContent>
- *     <extension base="{http://schemas.dmtf.org/ovf/environment/1}Section_Type">
- *       <sequence>
- *         <element name="Kind" type="{http://schemas.dmtf.org/wbem/wscim/1/common}cimString" minOccurs="0"/>
- *         <element name="Version" type="{http://schemas.dmtf.org/wbem/wscim/1/common}cimString" minOccurs="0"/>
- *         <element name="Vendor" type="{http://schemas.dmtf.org/wbem/wscim/1/common}cimString" minOccurs="0"/>
- *         <element name="Locale" type="{http://schemas.dmtf.org/wbem/wscim/1/common}cimString" minOccurs="0"/>
- *         <element name="Timezone" type="{http://www.w3.org/2001/XMLSchema}int" minOccurs="0"/>
- *         <any processContents='lax' namespace='##other' maxOccurs="unbounded" minOccurs="0"/>
- *       </sequence>
- *       <anyAttribute processContents='lax'/>
- *     </extension>
- *   </complexContent>
- * </complexType>
- * 
- */ -@XmlRootElement(name = "PlatformSection") -@XmlType(name = "PlatformSection_Type") -public class PlatformSectionType extends SectionType { - - @XmlElement(name = "Kind") - protected CimString kind; - @XmlElement(name = "Version") - protected CimString version; - @XmlElement(name = "Vendor") - protected CimString vendor; - @XmlElement(name = "Locale") - protected CimString locale; - @XmlElement(name = "Timezone") - protected Integer timezone; - @XmlAnyElement(lax = true) - protected Set any = Sets.newLinkedHashSet(); - - /** - * Gets the value of the kind property. - */ - public CimString getKind() { - return kind; - } - - /** - * Gets the value of the version property. - */ - public CimString getVersion() { - return version; - } - - /** - * Gets the value of the vendor property. - */ - public CimString getVendor() { - return vendor; - } - - /** - * Gets the value of the locale property. - */ - public CimString getLocale() { - return locale; - } - - /** - * Gets the value of the timezone property. - */ - public Integer getTimezone() { - return timezone; - } - - /** - * Gets the value of the any property. - */ - public Set getAny() { - return any; - } - - @Override - public int hashCode() { - return Objects.hashCode(super.hashCode(), version, vendor, timezone, locale, kind, any); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - PlatformSectionType that = (PlatformSectionType) obj; - return super.equals(that) && - Objects.equal(this.version, that.version) && - Objects.equal(this.vendor, that.vendor) && - Objects.equal(this.timezone, that.timezone) && - Objects.equal(this.locale, that.locale) && - Objects.equal(this.kind, that.kind) && - Objects.equal(this.any, that.any); - } - - @Override - protected Objects.ToStringHelper string() { - return super.string() - .add("version", version).add("vendor", vendor).add("timezone", timezone) - .add("locale", locale).add("kind", kind).add("any", any); - } -} diff --git a/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/environment/Property.java b/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/environment/Property.java deleted file mode 100644 index 021d569f8e..0000000000 --- a/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/environment/Property.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.dmtf.ovf.environment; - -import static org.jclouds.dmtf.DMTFConstants.OVF_ENV_NS; - -import java.util.Map; - -import com.google.common.collect.Maps; - -import javax.xml.bind.annotation.XmlAnyAttribute; -import javax.xml.bind.annotation.XmlAttribute; -import javax.xml.bind.annotation.XmlType; -import javax.xml.namespace.QName; - -/** - * Java class for anonymous complex type. - */ -@XmlType(name = "") -public class Property { - - @XmlAttribute(namespace = OVF_ENV_NS, required = true) - protected String key; - @XmlAttribute(namespace = OVF_ENV_NS, required = true) - protected String value; - @XmlAnyAttribute - private Map otherAttributes = Maps.newHashMap(); - - /** - * Gets the value of the key property. - */ - public String getKey() { - return key; - } - - /** - * Sets the value of the key property. - */ - public void setKey(String value) { - this.key = value; - } - - /** - * Gets the value of the value property. - */ - public String getValue() { - return value; - } - - /** - * Sets the value of the value property. - */ - public void setValue(String value) { - this.value = value; - } - - /** - * Gets a map that contains attributes that aren't bound to any typed property on this class. - */ - public Map getOtherAttributes() { - return otherAttributes; - } - -} diff --git a/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/environment/PropertySectionType.java b/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/environment/PropertySectionType.java deleted file mode 100644 index f60913dbed..0000000000 --- a/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/environment/PropertySectionType.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.dmtf.ovf.environment; - -import java.util.Set; - -import javax.xml.bind.annotation.XmlAnyElement; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlType; - -import com.google.common.base.Objects; -import com.google.common.collect.Sets; - -/** - * Key/value pairs of assigned properties for an entity - * - *
- * <complexType name="PropertySection_Type">
- *   <complexContent>
- *     <extension base="{http://schemas.dmtf.org/ovf/environment/1}Section_Type">
- *       <sequence>
- *         <element name="Property" maxOccurs="unbounded" minOccurs="0">
- *           <complexType>
- *             <complexContent>
- *               <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- *                 <attribute name="key" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
- *                 <attribute name="value" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
- *                 <anyAttribute processContents='lax'/>
- *               </restriction>
- *             </complexContent>
- *           </complexType>
- *         </element>
- *         <any processContents='lax' namespace='##other' maxOccurs="unbounded" minOccurs="0"/>
- *       </sequence>
- *       <anyAttribute processContents='lax'/>
- *     </extension>
- *   </complexContent>
- * </complexType>
- * 
- */ -@XmlRootElement(name = "PropertySection") -@XmlType(name = "PropertySection_Type") -public class PropertySectionType extends SectionType { - - @XmlElement(name = "Property") - protected Set properties = Sets.newLinkedHashSet(); - @XmlAnyElement(lax = true) - protected Set any = Sets.newLinkedHashSet(); - - /** - * Gets the value of the properties property. - */ - public Set getProperties() { - return properties; - } - - /** - * Gets the value of the any property. - */ - public Set getAny() { - return any; - } - - @Override - public int hashCode() { - return Objects.hashCode(super.hashCode(), properties, any); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - PropertySectionType that = (PropertySectionType) obj; - return super.equals(that) && - Objects.equal(this.properties, that.properties) && - Objects.equal(this.any, that.any); - } - - @Override - protected Objects.ToStringHelper string() { - return super.string() - .add("properties", properties).add("any", any); - } -} diff --git a/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/environment/SectionType.java b/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/environment/SectionType.java deleted file mode 100644 index ea60969848..0000000000 --- a/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/environment/SectionType.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.dmtf.ovf.environment; - -import java.util.Map; - -import javax.xml.bind.annotation.XmlAnyAttribute; -import javax.xml.bind.annotation.XmlSeeAlso; -import javax.xml.bind.annotation.XmlType; -import javax.xml.namespace.QName; - -import com.google.common.base.Objects; -import com.google.common.collect.Maps; - -/** - * Abstract type for all sections in - * environment - * - *

Java class for Section_Type complex type. - * - *

The following schema fragment specifies the expected content contained within this class. - * - *

- * <complexType name="Section_Type">
- *   <complexContent>
- *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- *       <anyAttribute processContents='lax'/>
- *     </restriction>
- *   </complexContent>
- * </complexType>
- * 
- */ -@XmlType(name = "Section_Type") -@XmlSeeAlso({ - PlatformSectionType.class, - PropertySectionType.class -}) -public abstract class SectionType> { - - @XmlAnyAttribute - private Map otherAttributes = Maps.newLinkedHashMap(); - - /** - * Gets a map that contains attributes that aren't bound to any typed property on this class. - */ - public Map getOtherAttributes() { - return otherAttributes; - } - - @Override - public int hashCode() { - return Objects.hashCode(otherAttributes); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - SectionType that = (SectionType) obj; - return Objects.equal(this.otherAttributes, that.otherAttributes); - } - - @Override - public String toString() { - return string().toString(); - } - - protected Objects.ToStringHelper string() { - return Objects.toStringHelper("").add("otherAttributes", otherAttributes); - } - -} diff --git a/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/environment/package-info.java b/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/environment/package-info.java deleted file mode 100644 index 4c5614427f..0000000000 --- a/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/environment/package-info.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -@XmlSchema(namespace = OVF_ENV_NS, - elementFormDefault = XmlNsForm.QUALIFIED, - xmlns = { - @XmlNs(prefix = "cim", namespaceURI = CIM_NS), - @XmlNs(prefix = "ovf", namespaceURI = OVF_NS), - @XmlNs(prefix = "env", namespaceURI = OVF_ENV_NS) - } -) -@XmlAccessorType(XmlAccessType.FIELD) -package org.jclouds.dmtf.ovf.environment; - -import static org.jclouds.dmtf.DMTFConstants.CIM_NS; -import static org.jclouds.dmtf.DMTFConstants.OVF_ENV_NS; -import static org.jclouds.dmtf.DMTFConstants.OVF_NS; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlNs; -import javax.xml.bind.annotation.XmlNsForm; -import javax.xml.bind.annotation.XmlSchema; - diff --git a/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/internal/BaseEnvelope.java b/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/internal/BaseEnvelope.java deleted file mode 100644 index 7b7d234d0c..0000000000 --- a/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/internal/BaseEnvelope.java +++ /dev/null @@ -1,182 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.dmtf.ovf.internal; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.Set; - -import org.jclouds.dmtf.ovf.DiskSection; -import org.jclouds.dmtf.ovf.NetworkSection; -import org.jclouds.dmtf.ovf.SectionType; - -import com.google.common.base.Objects; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Sets; - -/** - * @author Adrian Cole - * @author grkvlt@apache.org - */ -public abstract class BaseEnvelope> { - - public abstract Builder toBuilder(); - - public abstract static class Builder, V extends BaseVirtualSystem, E extends BaseEnvelope> { - - protected Set diskSections = Sets.newLinkedHashSet(); - protected Set networkSections = Sets.newLinkedHashSet(); - protected Set additionalSections = Sets.newLinkedHashSet(); - protected V virtualSystem; - - @SuppressWarnings("unchecked") - protected B self() { - return (B) this; - } - - /** - * @see BaseEnvelope#getDiskSections - */ - public B diskSection(DiskSection diskSection) { - this.diskSections.add(checkNotNull(diskSection, "diskSection")); - return self(); - } - - /** - * @see BaseEnvelope#getDiskSections - */ - public B diskSections(Iterable diskSections) { - this.diskSections = ImmutableSet. copyOf(checkNotNull(diskSections, "diskSections")); - return self(); - } - - /** - * @see BaseEnvelope#getNetworkSections - */ - public B networkSection(NetworkSection networkSection) { - this.networkSections.add(checkNotNull(networkSection, "networkSection")); - return self(); - } - - /** - * @see BaseEnvelope#getNetworkSections - */ - public B networkSections(Iterable networkSections) { - this.networkSections = ImmutableSet. copyOf(checkNotNull(networkSections, "networkSections")); - return self(); - } - - /** - * @see BaseEnvelope#getAdditionalSections - */ - public B additionalSection(SectionType additionalSection) { - this.additionalSections.add(checkNotNull(additionalSection, "additionalSection")); - return self(); - } - - /** - * @see BaseEnvelope#getAdditionalSections - */ - public B additionalSections(Iterable additionalSections) { - this.additionalSections = ImmutableSet. copyOf(checkNotNull(additionalSections, "additionalSections")); - return self(); - } - - /** - * @see BaseEnvelope#getVirtualSystem - */ - public B virtualSystem(V virtualSystem) { - this.virtualSystem = virtualSystem; - return self(); - } - - public abstract E build(); - - public B fromEnvelope(BaseEnvelope in) { - return virtualSystem(in.getVirtualSystem()) - .diskSections(in.getDiskSections()) - .networkSections(networkSections) - .additionalSections(in.getAdditionalSections()); - } - - } - - private Set diskSections; - private Set networkSections; - private Set additionalSections; - private V virtualSystem; - - protected BaseEnvelope(Builder builder) { - this.diskSections = ImmutableSet.copyOf(checkNotNull(builder.diskSections, "diskSections")); - this.networkSections = ImmutableSet.copyOf(checkNotNull(builder.networkSections, "networkSections")); - this.additionalSections = ImmutableSet.copyOf(checkNotNull(builder.additionalSections, "additionalSections")); - this.virtualSystem = checkNotNull(builder.virtualSystem, "virtualSystem"); - } - - protected BaseEnvelope() { - // for JAXB - } - - public V getVirtualSystem() { - return virtualSystem; - } - - public Set getDiskSections() { - return diskSections; - } - - public Set getNetworkSections() { - return networkSections; - } - - public Set getAdditionalSections() { - return additionalSections; - } - - @Override - public int hashCode() { - return Objects.hashCode(additionalSections, diskSections, networkSections, virtualSystem); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null) return false; - if (getClass() != obj.getClass()) return false; - - BaseEnvelope other = (BaseEnvelope) obj; - return Objects.equal(additionalSections, other.additionalSections) - && Objects.equal(diskSections, other.diskSections) - && Objects.equal(networkSections, other.networkSections) - && Objects.equal(virtualSystem, other.virtualSystem); - } - - @Override - public String toString() { - return string().toString(); - } - - protected Objects.ToStringHelper string() { - return Objects.toStringHelper("") - .add("diskSections", diskSections) - .add("networkSections", networkSections) - .add("additionalSections", additionalSections) - .add("virtualSystem", virtualSystem); - } -} diff --git a/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/internal/BaseVirtualSystem.java b/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/internal/BaseVirtualSystem.java deleted file mode 100644 index 954fbe705c..0000000000 --- a/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/internal/BaseVirtualSystem.java +++ /dev/null @@ -1,175 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.dmtf.ovf.internal; - -import static com.google.common.base.Objects.equal; -import static com.google.common.base.Preconditions.checkNotNull; -import static org.jclouds.dmtf.DMTFConstants.OVF_NS; - -import java.util.Set; - -import javax.xml.bind.annotation.XmlAttribute; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlElementRef; - -import org.jclouds.dmtf.ovf.ProductSection; -import org.jclouds.dmtf.ovf.SectionType; - -import com.google.common.base.Objects; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Sets; - -/** - * @author Adrian Cole - */ -public abstract class BaseVirtualSystem extends SectionType { - - public abstract static class Builder> extends SectionType.Builder { - - private String id; - private String name; - private Set productSections = Sets.newLinkedHashSet(); - private Set additionalSections = Sets.newLinkedHashSet(); - - /** - * @see BaseVirtualSystem#getName() - */ - public B name(String name) { - this.name = name; - return self(); - } - - /** - * @see BaseVirtualSystem#getId() - */ - public B id(String id) { - this.id = id; - return self(); - } - - /** - * @see BaseVirtualSystem#getProductSections() - */ - public B productSection(ProductSection productSection) { - this.productSections.add(checkNotNull(productSection, "productSection")); - return self(); - } - - /** - * @see BaseVirtualSystem#getProductSections() - */ - public B productSections(Iterable productSections) { - this.productSections = Sets.newLinkedHashSet(checkNotNull(productSections, "productSections")); - return self(); - } - - /** - * @see BaseVirtualSystem#getAdditionalSections() - */ - public B additionalSection(SectionType additionalSection) { - this.additionalSections.add(checkNotNull(additionalSection, "additionalSection")); - return self(); - } - - /** - * @see BaseVirtualSystem#getAdditionalSections() - */ - public B additionalSections(Iterable additionalSections) { - this.additionalSections = Sets.newLinkedHashSet(checkNotNull(additionalSections, "additionalSections")); - return self(); - } - - public B fromBaseVirtualSystem(BaseVirtualSystem in) { - return fromSectionType(in) - .id(in.getId()) - .name(in.getName()) - .productSections(in.getProductSections()) - .additionalSections(in.getAdditionalSections()); - } - } - - @XmlAttribute(namespace = OVF_NS) - private String id; - @XmlElement(name = "Name") - private String name; - @XmlElement(name = "ProductSection") - private Set productSections; - @XmlElementRef - private Set additionalSections; - - protected BaseVirtualSystem(Builder builder) { - super(builder); - this.id = builder.id; - this.name = builder.name; - this.productSections = ImmutableSet.copyOf(checkNotNull(builder.productSections, "productSections")); - this.additionalSections = ImmutableSet.copyOf(checkNotNull(builder.additionalSections, "additionalSections")); - } - - protected BaseVirtualSystem() { - // For JAXB - } - - public String getId() { - return id; - } - - public String getName() { - return name; - } - - /** - * Specifies product-information for a package, such as product name and version, along with a - * set of properties that can be configured - */ - public Set getProductSections() { - return productSections; - } - - public Set getAdditionalSections() { - return additionalSections; - } - - @Override - public int hashCode() { - return Objects.hashCode(super.hashCode(), id, name, productSections, additionalSections); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null) return false; - if (getClass() != obj.getClass()) return false; - - BaseVirtualSystem other = (BaseVirtualSystem) obj; - return super.equals(other) - && equal(id, other.id) - && equal(name, other.name) - && equal(productSections, other.productSections) - && equal(additionalSections, other.additionalSections); - } - - @Override - protected Objects.ToStringHelper string() { - return super.string() - .add("id", id) - .add("name", name) - .add("productSections", productSections) - .add("additionalSections", additionalSections); - } -} diff --git a/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/internal/package-info.java b/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/internal/package-info.java deleted file mode 100644 index b9f8c9df30..0000000000 --- a/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/internal/package-info.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -@XmlSchema(namespace = OVF_NS, - elementFormDefault = XmlNsForm.QUALIFIED, - xmlns = { - @XmlNs(prefix = "cim", namespaceURI = CIM_NS), - @XmlNs(prefix = "ovf", namespaceURI = OVF_NS) - } -) -@XmlAccessorType(XmlAccessType.FIELD) -package org.jclouds.dmtf.ovf.internal; - -import static org.jclouds.dmtf.DMTFConstants.CIM_NS; -import static org.jclouds.dmtf.DMTFConstants.OVF_NS; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlNs; -import javax.xml.bind.annotation.XmlNsForm; -import javax.xml.bind.annotation.XmlSchema; - diff --git a/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/package-info.java b/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/package-info.java deleted file mode 100644 index 48a2043de0..0000000000 --- a/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/package-info.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -@XmlSchema(namespace = OVF_NS, - elementFormDefault = XmlNsForm.QUALIFIED, - xmlns = { - @XmlNs(prefix = "cim", namespaceURI = CIM_NS), - @XmlNs(prefix = "ovf", namespaceURI = OVF_NS) - } -) -@XmlAccessorType(XmlAccessType.FIELD) -package org.jclouds.dmtf.ovf; - -import static org.jclouds.dmtf.DMTFConstants.CIM_NS; -import static org.jclouds.dmtf.DMTFConstants.OVF_NS; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlNs; -import javax.xml.bind.annotation.XmlNsForm; -import javax.xml.bind.annotation.XmlSchema; - diff --git a/labs/elb/README.txt b/labs/elb/README.txt deleted file mode 100644 index 981e590acc..0000000000 --- a/labs/elb/README.txt +++ /dev/null @@ -1,25 +0,0 @@ -==== - Licensed to jclouds, Inc. (jclouds) under one or more - contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. jclouds licenses this file - to you under the Apache License, Version 2.0 (the - "License"); you may not use this file except in compliance - with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, - software distributed under the License is distributed on an - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - KIND, either express or implied. See the License for the - specific language governing permissions and limitations - under the License. -==== - -# -# The jclouds API for Amazon's Elastic Load Balancing service (http://aws.amazon.com/elasticloadbalancing/). -# -# TODO: Implementation status. -# TODO: Supported features. -# TODO: Usage example. \ No newline at end of file diff --git a/labs/elb/pom.xml b/labs/elb/pom.xml deleted file mode 100644 index 222c5f5fd3..0000000000 --- a/labs/elb/pom.xml +++ /dev/null @@ -1,155 +0,0 @@ - - - - 4.0.0 - - org.jclouds.labs - jclouds-labs-project - 1.7.0-SNAPSHOT - ../project/pom.xml - - elb - jcloud elb api - jclouds components to access an implementation of Elastic Load Balancer - bundle - - - https://elasticloadbalancing.us-east-1.amazonaws.com - 2012-06-01 - - ${test.aws.identity} - ${test.aws.credential} - aws-ec2 - - - - ${test.aws.identity} - ${test.aws.credential} - - - org.jclouds.elb*;version="${project.version}" - - org.jclouds.labs*;version="${project.version}", - org.jclouds*;version="${jclouds.version}", - * - - - - - - org.jclouds.api - sts - ${jclouds.version} - - - org.jclouds - jclouds-loadbalancer - ${jclouds.version} - jar - - - org.jclouds - jclouds-core - ${jclouds.version} - test-jar - test - - - org.jclouds - jclouds-compute - ${jclouds.version} - test-jar - test - - - org.jclouds.provider - aws-ec2 - ${jclouds.version} - test - - - org.jclouds.driver - jclouds-sshj - ${jclouds.version} - test - - - org.jclouds - jclouds-loadbalancer - ${jclouds.version} - test-jar - test - - - org.jclouds.driver - jclouds-slf4j - ${jclouds.version} - test - - - ch.qos.logback - logback-classic - test - - - - - - live - - - - org.apache.maven.plugins - maven-surefire-plugin - - - integration - integration-test - - test - - - - ${test.elb.endpoint} - ${test.elb.api-version} - ${test.elb.build-version} - ${test.elb.identity} - ${test.elb.credential} - ${test.elb.compute.provider} - ${test.elb.compute.endpoint} - ${test.elb.compute.api-version} - ${test.elb.compute.build-version} - ${test.elb.compute.identity} - ${test.elb.compute.credential} - ${test.elb.compute.template} - - - - - - - - - - - - diff --git a/labs/elb/src/main/java/org/jclouds/elb/ELBApi.java b/labs/elb/src/main/java/org/jclouds/elb/ELBApi.java deleted file mode 100644 index 28307ff5a0..0000000000 --- a/labs/elb/src/main/java/org/jclouds/elb/ELBApi.java +++ /dev/null @@ -1,92 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.elb; - -import java.util.Set; -import org.jclouds.elb.features.AvailabilityZoneApi; -import org.jclouds.elb.features.InstanceApi; -import org.jclouds.elb.features.LoadBalancerApi; -import org.jclouds.elb.features.PolicyApi; -import org.jclouds.javax.annotation.Nullable; -import org.jclouds.location.Region; -import org.jclouds.location.functions.RegionToEndpointOrProviderIfNull; -import org.jclouds.rest.annotations.Delegate; -import org.jclouds.rest.annotations.EndpointParam; - -import com.google.common.annotations.Beta; -import com.google.inject.Provides; - -/** - * Provides access to EC2 Elastic Load Balancer via their REST API. - *

- * - * @author Adrian Cole - * @see ELBAsyncApi - */ -@Beta -public interface ELBApi { - /** - * - * @return the Region codes configured - */ - @Provides - @Region - Set getConfiguredRegions(); - - /** - * Provides synchronous access to LoadBalancer features. - */ - @Delegate - LoadBalancerApi getLoadBalancerApi(); - - @Delegate - LoadBalancerApi getLoadBalancerApiForRegion( - @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region); - - /** - * Provides synchronous access to Policy features. - */ - @Delegate - PolicyApi getPolicyApi(); - - @Delegate - PolicyApi getPolicyApiForRegion( - @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region); - - /** - * Provides synchronous access to Instance features. - */ - @Delegate - InstanceApi getInstanceApi(); - - @Delegate - InstanceApi getInstanceApiForRegion( - @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region); - - /** - * Provides synchronous access to Zone features. - */ - @Delegate - AvailabilityZoneApi getAvailabilityZoneApi(); - - @Delegate - AvailabilityZoneApi getAvailabilityZoneApiForRegion( - @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region); - -} diff --git a/labs/elb/src/main/java/org/jclouds/elb/ELBApiMetadata.java b/labs/elb/src/main/java/org/jclouds/elb/ELBApiMetadata.java deleted file mode 100644 index 30c9f49623..0000000000 --- a/labs/elb/src/main/java/org/jclouds/elb/ELBApiMetadata.java +++ /dev/null @@ -1,95 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.elb; - -import static org.jclouds.aws.reference.AWSConstants.PROPERTY_AUTH_TAG; -import static org.jclouds.aws.reference.AWSConstants.PROPERTY_HEADER_TAG; - -import java.net.URI; -import java.util.Properties; - -import org.jclouds.apis.ApiMetadata; -import org.jclouds.elb.config.ELBRestClientModule; -import org.jclouds.elb.loadbalancer.config.ELBLoadBalancerContextModule; -import org.jclouds.loadbalancer.LoadBalancerServiceContext; -import org.jclouds.rest.RestContext; -import org.jclouds.rest.internal.BaseRestApiMetadata; - -import com.google.common.collect.ImmutableSet; -import com.google.common.reflect.TypeToken; -import com.google.inject.Module; - -/** - * Implementation of {@link ApiMetadata} for Amazon's Elastic Load Balancing api. - * - * @author Adrian Cole - */ -public class ELBApiMetadata extends BaseRestApiMetadata { - - public static final TypeToken> CONTEXT_TOKEN = new TypeToken>() { - private static final long serialVersionUID = 1L; - }; - - @Override - public Builder toBuilder() { - return new Builder(getApi(), getAsyncApi()).fromApiMetadata(this); - } - - public ELBApiMetadata() { - this(new Builder(ELBApi.class, ELBAsyncApi.class)); - } - - protected ELBApiMetadata(Builder builder) { - super(builder); - } - - public static Properties defaultProperties() { - Properties properties = BaseRestApiMetadata.defaultProperties(); - properties.setProperty(PROPERTY_AUTH_TAG, "AWS"); - properties.setProperty(PROPERTY_HEADER_TAG, "amz"); - return properties; - } - - public static class Builder extends BaseRestApiMetadata.Builder { - - protected Builder(Class api, Class asyncApi) { - super(api, asyncApi); - id("elb") - .name("Amazon Elastic Load Balancing Api") - .identityName("Access Key ID") - .credentialName("Secret Access Key") - .version("2012-06-01") - .defaultProperties(ELBApiMetadata.defaultProperties()) - .defaultEndpoint("https://elasticloadbalancing.us-east-1.amazonaws.com") - .documentation(URI.create("http://docs.amazonwebservices.com/ElasticLoadBalancing/latest/APIReference")) - .view(LoadBalancerServiceContext.class) - .defaultModules(ImmutableSet.>of(ELBRestClientModule.class, ELBLoadBalancerContextModule.class)); - } - - @Override - public ELBApiMetadata build() { - return new ELBApiMetadata(this); - } - - @Override - protected Builder self() { - return this; - } - } -} diff --git a/labs/elb/src/main/java/org/jclouds/elb/ELBAsyncApi.java b/labs/elb/src/main/java/org/jclouds/elb/ELBAsyncApi.java deleted file mode 100644 index 009e3a875c..0000000000 --- a/labs/elb/src/main/java/org/jclouds/elb/ELBAsyncApi.java +++ /dev/null @@ -1,99 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.elb; - -import java.util.Set; - -import org.jclouds.aws.filters.FormSigner; -import org.jclouds.elb.features.AvailabilityZoneAsyncApi; -import org.jclouds.elb.features.InstanceAsyncApi; -import org.jclouds.elb.features.LoadBalancerAsyncApi; -import org.jclouds.elb.features.PolicyAsyncApi; -import org.jclouds.javax.annotation.Nullable; -import org.jclouds.location.Region; -import org.jclouds.location.functions.RegionToEndpointOrProviderIfNull; -import org.jclouds.rest.annotations.Delegate; -import org.jclouds.rest.annotations.EndpointParam; -import org.jclouds.rest.annotations.RequestFilters; -import org.jclouds.rest.annotations.VirtualHost; - -import com.google.common.annotations.Beta; -import com.google.inject.Provides; - -/** - * Provides access to EC2 Elastic Load Balancer via REST API. - *

- * - * @see ELB - * documentation - * @author Adrian Cole - */ -@Beta -@RequestFilters(FormSigner.class) -@VirtualHost -public interface ELBAsyncApi { - /** - * - * @return the Region codes configured - */ - @Provides - @Region - Set getConfiguredRegions(); - - /** - * Provides asynchronous access to LoadBalancer features. - */ - @Delegate - LoadBalancerAsyncApi getLoadBalancerApi(); - - @Delegate - LoadBalancerAsyncApi getLoadBalancerApiForRegion( - @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region); - - /** - * Provides asynchronous access to Policy features. - */ - @Delegate - PolicyAsyncApi getPolicyApi(); - - @Delegate - PolicyAsyncApi getPolicyApiForRegion( - @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region); - - /** - * Provides asynchronous access to Instance features. - */ - @Delegate - InstanceAsyncApi getInstanceApi(); - - @Delegate - InstanceAsyncApi getInstanceApiForRegion( - @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region); - - /** - * Provides asynchronous access to AvailabilityZone features. - */ - @Delegate - AvailabilityZoneAsyncApi getAvailabilityZoneApi(); - - @Delegate - AvailabilityZoneAsyncApi getAvailabilityZoneApiForRegion( - @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region); - -} diff --git a/labs/elb/src/main/java/org/jclouds/elb/binders/BindAvailabilityZonesToIndexedFormParams.java b/labs/elb/src/main/java/org/jclouds/elb/binders/BindAvailabilityZonesToIndexedFormParams.java deleted file mode 100644 index 28c93bdac2..0000000000 --- a/labs/elb/src/main/java/org/jclouds/elb/binders/BindAvailabilityZonesToIndexedFormParams.java +++ /dev/null @@ -1,40 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.elb.binders; - -import static org.jclouds.aws.util.AWSUtils.indexIterableToFormValuesWithPrefix; - -import javax.inject.Singleton; - -import org.jclouds.http.HttpRequest; -import org.jclouds.rest.Binder; - -/** - * Binds the Iterable to form parameters named with AvailabilityZones.member.N - * - * @author Adrian Cole - */ -@Singleton -public class BindAvailabilityZonesToIndexedFormParams implements Binder { - @Override - public R bindToRequest(R request, Object input) { - return indexIterableToFormValuesWithPrefix(request, "AvailabilityZones.member", input); - } - -} diff --git a/labs/elb/src/main/java/org/jclouds/elb/binders/BindInstanceIdsToIndexedFormParams.java b/labs/elb/src/main/java/org/jclouds/elb/binders/BindInstanceIdsToIndexedFormParams.java deleted file mode 100644 index 0c7cfe566a..0000000000 --- a/labs/elb/src/main/java/org/jclouds/elb/binders/BindInstanceIdsToIndexedFormParams.java +++ /dev/null @@ -1,52 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.elb.binders; - -import static com.google.common.base.Preconditions.checkNotNull; - -import javax.inject.Singleton; - -import org.jclouds.http.HttpRequest; -import org.jclouds.rest.Binder; - -import com.google.common.collect.ImmutableMultimap; -import com.google.common.collect.ImmutableMultimap.Builder; - -/** - * Binds the Iterable to form parameters named with Instances.member.index.InstanceId - * - * @author Adrian Cole - */ -@Singleton -public class BindInstanceIdsToIndexedFormParams implements Binder { - - @SuppressWarnings("unchecked") - @Override - public R bindToRequest(R request, Object input) { - Iterable values = Iterable.class.cast(checkNotNull(input, "instanceIds")); - Builder builder = ImmutableMultimap.builder(); - int i = 0; - for (Object o : values) { - builder.put("Instances.member." + (i++ + 1) + ".InstanceId", o.toString()); - } - ImmutableMultimap forms = builder.build(); - return (R) (forms.size() == 0 ? request : request.toBuilder().replaceFormParams(forms).build()); - } - -} diff --git a/labs/elb/src/main/java/org/jclouds/elb/binders/BindListenersToFormParams.java b/labs/elb/src/main/java/org/jclouds/elb/binders/BindListenersToFormParams.java deleted file mode 100644 index 4998136997..0000000000 --- a/labs/elb/src/main/java/org/jclouds/elb/binders/BindListenersToFormParams.java +++ /dev/null @@ -1,68 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.elb.binders; - -import static com.google.common.base.Preconditions.checkNotNull; - -import org.jclouds.elb.domain.Listener; -import org.jclouds.http.HttpRequest; - -import com.google.common.collect.ImmutableMultimap; -import com.google.common.collect.ImmutableSet; - -/** - * Binds the listeners request to the http request - * - * @see doc - * - * @author Adrian Cole - */ -public class BindListenersToFormParams implements org.jclouds.rest.Binder { - - /** - * {@inheritDoc} - */ - @SuppressWarnings("unchecked") - @Override - public R bindToRequest(R request, Object input) { - Iterable listeners = checkNotNull(input, "listeners must be set!") instanceof Listener ? ImmutableSet - .of(Listener.class.cast(input)) : (Iterable) input; - - ImmutableMultimap.Builder formParameters = ImmutableMultimap.builder(); - int listenerIndex = 1; - - for (Listener listener : listeners) { - formParameters.put("Listeners.member." + listenerIndex + ".LoadBalancerPort", listener.getPort() + ""); - formParameters.put("Listeners.member." + listenerIndex + ".InstancePort", listener.getInstancePort() + ""); - formParameters.put("Listeners.member." + listenerIndex + ".Protocol", listener.getProtocol() + ""); - formParameters.put("Listeners.member." + listenerIndex + ".InstanceProtocol", listener.getInstanceProtocol() - + ""); - if (listener.getSSLCertificateId().isPresent()) - formParameters.put("Listeners.member." + listenerIndex + ".SSLCertificateId", listener - .getSSLCertificateId().get() + ""); - listenerIndex++; - } - - return (R) request.toBuilder().replaceFormParams(formParameters.build()).build(); - - } - -} diff --git a/labs/elb/src/main/java/org/jclouds/elb/binders/BindPolicyTypeNamesToIndexedFormParams.java b/labs/elb/src/main/java/org/jclouds/elb/binders/BindPolicyTypeNamesToIndexedFormParams.java deleted file mode 100644 index f6e828f7c5..0000000000 --- a/labs/elb/src/main/java/org/jclouds/elb/binders/BindPolicyTypeNamesToIndexedFormParams.java +++ /dev/null @@ -1,40 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.elb.binders; - -import static org.jclouds.aws.util.AWSUtils.indexIterableToFormValuesWithPrefix; - -import javax.inject.Singleton; - -import org.jclouds.http.HttpRequest; -import org.jclouds.rest.Binder; - -/** - * Binds the Iterable to form parameters named with PolicyTypeNames.member.N - * - * @author Adrian Cole - */ -@Singleton -public class BindPolicyTypeNamesToIndexedFormParams implements Binder { - @Override - public R bindToRequest(R request, Object input) { - return indexIterableToFormValuesWithPrefix(request, "PolicyTypeNames.member", input); - } - -} diff --git a/labs/elb/src/main/java/org/jclouds/elb/binders/BindSecurityGroupsToIndexedFormParams.java b/labs/elb/src/main/java/org/jclouds/elb/binders/BindSecurityGroupsToIndexedFormParams.java deleted file mode 100644 index 0dd9e341e1..0000000000 --- a/labs/elb/src/main/java/org/jclouds/elb/binders/BindSecurityGroupsToIndexedFormParams.java +++ /dev/null @@ -1,40 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.elb.binders; - -import static org.jclouds.aws.util.AWSUtils.indexIterableToFormValuesWithPrefix; - -import javax.inject.Singleton; - -import org.jclouds.http.HttpRequest; -import org.jclouds.rest.Binder; - -/** - * Binds the Iterable to form parameters named with SecurityGroups.member.N - * - * @author Adrian Cole - */ -@Singleton -public class BindSecurityGroupsToIndexedFormParams implements Binder { - @Override - public R bindToRequest(R request, Object input) { - return indexIterableToFormValuesWithPrefix(request, "SecurityGroups.member", input); - } - -} diff --git a/labs/elb/src/main/java/org/jclouds/elb/binders/BindSubnetsToIndexedFormParams.java b/labs/elb/src/main/java/org/jclouds/elb/binders/BindSubnetsToIndexedFormParams.java deleted file mode 100644 index 658a6069f0..0000000000 --- a/labs/elb/src/main/java/org/jclouds/elb/binders/BindSubnetsToIndexedFormParams.java +++ /dev/null @@ -1,40 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.elb.binders; - -import static org.jclouds.aws.util.AWSUtils.indexIterableToFormValuesWithPrefix; - -import javax.inject.Singleton; - -import org.jclouds.http.HttpRequest; -import org.jclouds.rest.Binder; - -/** - * Binds the Iterable to form parameters named with Subnets.member.N - * - * @author Adrian Cole - */ -@Singleton -public class BindSubnetsToIndexedFormParams implements Binder { - @Override - public R bindToRequest(R request, Object input) { - return indexIterableToFormValuesWithPrefix(request, "Subnets.member", input); - } - -} diff --git a/labs/elb/src/main/java/org/jclouds/elb/config/ELBRestClientModule.java b/labs/elb/src/main/java/org/jclouds/elb/config/ELBRestClientModule.java deleted file mode 100644 index caccbe1c92..0000000000 --- a/labs/elb/src/main/java/org/jclouds/elb/config/ELBRestClientModule.java +++ /dev/null @@ -1,57 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.elb.config; - -import static org.jclouds.reflect.Reflection2.typeToken; - -import java.util.Map; - -import org.jclouds.aws.config.FormSigningRestClientModule; -import org.jclouds.elb.ELBApi; -import org.jclouds.elb.ELBAsyncApi; -import org.jclouds.elb.features.AvailabilityZoneApi; -import org.jclouds.elb.features.AvailabilityZoneAsyncApi; -import org.jclouds.elb.features.InstanceApi; -import org.jclouds.elb.features.InstanceAsyncApi; -import org.jclouds.elb.features.LoadBalancerApi; -import org.jclouds.elb.features.LoadBalancerAsyncApi; -import org.jclouds.elb.features.PolicyApi; -import org.jclouds.elb.features.PolicyAsyncApi; -import org.jclouds.rest.ConfiguresRestClient; - -import com.google.common.collect.ImmutableMap; - -/** - * Configures the ELB connection. - * - * @author Adrian Cole - */ -@ConfiguresRestClient -public class ELBRestClientModule extends FormSigningRestClientModule { - public static final Map, Class> DELEGATE_MAP = ImmutableMap., Class> builder()// - .put(LoadBalancerApi.class, LoadBalancerAsyncApi.class) - .put(PolicyApi.class, PolicyAsyncApi.class) - .put(InstanceApi.class, InstanceAsyncApi.class) - .put(AvailabilityZoneApi.class, AvailabilityZoneAsyncApi.class) - .build(); - - public ELBRestClientModule() { - super(typeToken(ELBApi.class), typeToken(ELBAsyncApi.class), DELEGATE_MAP); - } -} diff --git a/labs/elb/src/main/java/org/jclouds/elb/domain/AttributeMetadata.java b/labs/elb/src/main/java/org/jclouds/elb/domain/AttributeMetadata.java deleted file mode 100644 index 648dc87f07..0000000000 --- a/labs/elb/src/main/java/org/jclouds/elb/domain/AttributeMetadata.java +++ /dev/null @@ -1,235 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.elb.domain; - -import static com.google.common.base.Preconditions.checkNotNull; - -import com.google.common.base.Objects; -import com.google.common.base.Objects.ToStringHelper; -import com.google.common.base.Optional; - -/** - * This data type is used to describe values that are acceptable for the policy attribute. - * - * @see doc - * - * @author Adrian Cole - */ -public class AttributeMetadata { - /** - * The cardinality of the attribute. - */ - public static enum Cardinality { - /** - * ONE(1) : Single value required - */ - ONE, - /** - * ZERO_OR_ONE(0..1) : Up to one value can be supplied - */ - ZERO_OR_ONE, - /** - * ZERO_OR_MORE(0..*) : Optional. Multiple values are allowed - */ - ZERO_OR_MORE, - /** - * ONE_OR_MORE(1..*0) : Required. Multiple values are allowed * - */ - ONE_OR_MORE; - - } - - public static Builder builder() { - return new Builder(); - } - - public Builder toBuilder() { - return new Builder().fromAttributeMetadata(this); - } - - public static class Builder { - - protected String name; - protected Class type; - protected String rawType; - protected Cardinality cardinality; - protected Optional defaultValue = Optional.absent(); - protected Optional description = Optional.absent(); - - /** - * @see AttributeMetadata#getName() - */ - public Builder name(String name) { - this.name = name; - return this; - } - - /** - * @see AttributeMetadata#getType() - */ - public Builder type(Class type) { - this.type = type; - return this; - } - - /** - * @see AttributeMetadata#getRawType() - */ - public Builder rawType(String rawType) { - this.rawType = rawType; - return this; - } - - /** - * @see AttributeMetadata#getCardinality() - */ - public Builder cardinality(Cardinality cardinality) { - this.cardinality = cardinality; - return this; - } - - /** - * @see AttributeMetadata#getDefaultValue() - */ - public Builder defaultValue(V defaultValue) { - this.defaultValue = Optional.fromNullable(defaultValue); - return this; - } - - /** - * @see AttributeMetadata#getDescription() - */ - public Builder description(String description) { - this.description = Optional.fromNullable(description); - return this; - } - - public AttributeMetadata build() { - return new AttributeMetadata(name, type, rawType, cardinality, defaultValue, description); - } - - public Builder fromAttributeMetadata(AttributeMetadata in) { - return this.name(in.getName()).type(in.getType()).rawType(in.getRawType()).cardinality(in.getCardinality()) - .defaultValue(in.getDefaultValue().orNull()).description(in.getDescription().orNull()); - } - } - - protected final String name; - protected final Class type; - protected final String rawType; - protected final Cardinality cardinality; - protected final Optional defaultValue; - protected final Optional description; - - protected AttributeMetadata(String name, Class type, String rawType, Cardinality cardinality, - Optional defaultValue, Optional description) { - this.name = checkNotNull(name, "name"); - this.type = checkNotNull(type, "type"); - this.rawType = checkNotNull(rawType, "rawType"); - this.cardinality = checkNotNull(cardinality, "cardinality"); - this.defaultValue = checkNotNull(defaultValue, "defaultValue"); - this.description = checkNotNull(description, "description"); - } - - /** - * The name of the attribute associated with the policy type. - */ - public String getName() { - return name; - } - - /** - * The type of attribute. For example, Boolean, Long, String, etc. - */ - public Class getType() { - return type; - } - - /** - * Literal type of the value, noting that if it doesn't correspond to a primitive or String, - * {@link #getType() will return String.class} - */ - public String getRawType() { - return rawType; - } - - /** - * The cardinality of the attribute. - */ - public Cardinality getCardinality() { - return cardinality; - } - - /** - * The default value of the attribute, if applicable. - */ - public Optional getDefaultValue() { - return defaultValue; - } - - /** - * A human-readable description of the attribute. - */ - public Optional getDescription() { - return description; - } - - /** - * {@inheritDoc} - */ - @Override - public int hashCode() { - return Objects.hashCode(name, type, rawType, cardinality, defaultValue, description); - } - - /** - * {@inheritDoc} - */ - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - AttributeMetadata other = AttributeMetadata.class.cast(obj); - return Objects.equal(this.name, other.name) && Objects.equal(this.type, other.type) - && Objects.equal(this.rawType, other.rawType) && Objects.equal(this.cardinality, other.cardinality) - && Objects.equal(this.defaultValue, other.defaultValue) - && Objects.equal(this.description, other.description); - } - - /** - * {@inheritDoc} - */ - @Override - public String toString() { - return string().toString(); - } - - protected ToStringHelper string() { - return Objects.toStringHelper(this).omitNullValues().add("name", name).add("type", type).add("rawType", rawType) - .add("cardinality", cardinality).add("defaultValue", defaultValue.orNull()) - .add("description", description.orNull()); - } - -} diff --git a/labs/elb/src/main/java/org/jclouds/elb/domain/HealthCheck.java b/labs/elb/src/main/java/org/jclouds/elb/domain/HealthCheck.java deleted file mode 100644 index b7c3af6769..0000000000 --- a/labs/elb/src/main/java/org/jclouds/elb/domain/HealthCheck.java +++ /dev/null @@ -1,230 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.elb.domain; - -import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.base.Preconditions.checkNotNull; - -import com.google.common.base.Objects; -import com.google.common.base.Objects.ToStringHelper; - -/** - * Elastic Load Balancing routinely checks the health of each load-balanced Amazon EC2 instance - * based on the configurations that you specify. If Elastic Load Balancing finds an unhealthy - * instance, it stops sending traffic to the instance and reroutes traffic to healthy instances. - * - * - * @see doc - * - * @author Adrian Cole - */ -public class HealthCheck { - - public static Builder builder() { - return new ConcreteBuilder(); - } - - public Builder toBuilder() { - return new ConcreteBuilder().fromListener(this); - } - - public abstract static class Builder> { - protected abstract T self(); - - protected int healthyThreshold = -1; - protected int interval = -1; - protected String target; - protected int timeout = -1; - protected int unhealthyThreshold = -1; - - /** - * @see HealthCheck#getHealthyThreshold() - */ - public T healthyThreshold(int healthyThreshold) { - this.healthyThreshold = healthyThreshold; - return self(); - } - - /** - * @see HealthCheck#getInterval() - */ - public T interval(int interval) { - this.interval = interval; - return self(); - } - - /** - * @see HealthCheck#getTarget() - */ - public T target(String target) { - this.target = target; - return self(); - } - - /** - * @see HealthCheck#getTimeout() - */ - public T timeout(int timeout) { - this.timeout = timeout; - return self(); - } - - /** - * @see HealthCheck#getUnhealthyThreshold() - */ - public T unhealthyThreshold(int unhealthyThreshold) { - this.unhealthyThreshold = unhealthyThreshold; - return self(); - } - - public HealthCheck build() { - return new HealthCheck(healthyThreshold, interval, target, timeout, unhealthyThreshold); - } - - public T fromListener(HealthCheck in) { - return this.healthyThreshold(in.getHealthyThreshold()).interval(in.getInterval()).target(in.getTarget()) - .timeout(in.getTimeout()).unhealthyThreshold(in.getUnhealthyThreshold()); - } - } - - private static class ConcreteBuilder extends Builder { - @Override - protected ConcreteBuilder self() { - return this; - } - } - - protected final int healthyThreshold; - protected final int interval; - protected final String target; - protected final int timeout; - protected final int unhealthyThreshold; - - protected HealthCheck(int healthyThreshold, int interval, String target, int timeout, int unhealthyThreshold) { - this.healthyThreshold = checkNonNegative(healthyThreshold, "healthyThreshold"); - this.interval = checkNonNegative(interval, "interval"); - this.target = checkNotNull(target, "target"); - this.timeout = checkNonNegative(timeout, "timeout"); - this.unhealthyThreshold = checkNonNegative(unhealthyThreshold, "unhealthyThreshold"); - } - - static int checkNonNegative(int in, String name) { - checkArgument(in > 0, "%s must be non-negative", name); - return in; - } - - /** - * Specifies the number of consecutive health probe successes required before moving the instance - * to the Healthy state. - */ - public int getHealthyThreshold() { - return healthyThreshold; - } - - /** - * Specifies the approximate interval, in seconds, between health checks of an individual - * instance. - */ - public int getInterval() { - return interval; - } - - /** - * Specifies the instance being checked. The timeout is either TCP, HTTP, HTTPS, or SSL. The - * range of valid ports is one (1) through 65535. - * - *

Note

- * - * TCP is the default, specified as a TCP: port pair, for example "TCP:5000". In this case a - * healthcheck simply attempts to open a TCP connection to the instance on the specified port. - * Failure to connect within the configured timeout is considered unhealthy.
- * SSL is also specified as SSL: port pair, for example, SSL:5000.
- * - * For HTTP or HTTPS timeout, the situation is different. You have to include a ping path in the - * string. HTTP is specified as a HTTP:port;/;PathToPing; grouping, for example - * "HTTP:80/weather/us/wa/seattle". In this case, a HTTP GET request is issued to the instance on - * the given port and path. Any answer other than "200 OK" within the timeout period is - * considered unhealthy. - * - * The total length of the HTTP ping target needs to be 1024 16-bit Unicode characters or less. - */ - public String getTarget() { - return target; - } - - /** - * Specifies the amount of time, in seconds, during which no response means a failed health - * probe. - * - *

Note

This value must be less than the Interval value. - */ - public int getTimeout() { - return timeout; - } - - /** - * Specifies the number of consecutive health probe failures required before moving the instance - * to the Unhealthy state. - */ - public int getUnhealthyThreshold() { - return unhealthyThreshold; - } - - /** - * {@inheritDoc} - */ - @Override - public int hashCode() { - return Objects.hashCode(healthyThreshold, interval, target, timeout, unhealthyThreshold); - } - - /** - * {@inheritDoc} - */ - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - HealthCheck other = (HealthCheck) obj; - return Objects.equal(this.healthyThreshold, other.healthyThreshold) - && Objects.equal(this.interval, other.interval) && Objects.equal(this.target, other.target) - && Objects.equal(this.timeout, other.timeout) - && Objects.equal(this.unhealthyThreshold, other.unhealthyThreshold); - } - - /** - * {@inheritDoc} - */ - @Override - public String toString() { - return string().toString(); - } - - protected ToStringHelper string() { - return Objects.toStringHelper(this).omitNullValues().add("healthyThreshold", healthyThreshold).add("interval", - interval).add("target", target).add("timeout", timeout).add("unhealthyThreshold", unhealthyThreshold); - } - -} diff --git a/labs/elb/src/main/java/org/jclouds/elb/domain/InstanceHealth.java b/labs/elb/src/main/java/org/jclouds/elb/domain/InstanceHealth.java deleted file mode 100644 index 36101d39ef..0000000000 --- a/labs/elb/src/main/java/org/jclouds/elb/domain/InstanceHealth.java +++ /dev/null @@ -1,168 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.elb.domain; - -import static com.google.common.base.Preconditions.checkNotNull; - -import com.google.common.base.Objects; -import com.google.common.base.Optional; - -/** - * the current state of an instance in a loadbalancer. - * - * @see doc - * - * @author Adrian Cole - */ -public class InstanceHealth { - - public static Builder builder() { - return new Builder(); - } - - public Builder toBuilder() { - return new Builder().fromAttributeMetadata(this); - } - - public static class Builder { - - protected String description; - protected String instanceId; - protected Optional reasonCode = Optional.absent(); - protected String state; - - /** - * @see InstanceHealth#getDescription() - */ - public Builder description(String description) { - this.description = description; - return this; - } - - /** - * @see InstanceHealth#getInstanceId() - */ - public Builder instanceId(String instanceId) { - this.instanceId = instanceId; - return this; - } - - /** - * @see InstanceHealth#getReasonCode() - */ - public Builder reasonCode(String reasonCode) { - this.reasonCode = Optional.fromNullable(reasonCode); - return this; - } - - /** - * @see InstanceHealth#getState() - */ - public Builder state(String state) { - this.state = state; - return this; - } - - public InstanceHealth build() { - return new InstanceHealth(description, instanceId, reasonCode, state); - } - - public Builder fromAttributeMetadata(InstanceHealth in) { - return this.description(in.getDescription()).instanceId(in.getInstanceId()) - .reasonCode(in.getReasonCode().orNull()).state(in.getState()); - } - } - - protected final String description; - protected final String instanceId; - protected final Optional reasonCode; - protected final String state; - - protected InstanceHealth(String description, String instanceId, Optional reasonCode, String state) { - this.description = checkNotNull(description, "description"); - this.instanceId = checkNotNull(instanceId, "instanceId"); - this.reasonCode = checkNotNull(reasonCode, "reasonCode"); - this.state = checkNotNull(state, "state"); - } - - /** - * Provides a description of the instance. - */ - public String getDescription() { - return description; - } - - /** - * Provides an EC2 instance ID. - */ - public String getInstanceId() { - return instanceId; - } - - /** - * Provides information about the cause of OutOfService instances. Specifically, it indicates - * whether the cause is Elastic Load Balancing or the instance behind the LoadBalancer. - */ - public Optional getReasonCode() { - return reasonCode; - } - - /** - * Specifies the current status of the instance. - */ - public String getState() { - return state; - } - - /** - * {@inheritDoc} - */ - @Override - public int hashCode() { - return Objects.hashCode(description, instanceId, reasonCode, state); - } - - /** - * {@inheritDoc} - */ - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - InstanceHealth other = InstanceHealth.class.cast(obj); - return Objects.equal(this.description, other.description) && Objects.equal(this.instanceId, other.instanceId) - && Objects.equal(this.reasonCode, other.reasonCode) && Objects.equal(this.state, other.state); - } - - /** - * {@inheritDoc} - */ - @Override - public String toString() { - return Objects.toStringHelper(this).omitNullValues().add("description", description) - .add("instanceId", instanceId).add("reasonCode", reasonCode.orNull()).add("state", state).toString(); - } - -} diff --git a/labs/elb/src/main/java/org/jclouds/elb/domain/Listener.java b/labs/elb/src/main/java/org/jclouds/elb/domain/Listener.java deleted file mode 100644 index acf5c1e964..0000000000 --- a/labs/elb/src/main/java/org/jclouds/elb/domain/Listener.java +++ /dev/null @@ -1,228 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.elb.domain; - -import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.base.Preconditions.checkNotNull; - -import com.google.common.base.Objects; -import com.google.common.base.Optional; -import com.google.common.base.Objects.ToStringHelper; - -/** - * Listener is a process that listens for api connection requests. It is configured with a - * protocol and a port number for front-end (Load Balancer) and back-end (Back-end instance) - * connections. - * - * - * By default, your load balancer is set to use the HTTP protocol with port 80 for the front-end - * connection and the back-end connection. The default settings can be changed using the AWS - * Management Console, the Query API, the command line interface (CLI), or the SDKs. - * - * @see doc - * - * @author Adrian Cole - */ -public class Listener { - - public static Builder builder() { - return new ConcreteBuilder(); - } - - public Builder toBuilder() { - return new ConcreteBuilder().fromListener(this); - } - - public abstract static class Builder> { - protected abstract T self(); - - protected int instancePort = -1; - protected Protocol instanceProtocol; - protected int port = -1; - protected Protocol protocol; - protected Optional SSLCertificateId = Optional.absent(); - - /** - * @see Listener#getInstancePort() - */ - public T instancePort(int instancePort) { - this.instancePort = instancePort; - if (port == -1) - port = instancePort; - return self(); - } - - /** - * @see Listener#getInstanceProtocol() - */ - public T instanceProtocol(Protocol instanceProtocol) { - this.instanceProtocol = instanceProtocol; - if (protocol == null) - protocol = instanceProtocol; - return self(); - } - - /** - * @see Listener#getPort() - */ - public T port(int port) { - this.port = port; - if (instancePort == -1) - instancePort = port; - return self(); - } - - /** - * @see Listener#getProtocol() - */ - public T protocol(Protocol protocol) { - this.protocol = protocol; - if (instanceProtocol == null) - instanceProtocol = protocol; - return self(); - } - - /** - * @see Listener#getSSLCertificateId() - */ - public T SSLCertificateId(String SSLCertificateId) { - this.SSLCertificateId = Optional.fromNullable(SSLCertificateId); - return self(); - } - - public Listener build() { - return new Listener(instancePort, instanceProtocol, port, protocol, SSLCertificateId); - } - - public T fromListener(Listener in) { - return this.instancePort(in.getInstancePort()).instanceProtocol(in.getInstanceProtocol()).port(in.getPort()) - .protocol(in.getProtocol()).SSLCertificateId(in.getSSLCertificateId().orNull()); - } - } - - private static class ConcreteBuilder extends Builder { - @Override - protected ConcreteBuilder self() { - return this; - } - } - - protected final int instancePort; - protected final Protocol instanceProtocol; - protected final int port; - protected final Protocol protocol; - protected final Optional SSLCertificateId; - - protected Listener(int instancePort, Protocol instanceProtocol, int port, Protocol protocol, - Optional SSLCertificateId) { - this.instancePort = checkNonNegative(instancePort, "instancePort"); - this.instanceProtocol = checkNotNull(instanceProtocol, "instanceProtocol"); - this.port = checkNonNegative(port, "port"); - this.protocol = checkNotNull(protocol, "protocol"); - this.SSLCertificateId = checkNotNull(SSLCertificateId, "SSLCertificateId"); - } - - static int checkNonNegative(int in, String name) { - checkArgument(in > 0, "%s must be non-negative", name); - return in; - } - - /** - * The name associated with the LoadBalancer. The name must be unique within your set of - * LoadBalancers. - */ - public int getInstancePort() { - return instancePort; - } - - /** - * Specifies the protocol to use for routing traffic to back-end instances - HTTP, HTTPS, TCP, or - * SSL. This property cannot be modified for the life of the LoadBalancer. - */ - public Protocol getInstanceProtocol() { - return instanceProtocol; - } - - /** - * Specifies the external LoadBalancer port number. This property cannot be modified for the life - * of the LoadBalancer. - */ - public int getPort() { - return port; - } - - /** - * Specifies the LoadBalancer transport protocol to use for routing - HTTP, HTTPS, TCP or SSL. - * This property cannot be modified for the life of the LoadBalancer. - */ - public Protocol getProtocol() { - return protocol; - } - - /** - * The ARN string of the server certificate. To get the ARN of the server certificate, call the - * AWS Identity and Access Management UploadServerCertificate API. - */ - public Optional getSSLCertificateId() { - return SSLCertificateId; - } - - /** - * {@inheritDoc} - */ - @Override - public int hashCode() { - return Objects.hashCode(instancePort, instanceProtocol, port, protocol, SSLCertificateId); - } - - /** - * {@inheritDoc} - */ - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - Listener other = (Listener) obj; - return Objects.equal(this.instancePort, other.instancePort) - && Objects.equal(this.instanceProtocol, other.instanceProtocol) && Objects.equal(this.port, other.port) - && Objects.equal(this.protocol, other.protocol) - && Objects.equal(this.SSLCertificateId, other.SSLCertificateId); - } - - /** - * {@inheritDoc} - */ - @Override - public String toString() { - return string().toString(); - } - - protected ToStringHelper string() { - return Objects.toStringHelper(this).omitNullValues().add("instancePort", instancePort).add("instanceProtocol", - instanceProtocol).add("port", port).add("protocol", protocol).add("SSLCertificateId", - SSLCertificateId.orNull()); - } - -} diff --git a/labs/elb/src/main/java/org/jclouds/elb/domain/ListenerWithPolicies.java b/labs/elb/src/main/java/org/jclouds/elb/domain/ListenerWithPolicies.java deleted file mode 100644 index c98c16ce27..0000000000 --- a/labs/elb/src/main/java/org/jclouds/elb/domain/ListenerWithPolicies.java +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.elb.domain; - -import static com.google.common.base.Objects.equal; -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.Set; - -import com.google.common.base.Objects; -import com.google.common.base.Optional; -import com.google.common.base.Objects.ToStringHelper; -import com.google.common.collect.ImmutableSet; - -/** - * - * @author Adrian Cole - */ -public class ListenerWithPolicies extends Listener { - - public static Builder builder() { - return new ConcreteBuilder(); - } - - @Override - public Builder toBuilder() { - return builder().fromListenerWithPolicies(this); - } - - public abstract static class Builder> extends Listener.Builder { - - private ImmutableSet.Builder policyNames = ImmutableSet. builder(); - - /** - * @see ListenerWithPolicies#getPolicyNames() - */ - public T policyNames(Iterable policyNames) { - this.policyNames.addAll(checkNotNull(policyNames, "policyNames")); - return self(); - } - - /** - * @see ListenerWithPolicies#getPolicyNames() - */ - public T policyName(String policyName) { - this.policyNames.add(checkNotNull(policyName, "policyName")); - return self(); - } - - @Override - public ListenerWithPolicies build() { - return new ListenerWithPolicies(instancePort, instanceProtocol, port, protocol, SSLCertificateId, policyNames - .build()); - } - - public T fromListenerWithPolicies(ListenerWithPolicies in) { - return fromListener(in).policyNames(in.getPolicyNames()); - } - } - - private static class ConcreteBuilder extends Builder { - @Override - protected ConcreteBuilder self() { - return this; - } - } - - private final Set policyNames; - - protected ListenerWithPolicies(int instancePort, Protocol instanceProtocol, int port, Protocol protocol, - Optional SSLCertificateId, Iterable policyNames) { - super(instancePort, instanceProtocol, port, protocol, SSLCertificateId); - this.policyNames = ImmutableSet.copyOf(checkNotNull(policyNames, "policyNames")); - } - - /** - * A list of policies enabled for this listener. An empty list indicates that no policies are - * enabled. - */ - public Set getPolicyNames() { - return policyNames; - } - - @Override - public boolean equals(Object o) { - if (this == o) - return true; - if (o == null || getClass() != o.getClass()) - return false; - ListenerWithPolicies that = ListenerWithPolicies.class.cast(o); - return super.equals(that) && equal(this.policyNames, that.policyNames); - } - - @Override - public int hashCode() { - return Objects.hashCode(super.hashCode(), policyNames); - } - - @Override - public ToStringHelper string() { - return super.string().add("policyNames", policyNames); - } -} diff --git a/labs/elb/src/main/java/org/jclouds/elb/domain/LoadBalancer.java b/labs/elb/src/main/java/org/jclouds/elb/domain/LoadBalancer.java deleted file mode 100644 index 0b0ccfdf8d..0000000000 --- a/labs/elb/src/main/java/org/jclouds/elb/domain/LoadBalancer.java +++ /dev/null @@ -1,434 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.elb.domain; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.Date; -import java.util.Set; - -import com.google.common.base.Objects; -import com.google.common.base.Optional; -import com.google.common.collect.ImmutableSet; - -/** - * A load balancer is represented by a DNS name and a set of ports. The load - * balancer is the destination to which all requests intended for your - * application should be directed. Each load balancer can distribute requests to - * multiple EC2 instances. Load Balancers can span multiple Availability Zones - * within an EC2 region, but they cannot span multiple regions. - * - *

note

- * - * Elastic Load Balancing automatically generates a DNS name for each load - * balancer. You can map any other domain name (such as www.example.com) to the - * automatically generated DNS name using CNAME. Or you can use an Amazon Route - * 53 alias for the load balancer's DNS name. Amazon Route 53 provides secure - * and reliable routing to the infrastructure that uses AWS products, such as - * Amazon EC2, Amazon Simple Storage Service (Amazon S3), or Elastic Load - * Balancing. For more information on using Amazon Route 53 for your load - * balancer, see Using Domain Names with Elastic Load Balancing. For information - * about CNAME records, see the CNAME Record Wikipedia article. - * - * @see doc - * - * @author Adrian Cole - */ -public class LoadBalancer { - public static Builder builder() { - return new ConcreteBuilder(); - } - - public Builder toBuilder() { - return new ConcreteBuilder().fromLoadBalancer(this); - } - - public abstract static class Builder> { - protected abstract T self(); - - protected String name; - protected Date createdTime; - protected String dnsName; - protected HealthCheck healthCheck; - protected ImmutableSet.Builder instanceIds = ImmutableSet. builder(); - protected ImmutableSet.Builder listeners = ImmutableSet. builder(); - protected ImmutableSet.Builder availabilityZones = ImmutableSet. builder(); - protected Optional scheme = Optional.absent(); - protected Optional sourceSecurityGroup = Optional.absent(); - protected Optional VPCId = Optional.absent(); - protected ImmutableSet.Builder securityGroups = ImmutableSet. builder(); - protected ImmutableSet.Builder subnets = ImmutableSet. builder(); - protected Optional hostedZoneName = Optional.absent(); - protected Optional hostedZoneId = Optional.absent(); - - /** - * @see LoadBalancer#getName() - */ - public T name(String name) { - this.name = name; - return self(); - } - - /** - * @see LoadBalancer#getCreatedTime() - */ - public T createdTime(Date createdTime) { - this.createdTime = createdTime; - return self(); - } - - /** - * @see LoadBalancer#getDnsName() - */ - public T dnsName(String dnsName) { - this.dnsName = dnsName; - return self(); - } - - /** - * @see LoadBalancer#getHealthCheck() - */ - public T healthCheck(HealthCheck healthCheck) { - this.healthCheck = healthCheck; - return self(); - } - - /** - * @see LoadBalancer#getInstanceIds() - */ - public T instanceIds(Iterable instanceIds) { - this.instanceIds.addAll(checkNotNull(instanceIds, "instanceIds")); - return self(); - } - - /** - * @see LoadBalancer#getInstanceIds() - */ - public T instanceId(String instanceId) { - this.instanceIds.add(checkNotNull(instanceId, "instanceId")); - return self(); - } - - /** - * @see LoadBalancer#getListeners() - */ - public T listeners(Iterable listeners) { - this.listeners.addAll(checkNotNull(listeners, "listeners")); - return self(); - } - - /** - * @see LoadBalancer#getListeners() - */ - public T listener(ListenerWithPolicies listener) { - this.listeners.add(checkNotNull(listener, "listener")); - return self(); - } - - /** - * @see LoadBalancer#getAvailabilityZones() - */ - public T availabilityZones(Iterable availabilityZones) { - this.availabilityZones.addAll(checkNotNull(availabilityZones, "availabilityZones")); - return self(); - } - - /** - * @see LoadBalancer#getAvailabilityZones() - */ - public T availabilityZone(String availabilityZone) { - this.availabilityZones.add(checkNotNull(availabilityZone, "availabilityZone")); - return self(); - } - - /** - * @see LoadBalancer#getScheme() - */ - public T scheme(Scheme scheme) { - this.scheme = Optional.fromNullable(scheme); - return self(); - } - - /** - * @see LoadBalancer#getSourceSecurityGroup() - */ - public T sourceSecurityGroup(SecurityGroupAndOwner scheme) { - this.sourceSecurityGroup = Optional.fromNullable(scheme); - return self(); - } - - /** - * @see LoadBalancer#getVPCId() - */ - public T VPCId(String VPCId) { - this.VPCId = Optional.fromNullable(VPCId); - return self(); - } - - /** - * @see LoadBalancer#getSecurityGroups() - */ - public T securityGroups(Iterable securityGroups) { - this.securityGroups.addAll(checkNotNull(securityGroups, "securityGroups")); - return self(); - } - - /** - * @see LoadBalancer#getSecurityGroups() - */ - public T securityGroup(String securityGroup) { - this.securityGroups.add(checkNotNull(securityGroup, "securityGroup")); - return self(); - } - - /** - * @see LoadBalancer#getSubnets() - */ - public T subnets(Iterable subnets) { - this.subnets.addAll(checkNotNull(subnets, "subnets")); - return self(); - } - - /** - * @see LoadBalancer#getSubnets() - */ - public T subnet(String subnet) { - this.subnets.add(checkNotNull(subnet, "subnet")); - return self(); - } - - /** - * @see LoadBalancer#getHostedZoneName() - */ - public T hostedZoneName(String hostedZoneName) { - this.hostedZoneName = Optional.fromNullable(hostedZoneName); - return self(); - } - - /** - * @see LoadBalancer#getHostedZoneId() - */ - public T hostedZoneId(String hostedZoneId) { - this.hostedZoneId = Optional.fromNullable(hostedZoneId); - return self(); - } - - public LoadBalancer build() { - return new LoadBalancer(name, createdTime, dnsName, healthCheck, instanceIds.build(), listeners.build(), - availabilityZones.build(), scheme, sourceSecurityGroup, VPCId, securityGroups.build(), - subnets.build(), hostedZoneName, hostedZoneId); - } - - public T fromLoadBalancer(LoadBalancer in) { - return this.name(in.getName()).createdTime(in.getCreatedTime()).dnsName(in.getDnsName()) - .healthCheck(in.getHealthCheck()).listeners(in.getListeners()).instanceIds(in.getInstanceIds()) - .availabilityZones(in.getAvailabilityZones()).scheme(in.getScheme().orNull()) - .sourceSecurityGroup(in.getSourceSecurityGroup().orNull()).VPCId(in.getVPCId().orNull()) - .securityGroups(in.getSecurityGroups()).subnets(in.getSubnets()) - .hostedZoneName(in.getHostedZoneName().orNull()).hostedZoneId(in.getHostedZoneId().orNull()); - } - } - - private static class ConcreteBuilder extends Builder { - @Override - protected ConcreteBuilder self() { - return this; - } - } - - protected final String name; - protected final Date createdTime; - protected final String dnsName; - protected final HealthCheck healthCheck; - protected final Set instanceIds; - protected final Set listeners; - protected final Set availabilityZones; - protected final Optional scheme; - protected final Optional sourceSecurityGroup; - protected final Optional VPCId; - protected final Set securityGroups; - protected final Set subnets; - protected final Optional hostedZoneName; - protected final Optional hostedZoneId; - - protected LoadBalancer(String name, Date createdTime, String dnsName, HealthCheck healthCheck, - Iterable instanceIds, Iterable listeners, Iterable availabilityZones, - Optional scheme, Optional sourceSecurityGroup, Optional VPCId, - Iterable securityGroups, Iterable subnets, Optional hostedZoneName, - Optional hostedZoneId) { - this.name = checkNotNull(name, "name"); - this.createdTime = checkNotNull(createdTime, "createdTime"); - this.dnsName = checkNotNull(dnsName, "dnsName"); - this.healthCheck = checkNotNull(healthCheck, "healthCheck"); - this.instanceIds = ImmutableSet.copyOf(checkNotNull(instanceIds, "instanceIds")); - this.listeners = ImmutableSet.copyOf(checkNotNull(listeners, "listeners")); - this.availabilityZones = ImmutableSet.copyOf(checkNotNull(availabilityZones, "availabilityZones")); - this.scheme = checkNotNull(scheme, "scheme"); - this.sourceSecurityGroup = checkNotNull(sourceSecurityGroup, "sourceSecurityGroup"); - this.VPCId = checkNotNull(VPCId, "VPCId"); - this.securityGroups = ImmutableSet.copyOf(checkNotNull(securityGroups, "securityGroups")); - this.subnets = ImmutableSet.copyOf(checkNotNull(subnets, "subnets")); - this.hostedZoneName = checkNotNull(hostedZoneName, "hostedZoneName"); - this.hostedZoneId = checkNotNull(hostedZoneId, "hostedZoneId"); - } - - /** - * The name associated with the LoadBalancer. The name must be unique within - * your set of LoadBalancers. - */ - public String getName() { - return name; - } - - /** - * Provides the date and time the LoadBalancer was created. - */ - public Date getCreatedTime() { - return createdTime; - } - - /** - * Specifies the external DNS name associated with the LoadBalancer. - */ - public String getDnsName() { - return dnsName; - } - - /** - * Specifies information regarding the various health probes conducted on - * the LoadBalancer. - */ - public HealthCheck getHealthCheck() { - return healthCheck; - } - - /** - * Provides a list of EC2 instance IDs for the LoadBalancer. - */ - public Set getInstanceIds() { - return instanceIds; - } - - /** - * Provides a list of listeners for the LoadBalancer. - */ - public Set getListeners() { - return listeners; - } - - /** - * Specifies a list of Availability Zones. - */ - public Set getAvailabilityZones() { - return availabilityZones; - } - - /** - * Type of the loadbalancer; This option is only available for LoadBalancers - * attached to an Amazon VPC. - */ - public Optional getScheme() { - return scheme; - } - - /** - * The security group that you can use as part of your inbound rules for - * your LoadBalancer's back-end Amazon EC2 application instances. To only - * allow traffic from LoadBalancers, add a security group rule to your back - * end instance that specifies this source security group as the inbound - * source. - */ - public Optional getSourceSecurityGroup() { - return sourceSecurityGroup; - } - - /** - * Provides the ID of the VPC attached to the LoadBalancer. - */ - public Optional getVPCId() { - return VPCId; - } - - /** - * The security groups the LoadBalancer is a member of (VPC only). - */ - public Set getSecurityGroups() { - return securityGroups; - } - - /** - * Provides a list of VPC subnet IDs for the LoadBalancer. - */ - public Set getSubnets() { - return subnets; - } - - /** - * Provides the name of the Amazon Route 53 hosted zone that is associated with the LoadBalancer - */ - public Optional getHostedZoneName() { - return hostedZoneName; - } - - /** - * Provides the ID of the Amazon Route 53 hosted zone name that is associated with the LoadBalancer. - */ - public Optional getHostedZoneId() { - return hostedZoneId; - } - - /** - * {@inheritDoc} - */ - @Override - public int hashCode() { - return Objects.hashCode(name, createdTime); - } - - /** - * {@inheritDoc} - */ - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - LoadBalancer other = (LoadBalancer) obj; - return Objects.equal(this.name, other.name) && Objects.equal(this.createdTime, other.createdTime); - } - - /** - * {@inheritDoc} - */ - @Override - public String toString() { - return Objects.toStringHelper(this).omitNullValues().add("name", name).add("createdTime", createdTime) - .add("dnsName", dnsName).add("healthCheck", healthCheck).add("instanceIds", instanceIds) - .add("listeners", listeners).add("availabilityZones", availabilityZones).add("scheme", scheme.orNull()) - .add("sourceSecurityGroup", sourceSecurityGroup.orNull()).add("VPCId", VPCId.orNull()) - .add("securityGroups", securityGroups).add("subnets", subnets) - .add("hostedZoneName", hostedZoneName.orNull()).add("hostedZoneId", hostedZoneId.orNull()).toString(); - } - -} diff --git a/labs/elb/src/main/java/org/jclouds/elb/domain/Policy.java b/labs/elb/src/main/java/org/jclouds/elb/domain/Policy.java deleted file mode 100644 index ad7b3aec96..0000000000 --- a/labs/elb/src/main/java/org/jclouds/elb/domain/Policy.java +++ /dev/null @@ -1,156 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.elb.domain; - -import static com.google.common.base.Preconditions.checkNotNull; - -import com.google.common.base.Objects; -import com.google.common.collect.ImmutableMultimap; -import com.google.common.collect.Multimap; - -/** - * - * @see doc - * - * @author Adrian Cole - */ -public class Policy { - - public static Builder builder() { - return new Builder(); - } - - public Builder toBuilder() { - return builder().fromPolicy(this); - } - - public static class Builder { - - protected String name; - protected String typeName; - protected ImmutableMultimap.Builder attributes = ImmutableMultimap. builder(); - - /** - * @see Policy#getName() - */ - public Builder name(String name) { - this.name = name; - return this; - } - - /** - * @see Policy#getTypeName() - */ - public Builder typeName(String typeName) { - this.typeName = typeName; - return this; - } - - /** - * @see Policy#getAttributes() - */ - public Builder attributes(Multimap attributes) { - this.attributes.putAll(checkNotNull(attributes, "attributes")); - return this; - } - - /** - * @see Policy#getAttributes() - */ - public Builder attribute(String key, Object value) { - this.attributes.put(checkNotNull(key, "key"), checkNotNull(value, "value")); - return this; - } - - public Policy build() { - return new Policy(name, typeName, attributes.build()); - } - - public Builder fromPolicy(Policy in) { - return this.name(in.getName()).typeName(in.getTypeName()).attributes(in.getAttributes()); - } - } - - protected final String name; - protected final String typeName; - protected final Multimap attributes; - - protected Policy(String name, String typeName, Multimap attributes) { - this.name = checkNotNull(name, "name"); - this.typeName = checkNotNull(typeName, "typeName"); - this.attributes = ImmutableMultimap.copyOf(checkNotNull(attributes, "attributes")); - } - - /** - * The name of the policy associated with the LoadBalancer - */ - public String getName() { - return name; - } - - /** - * The name of the policy type associated with the LoadBalancer. - */ - public String getTypeName() { - return typeName; - } - - /** - * A list of policy attribute description structures. Note that values are either Long, Boolean, - * or String, depending on {@link AttributeMetadata#getType()} - */ - public Multimap getAttributes() { - return attributes; - } - - /** - * {@inheritDoc} - */ - @Override - public int hashCode() { - return Objects.hashCode(name, typeName); - } - - /** - * {@inheritDoc} - */ - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - Policy other = (Policy) obj; - return Objects.equal(this.name, other.name) && Objects.equal(this.typeName, other.typeName); - } - - /** - * {@inheritDoc} - */ - @Override - public String toString() { - return Objects.toStringHelper(this).omitNullValues().add("name", name).add("typeName", typeName) - .add("attributes", attributes).toString(); - } - -} diff --git a/labs/elb/src/main/java/org/jclouds/elb/domain/PolicyType.java b/labs/elb/src/main/java/org/jclouds/elb/domain/PolicyType.java deleted file mode 100644 index 49c21d07e9..0000000000 --- a/labs/elb/src/main/java/org/jclouds/elb/domain/PolicyType.java +++ /dev/null @@ -1,175 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.elb.domain; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.Map; -import java.util.Set; - -import com.google.common.base.Function; -import com.google.common.base.Objects; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Maps; - -/** - * - * @see doc - * - * @author Adrian Cole - */ -public class PolicyType { - - public static Builder builder() { - return new Builder(); - } - - public Builder toBuilder() { - return builder().fromPolicyType(this); - } - - public static class Builder { - - protected String name; - protected String description; - protected ImmutableSet.Builder> attributeMetadata = ImmutableSet.> builder(); - - /** - * @see PolicyType#getName() - */ - public Builder name(String name) { - this.name = name; - return this; - } - - /** - * @see PolicyType#getDescription() - */ - public Builder description(String description) { - this.description = description; - return this; - } - - /** - * @see PolicyType#getAttributeMetadata() - */ - public Builder attributeMetadata(Iterable> attributeMetadata) { - this.attributeMetadata.addAll(checkNotNull(attributeMetadata, "attributeMetadata")); - return this; - } - - /** - * @see PolicyType#getAttributeMetadata() - */ - public Builder attributeMetadata(AttributeMetadata attributeMetadata) { - this.attributeMetadata.add(checkNotNull(attributeMetadata, "attributeMetadata")); - return this; - } - - public PolicyType build() { - return new PolicyType(name, description, attributeMetadata.build()); - } - - public Builder fromPolicyType(PolicyType in) { - return this.name(in.getName()).description(in.getDescription()).attributeMetadata(in.getAttributeMetadata()); - } - } - - protected final String name; - protected final String description; - protected final Set> attributeMetadata; - - protected PolicyType(String name, String description, Iterable> attributeMetadata) { - this.name = checkNotNull(name, "name"); - this.description = checkNotNull(description, "description"); - this.attributeMetadata = ImmutableSet.copyOf(checkNotNull(attributeMetadata, "attributeMetadata")); - } - - /** - * The name of the policy type. - */ - public String getName() { - return name; - } - - /** - * A human-readable description of the policy type. - */ - public String getDescription() { - return description; - } - - /** - * The description of the policy attributes associated with the LoadBalancer policies defined by - * the Elastic Load Balancing service. - */ - public Set> getAttributeMetadata() { - return attributeMetadata; - } - - /** - * convenience method - * @see #getAttributeMetadata() - */ - public Map> getAttributeMetadataByName() { - return Maps.uniqueIndex(attributeMetadata, new Function, String>(){ - - @Override - public String apply(AttributeMetadata input) { - return input.getName(); - } - - }); - } - - /** - * {@inheritDoc} - */ - @Override - public int hashCode() { - return Objects.hashCode(name); - } - - /** - * {@inheritDoc} - */ - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - PolicyType other = (PolicyType) obj; - return Objects.equal(this.name, other.name); - } - - /** - * {@inheritDoc} - */ - @Override - public String toString() { - return Objects.toStringHelper(this).omitNullValues().add("name", name).add("description", description) - .add("attributeMetadata", attributeMetadata).toString(); - } - -} diff --git a/labs/elb/src/main/java/org/jclouds/elb/domain/Protocol.java b/labs/elb/src/main/java/org/jclouds/elb/domain/Protocol.java deleted file mode 100644 index 508386c6c1..0000000000 --- a/labs/elb/src/main/java/org/jclouds/elb/domain/Protocol.java +++ /dev/null @@ -1,48 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.elb.domain; - -/** - * Specifies transport protocol to use for routing or the protocol to use for routing traffic to - * back-end instances. - * - *

Note

If the front-end protocol is HTTP or HTTPS, InstanceProtocol has to be at the same - * protocol layer, i.e., HTTP or HTTPS. Likewise, if the front-end protocol is TCP or SSL, - * InstanceProtocol has to be TCP or SSL. - * - *

Note

If there is another listener with the same InstancePort whose InstanceProtocol is - * secure, i.e., HTTPS or SSL, the listener's InstanceProtocol has to be secure, i.e., HTTPS or SSL. - * If there is another listener with the same InstancePort whose InstanceProtocol is HTTP or TCP, - * the listener's InstanceProtocol must be either HTTP or TCP. - * - * @author Adrian Cole - * @see - * docs - */ -public enum Protocol { - - HTTP, HTTPS, TCP, SSL, - /** - * The protocol was returned unrecognized. - */ - UNRECOGNIZED; - -} diff --git a/labs/elb/src/main/java/org/jclouds/elb/domain/Scheme.java b/labs/elb/src/main/java/org/jclouds/elb/domain/Scheme.java deleted file mode 100644 index 2477280abe..0000000000 --- a/labs/elb/src/main/java/org/jclouds/elb/domain/Scheme.java +++ /dev/null @@ -1,62 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.elb.domain; - -import static com.google.common.base.Preconditions.checkNotNull; - -import com.google.common.base.CaseFormat; - -/** - * Specifies the type of LoadBalancer. This option is only available for - * LoadBalancers attached to an Amazon VPC. - */ -public enum Scheme { - - /** - * the LoadBalancer has a publicly resolvable DNS name that resolves to - * public IP addresses - */ - INTERNET_FACING, - /** - * the LoadBalancer has a publicly resolvable DNS name that resolves to - * private IP addresses. - */ - INTERNAL, - /** - * The scheme was returned unrecognized. - */ - UNRECOGNIZED; - - public String value() { - return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_HYPHEN, name()); - } - - @Override - public String toString() { - return value(); - } - - public static Scheme fromValue(String scheme) { - try { - return valueOf(CaseFormat.LOWER_HYPHEN.to(CaseFormat.UPPER_UNDERSCORE, checkNotNull(scheme, "scheme"))); - } catch (IllegalArgumentException e) { - return UNRECOGNIZED; - } - } -} diff --git a/labs/elb/src/main/java/org/jclouds/elb/domain/SecurityGroupAndOwner.java b/labs/elb/src/main/java/org/jclouds/elb/domain/SecurityGroupAndOwner.java deleted file mode 100644 index 36948d7244..0000000000 --- a/labs/elb/src/main/java/org/jclouds/elb/domain/SecurityGroupAndOwner.java +++ /dev/null @@ -1,130 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.elb.domain; - -import static com.google.common.base.Preconditions.checkNotNull; - -import com.google.common.base.Objects; - -/** - * The security group that you can use as part of your inbound rules for your - * LoadBalancer's back-end Amazon EC2 application instances. To only allow - * traffic from LoadBalancers, add a security group rule to your back end - * instance that specifies this source security group as the inbound source. - * - * @see doc - * - * @author Adrian Cole - */ -public class SecurityGroupAndOwner { - - public static Builder builder() { - return new Builder(); - } - - public Builder toBuilder() { - return builder().fromSourceSecurityGroup(this); - } - - public static class Builder { - - protected String name; - protected String owner; - - /** - * @see SecurityGroupAndOwner#getName() - */ - public Builder name(String name) { - this.name = name; - return this; - } - - /** - * @see SecurityGroupAndOwner#getOwner() - */ - public Builder owner(String owner) { - this.owner = owner; - return this; - } - - public SecurityGroupAndOwner build() { - return new SecurityGroupAndOwner(name, owner); - } - - public Builder fromSourceSecurityGroup(SecurityGroupAndOwner in) { - return this.name(in.getName()).owner(in.getOwner()); - } - } - - protected final String name; - protected final String owner; - - protected SecurityGroupAndOwner(String name, String owner) { - this.name = checkNotNull(name, "name"); - this.owner = checkNotNull(owner, "owner"); - } - - /** - * Name of the source security group. - */ - public String getName() { - return name; - } - - /** - * Owner of the source security group. - */ - public String getOwner() { - return owner; - } - - /** - * {@inheritDoc} - */ - @Override - public int hashCode() { - return Objects.hashCode(name, owner); - } - - /** - * {@inheritDoc} - */ - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - SecurityGroupAndOwner other = (SecurityGroupAndOwner) obj; - return Objects.equal(this.name, other.name) && Objects.equal(this.owner, other.owner); - } - - /** - * {@inheritDoc} - */ - @Override - public String toString() { - return Objects.toStringHelper(this).omitNullValues().add("name", name).add("owner", owner).toString(); - } - -} diff --git a/labs/elb/src/main/java/org/jclouds/elb/domain/regionscoped/LoadBalancerInRegion.java b/labs/elb/src/main/java/org/jclouds/elb/domain/regionscoped/LoadBalancerInRegion.java deleted file mode 100644 index 8351009e85..0000000000 --- a/labs/elb/src/main/java/org/jclouds/elb/domain/regionscoped/LoadBalancerInRegion.java +++ /dev/null @@ -1,30 +0,0 @@ -package org.jclouds.elb.domain.regionscoped; - -import static com.google.common.base.Preconditions.checkNotNull; - -import org.jclouds.elb.domain.LoadBalancer; - -/** - * @author Adrian Cole - */ -public class LoadBalancerInRegion extends RegionAndName { - protected final LoadBalancer loadBalancer; - - public LoadBalancerInRegion(LoadBalancer loadBalancer, String regionId) { - super(regionId, checkNotNull(loadBalancer, "loadBalancer").getName()); - this.loadBalancer = loadBalancer; - } - - public LoadBalancer getLoadBalancer() { - return loadBalancer; - } - - // superclass hashCode/equals are good enough, and help us use RegionAndId and LoadBalancerInRegion - // interchangeably as Map keys - - @Override - public String toString() { - return "[loadBalancer=" + loadBalancer + ", regionId=" + regionId + "]"; - } - -} diff --git a/labs/elb/src/main/java/org/jclouds/elb/domain/regionscoped/RegionAndName.java b/labs/elb/src/main/java/org/jclouds/elb/domain/regionscoped/RegionAndName.java deleted file mode 100644 index eb78fc67d3..0000000000 --- a/labs/elb/src/main/java/org/jclouds/elb/domain/regionscoped/RegionAndName.java +++ /dev/null @@ -1,88 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.elb.domain.regionscoped; - -import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.base.Preconditions.checkNotNull; - -import com.google.common.base.Objects; -import com.google.common.base.Splitter; -import com.google.common.collect.Iterables; - -/** - * @author Adrian Cole - */ -public class RegionAndName { - public static RegionAndName fromSlashEncoded(String name) { - Iterable parts = Splitter.on('/').split(checkNotNull(name, "name")); - checkArgument(Iterables.size(parts) == 2, "name must be in format regionId/name"); - return new RegionAndName(Iterables.get(parts, 0), Iterables.get(parts, 1)); - } - - public static RegionAndName fromRegionAndName(String regionId, String name) { - return new RegionAndName(regionId, name); - } - - private static String slashEncodeRegionAndName(String regionId, String name) { - return checkNotNull(regionId, "regionId") + "/" + checkNotNull(name, "name"); - } - - public String slashEncode() { - return slashEncodeRegionAndName(regionId, name); - } - - protected final String regionId; - protected final String name; - - protected RegionAndName(String regionId, String name) { - this.regionId = checkNotNull(regionId, "regionId"); - this.name = checkNotNull(name, "name"); - } - - @Override - public int hashCode() { - return Objects.hashCode(regionId, name); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - RegionAndName other = (RegionAndName) obj; - return Objects.equal(regionId, other.regionId) && Objects.equal(name, other.name); - } - - public String getRegion() { - return regionId; - } - - public String getName() { - return name; - } - - @Override - public String toString() { - return "[regionId=" + regionId + ", name=" + name + "]"; - } - -} diff --git a/labs/elb/src/main/java/org/jclouds/elb/features/AvailabilityZoneApi.java b/labs/elb/src/main/java/org/jclouds/elb/features/AvailabilityZoneApi.java deleted file mode 100644 index f59eea4e23..0000000000 --- a/labs/elb/src/main/java/org/jclouds/elb/features/AvailabilityZoneApi.java +++ /dev/null @@ -1,97 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.elb.features; - -import java.util.Set; -/** - * Provides access to Amazon ELB via the Query API - *

- * - * @see - * @see AvailabilityZoneAsyncApi - * @author Adrian Cole - */ -public interface AvailabilityZoneApi { - - /** - * Adds one or more EC2 Availability Zones to the LoadBalancer. - * - * The LoadBalancer evenly distributes requests across all its registered Availability Zones that - * contain instances. As a result, the api must ensure that its LoadBalancer is appropriately - * scaled for each registered Availability Zone. - * - *

Note

- * - * The new EC2 Availability Zones to be added must be in the same EC2 Region as the Availability - * Zones for which the LoadBalancer was created. - * - * @param zones - * A list of new Availability Zones for the LoadBalancer. Each Availability Zone must - * be in the same Region as the LoadBalancer. - * - * @param loadBalancerName - * The name associated with the LoadBalancer. The name must be unique within the api - * AWS account. - * - * @return An updated list of Availability Zones for the LoadBalancer. - */ - Set addAvailabilityZonesToLoadBalancer(Iterable zones, String loadBalancerName); - - Set addAvailabilityZoneToLoadBalancer(String zone, String loadBalancerName); - - /** - * Removes the specified EC2 Availability Zones from the set of configured Availability Zones for - * the LoadBalancer. - * - * - * There must be at least one Availability Zone registered with a LoadBalancer at all times. A - * api cannot remove all the Availability Zones from a LoadBalancer. Once an Availability Zone - * is removed, all the instances registered with the LoadBalancer that are in the removed - * Availability Zone go into the OutOfService state. Upon Availability Zone removal, the - * LoadBalancer attempts to equally balance the traffic among its remaining usable Availability - * Zones. Trying to remove an Availability Zone that was not associated with the LoadBalancer - * does nothing. - * - *

Note

- * - * In order for this call to be successful, the api must have created the LoadBalancer. The - * api must provide the same account credentials as those that were used to create the - * LoadBalancer. - * - * @param zones - * A list of Availability Zones to be removed from the LoadBalancer. - * - *

Note

- * - * There must be at least one Availability Zone registered with a LoadBalancer at all - * times. The api cannot remove all the Availability Zones from a LoadBalancer. - * Specified Availability Zones must be in the same Region. - * - * - * @param loadBalancerName - * The name associated with the LoadBalancer. The name must be unique within the api - * AWS account. - * - * @return A list of updated Availability Zones for the LoadBalancer. - */ - Set removeAvailabilityZonesFromLoadBalancer(Iterable zones, String loadBalancerName); - - Set removeAvailabilityZoneFromLoadBalancer(String zone, String loadBalancerName); - -} diff --git a/labs/elb/src/main/java/org/jclouds/elb/features/AvailabilityZoneAsyncApi.java b/labs/elb/src/main/java/org/jclouds/elb/features/AvailabilityZoneAsyncApi.java deleted file mode 100644 index 4b5164be5f..0000000000 --- a/labs/elb/src/main/java/org/jclouds/elb/features/AvailabilityZoneAsyncApi.java +++ /dev/null @@ -1,102 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.elb.features; - -import static org.jclouds.aws.reference.FormParameters.ACTION; - -import java.util.Set; - -import javax.inject.Named; -import javax.ws.rs.FormParam; -import javax.ws.rs.POST; -import javax.ws.rs.Path; - -import org.jclouds.aws.filters.FormSigner; -import org.jclouds.elb.binders.BindAvailabilityZonesToIndexedFormParams; -import org.jclouds.elb.xml.AvailabilityZonesResultHandler; -import org.jclouds.rest.annotations.BinderParam; -import org.jclouds.rest.annotations.FormParams; -import org.jclouds.rest.annotations.RequestFilters; -import org.jclouds.rest.annotations.VirtualHost; -import org.jclouds.rest.annotations.XMLResponseParser; - -import com.google.common.util.concurrent.ListenableFuture; - -/** - * Provides access to Amazon ELB via the Query API - *

- * - * @see doc - * @see AvailabilityZoneApi - * @author Adrian Cole - */ -@RequestFilters(FormSigner.class) -@VirtualHost -public interface AvailabilityZoneAsyncApi { - - /** - * @see AvailabilityZoneApi#addAvailabilityZonesToLoadBalancer - */ - @Named("EnableAvailabilityZonesForLoadBalancer") - @POST - @Path("/") - @XMLResponseParser(AvailabilityZonesResultHandler.class) - @FormParams(keys = ACTION, values = "EnableAvailabilityZonesForLoadBalancer") - ListenableFuture> addAvailabilityZonesToLoadBalancer( - @BinderParam(BindAvailabilityZonesToIndexedFormParams.class) Iterable zones, - @FormParam("LoadBalancerName") String loadBalancerName); - - - /** - * @see AvailabilityZoneApi#addAvailabilityZoneToLoadBalancer - */ - @Named("EnableAvailabilityZonesForLoadBalancer") - @POST - @Path("/") - @XMLResponseParser(AvailabilityZonesResultHandler.class) - @FormParams(keys = ACTION, values = "EnableAvailabilityZonesForLoadBalancer") - ListenableFuture> addAvailabilityZoneToLoadBalancer( - @FormParam("AvailabilityZones.member.1") String zone, - @FormParam("LoadBalancerName") String loadBalancerName); - - /** - * @see AvailabilityZoneApi#removeAvailabilityZonesFromLoadBalancer - */ - @Named("DisableAvailabilityZonesForLoadBalancer") - @POST - @Path("/") - @XMLResponseParser(AvailabilityZonesResultHandler.class) - @FormParams(keys = ACTION, values = "DisableAvailabilityZonesForLoadBalancer") - ListenableFuture> removeAvailabilityZonesFromLoadBalancer( - @BinderParam(BindAvailabilityZonesToIndexedFormParams.class) Iterable zones, - @FormParam("LoadBalancerName") String loadBalancerName); - - /** - * @see AvailabilityZoneApi#removeAvailabilityZoneFromLoadBalancer - */ - @Named("DisableAvailabilityZonesForLoadBalancer") - @POST - @Path("/") - @XMLResponseParser(AvailabilityZonesResultHandler.class) - @FormParams(keys = ACTION, values = "DisableAvailabilityZonesForLoadBalancer") - ListenableFuture> removeAvailabilityZoneFromLoadBalancer( - @FormParam("AvailabilityZones.member.1") String zone, - @FormParam("LoadBalancerName") String loadBalancerName); -} diff --git a/labs/elb/src/main/java/org/jclouds/elb/features/InstanceApi.java b/labs/elb/src/main/java/org/jclouds/elb/features/InstanceApi.java deleted file mode 100644 index 1c5f1f7671..0000000000 --- a/labs/elb/src/main/java/org/jclouds/elb/features/InstanceApi.java +++ /dev/null @@ -1,133 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.elb.features; - -import java.util.Set; -import org.jclouds.elb.domain.InstanceHealth; - -/** - * Provides access to Amazon ELB via the Query API - *

- * - * @see - * @see InstanceAsyncApi - * @author Adrian Cole - */ -public interface InstanceApi { - - /** - * Returns the current state of the instances of the specified LoadBalancer. - * - *

Note

- * - * The api must have created the specified input LoadBalancer in order to retrieve this - * information; the api must provide the same account credentials as those that were used to - * create the LoadBalancer. - * - * @param loadBalancerName - * The name associated with the LoadBalancer. The name must be unique within the api - * AWS account. - * - * @return state of all instances of the load balancer - */ - Set getHealthOfInstancesOfLoadBalancer(String loadBalancerName); - - /** - * Returns the current state of the instances of the specified LoadBalancer. - * - *

Note

- * - * The api must have created the specified input LoadBalancer in order to retrieve this - * information; the api must provide the same account credentials as those that were used to - * create the LoadBalancer. - * - * @param instanceIds - * A list of instance IDs whose states are being queried. - * @param loadBalancerName - * The name associated with the LoadBalancer. The name must be unique within the api - * AWS account. - * - * @return state of all instances of the load balancer - */ - Set getHealthOfInstancesOfLoadBalancer(Iterable instanceIds, String loadBalancerName); - - /** - * Adds new instances to the LoadBalancer. - * - * Once the instance is registered, it starts receiving traffic and requests from the - * LoadBalancer. Any instance that is not in any of the Availability Zones registered for the - * LoadBalancer will be moved to the OutOfService state. It will move to the InService state when - * the Availability Zone is added to the LoadBalancer. - * - *

Note

- * - * In order for this call to be successful, the api must have created the LoadBalancer. The - * api must provide the same account credentials as those that were used to create the - * LoadBalancer. - * - *

Note

- * - * Completion of this API does not guarantee that operation has completed. Rather, it means that - * the request has been registered and the changes will happen shortly. - * - * @param instanceIds - * A list of instance IDs that should be registered with the LoadBalancer. - * - *

Note

- * - * When the instance is stopped and then restarted, the IP addresses associated with - * your instance changes. Elastic Load Balancing cannot recognize the new IP address, - * which prevents it from routing traffic to your instances. We recommend that you - * de-register your Amazon EC2 instances from your load balancer after you stop your - * instance, and then register the load balancer with your instance after you've - * restarted. To de-register your instances from load balancer, use - * DeregisterInstancesFromLoadBalancer action. - * - * - * @param loadBalancerName - * The name associated with the LoadBalancer. The name must be unique within the api - * AWS account. - * - * @return instanceIds registered with load balancer - */ - Set registerInstancesWithLoadBalancer(Iterable instanceIds, String loadBalancerName); - - Set registerInstanceWithLoadBalancer(String instanceId, String loadBalancerName); - - /** - * Deregisters instances from the LoadBalancer. Once the instance is deregistered, it will stop - * receiving traffic from the LoadBalancer. - * - * In order to successfully call this API, the same account credentials as those used to create - * the LoadBalancer must be provided. - * - * @param instanceIds - * A list of EC2 instance IDs consisting of all instances to be deregistered. - * - * @param loadBalancerName - * The name associated with the LoadBalancer. The name must be unique within the api - * AWS account. - * - * @return instanceIds still registered with load balancer - */ - Set deregisterInstancesFromLoadBalancer(Iterable instanceIds, String loadBalancerName); - - Set deregisterInstanceFromLoadBalancer(String instanceId, String loadBalancerName); - -} diff --git a/labs/elb/src/main/java/org/jclouds/elb/features/InstanceAsyncApi.java b/labs/elb/src/main/java/org/jclouds/elb/features/InstanceAsyncApi.java deleted file mode 100644 index 879e23cf2c..0000000000 --- a/labs/elb/src/main/java/org/jclouds/elb/features/InstanceAsyncApi.java +++ /dev/null @@ -1,132 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.elb.features; - -import static org.jclouds.aws.reference.FormParameters.ACTION; - -import java.util.Set; - -import javax.inject.Named; -import javax.ws.rs.FormParam; -import javax.ws.rs.POST; -import javax.ws.rs.Path; - -import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404; -import org.jclouds.aws.filters.FormSigner; -import org.jclouds.elb.binders.BindInstanceIdsToIndexedFormParams; -import org.jclouds.elb.domain.InstanceHealth; -import org.jclouds.elb.xml.DescribeInstanceHealthResultHandler; -import org.jclouds.elb.xml.InstancesResultHandler; -import org.jclouds.rest.annotations.BinderParam; -import org.jclouds.rest.annotations.Fallback; -import org.jclouds.rest.annotations.FormParams; -import org.jclouds.rest.annotations.RequestFilters; -import org.jclouds.rest.annotations.VirtualHost; -import org.jclouds.rest.annotations.XMLResponseParser; - -import com.google.common.util.concurrent.ListenableFuture; - -/** - * Provides access to Amazon ELB via the Query API - *

- * - * @see doc - * @see InstanceApi - * @author Adrian Cole - */ -@RequestFilters(FormSigner.class) -@VirtualHost -public interface InstanceAsyncApi { - - /** - * @see InstanceApi#getHealthOfInstancesOfLoadBalancer(String) - */ - @Named("DescribeInstanceHealth") - @POST - @Path("/") - @XMLResponseParser(DescribeInstanceHealthResultHandler.class) - @Fallback(EmptySetOnNotFoundOr404.class) - @FormParams(keys = "Action", values = "DescribeInstanceHealth") - ListenableFuture> getHealthOfInstancesOfLoadBalancer( - @FormParam("LoadBalancerName") String loadBalancerName); - - /** - * @see InstanceApi#getHealthOfInstancesOfLoadBalancer(Iterable, String) - */ - @Named("DescribeInstanceHealth") - @POST - @Path("/") - @XMLResponseParser(DescribeInstanceHealthResultHandler.class) - @Fallback(EmptySetOnNotFoundOr404.class) - @FormParams(keys = "Action", values = "DescribeInstanceHealth") - ListenableFuture> getHealthOfInstancesOfLoadBalancer( - @BinderParam(BindInstanceIdsToIndexedFormParams.class) Iterable instanceIds, - @FormParam("LoadBalancerName") String loadBalancerName); - - - /** - * @see InstanceApi#registerInstancesWithLoadBalancer - */ - @Named("RegisterInstancesWithLoadBalancer") - @POST - @Path("/") - @XMLResponseParser(InstancesResultHandler.class) - @FormParams(keys = ACTION, values = "RegisterInstancesWithLoadBalancer") - ListenableFuture> registerInstancesWithLoadBalancer( - @BinderParam(BindInstanceIdsToIndexedFormParams.class) Iterable instanceIds, - @FormParam("LoadBalancerName") String loadBalancerName); - - - /** - * @see InstanceApi#registerInstanceWithLoadBalancer - */ - @Named("RegisterInstancesWithLoadBalancer") - @POST - @Path("/") - @XMLResponseParser(InstancesResultHandler.class) - @FormParams(keys = ACTION, values = "RegisterInstancesWithLoadBalancer") - ListenableFuture> registerInstanceWithLoadBalancer( - @FormParam("Instances.member.1.InstanceId") String instanceId, - @FormParam("LoadBalancerName") String loadBalancerName); - - /** - * @see InstanceApi#deregisterInstancesFromLoadBalancer - */ - @Named("DeregisterInstancesFromLoadBalancer") - @POST - @Path("/") - @XMLResponseParser(InstancesResultHandler.class) - @FormParams(keys = ACTION, values = "DeregisterInstancesFromLoadBalancer") - ListenableFuture> deregisterInstancesFromLoadBalancer( - @BinderParam(BindInstanceIdsToIndexedFormParams.class) Iterable instanceIds, - @FormParam("LoadBalancerName") String loadBalancerName); - - /** - * @see InstanceApi#deregisterInstanceFromLoadBalancer - */ - @Named("DeregisterInstancesFromLoadBalancer") - @POST - @Path("/") - @XMLResponseParser(InstancesResultHandler.class) - @FormParams(keys = ACTION, values = "DeregisterInstancesFromLoadBalancer") - ListenableFuture> deregisterInstanceFromLoadBalancer( - @FormParam("Instances.member.1.InstanceId") String instanceId, - @FormParam("LoadBalancerName") String loadBalancerName); -} diff --git a/labs/elb/src/main/java/org/jclouds/elb/features/LoadBalancerApi.java b/labs/elb/src/main/java/org/jclouds/elb/features/LoadBalancerApi.java deleted file mode 100644 index 9877a02cd1..0000000000 --- a/labs/elb/src/main/java/org/jclouds/elb/features/LoadBalancerApi.java +++ /dev/null @@ -1,107 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.elb.features; - -import org.jclouds.collect.IterableWithMarker; -import org.jclouds.collect.PagedIterable; -import org.jclouds.elb.domain.Listener; -import org.jclouds.elb.domain.LoadBalancer; -import org.jclouds.elb.options.ListLoadBalancersOptions; -import org.jclouds.javax.annotation.Nullable; - -/** - * Provides access to Amazon ELB via the Query API - *

- * - * @see doc - * @see LoadBalancerAsyncApi - * @author Adrian Cole - */ -public interface LoadBalancerApi { - - String createListeningInAvailabilityZones(String name, Iterable listeners, - Iterable availabilityZones); - - String createListeningInAvailabilityZones(String name, Listener listeners, - Iterable availabilityZones); - - String createListeningInSubnetAssignedToSecurityGroups(String name, String subnetId, - Iterable securityGroupIds); - - String createListeningInSubnetsAssignedToSecurityGroups(String name, Iterable subnetIds, - Iterable securityGroupIds); - - - /** - * Retrieves information about the specified loadBalancer. - * - * @param name - * Name of the loadBalancer to get information about. - * @return null if not found - */ - @Nullable - LoadBalancer get(String name); - - /** - * Returns detailed configuration information for the specified LoadBalancers. If there are none, - * the action returns an empty list. - * - *
- * You can paginate the results using the {@link ListLoadBalancersOptions parameter} - * - * @param options - * the options describing the loadBalancers query - * - * @return the response object - */ - IterableWithMarker list(ListLoadBalancersOptions options); - - /** - * Lists the loadBalancers all load balancers - * - * @return the response object - */ - PagedIterable list(); - - /** - * Deletes the specified LoadBalancer. - * - *

- * If attempting to recreate the LoadBalancer, the api must reconfigure all the settings. The - * DNS name associated with a deleted LoadBalancer will no longer be usable. Once deleted, the - * name and associated DNS record of the LoadBalancer no longer exist and traffic sent to any of - * its IP addresses will no longer be delivered to api instances. The api will not receive - * the same DNS name even if a new LoadBalancer with same LoadBalancerName is created. - * - *

- * To successfully call this API, the api must provide the same account credentials as were - * used to create the LoadBalancer. - * - *

Note

- * - * By design, if the LoadBalancer does not exist or has already been deleted, DeleteLoadBalancer - * still succeeds. - * - * - * @param name - * Name of the load balancer - */ - void delete(String name); - -} diff --git a/labs/elb/src/main/java/org/jclouds/elb/features/LoadBalancerAsyncApi.java b/labs/elb/src/main/java/org/jclouds/elb/features/LoadBalancerAsyncApi.java deleted file mode 100644 index bead82f817..0000000000 --- a/labs/elb/src/main/java/org/jclouds/elb/features/LoadBalancerAsyncApi.java +++ /dev/null @@ -1,161 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.elb.features; - -import static org.jclouds.aws.reference.FormParameters.ACTION; - -import javax.inject.Named; -import javax.ws.rs.FormParam; -import javax.ws.rs.POST; -import javax.ws.rs.Path; - -import org.jclouds.Fallbacks.EmptyIterableWithMarkerOnNotFoundOr404; -import org.jclouds.Fallbacks.EmptyPagedIterableOnNotFoundOr404; -import org.jclouds.Fallbacks.NullOnNotFoundOr404; -import org.jclouds.Fallbacks.VoidOnNotFoundOr404; -import org.jclouds.aws.filters.FormSigner; -import org.jclouds.collect.IterableWithMarker; -import org.jclouds.collect.PagedIterable; -import org.jclouds.elb.binders.BindAvailabilityZonesToIndexedFormParams; -import org.jclouds.elb.binders.BindListenersToFormParams; -import org.jclouds.elb.binders.BindSecurityGroupsToIndexedFormParams; -import org.jclouds.elb.binders.BindSubnetsToIndexedFormParams; -import org.jclouds.elb.domain.Listener; -import org.jclouds.elb.domain.LoadBalancer; -import org.jclouds.elb.functions.LoadBalancersToPagedIterable; -import org.jclouds.elb.options.ListLoadBalancersOptions; -import org.jclouds.elb.xml.CreateLoadBalancerResponseHandler; -import org.jclouds.elb.xml.DescribeLoadBalancersResultHandler; -import org.jclouds.elb.xml.LoadBalancerHandler; -import org.jclouds.rest.annotations.BinderParam; -import org.jclouds.rest.annotations.Fallback; -import org.jclouds.rest.annotations.FormParams; -import org.jclouds.rest.annotations.RequestFilters; -import org.jclouds.rest.annotations.Transform; -import org.jclouds.rest.annotations.VirtualHost; -import org.jclouds.rest.annotations.XMLResponseParser; - -import com.google.common.util.concurrent.ListenableFuture; - -/** - * Provides access to Amazon ELB via the Query API - *

- * - * @see doc - * @see LoadBalancerApi - * @author Adrian Cole - */ -@RequestFilters(FormSigner.class) -@VirtualHost -public interface LoadBalancerAsyncApi { - /** - * @see LoadBalancerApi#createListeningInAvailabilityZones() - */ - @Named("CreateLoadBalancer") - @POST - @Path("/") - @XMLResponseParser(CreateLoadBalancerResponseHandler.class) - @FormParams(keys = ACTION, values = "CreateLoadBalancer") - ListenableFuture createListeningInAvailabilityZones(@FormParam("LoadBalancerName") String name, - @BinderParam(BindListenersToFormParams.class) Listener listeners, - @BinderParam(BindAvailabilityZonesToIndexedFormParams.class) Iterable availabilityZones); - - /** - * @see LoadBalancerApi#createListeningInAvailabilityZones() - */ - @Named("CreateLoadBalancer") - @POST - @Path("/") - @XMLResponseParser(CreateLoadBalancerResponseHandler.class) - @FormParams(keys = ACTION, values = "CreateLoadBalancer") - ListenableFuture createListeningInAvailabilityZones(@FormParam("LoadBalancerName") String name, - @BinderParam(BindListenersToFormParams.class) Iterable listeners, - @BinderParam(BindAvailabilityZonesToIndexedFormParams.class) Iterable availabilityZones); - - /** - * @see LoadBalancerApi#createListeningInSubnetAssignedToSecurityGroups() - */ - @Named("CreateLoadBalancer") - @POST - @Path("/") - @XMLResponseParser(CreateLoadBalancerResponseHandler.class) - @FormParams(keys = ACTION, values = "CreateLoadBalancer") - ListenableFuture createListeningInSubnetAssignedToSecurityGroups( - @FormParam("LoadBalancerName") String name, - @FormParam("Subnets.member.1") String subnetId, - @BinderParam(BindSecurityGroupsToIndexedFormParams.class) Iterable securityGroupIds); - - /** - * @see LoadBalancerApi#createListeningInSubnetsAssignedToSecurityGroups() - */ - @Named("CreateLoadBalancer") - @POST - @Path("/") - @XMLResponseParser(CreateLoadBalancerResponseHandler.class) - @FormParams(keys = ACTION, values = "CreateLoadBalancer") - ListenableFuture createListeningInSubnetsAssignedToSecurityGroups( - @FormParam("LoadBalancerName") String name, - @BinderParam(BindSubnetsToIndexedFormParams.class) Iterable subnetIds, - @BinderParam(BindSecurityGroupsToIndexedFormParams.class) Iterable securityGroupIds); - - /** - * @see LoadBalancerApi#get() - */ - @Named("DescribeLoadBalancers") - @POST - @Path("/") - @XMLResponseParser(LoadBalancerHandler.class) - @FormParams(keys = "Action", values = "DescribeLoadBalancers") - @Fallback(NullOnNotFoundOr404.class) - ListenableFuture get(@FormParam("LoadBalancerNames.member.1") String name); - - /** - * @see LoadBalancerApi#list() - */ - @Named("DescribeLoadBalancers") - @POST - @Path("/") - @XMLResponseParser(DescribeLoadBalancersResultHandler.class) - @Transform(LoadBalancersToPagedIterable.class) - @Fallback(EmptyPagedIterableOnNotFoundOr404.class) - @FormParams(keys = "Action", values = "DescribeLoadBalancers") - ListenableFuture> list(); - - /** - * @see LoadBalancerApi#list(ListLoadBalancersOptions) - */ - @Named("DescribeLoadBalancers") - @POST - @Path("/") - @XMLResponseParser(DescribeLoadBalancersResultHandler.class) - @Fallback(EmptyIterableWithMarkerOnNotFoundOr404.class) - @FormParams(keys = "Action", values = "DescribeLoadBalancers") - ListenableFuture> list(ListLoadBalancersOptions options); - - /** - * @see LoadBalancerApi#delete() - */ - @Named("DeleteLoadBalancer") - @POST - @Path("/") - @Fallback(VoidOnNotFoundOr404.class) - @FormParams(keys = ACTION, values = "DeleteLoadBalancer") - ListenableFuture delete(@FormParam("LoadBalancerName") String name); -} diff --git a/labs/elb/src/main/java/org/jclouds/elb/features/PolicyApi.java b/labs/elb/src/main/java/org/jclouds/elb/features/PolicyApi.java deleted file mode 100644 index 23e39eaa42..0000000000 --- a/labs/elb/src/main/java/org/jclouds/elb/features/PolicyApi.java +++ /dev/null @@ -1,97 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.elb.features; - -import java.util.Set; -import org.jclouds.elb.domain.Policy; -import org.jclouds.elb.domain.PolicyType; -import org.jclouds.elb.options.ListPoliciesOptions; -import org.jclouds.javax.annotation.Nullable; - -/** - * Provides access to Amazon ELB via the Query API - *

- * - * @see - * @author Adrian Cole - */ -public interface PolicyApi { - - /** - * Retrieves information about the specified policy. - * - * @param name - * Name of the policy to get information about. - * @return null if not found - */ - @Nullable - Policy get(String name); - - /** - * Returns detailed descriptions of the policies. - * - * If you specify a LoadBalancer name, the operation returns either the descriptions of the - * specified policies, or descriptions of all the policies created for the LoadBalancer. If you - * don't specify a LoadBalancer name, the operation returns descriptions of the specified sample - * policies, or descriptions of all the sample policies. The names of the sample policies have - * the ELBSample- prefix. - * - * @param options - * the options describing the policies query - * - * @return the response object - */ - Set list(ListPoliciesOptions options); - - /** - * returns descriptions of the specified sample policies, or descriptions of all the sample - * policies. - * - * @return the response object - */ - Set list(); - - /** - * Retrieves information about the specified policy type. - * - * @param name - * Name of the policy type to get information about. - * @return null if not found - */ - @Nullable - PolicyType getType(String name); - - /** - * Returns meta-information on the specified LoadBalancer policies defined by the Elastic Load - * Balancing service. The policy types that are returned from this action can be used in a - * CreateLoadBalancerPolicy action to instantiate specific policy configurations that will be - * applied to an Elastic LoadBalancer. - * - * @return the response object - */ - Set listTypes(); - - /** - * @param names Specifies the name of the policy types. If no names are specified, returns the description of all the policy types defined by Elastic Load Balancing service. - * - * @see #listTypes() - */ - Set listTypes(Iterable names); - -} diff --git a/labs/elb/src/main/java/org/jclouds/elb/features/PolicyAsyncApi.java b/labs/elb/src/main/java/org/jclouds/elb/features/PolicyAsyncApi.java deleted file mode 100644 index 0723352454..0000000000 --- a/labs/elb/src/main/java/org/jclouds/elb/features/PolicyAsyncApi.java +++ /dev/null @@ -1,127 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.elb.features; - -import java.util.Set; - -import javax.inject.Named; -import javax.ws.rs.FormParam; -import javax.ws.rs.POST; -import javax.ws.rs.Path; - -import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404; -import org.jclouds.Fallbacks.NullOnNotFoundOr404; -import org.jclouds.aws.filters.FormSigner; -import org.jclouds.elb.binders.BindPolicyTypeNamesToIndexedFormParams; -import org.jclouds.elb.domain.Policy; -import org.jclouds.elb.domain.PolicyType; -import org.jclouds.elb.options.ListPoliciesOptions; -import org.jclouds.elb.xml.DescribeLoadBalancerPoliciesResultHandler; -import org.jclouds.elb.xml.DescribeLoadBalancerPolicyTypesResultHandler; -import org.jclouds.elb.xml.PolicyHandler; -import org.jclouds.elb.xml.PolicyTypeHandler; -import org.jclouds.rest.annotations.BinderParam; -import org.jclouds.rest.annotations.Fallback; -import org.jclouds.rest.annotations.FormParams; -import org.jclouds.rest.annotations.RequestFilters; -import org.jclouds.rest.annotations.VirtualHost; -import org.jclouds.rest.annotations.XMLResponseParser; - -import com.google.common.util.concurrent.ListenableFuture; - -/** - * Provides access to Amazon ELB via the Query API - *

- * - * @see doc - * @see PolicyApi - * @author Adrian Cole - */ -@RequestFilters(FormSigner.class) -@VirtualHost -public interface PolicyAsyncApi { - - /** - * @see PolicyApi#get() - */ - @Named("DescribeLoadBalancerPolicies") - @POST - @Path("/") - @XMLResponseParser(PolicyHandler.class) - @FormParams(keys = "Action", values = "DescribeLoadBalancerPolicies") - @Fallback(NullOnNotFoundOr404.class) - ListenableFuture get(@FormParam("PolicyNames.member.1") String name); - - /** - * @see PolicyApi#list() - */ - @Named("DescribeLoadBalancerPolicies") - @POST - @Path("/") - @XMLResponseParser(DescribeLoadBalancerPoliciesResultHandler.class) - @Fallback(EmptySetOnNotFoundOr404.class) - @FormParams(keys = "Action", values = "DescribeLoadBalancerPolicies") - ListenableFuture> list(); - - /** - * @see PolicyApi#list(ListPoliciesOptions) - */ - @Named("DescribeLoadBalancerPolicies") - @POST - @Path("/") - @XMLResponseParser(DescribeLoadBalancerPoliciesResultHandler.class) - @Fallback(EmptySetOnNotFoundOr404.class) - @FormParams(keys = "Action", values = "DescribeLoadBalancerPolicies") - ListenableFuture> list(ListPoliciesOptions options); - - - /** - * @see PolicyApi#getType() - */ - @Named("DescribeLoadBalancerPolicyTypes") - @POST - @Path("/") - @XMLResponseParser(PolicyTypeHandler.class) - @FormParams(keys = "Action", values = "DescribeLoadBalancerPolicyTypes") - @Fallback(NullOnNotFoundOr404.class) - ListenableFuture getType(@FormParam("PolicyTypeNames.member.1") String name); - - /** - * @see PolicyApi#listTypes() - */ - @Named("DescribeLoadBalancerPolicyTypes") - @POST - @Path("/") - @XMLResponseParser(DescribeLoadBalancerPolicyTypesResultHandler.class) - @Fallback(EmptySetOnNotFoundOr404.class) - @FormParams(keys = "Action", values = "DescribeLoadBalancerPolicyTypes") - ListenableFuture> listTypes(); - - /** - * @see PolicyApi#listTypes(Iterable) - */ - @Named("DescribeLoadBalancerPolicyTypes") - @POST - @Path("/") - @XMLResponseParser(DescribeLoadBalancerPolicyTypesResultHandler.class) - @Fallback(EmptySetOnNotFoundOr404.class) - @FormParams(keys = "Action", values = "DescribeLoadBalancerPolicyTypes") - ListenableFuture> listTypes(@BinderParam(BindPolicyTypeNamesToIndexedFormParams.class) Iterable names); - -} diff --git a/labs/elb/src/main/java/org/jclouds/elb/functions/LoadBalancersToPagedIterable.java b/labs/elb/src/main/java/org/jclouds/elb/functions/LoadBalancersToPagedIterable.java deleted file mode 100644 index 9088657c55..0000000000 --- a/labs/elb/src/main/java/org/jclouds/elb/functions/LoadBalancersToPagedIterable.java +++ /dev/null @@ -1,65 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.elb.functions; - -import static com.google.common.base.Preconditions.checkNotNull; - -import javax.inject.Inject; - -import org.jclouds.collect.IterableWithMarker; -import org.jclouds.collect.internal.CallerArg0ToPagedIterable; -import org.jclouds.elb.ELBApi; -import org.jclouds.elb.domain.LoadBalancer; -import org.jclouds.elb.features.LoadBalancerApi; -import org.jclouds.elb.options.ListLoadBalancersOptions; - -import com.google.common.annotations.Beta; -import com.google.common.base.Function; - -/** - * @author Adrian Cole - */ -@Beta -public class LoadBalancersToPagedIterable extends CallerArg0ToPagedIterable { - - private final ELBApi api; - - @Inject - protected LoadBalancersToPagedIterable(ELBApi api) { - this.api = checkNotNull(api, "api"); - } - - @Override - protected Function> markerToNextForCallingArg0(final String arg0) { - final LoadBalancerApi loadBalancerApi = api.getLoadBalancerApiForRegion(arg0); - return new Function>() { - - @Override - public IterableWithMarker apply(Object input) { - return loadBalancerApi.list(ListLoadBalancersOptions.Builder.afterMarker(input)); - } - - @Override - public String toString() { - return "listLoadBalancersInRegion(" + arg0 + ")"; - } - }; - } - -} diff --git a/labs/elb/src/main/java/org/jclouds/elb/loadbalancer/config/ELBBindLoadBalancerStrategiesByClass.java b/labs/elb/src/main/java/org/jclouds/elb/loadbalancer/config/ELBBindLoadBalancerStrategiesByClass.java deleted file mode 100644 index d7d87b9620..0000000000 --- a/labs/elb/src/main/java/org/jclouds/elb/loadbalancer/config/ELBBindLoadBalancerStrategiesByClass.java +++ /dev/null @@ -1,55 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.elb.loadbalancer.config; - -import org.jclouds.elb.loadbalancer.strategy.ELBDestroyLoadBalancerStrategy; -import org.jclouds.elb.loadbalancer.strategy.ELBGetLoadBalancerMetadataStrategy; -import org.jclouds.elb.loadbalancer.strategy.ELBListLoadBalancersStrategy; -import org.jclouds.elb.loadbalancer.strategy.ELBLoadBalanceNodesStrategy; -import org.jclouds.loadbalancer.config.BindLoadBalancerStrategiesByClass; -import org.jclouds.loadbalancer.strategy.DestroyLoadBalancerStrategy; -import org.jclouds.loadbalancer.strategy.GetLoadBalancerMetadataStrategy; -import org.jclouds.loadbalancer.strategy.ListLoadBalancersStrategy; -import org.jclouds.loadbalancer.strategy.LoadBalanceNodesStrategy; - -/** - * @author Adrian Cole - */ -public class ELBBindLoadBalancerStrategiesByClass extends BindLoadBalancerStrategiesByClass { - - @Override - protected Class defineLoadBalanceNodesStrategy() { - return ELBLoadBalanceNodesStrategy.class; - } - - @Override - protected Class defineDestroyLoadBalancerStrategy() { - return ELBDestroyLoadBalancerStrategy.class; - } - - @Override - protected Class defineGetLoadBalancerMetadataStrategy() { - return ELBGetLoadBalancerMetadataStrategy.class; - } - - @Override - protected Class defineListLoadBalancersStrategy() { - return ELBListLoadBalancersStrategy.class; - } -} diff --git a/labs/elb/src/main/java/org/jclouds/elb/loadbalancer/config/ELBLoadBalancerContextModule.java b/labs/elb/src/main/java/org/jclouds/elb/loadbalancer/config/ELBLoadBalancerContextModule.java deleted file mode 100644 index fb4b60df60..0000000000 --- a/labs/elb/src/main/java/org/jclouds/elb/loadbalancer/config/ELBLoadBalancerContextModule.java +++ /dev/null @@ -1,37 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.elb.loadbalancer.config; - -import org.jclouds.loadbalancer.config.BaseLoadBalancerServiceContextModule; - -/** - * Configures the ELB connection. - * - * @author Adrian Cole - */ - -public class ELBLoadBalancerContextModule extends BaseLoadBalancerServiceContextModule { - - @Override - protected void configure() { - install(new ELBBindLoadBalancerStrategiesByClass()); - install(new ELBLoadBalancerServiceDependenciesModule()); - super.configure(); - } -} diff --git a/labs/elb/src/main/java/org/jclouds/elb/loadbalancer/config/ELBLoadBalancerServiceDependenciesModule.java b/labs/elb/src/main/java/org/jclouds/elb/loadbalancer/config/ELBLoadBalancerServiceDependenciesModule.java deleted file mode 100644 index ea63f0bc48..0000000000 --- a/labs/elb/src/main/java/org/jclouds/elb/loadbalancer/config/ELBLoadBalancerServiceDependenciesModule.java +++ /dev/null @@ -1,41 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.elb.loadbalancer.config; - -import org.jclouds.elb.domain.regionscoped.LoadBalancerInRegion; -import org.jclouds.elb.loadbalancer.functions.LoadBalancerToLoadBalancerMetadata; -import org.jclouds.loadbalancer.domain.LoadBalancerMetadata; - -import com.google.common.base.Function; -import com.google.inject.AbstractModule; -import com.google.inject.TypeLiteral; - -/** - * - * @author Adrian Cole - */ -public class ELBLoadBalancerServiceDependenciesModule extends AbstractModule { - - @Override - protected void configure() { - bind(new TypeLiteral>() { - }).to(LoadBalancerToLoadBalancerMetadata.class); - } - -} diff --git a/labs/elb/src/main/java/org/jclouds/elb/loadbalancer/functions/LoadBalancerToLoadBalancerMetadata.java b/labs/elb/src/main/java/org/jclouds/elb/loadbalancer/functions/LoadBalancerToLoadBalancerMetadata.java deleted file mode 100644 index 4ee5f77132..0000000000 --- a/labs/elb/src/main/java/org/jclouds/elb/loadbalancer/functions/LoadBalancerToLoadBalancerMetadata.java +++ /dev/null @@ -1,75 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.elb.loadbalancer.functions; - -import java.util.Set; - -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jclouds.collect.Memoized; -import org.jclouds.domain.Location; -import org.jclouds.elb.domain.regionscoped.LoadBalancerInRegion; -import org.jclouds.loadbalancer.domain.LoadBalancerMetadata; -import org.jclouds.loadbalancer.domain.LoadBalancerType; -import org.jclouds.loadbalancer.domain.internal.LoadBalancerMetadataImpl; - -import com.google.common.base.Function; -import com.google.common.base.Predicate; -import com.google.common.base.Supplier; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Iterables; - -/** - * - * @author Adrian Cole - */ -@Singleton -public class LoadBalancerToLoadBalancerMetadata implements Function { - - protected final Supplier> locations; - - @Inject - public LoadBalancerToLoadBalancerMetadata(@Memoized Supplier> locations) { - this.locations = locations; - } - - @Override - public LoadBalancerMetadata apply(LoadBalancerInRegion input) { - - Location location = findLocationWithId(input.getRegion()); - - return new LoadBalancerMetadataImpl(LoadBalancerType.LB, input.getName(), input.getName(), input.slashEncode(), - location, null, ImmutableMap. of(), - ImmutableSet.of(input.getLoadBalancer().getDnsName())); - } - - private Location findLocationWithId(final String locationId) { - return Iterables.find(locations.get(), new Predicate() { - - @Override - public boolean apply(Location input) { - return input.getId().equals(locationId); - } - - }); - } - -} diff --git a/labs/elb/src/main/java/org/jclouds/elb/loadbalancer/strategy/ELBDestroyLoadBalancerStrategy.java b/labs/elb/src/main/java/org/jclouds/elb/loadbalancer/strategy/ELBDestroyLoadBalancerStrategy.java deleted file mode 100644 index beb63deca0..0000000000 --- a/labs/elb/src/main/java/org/jclouds/elb/loadbalancer/strategy/ELBDestroyLoadBalancerStrategy.java +++ /dev/null @@ -1,63 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.elb.loadbalancer.strategy; - -import static com.google.common.base.Preconditions.checkNotNull; -import static org.jclouds.aws.util.AWSUtils.parseHandle; - -import javax.annotation.Resource; -import javax.inject.Inject; -import javax.inject.Named; -import javax.inject.Singleton; - -import org.jclouds.elb.ELBApi; -import org.jclouds.loadbalancer.domain.LoadBalancerMetadata; -import org.jclouds.loadbalancer.reference.LoadBalancerConstants; -import org.jclouds.loadbalancer.strategy.DestroyLoadBalancerStrategy; -import org.jclouds.loadbalancer.strategy.GetLoadBalancerMetadataStrategy; -import org.jclouds.logging.Logger; - -/** - * - * @author Adrian Cole - */ -@Singleton -public class ELBDestroyLoadBalancerStrategy implements DestroyLoadBalancerStrategy { - @Resource - @Named(LoadBalancerConstants.LOADBALANCER_LOGGER) - protected Logger logger = Logger.NULL; - - private final ELBApi elbApi; - private final GetLoadBalancerMetadataStrategy getLoadBalancer; - - @Inject - protected ELBDestroyLoadBalancerStrategy(ELBApi elbApi, GetLoadBalancerMetadataStrategy getLoadBalancer) { - this.elbApi = checkNotNull(elbApi, "elbApi"); - this.getLoadBalancer = checkNotNull(getLoadBalancer, "getLoadBalancer"); - } - - @Override - public LoadBalancerMetadata destroyLoadBalancer(String id) { - String[] parts = parseHandle(id); - String region = parts[0]; - String instanceId = parts[1]; - elbApi.getLoadBalancerApiForRegion(region).delete(instanceId); - return getLoadBalancer.getLoadBalancer(id); - } -} diff --git a/labs/elb/src/main/java/org/jclouds/elb/loadbalancer/strategy/ELBGetLoadBalancerMetadataStrategy.java b/labs/elb/src/main/java/org/jclouds/elb/loadbalancer/strategy/ELBGetLoadBalancerMetadataStrategy.java deleted file mode 100644 index b470d13fed..0000000000 --- a/labs/elb/src/main/java/org/jclouds/elb/loadbalancer/strategy/ELBGetLoadBalancerMetadataStrategy.java +++ /dev/null @@ -1,61 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.elb.loadbalancer.strategy; - -import static com.google.common.base.Preconditions.checkNotNull; -import static org.jclouds.aws.util.AWSUtils.parseHandle; - -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jclouds.elb.ELBApi; -import org.jclouds.elb.domain.LoadBalancer; -import org.jclouds.elb.domain.regionscoped.LoadBalancerInRegion; -import org.jclouds.loadbalancer.domain.LoadBalancerMetadata; -import org.jclouds.loadbalancer.strategy.GetLoadBalancerMetadataStrategy; - -import com.google.common.base.Function; - -/** - * - * @author Adrian Cole - */ -@Singleton -public class ELBGetLoadBalancerMetadataStrategy implements GetLoadBalancerMetadataStrategy { - - private final ELBApi api; - private final Function converter; - - @Inject - protected ELBGetLoadBalancerMetadataStrategy(ELBApi api, - Function converter) { - this.api = checkNotNull(api, "api"); - this.converter = checkNotNull(converter, "converter"); - } - - @Override - public LoadBalancerMetadata getLoadBalancer(String id) { - String[] parts = parseHandle(id); - String region = parts[0]; - String name = parts[1]; - LoadBalancer input = api.getLoadBalancerApiForRegion(region).get(name); - return input != null ? converter.apply(new LoadBalancerInRegion(input, region)) : null; - } - -} diff --git a/labs/elb/src/main/java/org/jclouds/elb/loadbalancer/strategy/ELBListLoadBalancersStrategy.java b/labs/elb/src/main/java/org/jclouds/elb/loadbalancer/strategy/ELBListLoadBalancersStrategy.java deleted file mode 100644 index 4ec11b315b..0000000000 --- a/labs/elb/src/main/java/org/jclouds/elb/loadbalancer/strategy/ELBListLoadBalancersStrategy.java +++ /dev/null @@ -1,104 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.elb.loadbalancer.strategy; - -import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.collect.Iterables.concat; -import static com.google.common.collect.Iterables.transform; -import static com.google.common.util.concurrent.Futures.transform; -import static org.jclouds.concurrent.FutureIterables.transformParallel; - -import java.util.Set; - -import javax.annotation.Resource; -import javax.inject.Inject; -import javax.inject.Named; -import javax.inject.Singleton; - -import org.jclouds.Constants; -import org.jclouds.collect.PagedIterable; -import org.jclouds.elb.ELBAsyncApi; -import org.jclouds.elb.domain.LoadBalancer; -import org.jclouds.elb.domain.regionscoped.LoadBalancerInRegion; -import org.jclouds.loadbalancer.domain.LoadBalancerMetadata; -import org.jclouds.loadbalancer.reference.LoadBalancerConstants; -import org.jclouds.loadbalancer.strategy.ListLoadBalancersStrategy; -import org.jclouds.location.Region; -import org.jclouds.logging.Logger; - -import com.google.common.base.Function; -import com.google.common.base.Supplier; -import com.google.common.util.concurrent.ListenableFuture; -import com.google.common.util.concurrent.ListeningExecutorService; - -/** - * - * @author Adrian Cole - */ -@Singleton -public class ELBListLoadBalancersStrategy implements ListLoadBalancersStrategy { - @Resource - @Named(LoadBalancerConstants.LOADBALANCER_LOGGER) - protected Logger logger = Logger.NULL; - - private final ELBAsyncApi aapi; - private final Function converter; - private final ListeningExecutorService userExecutor; - private final Supplier> regions; - - @Inject - protected ELBListLoadBalancersStrategy(ELBAsyncApi aapi, - Function converter, - @Named(Constants.PROPERTY_USER_THREADS) ListeningExecutorService userExecutor, @Region Supplier> regions) { - this.aapi = checkNotNull(aapi, "aapi"); - this.regions = checkNotNull(regions, "regions"); - this.converter = checkNotNull(converter, "converter"); - this.userExecutor = checkNotNull(userExecutor, "userExecutor"); - } - - @Override - public Iterable listLoadBalancers() { - - Iterable loadBalancers = concat(transformParallel(regions.get(), - new Function>>() { - - @Override - public ListenableFuture> apply(final String from) { - // TODO: ELB.listLoadBalancers - return transform(aapi.getLoadBalancerApiForRegion(from).list(), - new Function, Iterable>() { - - @Override - public Iterable apply(PagedIterable input) { - return input.concat() - .transform(new Function() { - @Override - public LoadBalancerInRegion apply(LoadBalancer lb) { - return new LoadBalancerInRegion(lb, from); - } - }); - } - - }, userExecutor); - } - - }, userExecutor, null, logger, "loadbalancers")); - return transform(loadBalancers, converter); - } -} diff --git a/labs/elb/src/main/java/org/jclouds/elb/loadbalancer/strategy/ELBLoadBalanceNodesStrategy.java b/labs/elb/src/main/java/org/jclouds/elb/loadbalancer/strategy/ELBLoadBalanceNodesStrategy.java deleted file mode 100644 index be5a952183..0000000000 --- a/labs/elb/src/main/java/org/jclouds/elb/loadbalancer/strategy/ELBLoadBalanceNodesStrategy.java +++ /dev/null @@ -1,122 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.elb.loadbalancer.strategy; - -import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.base.Predicates.in; -import static com.google.common.base.Predicates.not; -import static com.google.common.collect.Iterables.transform; -import static com.google.common.collect.Sets.filter; -import static org.jclouds.aws.util.AWSUtils.getRegionFromLocationOrNull; - -import java.util.Set; - -import javax.annotation.Resource; -import javax.inject.Inject; -import javax.inject.Named; -import javax.inject.Singleton; - -import org.jclouds.compute.domain.NodeMetadata; -import org.jclouds.domain.Location; -import org.jclouds.elb.ELBApi; -import org.jclouds.elb.domain.Listener; -import org.jclouds.elb.domain.Protocol; -import org.jclouds.elb.domain.regionscoped.LoadBalancerInRegion; -import org.jclouds.loadbalancer.domain.LoadBalancerMetadata; -import org.jclouds.loadbalancer.reference.LoadBalancerConstants; -import org.jclouds.loadbalancer.strategy.LoadBalanceNodesStrategy; -import org.jclouds.logging.Logger; - -import com.google.common.base.Function; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Sets; - -/** - * - * @author Adrian Cole - */ -@Singleton -public class ELBLoadBalanceNodesStrategy implements LoadBalanceNodesStrategy { - @Resource - @Named(LoadBalancerConstants.LOADBALANCER_LOGGER) - protected Logger logger = Logger.NULL; - protected final ELBApi api; - protected final Function converter; - - @Inject - protected ELBLoadBalanceNodesStrategy(ELBApi api, - Function converter) { - this.api = checkNotNull(api, "api"); - this.converter = checkNotNull(converter, "converter"); - } - - @Override - public LoadBalancerMetadata createLoadBalancerInLocation(Location location, String name, String protocol, - int loadBalancerPort, int instancePort, Iterable nodes) { - checkNotNull(location, "location"); - String region = getRegionFromLocationOrNull(location); - - Set zonesDesired = ImmutableSet.copyOf(transform(nodes, new Function() { - - @Override - public String apply(NodeMetadata from) { - return from.getLocation().getId(); - } - })); - - logger.debug(">> creating loadBalancer(%s) in zones(%s)", name, zonesDesired); - try { - String dnsName = api.getLoadBalancerApiForRegion(region).createListeningInAvailabilityZones( - name, - ImmutableSet.of(Listener.builder().port(loadBalancerPort).instancePort(instancePort) - .protocol(Protocol.valueOf(protocol)).build()), zonesDesired); - logger.debug("<< created loadBalancer(%s) dnsName(%s)", name, dnsName); - } catch (IllegalStateException e) { - logger.debug("<< converging zones(%s) in loadBalancer(%s)", zonesDesired, name); - Set currentZones = api.getLoadBalancerApi().get(name).getAvailabilityZones(); - Set zonesToAdd = Sets.difference(zonesDesired, currentZones); - if (zonesToAdd.size() > 0) - currentZones = api.getAvailabilityZoneApi().addAvailabilityZonesToLoadBalancer(zonesToAdd, name); - Set zonesToRemove = Sets.difference(currentZones, zonesDesired); - if (zonesToRemove.size() > 0) - api.getAvailabilityZoneApi().removeAvailabilityZonesFromLoadBalancer(zonesToRemove, name); - } - - Set instanceIds = ImmutableSet.copyOf(transform(nodes, new Function() { - - @Override - public String apply(NodeMetadata from) { - return from.getProviderId(); - } - })); - - logger.debug(">> converging loadBalancer(%s) to instances(%s)", name, instanceIds); - Set registeredInstanceIds = api.getInstanceApiForRegion(region).registerInstancesWithLoadBalancer( - instanceIds, name); - - Set instancesToRemove = filter(registeredInstanceIds, not(in(instanceIds))); - if (instancesToRemove.size() > 0) { - logger.debug(">> deregistering instances(%s) from loadBalancer(%s)", instancesToRemove, name); - api.getInstanceApiForRegion(region).deregisterInstancesFromLoadBalancer(instancesToRemove, name); - } - logger.debug("<< converged loadBalancer(%s) ", name); - - return converter.apply(new LoadBalancerInRegion(api.getLoadBalancerApiForRegion(region).get(name), region)); - } -} diff --git a/labs/elb/src/main/java/org/jclouds/elb/options/ListLoadBalancersOptions.java b/labs/elb/src/main/java/org/jclouds/elb/options/ListLoadBalancersOptions.java deleted file mode 100644 index d8cd2410c3..0000000000 --- a/labs/elb/src/main/java/org/jclouds/elb/options/ListLoadBalancersOptions.java +++ /dev/null @@ -1,143 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.elb.options; - -import java.util.Set; - -import org.jclouds.http.options.BaseHttpRequestOptions; - -import com.google.common.base.Objects; -import com.google.common.collect.Multimap; -import com.google.common.collect.Sets; - -/** - * Options used to list available loadBalancers. - * - * @see docs - * - * @author Adrian Cole - */ -public class ListLoadBalancersOptions extends BaseHttpRequestOptions implements Cloneable { - - private Object marker; - private Set names = Sets.newLinkedHashSet(); - - /** - * Use this parameter only when paginating results, and only in a subsequent request after you've - * received a response where the results are truncated. Set it to the value of the Marker element - * in the response you just received. - */ - public ListLoadBalancersOptions afterMarker(Object marker) { - this.marker = marker; - return this; - } - - /** - * list of names associated with the LoadBalancers at creation time. - */ - public ListLoadBalancersOptions names(Set names) { - this.names = names; - return this; - } - - /** - * @see #names - */ - public ListLoadBalancersOptions name(String name) { - this.names.add(name); - return this; - } - - public static class Builder { - - /** - * @see ListLoadBalancersOptions#getMarker() - */ - public static ListLoadBalancersOptions afterMarker(Object marker) { - return new ListLoadBalancersOptions().afterMarker(marker); - } - - /** - * @see ListLoadBalancersOptions#getNames() - */ - public static ListLoadBalancersOptions name(String name) { - return new ListLoadBalancersOptions().name(name); - } - - /** - * @see ListLoadBalancersOptions#getNames() - */ - public static ListLoadBalancersOptions names(Set names) { - return new ListLoadBalancersOptions().names(names); - } - } - - @Override - public Multimap buildFormParameters() { - Multimap params = super.buildFormParameters(); - if (marker != null) - params.put("Marker", marker.toString()); - if (names.size() > 0) { - int nameIndex = 1; - for (String name : names) { - params.put("LoadBalancerNames.member." + nameIndex, name); - nameIndex++; - } - } - return params; - } - - /** - * {@inheritDoc} - */ - @Override - public int hashCode() { - return Objects.hashCode(marker, names); - } - - @Override - public ListLoadBalancersOptions clone() { - return new ListLoadBalancersOptions().afterMarker(marker).names(names); - } - - /** - * {@inheritDoc} - */ - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - ListLoadBalancersOptions other = ListLoadBalancersOptions.class.cast(obj); - return Objects.equal(this.marker, other.marker) && Objects.equal(this.names, other.names); - } - - /** - * {@inheritDoc} - */ - @Override - public String toString() { - return Objects.toStringHelper(this).omitNullValues().add("marker", marker).add("names", names).toString(); - } -} diff --git a/labs/elb/src/main/java/org/jclouds/elb/options/ListPoliciesOptions.java b/labs/elb/src/main/java/org/jclouds/elb/options/ListPoliciesOptions.java deleted file mode 100644 index 199bcee983..0000000000 --- a/labs/elb/src/main/java/org/jclouds/elb/options/ListPoliciesOptions.java +++ /dev/null @@ -1,159 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.elb.options; - -import java.util.Set; - -import org.jclouds.http.options.BaseHttpRequestOptions; - -import com.google.common.base.Objects; -import com.google.common.collect.Multimap; -import com.google.common.collect.Sets; - -/** - * Options used to list available policies. - * - * @see docs - * - * @author Adrian Cole - */ -public class ListPoliciesOptions extends BaseHttpRequestOptions implements Cloneable { - - private String loadBalancerName; - private Set names = Sets.newLinkedHashSet(); - - /** - * @see ListPoliciesOptions#getLoadBalancerName() - */ - public ListPoliciesOptions loadBalancerName(String loadBalancerName) { - this.loadBalancerName = loadBalancerName; - return this; - } - - /** - * @see ListPoliciesOptions#getNames() - */ - public ListPoliciesOptions names(Set names) { - this.names = names; - return this; - } - - /** - * @see ListPoliciesOptions#getNames() - */ - public ListPoliciesOptions name(String name) { - this.names.add(name); - return this; - } - - /** - * The mnemonic name associated with the LoadBalancer. If no name is specified, the operation - * returns the attributes of either all the sample policies pre-defined by Elastic Load Balancing - * or the specified sample polices. - */ - public String getLoadBalancerName() { - return loadBalancerName; - } - - /** - * The names of LoadBalancer policies you've created or Elastic Load Balancing sample policy - * names. - */ - public Set getNames() { - return names; - } - - public static class Builder { - - /** - * @see ListPoliciesOptions#getLoadBalancerName() - */ - public static ListPoliciesOptions loadBalancerName(String loadBalancerName) { - return new ListPoliciesOptions().loadBalancerName(loadBalancerName); - } - - /** - * @see ListPoliciesOptions#getNames() - */ - public static ListPoliciesOptions name(String name) { - return new ListPoliciesOptions().name(name); - } - - /** - * @see ListPoliciesOptions#getNames() - */ - public static ListPoliciesOptions names(Set names) { - return new ListPoliciesOptions().names(names); - } - } - - @Override - public Multimap buildFormParameters() { - Multimap params = super.buildFormParameters(); - if (loadBalancerName != null) - params.put("LoadBalancerName", loadBalancerName); - if (names.size() > 0) { - int nameIndex = 1; - for (String name : names) { - params.put("PolicyNames.member." + nameIndex, name); - nameIndex++; - } - } - return params; - } - - /** - * {@inheritDoc} - */ - @Override - public int hashCode() { - return Objects.hashCode(loadBalancerName, names); - } - - @Override - public ListPoliciesOptions clone() { - return new ListPoliciesOptions().loadBalancerName(loadBalancerName).names(names); - } - - /** - * {@inheritDoc} - */ - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - ListPoliciesOptions other = ListPoliciesOptions.class.cast(obj); - return Objects.equal(this.loadBalancerName, other.loadBalancerName) && Objects.equal(this.names, other.names); - } - - /** - * {@inheritDoc} - */ - @Override - public String toString() { - return Objects.toStringHelper(this).omitNullValues().add("loadBalancerName", loadBalancerName) - .add("names", names).toString(); - } -} diff --git a/labs/elb/src/main/java/org/jclouds/elb/xml/AttributeMetadataHandler.java b/labs/elb/src/main/java/org/jclouds/elb/xml/AttributeMetadataHandler.java deleted file mode 100644 index 7164218946..0000000000 --- a/labs/elb/src/main/java/org/jclouds/elb/xml/AttributeMetadataHandler.java +++ /dev/null @@ -1,98 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.elb.xml; - -import static org.jclouds.util.SaxUtils.currentOrNull; -import static org.jclouds.util.SaxUtils.equalsOrSuffix; - -import org.jclouds.elb.domain.AttributeMetadata; -import org.jclouds.elb.domain.AttributeMetadata.Cardinality; -import org.jclouds.http.functions.ParseSax; -import org.xml.sax.SAXException; - -/** - * @see xml - * - * @author Adrian Cole - */ -public class AttributeMetadataHandler extends ParseSax.HandlerForGeneratedRequestWithResult> { - - private StringBuilder currentText = new StringBuilder(); - @SuppressWarnings("rawtypes") - private AttributeMetadata.Builder builder = AttributeMetadata.builder(); - @SuppressWarnings("rawtypes") - private Class currentType = String.class; - - /** - * {@inheritDoc} - */ - @Override - public AttributeMetadata getResult() { - try { - return builder.build(); - } finally { - builder = AttributeMetadata.builder(); - } - } - - /** - * {@inheritDoc} - */ - @SuppressWarnings("unchecked") - @Override - public void endElement(String uri, String name, String qName) throws SAXException { - if (equalsOrSuffix(qName, "AttributeName")) { - builder.name(currentOrNull(currentText)); - } else if (equalsOrSuffix(qName, "AttributeType")) { - String rawType = currentOrNull(currentText); - if ("Long".equals(rawType)) { - currentType = Long.class; - } else if ("Boolean".equals(rawType)) { - currentType = Boolean.class; - } else { - currentType = String.class; - } - builder.type(currentType); - builder.rawType(rawType); - } else if (equalsOrSuffix(qName, "Cardinality")) { - builder.cardinality(Cardinality.valueOf(currentOrNull(currentText))); - } else if (equalsOrSuffix(qName, "DefaultValue")) { - Object value = currentOrNull(currentText); - if (currentType == Long.class) - value = Long.valueOf(currentOrNull(currentText)); - else if (currentType == Boolean.class) - value = Boolean.valueOf(currentOrNull(currentText)); - builder.defaultValue(value); - } else if (equalsOrSuffix(qName, "UnhealthyThreshold")) { - builder.description(currentOrNull(currentText)); - } - currentText = new StringBuilder(); - } - - /** - * {@inheritDoc} - */ - @Override - public void characters(char ch[], int start, int length) { - currentText.append(ch, start, length); - } - -} diff --git a/labs/elb/src/main/java/org/jclouds/elb/xml/AvailabilityZonesResultHandler.java b/labs/elb/src/main/java/org/jclouds/elb/xml/AvailabilityZonesResultHandler.java deleted file mode 100644 index 547ed6224d..0000000000 --- a/labs/elb/src/main/java/org/jclouds/elb/xml/AvailabilityZonesResultHandler.java +++ /dev/null @@ -1,46 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.elb.xml; - -import java.util.Set; - -import org.jclouds.http.functions.ParseSax; - -import com.google.common.collect.Sets; - -public class AvailabilityZonesResultHandler extends ParseSax.HandlerWithResult> { - - private Set zones = Sets.newLinkedHashSet(); - private StringBuilder currentText = new StringBuilder(); - - public void endElement(String uri, String localName, String qName) { - if (qName.equals("member")) - zones.add(currentText.toString().trim()); - currentText = new StringBuilder(); - } - - @Override - public Set getResult() { - return zones; - } - - public void characters(char ch[], int start, int length) { - currentText.append(ch, start, length); - } -} diff --git a/labs/elb/src/main/java/org/jclouds/elb/xml/CreateLoadBalancerResponseHandler.java b/labs/elb/src/main/java/org/jclouds/elb/xml/CreateLoadBalancerResponseHandler.java deleted file mode 100644 index 48304caa32..0000000000 --- a/labs/elb/src/main/java/org/jclouds/elb/xml/CreateLoadBalancerResponseHandler.java +++ /dev/null @@ -1,54 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.elb.xml; - -import javax.annotation.Resource; - -import org.jclouds.http.functions.ParseSax.HandlerWithResult; -import org.jclouds.logging.Logger; - -public class CreateLoadBalancerResponseHandler extends HandlerWithResult { - - @Resource - protected Logger logger = Logger.NULL; - - private String dnsName; - private StringBuilder currentText = new StringBuilder(); - - protected String currentOrNull() { - String returnVal = currentText.toString().trim(); - return returnVal.equals("") ? null : returnVal; - } - - public void endElement(String uri, String name, String qName) { - if (qName.equals("DNSName")) { - dnsName = currentOrNull(); - } - currentText = new StringBuilder(); - } - - public void characters(char ch[], int start, int length) { - currentText.append(ch, start, length); - } - - @Override - public String getResult() { - return dnsName; - } -} diff --git a/labs/elb/src/main/java/org/jclouds/elb/xml/DescribeInstanceHealthResultHandler.java b/labs/elb/src/main/java/org/jclouds/elb/xml/DescribeInstanceHealthResultHandler.java deleted file mode 100644 index 579172059e..0000000000 --- a/labs/elb/src/main/java/org/jclouds/elb/xml/DescribeInstanceHealthResultHandler.java +++ /dev/null @@ -1,118 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.elb.xml; - -import static org.jclouds.util.SaxUtils.equalsOrSuffix; - -import java.util.Set; - -import org.jclouds.elb.domain.InstanceHealth; -import org.jclouds.http.functions.ParseSax; -import org.xml.sax.Attributes; -import org.xml.sax.SAXException; - -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.ImmutableSet.Builder; -import com.google.inject.Inject; - -/** - * @see docs - * - * @author Adrian Cole - */ -public class DescribeInstanceHealthResultHandler extends - ParseSax.HandlerForGeneratedRequestWithResult> { - - private final InstanceStateHandler instanceStateHandler; - - private StringBuilder currentText = new StringBuilder(); - private Builder instanceStates = ImmutableSet. builder(); - private boolean inStates; - - protected int memberDepth; - - @Inject - public DescribeInstanceHealthResultHandler(InstanceStateHandler instanceStateHandler) { - this.instanceStateHandler = instanceStateHandler; - } - - /** - * {@inheritDoc} - */ - @Override - public Set getResult() { - return instanceStates.build(); - } - - /** - * {@inheritDoc} - */ - @Override - public void startElement(String url, String name, String qName, Attributes attributes) throws SAXException { - if (equalsOrSuffix(qName, "member")) { - memberDepth++; - } else if (equalsOrSuffix(qName, "InstanceStates")) { - inStates = true; - } - if (inStates) { - instanceStateHandler.startElement(url, name, qName, attributes); - } - } - - /** - * {@inheritDoc} - */ - @Override - public void endElement(String uri, String name, String qName) throws SAXException { - if (equalsOrSuffix(qName, "member")) { - endMember(uri, name, qName); - memberDepth--; - } else if (equalsOrSuffix(qName, "InstanceStates")) { - inStates = false; - } else if (inStates) { - instanceStateHandler.endElement(uri, name, qName); - } - - currentText = new StringBuilder(); - } - - protected void endMember(String uri, String name, String qName) throws SAXException { - if (inStates) { - if (memberDepth == 1) - instanceStates.add(instanceStateHandler.getResult()); - else - instanceStateHandler.endElement(uri, name, qName); - } - } - - /** - * {@inheritDoc} - */ - @Override - public void characters(char ch[], int start, int length) { - if (inStates) { - instanceStateHandler.characters(ch, start, length); - } else { - currentText.append(ch, start, length); - } - } - -} diff --git a/labs/elb/src/main/java/org/jclouds/elb/xml/DescribeLoadBalancerPoliciesResultHandler.java b/labs/elb/src/main/java/org/jclouds/elb/xml/DescribeLoadBalancerPoliciesResultHandler.java deleted file mode 100644 index 1f8b198e23..0000000000 --- a/labs/elb/src/main/java/org/jclouds/elb/xml/DescribeLoadBalancerPoliciesResultHandler.java +++ /dev/null @@ -1,118 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.elb.xml; - -import static org.jclouds.util.SaxUtils.equalsOrSuffix; - -import java.util.Set; - -import org.jclouds.elb.domain.Policy; -import org.jclouds.http.functions.ParseSax; -import org.xml.sax.Attributes; -import org.xml.sax.SAXException; - -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.ImmutableSet.Builder; -import com.google.inject.Inject; - -/** - * @see docs - * - * @author Adrian Cole - */ -public class DescribeLoadBalancerPoliciesResultHandler extends - ParseSax.HandlerForGeneratedRequestWithResult> { - - private final PolicyHandler policyHandler; - - private StringBuilder currentText = new StringBuilder(); - private Builder policies = ImmutableSet. builder(); - private boolean inPolicies; - - protected int memberDepth; - - @Inject - public DescribeLoadBalancerPoliciesResultHandler(PolicyHandler policyHandler) { - this.policyHandler = policyHandler; - } - - /** - * {@inheritDoc} - */ - @Override - public Set getResult() { - return policies.build(); - } - - /** - * {@inheritDoc} - */ - @Override - public void startElement(String url, String name, String qName, Attributes attributes) throws SAXException { - if (equalsOrSuffix(qName, "member")) { - memberDepth++; - } else if (equalsOrSuffix(qName, "PolicyDescriptions")) { - inPolicies = true; - } - if (inPolicies) { - policyHandler.startElement(url, name, qName, attributes); - } - } - - /** - * {@inheritDoc} - */ - @Override - public void endElement(String uri, String name, String qName) throws SAXException { - if (equalsOrSuffix(qName, "member")) { - endMember(uri, name, qName); - memberDepth--; - } else if (equalsOrSuffix(qName, "PolicyDescriptions")) { - inPolicies = false; - } else if (inPolicies) { - policyHandler.endElement(uri, name, qName); - } - - currentText = new StringBuilder(); - } - - protected void endMember(String uri, String name, String qName) throws SAXException { - if (inPolicies) { - if (memberDepth == 1) - policies.add(policyHandler.getResult()); - else - policyHandler.endElement(uri, name, qName); - } - } - - /** - * {@inheritDoc} - */ - @Override - public void characters(char ch[], int start, int length) { - if (inPolicies) { - policyHandler.characters(ch, start, length); - } else { - currentText.append(ch, start, length); - } - } - -} diff --git a/labs/elb/src/main/java/org/jclouds/elb/xml/DescribeLoadBalancerPolicyTypesResultHandler.java b/labs/elb/src/main/java/org/jclouds/elb/xml/DescribeLoadBalancerPolicyTypesResultHandler.java deleted file mode 100644 index 9536f6751c..0000000000 --- a/labs/elb/src/main/java/org/jclouds/elb/xml/DescribeLoadBalancerPolicyTypesResultHandler.java +++ /dev/null @@ -1,118 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.elb.xml; - -import static org.jclouds.util.SaxUtils.equalsOrSuffix; - -import java.util.Set; - -import org.jclouds.elb.domain.PolicyType; -import org.jclouds.http.functions.ParseSax; -import org.xml.sax.Attributes; -import org.xml.sax.SAXException; - -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.ImmutableSet.Builder; -import com.google.inject.Inject; - -/** - * @see docs - * - * @author Adrian Cole - */ -public class DescribeLoadBalancerPolicyTypesResultHandler extends - ParseSax.HandlerForGeneratedRequestWithResult> { - - private final PolicyTypeHandler policyTypeHandler; - - private StringBuilder currentText = new StringBuilder(); - private Builder policyTypes = ImmutableSet. builder(); - private boolean inPolicyTypeTypes; - - protected int memberDepth; - - @Inject - public DescribeLoadBalancerPolicyTypesResultHandler(PolicyTypeHandler policyTypeHandler) { - this.policyTypeHandler = policyTypeHandler; - } - - /** - * {@inheritDoc} - */ - @Override - public Set getResult() { - return policyTypes.build(); - } - - /** - * {@inheritDoc} - */ - @Override - public void startElement(String url, String name, String qName, Attributes attributes) throws SAXException { - if (equalsOrSuffix(qName, "member")) { - memberDepth++; - } else if (equalsOrSuffix(qName, "PolicyTypeDescriptions")) { - inPolicyTypeTypes = true; - } - if (inPolicyTypeTypes) { - policyTypeHandler.startElement(url, name, qName, attributes); - } - } - - /** - * {@inheritDoc} - */ - @Override - public void endElement(String uri, String name, String qName) throws SAXException { - if (equalsOrSuffix(qName, "member")) { - endMember(uri, name, qName); - memberDepth--; - } else if (equalsOrSuffix(qName, "PolicyTypeDescriptions")) { - inPolicyTypeTypes = false; - } else if (inPolicyTypeTypes) { - policyTypeHandler.endElement(uri, name, qName); - } - - currentText = new StringBuilder(); - } - - protected void endMember(String uri, String name, String qName) throws SAXException { - if (inPolicyTypeTypes) { - if (memberDepth == 1) - policyTypes.add(policyTypeHandler.getResult()); - else - policyTypeHandler.endElement(uri, name, qName); - } - } - - /** - * {@inheritDoc} - */ - @Override - public void characters(char ch[], int start, int length) { - if (inPolicyTypeTypes) { - policyTypeHandler.characters(ch, start, length); - } else { - currentText.append(ch, start, length); - } - } - -} diff --git a/labs/elb/src/main/java/org/jclouds/elb/xml/DescribeLoadBalancersResultHandler.java b/labs/elb/src/main/java/org/jclouds/elb/xml/DescribeLoadBalancersResultHandler.java deleted file mode 100644 index 5f643d65f4..0000000000 --- a/labs/elb/src/main/java/org/jclouds/elb/xml/DescribeLoadBalancersResultHandler.java +++ /dev/null @@ -1,123 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.elb.xml; - -import static org.jclouds.util.SaxUtils.currentOrNull; -import static org.jclouds.util.SaxUtils.equalsOrSuffix; - -import java.util.Set; - -import org.jclouds.collect.IterableWithMarker; -import org.jclouds.collect.IterableWithMarkers; -import org.jclouds.elb.domain.LoadBalancer; -import org.jclouds.http.functions.ParseSax; -import org.xml.sax.Attributes; -import org.xml.sax.SAXException; - -import com.google.common.collect.Sets; -import com.google.inject.Inject; - -/** - * @see docs - * - * @author Adrian Cole - */ -public class DescribeLoadBalancersResultHandler extends - ParseSax.HandlerForGeneratedRequestWithResult> { - - private final LoadBalancerHandler loadBalancerHandler; - - private StringBuilder currentText = new StringBuilder(); - private Set loadBalancers = Sets.newLinkedHashSet(); - private boolean inLoadBalancers; - private String marker; - - protected int memberDepth; - - @Inject - public DescribeLoadBalancersResultHandler(LoadBalancerHandler loadBalancerHandler) { - this.loadBalancerHandler = loadBalancerHandler; - } - - /** - * {@inheritDoc} - */ - @Override - public IterableWithMarker getResult() { - return IterableWithMarkers.from(loadBalancers, marker); - } - - /** - * {@inheritDoc} - */ - @Override - public void startElement(String url, String name, String qName, Attributes attributes) throws SAXException { - if (equalsOrSuffix(qName, "member")) { - memberDepth++; - } else if (equalsOrSuffix(qName, "LoadBalancerDescriptions")) { - inLoadBalancers = true; - } - if (inLoadBalancers) { - loadBalancerHandler.startElement(url, name, qName, attributes); - } - } - - /** - * {@inheritDoc} - */ - @Override - public void endElement(String uri, String name, String qName) throws SAXException { - if (equalsOrSuffix(qName, "member")) { - endMember( uri, name, qName); - memberDepth--; - } else if (equalsOrSuffix(qName, "LoadBalancerDescriptions")) { - inLoadBalancers = false; - } else if (equalsOrSuffix(qName, "Marker")) { - marker = currentOrNull(currentText); - } else if (inLoadBalancers) { - loadBalancerHandler.endElement(uri, name, qName); - } - - currentText = new StringBuilder(); - } - - protected void endMember(String uri, String name, String qName) throws SAXException { - if (inLoadBalancers) { - if (memberDepth == 1) - loadBalancers.add(loadBalancerHandler.getResult()); - else - loadBalancerHandler.endElement(uri, name, qName); - } - } - - /** - * {@inheritDoc} - */ - @Override - public void characters(char ch[], int start, int length) { - if (inLoadBalancers) { - loadBalancerHandler.characters(ch, start, length); - } else { - currentText.append(ch, start, length); - } - } - -} diff --git a/labs/elb/src/main/java/org/jclouds/elb/xml/HealthCheckHandler.java b/labs/elb/src/main/java/org/jclouds/elb/xml/HealthCheckHandler.java deleted file mode 100644 index 7bab62e0df..0000000000 --- a/labs/elb/src/main/java/org/jclouds/elb/xml/HealthCheckHandler.java +++ /dev/null @@ -1,79 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.elb.xml; - -import static org.jclouds.util.SaxUtils.currentOrNull; -import static org.jclouds.util.SaxUtils.equalsOrSuffix; - -import org.jclouds.elb.domain.HealthCheck; -import org.jclouds.http.functions.ParseSax; -import org.xml.sax.SAXException; - -/** - * @see xml - * - * @author Adrian Cole - */ -public class HealthCheckHandler extends ParseSax.HandlerForGeneratedRequestWithResult { - - private StringBuilder currentText = new StringBuilder(); - private HealthCheck.Builder builder = HealthCheck.builder(); - - /** - * {@inheritDoc} - */ - @Override - public HealthCheck getResult() { - try { - return builder.build(); - } finally { - builder = HealthCheck.builder(); - } - } - - /** - * {@inheritDoc} - */ - @Override - public void endElement(String uri, String name, String qName) throws SAXException { - if (equalsOrSuffix(qName, "HealthyThreshold")) { - builder.healthyThreshold(Integer.parseInt(currentOrNull(currentText))); - } else if (equalsOrSuffix(qName, "Interval")) { - builder.interval(Integer.parseInt(currentOrNull(currentText))); - } else if (equalsOrSuffix(qName, "Target")) { - builder.target(currentOrNull(currentText)); - } else if (equalsOrSuffix(qName, "Timeout")) { - builder.timeout(Integer.parseInt(currentOrNull(currentText))); - } else if (equalsOrSuffix(qName, "UnhealthyThreshold")) { - builder.unhealthyThreshold(Integer.parseInt(currentOrNull(currentText))); - } - currentText = new StringBuilder(); - } - - /** - * {@inheritDoc} - */ - @Override - public void characters(char ch[], int start, int length) { - currentText.append(ch, start, length); - } - -} diff --git a/labs/elb/src/main/java/org/jclouds/elb/xml/InstanceStateHandler.java b/labs/elb/src/main/java/org/jclouds/elb/xml/InstanceStateHandler.java deleted file mode 100644 index 4df2752ed1..0000000000 --- a/labs/elb/src/main/java/org/jclouds/elb/xml/InstanceStateHandler.java +++ /dev/null @@ -1,77 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.elb.xml; - -import static org.jclouds.util.SaxUtils.currentOrNull; -import static org.jclouds.util.SaxUtils.equalsOrSuffix; - -import org.jclouds.elb.domain.InstanceHealth; -import org.jclouds.http.functions.ParseSax; -import org.xml.sax.SAXException; - -/** - * @see xml - * - * @author Adrian Cole - */ -public class InstanceStateHandler extends ParseSax.HandlerForGeneratedRequestWithResult { - - private StringBuilder currentText = new StringBuilder(); - private InstanceHealth.Builder builder = InstanceHealth.builder(); - - /** - * {@inheritDoc} - */ - @Override - public InstanceHealth getResult() { - try { - return builder.build(); - } finally { - builder = InstanceHealth.builder(); - } - } - - /** - * {@inheritDoc} - */ - @Override - public void endElement(String uri, String name, String qName) throws SAXException { - if (equalsOrSuffix(qName, "Description")) { - builder.description(currentOrNull(currentText)); - } else if (equalsOrSuffix(qName, "InstanceId")) { - builder.instanceId(currentOrNull(currentText)); - } else if (equalsOrSuffix(qName, "ReasonCode")) { - builder.reasonCode(currentOrNull(currentText)); - } else if (equalsOrSuffix(qName, "State")) { - builder.state(currentOrNull(currentText)); - } - currentText = new StringBuilder(); - } - - /** - * {@inheritDoc} - */ - @Override - public void characters(char ch[], int start, int length) { - currentText.append(ch, start, length); - } - -} diff --git a/labs/elb/src/main/java/org/jclouds/elb/xml/InstancesResultHandler.java b/labs/elb/src/main/java/org/jclouds/elb/xml/InstancesResultHandler.java deleted file mode 100644 index f2cc87a553..0000000000 --- a/labs/elb/src/main/java/org/jclouds/elb/xml/InstancesResultHandler.java +++ /dev/null @@ -1,46 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.elb.xml; - -import java.util.Set; - -import org.jclouds.http.functions.ParseSax; - -import com.google.common.collect.Sets; - -public class InstancesResultHandler extends ParseSax.HandlerWithResult> { - - private Set instanceIds = Sets.newLinkedHashSet(); - private StringBuilder currentText = new StringBuilder(); - - public void endElement(String uri, String localName, String qName) { - if (qName.equals("InstanceId")) - instanceIds.add(currentText.toString().trim()); - currentText = new StringBuilder(); - } - - @Override - public Set getResult() { - return instanceIds; - } - - public void characters(char ch[], int start, int length) { - currentText.append(ch, start, length); - } -} diff --git a/labs/elb/src/main/java/org/jclouds/elb/xml/ListenerWithPoliciesHandler.java b/labs/elb/src/main/java/org/jclouds/elb/xml/ListenerWithPoliciesHandler.java deleted file mode 100644 index efe94a1352..0000000000 --- a/labs/elb/src/main/java/org/jclouds/elb/xml/ListenerWithPoliciesHandler.java +++ /dev/null @@ -1,97 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.elb.xml; - -import static org.jclouds.util.SaxUtils.currentOrNull; -import static org.jclouds.util.SaxUtils.equalsOrSuffix; - -import org.jclouds.elb.domain.ListenerWithPolicies; -import org.jclouds.elb.domain.Protocol; -import org.jclouds.http.functions.ParseSax; -import org.xml.sax.Attributes; -import org.xml.sax.SAXException; - -/** - * @see xml - * - * @author Adrian Cole - */ -public class ListenerWithPoliciesHandler extends ParseSax.HandlerForGeneratedRequestWithResult { - - private StringBuilder currentText = new StringBuilder(); - private ListenerWithPolicies.Builder builder = ListenerWithPolicies.builder(); - - private boolean inPolicyNames; - - /** - * {@inheritDoc} - */ - @Override - public ListenerWithPolicies getResult() { - try { - return builder.build(); - } finally { - builder = ListenerWithPolicies.builder(); - } - } - - /** - * {@inheritDoc} - */ - @Override - public void startElement(String url, String name, String qName, Attributes attributes) throws SAXException { - if (equalsOrSuffix(qName, "PolicyNames")) { - inPolicyNames = true; - } - } - - /** - * {@inheritDoc} - */ - @Override - public void endElement(String uri, String name, String qName) throws SAXException { - if (equalsOrSuffix(qName, "PolicyNames")) { - inPolicyNames = false; - } else if (equalsOrSuffix(qName, "member") && inPolicyNames) { - builder.policyName(currentOrNull(currentText)); - } else if (equalsOrSuffix(qName, "InstancePort")) { - builder.instancePort(Integer.parseInt(currentOrNull(currentText))); - } else if (equalsOrSuffix(qName, "InstanceProtocol")) { - builder.instanceProtocol(Protocol.valueOf(currentOrNull(currentText))); - } else if (equalsOrSuffix(qName, "LoadBalancerPort")) { - builder.port(Integer.parseInt(currentOrNull(currentText))); - } else if (equalsOrSuffix(qName, "Protocol")) { - builder.protocol(Protocol.valueOf(currentOrNull(currentText))); - } else if (equalsOrSuffix(qName, "SSLCertificateId")) { - builder.SSLCertificateId(currentOrNull(currentText)); - } - currentText = new StringBuilder(); - } - - /** - * {@inheritDoc} - */ - @Override - public void characters(char ch[], int start, int length) { - currentText.append(ch, start, length); - } - -} diff --git a/labs/elb/src/main/java/org/jclouds/elb/xml/LoadBalancerHandler.java b/labs/elb/src/main/java/org/jclouds/elb/xml/LoadBalancerHandler.java deleted file mode 100644 index d4961bf7d3..0000000000 --- a/labs/elb/src/main/java/org/jclouds/elb/xml/LoadBalancerHandler.java +++ /dev/null @@ -1,182 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.elb.xml; - -import static org.jclouds.util.SaxUtils.currentOrNull; -import static org.jclouds.util.SaxUtils.equalsOrSuffix; - -import javax.inject.Inject; - -import org.jclouds.date.DateService; -import org.jclouds.elb.domain.LoadBalancer; -import org.jclouds.elb.domain.Scheme; -import org.jclouds.elb.domain.SecurityGroupAndOwner; -import org.jclouds.http.functions.ParseSax; -import org.xml.sax.Attributes; -import org.xml.sax.SAXException; - -/** - * @see - * - * @author Adrian Cole - */ -public class LoadBalancerHandler extends ParseSax.HandlerForGeneratedRequestWithResult { - protected final DateService dateService; - protected final HealthCheckHandler healthCheckHandler; - protected final ListenerWithPoliciesHandler listenerHandler; - - @Inject - protected LoadBalancerHandler(DateService dateService, HealthCheckHandler healthCheckHandler, ListenerWithPoliciesHandler listenerHandler) { - this.dateService = dateService; - this.healthCheckHandler = healthCheckHandler; - this.listenerHandler = listenerHandler; - } - - private StringBuilder currentText = new StringBuilder(); - private LoadBalancer.Builder builder = LoadBalancer.builder(); - private SecurityGroupAndOwner.Builder sourceSecurityGroupBuilder; - - private boolean inHealthCheck; - private boolean inListeners; - private boolean inAvailabilityZones; - private boolean inSecurityGroups; - private boolean inSubnets; - - protected int memberDepth; - - /** - * {@inheritDoc} - */ - @Override - public LoadBalancer getResult() { - try { - return builder.build(); - } finally { - builder = LoadBalancer.builder(); - } - } - - /** - * {@inheritDoc} - */ - @Override - public void startElement(String url, String name, String qName, Attributes attributes) throws SAXException { - if (equalsOrSuffix(qName, "member")) { - memberDepth++; - } else if (equalsOrSuffix(qName, "HealthCheck")) { - inHealthCheck = true; - } else if (equalsOrSuffix(qName, "ListenerDescriptions")) { - inListeners = true; - } else if (equalsOrSuffix(qName, "AvailabilityZones")) { - inAvailabilityZones = true; - } else if (equalsOrSuffix(qName, "SecurityGroups")) { - inSecurityGroups = true; - } else if (equalsOrSuffix(qName, "Subnets")) { - inSubnets = true; - } else if (equalsOrSuffix(qName, "SourceSecurityGroup")) { - sourceSecurityGroupBuilder = SecurityGroupAndOwner.builder(); - } - - if (inListeners) { - listenerHandler.startElement(url, name, qName, attributes); - } - } - - /** - * {@inheritDoc} - */ - @Override - public void endElement(String uri, String name, String qName) throws SAXException { - if (equalsOrSuffix(qName, "member")) { - endMember(uri, name, qName); - memberDepth--; - } else if (equalsOrSuffix(qName, "ListenerDescriptions")) { - inListeners = false; - } else if (equalsOrSuffix(qName, "AvailabilityZones")) { - inAvailabilityZones = false; - } else if (equalsOrSuffix(qName, "SecurityGroups")) { - inSecurityGroups = false; - } else if (equalsOrSuffix(qName, "Subnets")) { - inSubnets = false; - } else if (equalsOrSuffix(qName, "HealthCheck")) { - builder.healthCheck(healthCheckHandler.getResult()); - inHealthCheck = false; - } else if (equalsOrSuffix(qName, "SourceSecurityGroup")) { - if (sourceSecurityGroupBuilder != null) - builder.sourceSecurityGroup(sourceSecurityGroupBuilder.build()); - sourceSecurityGroupBuilder = null; - } else if (equalsOrSuffix(qName, "LoadBalancerName")) { - builder.name(currentOrNull(currentText)); - } else if (equalsOrSuffix(qName, "CreatedTime")) { - builder.createdTime(dateService.iso8601DateParse(currentOrNull(currentText))); - } else if (equalsOrSuffix(qName, "DNSName")) { - builder.dnsName(currentOrNull(currentText)); - } else if (equalsOrSuffix(qName, "InstanceId")) { - builder.instanceId(currentOrNull(currentText)); - } else if (equalsOrSuffix(qName, "GroupName")) { - sourceSecurityGroupBuilder.name(currentOrNull(currentText)); - } else if (equalsOrSuffix(qName, "OwnerAlias")) { - sourceSecurityGroupBuilder.owner(currentOrNull(currentText)); - } else if (equalsOrSuffix(qName, "Scheme")) { - builder.scheme(Scheme.fromValue(currentOrNull(currentText))); - } else if (equalsOrSuffix(qName, "VPCId")) { - builder.VPCId(currentOrNull(currentText)); - } else if (equalsOrSuffix(qName, "CanonicalHostedZoneName")) { - builder.hostedZoneName(currentOrNull(currentText)); - } else if (equalsOrSuffix(qName, "CanonicalHostedZoneNameID")) { - builder.hostedZoneId(currentOrNull(currentText)); - } else if (inHealthCheck) { - healthCheckHandler.endElement(uri, name, qName); - } else if (inListeners) { - listenerHandler.endElement(uri, name, qName); - } - currentText = new StringBuilder(); - } - - protected void endMember(String uri, String name, String qName) throws SAXException { - if (inListeners) { - if (memberDepth == 2) - builder.listener(listenerHandler.getResult()); - else - listenerHandler.endElement(uri, name, qName); - } else if (inAvailabilityZones) { - builder.availabilityZone(currentOrNull(currentText)); - } else if (inSecurityGroups) { - builder.securityGroup(currentOrNull(currentText)); - } else if (inSubnets) { - builder.subnet(currentOrNull(currentText)); - } - } - - /** - * {@inheritDoc} - */ - @Override - public void characters(char ch[], int start, int length) { - if (inListeners) { - listenerHandler.characters(ch, start, length); - } else if (inHealthCheck) { - healthCheckHandler.characters(ch, start, length); - } else { - currentText.append(ch, start, length); - } - } - -} diff --git a/labs/elb/src/main/java/org/jclouds/elb/xml/PolicyHandler.java b/labs/elb/src/main/java/org/jclouds/elb/xml/PolicyHandler.java deleted file mode 100644 index edd1ad2e03..0000000000 --- a/labs/elb/src/main/java/org/jclouds/elb/xml/PolicyHandler.java +++ /dev/null @@ -1,87 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.elb.xml; - -import static org.jclouds.util.SaxUtils.currentOrNull; -import static org.jclouds.util.SaxUtils.equalsOrSuffix; - -import org.jclouds.elb.domain.Policy; -import org.jclouds.http.functions.ParseSax; -import org.xml.sax.SAXException; - -import com.google.common.primitives.Ints; - -/** - * @see xml - * - * @author Adrian Cole - */ -public class PolicyHandler extends ParseSax.HandlerForGeneratedRequestWithResult { - - private StringBuilder currentText = new StringBuilder(); - private Policy.Builder builder = Policy.builder(); - private String key; - - /** - * {@inheritDoc} - */ - @Override - public Policy getResult() { - try { - return builder.build(); - } finally { - builder = Policy.builder(); - } - } - - /** - * {@inheritDoc} - */ - @Override - public void endElement(String uri, String name, String qName) throws SAXException { - if (equalsOrSuffix(qName, "PolicyName")) { - builder.name(currentOrNull(currentText)); - } else if (equalsOrSuffix(qName, "PolicyTypeName")) { - builder.typeName(currentOrNull(currentText)); - } else if (equalsOrSuffix(qName, "AttributeName")) { - key = currentOrNull(currentText); - } else if (equalsOrSuffix(qName, "AttributeValue")) { - String value = currentOrNull(currentText); - if ("true".equalsIgnoreCase(value) || "false".equalsIgnoreCase(value)) - builder.attribute(key, Boolean.valueOf(value)); - else if (Ints.tryParse(value) != null) - builder.attribute(key, Long.valueOf(value)); - else - builder.attribute(key, value); - key = null; - } - currentText = new StringBuilder(); - } - - /** - * {@inheritDoc} - */ - @Override - public void characters(char ch[], int start, int length) { - currentText.append(ch, start, length); - } - -} diff --git a/labs/elb/src/main/java/org/jclouds/elb/xml/PolicyTypeHandler.java b/labs/elb/src/main/java/org/jclouds/elb/xml/PolicyTypeHandler.java deleted file mode 100644 index 8f9441f6c4..0000000000 --- a/labs/elb/src/main/java/org/jclouds/elb/xml/PolicyTypeHandler.java +++ /dev/null @@ -1,113 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.elb.xml; - -import static org.jclouds.util.SaxUtils.currentOrNull; -import static org.jclouds.util.SaxUtils.equalsOrSuffix; - -import javax.inject.Inject; - -import org.jclouds.elb.domain.PolicyType; -import org.jclouds.http.functions.ParseSax; -import org.xml.sax.Attributes; -import org.xml.sax.SAXException; - -/** - * @see doc - * - * @author Adrian Cole - */ -public class PolicyTypeHandler extends ParseSax.HandlerForGeneratedRequestWithResult { - protected final AttributeMetadataHandler attributeTypeHandler; - - @Inject - protected PolicyTypeHandler(AttributeMetadataHandler attributeTypeHandler) { - this.attributeTypeHandler = attributeTypeHandler; - } - - private StringBuilder currentText = new StringBuilder(); - private PolicyType.Builder builder = PolicyType.builder(); - - private boolean inAttributeTypes; - - /** - * {@inheritDoc} - */ - @Override - public PolicyType getResult() { - try { - return builder.build(); - } finally { - builder = PolicyType.builder(); - } - } - - /** - * {@inheritDoc} - */ - @Override - public void startElement(String url, String name, String qName, Attributes attributes) throws SAXException { - if (equalsOrSuffix(qName, "PolicyAttributeTypeDescriptions")) { - inAttributeTypes = true; - } - if (inAttributeTypes) { - attributeTypeHandler.startElement(url, name, qName, attributes); - } - } - - /** - * {@inheritDoc} - */ - @Override - public void endElement(String uri, String name, String qName) throws SAXException { - if (equalsOrSuffix(qName, "member")) { - endMember(uri, name, qName); - } else if (equalsOrSuffix(qName, "PolicyAttributeTypeDescriptions")) { - inAttributeTypes = false; - } else if (equalsOrSuffix(qName, "PolicyTypeName")) { - builder.name(currentOrNull(currentText)); - } else if (equalsOrSuffix(qName, "Description")) { - builder.description(currentOrNull(currentText)); - } else if (inAttributeTypes) { - attributeTypeHandler.endElement(uri, name, qName); - } - currentText = new StringBuilder(); - } - - protected void endMember(String uri, String name, String qName) throws SAXException { - if (inAttributeTypes) { - builder.attributeMetadata(attributeTypeHandler.getResult()); - } - } - - /** - * {@inheritDoc} - */ - @Override - public void characters(char ch[], int start, int length) { - if (inAttributeTypes) { - attributeTypeHandler.characters(ch, start, length); - } else { - currentText.append(ch, start, length); - } - } - -} diff --git a/labs/elb/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata b/labs/elb/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata deleted file mode 100644 index 612af6e1c7..0000000000 --- a/labs/elb/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata +++ /dev/null @@ -1 +0,0 @@ -org.jclouds.elb.ELBApiMetadata \ No newline at end of file diff --git a/labs/elb/src/test/java/org/jclouds/elb/ELBApiMetadataTest.java b/labs/elb/src/test/java/org/jclouds/elb/ELBApiMetadataTest.java deleted file mode 100644 index b0fc95098e..0000000000 --- a/labs/elb/src/test/java/org/jclouds/elb/ELBApiMetadataTest.java +++ /dev/null @@ -1,34 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.elb; - -import org.jclouds.loadbalancer.internal.BaseLoadBalancerServiceApiMetadataTest; -import org.testng.annotations.Test; - -/** - * - * @author Adrian Cole - */ -@Test(groups = "unit", testName = "ELBApiMetadataTest") -public class ELBApiMetadataTest extends BaseLoadBalancerServiceApiMetadataTest { - - public ELBApiMetadataTest() { - super(new ELBApiMetadata()); - } -} diff --git a/labs/elb/src/test/java/org/jclouds/elb/features/AvailabilityZoneApiExpectTest.java b/labs/elb/src/test/java/org/jclouds/elb/features/AvailabilityZoneApiExpectTest.java deleted file mode 100644 index 1230bf7bbc..0000000000 --- a/labs/elb/src/test/java/org/jclouds/elb/features/AvailabilityZoneApiExpectTest.java +++ /dev/null @@ -1,211 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unles required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either expres or implied. See the License for the - * specific language governing permisions and limitations - * under the License. - */ -package org.jclouds.elb.features; - -import static org.testng.Assert.assertEquals; - -import java.util.TimeZone; - -import org.jclouds.elb.ELBApi; -import org.jclouds.elb.internal.BaseELBApiExpectTest; -import org.jclouds.elb.parse.AvailabilityZonesResultHandlerTest; -import org.jclouds.http.HttpRequest; -import org.jclouds.http.HttpResponse; -import org.jclouds.rest.ResourceNotFoundException; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableSet; - -/** - * @author Adrian Cole - */ -@Test(groups = "unit", testName = "AvailabilityZoneApiExpectTest") -public class AvailabilityZoneApiExpectTest extends BaseELBApiExpectTest { - - public AvailabilityZoneApiExpectTest() { - TimeZone.setDefault(TimeZone.getTimeZone("America/Los_Angeles")); - } - - HttpRequest addZoneToLoadBalancer = HttpRequest.builder() - .method("POST") - .endpoint("https://elasticloadbalancing.us-east-1.amazonaws.com/") - .addHeader("Host", "elasticloadbalancing.us-east-1.amazonaws.com") - .payload( - payloadFromStringWithContentType( - "Action=EnableAvailabilityZonesForLoadBalancer" + - "&AvailabilityZones.member.1=us-east-1a" + - "&LoadBalancerName=name" + - "&Signature=lay8JNIpYsgWjiTbA4/rgKrQPWhFKToPxw/fCLld4SE%3D" + - "&SignatureMethod=HmacSHA256" + - "&SignatureVersion=2" + - "&Timestamp=2009-11-08T15%3A54%3A08.897Z" + - "&Version=2012-06-01" + - "&AWSAccessKeyId=identity", - "application/x-www-form-urlencoded")) - .build(); - - - public void testAddZoneToLoadBalancerWhenResponseIs2xx() throws Exception { - - HttpResponse getResponse = HttpResponse.builder().statusCode(200) - .payload(payloadFromResourceWithContentType("/zones.xml", "text/xml")).build(); - - ELBApi apiWhenExist = requestSendsResponse( - addZoneToLoadBalancer, getResponse); - - assertEquals(apiWhenExist.getAvailabilityZoneApi().addAvailabilityZoneToLoadBalancer("us-east-1a", "name").toString(), new AvailabilityZonesResultHandlerTest().expected().toString()); - } - - @Test(expectedExceptions = ResourceNotFoundException.class) - public void testAddZoneToLoadBalancerWhenResponseIs404() throws Exception { - - HttpResponse getResponse = HttpResponse.builder().statusCode(404).build(); - - ELBApi apiWhenDontExist = requestSendsResponse( - addZoneToLoadBalancer, getResponse); - - apiWhenDontExist.getAvailabilityZoneApi().addAvailabilityZoneToLoadBalancer("us-east-1a", "name"); - } - - HttpRequest addZonesToLoadBalancer = HttpRequest.builder() - .method("POST") - .endpoint("https://elasticloadbalancing.us-east-1.amazonaws.com/") - .addHeader("Host", "elasticloadbalancing.us-east-1.amazonaws.com") - .payload( - payloadFromStringWithContentType( - "Action=EnableAvailabilityZonesForLoadBalancer" + - "&AvailabilityZones.member.1=us-east-1a" + - "&AvailabilityZones.member.2=us-east-1b" + - "&LoadBalancerName=name" + - "&Signature=RAX1VLJU30B47RFUiywtknhgD2DxZygJ2niOO4UnW3U%3D" + - "&SignatureMethod=HmacSHA256" + - "&SignatureVersion=2" + - "&Timestamp=2009-11-08T15%3A54%3A08.897Z" + - "&Version=2012-06-01" + - "&AWSAccessKeyId=identity", - "application/x-www-form-urlencoded")) - .build(); - - - public void testAddZonesToLoadBalancerWhenResponseIs2xx() throws Exception { - - HttpResponse getResponse = HttpResponse.builder().statusCode(200) - .payload(payloadFromResourceWithContentType("/zones.xml", "text/xml")).build(); - - ELBApi apiWhenExist = requestSendsResponse(addZonesToLoadBalancer, getResponse); - - assertEquals( - apiWhenExist.getAvailabilityZoneApi().addAvailabilityZonesToLoadBalancer(ImmutableSet.of("us-east-1a", "us-east-1b"), "name") - .toString(), new AvailabilityZonesResultHandlerTest().expected().toString()); - } - - @Test(expectedExceptions = ResourceNotFoundException.class) - public void testAddZonesToLoadBalancerWhenResponseIs404() throws Exception { - - HttpResponse getResponse = HttpResponse.builder().statusCode(404).build(); - - ELBApi apiWhenDontExist = requestSendsResponse(addZonesToLoadBalancer, getResponse); - - apiWhenDontExist.getAvailabilityZoneApi().addAvailabilityZonesToLoadBalancer(ImmutableSet.of("us-east-1a", "us-east-1b"), "name"); - } - - - HttpRequest removeZoneFromLoadBalancer = HttpRequest.builder() - .method("POST") - .endpoint("https://elasticloadbalancing.us-east-1.amazonaws.com/") - .addHeader("Host", "elasticloadbalancing.us-east-1.amazonaws.com") - .payload( - payloadFromStringWithContentType( - "Action=DisableAvailabilityZonesForLoadBalancer" + - "&AvailabilityZones.member.1=us-east-1a" + - "&LoadBalancerName=name" + - "&Signature=tjzaFDhUghKwTpe/9OC8JK%2BJsRMCkF3Kh5YkvPEDPbg%3D" + - "&SignatureMethod=HmacSHA256" + - "&SignatureVersion=2" + - "&Timestamp=2009-11-08T15%3A54%3A08.897Z" + - "&Version=2012-06-01" + - "&AWSAccessKeyId=identity", - "application/x-www-form-urlencoded")) - .build(); - - - public void testRemoveZoneFromLoadBalancerWhenResponseIs2xx() throws Exception { - - HttpResponse getResponse = HttpResponse.builder().statusCode(200) - .payload(payloadFromResourceWithContentType("/zones.xml", "text/xml")).build(); - - ELBApi apiWhenExist = requestSendsResponse( - removeZoneFromLoadBalancer, getResponse); - - assertEquals(apiWhenExist.getAvailabilityZoneApi().removeAvailabilityZoneFromLoadBalancer("us-east-1a", "name").toString(), new AvailabilityZonesResultHandlerTest().expected().toString()); - } - - @Test(expectedExceptions = ResourceNotFoundException.class) - public void testRemoveZoneFromLoadBalancerWhenResponseIs404() throws Exception { - - HttpResponse getResponse = HttpResponse.builder().statusCode(404).build(); - - ELBApi apiWhenDontExist = requestSendsResponse( - removeZoneFromLoadBalancer, getResponse); - - apiWhenDontExist.getAvailabilityZoneApi().removeAvailabilityZoneFromLoadBalancer("us-east-1a", "name"); - } - - HttpRequest removeZonesFromLoadBalancer = HttpRequest.builder() - .method("POST") - .endpoint("https://elasticloadbalancing.us-east-1.amazonaws.com/") - .addHeader("Host", "elasticloadbalancing.us-east-1.amazonaws.com") - .payload( - payloadFromStringWithContentType( - "Action=DisableAvailabilityZonesForLoadBalancer" + - "&AvailabilityZones.member.1=us-east-1a" + - "&AvailabilityZones.member.2=us-east-1b" + - "&LoadBalancerName=name" + - "&Signature=5yUJQXjfntl0ptL%2BDv3p2jYpDSr%2BmV8hASIS7wtvkOI%3D" + - "&SignatureMethod=HmacSHA256" + - "&SignatureVersion=2" + - "&Timestamp=2009-11-08T15%3A54%3A08.897Z" + - "&Version=2012-06-01" + - "&AWSAccessKeyId=identity", - "application/x-www-form-urlencoded")) - .build(); - - - public void testRemoveZonesFromLoadBalancerWhenResponseIs2xx() throws Exception { - - HttpResponse getResponse = HttpResponse.builder().statusCode(200) - .payload(payloadFromResourceWithContentType("/zones.xml", "text/xml")).build(); - - ELBApi apiWhenExist = requestSendsResponse(removeZonesFromLoadBalancer, getResponse); - - assertEquals( - apiWhenExist.getAvailabilityZoneApi().removeAvailabilityZonesFromLoadBalancer(ImmutableSet.of("us-east-1a", "us-east-1b"), "name") - .toString(), new AvailabilityZonesResultHandlerTest().expected().toString()); - } - - @Test(expectedExceptions = ResourceNotFoundException.class) - public void testRemoveZonesFromLoadBalancerWhenResponseIs404() throws Exception { - - HttpResponse getResponse = HttpResponse.builder().statusCode(404).build(); - - ELBApi apiWhenDontExist = requestSendsResponse(removeZonesFromLoadBalancer, getResponse); - - apiWhenDontExist.getAvailabilityZoneApi().removeAvailabilityZonesFromLoadBalancer(ImmutableSet.of("us-east-1a", "us-east-1b"), "name"); - } -} diff --git a/labs/elb/src/test/java/org/jclouds/elb/features/AvailabilityZoneApiLiveTest.java b/labs/elb/src/test/java/org/jclouds/elb/features/AvailabilityZoneApiLiveTest.java deleted file mode 100644 index 0674cf171d..0000000000 --- a/labs/elb/src/test/java/org/jclouds/elb/features/AvailabilityZoneApiLiveTest.java +++ /dev/null @@ -1,33 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.elb.features; - -import org.jclouds.elb.internal.BaseELBApiLiveTest; -import org.testng.annotations.Test; - -/** - * @author Adrian Cole - */ -@Test(groups = "live", testName = "AvailabilityZoneApiLiveTest") -public class AvailabilityZoneApiLiveTest extends BaseELBApiLiveTest { - - protected AvailabilityZoneApi api() { - return context.getApi().getAvailabilityZoneApi(); - } -} diff --git a/labs/elb/src/test/java/org/jclouds/elb/features/InstanceApiExpectTest.java b/labs/elb/src/test/java/org/jclouds/elb/features/InstanceApiExpectTest.java deleted file mode 100644 index 5a05d69247..0000000000 --- a/labs/elb/src/test/java/org/jclouds/elb/features/InstanceApiExpectTest.java +++ /dev/null @@ -1,251 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unles required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either expres or implied. See the License for the - * specific language governing permisions and limitations - * under the License. - */ -package org.jclouds.elb.features; - -import static org.testng.Assert.assertEquals; - -import java.util.TimeZone; - -import org.jclouds.elb.ELBApi; -import org.jclouds.elb.internal.BaseELBApiExpectTest; -import org.jclouds.elb.parse.DescribeInstanceHealthResponseTest; -import org.jclouds.elb.parse.InstancesResultHandlerTest; -import org.jclouds.http.HttpRequest; -import org.jclouds.http.HttpResponse; -import org.jclouds.rest.ResourceNotFoundException; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableSet; - -/** - * @author Adrian Cole - */ -@Test(groups = "unit", testName = "InstanceApiExpectTest") -public class InstanceApiExpectTest extends BaseELBApiExpectTest { - - public InstanceApiExpectTest() { - TimeZone.setDefault(TimeZone.getTimeZone("America/Los_Angeles")); - } - - HttpRequest get = HttpRequest.builder() - .method("POST") - .endpoint("https://elasticloadbalancing.us-east-1.amazonaws.com/") - .addHeader("Host", "elasticloadbalancing.us-east-1.amazonaws.com") - .payload( - payloadFromStringWithContentType( - "Action=DescribeInstanceHealth" + - "&LoadBalancerName=name" + - "&Signature=zIwSuvkooYRNPLyDrPCF8%2BbMLA8t0n9hIlS6K2aahuA%3D" + - "&SignatureMethod=HmacSHA256" + - "&SignatureVersion=2" + - "&Timestamp=2009-11-08T15%3A54%3A08.897Z" + - "&Version=2012-06-01" + - "&AWSAccessKeyId=identity", - "application/x-www-form-urlencoded")) - .build(); - - - public void testGetHealthOfInstancesOfLoadBalancerIs2xx() throws Exception { - - HttpResponse getResponse = HttpResponse.builder().statusCode(200) - .payload(payloadFromResourceWithContentType("/describe_instancehealth.xml", "text/xml")).build(); - - ELBApi apiWhenExist = requestSendsResponse( - get, getResponse); - - assertEquals(apiWhenExist.getInstanceApi().getHealthOfInstancesOfLoadBalancer("name").toString(), new DescribeInstanceHealthResponseTest().expected().toString()); - } - - public void testGetHealthOfInstancesOfLoadBalancerWhenResponseIs404() throws Exception { - - HttpResponse getResponse = HttpResponse.builder().statusCode(404).build(); - - ELBApi apiWhenDontExist = requestSendsResponse( - get, getResponse); - - assertEquals(apiWhenDontExist.getInstanceApi().getHealthOfInstancesOfLoadBalancer("name"), ImmutableSet.of()); - } - - HttpRequest registerInstanceWithLoadBalancer = HttpRequest.builder() - .method("POST") - .endpoint("https://elasticloadbalancing.us-east-1.amazonaws.com/") - .addHeader("Host", "elasticloadbalancing.us-east-1.amazonaws.com") - .payload( - payloadFromStringWithContentType( - "Action=RegisterInstancesWithLoadBalancer" + - "&Instances.member.1.InstanceId=i-6055fa09" + - "&LoadBalancerName=name" + - "&Signature=YRYjrZGMNoeyghtfKvbMZbRrbIgCuxsCQeYdtai0chY%3D" + - "&SignatureMethod=HmacSHA256" + - "&SignatureVersion=2" + - "&Timestamp=2009-11-08T15%3A54%3A08.897Z" + - "&Version=2012-06-01" + - "&AWSAccessKeyId=identity", - "application/x-www-form-urlencoded")) - .build(); - - - public void testRegisterInstanceWithLoadBalancerWhenResponseIs2xx() throws Exception { - - HttpResponse getResponse = HttpResponse.builder().statusCode(200) - .payload(payloadFromResourceWithContentType("/instances.xml", "text/xml")).build(); - - ELBApi apiWhenExist = requestSendsResponse( - registerInstanceWithLoadBalancer, getResponse); - - assertEquals(apiWhenExist.getInstanceApi().registerInstanceWithLoadBalancer("i-6055fa09", "name").toString(), new InstancesResultHandlerTest().expected().toString()); - } - - @Test(expectedExceptions = ResourceNotFoundException.class) - public void testRegisterInstanceWithLoadBalancerWhenResponseIs404() throws Exception { - - HttpResponse getResponse = HttpResponse.builder().statusCode(404).build(); - - ELBApi apiWhenDontExist = requestSendsResponse( - registerInstanceWithLoadBalancer, getResponse); - - apiWhenDontExist.getInstanceApi().registerInstanceWithLoadBalancer("i-6055fa09", "name"); - } - - HttpRequest registerInstancesWithLoadBalancer = HttpRequest.builder() - .method("POST") - .endpoint("https://elasticloadbalancing.us-east-1.amazonaws.com/") - .addHeader("Host", "elasticloadbalancing.us-east-1.amazonaws.com") - .payload( - payloadFromStringWithContentType( - "Action=RegisterInstancesWithLoadBalancer" + - "&Instances.member.1.InstanceId=i-6055fa09" + - "&Instances.member.2.InstanceId=i-9055fa55" + - "&LoadBalancerName=name" + - "&Signature=Yfqg8TxL1J1Ug8SimY/30rnbt/UVygTEa0vhMT5Fz1Y%3D" + - "&SignatureMethod=HmacSHA256" + - "&SignatureVersion=2" + - "&Timestamp=2009-11-08T15%3A54%3A08.897Z" + - "&Version=2012-06-01" + - "&AWSAccessKeyId=identity", - "application/x-www-form-urlencoded")) - .build(); - - - public void testRegisterInstancesWithLoadBalancerWhenResponseIs2xx() throws Exception { - - HttpResponse getResponse = HttpResponse.builder().statusCode(200) - .payload(payloadFromResourceWithContentType("/instances.xml", "text/xml")).build(); - - ELBApi apiWhenExist = requestSendsResponse(registerInstancesWithLoadBalancer, getResponse); - - assertEquals( - apiWhenExist.getInstanceApi().registerInstancesWithLoadBalancer(ImmutableSet.of("i-6055fa09", "i-9055fa55"), "name") - .toString(), new InstancesResultHandlerTest().expected().toString()); - } - - @Test(expectedExceptions = ResourceNotFoundException.class) - public void testRegisterInstancesWithLoadBalancerWhenResponseIs404() throws Exception { - - HttpResponse getResponse = HttpResponse.builder().statusCode(404).build(); - - ELBApi apiWhenDontExist = requestSendsResponse(registerInstancesWithLoadBalancer, getResponse); - - apiWhenDontExist.getInstanceApi().registerInstancesWithLoadBalancer(ImmutableSet.of("i-6055fa09", "i-9055fa55"), "name"); - } - - - HttpRequest deregisterInstanceFromLoadBalancer = HttpRequest.builder() - .method("POST") - .endpoint("https://elasticloadbalancing.us-east-1.amazonaws.com/") - .addHeader("Host", "elasticloadbalancing.us-east-1.amazonaws.com") - .payload( - payloadFromStringWithContentType( - "Action=DeregisterInstancesFromLoadBalancer" + - "&Instances.member.1.InstanceId=i-6055fa09" + - "&LoadBalancerName=name" + - "&Signature=d%2BK6b2ggJLEekW8wLyRnm/pcEpZvc8VNI/W0bpYBGUk%3D" + - "&SignatureMethod=HmacSHA256" + - "&SignatureVersion=2" + - "&Timestamp=2009-11-08T15%3A54%3A08.897Z" + - "&Version=2012-06-01" + - "&AWSAccessKeyId=identity", - "application/x-www-form-urlencoded")) - .build(); - - - public void testDeregisterInstanceFromLoadBalancerWhenResponseIs2xx() throws Exception { - - HttpResponse getResponse = HttpResponse.builder().statusCode(200) - .payload(payloadFromResourceWithContentType("/instances.xml", "text/xml")).build(); - - ELBApi apiWhenExist = requestSendsResponse( - deregisterInstanceFromLoadBalancer, getResponse); - - assertEquals(apiWhenExist.getInstanceApi().deregisterInstanceFromLoadBalancer("i-6055fa09", "name").toString(), new InstancesResultHandlerTest().expected().toString()); - } - - @Test(expectedExceptions = ResourceNotFoundException.class) - public void testDeregisterInstanceFromLoadBalancerWhenResponseIs404() throws Exception { - - HttpResponse getResponse = HttpResponse.builder().statusCode(404).build(); - - ELBApi apiWhenDontExist = requestSendsResponse( - deregisterInstanceFromLoadBalancer, getResponse); - - apiWhenDontExist.getInstanceApi().deregisterInstanceFromLoadBalancer("i-6055fa09", "name"); - } - - HttpRequest deregisterInstancesFromLoadBalancer = HttpRequest.builder() - .method("POST") - .endpoint("https://elasticloadbalancing.us-east-1.amazonaws.com/") - .addHeader("Host", "elasticloadbalancing.us-east-1.amazonaws.com") - .payload( - payloadFromStringWithContentType( - "Action=DeregisterInstancesFromLoadBalancer" + - "&Instances.member.1.InstanceId=i-6055fa09" + - "&Instances.member.2.InstanceId=i-9055fa55" + - "&LoadBalancerName=name" + - "&Signature=nqn8iH70979k/u/KXEcMlT1Zd/PaNK6ZBwFDjvbuMRo%3D" + - "&SignatureMethod=HmacSHA256" + - "&SignatureVersion=2" + - "&Timestamp=2009-11-08T15%3A54%3A08.897Z" + - "&Version=2012-06-01" + - "&AWSAccessKeyId=identity", - "application/x-www-form-urlencoded")) - .build(); - - - public void testDeregisterInstancesFromLoadBalancerWhenResponseIs2xx() throws Exception { - - HttpResponse getResponse = HttpResponse.builder().statusCode(200) - .payload(payloadFromResourceWithContentType("/instances.xml", "text/xml")).build(); - - ELBApi apiWhenExist = requestSendsResponse(deregisterInstancesFromLoadBalancer, getResponse); - - assertEquals( - apiWhenExist.getInstanceApi().deregisterInstancesFromLoadBalancer(ImmutableSet.of("i-6055fa09", "i-9055fa55"), "name") - .toString(), new InstancesResultHandlerTest().expected().toString()); - } - - @Test(expectedExceptions = ResourceNotFoundException.class) - public void testDeregisterInstancesFromLoadBalancerWhenResponseIs404() throws Exception { - - HttpResponse getResponse = HttpResponse.builder().statusCode(404).build(); - - ELBApi apiWhenDontExist = requestSendsResponse(deregisterInstancesFromLoadBalancer, getResponse); - - apiWhenDontExist.getInstanceApi().deregisterInstancesFromLoadBalancer(ImmutableSet.of("i-6055fa09", "i-9055fa55"), "name"); - } -} diff --git a/labs/elb/src/test/java/org/jclouds/elb/features/InstanceApiLiveTest.java b/labs/elb/src/test/java/org/jclouds/elb/features/InstanceApiLiveTest.java deleted file mode 100644 index d040819144..0000000000 --- a/labs/elb/src/test/java/org/jclouds/elb/features/InstanceApiLiveTest.java +++ /dev/null @@ -1,70 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.elb.features; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.Set; - -import org.jclouds.elb.domain.InstanceHealth; -import org.jclouds.elb.domain.LoadBalancer; -import org.jclouds.elb.internal.BaseELBApiLiveTest; -import org.testng.Assert; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Iterables; - -/** - * @author Adrian Cole - */ -@Test(groups = "live", testName = "InstanceApiLiveTest") -public class InstanceApiLiveTest extends BaseELBApiLiveTest { - - private void checkInstanceState(InstanceHealth instanceState) { - checkNotNull(instanceState.getDescription(), "Description cannot be null for InstanceState"); - checkNotNull(instanceState.getInstanceId(), "InstanceId cannot be null for InstanceState"); - checkNotNull(instanceState.getReasonCode(), - "While ReasonCode can be null for InstanceState, its Optional wrapper cannot"); - checkNotNull(instanceState.getState(), "State cannot be null for InstanceState"); - } - - @Test - protected void testListInstanceStates() { - for (LoadBalancer loadBalancer : Iterables.concat(context.getApi().getLoadBalancerApi().list())) { - Set response = api().getHealthOfInstancesOfLoadBalancer(loadBalancer.getName()); - - for (InstanceHealth instanceState : response) { - checkInstanceState(instanceState); - } - - if (response.size() > 0) { - InstanceHealth instanceState = response.iterator().next(); - Assert.assertEquals( - ImmutableSet.of(api().getHealthOfInstancesOfLoadBalancer(ImmutableSet.of(instanceState.getInstanceId()), - loadBalancer.getName())), instanceState); - } - } - - } - - protected InstanceApi api() { - return context.getApi().getInstanceApi(); - } -} diff --git a/labs/elb/src/test/java/org/jclouds/elb/features/LoadBalancerApiExpectTest.java b/labs/elb/src/test/java/org/jclouds/elb/features/LoadBalancerApiExpectTest.java deleted file mode 100644 index f73401b1cb..0000000000 --- a/labs/elb/src/test/java/org/jclouds/elb/features/LoadBalancerApiExpectTest.java +++ /dev/null @@ -1,272 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unles required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either expres or implied. See the License for the - * specific language governing permisions and limitations - * under the License. - */ -package org.jclouds.elb.features; - -import static org.jclouds.elb.options.ListLoadBalancersOptions.Builder.afterMarker; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNull; - -import java.util.TimeZone; - -import org.jclouds.elb.ELBApi; -import org.jclouds.elb.domain.LoadBalancer; -import org.jclouds.elb.internal.BaseELBApiExpectTest; -import org.jclouds.elb.parse.DescribeLoadBalancersResponseTest; -import org.jclouds.elb.parse.GetLoadBalancerResponseTest; -import org.jclouds.http.HttpRequest; -import org.jclouds.http.HttpResponse; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Iterables; - -/** - * @author Adrian Cole - */ -@Test(groups = "unit", testName = "LoadBalancerApiExpectTest") -public class LoadBalancerApiExpectTest extends BaseELBApiExpectTest { - - public LoadBalancerApiExpectTest() { - TimeZone.setDefault(TimeZone.getTimeZone("America/Los_Angeles")); - } - - HttpRequest get = HttpRequest.builder() - .method("POST") - .endpoint("https://elasticloadbalancing.us-east-1.amazonaws.com/") - .addHeader("Host", "elasticloadbalancing.us-east-1.amazonaws.com") - .payload( - payloadFromStringWithContentType( - "Action=DescribeLoadBalancers" + - "&LoadBalancerNames.member.1=name" + - "&Signature=EYzZgYDMGi9uFZU%2BVh/mmsJ9KmHxm5vEAF%2BhGF12BP4%3D" + - "&SignatureMethod=HmacSHA256" + - "&SignatureVersion=2" + - "&Timestamp=2009-11-08T15%3A54%3A08.897Z" + - "&Version=2012-06-01" + - "&AWSAccessKeyId=identity", - "application/x-www-form-urlencoded")) - .build(); - - - public void testGetWhenResponseIs2xx() throws Exception { - - HttpResponse getResponse = HttpResponse.builder().statusCode(200) - .payload(payloadFromResourceWithContentType("/describe_loadbalancers.xml", "text/xml")).build(); - - ELBApi apiWhenExist = requestSendsResponse( - get, getResponse); - - assertEquals(apiWhenExist.getLoadBalancerApi().get("name").toString(), new GetLoadBalancerResponseTest().expected().toString()); - } - - public void testGetWhenResponseIs404() throws Exception { - - HttpResponse getResponse = HttpResponse.builder().statusCode(404).build(); - - ELBApi apiWhenDontExist = requestSendsResponse( - get, getResponse); - - assertNull(apiWhenDontExist.getLoadBalancerApi().get("name")); - } - - HttpRequest list = HttpRequest.builder() - .method("POST") - .endpoint("https://elasticloadbalancing.us-east-1.amazonaws.com/") - .addHeader("Host", "elasticloadbalancing.us-east-1.amazonaws.com") - .payload( - payloadFromStringWithContentType( - "Action=DescribeLoadBalancers" + - "&Signature=3pErfVJXXe4EndOr3nPMu2/5eO8aCvwcOaI%2BL64VMqg%3D" + - "&SignatureMethod=HmacSHA256" + - "&SignatureVersion=2" + - "&Timestamp=2009-11-08T15%3A54%3A08.897Z" + - "&Version=2012-06-01" + - "&AWSAccessKeyId=identity", - "application/x-www-form-urlencoded")) - .build(); - - public void testListWhenResponseIs2xx() throws Exception { - - HttpResponse listResponse = HttpResponse.builder().statusCode(200) - .payload(payloadFromResourceWithContentType("/describe_loadbalancers.xml", "text/xml")).build(); - - ELBApi apiWhenExist = requestSendsResponse( - list, listResponse); - - assertEquals(apiWhenExist.getLoadBalancerApi().list().get(0).toString(), new DescribeLoadBalancersResponseTest().expected().toString()); - } - - - public void testList2PagesWhenResponseIs2xx() throws Exception { - - HttpResponse listResponse1 = HttpResponse.builder().statusCode(200) - .payload(payloadFromResourceWithContentType("/describe_loadbalancers_marker.xml", "text/xml")).build(); - - HttpRequest list2 = HttpRequest.builder() - .method("POST") - .endpoint("https://elasticloadbalancing.us-east-1.amazonaws.com/") - .addHeader("Host", "elasticloadbalancing.us-east-1.amazonaws.com") - .payload( - payloadFromStringWithContentType( - "Action=DescribeLoadBalancers" + - "&Marker=MARKER" + - "&Signature=/JttkIXuYljhZLJOPYyn%2BYIkDhD9skmePH3LYEnqmes%3D" + - "&SignatureMethod=HmacSHA256" + - "&SignatureVersion=2" + - "&Timestamp=2009-11-08T15%3A54%3A08.897Z" + - "&Version=2012-06-01" + - "&AWSAccessKeyId=identity", - "application/x-www-form-urlencoded")) - .build(); - - HttpResponse listResponse2 = HttpResponse.builder().statusCode(200) - .payload(payloadFromResourceWithContentType("/describe_loadbalancers.xml", "text/xml")).build(); - - ELBApi apiWhenExist = requestsSendResponses( - list, listResponse1, list2, listResponse2); - - LoadBalancer lb1 = new GetLoadBalancerResponseTest().expected().toBuilder().name("my-load-balancer-1").build(); - LoadBalancer lb2 = new GetLoadBalancerResponseTest().expected(); - - assertEquals(apiWhenExist.getLoadBalancerApi().list().concat().toSet(), ImmutableSet.of(lb1, lb2)); - } - - public void testList2PagesWhenResponseIs2xxInEU() throws Exception { - - HttpRequest list = HttpRequest.builder() - .method("POST") - .endpoint("https://elasticloadbalancing.eu-west-1.amazonaws.com/") - .addHeader("Host", "elasticloadbalancing.eu-west-1.amazonaws.com") - .payload( - payloadFromStringWithContentType( - "Action=DescribeLoadBalancers" + - "&Signature=/T6QECRsE52DT6mA7AkBy4%2Bdnvy4RXU3nNt56td0GTo%3D" + - "&SignatureMethod=HmacSHA256" + - "&SignatureVersion=2" + - "&Timestamp=2009-11-08T15%3A54%3A08.897Z" + - "&Version=2012-06-01" + - "&AWSAccessKeyId=identity", - "application/x-www-form-urlencoded")) - .build(); - - HttpResponse listResponse1 = HttpResponse.builder().statusCode(200) - .payload(payloadFromResourceWithContentType("/describe_loadbalancers_marker.xml", "text/xml")).build(); - - HttpRequest list2 = HttpRequest.builder() - .method("POST") - .endpoint("https://elasticloadbalancing.eu-west-1.amazonaws.com/") - .addHeader("Host", "elasticloadbalancing.eu-west-1.amazonaws.com") - .payload( - payloadFromStringWithContentType( - "Action=DescribeLoadBalancers" + - "&Marker=MARKER" + - "&Signature=jiNCvpqj2fTKbput%2BhBtYMM6KpWAFzBeW20FyWeoyZw%3D" + - "&SignatureMethod=HmacSHA256" + - "&SignatureVersion=2" + - "&Timestamp=2009-11-08T15%3A54%3A08.897Z" + - "&Version=2012-06-01" + - "&AWSAccessKeyId=identity", - "application/x-www-form-urlencoded")) - .build(); - - HttpResponse listResponse2 = HttpResponse.builder().statusCode(200) - .payload(payloadFromResourceWithContentType("/describe_loadbalancers.xml", "text/xml")).build(); - - ELBApi apiWhenExist = requestsSendResponses(list, listResponse1, list2, listResponse2); - - LoadBalancer lb1 = new GetLoadBalancerResponseTest().expected().toBuilder().name("my-load-balancer-1").build(); - LoadBalancer lb2 = new GetLoadBalancerResponseTest().expected(); - - assertEquals(ImmutableSet.copyOf(Iterables.concat(apiWhenExist.getLoadBalancerApiForRegion("eu-west-1").list())), ImmutableSet.of(lb1, lb2)); - } - - public void testListWhenResponseIs404() throws Exception { - - HttpResponse listResponse = HttpResponse.builder().statusCode(404).build(); - - ELBApi apiWhenDontExist = requestSendsResponse( - list, listResponse); - - assertEquals(apiWhenDontExist.getLoadBalancerApi().list().get(0).toSet(), ImmutableSet.of()); - - } - - public void testListWithOptionsWhenResponseIs2xx() throws Exception { - HttpRequest listWithOptions = - HttpRequest.builder() - .method("POST") - .endpoint("https://elasticloadbalancing.us-east-1.amazonaws.com/") - .addHeader("Host", "elasticloadbalancing.us-east-1.amazonaws.com") - .payload(payloadFromStringWithContentType( - "Action=DescribeLoadBalancers" + - "&Marker=MARKER" + - "&Signature=/JttkIXuYljhZLJOPYyn%2BYIkDhD9skmePH3LYEnqmes%3D" + - "&SignatureMethod=HmacSHA256" + - "&SignatureVersion=2" + - "&Timestamp=2009-11-08T15%3A54%3A08.897Z" + - "&Version=2012-06-01" + - "&AWSAccessKeyId=identity", - "application/x-www-form-urlencoded")) - .build(); - - HttpResponse listWithOptionsResponse = HttpResponse.builder().statusCode(200) - .payload(payloadFromResourceWithContentType("/describe_loadbalancers.xml", "text/xml")).build(); - - ELBApi apiWhenWithOptionsExist = requestSendsResponse(listWithOptions, - listWithOptionsResponse); - - assertEquals(apiWhenWithOptionsExist.getLoadBalancerApi().list(afterMarker("MARKER")).toString(), - new DescribeLoadBalancersResponseTest().expected().toString()); - } - - HttpRequest delete = HttpRequest.builder() - .method("POST") - .endpoint("https://elasticloadbalancing.us-east-1.amazonaws.com/") - .addHeader("Host", "elasticloadbalancing.us-east-1.amazonaws.com") - .payload( - payloadFromStringWithContentType( - "Action=DeleteLoadBalancer" + - "&LoadBalancerName=name" + - "&Signature=LPfcRnIayHleMt9Z8QiGTMXoafF2ABKGeah3UO1eD0k%3D" + - "&SignatureMethod=HmacSHA256" + - "&SignatureVersion=2" + - "&Timestamp=2009-11-08T15%3A54%3A08.897Z" + - "&Version=2012-06-01" + - "&AWSAccessKeyId=identity", - "application/x-www-form-urlencoded")) - .build(); - - public void testDeleteWhenResponseIs2xx() throws Exception { - - HttpResponse deleteResponse = HttpResponse.builder().statusCode(200).build(); - - ELBApi apiWhenExist = requestSendsResponse(delete, deleteResponse); - - apiWhenExist.getLoadBalancerApi().delete("name"); - } - - public void testDeleteWhenResponseIs404() throws Exception { - - HttpResponse deleteResponse = HttpResponse.builder().statusCode(404).build(); - - ELBApi apiWhenDontExist = requestSendsResponse(delete, deleteResponse); - - apiWhenDontExist.getLoadBalancerApi().delete("name"); - } -} diff --git a/labs/elb/src/test/java/org/jclouds/elb/features/LoadBalancerApiLiveTest.java b/labs/elb/src/test/java/org/jclouds/elb/features/LoadBalancerApiLiveTest.java deleted file mode 100644 index 25c50e75ba..0000000000 --- a/labs/elb/src/test/java/org/jclouds/elb/features/LoadBalancerApiLiveTest.java +++ /dev/null @@ -1,118 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.elb.features; - -import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.base.Preconditions.checkState; - -import java.util.Set; - -import org.jclouds.collect.IterableWithMarker; -import org.jclouds.elb.domain.ListenerWithPolicies; -import org.jclouds.elb.domain.LoadBalancer; -import org.jclouds.elb.internal.BaseELBApiLiveTest; -import org.jclouds.elb.options.ListLoadBalancersOptions; -import org.testng.Assert; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Iterables; - -/** - * @author Adrian Cole - */ -@Test(groups = "live", testName = "LoadBalancerApiLiveTest") -public class LoadBalancerApiLiveTest extends BaseELBApiLiveTest { - - private void checkLoadBalancer(LoadBalancer loadBalancer) { - checkNotNull(loadBalancer.getName(), "While Name can be null for a LoadBalancer, its Optional wrapper cannot: %s", loadBalancer); - checkNotNull(loadBalancer.getCreatedTime(), "CreatedTime cannot be null for a LoadBalancer: %s", loadBalancer); - checkNotNull(loadBalancer.getDnsName(), "DnsName cannot be null for a LoadBalancer: %s", loadBalancer); - checkNotNull(loadBalancer.getHealthCheck(), "HealthCheck cannot be null for a LoadBalancer: %s", loadBalancer); - checkState(loadBalancer.getAvailabilityZones().size() > 0, "AvailabilityZones must have at least one zone: %s", loadBalancer); - checkNotNull(loadBalancer.getInstanceIds(), "While InstanceIds can be empty, it cannot be null: %s", loadBalancer); - checkNotNull(loadBalancer.getSourceSecurityGroup(), - "While SourceSecurityGroup can be null for a LoadBalancer, its Optional wrapper cannot: %s", loadBalancer); - - // VPC - checkNotNull(loadBalancer.getVPCId(), "While VPCId can be null for a LoadBalancer, its Optional wrapper cannot: %s", loadBalancer); - checkNotNull(loadBalancer.getScheme(), - "While Scheme can be null for a LoadBalancer, its Optional wrapper cannot: %s", loadBalancer); - checkNotNull(loadBalancer.getSecurityGroups(), "While SecurityGroups can be empty, it cannot be null: %s", loadBalancer); - checkNotNull(loadBalancer.getSubnets(), "While Subnets can be empty, it cannot be null: %s", loadBalancer); - - // Route 53 - checkNotNull(loadBalancer.getHostedZoneId(), "While HostedZoneId can be null for a LoadBalancer, its Optional wrapper cannot: %s", loadBalancer); - checkNotNull(loadBalancer.getHostedZoneName(), "While HostedZoneName can be null for a LoadBalancer, its Optional wrapper cannot: %s", loadBalancer); - - } - - private void checkListener(ListenerWithPolicies listener) { - checkNotNull(listener.getPolicyNames(), "While PolicyNames can be empty, it cannot be null."); - assert listener.getInstancePort() > 0 : "InstancePort must be positive"; - checkNotNull(listener.getInstanceProtocol(), "InstanceProtocol cannot be null"); - assert listener.getPort() > 0 : "Port must be positive"; - checkNotNull(listener.getProtocol(), "Protocol cannot be null"); - checkNotNull(listener.getSSLCertificateId(), - "While SSLCertificateId can be null for a ListenerWithPolicies, its Optional wrapper cannot."); - } - @Test - protected void testList() { - Set response = ImmutableSet.copyOf(Iterables.concat(api().list())); - - for (LoadBalancer loadBalancer : response) { - checkLoadBalancer(loadBalancer); - for (ListenerWithPolicies listener : loadBalancer.getListeners()) { - checkListener(listener); - } - } - - if (Iterables.size(response) > 0) { - LoadBalancer loadBalancer = response.iterator().next(); - Assert.assertEquals(api().get(loadBalancer.getName()), loadBalancer); - } - } - - @Test - protected void testListWithOptions() { - IterableWithMarker response = api().list(new ListLoadBalancersOptions()); - - for (LoadBalancer loadBalancer : response) { - checkLoadBalancer(loadBalancer); - for (ListenerWithPolicies listener : loadBalancer.getListeners()) { - checkListener(listener); - } - } - - if (Iterables.size(response) > 0) { - LoadBalancer loadBalancer = response.iterator().next(); - Assert.assertEquals(api().get(loadBalancer.getName()), loadBalancer); - } - - // Test with a Marker, even if it's null - response = api().list(ListLoadBalancersOptions.Builder.afterMarker(response.nextMarker().orNull())); - for (LoadBalancer loadBalancer : response) { - checkLoadBalancer(loadBalancer); - } - } - - protected LoadBalancerApi api() { - return context.getApi().getLoadBalancerApi(); - } -} diff --git a/labs/elb/src/test/java/org/jclouds/elb/features/PolicyApiExpectTest.java b/labs/elb/src/test/java/org/jclouds/elb/features/PolicyApiExpectTest.java deleted file mode 100644 index e9499c5056..0000000000 --- a/labs/elb/src/test/java/org/jclouds/elb/features/PolicyApiExpectTest.java +++ /dev/null @@ -1,257 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unles required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either expres or implied. See the License for the - * specific language governing permisions and limitations - * under the License. - */ -package org.jclouds.elb.features; - -import static org.jclouds.elb.options.ListPoliciesOptions.Builder.loadBalancerName; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNull; - -import java.util.TimeZone; - -import org.jclouds.elb.ELBApi; -import org.jclouds.elb.internal.BaseELBApiExpectTest; -import org.jclouds.elb.parse.DescribeLoadBalancerPoliciesResponseTest; -import org.jclouds.elb.parse.DescribeLoadBalancerPolicyTypesResponseTest; -import org.jclouds.elb.parse.GetPolicyResponseTest; -import org.jclouds.elb.parse.GetPolicyTypeResponseTest; -import org.jclouds.http.HttpRequest; -import org.jclouds.http.HttpResponse; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableSet; - -/** - * @author Adrian Cole - */ -@Test(groups = "unit", testName = "PolicyApiExpectTest") -public class PolicyApiExpectTest extends BaseELBApiExpectTest { - - public PolicyApiExpectTest() { - TimeZone.setDefault(TimeZone.getTimeZone("America/Los_Angeles")); - } - - HttpRequest get = HttpRequest.builder() - .method("POST") - .endpoint("https://elasticloadbalancing.us-east-1.amazonaws.com/") - .addHeader("Host", "elasticloadbalancing.us-east-1.amazonaws.com") - .payload( - payloadFromStringWithContentType( - "Action=DescribeLoadBalancerPolicies" + - "&PolicyNames.member.1=name" + - "&Signature=kroGA7XRZYqiw4zgAXkWRdF9ff3RcnZKgvfcPG5f%2Bjs%3D" + - "&SignatureMethod=HmacSHA256" + - "&SignatureVersion=2" + - "&Timestamp=2009-11-08T15%3A54%3A08.897Z" + - "&Version=2012-06-01" + - "&AWSAccessKeyId=identity", - "application/x-www-form-urlencoded")) - .build(); - - - public void testGetWhenResponseIs2xx() throws Exception { - - HttpResponse getResponse = HttpResponse.builder().statusCode(200) - .payload(payloadFromResourceWithContentType("/describe_policy.xml", "text/xml")).build(); - - ELBApi apiWhenExist = requestSendsResponse( - get, getResponse); - - assertEquals(apiWhenExist.getPolicyApi().get("name").toString(), new GetPolicyResponseTest().expected().toString()); - } - - public void testGetWhenResponseIs404() throws Exception { - - HttpResponse getResponse = HttpResponse.builder().statusCode(404).build(); - - ELBApi apiWhenDontExist = requestSendsResponse( - get, getResponse); - - assertNull(apiWhenDontExist.getPolicyApi().get("name")); - } - - HttpRequest list = HttpRequest.builder() - .method("POST") - .endpoint("https://elasticloadbalancing.us-east-1.amazonaws.com/") - .addHeader("Host", "elasticloadbalancing.us-east-1.amazonaws.com") - .payload( - payloadFromStringWithContentType( - "Action=DescribeLoadBalancerPolicies" + - "&Signature=0LPrgeysYoQe6PyK2nh3mCgo0lxPNiERxm46W/N5GpU%3D" + - "&SignatureMethod=HmacSHA256" + - "&SignatureVersion=2" + - "&Timestamp=2009-11-08T15%3A54%3A08.897Z" + - "&Version=2012-06-01" + - "&AWSAccessKeyId=identity", - "application/x-www-form-urlencoded")) - .build(); - - public void testListWhenResponseIs2xx() throws Exception { - - HttpResponse listResponse = HttpResponse.builder().statusCode(200) - .payload(payloadFromResourceWithContentType("/describe_policies.xml", "text/xml")).build(); - - ELBApi apiWhenExist = requestSendsResponse( - list, listResponse); - - assertEquals(apiWhenExist.getPolicyApi().list().toString(), new DescribeLoadBalancerPoliciesResponseTest().expected().toString()); - } - - public void testListWhenResponseIs404() throws Exception { - - HttpResponse listResponse = HttpResponse.builder().statusCode(404).build(); - - ELBApi apiWhenDontExist = requestSendsResponse( - list, listResponse); - - apiWhenDontExist.getPolicyApi().list(); - } - - public void testListWithOptionsWhenResponseIs2xx() throws Exception { - HttpRequest listWithOptions = - HttpRequest.builder() - .method("POST") - .endpoint("https://elasticloadbalancing.us-east-1.amazonaws.com/") - .addHeader("Host", "elasticloadbalancing.us-east-1.amazonaws.com") - .payload(payloadFromStringWithContentType( - "Action=DescribeLoadBalancerPolicies" + - "&LoadBalancerName=moo" + - "&Signature=c8PG1b5wI5YMU0motVEo5Mz7d5w8gy8u51kfCR6SnRI%3D" + - "&SignatureMethod=HmacSHA256" + - "&SignatureVersion=2" + - "&Timestamp=2009-11-08T15%3A54%3A08.897Z" + - "&Version=2012-06-01" + - "&AWSAccessKeyId=identity", - "application/x-www-form-urlencoded")) - .build(); - - HttpResponse listWithOptionsResponse = HttpResponse.builder().statusCode(200) - .payload(payloadFromResourceWithContentType("/describe_policies.xml", "text/xml")).build(); - - ELBApi apiWhenWithOptionsExist = requestSendsResponse(listWithOptions, - listWithOptionsResponse); - - assertEquals(apiWhenWithOptionsExist.getPolicyApi().list(loadBalancerName("moo")).toString(), - new DescribeLoadBalancerPoliciesResponseTest().expected().toString()); - } - - - HttpRequest getType = HttpRequest.builder() - .method("POST") - .endpoint("https://elasticloadbalancing.us-east-1.amazonaws.com/") - .addHeader("Host", "elasticloadbalancing.us-east-1.amazonaws.com") - .payload( - payloadFromStringWithContentType( - "Action=DescribeLoadBalancerPolicyTypes" + - "&PolicyTypeNames.member.1=name" + - "&Signature=WC5tQK0TacaxSRrCEKqbpIPFrrrgsBV4I1%2B9W2Lx58M%3D" + - "&SignatureMethod=HmacSHA256" + - "&SignatureVersion=2" + - "&Timestamp=2009-11-08T15%3A54%3A08.897Z" + - "&Version=2012-06-01" + - "&AWSAccessKeyId=identity", - "application/x-www-form-urlencoded")) - .build(); - - - public void testGetTypeWhenResponseIs2xx() throws Exception { - - HttpResponse getResponse = HttpResponse.builder().statusCode(200) - .payload(payloadFromResourceWithContentType("/describe_policy_type.xml", "text/xml")).build(); - - ELBApi apiWhenExist = requestSendsResponse( - getType, getResponse); - - assertEquals(apiWhenExist.getPolicyApi().getType("name").toString(), new GetPolicyTypeResponseTest().expected().toString()); - } - - public void testGetTypeWhenResponseIs404() throws Exception { - - HttpResponse getResponse = HttpResponse.builder().statusCode(404).build(); - - ELBApi apiWhenDontExist = requestSendsResponse( - getType, getResponse); - - assertNull(apiWhenDontExist.getPolicyApi().getType("name")); - } - - HttpRequest listTypes = HttpRequest.builder() - .method("POST") - .endpoint("https://elasticloadbalancing.us-east-1.amazonaws.com/") - .addHeader("Host", "elasticloadbalancing.us-east-1.amazonaws.com") - .payload( - payloadFromStringWithContentType( - "Action=DescribeLoadBalancerPolicyTypes" + - "&Signature=/1mMjugJD8Zvb%2BK/QgOZMYVenlveCKtvGBiHaZVc%2B9w%3D" + - "&SignatureMethod=HmacSHA256" + - "&SignatureVersion=2" + - "&Timestamp=2009-11-08T15%3A54%3A08.897Z" + - "&Version=2012-06-01" + - "&AWSAccessKeyId=identity", - "application/x-www-form-urlencoded")) - .build(); - - public void testListTypeWhenResponseIs2xx() throws Exception { - - HttpResponse listResponse = HttpResponse.builder().statusCode(200) - .payload(payloadFromResourceWithContentType("/describe_policy_types.xml", "text/xml")).build(); - - ELBApi apiWhenExist = requestSendsResponse( - listTypes, listResponse); - - assertEquals(apiWhenExist.getPolicyApi().listTypes().toString(), new DescribeLoadBalancerPolicyTypesResponseTest().expected().toString()); - } - - public void testListTypesWhenResponseIs404() throws Exception { - - HttpResponse listResponse = HttpResponse.builder().statusCode(404).build(); - - ELBApi apiWhenDontExist = requestSendsResponse( - listTypes, listResponse); - - apiWhenDontExist.getPolicyApi().listTypes(); - } - - public void testListTypesByNamesWhenResponseIs2xx() throws Exception { - HttpRequest listWithOptions = - HttpRequest.builder() - .method("POST") - .endpoint("https://elasticloadbalancing.us-east-1.amazonaws.com/") - .addHeader("Host", "elasticloadbalancing.us-east-1.amazonaws.com") - .payload(payloadFromStringWithContentType( - "Action=DescribeLoadBalancerPolicyTypes" + - "&PolicyTypeNames.member.1=moo" + - "&Signature=cX8twwn2E6%2B7V3CGZ4ac69NhyolJLsV1nzpQl3wQXW8%3D" + - "&SignatureMethod=HmacSHA256" + - "&SignatureVersion=2" + - "&Timestamp=2009-11-08T15%3A54%3A08.897Z" + - "&Version=2012-06-01" + - "&AWSAccessKeyId=identity", - "application/x-www-form-urlencoded")) - .build(); - - HttpResponse listWithOptionsResponse = HttpResponse.builder().statusCode(200) - .payload(payloadFromResourceWithContentType("/describe_policy_types.xml", "text/xml")).build(); - - ELBApi apiWhenWithOptionsExist = requestSendsResponse(listWithOptions, - listWithOptionsResponse); - - assertEquals(apiWhenWithOptionsExist.getPolicyApi().listTypes(ImmutableSet.of("moo")).toString(), - new DescribeLoadBalancerPolicyTypesResponseTest().expected().toString()); - } -} diff --git a/labs/elb/src/test/java/org/jclouds/elb/features/PolicyApiLiveTest.java b/labs/elb/src/test/java/org/jclouds/elb/features/PolicyApiLiveTest.java deleted file mode 100644 index b6155a19ec..0000000000 --- a/labs/elb/src/test/java/org/jclouds/elb/features/PolicyApiLiveTest.java +++ /dev/null @@ -1,108 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.elb.features; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.Set; - -import org.jclouds.elb.domain.AttributeMetadata; -import org.jclouds.elb.domain.Policy; -import org.jclouds.elb.domain.PolicyType; -import org.jclouds.elb.internal.BaseELBApiLiveTest; -import org.testng.Assert; -import org.testng.annotations.Test; - -import com.google.common.base.Function; -import com.google.common.collect.Iterables; - -/** - * @author Adrian Cole - */ -@Test(groups = "live", testName = "PolicyApiLiveTest") -public class PolicyApiLiveTest extends BaseELBApiLiveTest { - - private void checkPolicy(Policy policy) { - checkNotNull(policy.getName(), "Name cannot be null for a Policy."); - checkNotNull(policy.getTypeName(), "TypeName cannot be null for a Policy."); - checkNotNull(policy.getAttributes(), "While it is ok to have no attributes, the map cannot be null."); - } - - @Test - protected void testDescribePolicies() { - Set response = api().list(); - - for (Policy policy : response) { - checkPolicy(policy); - } - - if (response.size() > 0) { - Policy policy = response.iterator().next(); - Assert.assertEquals(api().get(policy.getName()), policy); - } - - } - - private void checkPolicyType(PolicyType policyType) { - checkNotNull(policyType.getName(), "Name cannot be null for a PolicyType."); - checkNotNull(policyType.getDescription(), "Description cannot be null for a PolicyType."); - checkNotNull(policyType.getAttributeMetadata(), "While it is ok to have no attributes, the set cannot be null."); - for (AttributeMetadata attributeMetadata: policyType.getAttributeMetadata()) { - checkAttributeMetadata(attributeMetadata); - } - } - - private void checkAttributeMetadata(AttributeMetadata attributeMetadata) { - checkNotNull(attributeMetadata.getName(), "Name cannot be null for a AttributeMetadata."); - checkNotNull(attributeMetadata.getType(), "Type cannot be null for a AttributeMetadata."); - checkNotNull(attributeMetadata.getCardinality(), "Cardinality cannot be null for a AttributeMetadata."); - checkNotNull(attributeMetadata.getDefaultValue(), "While DefaultValue can be null, its optional wrapper cannot"); - checkNotNull(attributeMetadata.getDescription(), "While Description can be null, its optional wrapper cannot"); - } - - @Test - protected void testDescribePolicyTypes() { - Set response = api().listTypes(); - - for (PolicyType policyType : response) { - checkPolicyType(policyType); - } - - if (response.size() > 0) { - PolicyType policyType = response.iterator().next(); - Assert.assertEquals(api().getType(policyType.getName()), policyType); - } - - if (response.size() > 0) { - Iterable names = Iterables.transform(response, new Function() { - - @Override - public String apply(PolicyType input) { - return input.getName(); - } - - }); - Assert.assertEquals(api().listTypes(names), response); - } - } - - protected PolicyApi api() { - return context.getApi().getPolicyApi(); - } -} diff --git a/labs/elb/src/test/java/org/jclouds/elb/internal/BaseELBApiExpectTest.java b/labs/elb/src/test/java/org/jclouds/elb/internal/BaseELBApiExpectTest.java deleted file mode 100644 index 2f358efd17..0000000000 --- a/labs/elb/src/test/java/org/jclouds/elb/internal/BaseELBApiExpectTest.java +++ /dev/null @@ -1,30 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.elb.internal; - -import org.jclouds.elb.ELBApi; - - -/** - * - * @author Adrian Cole - */ -public class BaseELBApiExpectTest extends BaseELBExpectTest { - -} diff --git a/labs/elb/src/test/java/org/jclouds/elb/internal/BaseELBApiLiveTest.java b/labs/elb/src/test/java/org/jclouds/elb/internal/BaseELBApiLiveTest.java deleted file mode 100644 index c27a05a5f1..0000000000 --- a/labs/elb/src/test/java/org/jclouds/elb/internal/BaseELBApiLiveTest.java +++ /dev/null @@ -1,46 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.elb.internal; - -import org.jclouds.apis.BaseContextLiveTest; -import org.jclouds.elb.ELBApiMetadata; -import org.jclouds.elb.ELBAsyncApi; -import org.jclouds.elb.ELBApi; -import org.jclouds.rest.RestContext; -import org.testng.annotations.Test; - -import com.google.common.reflect.TypeToken; - -/** - * - * @author Adrian Cole - */ -@Test(groups = "live") -public class BaseELBApiLiveTest extends BaseContextLiveTest> { - - public BaseELBApiLiveTest() { - provider = "elb"; - } - - @Override - protected TypeToken> contextType() { - return ELBApiMetadata.CONTEXT_TOKEN; - } - -} diff --git a/labs/elb/src/test/java/org/jclouds/elb/internal/BaseELBAsyncApiExpectTest.java b/labs/elb/src/test/java/org/jclouds/elb/internal/BaseELBAsyncApiExpectTest.java deleted file mode 100644 index 0130bc6739..0000000000 --- a/labs/elb/src/test/java/org/jclouds/elb/internal/BaseELBAsyncApiExpectTest.java +++ /dev/null @@ -1,38 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.elb.internal; - -import java.util.Properties; - -import org.jclouds.elb.ELBAsyncApi; -import org.jclouds.http.HttpRequest; -import org.jclouds.http.HttpResponse; - -import com.google.common.base.Function; -import com.google.inject.Module; - -/** - * - * @author Adrian Cole - */ -public class BaseELBAsyncApiExpectTest extends BaseELBExpectTest { - public ELBAsyncApi createApi(Function fn, Module module, Properties props) { - return createInjector(fn, module, props).getInstance(ELBAsyncApi.class); - } -} diff --git a/labs/elb/src/test/java/org/jclouds/elb/internal/BaseELBExpectTest.java b/labs/elb/src/test/java/org/jclouds/elb/internal/BaseELBExpectTest.java deleted file mode 100644 index dd08cb8784..0000000000 --- a/labs/elb/src/test/java/org/jclouds/elb/internal/BaseELBExpectTest.java +++ /dev/null @@ -1,78 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.elb.internal; - -import static com.google.common.collect.Maps.transformValues; - -import java.net.URI; -import java.util.Map; - -import org.jclouds.aws.domain.Region; -import org.jclouds.date.DateService; -import org.jclouds.elb.config.ELBRestClientModule; -import org.jclouds.location.config.LocationModule; -import org.jclouds.location.suppliers.RegionIdToURISupplier; -import org.jclouds.rest.ConfiguresRestClient; -import org.jclouds.rest.internal.BaseRestApiExpectTest; -import org.jclouds.util.Suppliers2; - -import com.google.common.base.Supplier; -import com.google.common.collect.ImmutableMap; -import com.google.inject.Module; - -/** - * - * @author Adrian Cole - */ -public class BaseELBExpectTest extends BaseRestApiExpectTest { - - public BaseELBExpectTest() { - provider = "elb"; - } - - @ConfiguresRestClient - private static final class TestELBRestClientModule extends ELBRestClientModule { - - @Override - protected void installLocations() { - install(new LocationModule()); - bind(RegionIdToURISupplier.class).toInstance(new RegionIdToURISupplier() { - - @Override - public Map> get() { - return transformValues(ImmutableMap. of(Region.EU_WEST_1, URI - .create("https://elasticloadbalancing.eu-west-1.amazonaws.com"), Region.US_EAST_1, URI - .create("https://elasticloadbalancing.us-east-1.amazonaws.com"), Region.US_WEST_1, URI - .create("https://elasticloadbalancing.us-west-1.amazonaws.com")), Suppliers2. ofInstanceFunction()); - } - - }); - } - - @Override - protected String provideTimeStamp(final DateService dateService) { - return "2009-11-08T15:54:08.897Z"; - } - } - - @Override - protected Module createModule() { - return new TestELBRestClientModule(); - } -} diff --git a/labs/elb/src/test/java/org/jclouds/elb/loadbalancer/ELBLoadBalancerServiceLiveTest.java b/labs/elb/src/test/java/org/jclouds/elb/loadbalancer/ELBLoadBalancerServiceLiveTest.java deleted file mode 100644 index b4172e83f8..0000000000 --- a/labs/elb/src/test/java/org/jclouds/elb/loadbalancer/ELBLoadBalancerServiceLiveTest.java +++ /dev/null @@ -1,70 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.elb.loadbalancer; - -import static org.testng.Assert.assertEquals; - -import org.jclouds.compute.domain.NodeMetadata; -import org.jclouds.elb.ELBApi; -import org.jclouds.elb.ELBAsyncApi; -import org.jclouds.elb.domain.LoadBalancer; -import org.jclouds.loadbalancer.BaseLoadBalancerServiceLiveTest; -import org.jclouds.rest.RestContext; -import org.jclouds.sshj.config.SshjSshClientModule; -import org.testng.annotations.Test; - -import com.google.common.collect.FluentIterable; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.ImmutableSet.Builder; - -/** - * - * @author Lili Nadar - */ -@Test(groups = "live", singleThreaded = true, testName = "ELBLoadBalancerServiceLiveTest") -public class ELBLoadBalancerServiceLiveTest extends BaseLoadBalancerServiceLiveTest { - public ELBLoadBalancerServiceLiveTest() { - provider = "elb"; - } - - @Override - protected SshjSshClientModule getSshModule() { - return new SshjSshClientModule(); - } - - @Override - protected void validateNodesInLoadBalancer() { - RestContext elbContext = view.unwrap(); - // TODO create a LoadBalancer object and an appropriate list method so that this - // does not have to be EC2 specific code - ELBApi elbApi = elbContext.getApi(); - - Builder instanceIds = ImmutableSet. builder(); - for (NodeMetadata node : nodes) { - instanceIds.add(node.getProviderId()); - } - - FluentIterable elbs = elbApi.getLoadBalancerApi().list().concat(); - for (LoadBalancer elb : elbs) { - if (elb.getName().equals(group)) - assertEquals(elb.getInstanceIds(), instanceIds.build()); - } - } - -} diff --git a/labs/elb/src/test/java/org/jclouds/elb/options/ListLoadBalancersOptionsTest.java b/labs/elb/src/test/java/org/jclouds/elb/options/ListLoadBalancersOptionsTest.java deleted file mode 100644 index b97dd689df..0000000000 --- a/labs/elb/src/test/java/org/jclouds/elb/options/ListLoadBalancersOptionsTest.java +++ /dev/null @@ -1,57 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.elb.options; - -import static org.jclouds.elb.options.ListLoadBalancersOptions.Builder.afterMarker; -import static org.jclouds.elb.options.ListLoadBalancersOptions.Builder.name; -import static org.testng.Assert.assertEquals; - -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableSet; - -/** - * Tests behavior of {@code ListLoadBalancersOptions} - * - * @author Adrian Cole - */ -@Test(groups = "unit", testName = "ListLoadBalancersOptionsTest") -public class ListLoadBalancersOptionsTest { - - public void testMarker() { - ListLoadBalancersOptions options = new ListLoadBalancersOptions().afterMarker("FFFFF"); - assertEquals(ImmutableSet.of("FFFFF"), options.buildFormParameters().get("Marker")); - } - - public void testMarkerStatic() { - ListLoadBalancersOptions options = afterMarker("FFFFF"); - assertEquals(ImmutableSet.of("FFFFF"), options.buildFormParameters().get("Marker")); - } - - public void testName() { - ListLoadBalancersOptions options = new ListLoadBalancersOptions().name("my-load-balancer"); - assertEquals(ImmutableSet.of("my-load-balancer"), options.buildFormParameters().get("LoadBalancerNames.member.1")); - } - - public void testNameStatic() { - ListLoadBalancersOptions options = name("my-load-balancer"); - assertEquals(ImmutableSet.of("my-load-balancer"), options.buildFormParameters().get("LoadBalancerNames.member.1")); - } - -} diff --git a/labs/elb/src/test/java/org/jclouds/elb/options/ListPoliciesOptionsTest.java b/labs/elb/src/test/java/org/jclouds/elb/options/ListPoliciesOptionsTest.java deleted file mode 100644 index dcfe15e630..0000000000 --- a/labs/elb/src/test/java/org/jclouds/elb/options/ListPoliciesOptionsTest.java +++ /dev/null @@ -1,57 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.elb.options; - -import static org.jclouds.elb.options.ListPoliciesOptions.Builder.loadBalancerName; -import static org.jclouds.elb.options.ListPoliciesOptions.Builder.name; -import static org.testng.Assert.assertEquals; - -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableSet; - -/** - * Tests behavior of {@code ListPoliciesOptions} - * - * @author Adrian Cole - */ -@Test(groups = "unit", testName = "ListPoliciesOptionsTest") -public class ListPoliciesOptionsTest { - - public void testLoadBalancerName() { - ListPoliciesOptions options = new ListPoliciesOptions().loadBalancerName("FFFFF"); - assertEquals(ImmutableSet.of("FFFFF"), options.buildFormParameters().get("LoadBalancerName")); - } - - public void testLoadBalancerNameStatic() { - ListPoliciesOptions options = loadBalancerName("FFFFF"); - assertEquals(ImmutableSet.of("FFFFF"), options.buildFormParameters().get("LoadBalancerName")); - } - - public void testName() { - ListPoliciesOptions options = new ListPoliciesOptions().name("my-load-balancer"); - assertEquals(ImmutableSet.of("my-load-balancer"), options.buildFormParameters().get("PolicyNames.member.1")); - } - - public void testNameStatic() { - ListPoliciesOptions options = name("my-load-balancer"); - assertEquals(ImmutableSet.of("my-load-balancer"), options.buildFormParameters().get("PolicyNames.member.1")); - } - -} diff --git a/labs/elb/src/test/java/org/jclouds/elb/parse/AvailabilityZonesResultHandlerTest.java b/labs/elb/src/test/java/org/jclouds/elb/parse/AvailabilityZonesResultHandlerTest.java deleted file mode 100644 index dd1a3f6ca7..0000000000 --- a/labs/elb/src/test/java/org/jclouds/elb/parse/AvailabilityZonesResultHandlerTest.java +++ /dev/null @@ -1,54 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.elb.parse; - -import static org.testng.Assert.assertEquals; - -import java.io.InputStream; -import java.util.Set; - -import org.jclouds.elb.xml.AvailabilityZonesResultHandler; -import org.jclouds.http.functions.BaseHandlerTest; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableSet; - -/** - * @author Adrian Cole - */ -// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire -@Test(groups = "unit", testName = "ZonesResultHandlerTest") -public class AvailabilityZonesResultHandlerTest extends BaseHandlerTest { - - public void test() { - InputStream is = getClass().getResourceAsStream("/zones.xml"); - - Set expected = expected(); - - AvailabilityZonesResultHandler handler = injector.getInstance(AvailabilityZonesResultHandler.class); - Set result = factory.create(handler).parse(is); - - assertEquals(result.toString(), expected.toString()); - - } - - public Set expected() { - return ImmutableSet.of("us-east-1c"); - } -} diff --git a/labs/elb/src/test/java/org/jclouds/elb/parse/DescribeInstanceHealthResponseTest.java b/labs/elb/src/test/java/org/jclouds/elb/parse/DescribeInstanceHealthResponseTest.java deleted file mode 100644 index 394fb33ce2..0000000000 --- a/labs/elb/src/test/java/org/jclouds/elb/parse/DescribeInstanceHealthResponseTest.java +++ /dev/null @@ -1,61 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.elb.parse; - -import static org.testng.Assert.assertEquals; - -import java.io.InputStream; -import java.util.Set; - -import org.jclouds.elb.domain.InstanceHealth; -import org.jclouds.elb.xml.DescribeInstanceHealthResultHandler; -import org.jclouds.http.functions.BaseHandlerTest; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableSet; - -/** - * @author Adrian Cole - */ -// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire -@Test(groups = "unit", testName = "DescribeInstanceHealthResponseTest") -public class DescribeInstanceHealthResponseTest extends BaseHandlerTest { - - public void test() { - InputStream is = getClass().getResourceAsStream("/describe_instancehealth.xml"); - - Set expected = expected(); - - DescribeInstanceHealthResultHandler handler = injector.getInstance(DescribeInstanceHealthResultHandler.class); - Set result = factory.create(handler).parse(is); - - assertEquals(result.toString(), expected.toString()); - - } - - public Set expected() { - return ImmutableSet.builder() - .add(InstanceHealth.builder() - .description("Instance is in terminated state.") - .instanceId("i-64bd081c") - .state("OutOfService") - .reasonCode("Instance") - .build()).build(); - } -} diff --git a/labs/elb/src/test/java/org/jclouds/elb/parse/DescribeLoadBalancerPoliciesResponseTest.java b/labs/elb/src/test/java/org/jclouds/elb/parse/DescribeLoadBalancerPoliciesResponseTest.java deleted file mode 100644 index b28f0fcb70..0000000000 --- a/labs/elb/src/test/java/org/jclouds/elb/parse/DescribeLoadBalancerPoliciesResponseTest.java +++ /dev/null @@ -1,69 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.elb.parse; - -import static org.testng.Assert.assertEquals; - -import java.io.InputStream; -import java.util.Set; - -import org.jclouds.elb.domain.Policy; -import org.jclouds.elb.xml.DescribeLoadBalancerPoliciesResultHandler; -import org.jclouds.http.functions.BaseHandlerTest; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableSet; - -/** - * @author Adrian Cole - */ -// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire -@Test(groups = "unit", testName = "DescribePoliciesResponseTest") -public class DescribeLoadBalancerPoliciesResponseTest extends BaseHandlerTest { - - public void test() { - InputStream is = getClass().getResourceAsStream("/describe_policies.xml"); - - Set expected = expected(); - - DescribeLoadBalancerPoliciesResultHandler handler = injector.getInstance(DescribeLoadBalancerPoliciesResultHandler.class); - Set result = factory.create(handler).parse(is); - - assertEquals(result.toString(), expected.toString()); - - } - - public Set expected() { - return ImmutableSet.of( - Policy.builder() - .name("ELBSample-OpenSSLDefaultNegotiationPolicy") - .typeName("SSLNegotiationPolicyType") - .attribute("Protocol-SSLv2", false) - .attribute("ADH-AES256-SHA", false) - .attribute("DHE-RSA-AES256-SHA", true) - .build(), - Policy.builder() - .name("ELBSample-ELBDefaultNegotiationPolicy") - .typeName("SSLNegotiationPolicyType") - .attribute("Protocol-SSLv2", false) - .attribute("EDH-DSS-DES-CBC3-SHA", false) - .build() - ); - } -} diff --git a/labs/elb/src/test/java/org/jclouds/elb/parse/DescribeLoadBalancerPolicyTypesResponseTest.java b/labs/elb/src/test/java/org/jclouds/elb/parse/DescribeLoadBalancerPolicyTypesResponseTest.java deleted file mode 100644 index efd54580a4..0000000000 --- a/labs/elb/src/test/java/org/jclouds/elb/parse/DescribeLoadBalancerPolicyTypesResponseTest.java +++ /dev/null @@ -1,110 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.elb.parse; - -import static org.testng.Assert.assertEquals; - -import java.io.InputStream; -import java.util.Set; - -import org.jclouds.elb.domain.AttributeMetadata; -import org.jclouds.elb.domain.AttributeMetadata.Cardinality; -import org.jclouds.elb.domain.PolicyType; -import org.jclouds.elb.xml.DescribeLoadBalancerPolicyTypesResultHandler; -import org.jclouds.http.functions.BaseHandlerTest; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableSet; - -/** - * @author Adrian Cole - */ -// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire -@Test(groups = "unit", testName = "DescribeLoadBalancerPolicyTypesResponseTest") -public class DescribeLoadBalancerPolicyTypesResponseTest extends BaseHandlerTest { - - public void test() { - InputStream is = getClass().getResourceAsStream("/describe_policy_types.xml"); - - Set expected = expected(); - - DescribeLoadBalancerPolicyTypesResultHandler handler = injector.getInstance(DescribeLoadBalancerPolicyTypesResultHandler.class); - Set result = factory.create(handler).parse(is); - - assertEquals(result.toString(), expected.toString()); - - } - - public Set expected() { - return ImmutableSet.builder() - .add(PolicyType.builder() - .attributeMetadata(AttributeMetadata.builder() - .name("PublicKey") - .type(String.class) - .rawType("String") - .cardinality(Cardinality.ONE) - .build()) - .name("PublicKeyPolicyType") - .description("Policy containing a list of public keys to accept when authenticating the back-end server(s). This policy cannot be applied directly to back-end servers or listeners but must be part of a BackendServerAuthenticationPolicyType.") - .build()) - .add(PolicyType.builder() - .attributeMetadata(AttributeMetadata.builder() - .name("CookieName") - .type(String.class) - .rawType("String") - .cardinality(Cardinality.ONE).build()) - .name("AppCookieStickinessPolicyType") - .description("Stickiness policy with session lifetimes controlled by the lifetime of the application-generated cookie. This policy can be associated only with HTTP/HTTPS listeners.") - .build()) - .add(PolicyType.builder() - .attributeMetadata(AttributeMetadata.builder() - .name("CookieExpirationPeriod") - .type(Long.class) - .rawType("Long") - .cardinality(Cardinality.ZERO_OR_ONE).build()) - .name("LBCookieStickinessPolicyType") - .description("Stickiness policy with session lifetimes controlled by the browser (user-agent) or a specified expiration period. This policy can be associated only with HTTP/HTTPS listeners.") - .build()) - .add(PolicyType.builder() - .attributeMetadata(AttributeMetadata.builder() - .name("Protocol-SSLv2") - .type(Boolean.class) - .rawType("Boolean") - .defaultValue(false) - .cardinality(Cardinality.ZERO_OR_ONE).build()) - .attributeMetadata(AttributeMetadata.builder() - .name("Protocol-TLSv1") - .type(Boolean.class) - .rawType("Boolean") - .defaultValue(true) - .cardinality(Cardinality.ZERO_OR_ONE).build()) - .name("SSLNegotiationPolicyType") - .description("Listener policy that defines the ciphers and protocols that will be accepted by the load balancer. This policy can be associated only with HTTPS/SSL listeners.") - .build()) - .add(PolicyType.builder() - .attributeMetadata(AttributeMetadata.builder() - .name("PublicKeyPolicyName") - .type(String.class) - .rawType("PolicyName") - .cardinality(Cardinality.ONE_OR_MORE).build()) - .name("BackendServerAuthenticationPolicyType") - .description("Policy that controls authentication to back-end server(s) and contains one or more policies, such as an instance of a PublicKeyPolicyType. This policy can be associated only with back-end servers that are using HTTPS/SSL.") - .build()).build(); - } -} diff --git a/labs/elb/src/test/java/org/jclouds/elb/parse/DescribeLoadBalancersResponseTest.java b/labs/elb/src/test/java/org/jclouds/elb/parse/DescribeLoadBalancersResponseTest.java deleted file mode 100644 index cd6c37affa..0000000000 --- a/labs/elb/src/test/java/org/jclouds/elb/parse/DescribeLoadBalancersResponseTest.java +++ /dev/null @@ -1,76 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.elb.parse; - -import static org.testng.Assert.assertEquals; - -import java.io.InputStream; - -import org.jclouds.collect.IterableWithMarker; -import org.jclouds.collect.IterableWithMarkers; -import org.jclouds.date.internal.SimpleDateFormatDateService; -import org.jclouds.elb.domain.HealthCheck; -import org.jclouds.elb.domain.ListenerWithPolicies; -import org.jclouds.elb.domain.LoadBalancer; -import org.jclouds.elb.domain.Protocol; -import org.jclouds.elb.xml.DescribeLoadBalancersResultHandler; -import org.jclouds.http.functions.BaseHandlerTest; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableSet; - -/** - * @author Adrian Cole - */ -// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire -@Test(groups = "unit", testName = "DescribeLoadBalancersResponseTest") -public class DescribeLoadBalancersResponseTest extends BaseHandlerTest { - - public void test() { - InputStream is = getClass().getResourceAsStream("/describe_loadbalancers.xml"); - - IterableWithMarker expected = expected(); - - DescribeLoadBalancersResultHandler handler = injector.getInstance(DescribeLoadBalancersResultHandler.class); - IterableWithMarker result = factory.create(handler).parse(is); - - assertEquals(result.toString(), expected.toString()); - - } - - public IterableWithMarker expected() { - return IterableWithMarkers.from(ImmutableSet.of( - LoadBalancer.builder() - .name("my-load-balancer") - .createdTime(new SimpleDateFormatDateService().iso8601DateParse("2010-03-03T20:54:45.110Z")) - .dnsName("my-load-balancer-1400212309.us-east-1.elb.amazonaws.com") - .healthCheck(HealthCheck.builder() - .interval(300) - .target("HTTP:80/index.html") - .healthyThreshold(3) - .timeout(30) - .unhealthyThreshold(5).build()) - .instanceIds(ImmutableSet.of("i-5b33e630", "i-8f26d7e4", "i-5933e632")) - .listener(ListenerWithPolicies.builder().protocol(Protocol.HTTP).port(80).instancePort(80).build()) - .listener(ListenerWithPolicies.builder().protocol(Protocol.TCP).port(443).instancePort(443).build()) - .availabilityZone("us-east-1a") - .build())); - } - -} diff --git a/labs/elb/src/test/java/org/jclouds/elb/parse/DescribeVPCLoadBalancersResponseTest.java b/labs/elb/src/test/java/org/jclouds/elb/parse/DescribeVPCLoadBalancersResponseTest.java deleted file mode 100644 index a2e4229ff1..0000000000 --- a/labs/elb/src/test/java/org/jclouds/elb/parse/DescribeVPCLoadBalancersResponseTest.java +++ /dev/null @@ -1,90 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.elb.parse; - -import static org.testng.Assert.assertEquals; - -import java.io.InputStream; - -import org.jclouds.collect.IterableWithMarker; -import org.jclouds.collect.IterableWithMarkers; -import org.jclouds.date.internal.SimpleDateFormatDateService; -import org.jclouds.elb.domain.HealthCheck; -import org.jclouds.elb.domain.ListenerWithPolicies; -import org.jclouds.elb.domain.LoadBalancer; -import org.jclouds.elb.domain.Protocol; -import org.jclouds.elb.domain.Scheme; -import org.jclouds.elb.xml.DescribeLoadBalancersResultHandler; -import org.jclouds.http.functions.BaseHandlerTest; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableSet; - -/** - * @author Adrian Cole - */ -// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire -@Test(groups = "unit", testName = "DescribeVPCLoadBalancersResponseTest") -public class DescribeVPCLoadBalancersResponseTest extends BaseHandlerTest { - - public void test() { - InputStream is = getClass().getResourceAsStream("/describe_loadbalancers_vpc.xml"); - - IterableWithMarker expected = expected(); - - DescribeLoadBalancersResultHandler handler = injector.getInstance(DescribeLoadBalancersResultHandler.class); - IterableWithMarker result = factory.create(handler).parse(is); - - assertEquals(result.toString(), expected.toString()); - - } - - public IterableWithMarker expected() { - return IterableWithMarkers.from(ImmutableSet.of( - LoadBalancer.builder() - .name("tests") - .createdTime(new SimpleDateFormatDateService().iso8601DateParse("2012-07-08T19:54:24.190Z")) - .dnsName("tests-144598086.us-east-1.elb.amazonaws.com") - .healthCheck(HealthCheck.builder() - .interval(30) - .target("TCP:22") - .healthyThreshold(10) - .timeout(5) - .unhealthyThreshold(2).build()) - .instanceIds(ImmutableSet.of("i-64bd081c")) - .listener(ListenerWithPolicies.builder() - .policyName("AWSConsolePolicy-1") - .protocol(Protocol.HTTP) - .port(80).build()) - .listener(ListenerWithPolicies.builder() - .protocol(Protocol.TCP) - .port(25) - .instancePort(22).build()) - .availabilityZone("us-east-1e") - .VPCId("vpc-56e10e3d") - .scheme(Scheme.INTERNET_FACING) - .subnet("subnet-28e10e43") - .securityGroup("sg-6ba54204") - .securityGroup("sg-99a641f6") - .hostedZoneName("tests-144598086.us-east-1.elb.amazonaws.com") - .hostedZoneId("Z3DZXE0Q79N41H") - .build())); - } - -} diff --git a/labs/elb/src/test/java/org/jclouds/elb/parse/GetLoadBalancerResponseTest.java b/labs/elb/src/test/java/org/jclouds/elb/parse/GetLoadBalancerResponseTest.java deleted file mode 100644 index 8496ab89be..0000000000 --- a/labs/elb/src/test/java/org/jclouds/elb/parse/GetLoadBalancerResponseTest.java +++ /dev/null @@ -1,76 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.elb.parse; - -import static org.testng.Assert.assertEquals; - -import java.io.InputStream; - -import org.jclouds.date.internal.SimpleDateFormatDateService; -import org.jclouds.elb.domain.HealthCheck; -import org.jclouds.elb.domain.ListenerWithPolicies; -import org.jclouds.elb.domain.LoadBalancer; -import org.jclouds.elb.domain.Protocol; -import org.jclouds.elb.xml.LoadBalancerHandler; -import org.jclouds.http.functions.BaseHandlerTest; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableSet; - -/** - * @author Adrian Cole - */ -// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire -@Test(groups = "unit", testName = "GetLoadBalancerResponseTest") -public class GetLoadBalancerResponseTest extends BaseHandlerTest { - - public void test() { - InputStream is = getClass().getResourceAsStream("/describe_loadbalancers.xml"); - - LoadBalancer expected = expected(); - - LoadBalancerHandler handler = injector.getInstance(LoadBalancerHandler.class); - LoadBalancer result = factory.create(handler).parse(is); - - assertEquals(result, expected); - assertEquals(result.getCreatedTime(), expected.getCreatedTime()); - assertEquals(result.getDnsName(), expected.getDnsName()); - assertEquals(result.getHealthCheck(), expected.getHealthCheck()); - assertEquals(result.getScheme(), expected.getScheme()); - assertEquals(result.getVPCId(), expected.getVPCId()); - } - - public LoadBalancer expected() { - return LoadBalancer.builder() - .name("my-load-balancer") - .createdTime(new SimpleDateFormatDateService().iso8601DateParse("2010-03-03T20:54:45.110Z")) - .dnsName("my-load-balancer-1400212309.us-east-1.elb.amazonaws.com") - .healthCheck(HealthCheck.builder() - .interval(300) - .target("HTTP:80/index.html") - .healthyThreshold(3) - .timeout(30) - .unhealthyThreshold(5).build()) - .instanceIds(ImmutableSet.of("i-5b33e630", "i-8f26d7e4", "i-5933e632")) - .listener(ListenerWithPolicies.builder().protocol(Protocol.HTTP).port(80).instancePort(80).build()) - .listener(ListenerWithPolicies.builder().protocol(Protocol.TCP).port(443).instancePort(443).build()) - .availabilityZone("us-east-1a") - .build(); - } -} diff --git a/labs/elb/src/test/java/org/jclouds/elb/parse/GetPolicyResponseTest.java b/labs/elb/src/test/java/org/jclouds/elb/parse/GetPolicyResponseTest.java deleted file mode 100644 index 25813c1e9d..0000000000 --- a/labs/elb/src/test/java/org/jclouds/elb/parse/GetPolicyResponseTest.java +++ /dev/null @@ -1,58 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.elb.parse; - -import static org.testng.Assert.assertEquals; - -import java.io.InputStream; - -import org.jclouds.elb.domain.Policy; -import org.jclouds.elb.xml.PolicyHandler; -import org.jclouds.http.functions.BaseHandlerTest; -import org.testng.annotations.Test; - -/** - * @author Adrian Cole - */ -// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire -@Test(groups = "unit", testName = "GetPolicyResponseTest") -public class GetPolicyResponseTest extends BaseHandlerTest { - - public void test() { - InputStream is = getClass().getResourceAsStream("/describe_policy.xml"); - - Policy expected = expected(); - - PolicyHandler handler = injector.getInstance(PolicyHandler.class); - Policy result = factory.create(handler).parse(is); - - assertEquals(result, expected); - assertEquals(result.getAttributes(), expected.getAttributes()); - } - - public Policy expected() { - return Policy.builder() - .name("ELBSample-OpenSSLDefaultNegotiationPolicy") - .typeName("SSLNegotiationPolicyType") - .attribute("Protocol-SSLv2", false) - .attribute("ADH-AES256-SHA", false) - .attribute("DHE-RSA-AES256-SHA", true) - .build(); - } -} diff --git a/labs/elb/src/test/java/org/jclouds/elb/parse/GetPolicyTypeResponseTest.java b/labs/elb/src/test/java/org/jclouds/elb/parse/GetPolicyTypeResponseTest.java deleted file mode 100644 index 04fd37005c..0000000000 --- a/labs/elb/src/test/java/org/jclouds/elb/parse/GetPolicyTypeResponseTest.java +++ /dev/null @@ -1,62 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.elb.parse; - -import static org.testng.Assert.assertEquals; - -import java.io.InputStream; - -import org.jclouds.elb.domain.AttributeMetadata; -import org.jclouds.elb.domain.AttributeMetadata.Cardinality; -import org.jclouds.elb.domain.PolicyType; -import org.jclouds.elb.xml.PolicyTypeHandler; -import org.jclouds.http.functions.BaseHandlerTest; -import org.testng.annotations.Test; - -/** - * @author Adrian Cole - */ -// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire -@Test(groups = "unit", testName = "GetPolicyTypeResponseTest") -public class GetPolicyTypeResponseTest extends BaseHandlerTest { - - public void test() { - InputStream is = getClass().getResourceAsStream("/describe_policy_type.xml"); - - PolicyType expected = expected(); - - PolicyTypeHandler handler = injector.getInstance(PolicyTypeHandler.class); - PolicyType result = factory.create(handler).parse(is); - - assertEquals(result, expected); - } - - public PolicyType expected() { - return PolicyType.builder() - .attributeMetadata(AttributeMetadata.builder() - .name("PublicKey") - .type(String.class) - .rawType("String") - .cardinality(Cardinality.ONE) - .build()) - .name("PublicKeyPolicyType") - .description("Policy containing a list of public keys to accept when authenticating the back-end server(s). This policy cannot be applied directly to back-end servers or listeners but must be part of a BackendServerAuthenticationPolicyType.") - .build(); - } -} diff --git a/labs/elb/src/test/java/org/jclouds/elb/parse/InstancesResultHandlerTest.java b/labs/elb/src/test/java/org/jclouds/elb/parse/InstancesResultHandlerTest.java deleted file mode 100644 index 28af89e8a3..0000000000 --- a/labs/elb/src/test/java/org/jclouds/elb/parse/InstancesResultHandlerTest.java +++ /dev/null @@ -1,54 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.elb.parse; - -import static org.testng.Assert.assertEquals; - -import java.io.InputStream; -import java.util.Set; - -import org.jclouds.elb.xml.InstancesResultHandler; -import org.jclouds.http.functions.BaseHandlerTest; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableSet; - -/** - * @author Adrian Cole - */ -// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire -@Test(groups = "unit", testName = "InstancesResultHandlerTest") -public class InstancesResultHandlerTest extends BaseHandlerTest { - - public void test() { - InputStream is = getClass().getResourceAsStream("/instances.xml"); - - Set expected = expected(); - - InstancesResultHandler handler = injector.getInstance(InstancesResultHandler.class); - Set result = factory.create(handler).parse(is); - - assertEquals(result.toString(), expected.toString()); - - } - - public Set expected() { - return ImmutableSet.of("i-6055fa09", "i-9055fa55"); - } -} diff --git a/labs/elb/src/test/resources/describe_instancehealth.xml b/labs/elb/src/test/resources/describe_instancehealth.xml deleted file mode 100644 index 98b81f0214..0000000000 --- a/labs/elb/src/test/resources/describe_instancehealth.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - Instance is in terminated state. - i-64bd081c - OutOfService - Instance - - - - - 6fb803d5-ca15-11e1-ba7e-87298bc8b11d - - \ No newline at end of file diff --git a/labs/elb/src/test/resources/describe_loadbalancers.xml b/labs/elb/src/test/resources/describe_loadbalancers.xml deleted file mode 100644 index 787ee8dda1..0000000000 --- a/labs/elb/src/test/resources/describe_loadbalancers.xml +++ /dev/null @@ -1,63 +0,0 @@ - - - - - my-load-balancer - 2010-03-03T20:54:45.110Z - my-load-balancer-1400212309.us-east-1.elb.amazonaws.com - - 300 - HTTP:80/index.html - 3 - 30 - 5 - - - - - - HTTP - 80 - 80 - - - - - - TCP - 443 - 443 - - - - - - i-5b33e630 - - - i-8f26d7e4 - - - i-5933e632 - - - - - - MyCookie - MyLoadBalancerPolicy - - - - - - us-east-1a - - - - - - 10e2b9c9-3899-11df-a1e2-b5349194c035 - - diff --git a/labs/elb/src/test/resources/describe_loadbalancers_marker.xml b/labs/elb/src/test/resources/describe_loadbalancers_marker.xml deleted file mode 100644 index bb86e540e5..0000000000 --- a/labs/elb/src/test/resources/describe_loadbalancers_marker.xml +++ /dev/null @@ -1,64 +0,0 @@ - - - - - my-load-balancer-1 - 2010-03-03T20:54:45.110Z - my-load-balancer-1400212309.us-east-1.elb.amazonaws.com - - 300 - HTTP:80/index.html - 3 - 30 - 5 - - - - - - HTTP - 80 - 80 - - - - - - TCP - 443 - 443 - - - - - - i-5b33e630 - - - i-8f26d7e4 - - - i-5933e632 - - - - - - MyCookie - MyLoadBalancerPolicy - - - - - - us-east-1a - - - - MARKER - - - 10e2b9c9-3899-11df-a1e2-b5349194c035 - - diff --git a/labs/elb/src/test/resources/describe_loadbalancers_vpc.xml b/labs/elb/src/test/resources/describe_loadbalancers_vpc.xml deleted file mode 100644 index 38cd460666..0000000000 --- a/labs/elb/src/test/resources/describe_loadbalancers_vpc.xml +++ /dev/null @@ -1,73 +0,0 @@ - - - - - - sg-6ba54204 - sg-99a641f6 - - tests - 2012-07-08T19:54:24.190Z - - 30 - TCP:22 - 10 - 5 - 2 - - vpc-56e10e3d - - - - AWSConsolePolicy-1 - - - HTTP - 80 - HTTP - 80 - - - - - - TCP - 25 - TCP - 22 - - - - - - i-64bd081c - - - - - - - - AWSConsolePolicy-1 - 30 - - - - - us-east-1e - - tests-144598086.us-east-1.elb.amazonaws.com - Z3DZXE0Q79N41H - internet-facing - tests-144598086.us-east-1.elb.amazonaws.com - - - subnet-28e10e43 - - - - - - c7aa8000-c94d-11e1-b952-e56e755e80dd - - \ No newline at end of file diff --git a/labs/elb/src/test/resources/describe_policies.xml b/labs/elb/src/test/resources/describe_policies.xml deleted file mode 100644 index 9e8f6a5f16..0000000000 --- a/labs/elb/src/test/resources/describe_policies.xml +++ /dev/null @@ -1,41 +0,0 @@ - - - - - ELBSample-OpenSSLDefaultNegotiationPolicy - SSLNegotiationPolicyType - - - Protocol-SSLv2 - false - - - ADH-AES256-SHA - false - - - DHE-RSA-AES256-SHA - true - - - - - ELBSample-ELBDefaultNegotiationPolicy - SSLNegotiationPolicyType - - - Protocol-SSLv2 - false - - - EDH-DSS-DES-CBC3-SHA - false - - - - - - - a60aacd5-c3c0-11e1-afb7-8f588567225c - - \ No newline at end of file diff --git a/labs/elb/src/test/resources/describe_policy.xml b/labs/elb/src/test/resources/describe_policy.xml deleted file mode 100644 index 76ca5e2dd4..0000000000 --- a/labs/elb/src/test/resources/describe_policy.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - - - ELBSample-OpenSSLDefaultNegotiationPolicy - SSLNegotiationPolicyType - - - Protocol-SSLv2 - false - - - ADH-AES256-SHA - false - - - DHE-RSA-AES256-SHA - true - - - - - - - a60aacd5-c3c0-11e1-afb7-8f588567225c - - \ No newline at end of file diff --git a/labs/elb/src/test/resources/describe_policy_type.xml b/labs/elb/src/test/resources/describe_policy_type.xml deleted file mode 100644 index 656e50f409..0000000000 --- a/labs/elb/src/test/resources/describe_policy_type.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - PublicKey - String - ONE - - - PublicKeyPolicyType - Policy containing a list of public keys to accept when authenticating the back-end server(s). This policy cannot be applied directly to back-end servers or listeners but must be part of a BackendServerAuthenticationPolicyType. - - - - - 261327c5-c3d7-11e1-8582-35377554a47d - - \ No newline at end of file diff --git a/labs/elb/src/test/resources/describe_policy_types.xml b/labs/elb/src/test/resources/describe_policy_types.xml deleted file mode 100644 index fb5480c8a3..0000000000 --- a/labs/elb/src/test/resources/describe_policy_types.xml +++ /dev/null @@ -1,71 +0,0 @@ - - - - - - - PublicKey - String - ONE - - - PublicKeyPolicyType - Policy containing a list of public keys to accept when authenticating the back-end server(s). This policy cannot be applied directly to back-end servers or listeners but must be part of a BackendServerAuthenticationPolicyType. - - - - - CookieName - String - ONE - - - AppCookieStickinessPolicyType - Stickiness policy with session lifetimes controlled by the lifetime of the application-generated cookie. This policy can be associated only with HTTP/HTTPS listeners. - - - - - CookieExpirationPeriod - Long - ZERO_OR_ONE - - - LBCookieStickinessPolicyType - Stickiness policy with session lifetimes controlled by the browser (user-agent) or a specified expiration period. This policy can be associated only with HTTP/HTTPS listeners. - - - - - Protocol-SSLv2 - Boolean - false - ZERO_OR_ONE - - - Protocol-TLSv1 - Boolean - true - ZERO_OR_ONE - - - SSLNegotiationPolicyType - Listener policy that defines the ciphers and protocols that will be accepted by the load balancer. This policy can be associated only with HTTPS/SSL listeners. - - - - - PublicKeyPolicyName - PolicyName - ONE_OR_MORE - - - BackendServerAuthenticationPolicyType - Policy that controls authentication to back-end server(s) and contains one or more policies, such as an instance of a PublicKeyPolicyType. This policy can be associated only with back-end servers that are using HTTPS/SSL. - - - - - 261327c5-c3d7-11e1-8582-35377554a47d - - \ No newline at end of file diff --git a/labs/elb/src/test/resources/instances.xml b/labs/elb/src/test/resources/instances.xml deleted file mode 100644 index 7b90c37911..0000000000 --- a/labs/elb/src/test/resources/instances.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - i-6055fa09 - i-9055fa55 - - - diff --git a/labs/elb/src/test/resources/logback.xml b/labs/elb/src/test/resources/logback.xml deleted file mode 100644 index b8b86bf55d..0000000000 --- a/labs/elb/src/test/resources/logback.xml +++ /dev/null @@ -1,77 +0,0 @@ - - - - target/test-data/jclouds.log - - - %d %-5p [%c] [%thread] %m%n - - - - - target/test-data/jclouds-wire.log - - - %d %-5p [%c] [%thread] %m%n - - - - - target/test-data/jclouds-loadbalancer.log - - - %d %-5p [%c] [%thread] %m%n - - - - - target/test-data/jclouds-compute.log - - - %d %-5p [%c] [%thread] %m%n - - - - - target/test-data/jclouds-ssh.log - - - %d %-5p [%c] [%thread] %m%n - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/labs/elb/src/test/resources/zones.xml b/labs/elb/src/test/resources/zones.xml deleted file mode 100644 index d542e018d0..0000000000 --- a/labs/elb/src/test/resources/zones.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - us-east-1c - - - - 04343154-ca27-11e1-b4e4-0b6ac7b9ca3a - - diff --git a/labs/fgcp-au/pom.xml b/labs/fgcp-au/pom.xml deleted file mode 100644 index 3a3050bbe9..0000000000 --- a/labs/fgcp-au/pom.xml +++ /dev/null @@ -1,160 +0,0 @@ - - - - 4.0.0 - - org.jclouds.labs - jclouds-labs-project - 1.7.0-SNAPSHOT - ../project/pom.xml - - fgcp-au - jclouds Fujitsu Global Cloud Platform AU provider - jclouds components to access Fujitsu Global Cloud Platform in Australia - http://globalcloud.fujitsu.com.au - - bundle - - - - Dies Koper - dkoper - diesk -at- fast -dot- au -dot- fujitsu -dot- com - Fujitsu - - Java Developer - - +10 - - - - - UTF-8 - https://api.globalcloud.fujitsu.com.au/ovissapi/endpoint - 2011-01-31 - - fgcp-id - fgcp-cred - - - - org.jclouds.fujitsu.fgcp*;version="${project.version}" - - org.jclouds.labs*;version="${project.version}", - org.jclouds.providers*;version="${jclouds.version}", - * - - - - - - - org.jclouds - jclouds-compute - ${jclouds.version} - - - org.jclouds.driver - jclouds-sshj - ${jclouds.version} - test - - - org.jclouds.driver - jclouds-log4j - ${jclouds.version} - test - - - org.jclouds - jclouds-core - ${jclouds.version} - test-jar - test - - - org.jclouds - jclouds-compute - ${jclouds.version} - test-jar - test - - - org.testng - testng - test - - - org.easymock - easymockclassextension - test - - - org.jclouds.labs - fgcp - ${project.version} - - - org.jclouds.labs - fgcp - ${project.version} - test-jar - test - - - - - - live - - - - org.apache.maven.plugins - maven-surefire-plugin - - - integration - integration-test - - test - - - - ${test.fgcp-au.identity} - ${test.fgcp-au.credential} - ${test.fgcp-au.endpoint} - ${test.fgcp-au.apiversion} - ${test.fgcp-au.build-version} - ${test.fgcp-au.image-id} - ${test.fgcp-au.image.login-user} - ${test.fgcp-au.image.authenticate-sudo} - - - - - - - - - - - diff --git a/labs/fgcp-au/src/main/java/org/jclouds/fujitsu/fgcp/FGCPAUProviderMetadata.java b/labs/fgcp-au/src/main/java/org/jclouds/fujitsu/fgcp/FGCPAUProviderMetadata.java deleted file mode 100644 index 54ca5805c4..0000000000 --- a/labs/fgcp-au/src/main/java/org/jclouds/fujitsu/fgcp/FGCPAUProviderMetadata.java +++ /dev/null @@ -1,77 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp; - -import java.net.URI; - -import org.jclouds.providers.ProviderMetadata; -import org.jclouds.providers.internal.BaseProviderMetadata; - -/** - * Implementation of {@link org.jclouds.providers.ProviderMetadata} for FGCP. - * - * @author Dies Koper - */ -public class FGCPAUProviderMetadata extends FGCPProviderMetadata { - - public static Builder builder() { - return new Builder(); - } - - public FGCPAUProviderMetadata() { - super(builder()); - } - - public FGCPAUProviderMetadata(Builder builder) { - super(builder); - } - - @Override - public Builder toBuilder() { - return builder().fromProviderMetadata(this); - } - - public static class Builder extends BaseProviderMetadata.Builder { - - protected Builder() { - id("fgcp-au") - .name("Fujitsu Global Cloud Platform (FGCP) - AU") - .apiMetadata(new FGCPApiMetadata()) - .homepage( - URI.create("http://www.fujitsu.com/global/solutions/cloud/solutions/global-cloud-platform/index.html")) - .console(URI.create("http://globalcloud.fujitsu.com.au")) - .defaultProperties(FGCPApiMetadata.defaultProperties()) - .iso3166Codes("AU-NSW") - .endpoint( - "https://api.globalcloud.fujitsu.com.au/ovissapi/endpoint") - .defaultProperties(FGCPProviderMetadata.defaultProperties()); - } - - @Override - public FGCPAUProviderMetadata build() { - return new FGCPAUProviderMetadata(this); - } - - @Override - public Builder fromProviderMetadata(ProviderMetadata in) { - super.fromProviderMetadata(in); - return this; - } - } -} diff --git a/labs/fgcp-au/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata b/labs/fgcp-au/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata deleted file mode 100644 index 83cbc2086a..0000000000 --- a/labs/fgcp-au/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata +++ /dev/null @@ -1 +0,0 @@ -org.jclouds.fujitsu.fgcp.FGCPAUProviderMetadata diff --git a/labs/fgcp-au/src/test/java/org/jclouds/fujitsu/fgcp/FGCPAUProviderTest.java b/labs/fgcp-au/src/test/java/org/jclouds/fujitsu/fgcp/FGCPAUProviderTest.java deleted file mode 100644 index fa37d4d2f2..0000000000 --- a/labs/fgcp-au/src/test/java/org/jclouds/fujitsu/fgcp/FGCPAUProviderTest.java +++ /dev/null @@ -1,34 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp; - -import org.jclouds.providers.internal.BaseProviderMetadataTest; -import org.testng.annotations.Test; - -/** - * @author Dies Koper - */ -@Test(groups = "unit", testName = "FGCPAUProviderTest") -public class FGCPAUProviderTest extends BaseProviderMetadataTest { - - public FGCPAUProviderTest() { - super(new FGCPAUProviderMetadata(), new FGCPApiMetadata()); - } - -} diff --git a/labs/fgcp-au/src/test/java/org/jclouds/fujitsu/fgcp/compute/FGCPAUTemplateBuilderLiveTest.java b/labs/fgcp-au/src/test/java/org/jclouds/fujitsu/fgcp/compute/FGCPAUTemplateBuilderLiveTest.java deleted file mode 100644 index b3881e66df..0000000000 --- a/labs/fgcp-au/src/test/java/org/jclouds/fujitsu/fgcp/compute/FGCPAUTemplateBuilderLiveTest.java +++ /dev/null @@ -1,43 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.compute; - -import java.util.Set; - -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableSet; - -/** - * @author Dies Koper - * - */ -@Test(groups = "live", enabled = true, singleThreaded = true, testName = "FGCPAUTemplateBuilderLiveTest") -public class FGCPAUTemplateBuilderLiveTest extends - FGCPBaseTemplateBuilderLiveTest { - - public FGCPAUTemplateBuilderLiveTest() { - provider = "fgcp-au"; - } - - @Override - protected Set getIso3166Codes() { - return ImmutableSet. of("AU-NSW"); - } -} diff --git a/labs/fgcp-au/src/test/java/org/jclouds/fujitsu/fgcp/compute/config/FGCPAUComputeServiceLiveTest.java b/labs/fgcp-au/src/test/java/org/jclouds/fujitsu/fgcp/compute/config/FGCPAUComputeServiceLiveTest.java deleted file mode 100644 index 15f8ab1c81..0000000000 --- a/labs/fgcp-au/src/test/java/org/jclouds/fujitsu/fgcp/compute/config/FGCPAUComputeServiceLiveTest.java +++ /dev/null @@ -1,37 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.compute.config; - - -import org.testng.annotations.Test; - - -/** - * @author Dies Koper - * - */ -@Test(groups = "live", enabled = true, singleThreaded = true, testName = "FGCPAUComputeServiceLiveTest") -public class FGCPAUComputeServiceLiveTest extends FGCPBaseComputeServiceLiveTest { - - @Override - public void setServiceDefaults() { - provider = "fgcp-au"; - } - -} diff --git a/labs/fgcp-de/pom.xml b/labs/fgcp-de/pom.xml deleted file mode 100644 index af6e84406c..0000000000 --- a/labs/fgcp-de/pom.xml +++ /dev/null @@ -1,160 +0,0 @@ - - - - 4.0.0 - - org.jclouds.labs - jclouds-labs-project - 1.7.0-SNAPSHOT - ../project/pom.xml - - fgcp-de - jclouds Fujitsu Global Cloud Platform DE provider - jclouds components to access Fujitsu Global Cloud Platform in Germany - http://globalcloud.de.fujitsu.com - - bundle - - - - Dies Koper - dkoper - diesk -at- fast -dot- au -dot- fujitsu -dot- com - Fujitsu - - Java Developer - - +10 - - - - - UTF-8 - https://api.globalcloud.de.fujitsu.com/ovissapi/endpoint - 2011-01-31 - - fgcp-id - fgcp-cred - - - - org.jclouds.fujitsu.fgcp*;version="${project.version}" - - org.jclouds.labs*;version="${project.version}", - org.jclouds.providers*;version="${jclouds.version}", - * - - - - - - - org.jclouds - jclouds-compute - ${jclouds.version} - - - org.jclouds.driver - jclouds-sshj - ${jclouds.version} - test - - - org.jclouds.driver - jclouds-log4j - ${jclouds.version} - test - - - org.jclouds - jclouds-core - ${jclouds.version} - test-jar - test - - - org.jclouds - jclouds-compute - ${jclouds.version} - test-jar - test - - - org.testng - testng - test - - - org.easymock - easymockclassextension - test - - - org.jclouds.labs - fgcp - ${project.version} - - - org.jclouds.labs - fgcp - ${project.version} - test-jar - test - - - - - - live - - - - org.apache.maven.plugins - maven-surefire-plugin - - - integration - integration-test - - test - - - - ${test.fgcp-de.identity} - ${test.fgcp-de.credential} - ${test.fgcp-de.endpoint} - ${test.fgcp-de.apiversion} - ${test.fgcp-de.build-version} - ${test.fgcp-de.image-id} - ${test.fgcp-de.image.login-user} - ${test.fgcp-de.image.authenticate-sudo} - - - - - - - - - - - diff --git a/labs/fgcp-de/src/main/java/org/jclouds/fujitsu/fgcp/FGCPDEProviderMetadata.java b/labs/fgcp-de/src/main/java/org/jclouds/fujitsu/fgcp/FGCPDEProviderMetadata.java deleted file mode 100644 index d1a056b02d..0000000000 --- a/labs/fgcp-de/src/main/java/org/jclouds/fujitsu/fgcp/FGCPDEProviderMetadata.java +++ /dev/null @@ -1,77 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp; - -import java.net.URI; - -import org.jclouds.providers.ProviderMetadata; -import org.jclouds.providers.internal.BaseProviderMetadata; - -/** - * Implementation of {@link org.jclouds.providers.ProviderMetadata} for FGCP. - * - * @author Dies Koper - */ -public class FGCPDEProviderMetadata extends FGCPProviderMetadata { - - public static Builder builder() { - return new Builder(); - } - - public FGCPDEProviderMetadata() { - super(builder()); - } - - public FGCPDEProviderMetadata(Builder builder) { - super(builder); - } - - @Override - public Builder toBuilder() { - return builder().fromProviderMetadata(this); - } - - public static class Builder extends BaseProviderMetadata.Builder { - - protected Builder() { - id("fgcp-de") - .name("Fujitsu Global Cloud Platform (FGCP) - DE") - .apiMetadata(new FGCPApiMetadata()) - .homepage( - URI.create("http://www.fujitsu.com/global/solutions/cloud/solutions/global-cloud-platform/index.html")) - .console(URI.create("http://globalcloud.de.fujitsu.com")) - .defaultProperties(FGCPApiMetadata.defaultProperties()) - .iso3166Codes("DE-BY") - .endpoint( - "https://api.globalcloud.de.fujitsu.com/ovissapi/endpoint") - .defaultProperties(FGCPProviderMetadata.defaultProperties()); - } - - @Override - public FGCPDEProviderMetadata build() { - return new FGCPDEProviderMetadata(this); - } - - @Override - public Builder fromProviderMetadata(ProviderMetadata in) { - super.fromProviderMetadata(in); - return this; - } - } -} diff --git a/labs/fgcp-de/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata b/labs/fgcp-de/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata deleted file mode 100644 index 9e952cb7ea..0000000000 --- a/labs/fgcp-de/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata +++ /dev/null @@ -1 +0,0 @@ -org.jclouds.fujitsu.fgcp.FGCPDEProviderMetadata diff --git a/labs/fgcp-de/src/test/java/org/jclouds/fujitsu/fgcp/FGCPDEProviderTest.java b/labs/fgcp-de/src/test/java/org/jclouds/fujitsu/fgcp/FGCPDEProviderTest.java deleted file mode 100644 index 175cb3d2a4..0000000000 --- a/labs/fgcp-de/src/test/java/org/jclouds/fujitsu/fgcp/FGCPDEProviderTest.java +++ /dev/null @@ -1,34 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp; - -import org.jclouds.providers.internal.BaseProviderMetadataTest; -import org.testng.annotations.Test; - -/** - * @author Dies Koper - */ -@Test(groups = "unit", testName = "FGCPDEProviderTest") -public class FGCPDEProviderTest extends BaseProviderMetadataTest { - - public FGCPDEProviderTest() { - super(new FGCPDEProviderMetadata(), new FGCPApiMetadata()); - } - -} diff --git a/labs/fgcp-de/src/test/java/org/jclouds/fujitsu/fgcp/compute/FGCPDETemplateBuilderLiveTest.java b/labs/fgcp-de/src/test/java/org/jclouds/fujitsu/fgcp/compute/FGCPDETemplateBuilderLiveTest.java deleted file mode 100644 index eaf6aeaf14..0000000000 --- a/labs/fgcp-de/src/test/java/org/jclouds/fujitsu/fgcp/compute/FGCPDETemplateBuilderLiveTest.java +++ /dev/null @@ -1,43 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.compute; - -import java.util.Set; - -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableSet; - -/** - * @author Dies Koper - * - */ -@Test(groups = "live", enabled = true, singleThreaded = true, testName = "FGCPDETemplateBuilderLiveTest") -public class FGCPDETemplateBuilderLiveTest extends - FGCPBaseTemplateBuilderLiveTest { - - public FGCPDETemplateBuilderLiveTest() { - provider = "fgcp-de"; - } - - @Override - protected Set getIso3166Codes() { - return ImmutableSet. of("DE-BY"); - } -} diff --git a/labs/fgcp-de/src/test/java/org/jclouds/fujitsu/fgcp/compute/config/FGCPDEComputeServiceLiveTest.java b/labs/fgcp-de/src/test/java/org/jclouds/fujitsu/fgcp/compute/config/FGCPDEComputeServiceLiveTest.java deleted file mode 100644 index 23f1cd72c7..0000000000 --- a/labs/fgcp-de/src/test/java/org/jclouds/fujitsu/fgcp/compute/config/FGCPDEComputeServiceLiveTest.java +++ /dev/null @@ -1,37 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.compute.config; - - -import org.testng.annotations.Test; - - -/** - * @author Dies Koper - * - */ -@Test(groups = "live", enabled = true, singleThreaded = true, testName = "FGCPDEComputeServiceLiveTest") -public class FGCPDEComputeServiceLiveTest extends FGCPBaseComputeServiceLiveTest { - - @Override - public void setServiceDefaults() { - provider = "fgcp-de"; - } - -} diff --git a/labs/fgcp/pom.xml b/labs/fgcp/pom.xml deleted file mode 100644 index ea0cbcdd17..0000000000 --- a/labs/fgcp/pom.xml +++ /dev/null @@ -1,154 +0,0 @@ - - - - 4.0.0 - - org.jclouds.labs - jclouds-labs-project - 1.7.0-SNAPSHOT - ../project/pom.xml - - fgcp - jclouds Fujitsu Global Cloud Platform - jclouds components to access Fujitsu Global Cloud Platform - - bundle - - - - Dies Koper - dkoper - diesk -at- fast -dot- au -dot- fujitsu -dot- com - Fujitsu - - Java Developer - - +10 - - - - - UTF-8 - https://api.globalcloud.fujitsu.com.au/ovissapi/endpoint - 2011-01-31 - - fgcp-id - fgcp-cred - IMG_3c9820_71OW9NZC268 - - - org.jclouds.fujitsu.fgcp*;version="${project.version}" - - org.jclouds.compute.internal;version="${jclouds.version}", - org.jclouds.rest.internal;version="${jclouds.version}", - org.jclouds.labs*;version="${project.version}", - org.jclouds*;version="${jclouds.version}", - * - - - - - - - org.jclouds - jclouds-compute - ${jclouds.version} - - - org.jclouds.driver - jclouds-sshj - ${jclouds.version} - test - - - org.jclouds.driver - jclouds-log4j - ${jclouds.version} - test - - - org.jclouds - jclouds-core - ${jclouds.version} - test-jar - test - - - org.jclouds - jclouds-compute - ${jclouds.version} - test-jar - test - - - org.testng - testng - test - - - org.easymock - easymockclassextension - test - - - ch.qos.logback - logback-classic - - - - - - - live - - - - org.apache.maven.plugins - maven-surefire-plugin - - - integration - integration-test - - test - - - - ${test.fgcp-au.identity} - ${test.fgcp-au.credential} - ${test.fgcp-au.endpoint} - ${test.fgcp-au.apiversion} - ${test.fgcp-au.build-version} - ${test.fgcp-au.image-id} - ${test.fgcp-au.image.login-user} - ${test.fgcp-au.image.authenticate-sudo} - - - - - - - - - - - diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/FGCPApi.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/FGCPApi.java deleted file mode 100644 index 2b49f1a4c5..0000000000 --- a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/FGCPApi.java +++ /dev/null @@ -1,65 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp; - -import org.jclouds.fujitsu.fgcp.services.AdditionalDiskApi; -import org.jclouds.fujitsu.fgcp.services.DiskImageApi; -import org.jclouds.fujitsu.fgcp.services.FirewallApi; -import org.jclouds.fujitsu.fgcp.services.LoadBalancerApi; -import org.jclouds.fujitsu.fgcp.services.PublicIPAddressApi; -import org.jclouds.fujitsu.fgcp.services.SystemTemplateApi; -import org.jclouds.fujitsu.fgcp.services.VirtualDCApi; -import org.jclouds.fujitsu.fgcp.services.VirtualServerApi; -import org.jclouds.fujitsu.fgcp.services.VirtualSystemApi; -import org.jclouds.rest.annotations.Delegate; - -/** - * Provides synchronous access to FGCP services. - * - * @author Dies Koper - */ -public interface FGCPApi { - - @Delegate - VirtualDCApi getVirtualDCApi(); - - @Delegate - VirtualSystemApi getVirtualSystemApi(); - - @Delegate - VirtualServerApi getVirtualServerApi(); - - @Delegate - AdditionalDiskApi getAdditionalDiskApi(); - - @Delegate - SystemTemplateApi getSystemTemplateApi(); - - @Delegate - DiskImageApi getDiskImageApi(); - - @Delegate - FirewallApi getFirewallApi(); - - @Delegate - LoadBalancerApi getLoadBalancerApi(); - - @Delegate - PublicIPAddressApi getPublicIPAddressApi(); -} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/FGCPApiMetadata.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/FGCPApiMetadata.java deleted file mode 100644 index 47027c5668..0000000000 --- a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/FGCPApiMetadata.java +++ /dev/null @@ -1,97 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp; - -import static org.jclouds.reflect.Reflection2.typeToken; - -import java.net.URI; -import java.util.Properties; - -import org.jclouds.Constants; -import org.jclouds.apis.ApiMetadata; -import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.fujitsu.fgcp.compute.FGCPRestClientModule; -import org.jclouds.fujitsu.fgcp.compute.config.FGCPComputeServiceContextModule; -import org.jclouds.rest.internal.BaseRestApiMetadata; - -import com.google.common.collect.ImmutableSet; -import com.google.inject.Module; - -/** - * Implementation of {@link ApiMetadata} for Fujitsu's Global Cloud Platform (FGCP) - * - * @author Dies Koper - */ -public class FGCPApiMetadata extends BaseRestApiMetadata { - - @Override - public Builder toBuilder() { - return new Builder().fromApiMetadata(this); - } - - public FGCPApiMetadata() { - this(new Builder()); - } - - protected FGCPApiMetadata(Builder builder) { - super(builder); - } - - public static Properties defaultProperties() { - Properties properties = BaseRestApiMetadata.defaultProperties(); - // enables peer verification using the CAs bundled with the JRE (or - // value of javax.net.ssl.trustStore if set) - properties.setProperty(Constants.PROPERTY_TRUST_ALL_CERTS, "false"); - // properties.setProperty("jclouds.ssh.max-retries", "5"); - // properties.setProperty("jclouds.ssh.retry-auth", "true"); - return properties; - } - - public static class Builder extends BaseRestApiMetadata.Builder { - - protected Builder() { - super(FGCPApi.class, FGCPAsyncApi.class); - id("fgcp") - .name("Fujitsu Global Cloud Platform (FGCP)") - .identityName("User certificate (PEM file)") - .credentialName("User certificate password") - .documentation( - URI.create("https://globalcloud.fujitsu.com.au/portala/ctrl/aboutSopManual")) - .version(FGCPAsyncApi.VERSION) - .defaultEndpoint( - "https://api.globalcloud.fujitsu.com.au/ovissapi/endpoint") - .defaultProperties(FGCPApiMetadata.defaultProperties()) - .view(typeToken(ComputeServiceContext.class)) - .defaultModules( - ImmutableSet.> of( - FGCPComputeServiceContextModule.class, - FGCPRestClientModule.class)); - } - - @Override - public FGCPApiMetadata build() { - return new FGCPApiMetadata(this); - } - - @Override - protected Builder self() { - return this; - } - } -} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/FGCPAsyncApi.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/FGCPAsyncApi.java deleted file mode 100644 index ab66f3d643..0000000000 --- a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/FGCPAsyncApi.java +++ /dev/null @@ -1,66 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp; - -import org.jclouds.fujitsu.fgcp.services.AdditionalDiskAsyncApi; -import org.jclouds.fujitsu.fgcp.services.DiskImageAsyncApi; -import org.jclouds.fujitsu.fgcp.services.FirewallAsyncApi; -import org.jclouds.fujitsu.fgcp.services.LoadBalancerAsyncApi; -import org.jclouds.fujitsu.fgcp.services.PublicIPAddressAsyncApi; -import org.jclouds.fujitsu.fgcp.services.SystemTemplateAsyncApi; -import org.jclouds.fujitsu.fgcp.services.VirtualDCAsyncApi; -import org.jclouds.fujitsu.fgcp.services.VirtualServerAsyncApi; -import org.jclouds.fujitsu.fgcp.services.VirtualSystemAsyncApi; -import org.jclouds.rest.annotations.Delegate; - -/** - * Provides asynchronous access to FGCP services. - * - * @author Dies Koper - */ -public interface FGCPAsyncApi { - public static final String VERSION = "2012-02-18"; - - @Delegate - VirtualDCAsyncApi getVirtualDCApi(); - - @Delegate - VirtualSystemAsyncApi getVirtualSystemApi(); - - @Delegate - VirtualServerAsyncApi getVirtualServerApi(); - - @Delegate - AdditionalDiskAsyncApi getAdditionalDiskApi(); - - @Delegate - SystemTemplateAsyncApi getSystemTemplateApi(); - - @Delegate - DiskImageAsyncApi getDiskImageApi(); - - @Delegate - FirewallAsyncApi getFirewallApi(); - - @Delegate - LoadBalancerAsyncApi getLoadBalancerApi(); - - @Delegate - PublicIPAddressAsyncApi getPublicIPAddressApi(); -} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/FGCPProviderMetadata.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/FGCPProviderMetadata.java deleted file mode 100644 index 3b0241e33f..0000000000 --- a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/FGCPProviderMetadata.java +++ /dev/null @@ -1,51 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp; - -import static org.jclouds.compute.config.ComputeServiceProperties.TEMPLATE; - -import java.util.Properties; - -import org.jclouds.providers.internal.BaseProviderMetadata; - -/** - * Base implementation of {@link org.jclouds.providers.ProviderMetadata} for FGCP. - * - * @author Dies Koper - */ -public class FGCPProviderMetadata extends BaseProviderMetadata { - - public static Builder builder() { - return new Builder(); - } - - public FGCPProviderMetadata() { - super(builder()); - } - - public FGCPProviderMetadata(Builder builder) { - super(builder); - } - - public static Properties defaultProperties() { - Properties properties = new Properties(); - properties.setProperty(TEMPLATE, "osFamily=CENTOS,osVersionMatches=6.2,os64Bit=true"); - return properties; - } -} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/binders/BindAlsoToSystemId.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/binders/BindAlsoToSystemId.java deleted file mode 100644 index 887d52b4f4..0000000000 --- a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/binders/BindAlsoToSystemId.java +++ /dev/null @@ -1,70 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.binders; - -import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import javax.inject.Singleton; - -import org.jclouds.http.HttpRequest; -import org.jclouds.http.HttpRequest.Builder; -import org.jclouds.rest.Binder; - -/** - * Adds system id to resource id and binds them to query parameters - * - * @author Dies Koper - */ -@Singleton -public class BindAlsoToSystemId implements Binder { - - /** - * - * @param request - * request where the query params will be set - * @param input - * array of String params - */ - @SuppressWarnings("unchecked") - @Override - public R bindToRequest(R request, Object input) { - - checkNotNull(input); - checkArgument( - input instanceof String, - "this binder only applies to String arguments: " - + input.getClass()); - - Pattern pattern = Pattern.compile("^(\\w+-\\w+)\\b.*"); - Matcher matcher = pattern.matcher((String) input); - - checkArgument(matcher.find(), - "no valid resource id found to construct vsys id from: " - + input.toString()); - - Builder builder = request.toBuilder(); - builder.replaceQueryParam("vsysId", matcher.group(1)); - - return (R) builder.build(); - } -} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/compute/FGCPRestClientModule.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/compute/FGCPRestClientModule.java deleted file mode 100644 index 7a9f94c837..0000000000 --- a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/compute/FGCPRestClientModule.java +++ /dev/null @@ -1,132 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.compute; - -import java.security.KeyStore; -import java.util.Calendar; -import java.util.Map; - -import javax.annotation.Resource; -import javax.net.ssl.SSLContext; - -import org.jclouds.date.TimeStamp; -import org.jclouds.fujitsu.fgcp.FGCPApi; -import org.jclouds.fujitsu.fgcp.FGCPAsyncApi; -import org.jclouds.fujitsu.fgcp.handlers.FGCPRetryIfNotProxyAuthenticationFailureHandler; -import org.jclouds.fujitsu.fgcp.location.SystemAndNetworkSegmentToLocationSupplier; -import org.jclouds.fujitsu.fgcp.services.AdditionalDiskApi; -import org.jclouds.fujitsu.fgcp.services.AdditionalDiskAsyncApi; -import org.jclouds.fujitsu.fgcp.services.BuiltinServerApi; -import org.jclouds.fujitsu.fgcp.services.BuiltinServerAsyncApi; -import org.jclouds.fujitsu.fgcp.services.DiskImageApi; -import org.jclouds.fujitsu.fgcp.services.DiskImageAsyncApi; -import org.jclouds.fujitsu.fgcp.services.FirewallApi; -import org.jclouds.fujitsu.fgcp.services.FirewallAsyncApi; -import org.jclouds.fujitsu.fgcp.services.LoadBalancerApi; -import org.jclouds.fujitsu.fgcp.services.LoadBalancerAsyncApi; -import org.jclouds.fujitsu.fgcp.services.PublicIPAddressApi; -import org.jclouds.fujitsu.fgcp.services.PublicIPAddressAsyncApi; -import org.jclouds.fujitsu.fgcp.services.SystemTemplateApi; -import org.jclouds.fujitsu.fgcp.services.SystemTemplateAsyncApi; -import org.jclouds.fujitsu.fgcp.services.VirtualDCApi; -import org.jclouds.fujitsu.fgcp.services.VirtualDCAsyncApi; -import org.jclouds.fujitsu.fgcp.services.VirtualServerApi; -import org.jclouds.fujitsu.fgcp.services.VirtualServerAsyncApi; -import org.jclouds.fujitsu.fgcp.services.VirtualSystemApi; -import org.jclouds.fujitsu.fgcp.services.VirtualSystemAsyncApi; -import org.jclouds.fujitsu.fgcp.suppliers.KeyStoreSupplier; -import org.jclouds.fujitsu.fgcp.suppliers.SSLContextWithKeysSupplier; -import org.jclouds.fujitsu.fgcp.xml.FGCPJAXBParser; -import org.jclouds.http.HttpRetryHandler; -import org.jclouds.http.annotation.ClientError; -import org.jclouds.location.suppliers.ImplicitLocationSupplier; -import org.jclouds.location.suppliers.LocationsSupplier; -import org.jclouds.location.suppliers.implicit.FirstNetwork; -import org.jclouds.logging.Logger; -import org.jclouds.rest.ConfiguresRestClient; -import org.jclouds.rest.config.RestClientModule; -import org.jclouds.xml.XMLParser; - -import com.google.common.base.Supplier; -import com.google.common.collect.ImmutableMap; -import com.google.inject.Provides; -import com.google.inject.Scopes; -import com.google.inject.TypeLiteral; - -/** - * Configures the FGCP connection. This module is added in FGCPContextBuilder. - * - * @author Dies Koper - */ -@ConfiguresRestClient -public class FGCPRestClientModule extends - RestClientModule { - - @Resource - Logger logger = Logger.NULL; - - public static final Map, Class> DELEGATE_MAP = ImmutableMap - ., Class> builder() - .put(VirtualDCApi.class, VirtualDCAsyncApi.class) - .put(VirtualSystemApi.class, VirtualSystemAsyncApi.class) - .put(VirtualServerApi.class, VirtualServerAsyncApi.class) - .put(AdditionalDiskApi.class, AdditionalDiskAsyncApi.class) - .put(SystemTemplateApi.class, SystemTemplateAsyncApi.class) - .put(DiskImageApi.class, DiskImageAsyncApi.class) - .put(BuiltinServerApi.class, BuiltinServerAsyncApi.class) - .put(FirewallApi.class, FirewallAsyncApi.class) - .put(LoadBalancerApi.class, LoadBalancerAsyncApi.class) - .put(PublicIPAddressApi.class, PublicIPAddressAsyncApi.class) - .build(); - - public FGCPRestClientModule() { - super(DELEGATE_MAP); - } - - @Override - protected void installLocations() { - super.installLocations(); - bind(ImplicitLocationSupplier.class).to(FirstNetwork.class).in(Scopes.SINGLETON); - bind(LocationsSupplier.class).to(SystemAndNetworkSegmentToLocationSupplier.class).in(Scopes.SINGLETON); - } - - @Override - protected void bindRetryHandlers() { - bind(HttpRetryHandler.class).annotatedWith(ClientError.class).to( - FGCPRetryIfNotProxyAuthenticationFailureHandler.class); - } - - @Override - protected void configure() { - super.configure(); - bind(XMLParser.class).to(FGCPJAXBParser.class); - bind(new TypeLiteral>() { - }).to(new TypeLiteral() { - }); - bind(new TypeLiteral>() { - }).to(new TypeLiteral() { - }); - } - - @Provides - @TimeStamp - protected Calendar provideCalendar() { - return Calendar.getInstance(); - } -} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/compute/config/FGCPComputeServiceContextModule.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/compute/config/FGCPComputeServiceContextModule.java deleted file mode 100644 index c455dd1132..0000000000 --- a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/compute/config/FGCPComputeServiceContextModule.java +++ /dev/null @@ -1,140 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.compute.config; - -import org.jclouds.compute.ComputeServiceAdapter; -import org.jclouds.compute.config.ComputeServiceAdapterContextModule; -import org.jclouds.compute.domain.Hardware; -import org.jclouds.compute.domain.Image; -import org.jclouds.compute.domain.NodeMetadata; -import org.jclouds.compute.domain.OperatingSystem; -import org.jclouds.compute.domain.Processor; -import org.jclouds.compute.domain.Volume; -import org.jclouds.compute.options.TemplateOptions; -import org.jclouds.domain.Location; -import org.jclouds.fujitsu.fgcp.compute.functions.CPUToProcessor; -import org.jclouds.fujitsu.fgcp.compute.functions.DiskImageToImage; -import org.jclouds.fujitsu.fgcp.compute.functions.DiskImageToOperatingSystem; -import org.jclouds.fujitsu.fgcp.compute.functions.DiskToVolume; -import org.jclouds.fujitsu.fgcp.compute.functions.ServerTypeToHardware; -import org.jclouds.fujitsu.fgcp.compute.functions.VServerMetadataToNodeMetadata; -import org.jclouds.fujitsu.fgcp.compute.options.FGCPTemplateOptions; -import org.jclouds.fujitsu.fgcp.compute.strategy.FGCPComputeServiceAdapter; -import org.jclouds.fujitsu.fgcp.compute.strategy.VServerMetadata; -import org.jclouds.fujitsu.fgcp.domain.CPU; -import org.jclouds.fujitsu.fgcp.domain.Disk; -import org.jclouds.fujitsu.fgcp.domain.DiskImage; -import org.jclouds.fujitsu.fgcp.domain.ServerType; -import org.jclouds.functions.IdentityFunction; - -import com.google.common.base.Function; -import com.google.inject.TypeLiteral; -//import org.jclouds.fujitsu.fgcp.compute.predicates.ServerStopped; - -/** - * Added in FGCPContextBuilder - * - * @author Dies Koper - */ -public class FGCPComputeServiceContextModule - extends - ComputeServiceAdapterContextModule { - - @SuppressWarnings({ "unchecked", "rawtypes" }) - @Override - protected void configure() { - super.configure(); - // installDependencies(); - - bind( - new TypeLiteral>() { - }).to(FGCPComputeServiceAdapter.class); - - // the following bind functions that map FGCP domain specific resources - // to jclouds' - bind(new TypeLiteral>() { - }).to(VServerMetadataToNodeMetadata.class); - bind(new TypeLiteral>() { - }).to(DiskImageToImage.class); - bind(new TypeLiteral>() { - }).to(DiskImageToOperatingSystem.class); - bind(new TypeLiteral>() { - }).to(ServerTypeToHardware.class); - bind(new TypeLiteral>() { - }).to(DiskToVolume.class); - bind(new TypeLiteral>() { - }).to(CPUToProcessor.class); - - // we aren't converting hardware from a provider-specific type - bind(new TypeLiteral>() { - }).to((Class) IdentityFunction.class); - bind(new TypeLiteral>() { - }).to((Class) IdentityFunction.class); - - bind(TemplateOptions.class).to(FGCPTemplateOptions.class); - - - // bind(new TypeLiteral>() { - // }).to((Class) ServerStopped.class); - - // need to look into the following later for to map (create) jclouds' - // location to FGCP. - // see LocationScope: - // PROVIDER: FGCP - // REGION: country?/country+state? - // ZONE: virtual DC: contractId - // NETWORK: VSYS? DMZ/SECURE1/SECURE2? - // RACK: N/A? - // HOST: N/A? - // there are no locations except the provider - // bind(new TypeLiteral>() { - // }).to(OnlyLocationOrFirstZone.class); - - // install(new FGCPBindComputeStrategiesByClass()); - // install(new FGCPBindComputeSuppliersByClass()); - // bind(ReviseParsedImage.class).to(AWSEC2ReviseParsedImage.class); - // bind(CreateKeyPairAndSecurityGroupsAsNeededAndReturnRunOptions.class).to( - // CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions.class); - // bind(EC2HardwareSupplier.class).to(AWSEC2HardwareSupplier.class); - // bind(EC2TemplateBuilderImpl.class).to(AWSEC2TemplateBuilderImpl.class); - // bind(EC2GetNodeMetadataStrategy.class).to(AWSEC2GetNodeMetadataStrategy.class); - // bind(InstancePresent.class).to(AWSEC2InstancePresent.class); - // bind(EC2CreateNodesInGroupThenAddToSet.class).to(AWSEC2CreateNodesInGroupThenAddToSet.class); - // bind(RunningInstanceToNodeMetadata.class).to(AWSRunningInstanceToNodeMetadata.class); - } - - // @Provides - // @Singleton - // @Named("SECURITY") - // protected Predicate provideServerStopped(ServerStopped - // serverStopped, Timeouts timeouts) { - // return RetryablePredicate.create(serverStopped, - // timeouts.nodeSuspended); - // } - - protected void installDependencies() { - // install(new FGCPComputeServiceDependenciesModule()); - } - - /* - * @Override protected TemplateBuilder provideTemplate(Injector injector, - * TemplateBuilder template) { return - * template.osFamily(CENTOS).os64Bit(true); } - */ -} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/compute/functions/CPUToProcessor.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/compute/functions/CPUToProcessor.java deleted file mode 100644 index 63079a76a0..0000000000 --- a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/compute/functions/CPUToProcessor.java +++ /dev/null @@ -1,45 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.compute.functions; - -import static com.google.common.base.Preconditions.checkNotNull; - -import javax.inject.Singleton; - -import org.jclouds.compute.domain.Processor; -import org.jclouds.fujitsu.fgcp.domain.CPU; - -import com.google.common.base.Function; - -/** - * Created by IntelliJ IDEA. - * - * @author Dies Koper - */ -@Singleton -public class CPUToProcessor implements Function { - - @Override - public Processor apply(CPU cpu) { - checkNotNull(cpu, "cpu"); - - return new Processor(Double.valueOf(cpu.getCores()), Double.valueOf(cpu - .getSpeedPerCore())); - } -} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/compute/functions/DiskImageToImage.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/compute/functions/DiskImageToImage.java deleted file mode 100644 index ca6c063a99..0000000000 --- a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/compute/functions/DiskImageToImage.java +++ /dev/null @@ -1,68 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.compute.functions; - -import static com.google.common.base.Preconditions.checkNotNull; - -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jclouds.compute.domain.Image; -import org.jclouds.compute.domain.Image.Status; -import org.jclouds.compute.domain.ImageBuilder; -import org.jclouds.compute.domain.OperatingSystem; -import org.jclouds.compute.domain.OsFamily; -import org.jclouds.domain.LoginCredentials; -import org.jclouds.fujitsu.fgcp.domain.DiskImage; - -import com.google.common.base.Function; - -/** - * Created by IntelliJ IDEA. - * - * @author Dies Koper - */ -@Singleton -public class DiskImageToImage implements Function { - - private final DiskImageToOperatingSystem diskImageToOperatingSystem; - - @Inject - public DiskImageToImage(DiskImageToOperatingSystem diskImageToOperatingSystem) { - this.diskImageToOperatingSystem = checkNotNull(diskImageToOperatingSystem, "diskImageToOperatingSystem"); - } - - @Override - public Image apply(DiskImage from) { - checkNotNull(from, "disk image"); - - ImageBuilder builder = new ImageBuilder(); - - builder.ids(from.getId()); - builder.name(from.getName()); - builder.description(from.getDescription()); - // in fgcp, if the image is listed it is available - builder.status(Status.AVAILABLE); - OperatingSystem os = diskImageToOperatingSystem.apply(from); - builder.operatingSystem(os); - String user = os.getFamily() == OsFamily.WINDOWS ? "Administrator" : "root"; - builder.defaultCredentials(LoginCredentials.builder().identity(user).noPassword().build()); - return builder.build(); - } -} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/compute/functions/DiskImageToOperatingSystem.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/compute/functions/DiskImageToOperatingSystem.java deleted file mode 100644 index eeab199368..0000000000 --- a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/compute/functions/DiskImageToOperatingSystem.java +++ /dev/null @@ -1,73 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.compute.functions; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import javax.inject.Singleton; - -import org.jclouds.compute.domain.OperatingSystem; -import org.jclouds.compute.domain.OsFamily; -import org.jclouds.compute.util.ComputeServiceUtils; -import org.jclouds.fujitsu.fgcp.domain.DiskImage; - -import com.google.common.base.Function; - -/** - * - * @author Dies Koper - */ -@Singleton -public class DiskImageToOperatingSystem implements - Function { - - private static final Pattern OS_VERSION_PATTERN = Pattern - .compile("^.*?(\\d.*)\\s(32|64).*$"); - - @Override - public OperatingSystem apply(DiskImage image) { - checkNotNull(image, "disk image"); - - // convert to short name rhel to accommodate ComputeServiceUtils - // conventions - String shortOsName = image.getOsName().replace( - "Red Hat Enterprise Linux", "rhel"); - OsFamily osFamily = ComputeServiceUtils - .parseOsFamilyOrUnrecognized(shortOsName); - OperatingSystem.Builder builder = OperatingSystem.builder(); - - builder.name(image.getOsName()); - builder.family(osFamily); - builder.is64Bit(image.getOsName().contains("64bit") - || image.getOsName().contains("64 bit") - || image.getOsName().contains("x64")); - // OsType returns guest type (hvm, pv), which aws-ec2 is mapping to arch - builder.arch(image.getOsType()); - Matcher m = OS_VERSION_PATTERN.matcher(image.getOsName()); - if (m.matches()) { - builder.version(m.group(1)); - } - builder.description(image.getOsName()); - - return builder.build(); - } -} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/compute/functions/DiskToVolume.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/compute/functions/DiskToVolume.java deleted file mode 100644 index e218cf0143..0000000000 --- a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/compute/functions/DiskToVolume.java +++ /dev/null @@ -1,54 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.compute.functions; - -import static com.google.common.base.Preconditions.checkNotNull; - -import javax.inject.Singleton; - -import org.jclouds.compute.domain.Volume; -import org.jclouds.compute.domain.VolumeBuilder; -import org.jclouds.fujitsu.fgcp.domain.Disk; - -import com.google.common.base.Function; - -/** - * Created by IntelliJ IDEA. - * - * @author Dies Koper - */ -@Singleton -public class DiskToVolume implements Function { - - @Override - public Volume apply(Disk disk) { - checkNotNull(disk, "disk"); - - VolumeBuilder builder = new VolumeBuilder(); - - builder.size(1000f * Float.valueOf(disk.getSize())); - // "Disk"'s are additional disks; they can't be booted disk(?) - builder.bootDevice(false); - builder.durable(true); - builder.type(Volume.Type.SAN); - builder.id("type: " + disk.getType() + " usage: " + disk.getUsage()); - - return builder.build(); - } -} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/compute/functions/ResourceIdToFirewallId.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/compute/functions/ResourceIdToFirewallId.java deleted file mode 100644 index 82beebbef8..0000000000 --- a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/compute/functions/ResourceIdToFirewallId.java +++ /dev/null @@ -1,51 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.compute.functions; - -import static com.google.common.base.Preconditions.checkNotNull; - -import javax.inject.Inject; -import javax.inject.Singleton; - -import com.google.common.base.Function; - -/** - * Determines the id of the firewall associated with a virtual system, server, - * load balancer or disk. - * - * @author Dies Koper - */ -@Singleton -public class ResourceIdToFirewallId implements Function { - - private ResourceIdToSystemId toSystemId; - - @Inject - private ResourceIdToFirewallId(ResourceIdToSystemId resourceIdToSystemId) { - this.toSystemId = checkNotNull(resourceIdToSystemId, - "resourceIdToSystemId"); - } - - @Override - public String apply(String id) { - checkNotNull(id, "resource id"); - - return toSystemId.apply(id) + "-S-0001"; - } -} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/compute/functions/ResourceIdToSystemId.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/compute/functions/ResourceIdToSystemId.java deleted file mode 100644 index 229a236101..0000000000 --- a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/compute/functions/ResourceIdToSystemId.java +++ /dev/null @@ -1,52 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.compute.functions; - -import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import javax.inject.Singleton; - -import com.google.common.base.Function; - -/** - * Determines the id of the virtual system that a server, load balancer or disk - * is part of. - * - * @author Dies Koper - */ -@Singleton -public class ResourceIdToSystemId implements Function { - - @Override - public String apply(String id) { - checkNotNull(id, "resource id"); - - Pattern pattern = Pattern.compile("^(\\w+-\\w+)\\b.*"); - Matcher matcher = pattern.matcher((String) id); - - checkArgument(matcher.find(), - "no valid resource id found: " + id.toString()); - - return matcher.group(1); - } -} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/compute/functions/ServerTypeToHardware.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/compute/functions/ServerTypeToHardware.java deleted file mode 100644 index fc0ed61e2c..0000000000 --- a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/compute/functions/ServerTypeToHardware.java +++ /dev/null @@ -1,68 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.compute.functions; - -import static com.google.common.base.Preconditions.checkNotNull; - -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jclouds.compute.domain.Hardware; -import org.jclouds.compute.domain.HardwareBuilder; -import org.jclouds.compute.domain.Image; -import org.jclouds.fujitsu.fgcp.domain.ServerType; - -import com.google.common.base.Function; -import com.google.common.base.Predicates; -import com.google.common.collect.Iterables; - -/** - * Created by IntelliJ IDEA. - * - * @author Dies Koper - */ -@Singleton -public class ServerTypeToHardware implements Function { - private final CPUToProcessor cpuToProcessor; - private final DiskToVolume diskToVolume; - - @Inject - public ServerTypeToHardware(CPUToProcessor cpuToProcessor, - DiskToVolume diskToVolume) { - this.cpuToProcessor = checkNotNull(cpuToProcessor); - this.diskToVolume = checkNotNull(diskToVolume); - } - - @Override - public Hardware apply(ServerType from) { - checkNotNull(from, "ServerType"); - HardwareBuilder builder = new HardwareBuilder(); - - builder.ids(from.getId()); - builder.name(from.getName()); - builder.ram((int) (1000d * Double.valueOf(from.getMemory().getSize()))); - builder.processor(cpuToProcessor.apply(from.getCpu())); - builder.supportsImage(Predicates. alwaysTrue()); - // all servers are 64bit. The OS however may be 32 bit. - builder.is64Bit(true); - builder.volumes(Iterables.transform(from.getDisks(), diskToVolume)); - - return builder.build(); - } -} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/compute/functions/SingleElementResponseToElement.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/compute/functions/SingleElementResponseToElement.java deleted file mode 100644 index 3f672adcb8..0000000000 --- a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/compute/functions/SingleElementResponseToElement.java +++ /dev/null @@ -1,34 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.compute.functions; - -import static com.google.common.base.Preconditions.checkNotNull; - -import org.jclouds.fujitsu.fgcp.xml.internal.SingleElementResponse; - -import com.google.common.base.Function; - -public class SingleElementResponseToElement implements - Function { - - @Override - public Object apply(SingleElementResponse r) { - return checkNotNull(r, "response").getElement(); - } -} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/compute/functions/VServerMetadataToNodeMetadata.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/compute/functions/VServerMetadataToNodeMetadata.java deleted file mode 100644 index 84a0c79c1a..0000000000 --- a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/compute/functions/VServerMetadataToNodeMetadata.java +++ /dev/null @@ -1,245 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.compute.functions; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.List; -import java.util.Map; -import java.util.NoSuchElementException; -import java.util.Set; - -import javax.annotation.Resource; -import javax.inject.Inject; -import javax.inject.Named; -import javax.inject.Singleton; - -import org.jclouds.collect.Memoized; -import org.jclouds.compute.domain.Hardware; -import org.jclouds.compute.domain.Image; -import org.jclouds.compute.domain.NodeMetadata; -import org.jclouds.compute.domain.NodeMetadata.Status; -import org.jclouds.compute.domain.NodeMetadataBuilder; -import org.jclouds.compute.functions.GroupNamingConvention; -import org.jclouds.compute.reference.ComputeServiceConstants; -import org.jclouds.domain.Location; -import org.jclouds.domain.LoginCredentials; -import org.jclouds.fujitsu.fgcp.compute.strategy.VServerMetadata; -import org.jclouds.fujitsu.fgcp.domain.VServer; -import org.jclouds.fujitsu.fgcp.domain.VServerStatus; -import org.jclouds.fujitsu.fgcp.domain.VServerWithVNICs; -import org.jclouds.logging.Logger; - -import com.google.common.base.Function; -import com.google.common.base.Predicate; -import com.google.common.base.Supplier; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Iterables; -import com.google.common.collect.Lists; - -/** - * @author Dies Koper - */ -@Singleton -public class VServerMetadataToNodeMetadata implements - Function { - - public static final Map vServerToStatus = ImmutableMap - . builder() - .put(VServerStatus.DEPLOYING, Status.PENDING) - .put(VServerStatus.RUNNING, Status.RUNNING) - .put(VServerStatus.STOPPING, Status.PENDING) - .put(VServerStatus.STOPPED, Status.SUSPENDED) - .put(VServerStatus.STARTING, Status.PENDING) - .put(VServerStatus.FAILOVER, Status.RUNNING) - .put(VServerStatus.UNEXPECTED_STOP, Status.SUSPENDED) - .put(VServerStatus.RESTORING, Status.PENDING) - .put(VServerStatus.BACKUP_ING, Status.PENDING) - .put(VServerStatus.ERROR, Status.ERROR) - .put(VServerStatus.START_ERROR, Status.ERROR) - .put(VServerStatus.STOP_ERROR, Status.ERROR) - .put(VServerStatus.CHANGE_TYPE, Status.PENDING) - .put(VServerStatus.REGISTERING, Status.PENDING) - .put(VServerStatus.UNRECOGNIZED, Status.UNRECOGNIZED).build(); - - @Resource - @Named(ComputeServiceConstants.COMPUTE_LOGGER) - protected Logger logger = Logger.NULL; - - protected final Supplier> locations; - protected final Supplier> images; - protected final Supplier> hardwares; - protected final GroupNamingConvention nodeNamingConvention; - - private static class FindImageForVServer implements Predicate { - private final VServer server; - - private FindImageForVServer(VServer server) { - this.server = server; - } - - @Override - public boolean apply(Image input) { - return input.getId().equals(server.getDiskimageId()); - } - } - - protected Image parseImage(VServer from) { - try { - return Iterables.find(images.get(), new FindImageForVServer(from)); - } catch (NoSuchElementException e) { - logger.warn("could not find a matching image for server %s", from); - } - return null; - } - - private static class FindHardwareForServerType implements - Predicate { - private final String type; - - private FindHardwareForServerType(String type) { - this.type = type; - } - - @Override - public boolean apply(Hardware input) { - return input.getName().equals(type); - } - } - - protected Hardware parseHardware(String from) { - try { - return Iterables.find(hardwares.get(), - new FindHardwareForServerType(from)); - } catch (NoSuchElementException e) { - logger.warn( - "could not find a matching hardware for server type %s", - from); - } - return null; - } - - private static class FindLocationForVServer implements Predicate { - private final VServerWithVNICs server; - - private FindLocationForVServer(VServerWithVNICs server) { - this.server = server; - } - - @Override - public boolean apply(Location input) { - return input.getId().equals( - Iterables.getLast(server.getVnics()).getNetworkId()); - } - } - - protected Location parseLocation(VServerWithVNICs from) { - try { - return Iterables.find(locations.get(), new FindLocationForVServer( - from)); - } catch (NoSuchElementException e) { - logger.warn("could not find a matching realm for server %s", from); - } - return null; - } - - @Inject - VServerMetadataToNodeMetadata( - @Memoized Supplier> locations, - @Memoized Supplier> images, - @Memoized Supplier> hardwares, - GroupNamingConvention.Factory namingConvention) { - this.images = checkNotNull(images, "images"); - this.locations = checkNotNull(locations, "locations"); - this.hardwares = checkNotNull(hardwares, "hardwares"); - this.nodeNamingConvention = checkNotNull(namingConvention, - "namingConvention").createWithoutPrefix(); - } - - @Override - public NodeMetadata apply(VServerMetadata from) { - NodeMetadataBuilder builder = new NodeMetadataBuilder(); - - builder.ids(from.getId()); - builder.name(from.getName()); - builder.group(nodeNamingConvention.groupInUniqueNameOrNull(from - .getName())); - if (from.getStatus() == null) - System.out.println("status null for: " + from.getId() + ": " - + from.getName()); - - builder.status(vServerToStatus.get(from.getStatus())); - builder.privateAddresses(ImmutableSet. of()); - builder.publicAddresses(ImmutableSet. of()); - - // - // if (from.getIps() != null) { - // - // builder.publicAddresses(Collections2.transform(from.getIps(), - // new Function() { - // - // @Override - // public String apply(PublicIP input) { - // return input.getAddress(); - // } - // - // })); - // } - - if (from.getServer() != null) { - - builder.imageId(from.getServer().getDiskimageId()); - builder.hardware(parseHardware(from.getServer().getType())); - - LoginCredentials.Builder credentialsBuilder = LoginCredentials - .builder().password(from.getInitialPassword()); - - Image image = parseImage(from.getServer()); - // image will not be found if server was created a while back and - // the image has since been destroyed or discontinued (like an old - // CentOS version) - if (image != null) { - - builder.operatingSystem(image.getOperatingSystem()); - String user = image.getDefaultCredentials().getUser(); - credentialsBuilder.identity(user); - } - - builder.credentials(credentialsBuilder.build()); - - if (from.getServer() instanceof VServerWithVNICs) { - - VServerWithVNICs server = (VServerWithVNICs) from.getServer(); - builder.location(parseLocation(server)); - List ips = Lists.newArrayList(); - if (server.getVnics() != null && server.getVnics().iterator().next().getPrivateIp() != null) { - ips.add(server.getVnics().iterator().next().getPrivateIp()); - } - builder.privateAddresses(ips); - } - } - if (from.getTemplate() != null) { - // when creating a new node - builder.location(from.getTemplate().getLocation()); - } - - return builder.build(); - } -} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/compute/options/FGCPTemplateOptions.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/compute/options/FGCPTemplateOptions.java deleted file mode 100644 index ca11f6c166..0000000000 --- a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/compute/options/FGCPTemplateOptions.java +++ /dev/null @@ -1,29 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.compute.options; - -import org.jclouds.compute.options.TemplateOptions; - -/** - * - * @author Dies Koper - */ -public class FGCPTemplateOptions extends TemplateOptions { - -} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/compute/predicates/ServerStopped.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/compute/predicates/ServerStopped.java deleted file mode 100644 index 4c9c96bc6a..0000000000 --- a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/compute/predicates/ServerStopped.java +++ /dev/null @@ -1,63 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.compute.predicates; - -import javax.annotation.Resource; -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jclouds.fujitsu.fgcp.FGCPApi; -import org.jclouds.fujitsu.fgcp.domain.VServerStatus; -import org.jclouds.logging.Logger; - -import com.google.common.base.Predicate; - -/** - * - * @author Adrian Cole - * @author Dies Koper - * - */ -@Singleton -public class ServerStopped implements Predicate { - - private final FGCPApi api; - - @Resource - protected Logger logger = Logger.NULL; - - @Inject - public ServerStopped(FGCPApi api) { - this.api = api; - } - - public boolean apply(String serverId) { - logger.trace("looking for status on server %s", serverId); - - VServerStatus status = api.getVirtualServerApi().getStatus(serverId); - logger.trace("looking for status on server %s: currently: %s", - serverId, status); - - if (status == VServerStatus.ERROR || status == VServerStatus.STOP_ERROR) - throw new IllegalStateException("server not around or in error: " - + status); - return status == VServerStatus.STOPPED; - } - -} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/compute/predicates/SystemStatusNormal.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/compute/predicates/SystemStatusNormal.java deleted file mode 100644 index c11191edf7..0000000000 --- a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/compute/predicates/SystemStatusNormal.java +++ /dev/null @@ -1,61 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.compute.predicates; - -import javax.annotation.Resource; -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jclouds.fujitsu.fgcp.FGCPApi; -import org.jclouds.fujitsu.fgcp.domain.VSystemStatus; -import org.jclouds.logging.Logger; - -import com.google.common.base.Predicate; - -/** - * - * @author Dies Koper - * - */ -@Singleton -public class SystemStatusNormal implements Predicate { - - private final FGCPApi api; - - @Resource - protected Logger logger = Logger.NULL; - - @Inject - public SystemStatusNormal(FGCPApi api) { - this.api = api; - } - - public boolean apply(String systemId) { - logger.trace("looking for status on system %s", systemId); - - VSystemStatus status = api.getVirtualSystemApi().getStatus(systemId); - logger.trace("looking for status on system %s: currently: %s", - systemId, status); - - if (status == VSystemStatus.ERROR) - throw new IllegalStateException("system in error: " + status); - return status == VSystemStatus.NORMAL; - } - -} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/compute/strategy/FGCPComputeServiceAdapter.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/compute/strategy/FGCPComputeServiceAdapter.java deleted file mode 100644 index 462bc1d0a9..0000000000 --- a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/compute/strategy/FGCPComputeServiceAdapter.java +++ /dev/null @@ -1,288 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.compute.strategy; - -import static com.google.common.base.Preconditions.checkNotNull; -import static org.jclouds.util.Predicates2.retry; - -import java.util.List; -import java.util.Set; -import java.util.concurrent.ExecutionException; - -import javax.annotation.Resource; -import javax.inject.Inject; -import javax.inject.Named; -import javax.inject.Singleton; - -import org.jclouds.compute.ComputeServiceAdapter; -import org.jclouds.compute.domain.OsFamily; -import org.jclouds.compute.domain.Template; -import org.jclouds.compute.reference.ComputeServiceConstants; -import org.jclouds.compute.reference.ComputeServiceConstants.Timeouts; -import org.jclouds.domain.Location; -import org.jclouds.domain.LoginCredentials; -import org.jclouds.fujitsu.fgcp.FGCPApi; -import org.jclouds.fujitsu.fgcp.FGCPAsyncApi; -import org.jclouds.fujitsu.fgcp.compute.functions.ResourceIdToFirewallId; -import org.jclouds.fujitsu.fgcp.compute.functions.ResourceIdToSystemId; -import org.jclouds.fujitsu.fgcp.compute.predicates.ServerStopped; -import org.jclouds.fujitsu.fgcp.compute.predicates.SystemStatusNormal; -import org.jclouds.fujitsu.fgcp.compute.strategy.VServerMetadata.Builder; -import org.jclouds.fujitsu.fgcp.domain.DiskImage; -import org.jclouds.fujitsu.fgcp.domain.ServerType; -import org.jclouds.fujitsu.fgcp.domain.VServerStatus; -import org.jclouds.fujitsu.fgcp.domain.VServerWithDetails; -import org.jclouds.fujitsu.fgcp.domain.VServerWithVNICs; -import org.jclouds.fujitsu.fgcp.domain.VSystem; -import org.jclouds.fujitsu.fgcp.domain.VSystemWithDetails; -import org.jclouds.logging.Logger; - -import com.google.common.base.Predicate; -import com.google.common.base.Throwables; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Lists; -import com.google.common.util.concurrent.Futures; -import com.google.common.util.concurrent.ListenableFuture; - -/** - * Defines the connection between the {@link org.jclouds.fujitsu.fgcp.FGCPApi} - * implementation and the jclouds {@link org.jclouds.compute.ComputeService}. - * Bound in FGCPComputeServiceAdapter. - * - * @author Dies Koper - */ -@Singleton -public class FGCPComputeServiceAdapter implements - ComputeServiceAdapter { - - @Resource - @Named(ComputeServiceConstants.COMPUTE_LOGGER) - protected Logger logger = Logger.NULL; - - private final FGCPApi api; - private final FGCPAsyncApi asyncApi; - protected Predicate serverStopped = null; - protected Predicate serverCreated = null; - protected Predicate systemNormal = null; - protected ResourceIdToFirewallId toFirewallId = null; - protected ResourceIdToSystemId toSystemId = null; - - @Inject - public FGCPComputeServiceAdapter(FGCPApi api, FGCPAsyncApi asyncApi, - ServerStopped serverStopped, SystemStatusNormal systemNormal, - Timeouts timeouts, ResourceIdToFirewallId toFirewallId, - ResourceIdToSystemId toSystemId) { - this.api = checkNotNull(api, "api"); - this.asyncApi = checkNotNull(asyncApi, "asyncApi"); - this.serverStopped = retry(checkNotNull(serverStopped), timeouts.nodeSuspended); - this.serverCreated = retry(checkNotNull(serverStopped), timeouts.nodeRunning); - this.systemNormal = retry(checkNotNull(systemNormal), timeouts.nodeTerminated); - this.toFirewallId = checkNotNull(toFirewallId, "ResourceIdToFirewallId"); - this.toSystemId = checkNotNull(toSystemId, "ResourceIdToSystemId"); - } - - /** - * {@inheritDoc} - */ - @Override - public NodeAndInitialCredentials createNodeWithGroupEncodedIntoName( - String group, String name, Template template) { - // Find vsys (how? create new? default to first found?) - // Target network DMZ/SECURE1/SECURE2 (how? default to DMZ?) - // Determine remaining params: [vserverType,diskImageId,networkId] - // what if no vsys exists yet? Location.AU(.contractId) creates 3? tier - // skeleton vsys and DMZ is picked? - String id = api.getVirtualSystemApi().createServer(name, - template.getHardware().getName(), template.getImage().getId(), - template.getLocation().getId()); - - // wait until fully created (i.e. transitions to stopped status) - serverCreated.apply(id); - resumeNode(id); - VServerMetadata server = getNode(id); - - //do we need this? - server.setTemplate(template); - String user = template.getImage().getOperatingSystem().getFamily() == OsFamily.WINDOWS ? "Administrator" - : "root"; - - return new NodeAndInitialCredentials(server, - id, LoginCredentials.builder().identity(user) - .password(server.getInitialPassword()).build()); - } - - /** - * {@inheritDoc} - */ - @Override - public Iterable listHardwareProfiles() { - return api.getVirtualDCApi().listServerTypes(); - } - - /** - * {@inheritDoc} - */ - @Override - public Iterable listImages() { - return api.getVirtualDCApi().listDiskImages(); - } - - /** - * {@inheritDoc} - */ - @Override - public DiskImage getImage(String id) { - return api.getDiskImageApi().get(id); - } - - /** - * {@inheritDoc} - */ - @Override - public Iterable listLocations() { - // Not using the adapter to determine locations - // see SystemAndNetworkSegmentToLocationSupplier - return ImmutableSet. of(); - } - - /** - * {@inheritDoc} - */ - @Override - public VServerMetadata getNode(String id) { - Builder builder = VServerMetadata.builder(); - builder.id(id); - - List> futures = Lists.newArrayList(); - - futures.add(asyncApi.getVirtualServerApi().getDetails(id)); - futures.add(asyncApi.getVirtualServerApi().getStatus(id)); - futures.add(asyncApi.getVirtualServerApi().getInitialPassword(id)); - // mapped public ips? - String fwId = toFirewallId.apply(id); -// futures.add(asyncApi.getBuiltinServerApi().getConfiguration(fwId, -// BuiltinServerConfiguration.SLB_RULE)); - try { - List results = Futures.successfulAsList(futures).get(); - VServerWithDetails server = (VServerWithDetails) results.get(0); - VServerStatus status = (VServerStatus) results.get(1); - System.out.println("getNode(" + id + ")'s getDetails: " + status +" - " + server); - if (server == null) { - server = api.getVirtualServerApi().getDetails(id); - System.out.println("getNode(" + id + ")'s getDetails(2) returns: " + server); - } - builder.serverWithDetails(server); - builder.status(status == null ? VServerStatus.UNRECOGNIZED : status); -// System.out.println("status in adapter#getNode: " -// + (VServerStatus) results.get(1) -// +" for " -// + server.getId()); - builder.initialPassword((String) results.get(2)); -// SLB slb = ((BuiltinServer) results.get(4)).; -// slb. - } catch (InterruptedException e) { - throw Throwables.propagate(e); - } catch (ExecutionException e) { - throw Throwables.propagate(e); - } - return builder.build(); - } - - /** - * {@inheritDoc} - */ - @Override - public Iterable listNodes() { - ImmutableSet.Builder servers = ImmutableSet - . builder(); - - Set systems = api.getVirtualDCApi().listVirtualSystems(); - List> futures = Lists.newArrayList(); - for (VSystem system : systems) { - - futures.add(asyncApi.getVirtualSystemApi().getDetails( - system.getId())); - } - try { - for (VSystemWithDetails system : Futures.successfulAsList(futures) - .get()) { - - if (system != null) { - - for (VServerWithVNICs server : system.getServers()) { - - // skip FW (S-0001) and SLBs (>0 for SLB) - if (!server.getId().endsWith("-S-0001") && server.getVnics().iterator().next().getNicNo() == 0) { - - servers.add(getNode(server.getId())); -// Builder builder = VServerMetadata.builder(); -// builder.server(server); -// builder.status(VServerStatus.UNRECOGNIZED); -// servers.add(builder.build()); - } - } - } - } - } catch (InterruptedException e) { - throw Throwables.propagate(e); - } catch (ExecutionException e) { - throw Throwables.propagate(e); - } - - return servers.build(); - } - - /** - * {@inheritDoc} - */ - @Override - public void destroyNode(String id) { - api.getVirtualServerApi().destroy(id); - // wait until fully destroyed - String systemId = toSystemId.apply(id); - systemNormal.apply(systemId); - } - - /** - * {@inheritDoc} - */ - @Override - public void rebootNode(String id) { - suspendNode(id); - // wait until fully stopped - serverStopped.apply(id); - resumeNode(id); - } - - /** - * {@inheritDoc} - */ - @Override - public void resumeNode(String id) { - api.getVirtualServerApi().start(id); - } - - /** - * {@inheritDoc} - */ - @Override - public void suspendNode(String id) { - api.getVirtualServerApi().stop(id); - } -} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/compute/strategy/VServerMetadata.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/compute/strategy/VServerMetadata.java deleted file mode 100644 index d0eb0a1680..0000000000 --- a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/compute/strategy/VServerMetadata.java +++ /dev/null @@ -1,178 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.compute.strategy; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.Set; - -import org.jclouds.compute.domain.Template; -import org.jclouds.fujitsu.fgcp.domain.DiskImage; -import org.jclouds.fujitsu.fgcp.domain.PublicIP; -import org.jclouds.fujitsu.fgcp.domain.VServer; -import org.jclouds.fujitsu.fgcp.domain.VServerStatus; -import org.jclouds.fujitsu.fgcp.domain.VServerWithVNICs; - -import com.google.common.collect.ImmutableSet; - -/** - * Holds metadata on a virtual server, both static (name, id, type, etc.) and - * dynamic (status, mapped public IPs, etc.). - * - * @author Dies Koper - */ -public class VServerMetadata { - - protected VServer server; - protected String id; - protected String name; - protected Template template; - protected String initialPassword; - protected VServerStatus status = VServerStatus.UNRECOGNIZED; - protected Set ips; - protected DiskImage image; - - public VServerMetadata(VServer server, String initialPassword, - VServerStatus status, DiskImage image, Set publicIps) { - this.server = checkNotNull(server, "server"); - this.initialPassword = initialPassword; - this.status = status; - this.image = image; - this.ips = publicIps; - id = server.getId(); - name = server.getName(); - } - - public VServerMetadata(String id, String name, Template template, - VServerStatus status) { - this.id = checkNotNull(id, "id"); - this.name = checkNotNull(name, "name"); - this.template = checkNotNull(template, "template"); - this.status = checkNotNull(status, "status"); - } - - public VServer getServer() { - return server; - } - - public String getId() { - return id; - } - - public String getName() { - return name; - } - - public Template getTemplate() { - return template; - } - - public void setTemplate(Template template) { - this.template = template; - } - - public String getInitialPassword() { - return initialPassword; - } - - public VServerStatus getStatus() { - return status; - } - - public Set getIps() { - return ips; - } - - public static Builder builder() { - return new Builder(); - } - - public static class Builder { - private VServer server; - private VServerWithVNICs serverWithDetails; - private String id; - private String name; - private Template template; - private String initialPassword; - private VServerStatus status = VServerStatus.UNRECOGNIZED; - private Set publicIps = ImmutableSet.of(); - private DiskImage image; - - public Builder id(String id) { - this.id = id; - return this; - } - - public Builder name(String name) { - this.name = name; - return this; - } - - public Builder template(Template template) { - this.template = template; - return this; - } - -// public Builder server(VServer server) { -// this.server = server; -// return this; -// } - - public Builder serverWithDetails(VServerWithVNICs serverWithDetails) { - this.serverWithDetails = serverWithDetails; - return this; - } - - public Builder initialPassword(String password) { - this.initialPassword = password; - return this; - } - - public Builder status(VServerStatus status) { - this.status = status; - return this; - } - - public Builder image(DiskImage image) { - this.image = image; - return this; - } - - public Builder publicIps(Set publicIps) { - this.publicIps = publicIps; - return this; - } - - public VServerMetadata build() { - if (initialPassword == null) initialPassword = ""; - if (server != null) { - return new VServerMetadata(server, initialPassword, status, - image, publicIps); - } else if (serverWithDetails != null) { - return new VServerMetadata(serverWithDetails, initialPassword, - status, image, publicIps); - } else { - // sometimes these fields are null because the server is returning a verify error - if (id == null) id = "dummy-id"; - if (name == null) name = "dummy-name"; - return new VServerMetadata(id, name, template, status); - } - } - } -} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/AddressRange.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/AddressRange.java deleted file mode 100644 index 30755a9cc4..0000000000 --- a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/AddressRange.java +++ /dev/null @@ -1,57 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.domain; - -import javax.xml.bind.annotation.XmlRootElement; - -/** - * Describes the address range pool in a contract used for allocating private IP - * address network segments for virtual systems. - * - * @author Dies Koper - */ -@XmlRootElement(name = "addressrange") -public class AddressRange { - private String range; - - private String from; - - private String to; - - /** - * @return the range - */ - public String getRange() { - return range; - } - - /** - * @return the from - */ - public String getFrom() { - return from; - } - - /** - * @return the to - */ - public String getTo() { - return to; - } -} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/BuiltinServer.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/BuiltinServer.java deleted file mode 100644 index cd8325147a..0000000000 --- a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/BuiltinServer.java +++ /dev/null @@ -1,73 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.domain; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; - -/** - * Represents a built-in server, also called extended function module (EFM), - * such as a firewall or load balancer (SLB). - * - * @author Dies Koper - */ -@XmlRootElement(name = "efm") -public class BuiltinServer { - @XmlElement(name = "efmId") - private String id; - @XmlElement(name = "efmType") - private BuiltinServerType builtinServerType; - @XmlElement(name = "efmName") - private String name; - private String creator; - private String slbVip; - private Firewall firewall; - private SLB loadbalancer; - - public enum BuiltinServerType {FW, SLB} - - public String getId() { - return id; - } - - public BuiltinServerType getType() { - return builtinServerType; - } - - public String getName() { - return name; - } - - public String getCreator() { - return creator; - } - - public String getSlbVip() { - return slbVip; - } - - public Firewall getFirewall() { - return firewall; - } - - public SLB getLoadbalancer() { - return loadbalancer; - } - -} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/BuiltinServerBackup.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/BuiltinServerBackup.java deleted file mode 100644 index 8548758f12..0000000000 --- a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/BuiltinServerBackup.java +++ /dev/null @@ -1,75 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.domain; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; - -import com.google.common.base.Objects; - -/** - * Holds information on a backup of a built-in server, such as a firewall or - * load balancer (SLB). - * - * @author Dies Koper - */ -@XmlRootElement(name = "backup") -public class BuiltinServerBackup { - @XmlElement(name = "backupId") - private String id; - @XmlElement(name = "backupTime") - private String time; - - /** - * @return the id - */ - public String getId() { - return id; - } - - /** - * @return the time - */ - public String getTime() { - return time; - } - - @Override - public int hashCode() { - return Objects.hashCode(id); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - BuiltinServerBackup that = BuiltinServerBackup.class.cast(obj); - return Objects.equal(this.id, that.id); - } - - @Override - public String toString() { - return Objects.toStringHelper(this).omitNullValues().add("id", id) - .add("time", time).toString(); - } -} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/BuiltinServerConfiguration.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/BuiltinServerConfiguration.java deleted file mode 100644 index 890c5861b7..0000000000 --- a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/BuiltinServerConfiguration.java +++ /dev/null @@ -1,68 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.domain; - -import static com.google.common.base.Preconditions.checkNotNull; - -import com.google.common.base.CaseFormat; - -/** - * Possible statuses of a built-in server, also called extended function module - * (EFM), such as a firewall or load balancer (SLB). - *

- * In addition to statuses that apply to regular virtual servers, it includes - * statuses relevant to the upgrade process for functionality of the built-in - * server. - * - * @author Dies Koper - */ -public enum BuiltinServerConfiguration { - FW_NAT_RULE, - FW_DNS, - FW_POLICY, - FW_LOG, - FW_LIMIT_POLICY, - SLB_RULE, - SLB_LOAD_STATISTICS, - SLB_ERROR_STATISTICS, - SLB_CERTIFICATE_LIST, - EFM_UPDATE, - SLB_CONNECTION, - UNRECOGNIZED; - - public String value() { - return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, name()); - } - - @Override - public String toString() { - return value(); - } - - public static BuiltinServerConfiguration fromValue(String configuration) { - try { - return valueOf(CaseFormat.UPPER_CAMEL - .to(CaseFormat.UPPER_UNDERSCORE, - checkNotNull(configuration, "configuration"))); - } catch (IllegalArgumentException e) { - return UNRECOGNIZED; - } - } - -} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/BuiltinServerStatus.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/BuiltinServerStatus.java deleted file mode 100644 index cb3886519a..0000000000 --- a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/BuiltinServerStatus.java +++ /dev/null @@ -1,60 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.domain; - -import static com.google.common.base.Preconditions.checkNotNull; - -import javax.xml.bind.annotation.XmlRootElement; - -import com.google.common.base.CaseFormat; - -/** - * Possible statuses of a built-in server, also called extended function module - * (EFM), such as a firewall or load balancer (SLB). - *

- * In addition to statuses that apply to regular virtual servers, it includes - * statuses relevant to the upgrade process for functionality of the built-in - * server. - * - * @author Dies Koper - */ -@XmlRootElement(name = "efmStatus") -public enum BuiltinServerStatus { - DEPLOYING, RUNNING, STOPPING, STOPPED, STARTING, FAILOVER, UNEXPECTED_STOP, RESTORING, BACKUP_ING, ERROR, EXECUTE_NETWORK_SERVER, START_ERROR, STOP_ERROR, UPDATE, BACKOUT, UNRECOGNIZED; - - public String value() { - return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, name()); - } - - @Override - public String toString() { - return value(); - } - - public static BuiltinServerStatus fromValue(String status) { - try { - return valueOf(CaseFormat.UPPER_CAMEL - .to(CaseFormat.UPPER_UNDERSCORE, - checkNotNull(status, "status"))); - } catch (IllegalArgumentException e) { - return UNRECOGNIZED; - } - } - -} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/CPU.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/CPU.java deleted file mode 100644 index f7fa487569..0000000000 --- a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/CPU.java +++ /dev/null @@ -1,77 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.domain; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; - -import com.google.common.base.Objects; - -/** - * Describes the virtual CPU of a server. - * - * @author Dies Koper - */ -@XmlRootElement(name = "cpu") -public class CPU { - @XmlElement(name = "cpuArch") - private String arch; - @XmlElement(name = "cpuPerf") - private double speedPerCore; - @XmlElement(name = "numOfCpu") - private double cores; - - public String getArch() { - return arch; - } - - public double getSpeedPerCore() { - return speedPerCore; - } - - public double getCores() { - return cores; - } - - @Override - public int hashCode() { - return Objects.hashCode(cores, speedPerCore, arch); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - CPU that = CPU.class.cast(obj); - return Objects.equal(this.cores, that.cores) - && Objects.equal(this.speedPerCore, that.speedPerCore) - && Objects.equal(this.arch, that.arch); - } - - @Override - public String toString() { - return Objects.toStringHelper(this).omitNullValues() - .add("cores", cores).add("speedPerCore", speedPerCore) - .add("arch", arch).toString(); - } -} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/Cause.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/Cause.java deleted file mode 100644 index 3e13e10804..0000000000 --- a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/Cause.java +++ /dev/null @@ -1,100 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.domain; - - -/** - * Represents a load balancer (SLB) log entry. - * - * @author Dies Koper - */ -public class Cause { - private String cat; - - private String status; - - private String filePath; - - private String current; - - private String before; - - private String today; - - private String yesterday; - - private String total; - - /** - * @return category - */ - public String getCat() { - return cat; - } - - /** - * @return the status - */ - public String getStatus() { - return status; - } - - /** - * @return the filePath - */ - public String getFilePath() { - return filePath; - } - - /** - * @return the current - */ - public String getCurrent() { - return current; - } - - /** - * @return the before - */ - public String getBefore() { - return before; - } - - /** - * @return the today - */ - public String getToday() { - return today; - } - - /** - * @return the yesterday - */ - public String getYesterday() { - return yesterday; - } - - /** - * @return the total - */ - public String getTotal() { - return total; - } - -} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/Direction.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/Direction.java deleted file mode 100644 index 5b825b261a..0000000000 --- a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/Direction.java +++ /dev/null @@ -1,113 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.domain; - -import java.util.Set; - -import com.google.common.base.Objects; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Sets; - -/** - * Grouping of firewall rules pertaining to a particular direction in network - * traffic, e.g. from the Internet to a server in the DMZ zone, or from a server - * in the SECURE2 zone to the SECURE1 zone, etc. - * - * @author Dies Koper - */ -public class Direction { - private String from; - private String to; - private Set policies = Sets.newLinkedHashSet(); - private Acceptable acceptable; - private Prefix prefix; - private int maxPolicyNum; - - enum Acceptable {OK, NG} - enum Prefix {free, src, dst, proto, srcport, dstport, action, rule, tab} - - /** - * @return the from - */ - public String getFrom() { - return from; - } - - /** - * @return the to - */ - public String getTo() { - return to; - } - - /** - * @return the policies - */ - public Set getPolicies() { - return policies == null ? ImmutableSet. of() : ImmutableSet - .copyOf(policies); - } - - /** - * @return the acceptable - */ - public Acceptable getAcceptable() { - return acceptable; - } - - /** - * @return the prefix - */ - public Prefix getPrefix() { - return prefix; - } - - /** - * @return the maxPolicyNum - */ - public int getMaxPolicyNum() { - return maxPolicyNum; - } - - @Override - public int hashCode() { - return Objects.hashCode(from, to); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - Direction that = Direction.class.cast(obj); - return Objects.equal(this.from, that.from) - && Objects.equal(this.to, that.to); - } - - @Override - public String toString() { - return Objects.toStringHelper(this).omitNullValues().add("from", from) - .add("to", to).add("prefix", prefix).add("policies", policies) - .add("maxPolicyNum", maxPolicyNum) - .add("acceptable", acceptable).toString(); - } -} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/Disk.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/Disk.java deleted file mode 100644 index cae3da8ba3..0000000000 --- a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/Disk.java +++ /dev/null @@ -1,85 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.domain; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; - -/** - * Describes a disk as part of the description of hardware represented by a - * virtual server. - * - * @author Dies Koper - */ -@XmlRootElement -public class Disk { - @XmlElement(name = "diskSize") - private String size; - - @XmlElement(name = "diskUsage") - private String usage; - - @XmlElement(name = "diskType") - private String type; - - public String getSize() { - return size; - } - - public String getUsage() { - return usage; - } - - public String getType() { - return type; - } - - @Override - public boolean equals(Object o) { - if (this == o) - return true; - if (!(o instanceof Disk)) - return false; - - Disk disk = (Disk) o; - - if (size != null ? !size.equals(disk.size) : disk.size != null) - return false; - if (type != null ? !type.equals(disk.type) : disk.type != null) - return false; - if (usage != null ? !usage.equals(disk.usage) : disk.usage != null) - return false; - - return true; - } - - @Override - public int hashCode() { - int result = size != null ? size.hashCode() : 0; - result = 31 * result + (usage != null ? usage.hashCode() : 0); - result = 31 * result + (type != null ? type.hashCode() : 0); - return result; - } - - @Override - public String toString() { - return "Disk{" + "size='" + size + '\'' + ", usage='" + usage + '\'' - + ", type='" + type + '\'' + '}'; - } -} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/DiskImage.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/DiskImage.java deleted file mode 100644 index f4a5e09040..0000000000 --- a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/DiskImage.java +++ /dev/null @@ -1,200 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.domain; - -import java.util.Set; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlElementWrapper; -import javax.xml.bind.annotation.XmlRootElement; - -import com.google.common.base.Objects; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Sets; - -/** - * Represents a disk image with pre-installed OS and/or software. - *

- * It is used as base for the system disk of a virtual server. - * - * @author Dies Koper - */ -@XmlRootElement(name = "diskimage") -public class DiskImage { - @XmlElement(name = "diskimageId") - private String id; - - @XmlElement(name = "diskimageName") - private String name; - - private int size; - - private String osName; - - private String osType; - - private String creatorName; - - private String registrant; - - private String licenseInfo; - - private String description; - - @XmlElementWrapper(name = "softwares") - @XmlElement(name = "software") - private Set software = Sets.newLinkedHashSet(); - - public String getId() { - return id; - } - - public int getSize() { - return size; - } - - public String getOsName() { - return osName; - } - - public String getOsType() { - return osType; - } - - public String getCreatorName() { - return creatorName; - } - - public String getRegistrant() { - return registrant; - } - - public String getLicenseInfo() { - return licenseInfo; - } - - public String getDescription() { - return description; - } - - public String getName() { - return name; - } - - public Set getSoftware() { - return software == null ? ImmutableSet. of() : ImmutableSet - .copyOf(software); - } - - public static Builder builder() { - return new Builder(); - } - - public static class Builder { - private String id; - private String name; - private int size; - private String osName; - private String osType; - private String creatorName; - private String registrant; - private String licenseInfo; - private String description; - private Set software; - - public Builder id(String id) { - this.id = id; - return this; - } - - public Builder name(String name) { - this.name = name; - return this; - } - - public Builder osName(String osName) { - this.osName = osName; - return this; - } - - public Builder osType(String osType) { - this.osType = osType; - return this; - } - - public Builder creatorName(String creatorName) { - this.creatorName = creatorName; - return this; - } - - public Builder registrant(String registrant) { - this.registrant = registrant; - return this; - } - - public Builder description(String description) { - this.description = description; - return this; - } - - public DiskImage build() { - DiskImage image = new DiskImage(); - - image.id = id; - image.name = name; - image.size = size; - image.osName = osName; - image.osType = osType; - image.creatorName = creatorName; - image.registrant = registrant; - image.licenseInfo = licenseInfo; - image.description = description; - image.software = software; - - return image; - } - } - - @Override - public int hashCode() { - return Objects.hashCode(id); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - DiskImage that = DiskImage.class.cast(obj); - return Objects.equal(this.id, that.id); - } - - @Override - public String toString() { - return Objects.toStringHelper(this).omitNullValues().add("id", id) - .add("name", name).add("osName", osName).add("osType", osType) - .add("size", size).add("creatorName", creatorName) - .add("description", description) - .add("licenseInfo", licenseInfo).add("registrant", registrant) - .add("software", software).toString(); - } -} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/ErrorStatistics.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/ErrorStatistics.java deleted file mode 100644 index 56b403eeaf..0000000000 --- a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/ErrorStatistics.java +++ /dev/null @@ -1,53 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.domain; - -import java.util.Set; - -import javax.xml.bind.annotation.XmlRootElement; - -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Sets; - -/** - * Holds statistics of errors reported by a load balancer (SLB). - * - * @author Dies Koper - */ -@XmlRootElement(name = "errorstatistics") -public class ErrorStatistics { - private Period period; - private Set groups = Sets.newLinkedHashSet(); - - /** - * @return the period - */ - public Period getPeriod() { - return period; - } - - /** - * @return the groups - */ - public Set getGroups() { - return groups == null ? ImmutableSet. of() : ImmutableSet - .copyOf(groups); - } - -} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/EventLog.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/EventLog.java deleted file mode 100644 index f9eef692e5..0000000000 --- a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/EventLog.java +++ /dev/null @@ -1,99 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.domain; - -import javax.xml.bind.annotation.XmlRootElement; - -import com.google.common.base.Objects; - -/** - * Represents an entry in the event log. - * - * @author Dies Koper - */ -@XmlRootElement(name = "errorlog") -public class EventLog { - private String title; - private String message; - private String startDate; - private String expiry; - private String entryDate; - - /** - * @return the title - */ - public String getTitle() { - return title; - } - - /** - * @return the message - */ - public String getMessage() { - return message; - } - - /** - * @return the startDate - */ - public String getStartDate() { - return startDate; - } - - /** - * @return the expiry - */ - public String getExpiry() { - return expiry; - } - - /** - * @return the entryDate - */ - public String getEntryDate() { - return entryDate; - } - - @Override - public int hashCode() { - return Objects.hashCode(entryDate, message, title); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - EventLog that = EventLog.class.cast(obj); - return Objects.equal(this.entryDate, that.entryDate) - && Objects.equal(this.message, that.message) - && Objects.equal(this.title, that.title); - } - - @Override - public String toString() { - return Objects.toStringHelper(this).omitNullValues() - .add("entryDate", entryDate).add("title", title) - .add("message", message).add("startDate", startDate) - .add("expiry", expiry).toString(); - } -} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/Firewall.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/Firewall.java deleted file mode 100644 index e419ffc2f7..0000000000 --- a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/Firewall.java +++ /dev/null @@ -1,133 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.domain; - -import java.util.Set; - -import javax.xml.bind.annotation.XmlRootElement; - -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Sets; - -/** - * Represents a firewall (FW). - * - * @author Dies Koper - */ -@XmlRootElement(name = "fw") -public class Firewall { - private NAT nat; - private Set directions = Sets.newLinkedHashSet(); - private String log; - private String status; - private String category; - private String latestVersion; - private String comment; - private boolean firmUpdateExist; - private boolean configUpdateExist; - private String backout; - private String updateDate; - private String currentVersion; - - /** - * @return the nat - */ - public NAT getNat() { - return nat; - } - - /** - * @return the directions - */ - public Set getDirections() { - return directions == null ? ImmutableSet. of() - : ImmutableSet.copyOf(directions); - } - - /** - * @return the log - */ - public String getLog() { - return log; - } - - /** - * @return the status - */ - public String getStatus() { - return status; - } - - /** - * @return the category - */ - public String getCategory() { - return category; - } - - /** - * @return the latestVersion - */ - public String getLatestVersion() { - return latestVersion; - } - - /** - * @return the comment - */ - public String getComment() { - return comment; - } - - /** - * @return the firmUpdateExist - */ - public boolean getFirmUpdateExist() { - return firmUpdateExist; - } - - /** - * @return the configUpdateExist - */ - public boolean getConfigUpdateExist() { - return configUpdateExist; - } - - /** - * @return the backout - */ - public String getBackout() { - return backout; - } - - /** - * @return the updateDate - */ - public String getUpdateDate() { - return updateDate; - } - - /** - * @return the currentVersion - */ - public String getCurrentVersion() { - return currentVersion; - } - -} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/Group.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/Group.java deleted file mode 100644 index 3eb86801ab..0000000000 --- a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/Group.java +++ /dev/null @@ -1,226 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.domain; - -import java.util.Set; - -import javax.xml.bind.annotation.XmlEnumValue; - -import com.google.common.base.Objects; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Sets; - -/** - * Describes attributes of a software load balancer's (SLB) configuration. - * - * @author Dies Koper - */ -public class Group { - private int id; - - private String protocol; - - private int port1; - - private int port2; - - private String balanceType; - - private String uniqueType; - - private String monitorType; - - private int maxConnection; - - private int uniqueRetention; - - private int interval; - - private int timeout; - - private int retryCount; - - private int certNum; - - private Set causes; - - private RecoveryAction recoveryAction; - - private Set targets = Sets.newLinkedHashSet(); - - private String validity; - - enum RecoveryAction { - @XmlEnumValue("switch-back") - SWITCH_BACK, @XmlEnumValue("maintenance") - MAINTENANCE - } - - /** - * @return the id - */ - public int getId() { - return id; - } - - /** - * @return the protocol - */ - public String getProtocol() { - return protocol; - } - - /** - * @return the port1 - */ - public int getPort1() { - return port1; - } - - /** - * @return the port2 - */ - public int getPort2() { - return port2; - } - - /** - * @return the balanceType - */ - public String getBalanceType() { - return balanceType; - } - - /** - * @return the uniqueType - */ - public String getUniqueType() { - return uniqueType; - } - - /** - * @return the monitorType - */ - public String getMonitorType() { - return monitorType; - } - - /** - * @return the maxConnection - */ - public int getMaxConnection() { - return maxConnection; - } - - /** - * @return the uniqueRetention - */ - public int getUniqueRetention() { - return uniqueRetention; - } - - /** - * @return the interval - */ - public int getInterval() { - return interval; - } - - /** - * @return the timeout - */ - public int getTimeout() { - return timeout; - } - - /** - * @return the retryCount - */ - public int getRetryCount() { - return retryCount; - } - - /** - * @return the certNum - */ - public int getCertNum() { - return certNum; - } - - /** - * @return the causes - */ - public Set getCauses() { - return causes == null ? ImmutableSet. of() : ImmutableSet - .copyOf(causes); - } - - /** - * @return the recoveryAction - */ - public RecoveryAction getRecoveryAction() { - return recoveryAction; - } - - /** - * @return the targets - */ - public Set getTargets() { - return targets == null ? ImmutableSet. of() : ImmutableSet - .copyOf(targets); - } - - /** - * @return the validity - */ - public String getValidity() { - return validity; - } - - @Override - public int hashCode() { - return Objects.hashCode(id); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - Group that = Group.class.cast(obj); - return Objects.equal(this.id, that.id); - } - - @Override - public String toString() { - return Objects.toStringHelper(this).omitNullValues().add("id", id) - .add("protocol", protocol).add("port1", port1) - .add("port2", port2).add("balanceType", balanceType) - .add("uniqueType", uniqueType).add("monitorType", monitorType) - .add("maxConnection", maxConnection) - .add("uniqueRetention", uniqueRetention) - .add("interval", interval).add("timeout", timeout) - .add("retryCount", retryCount).add("certNum", certNum) - .add("causes", causes).add("recoveryAction", recoveryAction) - .add("targets", targets).add("validity", validity).toString(); - } -} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/Image.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/Image.java deleted file mode 100644 index ed3b7df8ac..0000000000 --- a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/Image.java +++ /dev/null @@ -1,114 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.domain; - -import java.util.Set; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlElementWrapper; - -import com.google.common.base.Objects; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Sets; - -/** - * Holds information on the system disk image of a virtual server, including the - * OS and software pre-installed on it. - * - * @author Dies Koper - */ -public class Image { - private String id; - - private String serverCategory; - - private String serverApplication; - - private String cpuBit; - - private float sysvolSize; - - private int numOfMaxDisk; - - private int numOfMaxNic; - - @XmlElementWrapper(name = "softwares") - @XmlElement(name = "software") - private Set software = Sets.newLinkedHashSet(); - - public String getId() { - return id; - } - - public String getServerCategory() { - return serverCategory; - } - - public String getServerApplication() { - return serverApplication; - } - - public String getCpuBit() { - return cpuBit; - } - - public float getSysvolSize() { - return sysvolSize; - } - - public int getNumOfMaxDisk() { - return numOfMaxDisk; - } - - public int getNumOfMaxNic() { - return numOfMaxNic; - } - - public Set getSoftware() { - return software == null ? ImmutableSet. of() : ImmutableSet - .copyOf(software); - } - - @Override - public int hashCode() { - return Objects.hashCode(id); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - Image that = Image.class.cast(obj); - return Objects.equal(this.id, that.id); - } - - @Override - public String toString() { - return Objects.toStringHelper(this).omitNullValues().add("id", id) - .add("serverCategory", serverCategory) - .add("serverApplication", serverApplication) - .add("cpuBit", cpuBit).add("sysvolSize", sysvolSize) - .add("numOfMaxDisk", numOfMaxDisk) - .add("numOfMaxNic", numOfMaxNic).toString(); - } -} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/Information.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/Information.java deleted file mode 100644 index 21f292c4e2..0000000000 --- a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/Information.java +++ /dev/null @@ -1,105 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.domain; - -import com.google.common.base.Objects; - -/** - * Holds information relating to the FGCP service. - * - * @author Dies Koper - */ -public class Information { - private int seqno; - private String title; - private String message; - private String startDate; - private String expiry; - private String entryDate; - - /** - * @return the seqno - */ - public int getSeqno() { - return seqno; - } - - /** - * @return the title - */ - public String getTitle() { - return title; - } - - /** - * @return the message - */ - public String getMessage() { - return message; - } - - /** - * @return the startDate - */ - public String getStartDate() { - return startDate; - } - - /** - * @return the expiry - */ - public String getExpiry() { - return expiry; - } - - /** - * @return the entryDate - */ - public String getEntryDate() { - return entryDate; - } - - @Override - public int hashCode() { - return Objects.hashCode(seqno, entryDate, message, title); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - Information that = Information.class.cast(obj); - return Objects.equal(this.seqno, that.seqno) - && Objects.equal(this.entryDate, that.entryDate) - && Objects.equal(this.message, that.message) - && Objects.equal(this.title, that.title); - } - - @Override - public String toString() { - return Objects.toStringHelper(this).omitNullValues() - .add("seqno", seqno).add("entryDate", entryDate) - .add("title", title).add("message", message) - .add("startDate", startDate).add("expiry", expiry).toString(); - } -} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/IntermediateCACert.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/IntermediateCACert.java deleted file mode 100644 index 879171f8f8..0000000000 --- a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/IntermediateCACert.java +++ /dev/null @@ -1,120 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.domain; - -import javax.xml.bind.annotation.XmlRootElement; - -import com.google.common.base.Objects; - -/** - * Describes an intermediate CA certificate for use with a load balancer (SLB). - * - * @author Dies Koper - */ -@XmlRootElement(name = "ccacert") -public class IntermediateCACert implements Comparable { - private int ccacertNum; - - private String description; - - private String subject; - - private String issuer; - - private String validity; - - private String detail; - - /** - * @return the ccacertNum - */ - public int getCcacertNum() { - return ccacertNum; - } - - /** - * @return the description - */ - public String getDescription() { - return description; - } - - /** - * @return the subject - */ - public String getSubject() { - return subject; - } - - /** - * @return the issuer - */ - public String getIssuer() { - return issuer; - } - - /** - * @return the validity - */ - public String getValidity() { - return validity; - } - - /** - * @return the detail - */ - public String getDetail() { - return detail; - } - - @Override - public int hashCode() { - return Objects.hashCode(ccacertNum, issuer, subject, validity); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - IntermediateCACert that = IntermediateCACert.class.cast(obj); - return Objects.equal(this.ccacertNum, that.ccacertNum) - && Objects.equal(this.issuer, that.issuer) - && Objects.equal(this.subject, that.subject) - && Objects.equal(this.validity, that.validity); - } - - @Override - public String toString() { - return Objects.toStringHelper(this).omitNullValues() - .add("ccacertNum", ccacertNum).add("issuer", issuer) - .add("subject", subject).add("validity", validity) - .add("description", description).add("detail", detail) - .toString(); - } - - @Override - public int compareTo(IntermediateCACert o) { - return ccacertNum - o.ccacertNum; - } - -} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/LoadStatistics.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/LoadStatistics.java deleted file mode 100644 index 721801a668..0000000000 --- a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/LoadStatistics.java +++ /dev/null @@ -1,68 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.domain; - -import java.util.Set; - -import javax.xml.bind.annotation.XmlRootElement; - -import com.google.common.base.Objects; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Sets; - -/** - * Holds statistics of the load on a load balancer (SLB). - * - * @author Dies Koper - */ -@XmlRootElement(name = "loadstatistics") -public class LoadStatistics { - private Set groups = Sets.newLinkedHashSet(); - - /** - * @return the groups - */ - public Set getGroups() { - return groups == null ? ImmutableSet. of() : ImmutableSet - .copyOf(groups); - } - - @Override - public int hashCode() { - return Objects.hashCode(groups); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - LoadStatistics that = LoadStatistics.class.cast(obj); - return Objects.equal(this.groups, that.groups); - } - - @Override - public String toString() { - return Objects.toStringHelper(this).omitNullValues() - .add("groups", groups).toString(); - } -} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/Memory.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/Memory.java deleted file mode 100644 index d4bd9df3aa..0000000000 --- a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/Memory.java +++ /dev/null @@ -1,66 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.domain; - -import javax.xml.bind.annotation.XmlElement; - -import com.google.common.base.Objects; - -/** - * Represents the memory of a virtual server. - * - * @author Dies Koper - */ -public class Memory implements Comparable { - @XmlElement(name = "memorySize") - private double size; - - public double getSize() { - return size; - } - - @Override - public int hashCode() { - return Objects.hashCode(size); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - Memory that = Memory.class.cast(obj); - return Objects.equal(this.size, that.size); - } - - @Override - public String toString() { - return Objects.toStringHelper(this).omitNullValues().add("size", size) - .toString(); - } - - @Override - public int compareTo(Memory o) { - return Double.compare(size, o.size); - } - -} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/NAT.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/NAT.java deleted file mode 100644 index ca6b37da6b..0000000000 --- a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/NAT.java +++ /dev/null @@ -1,65 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.domain; - -import java.util.Set; - -import com.google.common.base.Objects; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Sets; - -/** - * Holds the network address translation rules of a firewall. - * - * @author Dies Koper - */ -public class NAT { - private Set rules = Sets.newLinkedHashSet(); - - /** - * @return the rules - */ - public Set getRules() { - return rules == null ? ImmutableSet. of() : ImmutableSet - .copyOf(rules); - } - - @Override - public int hashCode() { - return Objects.hashCode(rules); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - NAT that = NAT.class.cast(obj); - return Objects.equal(this.rules, that.rules); - } - - @Override - public String toString() { - return Objects.toStringHelper(this).omitNullValues() - .add("rules", rules).toString(); - } -} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/PerformanceInfo.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/PerformanceInfo.java deleted file mode 100644 index 37a8b780ee..0000000000 --- a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/PerformanceInfo.java +++ /dev/null @@ -1,149 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.domain; - -import javax.xml.bind.annotation.XmlRootElement; - -import com.google.common.base.Objects; - -/** - * Holds the statistics of a virtual server. - * - * @author Dies Koper - */ -@XmlRootElement(name = "performanceinfo") -public class PerformanceInfo implements Comparable { - private long recordTime; - private double cpuUtilization; - private long diskReadRequestCount; - private long diskWriteRequestCount; - private long diskReadSector; - private long diskWriteSector; - private long nicInputByte; - private long nicOutputByte; - private long nicInputPacket; - private long nicOutputPacket; - - /** - * @return the recordTime - */ - public long getRecordTime() { - return recordTime; - } - - /** - * @return the cpuUtilization - */ - public double getCpuUtilization() { - return cpuUtilization; - } - - /** - * @return the diskReadRequestCount - */ - public long getDiskReadRequestCount() { - return diskReadRequestCount; - } - - /** - * @return the diskWriteRequestCount - */ - public long getDiskWriteRequestCount() { - return diskWriteRequestCount; - } - - /** - * @return the diskReadSector - */ - public long getDiskReadSector() { - return diskReadSector; - } - - /** - * @return the diskWriteSector - */ - public long getDiskWriteSector() { - return diskWriteSector; - } - - /** - * @return the nicInputByte - */ - public long getNicInputByte() { - return nicInputByte; - } - - /** - * @return the nicOutputByte - */ - public long getNicOutputByte() { - return nicOutputByte; - } - - /** - * @return the nicInputPacket - */ - public long getNicInputPacket() { - return nicInputPacket; - } - - /** - * @return the nicOutputPacket - */ - public long getNicOutputPacket() { - return nicOutputPacket; - } - - @Override - public int hashCode() { - return Objects.hashCode(recordTime); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - PerformanceInfo that = PerformanceInfo.class.cast(obj); - return Objects.equal(this.recordTime, that.recordTime); - } - - @Override - public String toString() { - return Objects.toStringHelper(this).omitNullValues() - .add("recordTime", recordTime) - .add("cpuUtilization", cpuUtilization) - .add("diskReadRequestCount", diskReadRequestCount) - .add("diskWriteRequestCount", diskWriteRequestCount) - .add("diskReadSector", diskReadSector) - .add("diskWriteSector", diskWriteSector) - .add("nicInputByte", nicInputByte) - .add("nicOutputByte", nicOutputByte) - .add("nicInputPacket", nicInputPacket) - .add("nicOutputPacket", nicOutputPacket).toString(); - } - - @Override - public int compareTo(PerformanceInfo o) { - return (int) (recordTime - o.recordTime); - } -} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/Period.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/Period.java deleted file mode 100644 index 718af01285..0000000000 --- a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/Period.java +++ /dev/null @@ -1,61 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.domain; - -/** - * Describes the period over which error statistics of a load balancer (SLB) are - * kept. - * - * @author Dies Koper - */ -public class Period { - private String current; - private String before; - private String today; - private String yesterday; - - /** - * @return the current - */ - public String getCurrent() { - return current; - } - - /** - * @return the before - */ - public String getBefore() { - return before; - } - - /** - * @return the today - */ - public String getToday() { - return today; - } - - /** - * @return the yesterday - */ - public String getYesterday() { - return yesterday; - } - -} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/Policy.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/Policy.java deleted file mode 100644 index 4c7c1675dc..0000000000 --- a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/Policy.java +++ /dev/null @@ -1,195 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.domain; - -import javax.xml.bind.annotation.XmlEnumValue; - -import com.google.common.base.Objects; - -/** - * Describes a firewall rule in detail. - * - * @author Dies Koper - */ -public class Policy implements Comparable { - private int id; - - private String src; - - private PolicyType srcType; - - private String srcPort; - - private Service dstService; - - private String dst; - - private PolicyType dstType; - - private String dstPort; - - private Protocol protocol; - - private Action action; - - private Log log; - - enum Service { - NONE, WSUS, DNS, NTP, @XmlEnumValue("yum") - YUM, KMS, @XmlEnumValue("Symantec") - SYMANTEC, RHUI - } - - enum PolicyType {IP, FQDN, FQDNF} - - enum Protocol { - @XmlEnumValue("tcp") - TCP, @XmlEnumValue("udp") - UDP, @XmlEnumValue("tcp-udp") - TCP_UDP, @XmlEnumValue("icmp") - ICMP - } - - enum Action { - @XmlEnumValue("Accept") - ACCEPT, @XmlEnumValue("Deny") - DENY - } - - enum Log { - @XmlEnumValue("On") - ON, @XmlEnumValue("Off") - OFF - } - - /** - * @return the id - */ - public int getId() { - return id; - } - - /** - * @return the src - */ - public String getSrc() { - return src; - } - - /** - * @return the srcType - */ - public PolicyType getSrcType() { - return srcType; - } - - /** - * @return the srcPort - */ - public String getSrcPort() { - return srcPort; - } - - /** - * @return the dstService - */ - public Service getDstService() { - return dstService; - } - - /** - * @return the dst - */ - public String getDst() { - return dst; - } - - /** - * @return the dstType - */ - public PolicyType getDstType() { - return dstType; - } - - /** - * @return the dstPort - */ - public String getDstPort() { - return dstPort; - } - - /** - * @return the protocol - */ - public Protocol getProtocol() { - return protocol; - } - - /** - * @return the action - */ - public Action getAction() { - return action; - } - - /** - * @return the log - */ - public Log getLog() { - return log; - } - - @Override - public int hashCode() { - return Objects.hashCode(id); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - Policy that = Policy.class.cast(obj); - return Objects.equal(this.id, that.id); - } - - @Override - public String toString() { - return Objects.toStringHelper(this).omitNullValues() - .add("id", id) - .add("src", src) - .add("srcType", srcType) - .add("srcPort", srcPort) - .add("dstService", dstService) - .add("dst", dst) - .add("dstType", dstType) - .add("dstPort", dstPort) - .add("protocol", protocol) - .add("action", action) - .add("log", log).toString(); - } - - @Override - public int compareTo(Policy o) { - return id - o.id; - } -} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/Product.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/Product.java deleted file mode 100644 index c1765893c6..0000000000 --- a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/Product.java +++ /dev/null @@ -1,84 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.domain; - -import javax.xml.bind.annotation.XmlElement; - -import com.google.common.base.Objects; - -/** - * Represents a product for which usage information can be queried. - * - * @author Dies Koper - */ -public class Product { - @XmlElement(name = "productName") - private String name; - - private String unitName; - - private String usedPoints; - - /** - * @return the name - */ - public String getName() { - return name; - } - - /** - * @return the unitName - */ - public String getUnitName() { - return unitName; - } - - /** - * @return the usedPoints - */ - public String getUsedPoints() { - return usedPoints; - } - - @Override - public int hashCode() { - return Objects.hashCode(name, unitName, usedPoints); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - Product that = Product.class.cast(obj); - return Objects.equal(this.name, that.name) - && Objects.equal(this.unitName, that.unitName) - && Objects.equal(this.usedPoints, that.usedPoints); - } - - @Override - public String toString() { - return Objects.toStringHelper(this).omitNullValues().add("name", name) - .add("unitName", unitName).add("usedPoints", usedPoints) - .toString(); - } -} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/PublicIP.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/PublicIP.java deleted file mode 100644 index 9af50f7f9c..0000000000 --- a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/PublicIP.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.domain; - -import static com.google.common.base.Preconditions.checkNotNull; - -import javax.xml.bind.annotation.XmlElement; - -import com.google.common.base.CaseFormat; -import com.google.common.base.Objects; - -/** - * Represents a public IP address. - *

- * A public IP address can be allocated to a virtual system, then needs to be - * enabled/attached before it can be mapped to a virtual server by configuring - * the NAT settings of virtual system's firewall. - * - * @author Dies Koper - */ -public class PublicIP { - - public static enum Version { - IPv4, IPv6, UNRECOGNIZED; - - @Override - public String toString() { - return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, - name()); - } - - public static Version fromValue(String version) { - try { - return valueOf(CaseFormat.UPPER_CAMEL.to( - CaseFormat.UPPER_UNDERSCORE, - checkNotNull(version, "version"))); - } catch (IllegalArgumentException e) { - return UNRECOGNIZED; - } - } - - } - - protected String address; - @XmlElement(name = "v4v6Flag") - protected Version version; - - public String getAddress() { - return address; - } - - public Version getVersion() { - return version; - } - - @Override - public int hashCode() { - return Objects.hashCode(address); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - PublicIP that = PublicIP.class.cast(obj); - return Objects.equal(this.address, that.address); - } - - @Override - public String toString() { - return Objects.toStringHelper(this).omitNullValues() - .add("address", address).add("version", version).toString(); - } -} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/PublicIPStatus.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/PublicIPStatus.java deleted file mode 100644 index 19c9cd9aa7..0000000000 --- a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/PublicIPStatus.java +++ /dev/null @@ -1,57 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.domain; - -import static com.google.common.base.Preconditions.checkNotNull; - -import javax.xml.bind.annotation.XmlRootElement; - -import com.google.common.base.CaseFormat; - -/** - * Possible statuses of a public IP address. - *

- * An attached public IP address is enabled for a particular virtual system and - * or may not be mapped to a virtual server. - * - * @author Dies Koper - */ -@XmlRootElement(name = "publicipStatus") -public enum PublicIPStatus { - ATTACHED, ATTACHING, DETACHING, DETACHED, UNRECOGNIZED; - - public String value() { - return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, name()); - } - - @Override - public String toString() { - return value(); - } - - public static PublicIPStatus fromValue(String status) { - try { - return valueOf(CaseFormat.UPPER_CAMEL - .to(CaseFormat.UPPER_UNDERSCORE, - checkNotNull(status, "status"))); - } catch (IllegalArgumentException e) { - return UNRECOGNIZED; - } - } -} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/Rule.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/Rule.java deleted file mode 100644 index 3dc45cad99..0000000000 --- a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/Rule.java +++ /dev/null @@ -1,84 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.domain; - -import com.google.common.base.Objects; - -/** - * Represents a network address translation or network address port translation - * rule. - *

- * A rule either maps a public IP address to the NIC of a virtual server for - * incoming network traffic, or specifies the public IP address used as source - * address for traffic from all servers in the virtual system. - * - * @author Dies Koper - */ -public class Rule { - private String publicIp; - private String privateIp; - private boolean snapt; - - /** - * @return the publicIp - */ - public String getPublicIp() { - return publicIp; - } - - /** - * @return the privateIp - */ - public String getPrivateIp() { - return privateIp; - } - - /** - * @return the snapt - */ - public boolean isSnapt() { - return snapt; - } - - @Override - public int hashCode() { - return Objects.hashCode(privateIp, publicIp, snapt); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - Rule that = Rule.class.cast(obj); - return Objects.equal(this.privateIp, that.privateIp) - && Objects.equal(this.publicIp, that.publicIp) - && Objects.equal(this.snapt, that.snapt); - } - - @Override - public String toString() { - return Objects.toStringHelper(this).omitNullValues() - .add("privateIp", privateIp).add("publicIp", publicIp) - .add("snapt", snapt).toString(); - } -} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/SLB.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/SLB.java deleted file mode 100644 index 5e48fc7ba0..0000000000 --- a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/SLB.java +++ /dev/null @@ -1,200 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.domain; - -import java.util.Set; - -import javax.xml.bind.annotation.XmlRootElement; - -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Sets; - -/** - * Represents a software load balancer. - * - * @author Dies Koper - */ -@XmlRootElement(name = "slb") -public class SLB extends BuiltinServer { - private String ipAddress; - - private Set ccacerts = Sets.newLinkedHashSet(); - - private Set servercerts = Sets.newLinkedHashSet(); - - private Set groups; - - private String srcType; - - private String srcPort; - - private String status; - - private ErrorStatistics errorStatistics; - - private LoadStatistics loadStatistics; - - private String category; - - private String latestVersion; - - private String comment; - - private boolean firmUpdateExist; - - private boolean configUpdateExist; - - private boolean backout; - - private String updateDate; - - private String currentVersion; - - private String webAccelerator; - - /** - * @return the ipAddress - */ - public String getIpAddress() { - return ipAddress; - } - - /** - * @return the ccacerts - */ - public Set getCcacerts() { - return ccacerts == null ? ImmutableSet. of() - : ImmutableSet.copyOf(ccacerts); - } - - /** - * @return the servercerts - */ - public Set getServercerts() { - return servercerts == null ? ImmutableSet. of() - : ImmutableSet.copyOf(servercerts); - } - - /** - * @return the groups - */ - public Set getGroups() { - return groups == null ? ImmutableSet. of() : ImmutableSet - .copyOf(groups); - } - - /** - * @return the srcType - */ - public String getSrcType() { - return srcType; - } - - /** - * @return the srcPort - */ - public String getSrcPort() { - return srcPort; - } - - /** - * @return the status - */ - public String getStatus() { - return status; - } - - /** - * @return the errorStatistics - */ - public ErrorStatistics getErrorStatistics() { - return errorStatistics; - } - - /** - * @return the loadStatistics - */ - public LoadStatistics getLoadStatistics() { - return loadStatistics; - } - - /** - * @return the category - */ - public String getCategory() { - return category; - } - - /** - * @return the latestVersion - */ - public String getLatestVersion() { - return latestVersion; - } - - /** - * @return the comment - */ - public String getComment() { - return comment; - } - - /** - * @return the firmUpdateExist - */ - public boolean getFirmUpdateExist() { - return firmUpdateExist; - } - - /** - * @return the configUpdateExist - */ - public boolean getConfigUpdateExist() { - return configUpdateExist; - } - - /** - * @return the backout - */ - public boolean getBackout() { - return backout; - } - - /** - * @return the updateDate - */ - public String getUpdateDate() { - return updateDate; - } - - /** - * @return the currentVersion - */ - public String getCurrentVersion() { - return currentVersion; - } - - /** - * @return the webAccelerator - */ - public String getWebAccelerator() { - return webAccelerator; - } - -} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/ServerCert.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/ServerCert.java deleted file mode 100644 index 3df227fd3b..0000000000 --- a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/ServerCert.java +++ /dev/null @@ -1,121 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.domain; - -import javax.xml.bind.annotation.XmlRootElement; - -import com.google.common.base.Objects; - -/** - * Describes a server certificate for use with a load balancer (SLB). - * - * @author Dies Koper - */ -@XmlRootElement(name = "servercert") -public class ServerCert implements Comparable { - private int certNum; - - private String subject; - - private String issuer; - - private String validity; - - private int groupId; - - private String detail; - - /** - * @return the certNum - */ - public int getCertNum() { - return certNum; - } - - /** - * @return the subject - */ - public String getSubject() { - return subject; - } - - /** - * @return the issuer - */ - public String getIssuer() { - return issuer; - } - - /** - * @return the validity - */ - public String getValidity() { - return validity; - } - - /** - * @return the groupId - */ - public int getGroupId() { - return groupId; - } - - /** - * @return the detail - */ - public String getDetail() { - return detail; - } - - @Override - public int hashCode() { - return Objects.hashCode(certNum, groupId, issuer, subject, validity); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - ServerCert that = ServerCert.class.cast(obj); - return Objects.equal(this.certNum, that.certNum) - && Objects.equal(this.groupId, that.groupId) - && Objects.equal(this.issuer, that.issuer) - && Objects.equal(this.subject, that.subject) - && Objects.equal(this.validity, that.validity); - } - - @Override - public String toString() { - return Objects.toStringHelper(this).omitNullValues() - .add("certNum", certNum).add("issuer", issuer) - .add("subject", subject).add("validity", validity) - .add("groupId", groupId).add("detail", detail).toString(); - } - - @Override - public int compareTo(ServerCert o) { - return (certNum - o.certNum) == 0 ? (groupId - o.groupId) - : (certNum - o.certNum); - } - -} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/ServerType.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/ServerType.java deleted file mode 100644 index c5a8b36c13..0000000000 --- a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/ServerType.java +++ /dev/null @@ -1,145 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.domain; - -import java.util.Set; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlElementWrapper; -import javax.xml.bind.annotation.XmlRootElement; - -import com.google.common.base.Objects; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Sets; - -/** - * Describes the hardware of a virtual server. - * - * @author Dies Koper - */ -@XmlRootElement(name = "servertype") -public class ServerType implements Comparable { - private String id; - - private String name; - - private String label; - - private String comment; - - private String productId; - - private String productName; - - private String price; - - private String chargeType; - - private String expectedUsage; - - private CPU cpu; - - private Memory memory; - - @XmlElementWrapper(name = "disks") - @XmlElement(name = "disk") - private Set disks = Sets.newLinkedHashSet(); - - public String getId() { - return id; - } - - public String getName() { - return name; - } - - public String getLabel() { - return label; - } - - public String getComment() { - return comment; - } - - public String getProductId() { - return productId; - } - - public String getProductName() { - return productName; - } - - public String getPrice() { - return price; - } - - public String getChargeType() { - return chargeType; - } - - public String getExpectedUsage() { - return expectedUsage; - } - - public CPU getCpu() { - return cpu; - } - - public Memory getMemory() { - return memory; - } - - public Set getDisks() { - return disks == null ? ImmutableSet. of() : ImmutableSet - .copyOf(disks); - } - - @Override - public int hashCode() { - return Objects.hashCode(id); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - ServerType that = ServerType.class.cast(obj); - return Objects.equal(this.id, that.id); - } - - @Override - public String toString() { - return Objects.toStringHelper(this).omitNullValues().add("id", id) - .add("name", name).add("label", label).add("comment", comment) - .add("productId", productId).add("productName", productName) - .add("price", price).add("chargeType", chargeType) - .add("expectedUsage", expectedUsage).add("cpu", cpu) - .add("memory", memory).add("disks", disks).toString(); - } - - @Override - public int compareTo(ServerType o) { - return memory == null ? -1 : memory.compareTo(o.memory); - } - -} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/Software.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/Software.java deleted file mode 100644 index 0bf955a57c..0000000000 --- a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/Software.java +++ /dev/null @@ -1,103 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.domain; - -import com.google.common.base.Objects; - -/** - * Represents the software installed on a disk. - * - * @author Dies Koper - */ -public class Software { - private String name; - - private String id; - - private String category; - - private String version; - - private String officialVersion; - - private String patch; - - private String license; - - private String support; - - public String getName() { - return name; - } - - public String getId() { - return id; - } - - public String getCategory() { - return category; - } - - public String getVersion() { - return version; - } - - public String getOfficialVersion() { - return officialVersion; - } - - public String getPatch() { - return patch; - } - - public String getLicense() { - return license; - } - - public String getSupport() { - return support; - } - - @Override - public int hashCode() { - return Objects.hashCode(id); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - Software that = Software.class.cast(obj); - return Objects.equal(this.id, that.id); - } - - @Override - public String toString() { - return Objects.toStringHelper(this).omitNullValues().add("id", id) - .add("name", name).add("category", category) - .add("version", version) - .add("officialVersion", officialVersion) - .add("support", support).add("patch", patch) - .add("license", license).toString(); - } -} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/Target.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/Target.java deleted file mode 100644 index aeb340f772..0000000000 --- a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/Target.java +++ /dev/null @@ -1,126 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.domain; - -import com.google.common.base.Objects; - -/** - * Describes the target server of a load balancer. - * - * @author Dies Koper - */ -public class Target { - private String serverId; - - private String serverName; - - private String ipAddress; - - private String port1; - - private String port2; - - private String status; - - private String now; - - private String peak; - - /** - * @return the serverId - */ - public String getServerId() { - return serverId; - } - - /** - * @return the serverName - */ - public String getServerName() { - return serverName; - } - - /** - * @return the ipAddress - */ - public String getIpAddress() { - return ipAddress; - } - - /** - * @return the port1 - */ - public String getPort1() { - return port1; - } - - /** - * @return the port2 - */ - public String getPort2() { - return port2; - } - - /** - * @return the status - */ - public String getStatus() { - return status; - } - - /** - * @return the now - */ - public String getNow() { - return now; - } - - /** - * @return the peak - */ - public String getPeak() { - return peak; - } - - @Override - public int hashCode() { - return Objects.hashCode(serverId); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - Target that = Target.class.cast(obj); - return Objects.equal(this.serverId, that.serverId); - } - - @Override - public String toString() { - return Objects.toStringHelper(this).omitNullValues() - .add("serverId", serverId).add("serverName", serverName) - .add("ipAddress", ipAddress).add("port1", port1) - .add("port2", port2).add("status", status).add("now", now) - .add("peak", peak).toString(); - } -} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/UsageInfo.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/UsageInfo.java deleted file mode 100644 index b9d37b8656..0000000000 --- a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/UsageInfo.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.domain; - -import java.util.Set; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlElementWrapper; -import javax.xml.bind.annotation.XmlRootElement; - -import com.google.common.base.Objects; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Sets; - -/** - * Describes the usage by a virtual system. - * - * @author Dies Koper - */ -@XmlRootElement(name = "usageinfo") -public class UsageInfo { - @XmlElement(name = "vsysId") - private String systemId; - @XmlElement(name = "vsysName") - private String systemName; - - @XmlElementWrapper(name = "products") - @XmlElement(name = "product") - private Set products = Sets.newLinkedHashSet(); - - /** - * @return the systemId - */ - public String getSystemId() { - return systemId; - } - - /** - * @return the systemName - */ - public String getSystemName() { - return systemName; - } - - /** - * @return the products - */ - public Set getProducts() { - return products == null ? ImmutableSet. of() : ImmutableSet - .copyOf(products); - } - - @Override - public int hashCode() { - return Objects.hashCode(systemId, systemName, products); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - UsageInfo that = UsageInfo.class.cast(obj); - return Objects.equal(this.systemId, that.systemId) - && Objects.equal(this.systemName, that.systemName) - && Objects.equal(this.products, that.products); - } - - @Override - public String toString() { - return Objects.toStringHelper(this).omitNullValues() - .add("systemId", systemId).add("systemName", systemName) - .add("products", products).toString(); - } -} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/VDisk.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/VDisk.java deleted file mode 100644 index e90815e3c4..0000000000 --- a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/VDisk.java +++ /dev/null @@ -1,86 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.domain; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; - -import com.google.common.base.Objects; - -/** - * Represents attachable storage in the form of a virtual disk. - * - * @author Dies Koper - */ -@XmlRootElement(name = "vdisk") -public class VDisk { - @XmlElement(name = "diskId") - private String id; - @XmlElement(name = "diskName") - private String name; - @XmlElement(name = "attachedTo") - private String attachedServer; - private String creator; - private double size; - - public String getId() { - return id; - } - - public String getName() { - return name; - } - - public String getAttachedServer() { - return attachedServer; - } - - public String getCreator() { - return creator; - } - - public double getSize() { - return size; - } - - @Override - public int hashCode() { - return Objects.hashCode(id); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - VDisk that = VDisk.class.cast(obj); - return Objects.equal(this.id, that.id); - } - - @Override - public String toString() { - return Objects.toStringHelper(this).omitNullValues().add("id", id) - .add("name", name).add("attachedServer", attachedServer) - .add("creator", creator).add("size", size).toString(); - } - -} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/VDiskStatus.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/VDiskStatus.java deleted file mode 100644 index d329056c83..0000000000 --- a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/VDiskStatus.java +++ /dev/null @@ -1,55 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.domain; - -import static com.google.common.base.Preconditions.checkNotNull; - -import javax.xml.bind.annotation.XmlRootElement; - -import com.google.common.base.CaseFormat; - -/** - * Possible statuses of an attachable virtual disk. - * - * @author Dies Koper - */ -@XmlRootElement(name = "vdiskStatus") -public enum VDiskStatus { - - NORMAL, BACKUP_ING, DEPLOYING, DETACHING, ATTACHING, RESTORING, ERROR, UNRECOGNIZED; - - public String value() { - return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, name()); - } - - @Override - public String toString() { - return value(); - } - - public static VDiskStatus fromValue(String status) { - try { - return valueOf(CaseFormat.UPPER_CAMEL - .to(CaseFormat.UPPER_UNDERSCORE, - checkNotNull(status, "status"))); - } catch (IllegalArgumentException e) { - return UNRECOGNIZED; - } - } -} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/VNIC.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/VNIC.java deleted file mode 100644 index 9091384fe1..0000000000 --- a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/VNIC.java +++ /dev/null @@ -1,73 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.domain; - -import javax.xml.bind.annotation.XmlRootElement; - -import com.google.common.base.Objects; - -/** - * Represents a virtual network interface card (NIC). - * - * @author Dies Koper - */ -@XmlRootElement(name = "vnic") -public class VNIC { - private String networkId; - - private String privateIp; - - private int nicNo; - - public String getNetworkId() { - return networkId; - } - - public String getPrivateIp() { - return privateIp; - } - - public int getNicNo() { - return nicNo; - } - - @Override - public int hashCode() { - return Objects.hashCode(networkId); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - VNIC that = VNIC.class.cast(obj); - return Objects.equal(this.networkId, that.networkId); - } - - @Override - public String toString() { - return Objects.toStringHelper(this).omitNullValues() - .add("networkId", networkId).add("privateIp", privateIp) - .add("nicNo", nicNo).toString(); - } -} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/VNet.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/VNet.java deleted file mode 100644 index 99de06cc47..0000000000 --- a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/VNet.java +++ /dev/null @@ -1,61 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.domain; - -import javax.xml.bind.annotation.XmlRootElement; - -import com.google.common.base.Objects; - -/** - * Represents a virtual network. - * - * @author Dies Koper - */ -@XmlRootElement(name = "vnet") -public class VNet { - - private String networkId; - - public String getNetworkId() { - return networkId; - } - - @Override - public int hashCode() { - return Objects.hashCode(networkId); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - VNet that = VNet.class.cast(obj); - return Objects.equal(this.networkId, that.networkId); - } - - @Override - public String toString() { - return Objects.toStringHelper(this).add("networkId", networkId) - .toString(); - } -} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/VServer.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/VServer.java deleted file mode 100644 index cc57a903dc..0000000000 --- a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/VServer.java +++ /dev/null @@ -1,84 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.domain; - -import javax.xml.bind.annotation.XmlElement; - -import com.google.common.base.Objects; - -/** - * Represents a virtual server. - * - * @author Dies Koper - */ -public class VServer { - @XmlElement(name = "vserverId") - protected String id; - @XmlElement(name = "vserverName") - protected String name; - @XmlElement(name = "vserverType") - protected String type; - protected String diskimageId; - protected String creator; - - public String getId() { - return id; - } - - public String getName() { - return name; - } - - public String getType() { - return type; - } - - public String getDiskimageId() { - return diskimageId; - } - - public String getCreator() { - return creator; - } - - @Override - public int hashCode() { - return Objects.hashCode(id); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - VServer that = VServer.class.cast(obj); - return Objects.equal(this.id, that.id); - } - - @Override - public String toString() { - return Objects.toStringHelper(this).omitNullValues().add("id", id) - .add("name", name).add("type", type).add("creator", creator) - .add("diskimageId", diskimageId).toString(); - } - -} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/VServerStatus.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/VServerStatus.java deleted file mode 100644 index 2e2b8f34a0..0000000000 --- a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/VServerStatus.java +++ /dev/null @@ -1,54 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.domain; - -import static com.google.common.base.Preconditions.checkNotNull; - -import javax.xml.bind.annotation.XmlRootElement; - -import com.google.common.base.CaseFormat; - -/** - * Possible statuses of a virtual server. - * - * @author Dies Koper - */ -@XmlRootElement(name = "vserverStatus") -public enum VServerStatus { - DEPLOYING, RUNNING, STOPPING, STOPPED, STARTING, FAILOVER, UNEXPECTED_STOP, RESTORING, BACKUP_ING, ERROR, START_ERROR, STOP_ERROR, CHANGE_TYPE, REGISTERING, UNRECOGNIZED; - - public String value() { - return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, name()); - } - - @Override - public String toString() { - return value(); - } - - public static VServerStatus fromValue(String status) { - try { - return valueOf(CaseFormat.UPPER_CAMEL - .to(CaseFormat.UPPER_UNDERSCORE, - checkNotNull(status, "status"))); - } catch (IllegalArgumentException e) { - return UNRECOGNIZED; - } - } -} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/VServerWithDetails.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/VServerWithDetails.java deleted file mode 100644 index 1092fa0159..0000000000 --- a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/VServerWithDetails.java +++ /dev/null @@ -1,59 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.domain; - -import java.util.Set; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlElementWrapper; -import javax.xml.bind.annotation.XmlRootElement; - -import com.google.common.base.Objects; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Sets; - -/** - * Represents a virtual server with virtual storage and NICs. - * - * @author Dies Koper - */ -@XmlRootElement(name = "vserver") -public class VServerWithDetails extends VServerWithVNICs { - @XmlElementWrapper(name = "vdisks") - @XmlElement(name = "vdisk") - protected Set vdisks = Sets.newLinkedHashSet(); - protected Image image; - - public Set getVdisks() { - return vdisks == null ? ImmutableSet. of() : ImmutableSet - .copyOf(vdisks); - } - - public Image getImage() { - return image; - } - - @Override - public String toString() { - return Objects.toStringHelper(this).omitNullValues().add("id", id) - .add("name", name).add("type", type).add("creator", creator) - .add("diskimageId", diskimageId).add("vdisks", vdisks) - .add("vnics", vnics).add("image", image).toString(); - } -} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/VServerWithVNICs.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/VServerWithVNICs.java deleted file mode 100644 index 0571a29b5d..0000000000 --- a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/VServerWithVNICs.java +++ /dev/null @@ -1,29 +0,0 @@ -package org.jclouds.fujitsu.fgcp.domain; - -import java.util.Set; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlElementWrapper; - -import com.google.common.base.Objects; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Sets; - -public class VServerWithVNICs extends VServer { - - @XmlElementWrapper(name = "vnics") - @XmlElement(name = "vnic") - protected Set vnics = Sets.newLinkedHashSet(); - - public Set getVnics() { - return vnics == null ? ImmutableSet. of() : ImmutableSet - .copyOf(vnics); - } - - @Override - public String toString() { - return Objects.toStringHelper(this).omitNullValues().add("id", id) - .add("name", name).add("type", type).add("creator", creator) - .add("diskimageId", diskimageId).add("vnics", vnics).toString(); - } -} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/VSystem.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/VSystem.java deleted file mode 100644 index 30f51de348..0000000000 --- a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/VSystem.java +++ /dev/null @@ -1,84 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.domain; - -import javax.xml.bind.annotation.XmlElement; - -import com.google.common.base.Objects; - -/** - * Represents a virtual system. - * - * @author Dies Koper - */ -public class VSystem { - @XmlElement(name = "vsysId") - protected String id; - @XmlElement(name = "vsysName") - protected String name; - protected String creator; - @XmlElement(name = "baseDescriptor") - protected String template; - protected String description; - - public String getId() { - return id; - } - - public String getName() { - return name; - } - - public String getCreator() { - return creator; - } - - public String getTemplate() { - return template; - } - - public String getDescription() { - return description; - } - - @Override - public int hashCode() { - return Objects.hashCode(id); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - VSystem that = VSystem.class.cast(obj); - return Objects.equal(this.id, that.id); - } - - @Override - public String toString() { - return Objects.toStringHelper(this).omitNullValues().add("id", id) - .add("name", name).add("creator", creator) - .add("template", template).add("description", description) - .toString(); - } -} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/VSystemDescriptor.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/VSystemDescriptor.java deleted file mode 100644 index 893225316a..0000000000 --- a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/VSystemDescriptor.java +++ /dev/null @@ -1,104 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.domain; - -import java.util.Set; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlElementWrapper; -import javax.xml.bind.annotation.XmlRootElement; - -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Sets; - -/** - * Describes a virtual system template. - * - * @author Dies Koper - */ -@XmlRootElement(name = "vsysdescriptor") -public class VSystemDescriptor { - @XmlElement(name = "vsysdescriptorId") - private String id; - - @XmlElement(name = "vsysdescriptorName") - private String name; - - private String creatorName; - - private String registrant; - - private String description; - - private String keyword; - - @XmlElementWrapper(name = "vservers") - @XmlElement(name = "vserver") - private Set servers = Sets.newLinkedHashSet(); - - /** - * @return the id - */ - public String getId() { - return id; - } - - /** - * @return the name - */ - public String getName() { - return name; - } - - /** - * @return the creatorName - */ - public String getCreatorName() { - return creatorName; - } - - /** - * @return the registrant - */ - public String getRegistrant() { - return registrant; - } - - /** - * @return the description - */ - public String getDescription() { - return description; - } - - /** - * @return the keyword - */ - public String getKeyword() { - return keyword; - } - - /** - * @return the servers - */ - public Set getServers() { - return servers == null ? ImmutableSet. of() - : ImmutableSet.copyOf(servers); - } -} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/VSystemStatus.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/VSystemStatus.java deleted file mode 100644 index 0620641007..0000000000 --- a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/VSystemStatus.java +++ /dev/null @@ -1,54 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.domain; - -import static com.google.common.base.Preconditions.checkNotNull; - -import javax.xml.bind.annotation.XmlRootElement; - -import com.google.common.base.CaseFormat; - -/** - * Possible statuses of a virtual system. - * - * @author Dies Koper - */ -@XmlRootElement(name = "vsysStatus") -public enum VSystemStatus { - NORMAL, RECONFIG_ING, DEPLOYING, ERROR, UNRECOGNIZED; - - public String value() { - return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, name()); - } - - @Override - public String toString() { - return value(); - } - - public static VSystemStatus fromValue(String status) { - try { - return valueOf(CaseFormat.UPPER_CAMEL - .to(CaseFormat.UPPER_UNDERSCORE, - checkNotNull(status, "status"))); - } catch (IllegalArgumentException e) { - return UNRECOGNIZED; - } - } -} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/VSystemWithDetails.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/VSystemWithDetails.java deleted file mode 100644 index fe8568fed2..0000000000 --- a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/VSystemWithDetails.java +++ /dev/null @@ -1,80 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.domain; - -import java.util.Set; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlElementWrapper; -import javax.xml.bind.annotation.XmlRootElement; - -import com.google.common.base.Objects; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Sets; - -/** - * Represents a virtual system with servers, additional storage, public IP - * addresses and networks. - * - * @author Dies Koper - */ -@XmlRootElement(name = "vsys") -public class VSystemWithDetails extends VSystem { - @XmlElementWrapper(name = "vservers") - @XmlElement(name = "vserver") - private Set servers = Sets.newLinkedHashSet(); - @XmlElementWrapper(name = "vdisks") - @XmlElement(name = "vdisk") - private Set disks = Sets.newLinkedHashSet(); - @XmlElementWrapper(name = "publicips") - @XmlElement(name = "publicip") - private Set publicips = Sets.newLinkedHashSet(); - @XmlElementWrapper(name = "vnets") - @XmlElement(name = "vnet") - private Set networks = Sets.newLinkedHashSet(); - - public Set getServers() { - return servers == null ? ImmutableSet. of() : ImmutableSet - .copyOf(servers); - } - - public Set getDisks() { - return disks == null ? ImmutableSet. of() : ImmutableSet - .copyOf(disks); - } - - public Set getPublicips() { - return publicips == null ? ImmutableSet. of() : ImmutableSet - .copyOf(publicips); - } - - public Set getNetworks() { - return networks == null ? ImmutableSet. of() : ImmutableSet - .copyOf(networks); - } - - @Override - public String toString() { - return Objects.toStringHelper(this).omitNullValues().add("id", id) - .add("name", name).add("creator", creator) - .add("template", template).add("description", description) - .add("disks", disks).add("networks", networks) - .add("publicips", publicips).add("servers", servers).toString(); - } -} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/package-info.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/package-info.java deleted file mode 100644 index 4c2494a2a8..0000000000 --- a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/domain/package-info.java +++ /dev/null @@ -1,26 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -@XmlSchema(namespace = "http://apioviss.jp.fujitsu.com", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED) -@XmlAccessorType(XmlAccessType.FIELD) -package org.jclouds.fujitsu.fgcp.domain; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlSchema; - diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/filters/RequestAuthenticator.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/filters/RequestAuthenticator.java deleted file mode 100644 index 65dbdb8e68..0000000000 --- a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/filters/RequestAuthenticator.java +++ /dev/null @@ -1,243 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.filters; - -import static com.google.common.base.Charsets.UTF_8; -import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.base.Throwables.propagate; -import static com.google.common.io.BaseEncoding.base64; -import static org.jclouds.http.utils.Queries.queryParser; - -import java.security.InvalidKeyException; -import java.security.KeyStore; -import java.security.KeyStoreException; -import java.security.NoSuchAlgorithmException; -import java.security.PrivateKey; -import java.security.Signature; -import java.security.SignatureException; -import java.security.UnrecoverableKeyException; -import java.util.Calendar; -import java.util.Locale; -import java.util.concurrent.ExecutionException; - -import javax.annotation.Resource; -import javax.inject.Inject; -import javax.inject.Named; -import javax.inject.Provider; -import javax.inject.Singleton; -import javax.ws.rs.HttpMethod; -import javax.ws.rs.core.HttpHeaders; -import javax.ws.rs.core.MediaType; - -import org.jclouds.Constants; -import org.jclouds.date.TimeStamp; -import org.jclouds.domain.Credentials; -import org.jclouds.fujitsu.fgcp.reference.RequestParameters; -import org.jclouds.http.HttpException; -import org.jclouds.http.HttpRequest; -import org.jclouds.http.HttpRequest.Builder; -import org.jclouds.http.HttpRequestFilter; -import org.jclouds.http.HttpUtils; -import org.jclouds.http.internal.SignatureWire; -import org.jclouds.logging.Logger; -import org.jclouds.rest.RequestSigner; -import org.jclouds.rest.annotations.ApiVersion; - -import com.google.common.annotations.VisibleForTesting; -import com.google.common.base.Supplier; -import com.google.common.cache.CacheBuilder; -import com.google.common.cache.CacheLoader; -import com.google.common.cache.LoadingCache; -import com.google.common.collect.Multimap; - -/** - * Generates and signs the access key id and adds the mandatory http header and request parameters to the request. - * - * @author Dies Koper - */ -@Singleton -public class RequestAuthenticator implements HttpRequestFilter, RequestSigner { - - @Resource - @Named(Constants.LOGGER_SIGNATURE) - private Logger signatureLog = Logger.NULL; - - private final Supplier creds; - private final LoadingCache signerCache; - private final Provider calendarProvider; - private final HttpUtils utils; - private final String apiVersion; - - private final static String signatureVersion = "1.0"; - private final static String signatureMethod = "SHA1withRSA"; - - @Inject - public RequestAuthenticator(@TimeStamp Provider calendarProvider, - SignatureForCredentials loader, - @org.jclouds.location.Provider Supplier creds, - HttpUtils utils, SignatureWire signatureWire, - @ApiVersion String apiVersion) { - this.calendarProvider = checkNotNull(calendarProvider); - this.creds = checkNotNull(creds, "creds"); - // throw out the signature related to old keys - this.signerCache = CacheBuilder.newBuilder().maximumSize(2).build(checkNotNull(loader, "loader")); - this.utils = checkNotNull(utils, "utils"); - this.apiVersion = checkNotNull(apiVersion, "apiVersion"); - } - - /** - * it is relatively expensive to create a new signing key. cache the relationship between current credentials so that - * the signer is only recalculated once. - */ - @VisibleForTesting - static class SignatureForCredentials extends CacheLoader { - private final Supplier keyStore; - - @Inject - public SignatureForCredentials(Supplier keyStore) { - this.keyStore = checkNotNull(keyStore, "keyStore"); - } - - @Override - public Signature load(Credentials in) { - String keyPassword = checkNotNull(in.credential, - "credential supplier returned null for credential (keyPassword)"); - try { - Signature signer = Signature.getInstance(signatureMethod); - KeyStore keyStore = checkNotNull(this.keyStore.get(), "keyStore"); - String alias = keyStore.aliases().nextElement(); // there should be only one private key - PrivateKey privateKey = (PrivateKey) keyStore.getKey(alias, keyPassword.toCharArray()); - signer.initSign(privateKey); - return signer; - } catch (NoSuchAlgorithmException e) { - throw propagate(e); - } catch (KeyStoreException e) { - throw propagate(e); - } catch (UnrecoverableKeyException e) { - throw propagate(e); - } catch (InvalidKeyException e) { - throw propagate(e); - } - } - } - - public HttpRequest filter(HttpRequest request) throws HttpException { - checkNotNull(request, "request must be present"); - utils.logRequest(signatureLog, request, ">>"); - - // create accesskeyid - String accessKeyId = createStringToSign(request); - String signature = sign(accessKeyId); - - // only "en" and "ja" are allowed - String lang = Locale.JAPANESE.getLanguage().equals(Locale.getDefault().getLanguage()) ? Locale.JAPANESE - .getLanguage() : Locale.ENGLISH.getLanguage(); - - if (HttpMethod.GET.equals(request.getMethod())) { - request = addQueryParamsToRequest(request, accessKeyId, signature, - lang); - } else { - - String payload = request.getPayload().getRawContent().toString(); - payload = createXmlElementWithValue(payload, RequestParameters.VERSION, apiVersion); - payload = createXmlElementWithValue(payload, RequestParameters.LOCALE, lang); - payload = createXmlElementWithValue(payload, RequestParameters.ACCESS_KEY_ID, accessKeyId); - payload = createXmlElementWithValue(payload, RequestParameters.SIGNATURE, signature); - - // ensure there are no other query params left - request.setPayload(payload); - request.getPayload().getContentMetadata().setContentType(MediaType.TEXT_XML); - } - - // may need to do this elsewhere (see ConvertToGaeRequest) - HttpRequest filteredRequest = request.toBuilder().replaceHeader(HttpHeaders.USER_AGENT, "OViSS-API-CLIENT") - .build(); - - utils.logRequest(signatureLog, filteredRequest, ">>->"); - return filteredRequest; - } - - @VisibleForTesting - HttpRequest addQueryParamsToRequest(HttpRequest request, String accessKeyId, - String signature, String lang) { - // url encode "+" (which comes from base64 encoding) or else it may be - // converted into a %20 (space) which the API endpoint doesn't - // expect/accept. - accessKeyId = accessKeyId.replace("+", "%2B"); - signature = signature.replace("+", "%2B"); - - Multimap decodedParams = queryParser().apply( - request.getEndpoint().getRawQuery()); - Builder builder = request.toBuilder() - .endpoint(request.getEndpoint()) - .method(request.getMethod()); - if (!decodedParams.containsKey("Version")) { - builder.addQueryParam(RequestParameters.VERSION, apiVersion); - } - builder.addQueryParam(RequestParameters.LOCALE, lang) - .addQueryParam(RequestParameters.ACCESS_KEY_ID, accessKeyId) - // the addition of another param causes %2B's in prev. params to - // convert to %20. Needs to be addressed if there are cases where - // accessKeyId contains %2B's. - // So signature should be added last: - .addQueryParam(RequestParameters.SIGNATURE, signature); - - return builder.build(); - } - - String createXmlElementWithValue(String payload, String tag, String value) { - String startTag = String.format("<%s>", tag); - String endTag = String.format("", tag); - - return payload.replace(startTag + endTag, startTag + value + endTag); - } - - public String sign(String stringToSign) { - String signed; - try { - Signature signer = signerCache.get(checkNotNull(creds.get(), "credential supplier returned null")); - signer.update(stringToSign.getBytes(UTF_8)); - signed = base64().withSeparator("\n", 61).encode(signer.sign()); - } catch (SignatureException e) { - throw new HttpException("error signing request", e); - } catch (ExecutionException e) { - throw new HttpException("couldn't load key for signing request", e); - } - return signed; - } - - @VisibleForTesting - String generateAccessKeyId() { - Calendar cal = calendarProvider.get(); - String timezone = cal.getTimeZone().getDisplayName(Locale.ENGLISH); - String expires = String.valueOf(cal.getTime().getTime()); - - String signatureData = String.format("%s&%s&%s&%s", timezone, expires, signatureVersion, signatureMethod); - String accessKeyId = base64().withSeparator("\n", 61).encode( - signatureData.getBytes(UTF_8)); - - return accessKeyId; - } - - @Override - public String createStringToSign(HttpRequest input) { - return generateAccessKeyId(); - } - -} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/handlers/FGCPRetryIfNotProxyAuthenticationFailureHandler.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/handlers/FGCPRetryIfNotProxyAuthenticationFailureHandler.java deleted file mode 100644 index 9d4c05de9c..0000000000 --- a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/handlers/FGCPRetryIfNotProxyAuthenticationFailureHandler.java +++ /dev/null @@ -1,48 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.handlers; - -import javax.annotation.Resource; - -import org.jclouds.http.HttpCommand; -import org.jclouds.http.HttpResponse; -import org.jclouds.http.HttpRetryHandler; -import org.jclouds.logging.Logger; - -import com.google.inject.Singleton; - -/** - * Created by IntelliJ IDEA. - * - * @author Dies Koper - */ -@Singleton -public class FGCPRetryIfNotProxyAuthenticationFailureHandler implements - HttpRetryHandler { - @Resource - protected Logger logger = Logger.NULL; - - @Override - public boolean shouldRetryRequest(HttpCommand command, HttpResponse response) { - int statusCode = response.getStatusCode(); - System.out.println("Response status code: " + statusCode); - logger.error("StatusCode", statusCode); - return true; - } -} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/location/SystemAndNetworkSegmentToLocationSupplier.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/location/SystemAndNetworkSegmentToLocationSupplier.java deleted file mode 100644 index 74cd62f076..0000000000 --- a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/location/SystemAndNetworkSegmentToLocationSupplier.java +++ /dev/null @@ -1,120 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.location; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.List; -import java.util.Set; -import java.util.concurrent.ExecutionException; - -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jclouds.domain.Location; -import org.jclouds.domain.LocationBuilder; -import org.jclouds.domain.LocationScope; -import org.jclouds.fujitsu.fgcp.FGCPAsyncApi; -import org.jclouds.fujitsu.fgcp.domain.VNet; -import org.jclouds.fujitsu.fgcp.domain.VSystem; -import org.jclouds.fujitsu.fgcp.domain.VSystemWithDetails; -import org.jclouds.location.suppliers.LocationsSupplier; -import org.jclouds.location.suppliers.all.RegionToProviderOrJustProvider; - -import com.google.common.base.Throwables; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.ImmutableSet.Builder; -import com.google.common.collect.Iterables; -import com.google.common.collect.Lists; -import com.google.common.util.concurrent.Futures; -import com.google.common.util.concurrent.ListenableFuture; - -/** - * Builds location hierarchy by querying the back-end for the networks of all - * virtual systems. - *

- * Example: - *

- * - *

- * >location provider fgcp(-au)
- * -> location region au/nsw
- * --> location system vsys
- * ---> location network DMZ/SECURE1/SECURE2
- * 
- * - * Todo: caching - provider/region won't change. if vsys still exists, network - * won't change - * - * @author Dies Koper - */ -@Singleton -public class SystemAndNetworkSegmentToLocationSupplier implements - LocationsSupplier { - - private final RegionToProviderOrJustProvider regionProvider; - private FGCPAsyncApi api; - - @Inject - SystemAndNetworkSegmentToLocationSupplier( - RegionToProviderOrJustProvider regionProvider, FGCPAsyncApi api) { - this.regionProvider = checkNotNull(regionProvider, - "regionToProviderOrJustProvider"); - this.api = checkNotNull(api, "api"); - } - - @Override - public Set get() { - Builder locations = ImmutableSet.builder(); - try { - List> futures = Lists.newArrayList(); - for (VSystem system : api.getVirtualDCApi().listVirtualSystems() - .get()) { - - futures.add(api.getVirtualSystemApi() - .getDetails(system.getId())); - } - for (VSystemWithDetails system : Futures.successfulAsList(futures) - .get()) { - - Location systemLocation = new LocationBuilder() - .scope(LocationScope.SYSTEM) - .parent(Iterables.getOnlyElement(regionProvider.get())) - .description(system.getName()).id(system.getId()) - .build(); - - for (VNet net : system.getNetworks()) { - - locations.add(new LocationBuilder() - .scope(LocationScope.NETWORK) - .parent(systemLocation) - .description( - net.getNetworkId().replaceFirst( - ".+(DMZ|SECURE.)", "\\1")) - .id(net.getNetworkId()).build()); - } - } - } catch (InterruptedException e) { - throw Throwables.propagate(e); - } catch (ExecutionException e) { - throw Throwables.propagate(e); - } - return locations.build(); - } -} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/reference/RequestParameters.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/reference/RequestParameters.java deleted file mode 100644 index 784773cb10..0000000000 --- a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/reference/RequestParameters.java +++ /dev/null @@ -1,81 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.reference; - -/** - * Configuration parameters and constants used in HTTP requests. - * - * @author Dies Koper - */ -public interface RequestParameters { - - /** - * Indicates the action to perform. Example: ListVSYS - */ - public static final String ACTION = "Action"; - - /** - * The API version to use. Example: 2011-01-31 - */ - public static final String VERSION = "Version"; - - /** - * The locale to use. Example: en - */ - public static final String LOCALE = "Locale"; - - /** - * The Access Key ID for the request sender. This identifies the account - * which will be charged for usage of the service. The account with which - * the Access Key ID is associated must be signed up for FGCP, or requests - * will not be accepted. AKIADQKE4SARGYLE - */ - public static final String ACCESS_KEY_ID = "AccessKeyId"; - - /** - * The date and time at which the request is signed, in the format - * YYYY-MM-DDThh:mm:ssZ. For more information, go to ISO 8601. Example: - * 2006-07-07T15:04:56Z - */ - public static final String TIMESTAMP = "Timestamp"; - - /** - * The date and time at which the signer included in the request expires, in - * the format YYYY-MM-DDThh:mm:ssZ. Example: 2006-07-07T15:04:56Z - */ - public static final String EXPIRES = "Expires"; - - /** - * The request signer. For more information, go to the Amazon Elastic - * Compute Cloud Developer Guide. Example: Qnpl4Qk/7tINHzfXCiT7VbBatDA= - */ - public static final String SIGNATURE = "Signature"; - - /** - * The hash algorithm you use to create the request signer. Valid value: - * SHA1withRSA. - */ - public static final String SIGNATURE_METHOD = "SignatureMethod"; - - /** - * The signer version you use to sign the request. Set this value to 1.0. - * - */ - public static final String SIGNATURE_VERSION = "SignatureVersion"; -} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/services/AdditionalDiskApi.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/services/AdditionalDiskApi.java deleted file mode 100644 index 93daba5500..0000000000 --- a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/services/AdditionalDiskApi.java +++ /dev/null @@ -1,48 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.services; - -import org.jclouds.fujitsu.fgcp.domain.VDisk; -import org.jclouds.fujitsu.fgcp.domain.VDiskStatus; - -/** - * API relating to additional storage. - * - * @author Dies Koper - */ -public interface AdditionalDiskApi { - - VDiskStatus getStatus(String id); - - VDisk get(String id); - - void update(String id, String name, String value); - - void backup(String id); - - void restore(String systemId, String backupId); - - void destroy(String id); - - void detach(String diskId, String serverId); - - void destroyBackup(String sysId, String backupId); - - // Set<> listBackups(String sysId); -} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/services/AdditionalDiskAsyncApi.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/services/AdditionalDiskAsyncApi.java deleted file mode 100644 index 8515fe6b93..0000000000 --- a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/services/AdditionalDiskAsyncApi.java +++ /dev/null @@ -1,116 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.services; - -import javax.inject.Named; -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.MediaType; - -import org.jclouds.fujitsu.fgcp.FGCPAsyncApi; -import org.jclouds.fujitsu.fgcp.binders.BindAlsoToSystemId; -import org.jclouds.fujitsu.fgcp.compute.functions.SingleElementResponseToElement; -import org.jclouds.fujitsu.fgcp.domain.VDisk; -import org.jclouds.fujitsu.fgcp.domain.VDiskStatus; -import org.jclouds.fujitsu.fgcp.filters.RequestAuthenticator; -import org.jclouds.fujitsu.fgcp.reference.RequestParameters; -import org.jclouds.rest.annotations.BinderParam; -import org.jclouds.rest.annotations.JAXBResponseParser; -import org.jclouds.rest.annotations.PayloadParams; -import org.jclouds.rest.annotations.QueryParams; -import org.jclouds.rest.annotations.RequestFilters; -import org.jclouds.rest.annotations.Transform; - -import com.google.common.util.concurrent.ListenableFuture; - -/** - * Non-blocking API relating to additional storage. - * - * @author Dies Koper - */ -@RequestFilters(RequestAuthenticator.class) -@QueryParams(keys = RequestParameters.VERSION, values = FGCPAsyncApi.VERSION) -@PayloadParams(keys = RequestParameters.VERSION, values = FGCPAsyncApi.VERSION) -@Consumes(MediaType.TEXT_XML) -public interface AdditionalDiskAsyncApi { - - @Named("GetVDiskStatus") - @GET - @JAXBResponseParser - @QueryParams(keys = "Action", values = "GetVDiskStatus") - @Transform(SingleElementResponseToElement.class) - ListenableFuture getStatus( - @BinderParam(BindAlsoToSystemId.class) @QueryParam("vdiskId") String id); - - @Named("GetVDiskAttributes") - @GET - @JAXBResponseParser - @QueryParams(keys = "Action", values = "GetVDiskAttributes") - @Transform(SingleElementResponseToElement.class) - ListenableFuture get( - @BinderParam(BindAlsoToSystemId.class) @QueryParam("vdiskId") String id); - - @Named("UpdateVDiskAttribute") - @GET - @QueryParams(keys = "Action", values = "UpdateVDiskAttribute") - ListenableFuture update( - @BinderParam(BindAlsoToSystemId.class) @QueryParam("vdiskId") String id, - @QueryParam("attributeName") String name, - @QueryParam("attributeValue") String value); - - @Named("BackupVDisk") - @GET - @JAXBResponseParser - @QueryParams(keys = "Action", values = "BackupVDisk") - ListenableFuture backup( - @BinderParam(BindAlsoToSystemId.class) @QueryParam("vdiskId") String id); - - @Named("RestoreVDisk") - @GET - @JAXBResponseParser - @QueryParams(keys = "Action", values = "RestoreVDisk") - ListenableFuture restore(@QueryParam("vsysId") String systemId, - @QueryParam("backupId") String backupId); - - @Named("DestroyVDisk") - @GET - @JAXBResponseParser - @QueryParams(keys = "Action", values = "DestroyVDisk") - ListenableFuture destroy( - @BinderParam(BindAlsoToSystemId.class) @QueryParam("vdiskId") String id); - - @Named("DetachVDisk") - @GET - @JAXBResponseParser - @QueryParams(keys = "Action", values = "DetachVDisk") - ListenableFuture detach( - @BinderParam(BindAlsoToSystemId.class) @QueryParam("vdiskId") String diskId, - @QueryParam("vserverId") String serverId); - - @Named("DestroyVDiskBackup") - @GET - @JAXBResponseParser - @QueryParams(keys = "Action", values = "DestroyVDiskBackup") - ListenableFuture destroyBackup(@QueryParam("vsysId") String sysId, - @QueryParam("backupId") String backupId); - - // Set<> listBackups(String sysId); - -} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/services/BuiltinServerApi.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/services/BuiltinServerApi.java deleted file mode 100644 index 6cb14bb668..0000000000 --- a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/services/BuiltinServerApi.java +++ /dev/null @@ -1,69 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.services; - -import java.util.Set; -import org.jclouds.fujitsu.fgcp.domain.BuiltinServer; -import org.jclouds.fujitsu.fgcp.domain.BuiltinServerBackup; -import org.jclouds.fujitsu.fgcp.domain.BuiltinServerConfiguration; -import org.jclouds.fujitsu.fgcp.domain.BuiltinServerStatus; - -/** - * API relating to built-in servers, also called extended function module (EFM), - * such as a firewall or load balancer (SLB). - * - * @author Dies Koper - */ -public interface BuiltinServerApi { - - void start(String id); - - void stop(String id); - - void destroy(String id); - - void backup(String id); - - void restore(String id, String backupId); - - Set listBackups(String id); - - void destroyBackup(String id, String backupId); - - BuiltinServer get(String id); - - void update(String id, String name, String value); - - BuiltinServerStatus getStatus(String id); - - BuiltinServer getConfiguration(String id, BuiltinServerConfiguration configuration); - - // BuiltinServer getConfiguration(String id, BuiltinServerConfiguration configuration, ConfigurationRequest request); - // void updateConfiguration(String id, xml?); - /* -getDNSConfiguration(String id) -getNATConfiguration(String id) -getPolicyConfiguration(String id) -getLBConfiguration(String id) - - * UpdateEFMConfiguration - BuiltinServer getConfiguration(String id, BuiltinServerConfiguration configuration); - - */ -} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/services/BuiltinServerAsyncApi.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/services/BuiltinServerAsyncApi.java deleted file mode 100644 index 724c103bfa..0000000000 --- a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/services/BuiltinServerAsyncApi.java +++ /dev/null @@ -1,155 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.services; - -import java.util.Set; - -import javax.inject.Named; -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.MediaType; - -import org.jclouds.fujitsu.fgcp.FGCPAsyncApi; -import org.jclouds.fujitsu.fgcp.binders.BindAlsoToSystemId; -import org.jclouds.fujitsu.fgcp.compute.functions.SingleElementResponseToElement; -import org.jclouds.fujitsu.fgcp.domain.BuiltinServer; -import org.jclouds.fujitsu.fgcp.domain.BuiltinServerBackup; -import org.jclouds.fujitsu.fgcp.domain.BuiltinServerConfiguration; -import org.jclouds.fujitsu.fgcp.domain.BuiltinServerStatus; -import org.jclouds.fujitsu.fgcp.filters.RequestAuthenticator; -import org.jclouds.fujitsu.fgcp.reference.RequestParameters; -import org.jclouds.rest.annotations.BinderParam; -import org.jclouds.rest.annotations.JAXBResponseParser; -import org.jclouds.rest.annotations.PayloadParams; -import org.jclouds.rest.annotations.QueryParams; -import org.jclouds.rest.annotations.RequestFilters; -import org.jclouds.rest.annotations.Transform; - -import com.google.common.util.concurrent.ListenableFuture; - -/** - * Non-blocking API relating to built-in servers, also called extended function - * module (EFM), such as a firewall or load balancer (SLB). - * - * @author Dies Koper - */ -@RequestFilters(RequestAuthenticator.class) -@QueryParams(keys = RequestParameters.VERSION, values = FGCPAsyncApi.VERSION) -@PayloadParams(keys = RequestParameters.VERSION, values = FGCPAsyncApi.VERSION) -@Consumes(MediaType.TEXT_XML) -public interface BuiltinServerAsyncApi { - - @Named("StartEFM") - @GET - @JAXBResponseParser - @QueryParams(keys = "Action", values = "StartEFM") - ListenableFuture start( - @BinderParam(BindAlsoToSystemId.class) @QueryParam("efmId") String id); - - @Named("StopEFM") - @GET - @JAXBResponseParser - @QueryParams(keys = "Action", values = "StopEFM") - ListenableFuture stop( - @BinderParam(BindAlsoToSystemId.class) @QueryParam("efmId") String id); - - @Named("DestroyEFM") - @GET - @JAXBResponseParser - @QueryParams(keys = "Action", values = "DestroyEFM") - ListenableFuture destroy( - @BinderParam(BindAlsoToSystemId.class) @QueryParam("efmId") String id); - - @Named("BackupEFM") - @GET - @JAXBResponseParser - @QueryParams(keys = "Action", values = "BackupEFM") - ListenableFuture backup( - @BinderParam(BindAlsoToSystemId.class) @QueryParam("efmId") String id); - - @Named("RestoreEFM") - @GET - @JAXBResponseParser - @QueryParams(keys = "Action", values = "RestoreEFM") - ListenableFuture restore( - @BinderParam(BindAlsoToSystemId.class) @QueryParam("efmId") String id, - @QueryParam("backupId") String backupId); - - @Named("ListEFMBackup") - @GET - @JAXBResponseParser - @QueryParams(keys = "Action", values = "ListEFMBackup") - ListenableFuture> listBackups( - @BinderParam(BindAlsoToSystemId.class) @QueryParam("efmId") String id); - - @Named("DestroyEFMBackup") - @GET - @JAXBResponseParser - @QueryParams(keys = "Action", values = "DestroyEFMBackup") - ListenableFuture destroyBackup( - @BinderParam(BindAlsoToSystemId.class) @QueryParam("efmId") String id, - @QueryParam("backupId") String backupId); - - @Named("GetEFMAttributes") - @GET - @JAXBResponseParser - @QueryParams(keys = "Action", values = "GetEFMAttributes") - @Transform(SingleElementResponseToElement.class) - ListenableFuture get( - @BinderParam(BindAlsoToSystemId.class) @QueryParam("efmId") String id); - - @Named("UpdateEFMAttribute") - @GET - @JAXBResponseParser - @QueryParams(keys = "Action", values = "UpdateEFMAttribute") - ListenableFuture update( - @BinderParam(BindAlsoToSystemId.class) @QueryParam("efmId") String id, - @QueryParam("attributeName") String name, - @QueryParam("attributeValue") String value); - - @Named("GetEFMStatus") - @GET - @JAXBResponseParser - @QueryParams(keys = "Action", values = "GetEFMStatus") - @Transform(SingleElementResponseToElement.class) - ListenableFuture getStatus( - @BinderParam(BindAlsoToSystemId.class) @QueryParam("efmId") String id); - - @Named("GetEFMConfiguration") - @GET - @JAXBResponseParser - @QueryParams(keys = "Action", values = "GetEFMConfiguration") - @Transform(SingleElementResponseToElement.class) - ListenableFuture getConfiguration( - @BinderParam(BindAlsoToSystemId.class) @QueryParam("efmId") String id, - @QueryParam("configurationName") BuiltinServerConfiguration configuration); - -// @Named("GetEFMConfiguration") -// @POST -// @JAXBResponseParser -// @QueryParams(keys = "Action", values = "GetEFMConfiguration") -// @Transform(SingleElementResponseToElement.class) -// ListenableFuture> getUpdateDetails(String id); - - // ListenableFuture - // updateConfiguration(@BinderParam(BindAlsoToSystemId.class) - // @QueryParam("efmId") String id, xml?); -// EFM_UPDATE, getUpdateStatus(String id); -} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/services/DiskImageApi.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/services/DiskImageApi.java deleted file mode 100644 index 468b0783a1..0000000000 --- a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/services/DiskImageApi.java +++ /dev/null @@ -1,35 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.services; - -import org.jclouds.fujitsu.fgcp.domain.DiskImage; - -/** - * API relating to disk images. - * - * @author Dies Koper - */ -public interface DiskImageApi { - - DiskImage get(String id); - - void update(String diskImageId, String localeId, String name, String value); - - void deregister(String id); -} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/services/DiskImageAsyncApi.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/services/DiskImageAsyncApi.java deleted file mode 100644 index 416eebe57c..0000000000 --- a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/services/DiskImageAsyncApi.java +++ /dev/null @@ -1,73 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.services; - -import javax.inject.Named; -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.MediaType; - -import org.jclouds.fujitsu.fgcp.FGCPAsyncApi; -import org.jclouds.fujitsu.fgcp.compute.functions.SingleElementResponseToElement; -import org.jclouds.fujitsu.fgcp.domain.DiskImage; -import org.jclouds.fujitsu.fgcp.filters.RequestAuthenticator; -import org.jclouds.fujitsu.fgcp.reference.RequestParameters; -import org.jclouds.rest.annotations.JAXBResponseParser; -import org.jclouds.rest.annotations.PayloadParams; -import org.jclouds.rest.annotations.QueryParams; -import org.jclouds.rest.annotations.RequestFilters; -import org.jclouds.rest.annotations.Transform; - -import com.google.common.util.concurrent.ListenableFuture; - -/** - * Non-blocking API relating to disk images. - * - * @author Dies Koper - */ -@RequestFilters(RequestAuthenticator.class) -@QueryParams(keys = RequestParameters.VERSION, values = FGCPAsyncApi.VERSION) -@PayloadParams(keys = RequestParameters.VERSION, values = FGCPAsyncApi.VERSION) -@Consumes(MediaType.TEXT_XML) -public interface DiskImageAsyncApi { - - @Named("GetDiskImageAttributes") - @GET - @JAXBResponseParser - @QueryParams(keys = "Action", values = "GetDiskImageAttributes") - @Transform(SingleElementResponseToElement.class) - ListenableFuture get(@QueryParam("diskImageId") String id); - - @Named("UpdateDiskImageAttribute") - @GET - @JAXBResponseParser - @QueryParams(keys = "Action", values = "UpdateDiskImageAttribute") - ListenableFuture update( - @QueryParam("diskImageId") String diskImageId, - @QueryParam("updateLcId") String localeId, - @QueryParam("attributeName") String name, - @QueryParam("attributeValue") String value); - - @Named("UnregisterDiskImage") - @GET - @JAXBResponseParser - @QueryParams(keys = "Action", values = "UnregisterDiskImage") - ListenableFuture deregister(@QueryParam("diskImageId") String id); -} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/services/FirewallApi.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/services/FirewallApi.java deleted file mode 100644 index ebc23762ac..0000000000 --- a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/services/FirewallApi.java +++ /dev/null @@ -1,33 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.services; - -import java.util.Set; -import org.jclouds.fujitsu.fgcp.domain.Rule; - -/** - * API relating to a system's built-in server of type firewall. - * - * @author Dies Koper - */ -public interface FirewallApi extends BuiltinServerApi { - - Set getNATConfiguration(String id); - -} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/services/FirewallAsyncApi.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/services/FirewallAsyncApi.java deleted file mode 100644 index 204eb88b8c..0000000000 --- a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/services/FirewallAsyncApi.java +++ /dev/null @@ -1,70 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.services; - -import java.util.Set; - -import javax.inject.Named; -import javax.ws.rs.Consumes; -import javax.ws.rs.POST; -import javax.ws.rs.core.MediaType; - -import org.jclouds.fujitsu.fgcp.FGCPAsyncApi; -import org.jclouds.fujitsu.fgcp.compute.functions.SingleElementResponseToElement; -import org.jclouds.fujitsu.fgcp.domain.Rule; -import org.jclouds.fujitsu.fgcp.filters.RequestAuthenticator; -import org.jclouds.fujitsu.fgcp.reference.RequestParameters; -import org.jclouds.rest.annotations.JAXBResponseParser; -import org.jclouds.rest.annotations.PayloadParams; -import org.jclouds.rest.annotations.QueryParams; -import org.jclouds.rest.annotations.RequestFilters; -import org.jclouds.rest.annotations.Transform; - -import com.google.common.util.concurrent.ListenableFuture; - -/** - * Non-blocking API relating to a built-in server, also called extended function - * module (EFM), of type firewall. - * - * @author Dies Koper - */ -@RequestFilters(RequestAuthenticator.class) -@QueryParams(keys = RequestParameters.VERSION, values = FGCPAsyncApi.VERSION) -@PayloadParams(keys = RequestParameters.VERSION, values = FGCPAsyncApi.VERSION) -@Consumes(MediaType.TEXT_XML) -public interface FirewallAsyncApi extends BuiltinServerAsyncApi { - - @Named("GetEFMConfiguration") - @POST - @JAXBResponseParser - @QueryParams(keys = "Action", values = "GetEFMConfiguration") - @Transform(SingleElementResponseToElement.class) - ListenableFuture> getNATConfiguration(String id); - - /* - FW_NAT_RULE, getNATConfiguration(String id) - - FW_DNS, getDNSConfiguration(String id) - FW_POLICY, getPolicyConfiguration(String id) - - FW_LOG, getFirewallLogs(String id); - FW_LIMIT_POLICY, - - */ -} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/services/LoadBalancerApi.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/services/LoadBalancerApi.java deleted file mode 100644 index 276fc95d53..0000000000 --- a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/services/LoadBalancerApi.java +++ /dev/null @@ -1,28 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.services; - -/** - * API relating to a built-in server of type software load balancer (SLB). - * - * @author Dies Koper - */ -public interface LoadBalancerApi extends BuiltinServerApi { - -} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/services/LoadBalancerAsyncApi.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/services/LoadBalancerAsyncApi.java deleted file mode 100644 index 619bec3aa9..0000000000 --- a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/services/LoadBalancerAsyncApi.java +++ /dev/null @@ -1,51 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.services; - -import javax.ws.rs.Consumes; -import javax.ws.rs.core.MediaType; - -import org.jclouds.fujitsu.fgcp.FGCPAsyncApi; -import org.jclouds.fujitsu.fgcp.filters.RequestAuthenticator; -import org.jclouds.fujitsu.fgcp.reference.RequestParameters; -import org.jclouds.rest.annotations.PayloadParams; -import org.jclouds.rest.annotations.QueryParams; -import org.jclouds.rest.annotations.RequestFilters; - -/** - * Non-blocking API relating to a built-in server, also called extended function - * module (EFM), of type load balancer (SLB). - * - * @author Dies Koper - */ -@RequestFilters(RequestAuthenticator.class) -@QueryParams(keys = RequestParameters.VERSION, values = FGCPAsyncApi.VERSION) -@PayloadParams(keys = RequestParameters.VERSION, values = FGCPAsyncApi.VERSION) -@Consumes(MediaType.TEXT_XML) -public interface LoadBalancerAsyncApi extends BuiltinServerAsyncApi { - - /* - SLB_RULE, getLBConfiguration(String id) - SLB_LOAD_STATISTICS, getLoadBalancerStats(String id) - SLB_ERROR_STATISTICS, getLoadBalancerErrorStats(String id) - SLB_CERTIFICATE_LIST, getLoadBalancerCerts(String id) - SLB_CONNECTION, getLoadBalancerConnection(String id) - - */ -} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/services/PublicIPAddressApi.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/services/PublicIPAddressApi.java deleted file mode 100644 index ccf1d6da80..0000000000 --- a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/services/PublicIPAddressApi.java +++ /dev/null @@ -1,40 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.services; - -import org.jclouds.fujitsu.fgcp.domain.PublicIP; -import org.jclouds.fujitsu.fgcp.domain.PublicIPStatus; - -/** - * API relating to public IP addresses. - * - * @author Dies Koper - */ -public interface PublicIPAddressApi { - - void attach(String systemId, String ip); - - void detach(String systemId, String ip); - - void free(String systemId, String ip); - - PublicIPStatus getStatus(String ip); - - PublicIP get(String ip); -} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/services/PublicIPAddressAsyncApi.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/services/PublicIPAddressAsyncApi.java deleted file mode 100644 index 9fb95f6b5a..0000000000 --- a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/services/PublicIPAddressAsyncApi.java +++ /dev/null @@ -1,88 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.services; - -import javax.inject.Named; -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.MediaType; - -import org.jclouds.fujitsu.fgcp.FGCPAsyncApi; -import org.jclouds.fujitsu.fgcp.compute.functions.SingleElementResponseToElement; -import org.jclouds.fujitsu.fgcp.domain.PublicIP; -import org.jclouds.fujitsu.fgcp.domain.PublicIPStatus; -import org.jclouds.fujitsu.fgcp.filters.RequestAuthenticator; -import org.jclouds.fujitsu.fgcp.reference.RequestParameters; -import org.jclouds.rest.annotations.JAXBResponseParser; -import org.jclouds.rest.annotations.PayloadParams; -import org.jclouds.rest.annotations.QueryParams; -import org.jclouds.rest.annotations.RequestFilters; -import org.jclouds.rest.annotations.Transform; - -import com.google.common.util.concurrent.ListenableFuture; - -/** - * Non-blocking API relating to public IP addresses. - * - * @author Dies Koper - */ -@RequestFilters(RequestAuthenticator.class) -@QueryParams(keys = RequestParameters.VERSION, values = FGCPAsyncApi.VERSION) -@PayloadParams(keys = RequestParameters.VERSION, values = FGCPAsyncApi.VERSION) -@Consumes(MediaType.TEXT_XML) -public interface PublicIPAddressAsyncApi { - - @Named("AttachPublicIP") - @GET - @JAXBResponseParser - @QueryParams(keys = "Action", values = "AttachPublicIP") - ListenableFuture attach(@QueryParam("vsysId") String systemId, - @QueryParam("publicIp") String ip); - - @Named("DetachPublicIP") - @GET - @JAXBResponseParser - @QueryParams(keys = "Action", values = "DetachPublicIP") - ListenableFuture detach(@QueryParam("vsysId") String systemId, - @QueryParam("publicIp") String ip); - - @Named("GetPublicIPStatus") - @GET - @JAXBResponseParser - @QueryParams(keys = "Action", values = "GetPublicIPStatus") - @Transform(SingleElementResponseToElement.class) - ListenableFuture getStatus( - @QueryParam("publicIp") String ip); - - @Named("GetPublicIPAttributes") - @GET - @JAXBResponseParser - @QueryParams(keys = "Action", values = "GetPublicIPAttributes") - @Transform(SingleElementResponseToElement.class) - ListenableFuture get(@QueryParam("publicIp") String ip); - - @Named("FreePublicIP") - @GET - @JAXBResponseParser - @QueryParams(keys = "Action", values = "FreePublicIP") - ListenableFuture free(@QueryParam("vsysId") String systemId, - @QueryParam("publicIp") String ip); - -} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/services/SystemTemplateApi.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/services/SystemTemplateApi.java deleted file mode 100644 index 2d4e5af78b..0000000000 --- a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/services/SystemTemplateApi.java +++ /dev/null @@ -1,39 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.services; - -import org.jclouds.fujitsu.fgcp.domain.VSystemDescriptor; - -/** - * API relating to system templates, also referred to as virtual system - * descriptors. - * - * @author Dies Koper - */ -public interface SystemTemplateApi { - - VSystemDescriptor get(String id); - - void update(String id, String localeId, String name, String value); - - void deregister(String id); - - void deregisterPrivateTemplate(String id); - -} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/services/SystemTemplateAsyncApi.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/services/SystemTemplateAsyncApi.java deleted file mode 100644 index 333a4f601a..0000000000 --- a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/services/SystemTemplateAsyncApi.java +++ /dev/null @@ -1,82 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.services; - -import javax.inject.Named; -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.MediaType; - -import org.jclouds.fujitsu.fgcp.FGCPAsyncApi; -import org.jclouds.fujitsu.fgcp.compute.functions.SingleElementResponseToElement; -import org.jclouds.fujitsu.fgcp.domain.VSystemDescriptor; -import org.jclouds.fujitsu.fgcp.filters.RequestAuthenticator; -import org.jclouds.fujitsu.fgcp.reference.RequestParameters; -import org.jclouds.rest.annotations.JAXBResponseParser; -import org.jclouds.rest.annotations.PayloadParams; -import org.jclouds.rest.annotations.QueryParams; -import org.jclouds.rest.annotations.RequestFilters; -import org.jclouds.rest.annotations.Transform; - -import com.google.common.util.concurrent.ListenableFuture; - -/** - * Non-blocking API relating to system templates, also referred to as virtual - * system descriptors. - * - * @author Dies Koper - */ -@RequestFilters(RequestAuthenticator.class) -@QueryParams(keys = RequestParameters.VERSION, values = FGCPAsyncApi.VERSION) -@PayloadParams(keys = RequestParameters.VERSION, values = FGCPAsyncApi.VERSION) -@Consumes(MediaType.TEXT_XML) -public interface SystemTemplateAsyncApi { - - @Named("GetVSYSDescriptorConfiguration") - @GET - @JAXBResponseParser - @QueryParams(keys = "Action", values = "GetVSYSDescriptorConfiguration") - @Transform(SingleElementResponseToElement.class) - ListenableFuture get( - @QueryParam("vsysDescriptorId") String id); - - @Named("UpdateVSYSDescriptorAttribute") - @GET - @JAXBResponseParser - @QueryParams(keys = "Action", values = "UpdateVSYSDescriptorAttribute") - ListenableFuture update(@QueryParam("vsysDescriptorId") String id, - @QueryParam("updateLcId") String localeId, - @QueryParam("attributeName") String name, - @QueryParam("attributeValue") String value); - - @Named("UnregisterVSYSDescriptor") - @GET - @JAXBResponseParser - @QueryParams(keys = "Action", values = "UnregisterVSYSDescriptor") - ListenableFuture deregister( - @QueryParam("vsysDescriptorId") String id); - - @Named("UnregisterPrivateVSYSDescriptor") - @GET - @JAXBResponseParser - @QueryParams(keys = "Action", values = "UnregisterPrivateVSYSDescriptor") - ListenableFuture deregisterPrivateTemplate( - @QueryParam("vsysDescriptorId") String id); -} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/services/VirtualDCApi.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/services/VirtualDCApi.java deleted file mode 100644 index 9c8c49ee46..0000000000 --- a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/services/VirtualDCApi.java +++ /dev/null @@ -1,80 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.services; - -import java.util.Map; -import java.util.Set; -import org.jclouds.fujitsu.fgcp.domain.AddressRange; -import org.jclouds.fujitsu.fgcp.domain.DiskImage; -import org.jclouds.fujitsu.fgcp.domain.EventLog; -import org.jclouds.fujitsu.fgcp.domain.Information; -import org.jclouds.fujitsu.fgcp.domain.PublicIP; -import org.jclouds.fujitsu.fgcp.domain.ServerType; -import org.jclouds.fujitsu.fgcp.domain.UsageInfo; -import org.jclouds.fujitsu.fgcp.domain.VSystem; -import org.jclouds.fujitsu.fgcp.domain.VSystemDescriptor; -import org.jclouds.javax.annotation.Nullable; - -/** - * API relating to the virtual data center. - * - * @see VirtualDCAsyncApi - * @author Dies Koper - */ -public interface VirtualDCApi { - - String createVirtualSystem(String descriptorId, String name); - - Set listVirtualSystems(); - - // according to the manual it takes a 'String diskImageId' but value seems - // to be ignored - Set listServerTypes(); - - Set listDiskImages(); - - Set listDiskImages(@Nullable String serverCategory, String vsysDescriptorId); - - Map listPublicIPs(); - - void addAddressRange(String pipFrom, String pipTo); - - void createAddressPool(String pipFrom, String pipTo); - - void deleteAddressRange(String pipFrom, String pipTo); - - Set getAddressRange(); - - Set listVSYSDescriptor(); - - Set listVSYSDescriptor(String keyword, int estimateFrom, - int estimateTo); - - Set getEventLogs(boolean all); - - Set getEventLogs(); - - Set getInformation(boolean all); - - Set getInformation(); - - Set getSystemUsage(); - - Set getSystemUsage(String systemIds); -} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/services/VirtualDCAsyncApi.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/services/VirtualDCAsyncApi.java deleted file mode 100644 index f67996f3d3..0000000000 --- a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/services/VirtualDCAsyncApi.java +++ /dev/null @@ -1,206 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.services; - -import java.util.Map; -import java.util.Set; - -import javax.inject.Named; -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.MediaType; - -import org.jclouds.fujitsu.fgcp.FGCPAsyncApi; -import org.jclouds.fujitsu.fgcp.compute.functions.SingleElementResponseToElement; -import org.jclouds.fujitsu.fgcp.domain.AddressRange; -import org.jclouds.fujitsu.fgcp.domain.DiskImage; -import org.jclouds.fujitsu.fgcp.domain.EventLog; -import org.jclouds.fujitsu.fgcp.domain.Information; -import org.jclouds.fujitsu.fgcp.domain.PublicIP; -import org.jclouds.fujitsu.fgcp.domain.ServerType; -import org.jclouds.fujitsu.fgcp.domain.UsageInfo; -import org.jclouds.fujitsu.fgcp.domain.VSystem; -import org.jclouds.fujitsu.fgcp.domain.VSystemDescriptor; -import org.jclouds.fujitsu.fgcp.filters.RequestAuthenticator; -import org.jclouds.fujitsu.fgcp.reference.RequestParameters; -import org.jclouds.javax.annotation.Nullable; -import org.jclouds.rest.annotations.JAXBResponseParser; -import org.jclouds.rest.annotations.PayloadParams; -import org.jclouds.rest.annotations.QueryParams; -import org.jclouds.rest.annotations.RequestFilters; -import org.jclouds.rest.annotations.Transform; - -import com.google.common.util.concurrent.ListenableFuture; - -/** - * Non-blocking API relating to the virtual data center. - * - * @author Dies Koper - */ -@RequestFilters(RequestAuthenticator.class) -@QueryParams(keys = RequestParameters.VERSION, values = FGCPAsyncApi.VERSION) -@PayloadParams(keys = RequestParameters.VERSION, values = FGCPAsyncApi.VERSION) -@Consumes(MediaType.TEXT_XML) -public interface VirtualDCAsyncApi { - - @Named("CreateVSYS") - // @POST - @GET - @JAXBResponseParser - // @XMLResponseParser(VSYSCreateHandler.class) - @QueryParams(keys = "Action", values = "CreateVSYS") - @Transform(SingleElementResponseToElement.class) - // @PayloadParams(keys = "Action", values = "CreateVSYS") - // @Produces(MediaType.TEXT_XML) - // @MapBinder(BindParamsToXmlPayload.class) - // ListenableFuture - // createVirtualSystem(@PayloadParam("vsysDescriptorId") String - // vsysDescriptorId, @PayloadParam("vsysName") String vsysName); - ListenableFuture createVirtualSystem( - @QueryParam("vsysDescriptorId") String descriptorId, - @QueryParam("vsysName") String name); - - @Named("ListVSYS") - @GET - @JAXBResponseParser - // @XMLResponseParser(VSYSListHandler.class) - @QueryParams(keys = "Action", values = "ListVSYS") - ListenableFuture> listVirtualSystems(); - - @Named("ListServerType") - @GET - @JAXBResponseParser - // according to the manual it takes a 'String diskImageId' but value seems - // to be ignored - @QueryParams(keys = { "Action", "diskImageId" }, values = { - "ListServerType", "dummy" }) - // @XmlJavaTypeAdapter(SetOfServerTypesXMLAdapter.class) - // @XmlElement(type = ServerType.class) - ListenableFuture> listServerTypes(); - - @Named("ListDiskImage") - @GET - @JAXBResponseParser - @QueryParams(keys = "Action", values = "ListDiskImage") - ListenableFuture> listDiskImages(); - - @Named("ListDiskImage") - @GET - @JAXBResponseParser - @QueryParams(keys = "Action", values = "ListDiskImage") - ListenableFuture> listDiskImages( - @Nullable @QueryParam("serverCategory") String serverCategory, - @QueryParam("vsysDescriptorId") String vsysDescriptorId); - - /** - * - * @return - * @see VirtualSystemAsyncApi#listPublicIPs(String) - */ - @Named("ListPublicIP") - @GET - @JAXBResponseParser - @QueryParams(keys = "Action", values = "ListPublicIP") - ListenableFuture> listPublicIPs(); - - @Named("AddAddressRange") - @GET - @JAXBResponseParser - @QueryParams(keys = "Action", values = "AddAddressRange") - ListenableFuture addAddressRange( - @QueryParam("pipFrom") String pipFrom, - @QueryParam("pipTo") String pipTo); - - @Named("CreateAddressPool") - @GET - @JAXBResponseParser - @QueryParams(keys = "Action", values = "CreateAddressPool") - ListenableFuture createAddressPool( - @QueryParam("pipFrom") String pipFrom, - @QueryParam("pipTo") String pipTo); - - @Named("DeleteAddressRange") - @GET - @JAXBResponseParser - @QueryParams(keys = "Action", values = "DeleteAddressRange") - ListenableFuture deleteAddressRange( - @QueryParam("pipFrom") String pipFrom, - @QueryParam("pipTo") String pipTo); - - @Named("GetAddressRange") - @GET - @JAXBResponseParser - @QueryParams(keys = "Action", values = "GetAddressRange") - ListenableFuture> getAddressRange(); - - @Named("ListVSYSDescriptor") - @GET - @JAXBResponseParser - @QueryParams(keys = "Action", values = "ListVSYSDescriptor") - ListenableFuture> listVSYSDescriptor(); - - @Named("ListVSYSDescriptor") - @GET - @JAXBResponseParser - @QueryParams(keys = "Action", values = "ListVSYSDescriptor") - ListenableFuture> listVSYSDescriptor( - @QueryParam("keyword") String keyword, - @QueryParam("estimateFrom") int estimateFrom, - @QueryParam("estimateTo") int estimateTo); - - @Named("GetEventLog") - @GET - @JAXBResponseParser - @QueryParams(keys = "Action", values = "GetEventLog") - ListenableFuture> getEventLogs(); - - @Named("GetEventLog") - @GET - @JAXBResponseParser - @QueryParams(keys = "Action", values = "GetEventLog") - ListenableFuture> getEventLogs(@QueryParam("all") boolean all); - - @Named("GetInformation") - @GET - @JAXBResponseParser - @QueryParams(keys = "Action", values = "GetInformation") - ListenableFuture> getInformation(); - - @Named("GetInformation") - @GET - @JAXBResponseParser - @QueryParams(keys = "Action", values = "GetInformation") - ListenableFuture> getInformation( - @QueryParam("all") boolean all); - - @Named("GetSystemUsage") - @GET - @JAXBResponseParser - @QueryParams(keys = "Action", values = "GetSystemUsage") - ListenableFuture> getSystemUsage(); - - @Named("GetSystemUsage") - @GET - @JAXBResponseParser - @QueryParams(keys = "Action", values = "GetSystemUsage") - ListenableFuture> getSystemUsage( - @QueryParam("systemIds") String systemIds); - -} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/services/VirtualServerApi.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/services/VirtualServerApi.java deleted file mode 100644 index 81638facc8..0000000000 --- a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/services/VirtualServerApi.java +++ /dev/null @@ -1,57 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.services; - -import java.util.Set; -import org.jclouds.fujitsu.fgcp.domain.PerformanceInfo; -import org.jclouds.fujitsu.fgcp.domain.VServer; -import org.jclouds.fujitsu.fgcp.domain.VServerStatus; -import org.jclouds.fujitsu.fgcp.domain.VServerWithDetails; - -/** - * API relating to virtual servers. - * - * @author Dies Koper - */ -public interface VirtualServerApi { - - void start(String id); - - void stop(String id); - - void stopForcefully(String id); - - void destroy(String id); - - VServer get(String id); - - VServerWithDetails getDetails(String id); - - void update(String id, String name, String value); - - VServerStatus getStatus(String id); - - String getInitialPassword(String id); - - void attachDisk(String serverId, String diskId); - - Set getPerformanceInformation(String id, String interval); - - void registerAsPrivateDiskImage(String xml); -} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/services/VirtualServerAsyncApi.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/services/VirtualServerAsyncApi.java deleted file mode 100644 index 62cd6495a3..0000000000 --- a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/services/VirtualServerAsyncApi.java +++ /dev/null @@ -1,159 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.services; - -import java.util.Set; - -import javax.inject.Named; -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.MediaType; - -import org.jclouds.fujitsu.fgcp.FGCPAsyncApi; -import org.jclouds.fujitsu.fgcp.binders.BindAlsoToSystemId; -import org.jclouds.fujitsu.fgcp.compute.functions.SingleElementResponseToElement; -import org.jclouds.fujitsu.fgcp.domain.PerformanceInfo; -import org.jclouds.fujitsu.fgcp.domain.VServer; -import org.jclouds.fujitsu.fgcp.domain.VServerStatus; -import org.jclouds.fujitsu.fgcp.domain.VServerWithDetails; -import org.jclouds.fujitsu.fgcp.filters.RequestAuthenticator; -import org.jclouds.fujitsu.fgcp.reference.RequestParameters; -import org.jclouds.rest.annotations.BinderParam; -import org.jclouds.rest.annotations.JAXBResponseParser; -import org.jclouds.rest.annotations.PayloadParams; -import org.jclouds.rest.annotations.QueryParams; -import org.jclouds.rest.annotations.RequestFilters; -import org.jclouds.rest.annotations.Transform; - -import com.google.common.util.concurrent.ListenableFuture; - -/** - * Non-blocking API relating to virtual servers. - * - * @author Dies Koper - */ -@RequestFilters(RequestAuthenticator.class) -@QueryParams(keys = RequestParameters.VERSION, values = FGCPAsyncApi.VERSION) -@PayloadParams(keys = RequestParameters.VERSION, values = FGCPAsyncApi.VERSION) -@Consumes(MediaType.TEXT_XML) -public interface VirtualServerAsyncApi { - - @Named("StartVServer") - @GET - @JAXBResponseParser - @QueryParams(keys = "Action", values = "StartVServer") - ListenableFuture start( - @BinderParam(BindAlsoToSystemId.class) @QueryParam("vserverId") String id); - - @Named("StopVServer") - @GET - @JAXBResponseParser - @QueryParams(keys = "Action", values = "StopVServer") - ListenableFuture stop( - @BinderParam(BindAlsoToSystemId.class) @QueryParam("vserverId") String id); - - @Named("StopVServer") - @GET - @JAXBResponseParser - @QueryParams(keys = { "Action", "force" }, values = { "StopVServer", "true" }) - ListenableFuture stopForcefully( - @BinderParam(BindAlsoToSystemId.class) @QueryParam("vserverId") String id); - - @Named("DestroyVServer") - @GET - @JAXBResponseParser - @QueryParams(keys = "Action", values = "DestroyVServer") - ListenableFuture destroy( - @BinderParam(BindAlsoToSystemId.class) @QueryParam("vserverId") String id); - - @Named("GetVServerAttributes") - @GET - @JAXBResponseParser - @QueryParams(keys = "Action", values = "GetVServerAttributes") - @Transform(SingleElementResponseToElement.class) - ListenableFuture get( - @BinderParam(BindAlsoToSystemId.class) @QueryParam("vserverId") String id); - - @Named("GetVServerConfiguration") - @GET - @JAXBResponseParser - @QueryParams(keys = "Action", values = "GetVServerConfiguration") - @Transform(SingleElementResponseToElement.class) - ListenableFuture getDetails( - @BinderParam(BindAlsoToSystemId.class) @QueryParam("vserverId") String id); - - @Named("UpdateVServerAttribute") - @GET - @JAXBResponseParser - @QueryParams(keys = "Action", values = "UpdateVServerAttribute") - ListenableFuture update( - @BinderParam(BindAlsoToSystemId.class) @QueryParam("vserverId") String id, - @QueryParam("attributeName") String name, - @QueryParam("attributeValue") String value); - - @Named("GetVServerStatus") - @GET - @JAXBResponseParser - @QueryParams(keys = "Action", values = "GetVServerStatus") - // @Transform(StringToVServerStatus.class) - @Transform(SingleElementResponseToElement.class) - ListenableFuture getStatus( - @BinderParam(BindAlsoToSystemId.class) @QueryParam("vserverId") String id); - - @Named("GetVServerInitialPassword") - @GET - @JAXBResponseParser - @QueryParams(keys = "Action", values = "GetVServerInitialPassword") - @Transform(SingleElementResponseToElement.class) - ListenableFuture getInitialPassword( - @BinderParam(BindAlsoToSystemId.class) @QueryParam("vserverId") String id); - - @Named("AttachVDisk") - @GET - @JAXBResponseParser - @QueryParams(keys = "Action", values = "AttachVDisk") - ListenableFuture attachDisk( - @BinderParam(BindAlsoToSystemId.class) @QueryParam("vserverId") String serverId, - @QueryParam("vdiskId") String diskId); - - @Named("GetPerformanceInformation") - @GET - @JAXBResponseParser - @QueryParams(keys = "Action", values = "GetPerformanceInformation") - ListenableFuture> getPerformanceInformation( - @BinderParam(BindAlsoToSystemId.class) @QueryParam("serverId") String id, - @QueryParam("interval") String interval); - - @Named("GetPerformanceInformation") - @GET - @JAXBResponseParser - @QueryParams(keys = "Action", values = "GetPerformanceInformation") - ListenableFuture> getPerformanceInformation( - @BinderParam(BindAlsoToSystemId.class) @QueryParam("serverId") String id, - @QueryParam("dataType") String dataType, - @QueryParam("interval") String interval); - - @Named("RegisterPrivateDiskImage") - @POST - @JAXBResponseParser - @QueryParams(keys = "Action", values = "RegisterPrivateDiskImage") - ListenableFuture registerAsPrivateDiskImage(String xml); -} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/services/VirtualSystemApi.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/services/VirtualSystemApi.java deleted file mode 100644 index 1db2b09e7c..0000000000 --- a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/services/VirtualSystemApi.java +++ /dev/null @@ -1,70 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.services; - -import java.util.Set; -import org.jclouds.fujitsu.fgcp.domain.BuiltinServer; -import org.jclouds.fujitsu.fgcp.domain.PublicIP; -import org.jclouds.fujitsu.fgcp.domain.VDisk; -import org.jclouds.fujitsu.fgcp.domain.VServer; -import org.jclouds.fujitsu.fgcp.domain.VSystem; -import org.jclouds.fujitsu.fgcp.domain.VSystemStatus; -import org.jclouds.fujitsu.fgcp.domain.VSystemWithDetails; - -/** - * API relating to virtual systems. - * - * @author Dies Koper - */ -public interface VirtualSystemApi { - - void destroy(String id); - - VSystemStatus getStatus(String id); - - VSystem get(String id); - - VSystemWithDetails getDetails(String id); - - void update(String id, String name, String value); - - void updateConfiguration(String id, String name, String value); - - String createServer(String name, String type, String diskImageId, - String networkId); - - Set listServers(String id); - - String createBuiltinServer(String name, String networkId); - - Set listBuiltinServers(String id, String type); - - String createDisk(String id, String name, int size); - - Set listDisks(String id); - - void allocatePublicIP(String id); - - Set listPublicIPs(String id); - - String standByConsole(String id, String networkId); - - void registerAsPrivateVSYSDescriptor(String id, - String vsysDescriptorXMLFilePath); -} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/services/VirtualSystemAsyncApi.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/services/VirtualSystemAsyncApi.java deleted file mode 100644 index e750f063ac..0000000000 --- a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/services/VirtualSystemAsyncApi.java +++ /dev/null @@ -1,188 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.services; - -import java.util.Set; - -import javax.inject.Named; -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.MediaType; - -import org.jclouds.fujitsu.fgcp.FGCPAsyncApi; -import org.jclouds.fujitsu.fgcp.binders.BindAlsoToSystemId; -import org.jclouds.fujitsu.fgcp.compute.functions.SingleElementResponseToElement; -import org.jclouds.fujitsu.fgcp.domain.BuiltinServer; -import org.jclouds.fujitsu.fgcp.domain.PublicIP; -import org.jclouds.fujitsu.fgcp.domain.VDisk; -import org.jclouds.fujitsu.fgcp.domain.VServer; -import org.jclouds.fujitsu.fgcp.domain.VSystem; -import org.jclouds.fujitsu.fgcp.domain.VSystemStatus; -import org.jclouds.fujitsu.fgcp.domain.VSystemWithDetails; -import org.jclouds.fujitsu.fgcp.filters.RequestAuthenticator; -import org.jclouds.fujitsu.fgcp.reference.RequestParameters; -import org.jclouds.rest.annotations.BinderParam; -import org.jclouds.rest.annotations.JAXBResponseParser; -import org.jclouds.rest.annotations.PayloadParams; -import org.jclouds.rest.annotations.QueryParams; -import org.jclouds.rest.annotations.RequestFilters; -import org.jclouds.rest.annotations.Transform; - -import com.google.common.util.concurrent.ListenableFuture; - -/** - * Non-blocking API relating to virtual systems. - * - * @author Dies Koper - */ -@RequestFilters(RequestAuthenticator.class) -@QueryParams(keys = RequestParameters.VERSION, values = FGCPAsyncApi.VERSION) -@PayloadParams(keys = RequestParameters.VERSION, values = FGCPAsyncApi.VERSION) -@Consumes(MediaType.TEXT_XML) -public interface VirtualSystemAsyncApi { - - @Named("DestroyVSYS") - @GET - @JAXBResponseParser - @QueryParams(keys = "Action", values = "DestroyVSYS") - ListenableFuture destroy(@QueryParam("vsysId") String id); - - @Named("GetVSYSStatus") - @GET - @JAXBResponseParser - @QueryParams(keys = "Action", values = "GetVSYSStatus") - @Transform(SingleElementResponseToElement.class) - ListenableFuture getStatus(@QueryParam("vsysId") String id); - - @Named("GetVSYSAttributes") - @GET - @JAXBResponseParser - @QueryParams(keys = "Action", values = "GetVSYSAttributes") - @Transform(SingleElementResponseToElement.class) - ListenableFuture get(@QueryParam("vsysId") String id); - - @Named("GetVSYSConfiguration") - @GET - @JAXBResponseParser - @QueryParams(keys = "Action", values = "GetVSYSConfiguration") - @Transform(SingleElementResponseToElement.class) - ListenableFuture getDetails( - @QueryParam("vsysId") String id); - - @Named("UpdateVSYSAttribute") - @GET - @JAXBResponseParser - @QueryParams(keys = "Action", values = "UpdateVSYSAttribute") - ListenableFuture update(@QueryParam("vsysId") String id, - @QueryParam("attributeName") String name, - @QueryParam("attributeValue") String value); - - @Named("UpdateVSYSConfiguration") - @GET - @JAXBResponseParser - @QueryParams(keys = "Action", values = "UpdateVSYSConfiguration") - ListenableFuture updateConfiguration(@QueryParam("vsysId") String id, - @QueryParam("configurationName") String name, - @QueryParam("configurationValue") String value); - - @Named("CreateVServer") - @GET - @JAXBResponseParser - @QueryParams(keys = "Action", values = "CreateVServer") - @Transform(SingleElementResponseToElement.class) - ListenableFuture createServer( - @QueryParam("vserverName") String name, - @QueryParam("vserverType") String type, - @QueryParam("diskImageId") String diskImageId, - @BinderParam(BindAlsoToSystemId.class) @QueryParam("networkId") String networkId); - - @Named("ListVServer") - @GET - @JAXBResponseParser - @QueryParams(keys = "Action", values = "ListVServer") - ListenableFuture> listServers(@QueryParam("vsysId") String id); - - @Named("CreateVDisk") - @GET - @JAXBResponseParser - @QueryParams(keys = "Action", values = "CreateVDisk") - @Transform(SingleElementResponseToElement.class) - ListenableFuture createDisk(@QueryParam("vsysId") String id, - @QueryParam("vdiskName") String name, @QueryParam("size") int size); - - @Named("ListVDisk") - @GET - @JAXBResponseParser - @QueryParams(keys = "Action", values = "ListVDisk") - ListenableFuture> listDisks(@QueryParam("vsysId") String id); - - @Named("AllocatePublicIP") - @GET - @JAXBResponseParser - @QueryParams(keys = "Action", values = "AllocatePublicIP") - ListenableFuture allocatePublicIP(@QueryParam("vsysId") String id); - - /** - * - * @return - * @see VirtualDCAsyncApi#listPublicIPs() - */ - @Named("ListPublicIP") - @GET - @JAXBResponseParser - @QueryParams(keys = "Action", values = "ListPublicIP") - @Transform(SingleElementResponseToElement.class) - ListenableFuture> listPublicIPs( - @QueryParam("vsysId") String id); - - @Named("CreateEFM") - @GET - @JAXBResponseParser - // SLB is the only built-in server that can currently be created so - // hard-code it - @QueryParams(keys = { "Action", "efmType" }, values = { "CreateEFM", "SLB" }) - @Transform(SingleElementResponseToElement.class) - ListenableFuture createBuiltinServer( - @QueryParam("efmName") String name, - @BinderParam(BindAlsoToSystemId.class) @QueryParam("networkId") String networkId); - - @Named("ListEFM") - @GET - @JAXBResponseParser - @QueryParams(keys = "Action", values = "ListEFM") - ListenableFuture> listBuiltinServers( - @QueryParam("vsysId") String id, @QueryParam("efmType") String type); - - @Named("StandByConsole") - @GET - @JAXBResponseParser - @QueryParams(keys = "Action", values = "StandByConsole") - @Transform(SingleElementResponseToElement.class) - ListenableFuture standByConsole(@QueryParam("vsysId") String id, - @QueryParam("networkId") String networkId); - - @Named("RegisterPrivateVSYSDescriptor") - @GET - @JAXBResponseParser - @QueryParams(keys = "Action", values = "RegisterPrivateVSYSDescriptor") - ListenableFuture registerAsPrivateVSYSDescriptor( - @QueryParam("vsysId") String id, - @QueryParam("vsysDescriptorXMLFilePath") String vsysDescriptorXMLFilePath); -} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/suppliers/KeyStoreSupplier.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/suppliers/KeyStoreSupplier.java deleted file mode 100644 index 339b33b472..0000000000 --- a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/suppliers/KeyStoreSupplier.java +++ /dev/null @@ -1,134 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.suppliers; - -import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.base.Throwables.propagate; - -import java.io.ByteArrayInputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.security.KeyStore; -import java.security.KeyStoreException; -import java.security.NoSuchAlgorithmException; -import java.security.PrivateKey; -import java.security.cert.Certificate; -import java.security.cert.CertificateException; -import java.security.cert.CertificateFactory; -import java.security.spec.InvalidKeySpecException; -import java.security.spec.KeySpec; -import java.util.Collection; - -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jclouds.crypto.Crypto; -import org.jclouds.crypto.Pems; -import org.jclouds.domain.Credentials; -import org.jclouds.io.InputSuppliers; -import org.jclouds.location.Provider; - -import com.google.common.base.Charsets; -import com.google.common.base.Supplier; - -/** - * TODO this code needs to be completely refactored. It needs to stop using KeyStore of at all possible and definitely - * the local filesystem. Please look at oauth for examples on how to do this via PEMs. - */ -@Deprecated -@Singleton -public class KeyStoreSupplier implements Supplier { - private final Crypto crypto; - private final Supplier creds; - - @Inject - public KeyStoreSupplier(Crypto crypto, @Provider Supplier creds) { - this.crypto = crypto; - this.creds = creds; - } - - @Override - public KeyStore get() { - Credentials currentCreds = checkNotNull(creds.get(), "credential supplier returned null"); - String cert = checkNotNull(currentCreds.identity, "credential supplier returned null identity (should be cert)"); - String keyStorePassword = checkNotNull(currentCreds.credential, - "credential supplier returned null credential (should be keyStorePassword)"); - try { - KeyStore keyStore = KeyStore.getInstance("PKCS12"); - - File certFile = new File(checkNotNull(cert)); - if (certFile.isFile()) { // cert is path to pkcs12 file - FileInputStream stream = new FileInputStream(certFile); - try { - keyStore.load(stream, keyStorePassword.toCharArray()); - } finally { - stream.close(); - } - } else { // cert is PEM encoded, containing private key and certs - - // split in private key and certs - int privateKeyBeginIdx = cert.indexOf("-----BEGIN PRIVATE KEY"); - int privateKeyEndIdx = cert.indexOf("-----END PRIVATE KEY"); - String pemPrivateKey = cert.substring(privateKeyBeginIdx, privateKeyEndIdx + 26); - - StringBuilder pemCerts = new StringBuilder(); - int certsBeginIdx = 0; - - do { - certsBeginIdx = cert.indexOf("-----BEGIN CERTIFICATE", certsBeginIdx); - - if (certsBeginIdx >= 0) { - int certsEndIdx = cert.indexOf("-----END CERTIFICATE", certsBeginIdx) + 26; - pemCerts.append(cert.substring(certsBeginIdx, certsEndIdx)); - certsBeginIdx = certsEndIdx; - } - } while (certsBeginIdx != -1); - - // parse private key - KeySpec keySpec = Pems.privateKeySpec(InputSuppliers.of(pemPrivateKey)); - PrivateKey privateKey = crypto.rsaKeyFactory().generatePrivate(keySpec); - - // populate keystore with private key and certs - CertificateFactory cf = CertificateFactory.getInstance("X.509"); - @SuppressWarnings("unchecked") - Collection certs = (Collection) cf.generateCertificates(new ByteArrayInputStream( - pemCerts.toString().getBytes(Charsets.UTF_8))); - keyStore.load(null); - keyStore.setKeyEntry("dummy", privateKey, keyStorePassword.toCharArray(), - certs.toArray(new java.security.cert.Certificate[0])); - - } - return keyStore; - } catch (NoSuchAlgorithmException e) { - throw propagate(e); - } catch (KeyStoreException e) { - throw propagate(e); - } catch (CertificateException e) { - throw propagate(e); - } catch (FileNotFoundException e) { - throw propagate(e); - } catch (IOException e) { - throw propagate(e); - } catch (InvalidKeySpecException e) { - throw propagate(e); - } - } -} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/suppliers/SSLContextWithKeysSupplier.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/suppliers/SSLContextWithKeysSupplier.java deleted file mode 100644 index b50d978023..0000000000 --- a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/suppliers/SSLContextWithKeysSupplier.java +++ /dev/null @@ -1,85 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.suppliers; - -import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.base.Throwables.propagate; - -import java.security.KeyManagementException; -import java.security.KeyStore; -import java.security.KeyStoreException; -import java.security.NoSuchAlgorithmException; -import java.security.SecureRandom; -import java.security.UnrecoverableKeyException; - -import javax.inject.Inject; -import javax.inject.Singleton; -import javax.net.ssl.KeyManagerFactory; -import javax.net.ssl.SSLContext; -import javax.net.ssl.TrustManager; - -import org.jclouds.domain.Credentials; -import org.jclouds.http.HttpUtils; -import org.jclouds.http.config.SSLModule.TrustAllCerts; -import org.jclouds.location.Provider; - -import com.google.common.base.Supplier; - -/** - * TODO this code needs to be completely refactored. It needs to stop using KeyStore of at all possible and definitely - * the local filesystem. Please look at oauth for examples on how to do this via PEMs. - */ -@Deprecated -@Singleton -public class SSLContextWithKeysSupplier implements Supplier { - private final Supplier keyStore; - private final TrustManager[] trustManager; - private final Supplier creds; - - @Inject - SSLContextWithKeysSupplier(Supplier keyStore, @Provider Supplier creds, HttpUtils utils, - TrustAllCerts trustAllCerts) { - this.keyStore = keyStore; - this.trustManager = utils.trustAllCerts() ? new TrustManager[] { trustAllCerts } : null; - this.creds = creds; - } - - @Override - public SSLContext get() { - Credentials currentCreds = checkNotNull(creds.get(), "credential supplier returned null"); - String keyStorePassword = checkNotNull(currentCreds.credential, - "credential supplier returned null credential (should be keyStorePassword)"); - KeyManagerFactory kmf; - try { - kmf = KeyManagerFactory.getInstance("SunX509"); - kmf.init(keyStore.get(), keyStorePassword.toCharArray()); - SSLContext sc = SSLContext.getInstance("TLS"); - sc.init(kmf.getKeyManagers(), trustManager, new SecureRandom()); - return sc; - } catch (NoSuchAlgorithmException e) { - throw propagate(e); - } catch (UnrecoverableKeyException e) { - throw propagate(e); - } catch (KeyStoreException e) { - throw propagate(e); - } catch (KeyManagementException e) { - throw propagate(e); - } - } -} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/BindParamsToXmlPayload.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/BindParamsToXmlPayload.java deleted file mode 100644 index 153207338d..0000000000 --- a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/BindParamsToXmlPayload.java +++ /dev/null @@ -1,99 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.xml; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.net.URI; -import java.net.URISyntaxException; -import java.util.Map; - -import javax.ws.rs.core.MediaType; - -import org.jclouds.fujitsu.fgcp.reference.RequestParameters; -import org.jclouds.http.HttpRequest; -import org.jclouds.rest.MapBinder; -import org.jclouds.rest.binders.BindToStringPayload; - -import com.google.common.base.Strings; - -/** - * Not currently used but leaving for reference when implementing multipart POST - * methods. - * - * @author Dies Koper - */ -public class BindParamsToXmlPayload extends BindToStringPayload implements - MapBinder { - - @SuppressWarnings("unchecked") - @Override - public R bindToRequest(R request, - Map mapParams) { - String action = checkNotNull( - mapParams.remove(RequestParameters.ACTION), - RequestParameters.ACTION).toString(); - String version = Strings.nullToEmpty((String) mapParams - .remove(RequestParameters.VERSION)); - - StringBuilder xml = new StringBuilder(); - xml.append("\r\n"); - xml.append("\r\n"); - xml.append(" " + action + "\r\n"); - - for (Map.Entry entry : mapParams.entrySet()) { - String key = entry.getKey(); - xml.append(" <" + key + ">" + checkNotNull(mapParams.get(key)) - + "\r\n"); - } - - xml.append(" " + version + "\r\n"); - xml.append(" \r\n"); // value inserted in - // RequestAuthenticator#filter - xml.append(" \r\n"); // value inserted in - // RequestAuthenticator#filter - xml.append(" \r\n"); // value inserted in - // RequestAuthenticator#filter - xml.append(""); - - request = super.bindToRequest(request, xml); - request.getPayload().getContentMetadata() - .setContentType(MediaType.TEXT_XML); - - // remove version query param if set as it was moved to the xml body - URI uri = request.getEndpoint(); - URI uriWithoutQueryParams; - try { - uriWithoutQueryParams = new URI(uri.getScheme(), uri.getUserInfo(), - uri.getHost(), uri.getPort(), uri.getPath(), null, - uri.getFragment()); - } catch (URISyntaxException e) { - // should never happen as we're copying the components from a URI - uriWithoutQueryParams = uri; - } - - return (R) request.toBuilder().endpoint(uriWithoutQueryParams).build(); - } - - @Override - public R bindToRequest(R request, Object toBind) { - throw new IllegalArgumentException( - "BindParamsToXmlPayload needs bind parameters"); - } -} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/FGCPJAXBParser.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/FGCPJAXBParser.java deleted file mode 100644 index 7e8dfff2f7..0000000000 --- a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/FGCPJAXBParser.java +++ /dev/null @@ -1,88 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.xml; - -import java.io.IOException; -import java.io.StringReader; - -import javax.inject.Singleton; -import javax.xml.bind.JAXBContext; -import javax.xml.bind.JAXBException; -import javax.xml.bind.Unmarshaller; - -import org.jclouds.fujitsu.fgcp.domain.VServerWithDetails; -import org.jclouds.fujitsu.fgcp.xml.internal.ListServerTypeResponse; -import org.jclouds.fujitsu.fgcp.xml.internal.StatusQuerable; -import org.jclouds.http.HttpException; -import org.jclouds.xml.XMLParser; - -/** - * Parses XML documents using JAXB. - * - * @author Dies Koper - * @see org.jclouds.http.functions.ParseXMLWithJAXB - */ -@Singleton -public class FGCPJAXBParser implements XMLParser { - JAXBContext context; - - public FGCPJAXBParser() throws JAXBException { - context = JAXBContext.newInstance(VServerWithDetails.class.getPackage() - .getName() - + ":" - + ListServerTypeResponse.class.getPackage().getName(), - VServerWithDetails.class.getClassLoader()); - } - - @Override - public String toXML(final Object src) throws IOException { - return toXML(src, src.getClass()); - } - - @Override - public String toXML(final Object src, final Class type) - throws IOException { - throw new UnsupportedOperationException( - "only marshaling from XML is implemented"); - } - - @SuppressWarnings("unchecked") - @Override - public T fromXML(final String xml, final Class type) - throws IOException { - T response = null; - try { - StringReader reader = new StringReader(xml); - - Unmarshaller unmarshaller = context.createUnmarshaller(); - - response = (T) unmarshaller.unmarshal(reader); - } catch (Exception ex) { - throw new IOException("Could not unmarshal document", ex); - } - - if (((StatusQuerable) response).isError()) { - throw new HttpException( - ((StatusQuerable) response).getResponseMessage()); - } - - return response; - } - -} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/CreateEFMResponse.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/CreateEFMResponse.java deleted file mode 100644 index 8c3fdb9757..0000000000 --- a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/CreateEFMResponse.java +++ /dev/null @@ -1,44 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.xml.internal; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; - -/** - * Wrapper for CreateEFMResponse. - * - * @author Dies Koper - */ -@XmlRootElement(name = "CreateEFMResponse") -public class CreateEFMResponse extends StatusResponse implements - SingleElementResponse { - @XmlElement(required = true) - private String efmId; - - @Override - public String toString() { - return getElement(); - } - - @Override - public String getElement() { - return efmId; - } -} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/CreateVDiskResponse.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/CreateVDiskResponse.java deleted file mode 100644 index 6bf1a1f555..0000000000 --- a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/CreateVDiskResponse.java +++ /dev/null @@ -1,44 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.xml.internal; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; - -/** - * Wrapper for CreateVDiskResponse. - * - * @author Dies Koper - */ -@XmlRootElement(name = "CreateVDiskResponse") -public class CreateVDiskResponse extends StatusResponse implements - SingleElementResponse { - @XmlElement(required = true) - private String vdiskId; - - @Override - public String toString() { - return getElement(); - } - - @Override - public String getElement() { - return vdiskId; - } -} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/CreateVSYSResponse.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/CreateVSYSResponse.java deleted file mode 100644 index 61dd417633..0000000000 --- a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/CreateVSYSResponse.java +++ /dev/null @@ -1,44 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.xml.internal; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; - -/** - * Wrapper for CreateVSYSResponse. - * - * @author Dies Koper - */ -@XmlRootElement(name = "CreateVSYSResponse") -public class CreateVSYSResponse extends StatusResponse implements - SingleElementResponse { - @XmlElement(required = true) - private String vsysId; - - @Override - public String toString() { - return getElement(); - } - - @Override - public String getElement() { - return vsysId; - } -} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/CreateVServerResponse.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/CreateVServerResponse.java deleted file mode 100644 index 7d7ddcd88b..0000000000 --- a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/CreateVServerResponse.java +++ /dev/null @@ -1,44 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.xml.internal; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; - -/** - * Wrapper for CreateVServerResponse. - * - * @author Dies Koper - */ -@XmlRootElement(name = "CreateVServerResponse") -public class CreateVServerResponse extends StatusResponse implements - SingleElementResponse { - @XmlElement(required = true) - private String vserverId; - - @Override - public String toString() { - return getElement(); - } - - @Override - public String getElement() { - return vserverId; - } -} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/GetAddressRangeResponse.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/GetAddressRangeResponse.java deleted file mode 100644 index 4191e58737..0000000000 --- a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/GetAddressRangeResponse.java +++ /dev/null @@ -1,50 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.xml.internal; - -import java.util.Collections; -import java.util.Set; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlElementWrapper; -import javax.xml.bind.annotation.XmlRootElement; - -import org.jclouds.fujitsu.fgcp.domain.AddressRange; - -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Sets; - -/** - * Wrapper for GetAddressRangeResponse. - * - * @author Dies Koper - */ -@XmlRootElement(name = "GetAddressRangeResponse") -public class GetAddressRangeResponse extends - SetWithStatusResponse { - @XmlElementWrapper(name = "addressranges") - @XmlElement(name = "addressrange") - private Set ranges = Sets.newLinkedHashSet(); - - @Override - protected Set delegate() { - return ranges == null ? ImmutableSet. of() : Collections - .unmodifiableSet(ranges); - } -} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/GetDiskImageAttributesResponse.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/GetDiskImageAttributesResponse.java deleted file mode 100644 index 15a14ae213..0000000000 --- a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/GetDiskImageAttributesResponse.java +++ /dev/null @@ -1,46 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.xml.internal; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; - -import org.jclouds.fujitsu.fgcp.domain.DiskImage; - -/** - * Wrapper for GetDiskImageAttributesResponse. - * - * @author Dies Koper - */ -@XmlRootElement(name = "GetDiskImageAttributesResponse") -public class GetDiskImageAttributesResponse extends StatusResponse implements - SingleElementResponse { - @XmlElement(name = "diskimage") - private DiskImage diskImage; - - @Override - public String toString() { - return getElement().toString(); - } - - @Override - public DiskImage getElement() { - return diskImage; - } -} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/GetEFMAttributesResponse.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/GetEFMAttributesResponse.java deleted file mode 100644 index 939d63e4a0..0000000000 --- a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/GetEFMAttributesResponse.java +++ /dev/null @@ -1,46 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.xml.internal; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; - -import org.jclouds.fujitsu.fgcp.domain.BuiltinServer; - -/** - * Wrapper for GetEFMAttributesResponse. - * - * @author Dies Koper - */ -@XmlRootElement(name = "GetEFMAttributesResponse") -public class GetEFMAttributesResponse extends StatusResponse implements - SingleElementResponse { - @XmlElement(required = true) - private BuiltinServer efm; - - @Override - public String toString() { - return getElement().toString(); - } - - @Override - public Object getElement() { - return efm; - } -} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/GetEFMStatusResponse.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/GetEFMStatusResponse.java deleted file mode 100644 index a243c80459..0000000000 --- a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/GetEFMStatusResponse.java +++ /dev/null @@ -1,46 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.xml.internal; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; - -import org.jclouds.fujitsu.fgcp.domain.BuiltinServerStatus; - -/** - * Wrapper for GetEFMStatusResponse. - * - * @author Dies Koper - */ -@XmlRootElement(name = "GetEFMStatusResponse") -public class GetEFMStatusResponse extends StatusResponse implements - SingleElementResponse { - @XmlElement(required = true) - private BuiltinServerStatus efmStatus; - - @Override - public String toString() { - return getElement().toString(); - } - - @Override - public Object getElement() { - return efmStatus; - } -} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/GetEventLogResponse.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/GetEventLogResponse.java deleted file mode 100644 index 6680b2da43..0000000000 --- a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/GetEventLogResponse.java +++ /dev/null @@ -1,49 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.xml.internal; - -import java.util.Collections; -import java.util.Set; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlElementWrapper; -import javax.xml.bind.annotation.XmlRootElement; - -import org.jclouds.fujitsu.fgcp.domain.EventLog; - -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Sets; - -/** - * Wrapper for GetEventLogResponse. - * - * @author Dies Koper - */ -@XmlRootElement(name = "GetEventLogResponse") -public class GetEventLogResponse extends SetWithStatusResponse { - @XmlElementWrapper(name = "eventlogs") - @XmlElement(name = "eventlog") - private Set logs = Sets.newLinkedHashSet(); - - @Override - protected Set delegate() { - return logs == null ? ImmutableSet. of() : Collections - .unmodifiableSet(logs); - } -} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/GetPerformanceInformationResponse.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/GetPerformanceInformationResponse.java deleted file mode 100644 index a9afceed33..0000000000 --- a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/GetPerformanceInformationResponse.java +++ /dev/null @@ -1,50 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.xml.internal; - -import java.util.Collections; -import java.util.Set; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlElementWrapper; -import javax.xml.bind.annotation.XmlRootElement; - -import org.jclouds.fujitsu.fgcp.domain.PerformanceInfo; - -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Sets; - -/** - * Wrapper for GetPerformanceInformationResponse. - * - * @author Dies Koper - */ -@XmlRootElement(name = "GetPerformanceInformationResponse") -public class GetPerformanceInformationResponse extends - SetWithStatusResponse { - @XmlElementWrapper(name = "performanceinfos") - @XmlElement(name = "performanceinfo") - private Set stats = Sets.newLinkedHashSet(); - - @Override - protected Set delegate() { - return stats == null ? ImmutableSet. of() - : Collections.unmodifiableSet(stats); - } -} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/GetPublicIPAttributesResponse.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/GetPublicIPAttributesResponse.java deleted file mode 100644 index cb4f958b62..0000000000 --- a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/GetPublicIPAttributesResponse.java +++ /dev/null @@ -1,52 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.xml.internal; - -import java.util.Set; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlElementWrapper; -import javax.xml.bind.annotation.XmlRootElement; - -import org.jclouds.fujitsu.fgcp.domain.PublicIP; - -import com.google.common.collect.Iterables; - -/** - * Wrapper for GetPublicIPAttributesResponse. - * - * @author Dies Koper - */ -@XmlRootElement(name = "GetPublicIPAttributesResponse") -public class GetPublicIPAttributesResponse extends StatusResponse implements - SingleElementResponse { - @XmlElementWrapper(name = "publicips") - @XmlElement(name = "publicip") - private Set publicIPs; - - @Override - public String toString() { - return getElement().toString(); - } - - @Override - public Object getElement() { - return Iterables.getOnlyElement(publicIPs); - } -} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/GetPublicIPStatusResponse.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/GetPublicIPStatusResponse.java deleted file mode 100644 index 69b4fc26db..0000000000 --- a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/GetPublicIPStatusResponse.java +++ /dev/null @@ -1,46 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.xml.internal; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; - -import org.jclouds.fujitsu.fgcp.domain.PublicIPStatus; - -/** - * Wrapper for GetPublicIPStatusResponse. - * - * @author Dies Koper - */ -@XmlRootElement(name = "GetPublicIPStatusResponse") -public class GetPublicIPStatusResponse extends StatusResponse implements - SingleElementResponse { - @XmlElement(required = true) - private PublicIPStatus publicipStatus; - - @Override - public String toString() { - return publicipStatus.toString(); - } - - @Override - public Object getElement() { - return publicipStatus; - } -} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/GetVDiskAttributesResponse.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/GetVDiskAttributesResponse.java deleted file mode 100644 index cc486d1213..0000000000 --- a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/GetVDiskAttributesResponse.java +++ /dev/null @@ -1,46 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.xml.internal; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; - -import org.jclouds.fujitsu.fgcp.domain.VDisk; - -/** - * Wrapper for GetVDiskAttributesResponse. - * - * @author Dies Koper - */ -@XmlRootElement(name = "GetVDiskAttributesResponse") -public class GetVDiskAttributesResponse extends StatusResponse implements - SingleElementResponse { - @XmlElement(required = true) - private VDisk vdisk; - - @Override - public String toString() { - return getElement().toString(); - } - - @Override - public Object getElement() { - return vdisk; - } -} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/GetVSYSAttributesResponse.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/GetVSYSAttributesResponse.java deleted file mode 100644 index 49d44d9e66..0000000000 --- a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/GetVSYSAttributesResponse.java +++ /dev/null @@ -1,46 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.xml.internal; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; - -import org.jclouds.fujitsu.fgcp.domain.VSystem; - -/** - * Wrapper for GetVSYSAttributesResponse. - * - * @author Dies Koper - */ -@XmlRootElement(name = "GetVSYSAttributesResponse") -public class GetVSYSAttributesResponse extends StatusResponse implements - SingleElementResponse { - @XmlElement(name = "vsys") - private VSystem system; - - @Override - public String toString() { - return getElement().toString(); - } - - @Override - public Object getElement() { - return system; - } -} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/GetVSYSConfigurationResponse.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/GetVSYSConfigurationResponse.java deleted file mode 100644 index ddf45c1c70..0000000000 --- a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/GetVSYSConfigurationResponse.java +++ /dev/null @@ -1,46 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.xml.internal; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; - -import org.jclouds.fujitsu.fgcp.domain.VSystemWithDetails; - -/** - * Wrapper for GetVSYSConfigurationResponse. - * - * @author Dies Koper - */ -@XmlRootElement(name = "GetVSYSConfigurationResponse") -public class GetVSYSConfigurationResponse extends StatusResponse implements - SingleElementResponse { - @XmlElement(name = "vsys") - private VSystemWithDetails system; - - @Override - public String toString() { - return getElement().toString(); - } - - @Override - public Object getElement() { - return system; - } -} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/GetVSYSDescriptorConfigurationResponse.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/GetVSYSDescriptorConfigurationResponse.java deleted file mode 100644 index c38ba553cc..0000000000 --- a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/GetVSYSDescriptorConfigurationResponse.java +++ /dev/null @@ -1,46 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.xml.internal; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; - -import org.jclouds.fujitsu.fgcp.domain.VSystemDescriptor; - -/** - * Wrapper for GetVSYSDescriptorConfigurationResponse. - * - * @author Dies Koper - */ -@XmlRootElement(name = "GetVSYSDescriptorConfigurationResponse") -public class GetVSYSDescriptorConfigurationResponse extends StatusResponse - implements SingleElementResponse { - @XmlElement - private VSystemDescriptor vsysdescriptor; - - @Override - public String toString() { - return getElement().toString(); - } - - @Override - public Object getElement() { - return vsysdescriptor; - } -} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/GetVSYSStatusResponse.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/GetVSYSStatusResponse.java deleted file mode 100644 index 074ea0bab6..0000000000 --- a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/GetVSYSStatusResponse.java +++ /dev/null @@ -1,46 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.xml.internal; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; - -import org.jclouds.fujitsu.fgcp.domain.VSystemStatus; - -/** - * Wrapper for GetVSYSStatusResponse. - * - * @author Dies Koper - */ -@XmlRootElement(name = "GetVSYSStatusResponse") -public class GetVSYSStatusResponse extends StatusResponse implements - SingleElementResponse { - @XmlElement(required = true) - private VSystemStatus vsysStatus; - - @Override - public String toString() { - return getElement().toString(); - } - - @Override - public Object getElement() { - return vsysStatus; - } -} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/GetVServerAttributesResponse.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/GetVServerAttributesResponse.java deleted file mode 100644 index 5f9637c98b..0000000000 --- a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/GetVServerAttributesResponse.java +++ /dev/null @@ -1,46 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.xml.internal; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; - -import org.jclouds.fujitsu.fgcp.domain.VServer; - -/** - * Wrapper for GetVServerAttributesResponse. - * - * @author Dies Koper - */ -@XmlRootElement(name = "GetVServerAttributesResponse") -public class GetVServerAttributesResponse extends StatusResponse implements - SingleElementResponse { - @XmlElement(required = true) - private VServer vserver; - - @Override - public String toString() { - return vserver.toString(); - } - - @Override - public Object getElement() { - return vserver; - } -} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/GetVServerConfigurationResponse.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/GetVServerConfigurationResponse.java deleted file mode 100644 index cebe6ceda1..0000000000 --- a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/GetVServerConfigurationResponse.java +++ /dev/null @@ -1,46 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.xml.internal; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; - -import org.jclouds.fujitsu.fgcp.domain.VServerWithDetails; - -/** - * Wrapper for GetVServerConfigurationResponse. - * - * @author Dies Koper - */ -@XmlRootElement(name = "GetVServerConfigurationResponse") -public class GetVServerConfigurationResponse extends StatusResponse implements - SingleElementResponse { - @XmlElement(required = true) - private VServerWithDetails vserver; - - @Override - public String toString() { - return vserver.toString(); - } - - @Override - public Object getElement() { - return vserver; - } -} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/GetVServerInitialPasswordResponse.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/GetVServerInitialPasswordResponse.java deleted file mode 100644 index 39f6ee3797..0000000000 --- a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/GetVServerInitialPasswordResponse.java +++ /dev/null @@ -1,39 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.xml.internal; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; - -/** - * Wrapper for GetVServerInitialPasswordResponse. - * - * @author Dies Koper - */ -@XmlRootElement(name = "GetVServerInitialPasswordResponse") -public class GetVServerInitialPasswordResponse extends StatusResponse implements - SingleElementResponse { - @XmlElement(required = true) - private String initialPassword; - - @Override - public Object getElement() { - return initialPassword; - } -} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/GetVServerStatusResponse.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/GetVServerStatusResponse.java deleted file mode 100644 index 657c5b6e8f..0000000000 --- a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/GetVServerStatusResponse.java +++ /dev/null @@ -1,46 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.xml.internal; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; - -import org.jclouds.fujitsu.fgcp.domain.VServerStatus; - -/** - * Wrapper for GetVServerStatusResponse. - * - * @author Dies Koper - */ -@XmlRootElement(name = "GetVServerStatusResponse") -public class GetVServerStatusResponse extends StatusResponse implements - SingleElementResponse { - @XmlElement(required = true) - private VServerStatus vserverStatus; - - @Override - public String toString() { - return getElement().toString(); - } - - @Override - public Object getElement() { - return vserverStatus; - } -} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/ListDiskImageResponse.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/ListDiskImageResponse.java deleted file mode 100644 index 455f29ba62..0000000000 --- a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/ListDiskImageResponse.java +++ /dev/null @@ -1,49 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.xml.internal; - -import java.util.Collections; -import java.util.Set; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlElementWrapper; -import javax.xml.bind.annotation.XmlRootElement; - -import org.jclouds.fujitsu.fgcp.domain.DiskImage; - -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Sets; - -/** - * Wrapper for ListDiskImageResponse. - * - * @author Dies Koper - */ -@XmlRootElement(name = "ListDiskImageResponse") -public class ListDiskImageResponse extends SetWithStatusResponse { - @XmlElementWrapper(name = "diskimages") - @XmlElement(name = "diskimage") - private Set diskImages = Sets.newLinkedHashSet(); - - @Override - protected Set delegate() { - return diskImages == null ? ImmutableSet. of() : Collections - .unmodifiableSet(diskImages); - } -} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/ListEFMBackupResponse.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/ListEFMBackupResponse.java deleted file mode 100644 index 5f9b18b0bb..0000000000 --- a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/ListEFMBackupResponse.java +++ /dev/null @@ -1,50 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.xml.internal; - -import java.util.Collections; -import java.util.Set; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlElementWrapper; -import javax.xml.bind.annotation.XmlRootElement; - -import org.jclouds.fujitsu.fgcp.domain.BuiltinServerBackup; - -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Sets; - -/** - * Wrapper for ListEFMBackupResponse. - * - * @author Dies Koper - */ -@XmlRootElement(name = "ListEFMBackupResponse") -public class ListEFMBackupResponse extends - SetWithStatusResponse { - @XmlElementWrapper(name = "backups") - @XmlElement(name = "backup") - private Set backup = Sets.newLinkedHashSet(); - - @Override - protected Set delegate() { - return backup == null ? ImmutableSet. of() - : Collections.unmodifiableSet(backup); - } -} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/ListEFMResponse.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/ListEFMResponse.java deleted file mode 100644 index ecc97c6622..0000000000 --- a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/ListEFMResponse.java +++ /dev/null @@ -1,49 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.xml.internal; - -import java.util.Collections; -import java.util.Set; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlElementWrapper; -import javax.xml.bind.annotation.XmlRootElement; - -import org.jclouds.fujitsu.fgcp.domain.BuiltinServer; - -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Sets; - -/** - * Wrapper for ListEFMResponse. - * - * @author Dies Koper - */ -@XmlRootElement(name = "ListEFMResponse") -public class ListEFMResponse extends SetWithStatusResponse { - @XmlElementWrapper(name = "efms") - @XmlElement(name = "efm") - private Set efm = Sets.newLinkedHashSet(); - - @Override - protected Set delegate() { - return efm == null ? ImmutableSet. of() : Collections - .unmodifiableSet(efm); - } -} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/ListPublicIPResponse.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/ListPublicIPResponse.java deleted file mode 100644 index 6ddfa79126..0000000000 --- a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/ListPublicIPResponse.java +++ /dev/null @@ -1,70 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.xml.internal; - -import java.util.Collections; -import java.util.Map; -import java.util.Set; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlElementWrapper; -import javax.xml.bind.annotation.XmlRootElement; - -import org.jclouds.fujitsu.fgcp.domain.PublicIP; - -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableMap.Builder; -import com.google.common.collect.ImmutableSet; - -/** - * Wrapper for ListPublicIPResponse. - * - * @author Dies Koper - */ -@XmlRootElement(name = "ListPublicIPResponse") -public class ListPublicIPResponse extends - MapWithStatusResponse implements - SingleElementResponse { - @XmlElementWrapper(name = "publicips") - @XmlElement(name = "publicip") - private Set ips; - - @Override - public String toString() { - return getElement().toString(); - } - - @Override - protected Map delegate() { - Builder returnVal = ImmutableMap.builder(); - if (ips != null) { - - for (PublicIPWithSystemId ip : ips) { - returnVal.put(ip, ip.getVsysId()); - } - } - return returnVal.build(); - } - - @Override - public Set getElement() { - return ips == null ? ImmutableSet. of() : Collections - .unmodifiableSet(ips); - } -} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/ListServerTypeResponse.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/ListServerTypeResponse.java deleted file mode 100644 index c10b0c8120..0000000000 --- a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/ListServerTypeResponse.java +++ /dev/null @@ -1,48 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.xml.internal; - -import java.util.Collections; -import java.util.Set; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlElementWrapper; -import javax.xml.bind.annotation.XmlRootElement; - -import org.jclouds.fujitsu.fgcp.domain.ServerType; - -import com.google.common.collect.ImmutableSet; - -/** - * Wrapper for ListServerTypeResponse. - * - * @author Dies Koper - */ -@XmlRootElement(name = "ListServerTypeResponse") -public class ListServerTypeResponse extends SetWithStatusResponse { - @XmlElementWrapper(name = "servertypes") - @XmlElement(name = "servertype") - private Set serverTypes; - - @Override - protected Set delegate() { - return serverTypes == null ? ImmutableSet. of() - : Collections.unmodifiableSet(serverTypes); - } -} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/ListVDiskResponse.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/ListVDiskResponse.java deleted file mode 100644 index 1e96a46484..0000000000 --- a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/ListVDiskResponse.java +++ /dev/null @@ -1,49 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.xml.internal; - -import java.util.Collections; -import java.util.Set; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlElementWrapper; -import javax.xml.bind.annotation.XmlRootElement; - -import org.jclouds.fujitsu.fgcp.domain.VDisk; - -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Sets; - -/** - * Wrapper for ListVDiskResponse. - * - * @author Dies Koper - */ -@XmlRootElement(name = "ListVDiskResponse") -public class ListVDiskResponse extends SetWithStatusResponse { - @XmlElementWrapper(name = "vdisks") - @XmlElement(name = "vdisk") - private Set disks = Sets.newLinkedHashSet(); - - @Override - protected Set delegate() { - return disks == null ? ImmutableSet. of() : Collections - .unmodifiableSet(disks); - } -} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/ListVSYSResponse.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/ListVSYSResponse.java deleted file mode 100644 index a3457c9eda..0000000000 --- a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/ListVSYSResponse.java +++ /dev/null @@ -1,49 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.xml.internal; - -import java.util.Collections; -import java.util.Set; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlElementWrapper; -import javax.xml.bind.annotation.XmlRootElement; - -import org.jclouds.fujitsu.fgcp.domain.VSystem; - -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Sets; - -/** - * Wrapper for ListVSYSResponse. - * - * @author Dies Koper - */ -@XmlRootElement(name = "ListVSYSResponse") -public class ListVSYSResponse extends SetWithStatusResponse { - @XmlElementWrapper(name = "vsyss") - @XmlElement(name = "vsys") - private Set systems = Sets.newLinkedHashSet(); - - @Override - protected Set delegate() { - return systems == null ? ImmutableSet. of() : Collections - .unmodifiableSet(systems); - } -} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/ListVServerResponse.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/ListVServerResponse.java deleted file mode 100644 index 9aaaec7f7e..0000000000 --- a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/ListVServerResponse.java +++ /dev/null @@ -1,49 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.xml.internal; - -import java.util.Collections; -import java.util.Set; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlElementWrapper; -import javax.xml.bind.annotation.XmlRootElement; - -import org.jclouds.fujitsu.fgcp.domain.VServer; - -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Sets; - -/** - * Wrapper for ListVServerResponse. - * - * @author Dies Koper - */ -@XmlRootElement(name = "ListVServerResponse") -public class ListVServerResponse extends SetWithStatusResponse { - @XmlElementWrapper(name = "vservers") - @XmlElement(name = "vserver") - private Set servers = Sets.newLinkedHashSet(); - - @Override - protected Set delegate() { - return servers == null ? ImmutableSet. of() : Collections - .unmodifiableSet(servers); - } -} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/MapWithStatusResponse.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/MapWithStatusResponse.java deleted file mode 100644 index e0f841ae87..0000000000 --- a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/MapWithStatusResponse.java +++ /dev/null @@ -1,58 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.xml.internal; - -import javax.xml.bind.annotation.XmlElement; - -import com.google.common.collect.ForwardingMap; - -/** - * Special base class extending (forwardable) Map with fields for the elements - * that FGCP XML responses specify. - *

- * This is useful for methods that return a set of elements that are better - * represented as key value pairs. - * - * @author Dies Koper - */ -public abstract class MapWithStatusResponse extends ForwardingMap - implements StatusQuerable { - @XmlElement(required = true) - private String responseMessage; - @XmlElement(required = true) - private String responseStatus; - - public String getResponseMessage() { - return responseMessage; - } - - public String getResponseStatus() { - return responseStatus; - } - - public boolean isError() { - return !"SUCCESS".equals(responseStatus); - } - - @Override - public String toString() { - return "StatusResponse{" + "responseMessage='" + responseMessage + '\'' - + ", responseStatus='" + responseStatus + '\'' + '}'; - } -} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/PublicIPWithSystemId.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/PublicIPWithSystemId.java deleted file mode 100644 index 6995541d50..0000000000 --- a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/PublicIPWithSystemId.java +++ /dev/null @@ -1,43 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.xml.internal; - -import javax.xml.bind.annotation.XmlRootElement; - -import org.jclouds.fujitsu.fgcp.domain.PublicIP; - -/** - * Represents a public IP address with its system id. - * - * @author Dies Koper - */ -@XmlRootElement(name = "publicip") -public class PublicIPWithSystemId extends PublicIP { - private String vsysId; - - public String getVsysId() { - return vsysId; - } - - @Override - public String toString() { - return "PublicIP{" + "address='" + address + '\'' + ", IP version='" - + version + '\'' + ", vsysId='" + vsysId + '\'' + '}'; - } -} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/SetWithStatusResponse.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/SetWithStatusResponse.java deleted file mode 100644 index 6ee4e7c8f0..0000000000 --- a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/SetWithStatusResponse.java +++ /dev/null @@ -1,58 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.xml.internal; - -import javax.xml.bind.annotation.XmlElement; - -import com.google.common.collect.ForwardingSet; - -/** - * Special base class extending (forwardable) Set with fields for the elements - * that FGCP XML responses specify. - *

- * This is useful for methods that return a Set and the XML response has no - * other elements but the set of elements (and message and status of course). - * - * @author Dies Koper - */ -public abstract class SetWithStatusResponse extends ForwardingSet - implements StatusQuerable { - @XmlElement(required = true) - private String responseMessage; - @XmlElement(required = true) - private String responseStatus; - - public String getResponseMessage() { - return responseMessage; - } - - public String getResponseStatus() { - return responseStatus; - } - - public boolean isError() { - return !"SUCCESS".equals(responseStatus); - } - - @Override - public String toString() { - return delegate().toString(); - } - -} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/SingleElementResponse.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/SingleElementResponse.java deleted file mode 100644 index 4ced6da144..0000000000 --- a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/SingleElementResponse.java +++ /dev/null @@ -1,29 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.xml.internal; - -/** - * Wrapper for CreateVSYSResponse. - * - * @author Dies Koper - */ -public interface SingleElementResponse { - - Object getElement(); -} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/StatusQuerable.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/StatusQuerable.java deleted file mode 100644 index 5a83701844..0000000000 --- a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/StatusQuerable.java +++ /dev/null @@ -1,32 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.xml.internal; - -/** - * Exposes methods to obtain the status and message from the API server. - * - * @author Dies Koper - */ -public interface StatusQuerable { - public String getResponseMessage(); - - public String getResponseStatus(); - - public boolean isError(); -} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/StatusResponse.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/StatusResponse.java deleted file mode 100644 index d9d7f06126..0000000000 --- a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/StatusResponse.java +++ /dev/null @@ -1,59 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.xml.internal; - -import javax.xml.bind.annotation.XmlElement; - -/** - * Base class with fields for the elements that FGCP XML responses specify. - * - * @author Dies Koper - */ -public abstract class StatusResponse implements StatusQuerable { - @XmlElement(required = true) - private String responseMessage; - @XmlElement(required = true) - private String responseStatus; - - public String getResponseMessage() { - return responseMessage; - } - - public void setResponseMessage(String responseMessage) { - this.responseMessage = responseMessage; - } - - public String getResponseStatus() { - return responseStatus; - } - - public void setResponseStatus(String responseStatus) { - this.responseStatus = responseStatus; - } - - public boolean isError() { - return !"SUCCESS".equals(responseStatus); - } - - @Override - public String toString() { - return "StatusResponse{" + "responseMessage='" + responseMessage + '\'' - + ", responseStatus='" + responseStatus + '\'' + '}'; - } -} diff --git a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/package-info.java b/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/package-info.java deleted file mode 100644 index 1347685ce9..0000000000 --- a/labs/fgcp/src/main/java/org/jclouds/fujitsu/fgcp/xml/internal/package-info.java +++ /dev/null @@ -1,28 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -@XmlSchema(namespace = "http://apioviss.jp.fujitsu.com", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED) -//@XmlJavaTypeAdapter(value=SetOfServerTypesXMLAdapter.class,type= Set.class) -//@XmlJavaTypeAdapter(value=SetOfServerTypesXMLAdapter.class,type= ListServerTypeResponse.class) -@XmlAccessorType(XmlAccessType.FIELD) -package org.jclouds.fujitsu.fgcp.xml.internal; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlSchema; - diff --git a/labs/fgcp/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata b/labs/fgcp/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata deleted file mode 100644 index f2a75c058f..0000000000 --- a/labs/fgcp/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata +++ /dev/null @@ -1 +0,0 @@ -org.jclouds.fujitsu.fgcp.FGCPApiMetadata \ No newline at end of file diff --git a/labs/fgcp/src/main/resources/org/jclouds/fujitsu/fgcp/domain/jaxb.index b/labs/fgcp/src/main/resources/org/jclouds/fujitsu/fgcp/domain/jaxb.index deleted file mode 100644 index 4917877347..0000000000 --- a/labs/fgcp/src/main/resources/org/jclouds/fujitsu/fgcp/domain/jaxb.index +++ /dev/null @@ -1,45 +0,0 @@ -#listing of all classes in the domain package (at this time of writing) -#as some or all are likely to contain JAXB annotations -#note that even if (newer) classes are missing, as long as they are statically referenced from -#any of these classes they'll be included in the JAXB context. -AddressRange -BuiltinServer -BuiltinServerStatus -Cause -CPU -Direction -Disk -DiskImage -ErrorStatistics -EventLog -Firewall -Group -Image -Information -IntermediateCACert -LoadStatistics -Memory -NAT -PerformanceInfo -Period -Policy -Product -PublicIPStatus -Rule -ServerCert -ServerType -SLB -Software -Target -UsageInfo -VDisk -VDiskStatus -VNet -VNIC -VServer -VServerStatus -VServerWithDetails -VSystem -VSystemDescriptor -VSystemStatus -VSystemWithDetails \ No newline at end of file diff --git a/labs/fgcp/src/main/resources/org/jclouds/fujitsu/fgcp/xml/internal/jaxb.index b/labs/fgcp/src/main/resources/org/jclouds/fujitsu/fgcp/xml/internal/jaxb.index deleted file mode 100644 index 3e4a1e887c..0000000000 --- a/labs/fgcp/src/main/resources/org/jclouds/fujitsu/fgcp/xml/internal/jaxb.index +++ /dev/null @@ -1,30 +0,0 @@ -#listing of all classes in the xml.internal package (at this time of writing) -CreateVDiskResponse -CreateEFMResponse -CreateVServerResponse -CreateVSYSResponse -GetAddressRangeResponse -GetDiskImageAttributesResponse -GetEFMAttributesResponse -GetEFMStatusResponse -GetEventLogResponse -GetPublicIPAttributesResponse -GetPublicIPStatusResponse -GetVDiskAttributesResponse -GetVServerAttributesResponse -GetVServerConfigurationResponse -GetVServerInitialPasswordResponse -GetVServerStatusResponse -GetVSYSAttributesResponse -GetVSYSConfigurationResponse -GetVSYSDescriptorConfigurationResponse -GetVSYSStatusResponse -ListDiskImageResponse -ListEFMBackupResponse -ListEFMResponse -ListPublicIPResponse -ListServerTypeResponse -ListVDiskResponse -ListVServerResponse -ListVSYSResponse -PublicIPWithSystemId diff --git a/labs/fgcp/src/test/java/org/jclouds/fujitsu/fgcp/compute/FGCPBaseTemplateBuilderLiveTest.java b/labs/fgcp/src/test/java/org/jclouds/fujitsu/fgcp/compute/FGCPBaseTemplateBuilderLiveTest.java deleted file mode 100644 index d3f7987641..0000000000 --- a/labs/fgcp/src/test/java/org/jclouds/fujitsu/fgcp/compute/FGCPBaseTemplateBuilderLiveTest.java +++ /dev/null @@ -1,75 +0,0 @@ -package org.jclouds.fujitsu.fgcp.compute; - -import static org.jclouds.compute.util.ComputeServiceUtils.getCores; -import static org.testng.Assert.assertEquals; - -import java.io.IOException; -import java.util.Properties; - -import org.jclouds.Constants; -import org.jclouds.compute.domain.OsFamily; -import org.jclouds.compute.domain.OsFamilyVersion64Bit; -import org.jclouds.compute.domain.Template; -import org.jclouds.compute.internal.BaseTemplateBuilderLiveTest; - -import com.google.common.base.Predicate; -import com.google.common.base.Predicates; - -public abstract class FGCPBaseTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest { - - @Override - protected Properties setupProperties() { - Properties overrides = super.setupProperties(); - - String proxy = System.getenv("http_proxy"); - if (proxy != null) { - - String[] parts = proxy.split("http://|:|@"); - - overrides.setProperty(Constants.PROPERTY_PROXY_HOST, parts[parts.length - 2]); - overrides.setProperty(Constants.PROPERTY_PROXY_PORT, parts[parts.length - 1]); - - if (parts.length >= 4) { - overrides.setProperty(Constants.PROPERTY_PROXY_USER, parts[parts.length - 4]); - overrides.setProperty(Constants.PROPERTY_PROXY_PASSWORD, parts[parts.length - 3]); - } - } - - // enables peer verification using the CAs bundled with the JRE (or - // value of javax.net.ssl.trustStore if set) - overrides.setProperty(Constants.PROPERTY_TRUST_ALL_CERTS, "false"); - - return overrides; - } - - @Override - protected Predicate defineUnsupportedOperatingSystems() { - return Predicates.not(new Predicate() { - - @Override - public boolean apply(OsFamilyVersion64Bit input) { - switch (input.family) { - case CENTOS: - return ("".equals(input.version) && input.is64Bit) || (input.version.matches("5.[46]") && input.is64Bit) - || input.version.equals("6.[2]"); - case WINDOWS: - return ("".equals(input.version) && input.is64Bit) - || (input.version.equals("2008 R2 SE") || input.version.equals("2008 R2 EE")) && input.is64Bit; - default: - return false; - } - } - - }); - } - - public void testDefaultTemplateBuilder() throws IOException { - Template defaultTemplate = view.getComputeService().templateBuilder().build(); - assert defaultTemplate.getImage().getOperatingSystem().getVersion().matches("6.2") : defaultTemplate.getImage() - .getOperatingSystem().getVersion(); - assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true); - assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.CENTOS); - assertEquals(getCores(defaultTemplate.getHardware()), 1.0d); - } - -} diff --git a/labs/fgcp/src/test/java/org/jclouds/fujitsu/fgcp/compute/FGCPRestClientModuleTest.java b/labs/fgcp/src/test/java/org/jclouds/fujitsu/fgcp/compute/FGCPRestClientModuleTest.java deleted file mode 100644 index 78db6e5c4c..0000000000 --- a/labs/fgcp/src/test/java/org/jclouds/fujitsu/fgcp/compute/FGCPRestClientModuleTest.java +++ /dev/null @@ -1,95 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.compute; - -import static org.testng.Assert.assertNotNull; - -import java.io.IOException; -import java.net.URL; -import java.security.KeyStore; -import java.security.KeyStoreException; -import java.security.NoSuchAlgorithmException; -import java.security.cert.CertificateException; -import java.security.spec.InvalidKeySpecException; - -import org.jclouds.crypto.Crypto; -import org.jclouds.domain.Credentials; -import org.jclouds.fujitsu.fgcp.suppliers.KeyStoreSupplier; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.Test; - -import com.google.common.base.Suppliers; -import com.google.inject.Guice; -import com.google.inject.Injector; - -/** - * @author Dies Koper - */ -@Test(groups = "unit", testName = "FGCPRestClientModuleTest") -public class FGCPRestClientModuleTest { - - protected FGCPRestClientModule module; - protected Crypto crypto; - - @BeforeTest - protected void createCrypto() { - Injector i = Guice.createInjector(); - crypto = i.getInstance(Crypto.class); - } - - @BeforeTest - protected void createRestClientModule() { - Injector i = Guice.createInjector(); - module = i.getInstance(FGCPRestClientModule.class); - } - - public void testKeyStoreAsPkcs12() throws IOException, InvalidKeySpecException, NoSuchAlgorithmException, - KeyStoreException, CertificateException { - assertNotNull(crypto); - assertNotNull(module); - - // self-signed dummy cert: - // keytool -genkey -alias test-fgcp -keyalg RSA -keysize 1024 -validity 5475 -dname "CN=localhost" -keystore - // jclouds-test-fgcp.p12 -storepass jcloudsjclouds -storetype pkcs12 - String cert = "/certs/jclouds-test-fgcp.p12"; - URL url = this.getClass().getResource(cert); - String certPath = url.getFile(); - - KeyStore ks = new KeyStoreSupplier(crypto, Suppliers.ofInstance(new Credentials(certPath, "jcloudsjclouds"))) - .get(); - - assertNotNull(ks.getCertificate("test-fgcp"), "cert with alias"); - } - - /* - * public void testKeyStoreAsPEM() throws IOException, InvalidKeySpecException, NoSuchAlgorithmException, - * KeyStoreException, CertificateException { assertNotNull(crypto); assertNotNull(module); - * - * //openssl pkcs12 -nodes -in jclouds-test-fgcp.p12 -out jclouds-test-fgcp.pem // String privKeyFilename = - * "D:\\UserCert.pem.pkcs12-nodes";//_nobags"; String cert = "/certs/jclouds-test-fgcp.pem"; String keyPassword = - * "jcloudsjclouds"; - * - * URL url = this.getClass().getResource(cert); String certPath = url.getFile(); Scanner scanner = new Scanner(new - * File(certPath)); String content = scanner.useDelimiter("\\A").next(); - * - * KeyStore ks = module.provideKeyStore(crypto, content, keyPassword); - * - * assertNotNull(ks.getCertificate("test-fgcp"), "cert with alias"); } - */ -} diff --git a/labs/fgcp/src/test/java/org/jclouds/fujitsu/fgcp/compute/config/FGCPBaseComputeServiceLiveTest.java b/labs/fgcp/src/test/java/org/jclouds/fujitsu/fgcp/compute/config/FGCPBaseComputeServiceLiveTest.java deleted file mode 100644 index 2d216081c6..0000000000 --- a/labs/fgcp/src/test/java/org/jclouds/fujitsu/fgcp/compute/config/FGCPBaseComputeServiceLiveTest.java +++ /dev/null @@ -1,187 +0,0 @@ -package org.jclouds.fujitsu.fgcp.compute.config; - -import java.util.Properties; - -import org.jclouds.Constants; -import org.jclouds.compute.domain.ExecResponse; -import org.jclouds.compute.domain.NodeMetadata; -import org.jclouds.compute.internal.BaseComputeServiceLiveTest; -import org.jclouds.rest.AuthorizationException; -import org.jclouds.sshj.config.SshjSshClientModule; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; -import com.google.inject.Module; - -public abstract class FGCPBaseComputeServiceLiveTest extends - BaseComputeServiceLiveTest { - - @Override - protected Properties setupProperties() { - Properties overrides = super.setupProperties(); - - String proxy = System.getenv("http_proxy"); - if (proxy != null) { - - String[] parts = proxy.split("http://|:|@"); - - overrides.setProperty(Constants.PROPERTY_PROXY_HOST, parts[parts.length - 2]); - overrides.setProperty(Constants.PROPERTY_PROXY_PORT, parts[parts.length - 1]); - - if (parts.length >= 4) { - overrides.setProperty(Constants.PROPERTY_PROXY_USER, parts[parts.length - 4]); - overrides.setProperty(Constants.PROPERTY_PROXY_PASSWORD, parts[parts.length - 3]); - } - } - - // enables peer verification using the CAs bundled with the JRE (or - // value of javax.net.ssl.trustStore if set) - overrides.setProperty(Constants.PROPERTY_TRUST_ALL_CERTS, "false"); - - return overrides; - } - - @Override - protected Module getSshModule() { - return new SshjSshClientModule(); - } - - @Override - @Test(enabled = false, expectedExceptions = AuthorizationException.class) - public void testCorrectAuthException() throws Exception { - // http://code.google.com/p/jclouds/issues/detail?id=1060 - } - - // fgcp does not support metadata - @Override - protected void checkUserMetadataContains(NodeMetadata node, ImmutableMap userMetadata) { - assert node.getUserMetadata().isEmpty() : String.format( - "node userMetadata not empty: %s %s", node, - node.getUserMetadata()); - } - - // node name can't be retrieved through the API and is therefore null - protected void checkResponseEqualsHostname(ExecResponse execResponse, - NodeMetadata node) { - assert node.getHostname() == null : node + " with hostname: " - + node.getHostname(); - } - - // tags are not (yet) supported for fgcp - protected void checkTagsInNodeEquals(NodeMetadata node, - ImmutableSet tags) { - assert node.getTags().isEmpty() : String.format( - "node tags found %s (%s) in node %s", node.getTags(), tags, node); - } - - /* - * public void testCreateAndRunAService() throws Exception { - * super.testCreateAndRunAService(); } - */ - - // this test requires network access to the VM it creates: - // before running it, start an SSL/VPN connection to the last updated vsys' - // DMZ. - // may also need to configure SNAT and FW rules to allow the VM to - // communicate out (53/tcp-udp for DNS, 80/tcp for yum). - public void testAScriptExecutionAfterBootWithBasicTemplate() - throws Exception { - super.testAScriptExecutionAfterBootWithBasicTemplate(); - } - - @Override - @Test(enabled = false) - public void testOptionToNotBlock() throws Exception { - // start call returns before node reaches running state, but - // test may be failing due to the system being in a 're-configuring' - // state while destroying nodes of a previous test. - // http://code.google.com/p/jclouds/issues/detail?id=1066 - /* - org.jclouds.compute.RunNodesException: error running 1 node group(fgcp-aublock) location(UZXC0GRT-IZKDVGIL5-N-SECURE1) image(IMG_3c9820_71OW9NZC268) size(islanda-cbrm_140) options({inboundPorts=[], blockUntilRunning=false}) - Execution failures: - - 1) ExecutionException on fgcp-aublock-787: - java.util.concurrent.ExecutionException: java.lang.IllegalStateException: The status of Instance[UZXC0GRT-IZKDVGIL5] is [RECONFIG_ING]. - at com.google.common.util.concurrent.AbstractFuture$Sync.getValue(AbstractFuture.java:289) - at com.google.common.util.concurrent.AbstractFuture$Sync.get(AbstractFuture.java:276) - at com.google.common.util.concurrent.AbstractFuture.get(AbstractFuture.java:111) - at org.jclouds.concurrent.FutureIterables$1.run(FutureIterables.java:134) - at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source) - at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) - at java.lang.Thread.run(Unknown Source) - Caused by: java.lang.IllegalStateException: The status of Instance[UZXC0GRT-IZKDVGIL5] is [RECONFIG_ING]. - at org.jclouds.fujitsu.fgcp.xml.FGCPJAXBParser.fromXML(FGCPJAXBParser.java:75) - at org.jclouds.http.functions.ParseXMLWithJAXB.apply(ParseXMLWithJAXB.java:91) - at org.jclouds.http.functions.ParseXMLWithJAXB.apply(ParseXMLWithJAXB.java:86) - at org.jclouds.http.functions.ParseXMLWithJAXB.apply(ParseXMLWithJAXB.java:73) - at org.jclouds.http.functions.ParseXMLWithJAXB.apply(ParseXMLWithJAXB.java:54) - at com.google.common.base.Functions$FunctionComposition.apply(Functions.java:209) - at com.google.common.util.concurrent.Futures$3.apply(Futures.java:380) - at com.google.common.util.concurrent.Futures$ChainingListenableFuture.run(Futures.java:522) - at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source) - at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) - at java.lang.Thread.run(Unknown Source) - at org.jclouds.concurrent.config.DescribingExecutorService.submit(DescribingExecutorService.java:89) - at org.jclouds.compute.strategy.impl.CreateNodesWithGroupEncodedIntoNameThenAddToSet.createNodeInGroupWithNameAndTemplate(CreateNodesWithGroupEncodedIntoNameThenAddToSet.java:170) - at org.jclouds.compute.strategy.impl.CreateNodesWithGroupEncodedIntoNameThenAddToSet.execute(CreateNodesWithGroupEncodedIntoNameThenAddToSet.java:125) - at org.jclouds.compute.internal.BaseComputeService.createNodesInGroup(BaseComputeService.java:213) - at org.jclouds.compute.internal.BaseComputeService.createNodesInGroup(BaseComputeService.java:229) - at org.jclouds.compute.internal.BaseComputeServiceLiveTest.testOptionToNotBlock(BaseComputeServiceLiveTest.java:803) - */ - } - -/* @Override - @Test(enabled = false) - public void testCreateTwoNodesWithRunScript() { - } - - @Override - @Test(enabled = false) - public void testCreateAnotherNodeWithANewContextToEnsureSharedMemIsntRequired() { - } - - @Override - @Test(enabled = false) - public void testGet() { - } -*/ -// @Override -// @Test(enabled = false) -// public void testConcurrentUseOfComputeServiceToCreateNodes() throws Exception { - // http://code.google.com/p/jclouds/issues/detail?id=1066 - /* - 1) ExecutionException on twin0-f6a: - java.util.concurrent.ExecutionException: org.jclouds.http.HttpResponseException: Error parsing input - {statusCode=200, message=OK, headers={Date=[Sun, 26 Aug 2012 01:22:50 GMT], Transfer-Encoding=[chunked], Set-Cookie=[JSESSIONID=8A07404DF0405E46B3A748C3763B0D9F; Path=/ovisspxy; Secure], Connection=[close]}, payload=[content=true, contentMetadata=[contentDisposition=null, contentEncoding=null, contentLanguage=null, contentLength=null, contentMD5=null, contentType=text/xml;charset=UTF-8, expires=null], written=false]} - at com.google.common.util.concurrent.AbstractFuture$Sync.getValue(AbstractFuture.java:289) - at com.google.common.util.concurrent.AbstractFuture$Sync.get(AbstractFuture.java:276) - at com.google.common.util.concurrent.AbstractFuture.get(AbstractFuture.java:111) - at org.jclouds.concurrent.FutureIterables$1.run(FutureIterables.java:134) - at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source) - at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) - at java.lang.Thread.run(Unknown Source) - Caused by: org.jclouds.http.HttpResponseException: Error parsing input - {statusCode=200, message=OK, headers={Date=[Sun, 26 Aug 2012 01:22:50 GMT], Transfer-Encoding=[chunked], Set-Cookie=[JSESSIONID=8A07404DF0405E46B3A748C3763B0D9F; Path=/ovisspxy; Secure], Connection=[close]}, payload=[content=true, contentMetadata=[contentDisposition=null, contentEncoding=null, contentLanguage=null, contentLength=null, contentMD5=null, contentType=text/xml;charset=UTF-8, expires=null], written=false]} - at org.jclouds.http.functions.ParseXMLWithJAXB.apply(ParseXMLWithJAXB.java:78) - at org.jclouds.http.functions.ParseXMLWithJAXB.apply(ParseXMLWithJAXB.java:1) - at com.google.common.base.Functions$FunctionComposition.apply(Functions.java:209) - at com.google.common.util.concurrent.Futures$3.apply(Futures.java:380) - at com.google.common.util.concurrent.Futures$ChainingListenableFuture.run(Futures.java:522) - at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source) - at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) - at java.lang.Thread.run(Unknown Source) - at org.jclouds.concurrent.config.DescribingExecutorService.submit(DescribingExecutorService.java:89) - at org.jclouds.compute.strategy.impl.CreateNodesWithGroupEncodedIntoNameThenAddToSet.createNodeInGroupWithNameAndTemplate(CreateNodesWithGroupEncodedIntoNameThenAddToSet.java:170) - at org.jclouds.compute.strategy.impl.CreateNodesWithGroupEncodedIntoNameThenAddToSet.execute(CreateNodesWithGroupEncodedIntoNameThenAddToSet.java:125) - at org.jclouds.compute.internal.BaseComputeService.createNodesInGroup(BaseComputeService.java:213) - at org.jclouds.compute.internal.BaseComputeService.createNodesInGroup(BaseComputeService.java:229) - at org.jclouds.compute.internal.BaseComputeServiceLiveTest$1.call(BaseComputeServiceLiveTest.java:442) - at org.jclouds.compute.internal.BaseComputeServiceLiveTest$1.call(BaseComputeServiceLiveTest.java:1) - ... 3 more - Caused by: org.jclouds.http.HttpException: The status of Instance[UZXC0GRT-9Q988189J] is [RECONFIG_ING]. - at org.jclouds.fujitsu.fgcp.xml.FGCPJAXBParser.fromXML(FGCPJAXBParser.java:81) - at org.jclouds.http.functions.ParseXMLWithJAXB.apply(ParseXMLWithJAXB.java:91) -*/ -// } -} diff --git a/labs/fgcp/src/test/java/org/jclouds/fujitsu/fgcp/compute/functions/DiskImageToOperatingSystemTest.java b/labs/fgcp/src/test/java/org/jclouds/fujitsu/fgcp/compute/functions/DiskImageToOperatingSystemTest.java deleted file mode 100644 index 557651812e..0000000000 --- a/labs/fgcp/src/test/java/org/jclouds/fujitsu/fgcp/compute/functions/DiskImageToOperatingSystemTest.java +++ /dev/null @@ -1,163 +0,0 @@ -package org.jclouds.fujitsu.fgcp.compute.functions; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertNotEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertNull; -import static org.testng.Assert.assertTrue; - -import java.util.Arrays; -import java.util.List; - -import org.jclouds.compute.domain.OperatingSystem; -import org.jclouds.compute.domain.OsFamily; -import org.jclouds.fujitsu.fgcp.domain.DiskImage; -import org.jclouds.fujitsu.fgcp.domain.DiskImage.Builder; -import org.testng.annotations.Test; - -/** - * @author Dies Koper - */ -@Test(groups = "unit", testName = "DiskImageToOperatingSystemTest") -public class DiskImageToOperatingSystemTest { - // Operating Systems available JAN 2012 (taken from osName) - private static final List operatingSystems = Arrays.asList( - // JP - "CentOS 5.6 32bit (English)", - "CentOS 5.6 64bit (English)", - "Red Hat Enterprise Linux 5.5 32bit (Japanese)", - "Red Hat Enterprise Linux 5.5 64bit (Japanese)", - "Windows Server 2003 R2 EE 32bit SP2 (日本語版) サポート付", - "Windows Server 2003 R2 EE 32bit SP2 (日本語版)", - "Windows Server 2008 R2 EE 64bit (日本語版) サポート付", - "Windows Server 2008 R2 EE 64bit (日本語版)", - "Windows Server 2008 R2 SE 64bit (日本語版) サポート付", - "Windows Server 2008 R2 SE 64bit (日本語版)", - "Windows Server 2008 SE 32bit SP2 (日本語版) サポート付", - "Windows Server 2008 SE 32bit SP2 (日本語版)", - // AU - "CentOS 5.4 64bit (English)", "CentOS 5.4 32bit (English)", - "Windows Server 2008 R2 SE 64bit (English)", - "Windows Server 2008 R2 EE 64bit (English)"); - - @Test - public void testConversion() { - for (String description : operatingSystems) { - Builder builder = DiskImage.builder(); - builder.osName(description); - builder.osType("hvm"); - builder.creatorName("creator"); - builder.registrant("registrant"); - builder.description("description"); - builder.id("ABCDEFGH"); - DiskImage image = builder.build(); - - OperatingSystem os = new DiskImageToOperatingSystem().apply(image); - - assertNotNull(os, description); - assertNotNull(os.getFamily(), description); - assertNotEquals(OsFamily.UNRECOGNIZED, os.getFamily(), - "OsFamily not recognised: " + description); - assertNotNull(os.getVersion(), "Version not recognised: " - + description); - assertEquals(os.getName(), description); - assertEquals(os.getDescription(), description); - assertNotNull(os.getArch(), description); - } - } - - @Test - public void testOsFamilyUnrecognized() { - DiskImage image = DiskImage.builder() - .osName("not a known operating system").build(); - - OperatingSystem os = new DiskImageToOperatingSystem().apply(image); - - assertNotNull(os); - assertEquals(os.getFamily(), OsFamily.UNRECOGNIZED); - } - - @Test - public void test64BitsWithSpace() { - DiskImage image = DiskImage.builder().osName("a (64 bit) os").build(); - - OperatingSystem os = new DiskImageToOperatingSystem().apply(image); - - assertNotNull(os); - assertTrue(os.is64Bit()); - } - - @Test - public void test64BitsNoSpace() { - DiskImage image = DiskImage.builder().osName("a (64bit) os").build(); - - OperatingSystem os = new DiskImageToOperatingSystem().apply(image); - - assertNotNull(os); - assertTrue(os.is64Bit()); - } - - @Test - public void test32BitsNoSpace() { - DiskImage image = DiskImage.builder().osName("a (32bit) os").build(); - - OperatingSystem os = new DiskImageToOperatingSystem().apply(image); - - assertNotNull(os); - assertFalse(os.is64Bit()); - } - - @Test - public void testx64NoSpace() { - DiskImage image = DiskImage.builder().osName("a (x64) os").build(); - - OperatingSystem os = new DiskImageToOperatingSystem().apply(image); - - assertNotNull(os); - assertTrue(os.is64Bit()); - } - - @Test - public void testWindowsVersion() { - DiskImage image = DiskImage.builder() - .osName("Windows Server 2008 R2 SE 64 bit").build(); - - OperatingSystem os = new DiskImageToOperatingSystem().apply(image); - - assertNotNull(os); - assertEquals(os.getVersion(), "2008 R2 SE"); - } - - @Test - public void testCentOSVersion() { - DiskImage image = DiskImage.builder() - .osName("CentOS 6.2 64bit (English)").build(); - - OperatingSystem os = new DiskImageToOperatingSystem().apply(image); - - assertNotNull(os); - assertEquals(os.getVersion(), "6.2"); - } - - @Test - public void testUnrecognizedOsVersion() { - DiskImage image = DiskImage.builder() - .osName("Windows Server 2099 (256 bit)").build(); - - OperatingSystem os = new DiskImageToOperatingSystem().apply(image); - - assertNotNull(os); - assertNull(os.getVersion()); - } - - @Test - public void testOsVersionMissing() { - DiskImage image = DiskImage.builder().osName("asd Server").build(); - - OperatingSystem os = new DiskImageToOperatingSystem().apply(image); - assertNotNull(os); - assertNull(os.getVersion(), "os.getVersion(): \'" + os.getVersion() - + "\'"); - } -} diff --git a/labs/fgcp/src/test/java/org/jclouds/fujitsu/fgcp/filters/RequestAuthenticatorTest.java b/labs/fgcp/src/test/java/org/jclouds/fujitsu/fgcp/filters/RequestAuthenticatorTest.java deleted file mode 100644 index 9f2a65ddcd..0000000000 --- a/labs/fgcp/src/test/java/org/jclouds/fujitsu/fgcp/filters/RequestAuthenticatorTest.java +++ /dev/null @@ -1,160 +0,0 @@ -package org.jclouds.fujitsu.fgcp.filters; - -import static org.testng.Assert.assertEquals; - -import java.security.KeyStore; -import java.util.Calendar; -import java.util.TimeZone; - -import javax.inject.Provider; - -import org.jclouds.domain.Credentials; -import org.jclouds.http.HttpRequest; -import org.jclouds.http.HttpUtils; -import org.jclouds.http.internal.SignatureWire; -import org.testng.annotations.Test; - -import com.google.common.base.Supplier; - -public class RequestAuthenticatorTest { - - Provider calendarProvider = new Provider() { - public Calendar get() { - Calendar c = Calendar.getInstance(TimeZone.getTimeZone("Australia/Sydney")); - c.setTimeInMillis(1358747939000L); // Mon Jan 21 16:58:59 +1100 2013 - return c; - } - }; - Supplier creds = new Supplier() { - @Override - public Credentials get() { - return null; - } - }; - Supplier keystore = new Supplier() { - public KeyStore get() { - return null; - } - }; - RequestAuthenticator a = new RequestAuthenticator(calendarProvider, - new RequestAuthenticator.SignatureForCredentials(keystore), creds, - new HttpUtils(0, 0, 0, 0), new SignatureWire(), ""); - - @Test - public void testGenerateAccessKeyIdWithNewline() throws Exception { - String accessKeyId = a.generateAccessKeyId(); - assertEquals( - accessKeyId, - "RWFzdGVybiBTdGFuZGFyZCBUaW1lIChOZXcgU291dGggV2FsZXMpJjEzNTg3N\nDc5MzkwMDAmMS4wJlNIQTF3aXRoUlNB"); - } - - @Test - public void testAddQueryParamsToRequest() throws Exception { - String accessKeyId = "accessKeyId"; - String signature = "signature"; - String lang = "en"; - - HttpRequest request = HttpRequest - .builder() - .endpoint( - "https://api.globalcloud.fujitsu.com.au/ovissapi/endpoint?Version=2012-02-18") - .method("GET").build(); - HttpRequest newRequest = a.addQueryParamsToRequest(request, accessKeyId, - signature, lang); - assertEquals( - newRequest.getRequestLine(), - "GET https://api.globalcloud.fujitsu.com.au/ovissapi/endpoint?Version=2012-02-18&Locale=en&AccessKeyId=accessKeyId&Signature=signature HTTP/1.1"); - } - - @Test - public void testAddQueryParamsWithRealValuesToRequest() throws Exception { - String accessKeyId = "RWFzdGVybiBTdGFuZGFyZCBUaW1lIChOZXcgU291dGggV2FsZXMpJjEzNTg4M\nzg4OTgwNTcmMS4wJlNIQTF3aXRoUlNB"; - String signature = "QFAmuZ0XyOjy6fmMLkMCH/xObY6Jhyltjo2hBcUrXHape8ecTmAlbCUO/+lKr\nQ3Qeu1cNqh8BXSnoc4vXR3aezR6V94aBlQ/4uowQuZP3S8yjnC0aPjWQ70JcB\nULR+qSGNmc97agOTMmIl4JJcukCBEEyLSzRDDe2ib2PqN11RA55GmAP/xx7qg\n0fj6ieauzuzImL1tJq03w0tPdCSuB6lnZe/81Z+Rbqwfl3kdGNBnV7YrdD3Qg\nRBDOKgA2okMlc5pzgk59i/O07ScfoJs7A58HnTZZ2KyVPFgHq6YGpCA2PqII6\nHUlqx6hkX9HFXIz+wz52gbSwBrqgloAw8w8Iw=="; - String lang = "en"; - - HttpRequest request = HttpRequest - .builder() - .endpoint( - "https://api.globalcloud.fujitsu.com.au/ovissapi/endpoint?Version=2012-02-18") - .method("GET").build(); - HttpRequest newRequest = a.addQueryParamsToRequest(request, accessKeyId, - signature, lang); - assertEquals( - newRequest.getRequestLine(), - "GET https://api.globalcloud.fujitsu.com.au/ovissapi/endpoint?Version=2012-02-18&Locale=en&AccessKeyId=RWFzdGVybiBTdGFuZGFyZCBUaW1lIChOZXcgU291dGggV2FsZXMpJjEzNTg4M%0Azg4OTgwNTcmMS4wJlNIQTF3aXRoUlNB&Signature=QFAmuZ0XyOjy6fmMLkMCH/xObY6Jhyltjo2hBcUrXHape8ecTmAlbCUO/%2BlKr%0AQ3Qeu1cNqh8BXSnoc4vXR3aezR6V94aBlQ/4uowQuZP3S8yjnC0aPjWQ70JcB%0AULR%2BqSGNmc97agOTMmIl4JJcukCBEEyLSzRDDe2ib2PqN11RA55GmAP/xx7qg%0A0fj6ieauzuzImL1tJq03w0tPdCSuB6lnZe/81Z%2BRbqwfl3kdGNBnV7YrdD3Qg%0ARBDOKgA2okMlc5pzgk59i/O07ScfoJs7A58HnTZZ2KyVPFgHq6YGpCA2PqII6%0AHUlqx6hkX9HFXIz%2Bwz52gbSwBrqgloAw8w8Iw%3D%3D HTTP/1.1"); - } - - @Test - public void testAddQueryParamsWithSlashes() throws Exception { - String accessKeyId = "accessKeyId"; - String signature = "sig/na/ture"; - String lang = "en"; - - HttpRequest request = HttpRequest - .builder() - .endpoint( - "https://api.globalcloud.fujitsu.com.au/ovissapi/endpoint?Version=2012-02-18") - .method("GET").build(); - HttpRequest newRequest = a.addQueryParamsToRequest(request, accessKeyId, - signature, lang); - assertEquals( - newRequest.getRequestLine(), - "GET https://api.globalcloud.fujitsu.com.au/ovissapi/endpoint?Version=2012-02-18&Locale=en&AccessKeyId=accessKeyId&Signature=sig/na/ture HTTP/1.1"); - } - - @Test - public void testAddQueryParamsWithNewlines() throws Exception { - String accessKeyId = "accessKey\nId"; - String signature = "sig\nna\nture"; - String lang = "en"; - - HttpRequest request = HttpRequest - .builder() - .endpoint( - "https://api.globalcloud.fujitsu.com.au/ovissapi/endpoint?Version=2012-02-18") - .method("GET").build(); - HttpRequest newRequest = a.addQueryParamsToRequest(request, accessKeyId, - signature, lang); - assertEquals( - newRequest.getRequestLine(), - "GET https://api.globalcloud.fujitsu.com.au/ovissapi/endpoint?Version=2012-02-18&Locale=en&AccessKeyId=accessKey%0AId&Signature=sig%0Ana%0Ature HTTP/1.1"); - } - - @Test - public void testAddQueryParamsWithPlus() throws Exception { - String accessKeyId = "accessKey+Id"; - String signature = "sign+ature"; - String lang = "en"; - - HttpRequest request = HttpRequest - .builder() - .endpoint( - "https://api.globalcloud.fujitsu.com.au/ovissapi/endpoint?Version=2012-02-18") - .method("GET").build(); - HttpRequest newRequest = a.addQueryParamsToRequest(request, accessKeyId, - signature, lang); - assertEquals( - newRequest.getRequestLine(), - // NOTE: AccessKeyId's "=" becomes a %20 (space) as explained in - // addQueryParamsToRequest(). - "GET https://api.globalcloud.fujitsu.com.au/ovissapi/endpoint?Version=2012-02-18&Locale=en&AccessKeyId=accessKey%20Id&Signature=sign%2Bature HTTP/1.1"); - } - - @Test - public void testAddQueryParamsWithBase64Symbols() throws Exception { - String accessKeyId = "accessKeyId\nWith/And+And="; - String signature = "signature\nWith/And+And="; - String lang = "en"; - - HttpRequest request = HttpRequest - .builder() - .endpoint( - "https://api.globalcloud.fujitsu.com.au/ovissapi/endpoint?Version=2012-02-18") - .method("GET").build(); - HttpRequest newRequest = a.addQueryParamsToRequest(request, accessKeyId, - signature, lang); - assertEquals( - newRequest.getRequestLine(), - "GET https://api.globalcloud.fujitsu.com.au/ovissapi/endpoint?Version=2012-02-18&Locale=en&AccessKeyId=accessKeyId%0AWith/And%20And%3D&Signature=signature%0AWith/And%2BAnd%3D HTTP/1.1"); - } -} diff --git a/labs/fgcp/src/test/java/org/jclouds/fujitsu/fgcp/services/AdditionalDiskApiExpectTest.java b/labs/fgcp/src/test/java/org/jclouds/fujitsu/fgcp/services/AdditionalDiskApiExpectTest.java deleted file mode 100644 index df0245d44f..0000000000 --- a/labs/fgcp/src/test/java/org/jclouds/fujitsu/fgcp/services/AdditionalDiskApiExpectTest.java +++ /dev/null @@ -1,157 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.services; - -import static org.testng.Assert.assertEquals; - -import org.jclouds.http.HttpRequest; -import org.jclouds.http.HttpResponse; -import org.testng.annotations.Test; - -/** - * @author Dies Koper - */ -@Test(groups = "unit", testName = "AdditionalDiskApiExpectTest", singleThreaded = true) -public class AdditionalDiskApiExpectTest extends BaseFGCPRestApiExpectTest { - - public void testGet() { - HttpRequest request = buildGETWithQuery("Action=GetVDiskAttributes" - + "&vdiskId=CONTRACT-VSYS00001-D-0001" - + "&vsysId=CONTRACT-VSYS00001"); - HttpResponse response = HttpResponse - .builder() - .statusCode(200) - .payload( - payloadFromResource("/GetVDiskAttributes-response.xml")) - .build(); - - AdditionalDiskApi api = requestSendsResponse(request, response) - .getAdditionalDiskApi(); - - assertEquals(api.get("CONTRACT-VSYS00001-D-0001").getSize(), 10.0); - } - - public void testGetStatus() { - HttpRequest request = buildGETWithQuery("Action=GetVDiskStatus" - + "&vdiskId=CONTRACT-VSYS00001-S-0001" - + "&vsysId=CONTRACT-VSYS00001"); - HttpResponse response = HttpResponse - .builder() - .statusCode(200) - .payload( - payloadFromResource("/GetVDiskStatus-response.xml")) - .build(); - - AdditionalDiskApi api = requestSendsResponse(request, response) - .getAdditionalDiskApi(); - - // api is returning STOPPED which is not a documented status. Documentation error? -// assertEquals(api.getStatus("CONTRACT-VSYS00001-S-0001"), VDiskStatus.STOPPED); - } - - public void testUpdate() { - HttpRequest request = buildGETWithQuery("Action=UpdateVDiskAttribute" - + "&vdiskId=CONTRACT-VSYS00001-D-0001" - + "&attributeName=updateName" + "&attributeValue=new-name" - + "&vsysId=CONTRACT-VSYS00001"); - HttpResponse response = HttpResponse - .builder() - .statusCode(200) - .payload( - payloadFromResource("/UpdateVDiskAttribute-response.xml")) - .build(); - - AdditionalDiskApi api = requestSendsResponse(request, response) - .getAdditionalDiskApi(); - - api.update("CONTRACT-VSYS00001-D-0001", "updateName", "new-name"); - } - - public void testDestroy() { - HttpRequest request = buildGETWithQuery("Action=DestroyVDisk" - + "&vdiskId=CONTRACT-VSYS00001-D-0001" - + "&vsysId=CONTRACT-VSYS00001"); - HttpResponse response = HttpResponse.builder().statusCode(200) - .payload(payloadFromResource("/DestroyVDisk-response.xml")) - .build(); - - AdditionalDiskApi api = requestSendsResponse(request, response) - .getAdditionalDiskApi(); - - api.destroy("CONTRACT-VSYS00001-D-0001"); - } - - public void testBackup() { - HttpRequest request = buildGETWithQuery("Action=BackupVDisk" - + "&vdiskId=CONTRACT-VSYS00001-D-0001" - + "&vsysId=CONTRACT-VSYS00001"); - HttpResponse response = HttpResponse.builder().statusCode(200) - .payload(payloadFromResource("/BackupVDisk-response.xml")) - .build(); - - AdditionalDiskApi api = requestSendsResponse(request, response) - .getAdditionalDiskApi(); - - api.backup("CONTRACT-VSYS00001-D-0001"); - } - - public void testRestore() { - HttpRequest request = buildGETWithQuery("Action=RestoreVDisk" - + "&vsysId=CONTRACT-VSYS00001" - + "&backupId=003"); - HttpResponse response = HttpResponse.builder().statusCode(200) - .payload(payloadFromResource("/RestoreVDisk-response.xml")) - .build(); - - AdditionalDiskApi api = requestSendsResponse(request, response) - .getAdditionalDiskApi(); - - api.restore("CONTRACT-VSYS00001", "003"); - } - - public void testDetach() { - HttpRequest request = buildGETWithQuery("Action=DetachVDisk" - + "&vdiskId=CONTRACT-VSYS00001-D-0001" - + "&vserverId=CONTRACT-VSYS00001-S-0006" - + "&vsysId=CONTRACT-VSYS00001"); - HttpResponse response = HttpResponse.builder().statusCode(200) - .payload(payloadFromResource("/DetachVDisk-response.xml")) - .build(); - - AdditionalDiskApi api = requestSendsResponse(request, response) - .getAdditionalDiskApi(); - - api.detach("CONTRACT-VSYS00001-D-0001", "CONTRACT-VSYS00001-S-0006"); - } - - public void testDestroyBackup() { - HttpRequest request = buildGETWithQuery("Action=DestroyVDiskBackup" - + "&vsysId=CONTRACT-VSYS00001" - + "&backupId=003"); - HttpResponse response = HttpResponse.builder().statusCode(200) - .payload(payloadFromResource("/DestroyVDiskBackup-response.xml")) - .build(); - - AdditionalDiskApi api = requestSendsResponse(request, response) - .getAdditionalDiskApi(); - - api.destroyBackup("CONTRACT-VSYS00001", "003"); - } - -} diff --git a/labs/fgcp/src/test/java/org/jclouds/fujitsu/fgcp/services/BaseFGCPApiLiveTest.java b/labs/fgcp/src/test/java/org/jclouds/fujitsu/fgcp/services/BaseFGCPApiLiveTest.java deleted file mode 100644 index 0a209d36e5..0000000000 --- a/labs/fgcp/src/test/java/org/jclouds/fujitsu/fgcp/services/BaseFGCPApiLiveTest.java +++ /dev/null @@ -1,84 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.services; - -import java.util.Properties; - -import org.jclouds.Constants; -import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest; -import org.jclouds.fujitsu.fgcp.FGCPApi; -import org.jclouds.fujitsu.fgcp.FGCPAsyncApi; -import org.jclouds.rest.RestContext; -import org.jclouds.sshj.config.SshjSshClientModule; -import org.testng.annotations.BeforeGroups; - -import com.google.inject.Module; - -/** - * @author Dies Koper - */ -public class BaseFGCPApiLiveTest extends BaseComputeServiceContextLiveTest { - - protected RestContext fgcpContext; - - public BaseFGCPApiLiveTest() { - provider = "fgcp"; - } - - @Override - protected Properties setupProperties() { - Properties overrides = super.setupProperties(); - - String proxy = System.getenv("http_proxy"); - if (proxy != null) { - - String[] parts = proxy.split("http://|:|@"); - - overrides.setProperty(Constants.PROPERTY_PROXY_HOST, - parts[parts.length - 2]); - overrides.setProperty(Constants.PROPERTY_PROXY_PORT, - parts[parts.length - 1]); - - if (parts.length >= 4) { - overrides.setProperty(Constants.PROPERTY_PROXY_USER, - parts[parts.length - 4]); - overrides.setProperty(Constants.PROPERTY_PROXY_PASSWORD, - parts[parts.length - 3]); - } - } - - // enables peer verification using the CAs bundled with the JRE (or - // value of javax.net.ssl.trustStore if set) - overrides.setProperty(Constants.PROPERTY_TRUST_ALL_CERTS, "false"); - - return overrides; - } - - @BeforeGroups(groups = { "integration", "live" }) - @Override - public void setupContext() { - super.setupContext(); - fgcpContext = view.unwrap(); - } - - @Override - protected Module getSshModule() { - return new SshjSshClientModule(); - } -} diff --git a/labs/fgcp/src/test/java/org/jclouds/fujitsu/fgcp/services/BaseFGCPRestApiExpectTest.java b/labs/fgcp/src/test/java/org/jclouds/fujitsu/fgcp/services/BaseFGCPRestApiExpectTest.java deleted file mode 100644 index 9bd338855f..0000000000 --- a/labs/fgcp/src/test/java/org/jclouds/fujitsu/fgcp/services/BaseFGCPRestApiExpectTest.java +++ /dev/null @@ -1,124 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.services; - -import static org.testng.Assert.assertNotNull; - -import java.net.URI; -import java.net.URL; -import java.util.Calendar; -import java.util.Locale; -import java.util.TimeZone; - -import javax.ws.rs.core.MediaType; - -import org.jclouds.fujitsu.fgcp.FGCPApi; -import org.jclouds.fujitsu.fgcp.FGCPProviderMetadata; -import org.jclouds.fujitsu.fgcp.compute.FGCPRestClientModule; -import org.jclouds.http.HttpRequest; -import org.jclouds.io.Payload; -import org.jclouds.providers.ProviderMetadata; -import org.jclouds.rest.ConfiguresRestClient; -import org.jclouds.rest.internal.BaseRestClientExpectTest; - -import com.google.common.collect.ImmutableMultimap; -import com.google.inject.Module; - -/** - * @author Dies Koper - */ -public class BaseFGCPRestApiExpectTest extends - BaseRestClientExpectTest { - - public BaseFGCPRestApiExpectTest() { - provider = "fgcp"; - - // self-signed dummy cert: - // keytool -genkey -alias test-fgcp -keyalg RSA -keysize 1024 -validity 5475 -dname "CN=localhost" -keystore jclouds-test-fgcp.p12 -storepass jcloudsjclouds -storetype pkcs12 - String cert = "/certs/jclouds-test-fgcp.p12"; - URL url = this.getClass().getResource(cert); - assertNotNull(url, cert + " not found"); - - identity = url.getFile(); - credential = "jcloudsjclouds"; - } - - @ConfiguresRestClient - protected static final class TestFGCPRestClientModule extends - FGCPRestClientModule { - - @Override - protected Calendar provideCalendar() { - // pick country/TZ with no DST just in case to maintain constant - // time wherever the tests are run. - Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT-9"), - Locale.JAPAN); - cal.setTimeInMillis(1234567890); - return cal; - } - } - - @Override - protected Module createModule() { - return new TestFGCPRestClientModule(); - } - - @Override - protected ProviderMetadata createProviderMetadata() { - return new FGCPProviderMetadata(); - } - - @Override - public Payload payloadFromResource(String resource) { - return super.payloadFromResource("/responses" + resource); - } - - protected static HttpRequest buildGETWithQuery(String query) { - URI uri = URI.create("https://api.globalcloud.fujitsu.com.au/ovissapi/endpoint" - + "?Version=2012-02-18" - + "&" + query - + "&Locale=en" - + "&AccessKeyId=R01ULTA5OjAwJjEyMzQ1Njc4OTAmMS4wJlNIQTF3aXRoUlNB" - + "&Signature=G2rGfLAkbq0IURQfXIWYxj3BnMGbjRk4KPnZLAze3Lt4SMMRt8lkjqKvR5Cm%2B%0AnFpDN7J6IprVCCsIrRq5BqPeXT6xtWyb6qMNds2BAr1h/JePGs0UosOh2tgPU%0AMSFlZwLVjgNyrSa2zeHA3AEHjF6H1jqcWXXqfCAD4SOHaNavk%3D"); - return HttpRequest - .builder() - .method("GET") - .endpoint(uri) - .addHeader("Accept", "text/xml") - .addHeader("User-Agent", "OViSS-API-CLIENT") - .build(); - } - - protected HttpRequest preparePOSTForAction(String action) { - return HttpRequest - .builder() - .method("POST") - .endpoint( - URI.create("https://api.globalcloud.fujitsu.com.au/ovissapi/endpoint")) - .payload( - payloadFromResourceWithContentType( - "/" + action.toLowerCase() + "-request.xml", - MediaType.TEXT_XML)) - .headers( - ImmutableMultimap. builder() - .put("Accept", "text/xml") - .put("User-Agent", "OViSS-API-CLIENT").build()) - .build(); - } -} diff --git a/labs/fgcp/src/test/java/org/jclouds/fujitsu/fgcp/services/BuiltinServerApiExpectTest.java b/labs/fgcp/src/test/java/org/jclouds/fujitsu/fgcp/services/BuiltinServerApiExpectTest.java deleted file mode 100644 index 52c0c452f4..0000000000 --- a/labs/fgcp/src/test/java/org/jclouds/fujitsu/fgcp/services/BuiltinServerApiExpectTest.java +++ /dev/null @@ -1,215 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.services; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; - -import java.util.Set; - -import org.jclouds.fujitsu.fgcp.domain.BuiltinServer; -import org.jclouds.fujitsu.fgcp.domain.BuiltinServerBackup; -import org.jclouds.fujitsu.fgcp.domain.BuiltinServerStatus; -import org.jclouds.http.HttpRequest; -import org.jclouds.http.HttpResponse; -import org.testng.annotations.Test; - -/** - * @author Dies Koper - */ -@Test(groups = "unit", testName = "BuiltinServerApiExpectTest", singleThreaded = true) -public class BuiltinServerApiExpectTest extends BaseFGCPRestApiExpectTest { - - public void testStart() { - HttpRequest request = buildGETWithQuery("Action=StartEFM" - + "&efmId=CONTRACT-VSYS00001-S-0001" - + "&vsysId=CONTRACT-VSYS00001"); - HttpResponse response = HttpResponse.builder().statusCode(200) - .payload(payloadFromResource("/StartEFM-response.xml")) - .build(); - - BuiltinServerApi api = requestSendsResponse(request, response) - .getFirewallApi(); - - api.start("CONTRACT-VSYS00001-S-0001"); - } - - public void testStop() { - HttpRequest request = buildGETWithQuery("Action=StopEFM" - + "&efmId=CONTRACT-VSYS00001-S-0001" - + "&vsysId=CONTRACT-VSYS00001"); - HttpResponse response = HttpResponse.builder().statusCode(200) - .payload(payloadFromResource("/StopEFM-response.xml")) - .build(); - - BuiltinServerApi api = requestSendsResponse(request, response) - .getFirewallApi(); - - api.stop("CONTRACT-VSYS00001-S-0001"); - } - - public void testDestroy() { - HttpRequest request = buildGETWithQuery("Action=DestroyEFM" - + "&efmId=CONTRACT-VSYS00001-S-0001" - + "&vsysId=CONTRACT-VSYS00001"); - HttpResponse response = HttpResponse.builder().statusCode(200) - .payload(payloadFromResource("/DestroyEFM-response.xml")) - .build(); - - BuiltinServerApi api = requestSendsResponse(request, response) - .getFirewallApi(); - - api.destroy("CONTRACT-VSYS00001-S-0001"); - } - - public void testGet() { - HttpRequest request = buildGETWithQuery("Action=GetEFMAttributes" - + "&efmId=CONTRACT-VSYS00001-S-0001" - + "&vsysId=CONTRACT-VSYS00001"); - HttpResponse response = HttpResponse - .builder() - .statusCode(200) - .payload( - payloadFromResource("/GetEFMAttributes-response.xml")) - .build(); - - BuiltinServerApi api = requestSendsResponse(request, response) - .getFirewallApi(); - - assertEquals(api.get("CONTRACT-VSYS00001-S-0001").getType(), BuiltinServer.BuiltinServerType.FW); - } - -/* - public void testGetDetails() { - HttpRequest request = buildGETWithQuery("Action=GetEFMConfiguration" - + "&efmId=CONTRACT-VSYS00001-S-0001" - + "&vsysId=CONTRACT-VSYS00001"); - HttpResponse response = HttpResponse - .builder() - .statusCode(200) - .payload( - payloadFromResource("/GetEFMConfiguration-response.xml")) - .build(); - - BuiltinServerApi api = requestSendsResponse(request, response) - .getFirewallApi(); - -// assertNotNull(api.getDetails("CONTRACT-VSYS00001-S-0001")); - } -*/ - - public void testGetStatus() { - HttpRequest request = buildGETWithQuery("Action=GetEFMStatus" - + "&efmId=CONTRACT-VSYS00001-S-0001" - + "&vsysId=CONTRACT-VSYS00001"); - HttpResponse response = HttpResponse - .builder() - .statusCode(200) - .payload( - payloadFromResource("/GetEFMStatus-response.xml")) - .build(); - - BuiltinServerApi api = requestSendsResponse(request, response) - .getFirewallApi(); - - assertEquals(api.getStatus("CONTRACT-VSYS00001-S-0001"), BuiltinServerStatus.RUNNING); - } - - public void testUpdate() { - HttpRequest request = buildGETWithQuery("Action=UpdateEFMAttribute" - + "&efmId=CONTRACT-VSYS00001-S-0001" - + "&attributeName=vserverName" - + "&attributeValue=new%20name" - + "&vsysId=CONTRACT-VSYS00001"); - HttpResponse response = HttpResponse - .builder() - .statusCode(200) - .payload( - payloadFromResource("/UpdateEFMAttribute-response.xml")) - .build(); - - BuiltinServerApi api = requestSendsResponse(request, response) - .getFirewallApi(); - - api.update("CONTRACT-VSYS00001-S-0001", "vserverName", "new name"); - } - - public void testBackup() { - HttpRequest request = buildGETWithQuery("Action=BackupEFM" - + "&efmId=CONTRACT-VSYS00001-S-0001" - + "&vsysId=CONTRACT-VSYS00001"); - HttpResponse response = HttpResponse.builder().statusCode(200) - .payload(payloadFromResource("/BackupEFM-response.xml")) - .build(); - - BuiltinServerApi api = requestSendsResponse(request, response) - .getFirewallApi(); - - api.backup("CONTRACT-VSYS00001-S-0001"); - } - - public void testRestore() { - HttpRequest request = buildGETWithQuery("Action=RestoreEFM" - + "&efmId=CONTRACT-VSYS00001-S-0001" - + "&backupId=003" - + "&vsysId=CONTRACT-VSYS00001"); - HttpResponse response = HttpResponse.builder().statusCode(200) - .payload(payloadFromResource("/RestoreEFM-response.xml")) - .build(); - - BuiltinServerApi api = requestSendsResponse(request, response) - .getFirewallApi(); - - api.restore("CONTRACT-VSYS00001-S-0001", "003"); - } - - public void testListBackups() { - HttpRequest request = buildGETWithQuery("Action=ListEFMBackup" - + "&efmId=CONTRACT-VSYS00001-S-0001" - + "&vsysId=CONTRACT-VSYS00001"); - HttpResponse response = HttpResponse.builder().statusCode(200) - .payload(payloadFromResource("/ListEFMBackup-response.xml")) - .build(); - - BuiltinServerApi api = requestSendsResponse(request, response) - .getFirewallApi(); - - Set backups = api.listBackups("CONTRACT-VSYS00001-S-0001"); - assertNotNull(backups, "backups"); - assertEquals(backups.size(), 2); - assertEquals(backups.iterator().next().getId(), "001"); - assertEquals(backups.iterator().next().getTime(), "20121008201127"); - } - - public void testDestroyBackup() { - HttpRequest request = buildGETWithQuery("Action=DestroyEFMBackup" - + "&efmId=CONTRACT-VSYS00001-S-0001" - + "&backupId=003" - + "&vsysId=CONTRACT-VSYS00001"); - HttpResponse response = HttpResponse.builder().statusCode(200) - .payload(payloadFromResource("/DestroyEFMBackup-response.xml")) - .build(); - - BuiltinServerApi api = requestSendsResponse(request, response) - .getFirewallApi(); - - api.destroyBackup("CONTRACT-VSYS00001-S-0001", "003"); - } - -} diff --git a/labs/fgcp/src/test/java/org/jclouds/fujitsu/fgcp/services/DiskImageApiExpectTest.java b/labs/fgcp/src/test/java/org/jclouds/fujitsu/fgcp/services/DiskImageApiExpectTest.java deleted file mode 100644 index fce7079bbc..0000000000 --- a/labs/fgcp/src/test/java/org/jclouds/fujitsu/fgcp/services/DiskImageApiExpectTest.java +++ /dev/null @@ -1,79 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.services; - -import static org.testng.Assert.assertEquals; - -import org.jclouds.fujitsu.fgcp.domain.DiskImage; -import org.jclouds.http.HttpRequest; -import org.jclouds.http.HttpResponse; -import org.testng.annotations.Test; - -/** - * @author Dies Koper - */ -@Test(groups = "unit", testName = "DiskImageApiExpectTest", singleThreaded = true) -public class DiskImageApiExpectTest extends BaseFGCPRestApiExpectTest { - - public void testGet() { - HttpRequest request = buildGETWithQuery("Action=GetDiskImageAttributes" - + "&diskImageId=IMG_A1B2C3_1234567890ABCD"); - HttpResponse response = HttpResponse.builder().statusCode(200) - .payload(payloadFromResource("/GetDiskImageAttributes-response.xml")) - .build(); - - DiskImageApi api = requestSendsResponse(request, response) - .getDiskImageApi(); - - DiskImage image = api.get("IMG_A1B2C3_1234567890ABCD"); - - assertEquals(image.getId(), "IMG_A1B2C3_1234567890ABCD"); - assertEquals(image.getCreatorName(), "ABCDEFGH"); - } - - public void testUpdate() { - HttpRequest request = buildGETWithQuery("Action=UpdateDiskImageAttribute" - + "&diskImageId=IMG_A1B2C3_1234567890ABCD" - + "&updateLcId=en" - + "&attributeName=updateName" - + "&attributeValue=new-name"); - HttpResponse response = HttpResponse.builder().statusCode(200) - .payload(payloadFromResource("/UpdateDiskImageAttribute-response.xml")) - .build(); - - DiskImageApi api = requestSendsResponse(request, response) - .getDiskImageApi(); - - api.update("IMG_A1B2C3_1234567890ABCD", "en", "updateName", "new-name"); - } - - public void testDeregister() { - HttpRequest request = buildGETWithQuery("Action=UnregisterDiskImage" - + "&diskImageId=IMG_A1B2C3_1234567890ABCD"); - HttpResponse response = HttpResponse.builder().statusCode(200) - .payload(payloadFromResource("/UnregisterDiskImage-response.xml")) - .build(); - - DiskImageApi api = requestSendsResponse(request, response) - .getDiskImageApi(); - - api.deregister("IMG_A1B2C3_1234567890ABCD"); - } - -} diff --git a/labs/fgcp/src/test/java/org/jclouds/fujitsu/fgcp/services/PublicIPAddressApiExpectTest.java b/labs/fgcp/src/test/java/org/jclouds/fujitsu/fgcp/services/PublicIPAddressApiExpectTest.java deleted file mode 100644 index 8458fe2a92..0000000000 --- a/labs/fgcp/src/test/java/org/jclouds/fujitsu/fgcp/services/PublicIPAddressApiExpectTest.java +++ /dev/null @@ -1,109 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.services; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; - -import org.jclouds.fujitsu.fgcp.domain.PublicIP; -import org.jclouds.fujitsu.fgcp.domain.PublicIPStatus; -import org.jclouds.http.HttpRequest; -import org.jclouds.http.HttpResponse; -import org.testng.annotations.Test; - -/** - * @author Dies Koper - */ -@Test(groups = "unit", testName = "PublicIPAddressApiExpectTest", singleThreaded = true) -public class PublicIPAddressApiExpectTest extends BaseFGCPRestApiExpectTest { - - public void testAttach() { - HttpRequest request = buildGETWithQuery("Action=AttachPublicIP" - + "&vsysId=CONTRACT-VSYS00001" - + "&publicIp=123.45.67.89"); - HttpResponse response = HttpResponse.builder().statusCode(200) - .payload(payloadFromResource("/AttachPublicIP-response.xml")) - .build(); - - PublicIPAddressApi api = requestSendsResponse(request, response) - .getPublicIPAddressApi(); - - api.attach("CONTRACT-VSYS00001", "123.45.67.89"); - } - - public void testDetach() { - HttpRequest request = buildGETWithQuery("Action=DetachPublicIP" - + "&vsysId=CONTRACT-VSYS00001" - + "&publicIp=123.45.67.89"); - HttpResponse response = HttpResponse.builder().statusCode(200) - .payload(payloadFromResource("/DetachPublicIP-response.xml")) - .build(); - - PublicIPAddressApi api = requestSendsResponse(request, response) - .getPublicIPAddressApi(); - - api.detach("CONTRACT-VSYS00001", "123.45.67.89"); - } - - public void testFree() { - HttpRequest request = buildGETWithQuery("Action=FreePublicIP" - + "&vsysId=CONTRACT-VSYS00001" - + "&publicIp=123.45.67.89"); - HttpResponse response = HttpResponse.builder().statusCode(200) - .payload(payloadFromResource("/FreePublicIP-response.xml")) - .build(); - - PublicIPAddressApi api = requestSendsResponse(request, response) - .getPublicIPAddressApi(); - - api.free("CONTRACT-VSYS00001", "123.45.67.89"); - } - - public void testGetStatus() { - HttpRequest request = buildGETWithQuery("Action=GetPublicIPStatus" - + "&publicIp=123.45.67.89"); - HttpResponse response = HttpResponse.builder().statusCode(200) - .payload(payloadFromResource("/GetPublicIPStatus-response.xml")) - .build(); - - PublicIPAddressApi api = requestSendsResponse(request, response) - .getPublicIPAddressApi(); - - PublicIPStatus status = api.getStatus("123.45.67.89"); - assertEquals(status, PublicIPStatus.ATTACHED); - } - - public void testGet() { - HttpRequest request = buildGETWithQuery("Action=GetPublicIPAttributes" - + "&publicIp=123.45.67.89"); - HttpResponse response = HttpResponse.builder().statusCode(200) - .payload(payloadFromResource("/GetPublicIPAttributes-response.xml")) - .build(); - - PublicIPAddressApi api = requestSendsResponse(request, response) - .getPublicIPAddressApi(); - - PublicIP ip = api.get("123.45.67.89"); - - assertNotNull(ip, "ip"); - assertEquals(ip.getAddress(), "123.45.67.89"); - assertEquals(ip.getVersion(), PublicIP.Version.IPv4); - } - -} diff --git a/labs/fgcp/src/test/java/org/jclouds/fujitsu/fgcp/services/SystemTemplateApiExpectTest.java b/labs/fgcp/src/test/java/org/jclouds/fujitsu/fgcp/services/SystemTemplateApiExpectTest.java deleted file mode 100644 index f89fc9994a..0000000000 --- a/labs/fgcp/src/test/java/org/jclouds/fujitsu/fgcp/services/SystemTemplateApiExpectTest.java +++ /dev/null @@ -1,101 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.services; - -import static org.testng.Assert.assertNotNull; - -import org.jclouds.fujitsu.fgcp.domain.VSystemDescriptor; -import org.jclouds.http.HttpRequest; -import org.jclouds.http.HttpResponse; -import org.testng.annotations.Test; - -/** - * @author Dies Koper - */ -@Test(groups = "unit", testName = "SystemTemplateApiExpectTest", singleThreaded = true) -public class SystemTemplateApiExpectTest extends BaseFGCPRestApiExpectTest { - - public void testGet() { - HttpRequest request = buildGETWithQuery("Action=GetVSYSDescriptorConfiguration" - + "&vsysDescriptorId=3-tier%20Skeleton"); - HttpResponse response = HttpResponse - .builder() - .statusCode(200) - .payload( - payloadFromResource("/GetVSYSDescriptorConfiguration-response.xml")) - .build(); - SystemTemplateApi client = requestSendsResponse(request, response) - .getSystemTemplateApi(); - - VSystemDescriptor desc = client.get("3-tier Skeleton"); - assertNotNull(desc, "desc"); -// assertEquals(desc.) - } - - - public void testUpdate() { - HttpRequest request = buildGETWithQuery("Action=UpdateVSYSDescriptorAttribute" - + "&vsysDescriptorId=3-tier%20Skeleton" - + "&updateLcId=en" + "&attributeName=updateName" - + "&attributeValue=new-name"); - HttpResponse response = HttpResponse - .builder() - .statusCode(200) - .payload( - payloadFromResource("/UpdateVSYSDescriptorAttribute-response.xml")) - .build(); - - SystemTemplateApi api = requestSendsResponse(request, response) - .getSystemTemplateApi(); - - api.update("3-tier Skeleton", "en", "updateName", "new-name"); - } - - public void testDeregister() { - HttpRequest request = buildGETWithQuery("Action=UnregisterVSYSDescriptor" - + "&vsysDescriptorId=3-tier%20Skeleton"); - HttpResponse response = HttpResponse - .builder() - .statusCode(200) - .payload( - payloadFromResource("/UnregisterVSYSDescriptor-response.xml")) - .build(); - - SystemTemplateApi api = requestSendsResponse(request, response) - .getSystemTemplateApi(); - - api.deregister("3-tier Skeleton"); - } - - public void testDeregisterPrivateTemplate() { - HttpRequest request = buildGETWithQuery("Action=UnregisterPrivateVSYSDescriptor" - + "&vsysDescriptorId=3-tier%20Skeleton"); - HttpResponse response = HttpResponse - .builder() - .statusCode(200) - .payload( - payloadFromResource("/UnregisterPrivateVSYSDescriptor-response.xml")) - .build(); - - SystemTemplateApi api = requestSendsResponse(request, response) - .getSystemTemplateApi(); - - api.deregisterPrivateTemplate("3-tier Skeleton"); - } -} diff --git a/labs/fgcp/src/test/java/org/jclouds/fujitsu/fgcp/services/VirtualDCApiExpectTest.java b/labs/fgcp/src/test/java/org/jclouds/fujitsu/fgcp/services/VirtualDCApiExpectTest.java deleted file mode 100644 index 3f21b6c9c5..0000000000 --- a/labs/fgcp/src/test/java/org/jclouds/fujitsu/fgcp/services/VirtualDCApiExpectTest.java +++ /dev/null @@ -1,207 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.services; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertTrue; - -import java.util.Map; -import java.util.Set; - -import org.jclouds.fujitsu.fgcp.domain.AddressRange; -import org.jclouds.fujitsu.fgcp.domain.DiskImage; -import org.jclouds.fujitsu.fgcp.domain.EventLog; -import org.jclouds.fujitsu.fgcp.domain.PublicIP; -import org.jclouds.fujitsu.fgcp.domain.ServerType; -import org.jclouds.fujitsu.fgcp.domain.VSystem; -import org.jclouds.http.HttpRequest; -import org.jclouds.http.HttpResponse; -import org.testng.annotations.Test; - -/** - * @author Dies Koper - */ -@Test(groups = "unit", testName = "VirtualDCApiExpectTest", singleThreaded = true) -public class VirtualDCApiExpectTest extends BaseFGCPRestApiExpectTest { - - public void testListVirtualSystems() { - HttpRequest request = buildGETWithQuery("Action=ListVSYS"); - HttpResponse response = HttpResponse.builder() - .statusCode(200) - .payload(payloadFromResource("/ListVSYS-response.xml")) - .build(); - - VirtualDCApi api = requestSendsResponse(request, response).getVirtualDCApi(); - - Set vsysSet = api.listVirtualSystems(); - assertEquals(vsysSet.size(), 2); - } - - public void testCreateVirtualSystem() { - HttpRequest request = buildGETWithQuery("Action=CreateVSYS&vsysDescriptorId=myDescId&vsysName=myVSYS"); - HttpResponse response = HttpResponse.builder() - .statusCode(200) - .payload(payloadFromResource("/CreateVSYS-response.xml")) - .build(); - VirtualDCApi api = requestSendsResponse(request, response) - .getVirtualDCApi(); - - String vsysId = api.createVirtualSystem("myDescId", "myVSYS"); - assertEquals(vsysId, "CONTRACT-VSYS00001", "vsysId: " + vsysId); - } - - - public void testListServerTypes() { - HttpRequest request = buildGETWithQuery("Action=ListServerType&diskImageId=dummy"); - HttpResponse response = HttpResponse.builder() - .statusCode(200) - .payload(payloadFromResource("/ListServerType-response.xml")) - .build(); - VirtualDCApi api = requestSendsResponse(request, response) - .getVirtualDCApi(); - - Set serverTypes = api.listServerTypes(); - assertNotNull(serverTypes, "serverTypes"); - assertEquals(serverTypes.size(), 4, - "Unexpected number of server types: " + serverTypes.size()); - } - - public void testListPublicIPs() { - HttpRequest request = buildGETWithQuery("Action=ListPublicIP"); - HttpResponse response = HttpResponse.builder() - .statusCode(200) - .payload(payloadFromResource("/ListPublicIP-response.xml")) - .build(); - VirtualDCApi api = requestSendsResponse(request, response) - .getVirtualDCApi(); - - Map ips = api.listPublicIPs(); - - assertNotNull(ips, "ips"); - assertEquals(ips.size(), 2, "Unexpected number of ips: " + ips.size()); - assertEquals(ips.keySet().size(), 2, "Unexpected number of ips: " + ips.size()); - assertTrue(ips.containsValue("ABCDEFGH-A123B456CE"), "missing system id"); - assertEquals(ips.keySet().iterator().next().getVersion(), PublicIP.Version.IPv4); - } - - public void testListDiskImages() { - HttpRequest request = buildGETWithQuery("Action=ListDiskImage"); - HttpResponse response = HttpResponse.builder() - .statusCode(200) - .payload(payloadFromResource("/ListDiskImages-response.xml")) - .build(); - VirtualDCApi api = requestSendsResponse(request, response) - .getVirtualDCApi(); - - Set images = api.listDiskImages(); - - assertNotNull(images, "images"); - assertTrue(images.size() > 5, "Unexpected number of images: " + images.size()); - } - - public void testListDiskImage() { - HttpRequest request = buildGETWithQuery("Action=ListDiskImage&vsysDescriptorId=IMG_A1B2C3_1234567890ABCD"); - HttpResponse response = HttpResponse.builder() - .statusCode(200) - .payload(payloadFromResource("/ListDiskImage-response.xml")) - .build(); - VirtualDCApi api = requestSendsResponse(request, response) - .getVirtualDCApi(); - - Set images = api.listDiskImages(null, "IMG_A1B2C3_1234567890ABCD"); - - assertNotNull(images, "images"); - assertEquals(1, images.size(), "Unexpected number of images: " + images.size()); - } - - public void testGetAddressRange() { - HttpRequest request = buildGETWithQuery("Action=GetAddressRange"); - HttpResponse response = HttpResponse.builder() - .statusCode(200) - .payload(payloadFromResource("/GetAddressRange-response.xml")) - .build(); - VirtualDCApi api = requestSendsResponse(request, response) - .getVirtualDCApi(); - - Set range = api.getAddressRange(); - assertNotNull(range); - assertEquals(range.size(), 1); - } - - public void testAddAddressRange() { - HttpRequest request = buildGETWithQuery("Action=AddAddressRange" - + "&pipFrom=192.168.0.0" - + "&pipTo=192.168.30.0"); - HttpResponse response = HttpResponse.builder() - .statusCode(200) - .payload(payloadFromResource("/AddAddressRange-response.xml")) - .build(); - VirtualDCApi api = requestSendsResponse(request, response) - .getVirtualDCApi(); - - api.addAddressRange("192.168.0.0", "192.168.30.0"); - } - - public void testDeleteAddressRange() { - HttpRequest request = buildGETWithQuery("Action=DeleteAddressRange" - + "&pipFrom=192.168.0.0" - + "&pipTo=192.168.30.0"); - HttpResponse response = HttpResponse.builder() - .statusCode(200) - .payload(payloadFromResource("/DeleteAddressRange-response.xml")) - .build(); - VirtualDCApi api = requestSendsResponse(request, response) - .getVirtualDCApi(); - - api.deleteAddressRange("192.168.0.0", "192.168.30.0"); - } - - public void testCreateAddressPool() { - HttpRequest request = buildGETWithQuery("Action=CreateAddressPool" - + "&pipFrom=192.168.0.0" - + "&pipTo=192.168.30.0"); - HttpResponse response = HttpResponse.builder() - .statusCode(200) - .payload(payloadFromResource("/CreateAddressPool-response.xml")) - .build(); - VirtualDCApi api = requestSendsResponse(request, response) - .getVirtualDCApi(); - - api.createAddressPool("192.168.0.0", "192.168.30.0"); - } - - public void testGetEventLog() { - HttpRequest request = buildGETWithQuery("Action=GetEventLog"); - HttpResponse response = HttpResponse.builder() - .statusCode(200) - .payload(payloadFromResource("/GetEventLog-response.xml")) - .build(); - VirtualDCApi api = requestSendsResponse(request, response) - .getVirtualDCApi(); - - Set logs = api.getEventLogs(); - assertNotNull(logs); - //TODO: get one with several -// assertEquals(logs.size(), 1); - } - - - -} diff --git a/labs/fgcp/src/test/java/org/jclouds/fujitsu/fgcp/services/VirtualDCApiLiveTest.java b/labs/fgcp/src/test/java/org/jclouds/fujitsu/fgcp/services/VirtualDCApiLiveTest.java deleted file mode 100644 index 45fade92e7..0000000000 --- a/labs/fgcp/src/test/java/org/jclouds/fujitsu/fgcp/services/VirtualDCApiLiveTest.java +++ /dev/null @@ -1,78 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.services; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertTrue; - -import java.util.Set; - -import org.jclouds.fujitsu.fgcp.domain.ServerType; -import org.jclouds.fujitsu.fgcp.domain.VSystem; -import org.testng.annotations.BeforeGroups; -import org.testng.annotations.Test; - -/** - * @author Dies Koper - */ -@Test(groups = "live", enabled = true, singleThreaded = true, testName = "VirtualDCApiLiveTest") -public class VirtualDCApiLiveTest extends BaseFGCPApiLiveTest { - - private VirtualDCApi api; - - @BeforeGroups(groups = { "live" }) - public void setupContext() { - super.setupContext(); - api = fgcpContext.getApi().getVirtualDCApi(); - } - - public void testListVirtualSystems() { -/* Properties overrides = setupProperties(); - RestContext context = new RestContextFactory().createContext(provider, ImmutableSet. of(new Log4JLoggingModule()), - overrides);*/ - - Set vsysSet = api.listVirtualSystems(); - assertNotNull(vsysSet, "vsysSet"); - assertTrue(vsysSet.size() > 0, "vsysSet.size() should be greater than 0"); - for (VSystem vsys : vsysSet) { - System.out.println(vsys); - } - } - -/* public void testCreateVirtualSystem() { - String vsysId = api.createVirtualSystem("abc", "def"); - - assertNotNull(vsysId, "vsysId"); - assertNotEquals("", vsysId, "vsysId is empty (\"\")"); - System.out.println("vsysId: " + vsysId); - }*/ - - public void testListServerTypes() { - Set serverTypes = api.listServerTypes(); - - assertNotNull(serverTypes, "serverTypes"); - assertEquals(4, serverTypes.size(), "serverTypes.size should return 4, not " + serverTypes.size()); - -// System.out.println("listServerTypes: " + serverTypes); - } - - - -} diff --git a/labs/fgcp/src/test/java/org/jclouds/fujitsu/fgcp/services/VirtualServerApiExpectTest.java b/labs/fgcp/src/test/java/org/jclouds/fujitsu/fgcp/services/VirtualServerApiExpectTest.java deleted file mode 100644 index efc342ef2b..0000000000 --- a/labs/fgcp/src/test/java/org/jclouds/fujitsu/fgcp/services/VirtualServerApiExpectTest.java +++ /dev/null @@ -1,221 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.services; - -import static org.testng.Assert.assertEquals; -import static org.testng.AssertJUnit.assertNotNull; - -import org.jclouds.fujitsu.fgcp.domain.VServerStatus; -import org.jclouds.fujitsu.fgcp.domain.VServerWithDetails; -import org.jclouds.http.HttpRequest; -import org.jclouds.http.HttpResponse; -import org.testng.annotations.Test; - -/** - * @author Dies Koper - */ -@Test(groups = "unit", testName = "VirtualServerApiExpectTest", singleThreaded = true) -public class VirtualServerApiExpectTest extends BaseFGCPRestApiExpectTest { - - public void testStart() { - HttpRequest request = buildGETWithQuery("Action=StartVServer" - + "&vserverId=CONTRACT-VSYS00001-S-0005" - + "&vsysId=CONTRACT-VSYS00001"); - HttpResponse response = HttpResponse.builder().statusCode(200) - .payload(payloadFromResource("/StartVServer-response.xml")) - .build(); - - VirtualServerApi api = requestSendsResponse(request, response) - .getVirtualServerApi(); - - api.start("CONTRACT-VSYS00001-S-0005"); - } - - public void testStop() { - HttpRequest request = buildGETWithQuery("Action=StopVServer" - + "&vserverId=CONTRACT-VSYS00001-S-0005" - + "&vsysId=CONTRACT-VSYS00001"); - HttpResponse response = HttpResponse.builder().statusCode(200) - .payload(payloadFromResource("/StopVServer-response.xml")) - .build(); - - VirtualServerApi api = requestSendsResponse(request, response) - .getVirtualServerApi(); - - api.stop("CONTRACT-VSYS00001-S-0005"); - } - - public void testStopForcefully() { - HttpRequest request = buildGETWithQuery("Action=StopVServer" - + "&force=true" - + "&vserverId=CONTRACT-VSYS00001-S-0005" - + "&vsysId=CONTRACT-VSYS00001"); - HttpResponse response = HttpResponse.builder().statusCode(200) - .payload(payloadFromResource("/StopVServer-response.xml")) - .build(); - - VirtualServerApi api = requestSendsResponse(request, response) - .getVirtualServerApi(); - - api.stopForcefully("CONTRACT-VSYS00001-S-0005"); - } - - public void testDestroy() { - HttpRequest request = buildGETWithQuery("Action=DestroyVServer" - + "&vserverId=CONTRACT-VSYS00001-S-0005" - + "&vsysId=CONTRACT-VSYS00001"); - HttpResponse response = HttpResponse.builder().statusCode(200) - .payload(payloadFromResource("/DestroyVServer-response.xml")) - .build(); - - VirtualServerApi api = requestSendsResponse(request, response) - .getVirtualServerApi(); - - api.destroy("CONTRACT-VSYS00001-S-0005"); - } - - public void testGet() { - HttpRequest request = buildGETWithQuery("Action=GetVServerAttributes" - + "&vserverId=CONTRACT-VSYS00001-S-0005" - + "&vsysId=CONTRACT-VSYS00001"); - HttpResponse response = HttpResponse - .builder() - .statusCode(200) - .payload( - payloadFromResource("/GetVServerAttributes-response.xml")) - .build(); - - VirtualServerApi api = requestSendsResponse(request, response) - .getVirtualServerApi(); - - assertNotNull(api.get("CONTRACT-VSYS00001-S-0005")); - } - - public void testGetDetails() { - HttpRequest request = buildGETWithQuery("Action=GetVServerConfiguration" - + "&vserverId=CONTRACT-VSYS00001-S-0005" - + "&vsysId=CONTRACT-VSYS00001"); - HttpResponse response = HttpResponse - .builder() - .statusCode(200) - .payload( - payloadFromResource("/GetVServerConfiguration-response.xml")) - .build(); - - VirtualServerApi api = requestSendsResponse(request, response) - .getVirtualServerApi(); - - VServerWithDetails server = api.getDetails("CONTRACT-VSYS00001-S-0005"); - assertNotNull(server); - assertEquals(server.getId(), "CONTRACT-VSYS00001-S-0005"); - assertEquals(server.getVnics().iterator().next().getNicNo(), 0); - assertEquals(server.getVnics().iterator().next().getPrivateIp(), "192.168.4.13"); - assertEquals(server.getVnics().iterator().next().getNetworkId(), "CONTRACT-VSYS00001-N-DMZ"); - assertEquals(server.getImage().getId(), "IMG_A1B2C3_1234567890ABCD"); - assertEquals(server.getImage().getSysvolSize(), 10.0f); - } - - public void testGetStatus() { - HttpRequest request = buildGETWithQuery("Action=GetVServerStatus" - + "&vserverId=CONTRACT-VSYS00001-S-0005" - + "&vsysId=CONTRACT-VSYS00001"); - HttpResponse response = HttpResponse - .builder() - .statusCode(200) - .payload( - payloadFromResource("/GetVServerStatus-response.xml")) - .build(); - - VirtualServerApi api = requestSendsResponse(request, response) - .getVirtualServerApi(); - - assertEquals(api.getStatus("CONTRACT-VSYS00001-S-0005"), VServerStatus.STOPPED); - } - - public void testInitialPassword() { - HttpRequest request = buildGETWithQuery("Action=GetVServerInitialPassword" - + "&vserverId=CONTRACT-VSYS00001-S-0005" - + "&vsysId=CONTRACT-VSYS00001"); - HttpResponse response = HttpResponse - .builder() - .statusCode(200) - .payload( - payloadFromResource("/GetVServerInitialPassword-response.xml")) - .build(); - - VirtualServerApi api = requestSendsResponse(request, response) - .getVirtualServerApi(); - - assertEquals(api.getInitialPassword("CONTRACT-VSYS00001-S-0005"), "mySecretpwd1"); - } - - public void testUpdate() { - HttpRequest request = buildGETWithQuery("Action=UpdateVServerAttribute" - + "&vserverId=CONTRACT-VSYS00001-S-0005" - + "&attributeName=vserverName" - + "&attributeValue=new%20name" - + "&vsysId=CONTRACT-VSYS00001"); - HttpResponse response = HttpResponse - .builder() - .statusCode(200) - .payload( - payloadFromResource("/UpdateVServerAttribute-response.xml")) - .build(); - - VirtualServerApi api = requestSendsResponse(request, response) - .getVirtualServerApi(); - - api.update("CONTRACT-VSYS00001-S-0005", "vserverName", "new name"); - } - - public void testAttachDisk() { - HttpRequest request = buildGETWithQuery("Action=AttachVDisk" - + "&vserverId=CONTRACT-VSYS00001-S-0005" - + "&vdiskId=CONTRACT-VSYS00001-D-0001" - + "&vsysId=CONTRACT-VSYS00001"); - HttpResponse response = HttpResponse.builder().statusCode(200) - .payload(payloadFromResource("/AttachVDisk-response.xml")) - .build(); - - VirtualServerApi api = requestSendsResponse(request, response) - .getVirtualServerApi(); - - api.attachDisk("CONTRACT-VSYS00001-S-0005", "CONTRACT-VSYS00001-D-0001"); - } - -/* public void testGetPerformanceInformation() { - HttpRequest request = buildGETWithQuery("Action=GetPerformanceInformation" - + "&serverId=CONTRACT-VSYS00001-S-0005" - + "&interval=10minute" - + "&vsysId=CONTRACT-VSYS00001"); - HttpResponse response = HttpResponse - .builder() - .statusCode(200) - .payload( - payloadFromResource("/GetPerformanceInformation-response.xml")) - .build(); - - VirtualServerApi api = requestSendsResponse(request, response) - .getVirtualServerApi(); - - assertNotNull(api.getPerformanceInformation( - "CONTRACT-VSYS00001-S-0005", "10minute")); - } -*/ -} diff --git a/labs/fgcp/src/test/java/org/jclouds/fujitsu/fgcp/services/VirtualSystemApiExpectTest.java b/labs/fgcp/src/test/java/org/jclouds/fujitsu/fgcp/services/VirtualSystemApiExpectTest.java deleted file mode 100644 index 97b9c8cb8e..0000000000 --- a/labs/fgcp/src/test/java/org/jclouds/fujitsu/fgcp/services/VirtualSystemApiExpectTest.java +++ /dev/null @@ -1,257 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.fujitsu.fgcp.services; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; - -import java.util.Set; - -import org.jclouds.fujitsu.fgcp.domain.BuiltinServer; -import org.jclouds.fujitsu.fgcp.domain.PublicIP; -import org.jclouds.fujitsu.fgcp.domain.VDisk; -import org.jclouds.fujitsu.fgcp.domain.VServer; -import org.jclouds.fujitsu.fgcp.domain.VSystem; -import org.jclouds.fujitsu.fgcp.domain.VSystemStatus; -import org.jclouds.http.HttpRequest; -import org.jclouds.http.HttpResponse; -import org.testng.annotations.Test; - -/** - * @author Dies Koper - */ -@Test(groups = "unit", testName = "VirtualSystemApiExpectTest", singleThreaded = true) -public class VirtualSystemApiExpectTest extends BaseFGCPRestApiExpectTest { - - public void testGet() { - HttpRequest request = buildGETWithQuery("Action=GetVSYSAttributes&vsysId=ABCDEFGH-A123B456CE"); - HttpResponse response = HttpResponse - .builder() - .statusCode(200) - .payload( - payloadFromResource("/GetVSYSAttributes-response.xml")) - .build(); - VirtualSystemApi api = requestSendsResponse(request, response) - .getVirtualSystemApi(); - - VSystem system = api.get("ABCDEFGH-A123B456CE"); - assertNotNull(system, "system"); - } - - public void testGetDetails() { - HttpRequest request = buildGETWithQuery("Action=GetVSYSConfiguration&vsysId=ABCDEFGH-A123B456CE"); - HttpResponse response = HttpResponse - .builder() - .statusCode(200) - .payload( - payloadFromResource("/GetVSYSConfiguration-response.xml")) - .build(); - VirtualSystemApi api = requestSendsResponse(request, response) - .getVirtualSystemApi(); - - VSystem system = api.getDetails("ABCDEFGH-A123B456CE"); - assertNotNull(system, "system"); - } - - public void testGetStatus() { - HttpRequest request = buildGETWithQuery("Action=GetVSYSStatus" - + "&vsysId=ABCDEFGH-A123B456CE"); - HttpResponse response = HttpResponse.builder().statusCode(200) - .payload(payloadFromResource("/GetVSYSStatus-response.xml")) - .build(); - VirtualSystemApi api = requestSendsResponse(request, response) - .getVirtualSystemApi(); - - assertEquals(api.getStatus("ABCDEFGH-A123B456CE"), VSystemStatus.NORMAL); - } - - public void testUpdate() { - HttpRequest request = buildGETWithQuery("Action=UpdateVSYSAttribute" - + "&vsysId=ABCDEFGH-A123B456CE" - + "&attributeName=updateName" + "&attributeValue=new-name"); - HttpResponse response = HttpResponse - .builder() - .statusCode(200) - .payload( - payloadFromResource("/UpdateVDiskAttribute-response.xml")) - .build(); - - VirtualSystemApi api = requestSendsResponse(request, response) - .getVirtualSystemApi(); - - api.update("ABCDEFGH-A123B456CE", "updateName", "new-name"); - } - - public void testListPublicIPs() { - HttpRequest request = buildGETWithQuery("Action=ListPublicIP" - + "&vsysId=ABCDEFGH-A123B456CE"); - HttpResponse response = HttpResponse - .builder() - .statusCode(200) - .payload( - payloadFromResource("/ListPublicIP_one_vsys-response.xml")) - .build(); - VirtualSystemApi api = requestSendsResponse(request, response) - .getVirtualSystemApi(); - - Set ips = api.listPublicIPs("ABCDEFGH-A123B456CE"); - assertNotNull(ips, "ips"); - assertEquals(2, ips.size(), "Unexpected number of ips: " + ips.size()); - assertEquals(ips.iterator().next().getVersion(), PublicIP.Version.IPv4); - } - - public void testListServers() { - HttpRequest request = buildGETWithQuery("Action=ListVServer" - + "&vsysId=ABCDEFGH-A123B456CE"); - HttpResponse response = HttpResponse - .builder() - .statusCode(200) - .payload( - payloadFromResource("/ListVServer-response.xml")) - .build(); - VirtualSystemApi api = requestSendsResponse(request, response) - .getVirtualSystemApi(); - - Set servers = api.listServers("ABCDEFGH-A123B456CE"); - assertNotNull(servers, "servers"); - assertEquals(servers.size(), 2); - } - - public void testDisks() { - HttpRequest request = buildGETWithQuery("Action=ListVDisk" - + "&vsysId=ABCDEFGH-A123B456CE"); - HttpResponse response = HttpResponse - .builder() - .statusCode(200) - .payload( - payloadFromResource("/ListVDisk-response.xml")) - .build(); - VirtualSystemApi api = requestSendsResponse(request, response) - .getVirtualSystemApi(); - - Set disks = api.listDisks("ABCDEFGH-A123B456CE"); - assertNotNull(disks, "disks"); - assertEquals(disks.size(), 1); - } - - public void testListBuiltinServers() { - HttpRequest request = buildGETWithQuery("Action=ListEFM" - + "&vsysId=ABCDEFGH-A123B456CE" + "&efmType=FW"); - HttpResponse response = HttpResponse - .builder() - .statusCode(200) - .payload( - payloadFromResource("/ListEFM-response.xml")) - .build(); - VirtualSystemApi api = requestSendsResponse(request, response) - .getVirtualSystemApi(); - - Set fws = api.listBuiltinServers("ABCDEFGH-A123B456CE", "FW"); - assertNotNull(fws, "fws"); - assertEquals(fws.size(), 1); - } - - public void testAllocatePublicIP() { - HttpRequest request = buildGETWithQuery("Action=AllocatePublicIP&vsysId=ABCDEFGH-A123B456CE"); - HttpResponse response = HttpResponse - .builder() - .statusCode(200) - .payload( - payloadFromResource("/AllocatePublicIP-response.xml")) - .build(); - VirtualSystemApi api = requestSendsResponse(request, response) - .getVirtualSystemApi(); - - api.allocatePublicIP("ABCDEFGH-A123B456CE"); - } - - public void testCreateBuiltinServer() { - HttpRequest request = buildGETWithQuery("Action=CreateEFM" - + "&efmType=SLB" - + "&efmName=web%20load%20balancer" - + "&networkId=ABCDEFGH-A123B456CE-N-DMZ" - + "&vsysId=ABCDEFGH-A123B456CE"); - HttpResponse response = HttpResponse - .builder() - .statusCode(200) - .payload( - payloadFromResource("/CreateEFM-response.xml")) - .build(); - VirtualSystemApi api = requestSendsResponse(request, response) - .getVirtualSystemApi(); - - String id = api.createBuiltinServer("web load balancer", - "ABCDEFGH-A123B456CE-N-DMZ"); - assertEquals(id, "CONTRACT-EFM00001"); - } - - public void testCreateServer() { - HttpRequest request = buildGETWithQuery("Action=CreateVServer" - + "&vserverName=vm1" - + "&vserverType=economy" - + "&diskImageId=IMG_A1B2C3_1234567890ABCD" - + "&networkId=ABCDEFGH-A123B456CE-N-DMZ" - + "&vsysId=ABCDEFGH-A123B456CE"); - HttpResponse response = HttpResponse - .builder() - .statusCode(200) - .payload( - payloadFromResource("/CreateVServer-response.xml")) - .build(); - VirtualSystemApi api = requestSendsResponse(request, response) - .getVirtualSystemApi(); - - String id = api.createServer("vm1", "economy", "IMG_A1B2C3_1234567890ABCD", - "ABCDEFGH-A123B456CE-N-DMZ"); - assertEquals(id, "ABCDEFGH-A123B456CE-S-0007"); - } - - public void testCreateDisk() { - HttpRequest request = buildGETWithQuery("Action=CreateVDisk" - + "&vsysId=ABCDEFGH-A123B456CE" + "&vdiskName=disk1" - + "&size=10"); - HttpResponse response = HttpResponse - .builder() - .statusCode(200) - .payload( - payloadFromResource("/CreateVDisk-response.xml")) - .build(); - VirtualSystemApi api = requestSendsResponse(request, response) - .getVirtualSystemApi(); - - String id = api.createDisk("ABCDEFGH-A123B456CE", "disk1", 10); - assertEquals(id, "ABCDEFGH-A123B456CE-S-0006"); - } - -/* - public void testRegisterAsPrivateImage() { - HttpRequest request = buildGETWithQuery("Action=AllocatePublicIP&vsysId=ABCDEFGH-A123B456CE"); - HttpResponse response = HttpResponse - .builder() - .statusCode(200) - .payload( - payloadFromResource("/AllocatePublicIP-response.xml")) - .build(); - VirtualSystemApi api = requestSendsResponse(request, response) - .getVirtualSystemApi(); - - api.registerAsPrivateVSYSDescriptor("ABCDEFGH-A123B456CE"); - } -*/ -} diff --git a/labs/fgcp/src/test/java/org/jclouds/http/internal/HttpInternalsLiveTest.java b/labs/fgcp/src/test/java/org/jclouds/http/internal/HttpInternalsLiveTest.java deleted file mode 100644 index e600072a1c..0000000000 --- a/labs/fgcp/src/test/java/org/jclouds/http/internal/HttpInternalsLiveTest.java +++ /dev/null @@ -1,38 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.http.internal; - -import static org.testng.Assert.assertNotNull; - -import org.jclouds.fujitsu.fgcp.services.BaseFGCPApiLiveTest; -import org.testng.annotations.Test; - -/** - * Created by IntelliJ IDEA. - * - * @author Dies Koper - */ -@Test(groups = "live", enabled = true, singleThreaded = true, testName = "HttpInternalsLiveTest") -public class HttpInternalsLiveTest extends BaseFGCPApiLiveTest { - - @Test - public void testTrustedSSLContext() { - assertNotNull(context.utils().injector().getInstance(JavaUrlHttpCommandExecutorService.class).sslContextSupplier); - } -} diff --git a/labs/fgcp/src/test/resources/certs/jclouds-test-fgcp.p12 b/labs/fgcp/src/test/resources/certs/jclouds-test-fgcp.p12 deleted file mode 100644 index 6ff57866ca..0000000000 Binary files a/labs/fgcp/src/test/resources/certs/jclouds-test-fgcp.p12 and /dev/null differ diff --git a/labs/fgcp/src/test/resources/certs/jclouds-test-fgcp.pem b/labs/fgcp/src/test/resources/certs/jclouds-test-fgcp.pem deleted file mode 100644 index 33da39687a..0000000000 --- a/labs/fgcp/src/test/resources/certs/jclouds-test-fgcp.pem +++ /dev/null @@ -1,35 +0,0 @@ -Bag Attributes - friendlyName: test-fgcp - localKeyID: 54 69 6D 65 20 31 33 32 36 36 38 34 30 33 32 34 35 31 -Key Attributes: ------BEGIN RSA PRIVATE KEY----- -MIICXAIBAAKBgQCHj9j4voqoMfTVvsAUjxoJYCz9cXpmRzkPwoxOOP99bc+xnIEe -K8jOVrlCy0Zwr0fr+PZT15RX8tAzg69kP7WLiVBqYeW7TKZ+9b+HgxUvDd6aaj1C -SVdgHyQPmpcBLe2E2ADvbeEWYFiqhm5ms8Qes/Hb7S5Ct/Ux4R9UUrDnYQIDAQAB -AoGABkxrs1r/DEON8aR0PkBL4GWkkX4FRt1GTHIonLXPQR+qB8GSyjkUkmm7H9xc -AH5UZCVkJI8eqFtyywHyU0EWiTyd3pjkXIuWPcmtydTN3LwY6UZww07g7cAjQNsw -cSXDXfmpAWNoavJWsjd7EUQ1VnnJMDo8A3Jj8BgvF7mTlZUCQQDdMmmOJNBRmbZP -i9jfuggupIHNoJEyI8hQM1LQdyDYMojFZ/hz09vzuWzO1J4XpHtCa2Vuxq9hvC5R -6jKmcTI3AkEAnOQkvv2/2x7T6+7zx53xqFuGjHeNjuaHqTENoT2Gh0oug4IX0HPE -PTw9yVDqDCQe72jeSZZDLpejdF9tcyNHJwJBAIOkC/PfbucRXtGqfdBwK4xutR2G -UMMRTpaEZOXR8Aca1BD/1npAfKdpFBtnqAqUBhM6TSyHLDszPjHb+nbZ6TMCQGEM -Mrq9xd6qDBbmQX+Z8LDepLThAvyBFyuOP0sc/slTFsCcSVTVN29VgzazSYNnGIep -S88jFr2MaTyEBvTwvoMCQE9ZWyYcmpkHxH5X5j6Bpf+ksY6eLnlH/YSOa9Hw8vZY -SR2RvvhAa4UovUoyYJ3p0U/pO/h/W0p5TxIA3V+y7CY= ------END RSA PRIVATE KEY----- -Bag Attributes - friendlyName: CN=localhost - localKeyID: 54 69 6D 65 20 31 33 32 36 36 38 34 30 33 32 34 35 31 -subject=/CN=localhost -issuer=/CN=localhost ------BEGIN CERTIFICATE----- -MIIBnzCCAQigAwIBAgIETxOXgDANBgkqhkiG9w0BAQUFADAUMRIwEAYDVQQDEwls -b2NhbGhvc3QwHhcNMTIwMTE2MDMyMDMyWhcNMjcwMTEyMDMyMDMyWjAUMRIwEAYD -VQQDEwlsb2NhbGhvc3QwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAIeP2Pi+ -iqgx9NW+wBSPGglgLP1xemZHOQ/CjE44/31tz7GcgR4ryM5WuULLRnCvR+v49lPX -lFfy0DODr2Q/tYuJUGph5btMpn71v4eDFS8N3ppqPUJJV2AfJA+alwEt7YTYAO9t -4RZgWKqGbmazxB6z8dvtLkK39THhH1RSsOdhAgMBAAEwDQYJKoZIhvcNAQEFBQAD -gYEANbfXtBVCUIZiQCU5LP/vKoKZMpE5X6s+kDqTJ3vntuczkN0qFWKIi9WABwAa -/Aq2IffJIu6rZgWchJqhN7+PeVOTfh9xRWE7QFHDrsuBYaicrki7RB1kKCQLtUpD -aZB5xlm5FhT2Hzkgkawdo5keD/+OcDqKVK2fEK8W6r61Spc= ------END CERTIFICATE----- diff --git a/labs/fgcp/src/test/resources/log4j.xml b/labs/fgcp/src/test/resources/log4j.xml deleted file mode 100644 index eb276c1631..0000000000 --- a/labs/fgcp/src/test/resources/log4j.xml +++ /dev/null @@ -1,194 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/labs/fgcp/src/test/resources/logback.xml b/labs/fgcp/src/test/resources/logback.xml deleted file mode 100644 index a4a6a3f2c0..0000000000 --- a/labs/fgcp/src/test/resources/logback.xml +++ /dev/null @@ -1,64 +0,0 @@ - - - - target/test-data/jclouds.log - - - %d %-5p [%c] [%thread] %m%n - - - - - target/test-data/jclouds-wire.log - - - %d %-5p [%c] [%thread] %m%n - - - - - target/test-data/jclouds-compute.log - - - %d %-5p [%c] [%thread] %m%n - - - - - target/test-data/jclouds-ssh.log - - - %d %-5p [%c] [%thread] %m%n - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/labs/fgcp/src/test/resources/requests/CreateVSYS-request.xml b/labs/fgcp/src/test/resources/requests/CreateVSYS-request.xml deleted file mode 100644 index 8dd318b518..0000000000 --- a/labs/fgcp/src/test/resources/requests/CreateVSYS-request.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - CreateVSYS - myDescId - myVSYS - 2011-01-31 - en - R01ULTA5OjAwJjEyMzQ1Njc4OTAmMS4wJlNIQTF3aXRoUlNB - G2rGfLAkbq0IURQfXIWYxj3BnMGbjRk4KPnZLAze3Lt4SMMRt8lkjqKvR5Cm+nFpDN7J6IprVCCsIrRq5BqPeXT6xtWyb6qMNds2BAr1h/JePGs0UosOh2tgPUMSFlZwLVjgNyrSa2zeHA3AEHjF6H1jqcWXXqfCAD4SOHaNavk= - \ No newline at end of file diff --git a/labs/fgcp/src/test/resources/responses/AddAddressRange-response.xml b/labs/fgcp/src/test/resources/responses/AddAddressRange-response.xml deleted file mode 100644 index 81265be495..0000000000 --- a/labs/fgcp/src/test/resources/responses/AddAddressRange-response.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - Processing was completed. - SUCCESS - \ No newline at end of file diff --git a/labs/fgcp/src/test/resources/responses/AllocatePublicIP-response.xml b/labs/fgcp/src/test/resources/responses/AllocatePublicIP-response.xml deleted file mode 100644 index 4411beb9f6..0000000000 --- a/labs/fgcp/src/test/resources/responses/AllocatePublicIP-response.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - Processing was completed. - SUCCESS - \ No newline at end of file diff --git a/labs/fgcp/src/test/resources/responses/AttachPublicIP-response.xml b/labs/fgcp/src/test/resources/responses/AttachPublicIP-response.xml deleted file mode 100644 index bcc457fb19..0000000000 --- a/labs/fgcp/src/test/resources/responses/AttachPublicIP-response.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - Processing was completed. - SUCCESS - \ No newline at end of file diff --git a/labs/fgcp/src/test/resources/responses/AttachVDisk-response.xml b/labs/fgcp/src/test/resources/responses/AttachVDisk-response.xml deleted file mode 100644 index 0a385835ef..0000000000 --- a/labs/fgcp/src/test/resources/responses/AttachVDisk-response.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - Processing was completed. - SUCCESS - \ No newline at end of file diff --git a/labs/fgcp/src/test/resources/responses/BackupEFM-response.xml b/labs/fgcp/src/test/resources/responses/BackupEFM-response.xml deleted file mode 100644 index 39e69e3475..0000000000 --- a/labs/fgcp/src/test/resources/responses/BackupEFM-response.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - Processing was completed. - SUCCESS - \ No newline at end of file diff --git a/labs/fgcp/src/test/resources/responses/BackupVDisk-response.xml b/labs/fgcp/src/test/resources/responses/BackupVDisk-response.xml deleted file mode 100644 index 0018289051..0000000000 --- a/labs/fgcp/src/test/resources/responses/BackupVDisk-response.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - Processing was completed. - SUCCESS - \ No newline at end of file diff --git a/labs/fgcp/src/test/resources/responses/CreateAddressPool-response.xml b/labs/fgcp/src/test/resources/responses/CreateAddressPool-response.xml deleted file mode 100644 index 17988f5571..0000000000 --- a/labs/fgcp/src/test/resources/responses/CreateAddressPool-response.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - Processing was completed. - SUCCESS - \ No newline at end of file diff --git a/labs/fgcp/src/test/resources/responses/CreateEFM-response.xml b/labs/fgcp/src/test/resources/responses/CreateEFM-response.xml deleted file mode 100644 index bd20f9a2b0..0000000000 --- a/labs/fgcp/src/test/resources/responses/CreateEFM-response.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - Processing was completed. - SUCCESS - CONTRACT-EFM00001 - \ No newline at end of file diff --git a/labs/fgcp/src/test/resources/responses/CreateVDisk-response.xml b/labs/fgcp/src/test/resources/responses/CreateVDisk-response.xml deleted file mode 100644 index ae7d8a31e4..0000000000 --- a/labs/fgcp/src/test/resources/responses/CreateVDisk-response.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - Processing was completed. - SUCCESS - ABCDEFGH-A123B456CE-S-0006 - \ No newline at end of file diff --git a/labs/fgcp/src/test/resources/responses/CreateVSYS-response.xml b/labs/fgcp/src/test/resources/responses/CreateVSYS-response.xml deleted file mode 100644 index 425cbc76f9..0000000000 --- a/labs/fgcp/src/test/resources/responses/CreateVSYS-response.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - Processing was completed. - SUCCESS - CONTRACT-VSYS00001 - \ No newline at end of file diff --git a/labs/fgcp/src/test/resources/responses/CreateVServer-response.xml b/labs/fgcp/src/test/resources/responses/CreateVServer-response.xml deleted file mode 100644 index 81c51b985d..0000000000 --- a/labs/fgcp/src/test/resources/responses/CreateVServer-response.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - Processing was completed. - SUCCESS - ABCDEFGH-A123B456CE-S-0007 - \ No newline at end of file diff --git a/labs/fgcp/src/test/resources/responses/DeleteAddressRange-response.xml b/labs/fgcp/src/test/resources/responses/DeleteAddressRange-response.xml deleted file mode 100644 index e3cdd50388..0000000000 --- a/labs/fgcp/src/test/resources/responses/DeleteAddressRange-response.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - Processing was completed. - SUCCESS - \ No newline at end of file diff --git a/labs/fgcp/src/test/resources/responses/DestroyEFM-response.xml b/labs/fgcp/src/test/resources/responses/DestroyEFM-response.xml deleted file mode 100644 index aa8e374d0f..0000000000 --- a/labs/fgcp/src/test/resources/responses/DestroyEFM-response.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - Processing was completed. - SUCCESS - \ No newline at end of file diff --git a/labs/fgcp/src/test/resources/responses/DestroyEFMBackup-response.xml b/labs/fgcp/src/test/resources/responses/DestroyEFMBackup-response.xml deleted file mode 100644 index a2da3c49ba..0000000000 --- a/labs/fgcp/src/test/resources/responses/DestroyEFMBackup-response.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - Processing was completed. - SUCCESS - \ No newline at end of file diff --git a/labs/fgcp/src/test/resources/responses/DestroyVDisk-response.xml b/labs/fgcp/src/test/resources/responses/DestroyVDisk-response.xml deleted file mode 100644 index c66a6a9600..0000000000 --- a/labs/fgcp/src/test/resources/responses/DestroyVDisk-response.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - Processing was completed. - SUCCESS - \ No newline at end of file diff --git a/labs/fgcp/src/test/resources/responses/DestroyVDiskBackup-response.xml b/labs/fgcp/src/test/resources/responses/DestroyVDiskBackup-response.xml deleted file mode 100644 index af0088facd..0000000000 --- a/labs/fgcp/src/test/resources/responses/DestroyVDiskBackup-response.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - Processing was completed. - SUCCESS - \ No newline at end of file diff --git a/labs/fgcp/src/test/resources/responses/DestroyVServer-response.xml b/labs/fgcp/src/test/resources/responses/DestroyVServer-response.xml deleted file mode 100644 index c9fbbd2702..0000000000 --- a/labs/fgcp/src/test/resources/responses/DestroyVServer-response.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - Processing was completed. - SUCCESS - \ No newline at end of file diff --git a/labs/fgcp/src/test/resources/responses/DetachPublicIP-response.xml b/labs/fgcp/src/test/resources/responses/DetachPublicIP-response.xml deleted file mode 100644 index ee99b2e3fe..0000000000 --- a/labs/fgcp/src/test/resources/responses/DetachPublicIP-response.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - Processing was completed. - SUCCESS - \ No newline at end of file diff --git a/labs/fgcp/src/test/resources/responses/DetachVDisk-response.xml b/labs/fgcp/src/test/resources/responses/DetachVDisk-response.xml deleted file mode 100644 index 877cb7423c..0000000000 --- a/labs/fgcp/src/test/resources/responses/DetachVDisk-response.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - Processing was completed. - SUCCESS - \ No newline at end of file diff --git a/labs/fgcp/src/test/resources/responses/FreePublicIP-response.xml b/labs/fgcp/src/test/resources/responses/FreePublicIP-response.xml deleted file mode 100644 index 7644e11a2b..0000000000 --- a/labs/fgcp/src/test/resources/responses/FreePublicIP-response.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - Processing was completed. - SUCCESS - \ No newline at end of file diff --git a/labs/fgcp/src/test/resources/responses/GetAddressRange-response.xml b/labs/fgcp/src/test/resources/responses/GetAddressRange-response.xml deleted file mode 100644 index 2eb92bdf74..0000000000 --- a/labs/fgcp/src/test/resources/responses/GetAddressRange-response.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - 192.168.0.0 - MANUAL - 192.168.255.255 - - - Processing was completed. - SUCCESS - diff --git a/labs/fgcp/src/test/resources/responses/GetDiskImageAttributes-response.xml b/labs/fgcp/src/test/resources/responses/GetDiskImageAttributes-response.xml deleted file mode 100644 index 044d31df9a..0000000000 --- a/labs/fgcp/src/test/resources/responses/GetDiskImageAttributes-response.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - ABCDEFGH - - IMG_A1B2C3_1234567890ABCD - CentOS 6.0 64bit(EN) - - CentOS 6.0 64bit (English) - pv - ABCDEFGH - 10.0 - - Processing was completed. - SUCCESS - diff --git a/labs/fgcp/src/test/resources/responses/GetEFMAttributes-response.xml b/labs/fgcp/src/test/resources/responses/GetEFMAttributes-response.xml deleted file mode 100644 index 02f7bfeda4..0000000000 --- a/labs/fgcp/src/test/resources/responses/GetEFMAttributes-response.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - CONTRACT-VSYS00001 - CONTRACT-VSYS00001-S-0001 - Firewall - FW - - Processing was completed. - SUCCESS - diff --git a/labs/fgcp/src/test/resources/responses/GetEFMStatus-response.xml b/labs/fgcp/src/test/resources/responses/GetEFMStatus-response.xml deleted file mode 100644 index 960d939374..0000000000 --- a/labs/fgcp/src/test/resources/responses/GetEFMStatus-response.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - Processing was completed. - SUCCESS - RUNNING - \ No newline at end of file diff --git a/labs/fgcp/src/test/resources/responses/GetEventLog-response.xml b/labs/fgcp/src/test/resources/responses/GetEventLog-response.xml deleted file mode 100644 index 6d757f99d7..0000000000 --- a/labs/fgcp/src/test/resources/responses/GetEventLog-response.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - Processing was completed. - SUCCESS - \ No newline at end of file diff --git a/labs/fgcp/src/test/resources/responses/GetPerformanceInformation-response.xml b/labs/fgcp/src/test/resources/responses/GetPerformanceInformation-response.xml deleted file mode 100644 index f34995aea8..0000000000 --- a/labs/fgcp/src/test/resources/responses/GetPerformanceInformation-response.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - 10minute - Processing was completed. - SUCCESS - CONTRACT-VSYS00001-S-0001 - my server - GENERAL - \ No newline at end of file diff --git a/labs/fgcp/src/test/resources/responses/GetPublicIPAttributes-response.xml b/labs/fgcp/src/test/resources/responses/GetPublicIPAttributes-response.xml deleted file mode 100644 index c9cc6397a1..0000000000 --- a/labs/fgcp/src/test/resources/responses/GetPublicIPAttributes-response.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - -

123.45.67.89
- IPv4 -
- - Processing was completed. - SUCCESS - \ No newline at end of file diff --git a/labs/fgcp/src/test/resources/responses/GetPublicIPStatus-response.xml b/labs/fgcp/src/test/resources/responses/GetPublicIPStatus-response.xml deleted file mode 100644 index d8eb549cc6..0000000000 --- a/labs/fgcp/src/test/resources/responses/GetPublicIPStatus-response.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - ATTACHED - Processing was completed. - SUCCESS - \ No newline at end of file diff --git a/labs/fgcp/src/test/resources/responses/GetVDiskAttributes-response.xml b/labs/fgcp/src/test/resources/responses/GetVDiskAttributes-response.xml deleted file mode 100644 index b0faecc099..0000000000 --- a/labs/fgcp/src/test/resources/responses/GetVDiskAttributes-response.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - Processing was completed. - SUCCESS - - CONTRACT-VSYS00001-D-0001 - CONTRACT - 10.0 - CONTRACT-VSYS00001-S-0006 - disk1 - - \ No newline at end of file diff --git a/labs/fgcp/src/test/resources/responses/GetVDiskStatus-response.xml b/labs/fgcp/src/test/resources/responses/GetVDiskStatus-response.xml deleted file mode 100644 index 5a0709ad48..0000000000 --- a/labs/fgcp/src/test/resources/responses/GetVDiskStatus-response.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - Processing was completed. - SUCCESS - STOPPED - \ No newline at end of file diff --git a/labs/fgcp/src/test/resources/responses/GetVSYSAttributes-response.xml b/labs/fgcp/src/test/resources/responses/GetVSYSAttributes-response.xml deleted file mode 100644 index 8f1044f249..0000000000 --- a/labs/fgcp/src/test/resources/responses/GetVSYSAttributes-response.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - Processing was completed. - SUCCESS - - 2-tier Skeleton - ABCDEFGH - 2-tier Skeleton - ABCDEFGH-I123J456K - my virtual system - - diff --git a/labs/fgcp/src/test/resources/responses/GetVSYSConfiguration-response.xml b/labs/fgcp/src/test/resources/responses/GetVSYSConfiguration-response.xml deleted file mode 100644 index ca01590dc0..0000000000 --- a/labs/fgcp/src/test/resources/responses/GetVSYSConfiguration-response.xml +++ /dev/null @@ -1,78 +0,0 @@ - - - Processing was completed. - SUCCESS - - 2-tier Skeleton - NONE - ABCDEFGH - 2-tier Skeleton - - - ABCDEFGH - 10.0 - ABCDEFGH-I123J456K-D-0001 - DISK1 - - - - - ABCDEFGH-I123J456K-N-DMZ - - - ABCDEFGH-I123J456K-N-SECURE1 - - - - - ABCDEFGH - IMG_A1B2C3_1234567890ABCD - - - ABCDEFGH-I123J456K-N-DMZ - 4 - 192.168.32.11 - - - ABCDEFGH-I123J456K-N-SECURE1 - 5 - 192.168.33.11 - - - ABCDEFGH-I123J456K-S-0001 - Firewall - economy - - - ABCDEFGH - IMG_A1B2C3_1234567890ABCD - - - ABCDEFGH-I123J456K-N-DMZ - 0 - 192.168.32.13 - - - ABCDEFGH-I123J456K-S-0003 - CentOS 6.3 32bit(EN)1 - economy - - - ABCDEFGH - IMG_A1B2C3_1234567890ABCD - - - ABCDEFGH-I123J456K-N-SECURE1 - 0 - 192.168.33.12 - - - ABCDEFGH-I123J456K-S-0004 - CentOS 6.3 32bit(EN)2 - economy - - - ABCDEFGH-I123J456K - system 2 - - \ No newline at end of file diff --git a/labs/fgcp/src/test/resources/responses/GetVSYSDescriptorConfiguration-response.xml b/labs/fgcp/src/test/resources/responses/GetVSYSDescriptorConfiguration-response.xml deleted file mode 100644 index 5fa9adbcf7..0000000000 --- a/labs/fgcp/src/test/resources/responses/GetVSYSDescriptorConfiguration-response.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - Processing was completed. - SUCCESS - - ABCDEFGH - 3-tier Skeleton - 3-tier,Skeleton - ABCDEFGH - - - ABCDEFGH - IMG_A1B2C3_1234567890ABCD - Firewall - economy - - - 3-tier Skeleton - 3-tier Skeleton - - diff --git a/labs/fgcp/src/test/resources/responses/GetVSYSStatus-response.xml b/labs/fgcp/src/test/resources/responses/GetVSYSStatus-response.xml deleted file mode 100644 index 552d4a27ee..0000000000 --- a/labs/fgcp/src/test/resources/responses/GetVSYSStatus-response.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - Processing was completed. - SUCCESS - NORMAL - diff --git a/labs/fgcp/src/test/resources/responses/GetVServerAttributes-response.xml b/labs/fgcp/src/test/resources/responses/GetVServerAttributes-response.xml deleted file mode 100644 index a18730ed4f..0000000000 --- a/labs/fgcp/src/test/resources/responses/GetVServerAttributes-response.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - Processing was completed. - SUCCESS - - CONTRACT - IMG_A1B2C3_1234567890ABCD - CONTRACT-VSYS00001-S-0001 - my VM - economy - - diff --git a/labs/fgcp/src/test/resources/responses/GetVServerConfiguration-response.xml b/labs/fgcp/src/test/resources/responses/GetVServerConfiguration-response.xml deleted file mode 100644 index 36a8574b22..0000000000 --- a/labs/fgcp/src/test/resources/responses/GetVServerConfiguration-response.xml +++ /dev/null @@ -1,40 +0,0 @@ - - - Processing was completed. - SUCCESS - - CONTRACT - IMG_A1B2C3_1234567890ABCD - - 32 - IMG_A1B2C3_1234567890ABCD - 14 - 8 - AP - GENERAL - - - OS - SW00000001 - - CentOS 5.4 32bit (English) - 5.4 - - - 5.4 - - - 10.0 - - - - CONTRACT-VSYS00001-N-DMZ - 0 - 192.168.4.13 - - - CONTRACT-VSYS00001-S-0005 - my VM - economy - - diff --git a/labs/fgcp/src/test/resources/responses/GetVServerInitialPassword-response.xml b/labs/fgcp/src/test/resources/responses/GetVServerInitialPassword-response.xml deleted file mode 100644 index c4816ed315..0000000000 --- a/labs/fgcp/src/test/resources/responses/GetVServerInitialPassword-response.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - mySecretpwd1 - Processing was completed. - SUCCESS - diff --git a/labs/fgcp/src/test/resources/responses/GetVServerStatus-response.xml b/labs/fgcp/src/test/resources/responses/GetVServerStatus-response.xml deleted file mode 100644 index d36f0fcd2b..0000000000 --- a/labs/fgcp/src/test/resources/responses/GetVServerStatus-response.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - Processing was completed. - SUCCESS - STOPPED - \ No newline at end of file diff --git a/labs/fgcp/src/test/resources/responses/ListDiskImage-response.xml b/labs/fgcp/src/test/resources/responses/ListDiskImage-response.xml deleted file mode 100644 index 765979a58a..0000000000 --- a/labs/fgcp/src/test/resources/responses/ListDiskImage-response.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - ABCDEFGH - - IMG_A1B2C3_1234567890ABCD - CentOS 6.0 64bit(EN) - - CentOS 6.0 64bit (English) - pv - ABCDEFGH - 10.0 - - - Processing was completed. - SUCCESS - \ No newline at end of file diff --git a/labs/fgcp/src/test/resources/responses/ListDiskImages-response.xml b/labs/fgcp/src/test/resources/responses/ListDiskImages-response.xml deleted file mode 100644 index c7f0e83f79..0000000000 --- a/labs/fgcp/src/test/resources/responses/ListDiskImages-response.xml +++ /dev/null @@ -1,118 +0,0 @@ - - - - - ABCDEFGH - - IMG_A1B2C3_1234567890ABCA - - Included - Windows Server 2008 R2 EE 64bit (English) - hvm - ABCDEFGH - 40.0 - - - ABCDEFGH - - IMG_A1B2C3_1234567890ABCB - my image - - CentOS 6.2 64bit (English) - pv - ABCDEFGH - 10.0 - - - ABCDEFGH - - IMG_A1B2C3_1234567890ABCC - W2k8R2EE(EN) - Included - Windows Server 2008 R2 EE 64bit (English) - hvm - ABCDEFGH - 40.0 - - - ABCDEFGH - - IMG_A1B2C3_1234567890ABCD - CentOS 5.6 64bit(EN) - - CentOS 5.6 64bit (English) - pv - ABCDEFGH - 10.0 - - - ABCDEFGH - - IMG_A1B2C3_1234567890ABCE - W2k8R2SE/SQL2k8R2(EN) - Included - Windows Server 2008 R2 SE 64bit (English) - hvm - ABCDEFGH - 40.0 - - - Included - SQLServer 2008 R2 SE (English) - - - - - ABCDEFGH - - IMG_A1B2C3_1234567890ABCF - W2k8R2SE(EN) - Included - Windows Server 2008 R2 SE 64bit (English) - hvm - ABCDEFGH - 40.0 - - - ABCDEFGH - - IMG_A1B2C3_1234567890ABCG - CentOS 6.0 64bit(EN) - - CentOS 6.0 64bit (English) - pv - ABCDEFGH - 10.0 - - - ABCDEFGH - - IMG_A1B2C3_1234567890ABCH - CentOS 6.0 32bit(EN) - - CentOS 6.0 32bit (English) - pv - ABCDEFGH - 10.0 - - - ABCDEFGH - - IMG_A1B2C3_1234567890ABCI - W2k8R2SE/IIS(EN) - Included - Windows Server 2008 R2 SE 64bit (English) - hvm - ABCDEFGH - 40.0 - - - - Internet Information Server 7.5 - - - - - Processing was completed. - SUCCESS - \ No newline at end of file diff --git a/labs/fgcp/src/test/resources/responses/ListEFM-response.xml b/labs/fgcp/src/test/resources/responses/ListEFM-response.xml deleted file mode 100644 index 3e4a1e3be6..0000000000 --- a/labs/fgcp/src/test/resources/responses/ListEFM-response.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - ABCDEFGH - ABCDEFGH-A123B456CE-S-0001 - Firewall - FW - - - Processing was completed. - SUCCESS - diff --git a/labs/fgcp/src/test/resources/responses/ListEFMBackup-response.xml b/labs/fgcp/src/test/resources/responses/ListEFMBackup-response.xml deleted file mode 100644 index 780dbedd74..0000000000 --- a/labs/fgcp/src/test/resources/responses/ListEFMBackup-response.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - 001 - 20121008201127 - - - 002 - 20121009201127 - - - Processing was completed. - SUCCESS - diff --git a/labs/fgcp/src/test/resources/responses/ListPublicIP-response.xml b/labs/fgcp/src/test/resources/responses/ListPublicIP-response.xml deleted file mode 100644 index 628620959b..0000000000 --- a/labs/fgcp/src/test/resources/responses/ListPublicIP-response.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - -
123.45.67.89
- IPv4 - ABCDEFGH-A123B456CE -
- -
123.45.67.90
- IPv4 - ABCDEFGH-A123B456CD -
-
- Processing was completed. - SUCCESS -
diff --git a/labs/fgcp/src/test/resources/responses/ListPublicIP_one_vsys-response.xml b/labs/fgcp/src/test/resources/responses/ListPublicIP_one_vsys-response.xml deleted file mode 100644 index d470837270..0000000000 --- a/labs/fgcp/src/test/resources/responses/ListPublicIP_one_vsys-response.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - -
123.45.67.88
- IPv4 - ABCDEFGH-A123B456CE -
- -
123.45.67.89
- IPv4 - ABCDEFGH-A123B456CE -
-
- Processing was completed. - SUCCESS -
diff --git a/labs/fgcp/src/test/resources/responses/ListServerType-response.xml b/labs/fgcp/src/test/resources/responses/ListServerType-response.xml deleted file mode 100644 index 0c9cee612c..0000000000 --- a/labs/fgcp/src/test/resources/responses/ListServerType-response.xml +++ /dev/null @@ -1,82 +0,0 @@ - - - Processing was completed. - SUCCESS - - - amount - - IA - 4.0 - 1 - - 744 - islanda-cbrm_144 - - 7.5 - - advanced - 0.3 - AUS-VM-0001-0003 - Advanced VM - - - amount - - IA - 1.0 - 1 - - 744 - islanda-cbrm_140 - - 1.7 - - economy - 0.1 - AUS-VM-0001-0001 - Economy VM - - - amount - - IA - 4.0 - 2 - - 744 - islanda-cbrm_146 - - 15.0 - - high_performance - 0.4 - AUS-VM-0001-0004 - High-Performance VM - - - amount - - IA - 2.0 - 1 - - - - 10 - Disk type - Disk purpose - - - 744 - islanda-cbrm_142 - - 3.4 - - standard - 0.3 - AUS-VM-0001-0002 - Standard VM - - - \ No newline at end of file diff --git a/labs/fgcp/src/test/resources/responses/ListVDisk-response.xml b/labs/fgcp/src/test/resources/responses/ListVDisk-response.xml deleted file mode 100644 index e9e9242ce0..0000000000 --- a/labs/fgcp/src/test/resources/responses/ListVDisk-response.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - Processing was completed. - SUCCESS - - - ABCDEFGH-A123B456CE-S-0006 - ABCDEFGH - 10.0 - ABCDEFGH-A123B456CE-S-0006 - VM1 - - - \ No newline at end of file diff --git a/labs/fgcp/src/test/resources/responses/ListVSYS-response.xml b/labs/fgcp/src/test/resources/responses/ListVSYS-response.xml deleted file mode 100644 index 947f78715b..0000000000 --- a/labs/fgcp/src/test/resources/responses/ListVSYS-response.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - Processing was completed. - SUCCESS - - - 2-tier Skeleton - ABCDEFGH - 2-tier Skeleton - ABCDEFGH-I123J456K - expect test - - - 2-tier Skeleton - ABCDEFGH - 2-tier Skeleton - ABCDEFGH-L654J321I - expect test 2 - - - \ No newline at end of file diff --git a/labs/fgcp/src/test/resources/responses/ListVServer-response.xml b/labs/fgcp/src/test/resources/responses/ListVServer-response.xml deleted file mode 100644 index 643925db2a..0000000000 --- a/labs/fgcp/src/test/resources/responses/ListVServer-response.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - Processing was completed. - SUCCESS - - - ABCDEFGH - IMG_A1B2C3_1234567890ABCD - ABCDEFGH-A123B456CE-S-0005 - VM1 - economy - - - ABCDEFGH - IMG_A1B2C3_1234567890ABCD - ABCDEFGH-A123B456CE-S-0006 - VM2 - standard - - - diff --git a/labs/fgcp/src/test/resources/responses/RestoreEFM-response.xml b/labs/fgcp/src/test/resources/responses/RestoreEFM-response.xml deleted file mode 100644 index 03a98713f5..0000000000 --- a/labs/fgcp/src/test/resources/responses/RestoreEFM-response.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - Processing was completed. - SUCCESS - \ No newline at end of file diff --git a/labs/fgcp/src/test/resources/responses/RestoreVDisk-response.xml b/labs/fgcp/src/test/resources/responses/RestoreVDisk-response.xml deleted file mode 100644 index a4f4bd7262..0000000000 --- a/labs/fgcp/src/test/resources/responses/RestoreVDisk-response.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - Processing was completed. - SUCCESS - \ No newline at end of file diff --git a/labs/fgcp/src/test/resources/responses/StartEFM-response.xml b/labs/fgcp/src/test/resources/responses/StartEFM-response.xml deleted file mode 100644 index 1914e55354..0000000000 --- a/labs/fgcp/src/test/resources/responses/StartEFM-response.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - Processing was completed. - SUCCESS - \ No newline at end of file diff --git a/labs/fgcp/src/test/resources/responses/StartVServer-response.xml b/labs/fgcp/src/test/resources/responses/StartVServer-response.xml deleted file mode 100644 index 0648bb7a60..0000000000 --- a/labs/fgcp/src/test/resources/responses/StartVServer-response.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - Processing was completed. - SUCCESS - \ No newline at end of file diff --git a/labs/fgcp/src/test/resources/responses/StopEFM-response.xml b/labs/fgcp/src/test/resources/responses/StopEFM-response.xml deleted file mode 100644 index 332d315dfb..0000000000 --- a/labs/fgcp/src/test/resources/responses/StopEFM-response.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - Processing was completed. - SUCCESS - \ No newline at end of file diff --git a/labs/fgcp/src/test/resources/responses/StopVServer-response.xml b/labs/fgcp/src/test/resources/responses/StopVServer-response.xml deleted file mode 100644 index 332d315dfb..0000000000 --- a/labs/fgcp/src/test/resources/responses/StopVServer-response.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - Processing was completed. - SUCCESS - \ No newline at end of file diff --git a/labs/fgcp/src/test/resources/responses/UnregisterDiskImage-response.xml b/labs/fgcp/src/test/resources/responses/UnregisterDiskImage-response.xml deleted file mode 100644 index 65d4052bc4..0000000000 --- a/labs/fgcp/src/test/resources/responses/UnregisterDiskImage-response.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - Processing was completed. - SUCCESS - \ No newline at end of file diff --git a/labs/fgcp/src/test/resources/responses/UnregisterPrivateVSYSDescriptor-response.xml b/labs/fgcp/src/test/resources/responses/UnregisterPrivateVSYSDescriptor-response.xml deleted file mode 100644 index fcb6dce2ad..0000000000 --- a/labs/fgcp/src/test/resources/responses/UnregisterPrivateVSYSDescriptor-response.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - Processing was completed. - SUCCESS - \ No newline at end of file diff --git a/labs/fgcp/src/test/resources/responses/UnregisterVSYSDescriptor-response.xml b/labs/fgcp/src/test/resources/responses/UnregisterVSYSDescriptor-response.xml deleted file mode 100644 index 884e5fd625..0000000000 --- a/labs/fgcp/src/test/resources/responses/UnregisterVSYSDescriptor-response.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - Processing was completed. - SUCCESS - \ No newline at end of file diff --git a/labs/fgcp/src/test/resources/responses/UpdateDiskImageAttribute-response.xml b/labs/fgcp/src/test/resources/responses/UpdateDiskImageAttribute-response.xml deleted file mode 100644 index 5210fc8844..0000000000 --- a/labs/fgcp/src/test/resources/responses/UpdateDiskImageAttribute-response.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - Processing was completed. - SUCCESS - \ No newline at end of file diff --git a/labs/fgcp/src/test/resources/responses/UpdateEFMAttribute-response.xml b/labs/fgcp/src/test/resources/responses/UpdateEFMAttribute-response.xml deleted file mode 100644 index 935b9a2ccd..0000000000 --- a/labs/fgcp/src/test/resources/responses/UpdateEFMAttribute-response.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - Processing was completed. - SUCCESS - \ No newline at end of file diff --git a/labs/fgcp/src/test/resources/responses/UpdateVDiskAttribute-response.xml b/labs/fgcp/src/test/resources/responses/UpdateVDiskAttribute-response.xml deleted file mode 100644 index 57ad9484d2..0000000000 --- a/labs/fgcp/src/test/resources/responses/UpdateVDiskAttribute-response.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - Processing was completed. - SUCCESS - \ No newline at end of file diff --git a/labs/fgcp/src/test/resources/responses/UpdateVSYSDescriptorAttribute-response.xml b/labs/fgcp/src/test/resources/responses/UpdateVSYSDescriptorAttribute-response.xml deleted file mode 100644 index d660beef84..0000000000 --- a/labs/fgcp/src/test/resources/responses/UpdateVSYSDescriptorAttribute-response.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - Processing was completed. - SUCCESS - \ No newline at end of file diff --git a/labs/fgcp/src/test/resources/responses/UpdateVServerAttribute-response.xml b/labs/fgcp/src/test/resources/responses/UpdateVServerAttribute-response.xml deleted file mode 100644 index b1be00123b..0000000000 --- a/labs/fgcp/src/test/resources/responses/UpdateVServerAttribute-response.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - Processing was completed. - SUCCESS - \ No newline at end of file diff --git a/labs/google-compute/README.txt b/labs/google-compute/README.txt deleted file mode 100644 index 8c50447559..0000000000 --- a/labs/google-compute/README.txt +++ /dev/null @@ -1,54 +0,0 @@ -jclouds Google Compute Engine Provider -====== - - -Authenticating into the instances: --------- - -User: -If no user is provided in GoogleComputeTemplateOptions when launching an instance by defaul "jclouds" is used. - -Credential: - -GCE uses exclusively ssh keys to login into instances. -In order for an instance to be sshable a public key must be installed. Public keys are installed if they are present in the project or instance's metatada. - -For an instance to be ssable one of the following must happen: -1 - the project's metadata has an adequately built "sshKeys" entry and a corresponding private key is provided in GoogleComputeTemplateOptions when createNodesInGroup is called. -2 - an instance of GoogleComputeTemplateOptions with an adequate public and private key is provided. - -NOTE: if methods 2 is chosen the global project keys will not be installed in the instance. - -Please refer to Google's documentation on how to form valid project wide ssh keys metadata entries. - -FAQ: --------- - -* Q. What is the identity for GCE? - -A. the identity is the developer email which can be obtained from the admin GUI. Its usually something in the form: @developer.gserviceaccount.com - -* Q. What is the crendential for GCE - -A. the credential is a private key, in pem format. It can be extracted from the p12 keystore that is obtained when creating a "Service Account" (in the GUI: Google apis console > Api Access > Create another client ID > "Service Account" - -* Q. How to convert a p12 keystore into a pem format jclouds-gce can handle: - -A. - -1. Convert the p12 file into pem format (it will ask for the keystore password, which is usually "notasecret"): - openssl pkcs12 -in .p12 -out .pem -nodes - -2. Extract only the pk and remove passphrase - openssl rsa -in .pem -out .pem - -The last file (.pem) should contain the pk that needs to be passed to google-compute as a string literal property named "google-compute.credential". - - -Running the live tests: --------- - -mvn clean install -Plive -Dtest.google-compute.identity=@developer.gserviceaccount.com -Dtest.google-compute.credential= - - - diff --git a/labs/google-compute/pom.xml b/labs/google-compute/pom.xml deleted file mode 100644 index 9a80af7c68..0000000000 --- a/labs/google-compute/pom.xml +++ /dev/null @@ -1,126 +0,0 @@ - - - - - 4.0.0 - - org.jclouds.labs - jclouds-labs-project - 1.7.0-SNAPSHOT - ../project/pom.xml - - google-compute - jclouds Google Compute Engine provider - jclouds components to access GoogleCompute - - - Email associated with the Google API client_id - Private key (PKCS12 file) associated with the Google API client_id - v1beta13 - - - - - - org.jclouds - jclouds-core - ${jclouds.version} - - - org.jclouds.labs - oauth - ${project.version} - jar - - - org.jclouds.labs - oauth - ${project.version} - test-jar - test - - - org.jclouds - jclouds-compute - ${jclouds.version} - - - org.jclouds - jclouds-compute - ${jclouds.version} - test-jar - test - - - org.jclouds - jclouds-core - ${jclouds.version} - test-jar - test - - - org.jclouds.driver - jclouds-slf4j - ${jclouds.version} - test - - - org.jclouds.driver - jclouds-sshj - ${jclouds.version} - test - - - ch.qos.logback - logback-classic - test - - - - - live - - - - org.apache.maven.plugins - maven-surefire-plugin - - - integration - integration-test - - test - - - - ${test.google-compute.identity} - ${test.google-compute.credential} - ${test.google-compute.api-version} - ${test.google-compute.build-version} - - - - - - - - - - diff --git a/labs/google-compute/src/main/java/org/jclouds/googlecompute/GoogleComputeApi.java b/labs/google-compute/src/main/java/org/jclouds/googlecompute/GoogleComputeApi.java deleted file mode 100644 index 2a9b7fe7b8..0000000000 --- a/labs/google-compute/src/main/java/org/jclouds/googlecompute/GoogleComputeApi.java +++ /dev/null @@ -1,137 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.googlecompute; - -import com.google.common.annotations.Beta; -import org.jclouds.googlecompute.features.DiskApi; -import org.jclouds.googlecompute.features.FirewallApi; -import org.jclouds.googlecompute.features.ImageApi; -import org.jclouds.googlecompute.features.InstanceApi; -import org.jclouds.googlecompute.features.KernelApi; -import org.jclouds.googlecompute.features.MachineTypeApi; -import org.jclouds.googlecompute.features.NetworkApi; -import org.jclouds.googlecompute.features.OperationApi; -import org.jclouds.googlecompute.features.ProjectApi; -import org.jclouds.googlecompute.features.ZoneApi; -import org.jclouds.rest.annotations.Delegate; - -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; - - -/** - * Provides synchronous access to GoogleCompute. - *

- * - * @author David Alves - * @see GoogleComputeAsyncApi - * @see api doc - */ -@Beta -public interface GoogleComputeApi { - - /** - * Provides synchronous access to Disk features - * - * @param projectName the name of the project - */ - @Delegate - @Path("/projects/{project}") - DiskApi getDiskApiForProject(@PathParam("project") String projectName); - - /** - * Provides synchronous access to Firewall features - * - * @param projectName the name of the project - */ - @Delegate - @Path("/projects/{project}") - FirewallApi getFirewallApiForProject(@PathParam("project") String projectName); - - /** - * Provides synchronous access to Image features - * - * @param projectName the name of the project - */ - @Delegate - @Path("/projects/{project}") - ImageApi getImageApiForProject(@PathParam("project") String projectName); - - /** - * Provides synchronous access to Instance features - * - * @param projectName the name of the project - */ - @Delegate - @Path("/projects/{project}") - InstanceApi getInstanceApiForProject(@PathParam("project") String projectName); - - /** - * Provides synchronous access to Kernel features - * - * @param projectName the name of the project - */ - @Delegate - @Path("/projects/{project}") - KernelApi getKernelApiForProject(@PathParam("project") String projectName); - - /** - * Provides synchronous access to MachineType features - * - * @param projectName the name of the project - */ - @Delegate - @Path("/projects/{project}") - MachineTypeApi getMachineTypeApiForProject(@PathParam("project") String projectName); - - /** - * Provides synchronous access to Network features - * - * @param projectName the name of the project - */ - @Delegate - @Path("/projects/{project}") - NetworkApi getNetworkApiForProject(@PathParam("project") String projectName); - - /** - * Provides synchronous access to Operation features - * - * @param projectName the name of the project - */ - @Delegate - @Path("/projects/{project}") - OperationApi getOperationApiForProject(@PathParam("project") String projectName); - - /** - * Provides synchronous access to Project features - */ - @Delegate - ProjectApi getProjectApi(); - - /** - * Provides synchronous access to Zone features - * - * @param projectName the name of the project - */ - @Delegate - @Path("/projects/{project}") - ZoneApi getZoneApiForProject(@PathParam("project") String projectName); - - -} diff --git a/labs/google-compute/src/main/java/org/jclouds/googlecompute/GoogleComputeApiMetadata.java b/labs/google-compute/src/main/java/org/jclouds/googlecompute/GoogleComputeApiMetadata.java deleted file mode 100644 index 1c2285dfeb..0000000000 --- a/labs/google-compute/src/main/java/org/jclouds/googlecompute/GoogleComputeApiMetadata.java +++ /dev/null @@ -1,111 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.googlecompute; - -import com.google.common.collect.ImmutableSet; -import com.google.common.reflect.TypeToken; -import com.google.inject.Module; -import org.jclouds.apis.ApiMetadata; -import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.googlecompute.compute.config.GoogleComputeServiceContextModule; -import org.jclouds.googlecompute.config.GoogleComputeParserModule; -import org.jclouds.googlecompute.config.GoogleComputeRestClientModule; -import org.jclouds.googlecompute.config.OAuthModuleWithoutTypeAdapters; -import org.jclouds.oauth.v2.config.OAuthAuthenticationModule; -import org.jclouds.rest.RestContext; -import org.jclouds.rest.internal.BaseRestApiMetadata; - -import java.net.URI; -import java.util.Properties; - -import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL; -import static org.jclouds.compute.config.ComputeServiceProperties.TEMPLATE; -import static org.jclouds.oauth.v2.config.OAuthProperties.AUDIENCE; -import static org.jclouds.oauth.v2.config.OAuthProperties.SIGNATURE_OR_MAC_ALGORITHM; -import static org.jclouds.reflect.Reflection2.typeToken; - -/** - * Implementation of {@link ApiMetadata} for GoogleCompute v1beta13 API - * - * @author David Alves - */ -public class GoogleComputeApiMetadata extends BaseRestApiMetadata { - - public static final TypeToken> CONTEXT_TOKEN = new - TypeToken>() {}; - - @Override - public Builder toBuilder() { - return new Builder().fromApiMetadata(this); - } - - public GoogleComputeApiMetadata() { - this(new Builder()); - } - - protected GoogleComputeApiMetadata(Builder builder) { - super(builder); - } - - public static Properties defaultProperties() { - Properties properties = BaseRestApiMetadata.defaultProperties(); - properties.put("oauth.endpoint", "https://accounts.google.com/o/oauth2/token"); - properties.put(AUDIENCE, "https://accounts.google.com/o/oauth2/token"); - properties.put(SIGNATURE_OR_MAC_ALGORITHM, "RS256"); - properties.put(PROPERTY_SESSION_INTERVAL, 3600); - properties.setProperty(TEMPLATE, "osFamily=GCEL,osVersionMatches=1[012].[01][04],locationId=us-central1-a," + - "loginUser=jclouds"); - properties.put(GoogleComputeConstants.OPERATION_COMPLETE_INTERVAL, 500); - properties.put(GoogleComputeConstants.OPERATION_COMPLETE_TIMEOUT, 600000); - return properties; - } - - public static class Builder extends BaseRestApiMetadata.Builder { - - protected Builder() { - super(GoogleComputeApi.class, GoogleComputeAsyncApi.class); - id("google-compute") - .name("Google Compute Engine Api") - .identityName("Email associated with the Goole API client_id") - .credentialName("Private key literal associated with the Google API client_id") - .documentation(URI.create("https://developers.google.com/compute/docs")) - .version("v1beta13") - .defaultEndpoint("https://www.googleapis.com/compute/v1beta13") - .defaultProperties(GoogleComputeApiMetadata.defaultProperties()) - .view(typeToken(ComputeServiceContext.class)) - .defaultModules(ImmutableSet.>builder() - .add(GoogleComputeRestClientModule.class) - .add(GoogleComputeParserModule.class) - .add(OAuthAuthenticationModule.class) - .add(OAuthModuleWithoutTypeAdapters.class) - .add(GoogleComputeServiceContextModule.class) - .build()); - } - - @Override - public GoogleComputeApiMetadata build() { - return new GoogleComputeApiMetadata(this); - } - - @Override - protected Builder self() { - return this; - } - } -} diff --git a/labs/google-compute/src/main/java/org/jclouds/googlecompute/GoogleComputeAsyncApi.java b/labs/google-compute/src/main/java/org/jclouds/googlecompute/GoogleComputeAsyncApi.java deleted file mode 100644 index 4affe63d1b..0000000000 --- a/labs/google-compute/src/main/java/org/jclouds/googlecompute/GoogleComputeAsyncApi.java +++ /dev/null @@ -1,134 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.googlecompute; - -import com.google.common.annotations.Beta; -import org.jclouds.googlecompute.features.DiskAsyncApi; -import org.jclouds.googlecompute.features.FirewallAsyncApi; -import org.jclouds.googlecompute.features.ImageAsyncApi; -import org.jclouds.googlecompute.features.InstanceAsyncApi; -import org.jclouds.googlecompute.features.KernelAsyncApi; -import org.jclouds.googlecompute.features.MachineTypeAsyncApi; -import org.jclouds.googlecompute.features.NetworkAsyncApi; -import org.jclouds.googlecompute.features.OperationAsyncApi; -import org.jclouds.googlecompute.features.ProjectAsyncApi; -import org.jclouds.googlecompute.features.ZoneAsyncApi; -import org.jclouds.rest.annotations.Delegate; - -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; - - -/** - * Provides asynchronous access to GoogleCompute via their REST API. - *

- * - * @author David Alves - * @see GoogleComputeApi - */ -@Beta -public interface GoogleComputeAsyncApi { - - /** - * Provides asynchronous access to Disk features - * - * @param projectName the name of the project - */ - @Delegate - @Path("/projects/{project}") - DiskAsyncApi getDiskApiForProject(@PathParam("project") String projectName); - - /** - * Provides asynchronous access to Firewall features - * - * @param projectName the name of the project - */ - @Delegate - @Path("/projects/{project}") - FirewallAsyncApi getFirewallApiForProject(@PathParam("project") String projectName); - - /** - * Provides asynchronous access to Image features - * - * @param projectName the name of the project - */ - @Delegate - @Path("/projects/{project}") - ImageAsyncApi getImageApiForProject(@PathParam("project") String projectName); - - /** - * Provides asynchronous access to Instance features - * - * @param projectName the name of the project - */ - @Delegate - @Path("/projects/{project}") - InstanceAsyncApi getInstanceApiForProject(@PathParam("project") String projectName); - - /** - * Provides asynchronous access to Kernel features - * - * @param projectName the name of the project - */ - @Delegate - @Path("/projects/{project}") - KernelAsyncApi getKernelApiForProject(@PathParam("project") String projectName); - - /** - * Provides asynchronous access to MachineType features - * - * @param projectName the name of the project - */ - @Delegate - @Path("/projects/{project}") - MachineTypeAsyncApi getMachineTypeApiForProject(@PathParam("project") String projectName); - - /** - * Provides asynchronous access to Network features - * - * @param projectName the name of the project - */ - @Delegate - @Path("/projects/{project}") - NetworkAsyncApi getNetworkApiForProject(@PathParam("project") String projectName); - - /** - * Provides asynchronous access to Operation features - * - * @param projectName the name of the project - */ - @Delegate - @Path("/projects/{project}") - OperationAsyncApi getOperationApiForProject(@PathParam("project") String projectName); - - /** - * Provides asynchronous access to Project features - */ - @Delegate - ProjectAsyncApi getProjectApi(); - - /** - * Provides asynchronous access to Zone features - * - * @param projectName the name of the project - */ - @Delegate - @Path("/projects/{project}") - ZoneAsyncApi getZoneApiForProject(@PathParam("project") String projectName); -} diff --git a/labs/google-compute/src/main/java/org/jclouds/googlecompute/GoogleComputeConstants.java b/labs/google-compute/src/main/java/org/jclouds/googlecompute/GoogleComputeConstants.java deleted file mode 100644 index c2d8b72d5b..0000000000 --- a/labs/google-compute/src/main/java/org/jclouds/googlecompute/GoogleComputeConstants.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.googlecompute; - -import com.google.common.annotations.Beta; -import org.jclouds.domain.Location; -import org.jclouds.domain.LocationBuilder; -import org.jclouds.domain.LocationScope; - -/** - * @author David Alves - */ -public interface GoogleComputeConstants { - - public static final String GOOGLE_PROVIDER_NAME = "google-compute"; - - /** - * The name of the project that keeps public resources. - */ - public static final String GOOGLE_PROJECT = "google"; - - public static final String COMPUTE_SCOPE = "https://www.googleapis.com/auth/compute"; - - public static final String COMPUTE_READONLY_SCOPE = "https://www.googleapis.com/auth/compute.readonly"; - - /** - * The total time, in msecs, to wait for an operation to complete. - */ - @Beta - public static final String OPERATION_COMPLETE_TIMEOUT = "jclouds.google-compute.operation-complete-timeout"; - - /** - * The interval, in msecs, between calls to check whether an operation has completed. - */ - @Beta - public static final String OPERATION_COMPLETE_INTERVAL = "jclouds.google-compute.operation-complete-interval"; - - public static final Location GOOGLE_PROVIDER_LOCATION = new LocationBuilder().scope(LocationScope.PROVIDER).id - (GOOGLE_PROVIDER_NAME).description(GOOGLE_PROVIDER_NAME).build(); - -} diff --git a/labs/google-compute/src/main/java/org/jclouds/googlecompute/compute/GoogleComputeService.java b/labs/google-compute/src/main/java/org/jclouds/googlecompute/compute/GoogleComputeService.java deleted file mode 100644 index 556222e492..0000000000 --- a/labs/google-compute/src/main/java/org/jclouds/googlecompute/compute/GoogleComputeService.java +++ /dev/null @@ -1,183 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.googlecompute.compute; - -import com.google.common.base.Function; -import com.google.common.base.Optional; -import com.google.common.base.Predicate; -import com.google.common.base.Supplier; -import com.google.common.util.concurrent.ListeningExecutorService; -import org.jclouds.Constants; -import org.jclouds.collect.Memoized; -import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.compute.callables.RunScriptOnNode; -import org.jclouds.compute.domain.Hardware; -import org.jclouds.compute.domain.Image; -import org.jclouds.compute.domain.NodeMetadata; -import org.jclouds.compute.domain.TemplateBuilder; -import org.jclouds.compute.extensions.ImageExtension; -import org.jclouds.compute.functions.GroupNamingConvention; -import org.jclouds.compute.internal.BaseComputeService; -import org.jclouds.compute.internal.PersistNodeCredentials; -import org.jclouds.compute.options.TemplateOptions; -import org.jclouds.compute.reference.ComputeServiceConstants; -import org.jclouds.compute.strategy.CreateNodesInGroupThenAddToSet; -import org.jclouds.compute.strategy.DestroyNodeStrategy; -import org.jclouds.compute.strategy.GetImageStrategy; -import org.jclouds.compute.strategy.GetNodeMetadataStrategy; -import org.jclouds.compute.strategy.InitializeRunScriptOnNodeOrPlaceInBadMap; -import org.jclouds.compute.strategy.ListNodesStrategy; -import org.jclouds.compute.strategy.RebootNodeStrategy; -import org.jclouds.compute.strategy.ResumeNodeStrategy; -import org.jclouds.compute.strategy.SuspendNodeStrategy; -import org.jclouds.domain.Credentials; -import org.jclouds.domain.Location; -import org.jclouds.googlecompute.GoogleComputeApi; -import org.jclouds.googlecompute.compute.options.GoogleComputeTemplateOptions; -import org.jclouds.googlecompute.config.UserProject; -import org.jclouds.googlecompute.domain.Operation; -import org.jclouds.http.HttpResponse; -import org.jclouds.scriptbuilder.functions.InitAdminAccess; - -import javax.inject.Inject; -import javax.inject.Named; -import javax.inject.Provider; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.atomic.AtomicReference; - -import static com.google.common.base.Preconditions.checkNotNull; -import static java.util.concurrent.TimeUnit.MILLISECONDS; -import static org.jclouds.compute.config.ComputeServiceProperties.TIMEOUT_NODE_RUNNING; -import static org.jclouds.compute.config.ComputeServiceProperties.TIMEOUT_NODE_SUSPENDED; -import static org.jclouds.compute.config.ComputeServiceProperties.TIMEOUT_NODE_TERMINATED; -import static org.jclouds.googlecompute.GoogleComputeConstants.OPERATION_COMPLETE_INTERVAL; -import static org.jclouds.googlecompute.GoogleComputeConstants.OPERATION_COMPLETE_TIMEOUT; -import static org.jclouds.util.Predicates2.retry; - -/** - * @author David Alves - */ -public class GoogleComputeService extends BaseComputeService { - - private final Function, Set> findOrphanedGroups; - private final GroupNamingConvention.Factory namingConvention; - private final GoogleComputeApi api; - private final Supplier project; - private final Predicate> operationDonePredicate; - private final long operationCompleteCheckInterval; - private final long operationCompleteCheckTimeout; - - @Inject - protected GoogleComputeService(ComputeServiceContext context, - Map credentialStore, - @Memoized Supplier> images, - @Memoized Supplier> hardwareProfiles, - @Memoized Supplier> locations, - ListNodesStrategy listNodesStrategy, - GetImageStrategy getImageStrategy, - GetNodeMetadataStrategy getNodeMetadataStrategy, - CreateNodesInGroupThenAddToSet runNodesAndAddToSetStrategy, - RebootNodeStrategy rebootNodeStrategy, - DestroyNodeStrategy destroyNodeStrategy, - ResumeNodeStrategy resumeNodeStrategy, - SuspendNodeStrategy suspendNodeStrategy, - Provider templateBuilderProvider, - @Named("DEFAULT") Provider templateOptionsProvider, - @Named(TIMEOUT_NODE_RUNNING) Predicate> nodeRunning, - @Named(TIMEOUT_NODE_TERMINATED) Predicate> - nodeTerminated, - @Named(TIMEOUT_NODE_SUSPENDED) - Predicate> nodeSuspended, - InitializeRunScriptOnNodeOrPlaceInBadMap.Factory initScriptRunnerFactory, - InitAdminAccess initAdminAccess, - RunScriptOnNode.Factory runScriptOnNodeFactory, - PersistNodeCredentials persistNodeCredentials, - ComputeServiceConstants.Timeouts timeouts, - @Named(Constants.PROPERTY_USER_THREADS) ListeningExecutorService userExecutor, - Optional imageExtension, - Function, Set> findOrphanedGroups, - GroupNamingConvention.Factory namingConvention, - GoogleComputeApi api, - @UserProject Supplier project, - Predicate> operationDonePredicate, - @Named(OPERATION_COMPLETE_INTERVAL) Long operationCompleteCheckInterval, - @Named(OPERATION_COMPLETE_TIMEOUT) Long operationCompleteCheckTimeout) { - - super(context, credentialStore, images, hardwareProfiles, locations, listNodesStrategy, getImageStrategy, - getNodeMetadataStrategy, runNodesAndAddToSetStrategy, rebootNodeStrategy, destroyNodeStrategy, - resumeNodeStrategy, suspendNodeStrategy, templateBuilderProvider, templateOptionsProvider, nodeRunning, - nodeTerminated, nodeSuspended, initScriptRunnerFactory, initAdminAccess, runScriptOnNodeFactory, - persistNodeCredentials, timeouts, userExecutor, imageExtension); - this.findOrphanedGroups = checkNotNull(findOrphanedGroups, "find orphaned groups function"); - this.namingConvention = checkNotNull(namingConvention, "naming convention factory"); - this.api = checkNotNull(api, "google compute api"); - this.project = checkNotNull(project, "user project name"); - this.operationDonePredicate = checkNotNull(operationDonePredicate, "operation completed predicate"); - this.operationCompleteCheckInterval = checkNotNull(operationCompleteCheckInterval, - "operation completed check interval"); - this.operationCompleteCheckTimeout = checkNotNull(operationCompleteCheckTimeout, - "operation completed check timeout"); - } - - @Override - protected synchronized void cleanUpIncidentalResourcesOfDeadNodes(Set deadNodes) { - Set orphanedGroups = findOrphanedGroups.apply(deadNodes); - for (String orphanedGroup : orphanedGroups) { - cleanUpNetworksAndFirewallsForGroup(orphanedGroup); - } - } - - - protected void cleanUpNetworksAndFirewallsForGroup(String groupName) { - String resourceName = namingConvention.create().sharedNameForGroup(groupName); - AtomicReference operation = new AtomicReference(api.getFirewallApiForProject(project.get()) - .delete(resourceName)); - - retry(operationDonePredicate, operationCompleteCheckTimeout, operationCompleteCheckInterval, - MILLISECONDS).apply(operation); - - if (operation.get().getHttpError().isPresent()) { - HttpResponse response = operation.get().getHttpError().get(); - logger.warn("delete orphaned firewall failed. Http Error Code: " + response.getStatusCode() + - " HttpError: " + response.getMessage()); - } - - operation = new AtomicReference(api.getNetworkApiForProject(project.get()).delete(resourceName)); - - retry(operationDonePredicate, operationCompleteCheckTimeout, operationCompleteCheckInterval, - MILLISECONDS).apply(operation); - - if (operation.get().getHttpError().isPresent()) { - HttpResponse response = operation.get().getHttpError().get(); - logger.warn("delete orphaned network failed. Http Error Code: " + response.getStatusCode() + - " HttpError: " + response.getMessage()); - } - } - - - /** - * returns template options, except of type {@link GoogleComputeTemplateOptions}. - */ - @Override - public GoogleComputeTemplateOptions templateOptions() { - return GoogleComputeTemplateOptions.class.cast(super.templateOptions()); - } -} diff --git a/labs/google-compute/src/main/java/org/jclouds/googlecompute/compute/GoogleComputeServiceAdapter.java b/labs/google-compute/src/main/java/org/jclouds/googlecompute/compute/GoogleComputeServiceAdapter.java deleted file mode 100644 index ab083b0a4f..0000000000 --- a/labs/google-compute/src/main/java/org/jclouds/googlecompute/compute/GoogleComputeServiceAdapter.java +++ /dev/null @@ -1,252 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.googlecompute.compute; - -import com.google.common.base.Function; -import com.google.common.base.Objects; -import com.google.common.base.Predicate; -import com.google.common.base.Supplier; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; -import com.google.common.util.concurrent.UncheckedTimeoutException; -import com.google.inject.Inject; -import org.jclouds.compute.ComputeServiceAdapter; -import org.jclouds.compute.domain.Hardware; -import org.jclouds.compute.domain.Template; -import org.jclouds.compute.options.TemplateOptions; -import org.jclouds.compute.reference.ComputeServiceConstants; -import org.jclouds.domain.LoginCredentials; -import org.jclouds.googlecompute.GoogleComputeApi; -import org.jclouds.googlecompute.compute.options.GoogleComputeTemplateOptions; -import org.jclouds.googlecompute.config.UserProject; -import org.jclouds.googlecompute.domain.Image; -import org.jclouds.googlecompute.domain.Instance; -import org.jclouds.googlecompute.domain.InstanceTemplate; -import org.jclouds.googlecompute.domain.MachineType; -import org.jclouds.googlecompute.domain.Operation; -import org.jclouds.googlecompute.domain.Zone; -import org.jclouds.http.HttpResponse; -import org.jclouds.logging.Logger; - -import javax.annotation.Resource; -import javax.inject.Named; -import java.net.URI; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicReference; - -import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.base.Preconditions.checkState; -import static java.util.concurrent.TimeUnit.MILLISECONDS; -import static org.jclouds.googlecompute.GoogleComputeConstants.GOOGLE_PROJECT; -import static org.jclouds.googlecompute.GoogleComputeConstants.OPERATION_COMPLETE_INTERVAL; -import static org.jclouds.googlecompute.GoogleComputeConstants.OPERATION_COMPLETE_TIMEOUT; -import static org.jclouds.googlecompute.domain.Instance.NetworkInterface.AccessConfig.Type; -import static org.jclouds.util.Predicates2.retry; - -/** - * @author David Alves - */ -public class GoogleComputeServiceAdapter implements ComputeServiceAdapter { - - @Resource - @Named(ComputeServiceConstants.COMPUTE_LOGGER) - protected Logger logger = Logger.NULL; - - private final GoogleComputeApi api; - private final Supplier userProject; - private final Function> metatadaFromTemplateOptions; - private final Predicate> retryOperationDonePredicate; - private final long operationCompleteCheckInterval; - private final long operationCompleteCheckTimeout; - - @Inject - public GoogleComputeServiceAdapter(GoogleComputeApi api, - @UserProject Supplier userProject, - Function> metatadaFromTemplateOptions, - Predicate> operationDonePredicate, - @Named(OPERATION_COMPLETE_INTERVAL) Long operationCompleteCheckInterval, - @Named(OPERATION_COMPLETE_TIMEOUT) Long operationCompleteCheckTimeout) { - this.api = checkNotNull(api, "google compute api"); - this.userProject = checkNotNull(userProject, "user project name"); - this.metatadaFromTemplateOptions = checkNotNull(metatadaFromTemplateOptions, - "metadata from template options function"); - this.operationCompleteCheckInterval = checkNotNull(operationCompleteCheckInterval, - "operation completed check interval"); - this.operationCompleteCheckTimeout = checkNotNull(operationCompleteCheckTimeout, - "operation completed check timeout"); - this.retryOperationDonePredicate = retry(operationDonePredicate, operationCompleteCheckTimeout, - operationCompleteCheckInterval, TimeUnit.MILLISECONDS); - } - - @Override - public NodeAndInitialCredentials createNodeWithGroupEncodedIntoName( - final String group, final String name, Template template) { - - checkNotNull(template, "template"); - - GoogleComputeTemplateOptions options = GoogleComputeTemplateOptions.class.cast(template.getOptions()).clone(); - checkState(options.getNetwork().isPresent(), "network was not present in template options"); - Hardware hardware = checkNotNull(template.getHardware(), "hardware must be set"); - URI machineType = checkNotNull(hardware.getUri(), "hardware uri must be set"); - - InstanceTemplate instanceTemplate = InstanceTemplate.builder() - .forMachineType(machineType); - - if (options.isEnableNat()) { - instanceTemplate.addNetworkInterface(options.getNetwork().get(), Type.ONE_TO_ONE_NAT); - } else { - instanceTemplate.addNetworkInterface(options.getNetwork().get()); - } - - LoginCredentials credentials = getFromImageAndOverrideIfRequired(template.getImage(), options); - - ImmutableMap.Builder metadataBuilder = metatadaFromTemplateOptions.apply(options); - instanceTemplate.metadata(metadataBuilder.build()); - instanceTemplate.tags(options.getTags()); - instanceTemplate.serviceAccounts(options.getServiceAccounts()); - instanceTemplate.image(checkNotNull(template.getImage().getUri(), "image URI is null")); - - Operation operation = api.getInstanceApiForProject(userProject.get()) - .createInZone(name, instanceTemplate, template.getLocation().getId()); - - if (options.shouldBlockUntilRunning()) { - waitOperationDone(operation); - } - - // some times the newly created instances are not immediately returned - AtomicReference instance = new AtomicReference(); - - retry(new Predicate>() { - @Override - public boolean apply(AtomicReference input) { - input.set(api.getInstanceApiForProject(userProject.get()).get(name)); - return input.get() != null; - } - }, operationCompleteCheckTimeout, operationCompleteCheckInterval, MILLISECONDS).apply(instance); - - return new NodeAndInitialCredentials(instance.get(), name, credentials); - } - - - @Override - public Iterable listHardwareProfiles() { - return api.getMachineTypeApiForProject(userProject.get()).list().concat(); - } - - @Override - public Iterable listImages() { - return ImmutableSet.builder() - .addAll(api.getImageApiForProject(userProject.get()).list().concat()) - .addAll(api.getImageApiForProject(GOOGLE_PROJECT).list().concat()) - .build(); - } - - @Override - public Image getImage(String id) { - return Objects.firstNonNull(api.getImageApiForProject(userProject.get()).get(id), - api.getImageApiForProject(GOOGLE_PROJECT).get(id)); - } - - @Override - public Iterable listLocations() { - return api.getZoneApiForProject(userProject.get()).list().concat(); - } - - @Override - public Instance getNode(String name) { - return api.getInstanceApiForProject(userProject.get()).get(name); - } - - @Override - public Iterable listNodes() { - return api.getInstanceApiForProject(userProject.get()).list().concat(); - } - - @Override - public void destroyNode(final String name) { - waitOperationDone(api.getInstanceApiForProject(userProject.get()).delete(name)); - } - - @Override - public void rebootNode(String name) { - throw new UnsupportedOperationException("reboot is not supported by GCE"); - } - - @Override - public void resumeNode(String name) { - throw new UnsupportedOperationException("resume is not supported by GCE"); - } - - @Override - public void suspendNode(String name) { - throw new UnsupportedOperationException("suspend is not supported by GCE"); - } - - private LoginCredentials getFromImageAndOverrideIfRequired(org.jclouds.compute.domain.Image image, - GoogleComputeTemplateOptions options) { - LoginCredentials defaultCredentials = image.getDefaultCredentials(); - String[] keys = defaultCredentials.getPrivateKey().split(":"); - String publicKey = keys[0]; - String privateKey = keys[1]; - - LoginCredentials.Builder credentialsBuilder = defaultCredentials.toBuilder(); - credentialsBuilder.privateKey(privateKey); - - // LoginCredentials from image stores the public key along with the private key in the privateKey field - // @see GoogleComputePopulateDefaultLoginCredentialsForImageStrategy - // so if options doesn't have a public key set we set it from the default - if (options.getPublicKey() == null) { - options.authorizePublicKey(publicKey); - } - if (options.hasLoginPrivateKeyOption()) { - credentialsBuilder.privateKey(options.getPrivateKey()); - } - if (options.getLoginUser() != null) { - credentialsBuilder.identity(options.getLoginUser()); - } - if (options.hasLoginPasswordOption()) { - credentialsBuilder.password(options.getLoginPassword()); - } - if (options.shouldAuthenticateSudo() != null) { - credentialsBuilder.authenticateSudo(options.shouldAuthenticateSudo()); - } - LoginCredentials credentials = credentialsBuilder.build(); - options.overrideLoginCredentials(credentials); - return credentials; - } - - private void waitOperationDone(Operation operation) { - AtomicReference operationRef = new AtomicReference(operation); - - // wait for the operation to complete - if (!retryOperationDonePredicate.apply(operationRef)) { - throw new UncheckedTimeoutException("operation did not reach DONE state" + operationRef.get()); - } - - // check if the operation failed - if (operationRef.get().getHttpError().isPresent()) { - HttpResponse response = operationRef.get().getHttpError().get(); - throw new IllegalStateException("operation failed. Http Error Code: " + response.getStatusCode() + - " HttpError: " + response.getMessage()); - } - } - -} diff --git a/labs/google-compute/src/main/java/org/jclouds/googlecompute/compute/config/GoogleComputeServiceContextModule.java b/labs/google-compute/src/main/java/org/jclouds/googlecompute/compute/config/GoogleComputeServiceContextModule.java deleted file mode 100644 index b0421b3c85..0000000000 --- a/labs/google-compute/src/main/java/org/jclouds/googlecompute/compute/config/GoogleComputeServiceContextModule.java +++ /dev/null @@ -1,196 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.googlecompute.compute.config; - -import com.google.common.annotations.VisibleForTesting; -import com.google.common.base.Function; -import com.google.common.base.Optional; -import com.google.common.base.Predicate; -import com.google.common.base.Supplier; -import com.google.common.collect.ImmutableMap; -import com.google.inject.Injector; -import com.google.inject.Provides; -import com.google.inject.TypeLiteral; -import org.jclouds.collect.Memoized; -import org.jclouds.compute.ComputeService; -import org.jclouds.compute.ComputeServiceAdapter; -import org.jclouds.compute.config.ComputeServiceAdapterContextModule; -import org.jclouds.compute.domain.Hardware; -import org.jclouds.compute.domain.NodeMetadata; -import org.jclouds.compute.extensions.ImageExtension; -import org.jclouds.compute.options.TemplateOptions; -import org.jclouds.compute.strategy.PopulateDefaultLoginCredentialsForImageStrategy; -import org.jclouds.compute.strategy.PrioritizeCredentialsFromTemplate; -import org.jclouds.compute.strategy.impl.CreateNodesWithGroupEncodedIntoNameThenAddToSet; -import org.jclouds.domain.Location; -import org.jclouds.googlecompute.GoogleComputeApi; -import org.jclouds.googlecompute.compute.GoogleComputeService; -import org.jclouds.googlecompute.compute.GoogleComputeServiceAdapter; -import org.jclouds.googlecompute.compute.functions.BuildInstanceMetadata; -import org.jclouds.googlecompute.compute.functions.GoogleComputeImageToImage; -import org.jclouds.googlecompute.compute.functions.InstanceToNodeMetadata; -import org.jclouds.googlecompute.compute.functions.MachineTypeToHardware; -import org.jclouds.googlecompute.compute.functions.OrphanedGroupsFromDeadNodes; -import org.jclouds.googlecompute.compute.functions.ZoneToLocation; -import org.jclouds.googlecompute.compute.options.GoogleComputeTemplateOptions; -import org.jclouds.googlecompute.compute.predicates.AllNodesInGroupTerminated; -import org.jclouds.googlecompute.compute.strategy.ApplyTemplateOptionsCreateNodesWithGroupEncodedIntoNameThenAddToSet; -import org.jclouds.googlecompute.compute.strategy.GoogleComputePopulateDefaultLoginCredentialsForImageStrategy; -import org.jclouds.googlecompute.compute.strategy.UseNodeCredentialsButOverrideFromTemplate; -import org.jclouds.googlecompute.config.UserProject; -import org.jclouds.googlecompute.domain.Image; -import org.jclouds.googlecompute.domain.Instance; -import org.jclouds.googlecompute.domain.MachineType; -import org.jclouds.googlecompute.domain.Zone; - -import javax.inject.Singleton; -import java.net.URI; -import java.util.Map; -import java.util.Set; - -import static com.google.common.collect.Iterables.transform; -import static com.google.common.collect.Maps.uniqueIndex; - -/** - * @author David Alves - */ -public class GoogleComputeServiceContextModule - extends ComputeServiceAdapterContextModule { - - @Override - protected void configure() { - super.configure(); - - bind(ComputeService.class).to(GoogleComputeService.class); - - bind(new TypeLiteral>() {}) - .to(GoogleComputeServiceAdapter.class); - - bind(new TypeLiteral>() {}) - .to(InstanceToNodeMetadata.class); - - bind(new TypeLiteral>() {}) - .to(MachineTypeToHardware.class); - - bind(new TypeLiteral>() {}) - .to(GoogleComputeImageToImage.class); - - bind(new TypeLiteral>() {}) - .to(ZoneToLocation.class); - - bind(new TypeLiteral>>() {}) - .to(BuildInstanceMetadata.class); - - bind(PopulateDefaultLoginCredentialsForImageStrategy.class) - .to(GoogleComputePopulateDefaultLoginCredentialsForImageStrategy.class); - - bind(CreateNodesWithGroupEncodedIntoNameThenAddToSet.class).to( - ApplyTemplateOptionsCreateNodesWithGroupEncodedIntoNameThenAddToSet.class); - - bind(TemplateOptions.class).to(GoogleComputeTemplateOptions.class); - - bind(new TypeLiteral, Set>>() {}) - .to(OrphanedGroupsFromDeadNodes.class); - - bind(new TypeLiteral>() {}).to(AllNodesInGroupTerminated.class); - - bind(PrioritizeCredentialsFromTemplate.class).to(UseNodeCredentialsButOverrideFromTemplate.class); - - install(new LocationsFromComputeServiceAdapterModule() {}); - - } - - @Provides - @Singleton - @Memoized - public Supplier> provideImagesMap( - final Supplier> images) { - return new Supplier>() { - @Override - public Map get() { - return uniqueIndex(images.get(), new Function() { - @Override - public URI apply(org.jclouds.compute.domain.Image input) { - return input.getUri(); - } - }); - } - }; - } - - @Provides - @Singleton - @Memoized - public Supplier> provideHardwaresMap( - final Supplier> hardwares) { - return new Supplier>() { - @Override - public Map get() { - return uniqueIndex(hardwares.get(), new Function() { - @Override - public URI apply(Hardware input) { - return input.getUri(); - } - }); - } - }; - } - - @Provides - @Singleton - @Memoized - public Supplier> provideLocations( - final GoogleComputeApi api, final Function zoneToLocation, - final @UserProject Supplier userProject) { - return new Supplier>() { - @Override - public Map get() { - return uniqueIndex(transform(api.getZoneApiForProject(userProject.get()).list().concat(), zoneToLocation), - new Function() { - @Override - public URI apply(Location input) { - return (URI) input.getMetadata().get("selfLink"); - } - }); - } - }; - } - - @Override - protected Optional provideImageExtension(Injector i) { - return Optional.absent(); - } - - @VisibleForTesting - public static final Map toPortableNodeStatus = - ImmutableMap.builder() - .put(Instance.Status.PROVISIONING, NodeMetadata.Status.PENDING) - .put(Instance.Status.STAGING, NodeMetadata.Status.PENDING) - .put(Instance.Status.RUNNING, NodeMetadata.Status.RUNNING) - .put(Instance.Status.STOPPING, NodeMetadata.Status.PENDING) - .put(Instance.Status.STOPPED, NodeMetadata.Status.SUSPENDED) - .put(Instance.Status.TERMINATED, NodeMetadata.Status.TERMINATED).build(); - - @Singleton - @Provides - protected Map toPortableNodeStatus() { - return toPortableNodeStatus; - } -} diff --git a/labs/google-compute/src/main/java/org/jclouds/googlecompute/compute/functions/BuildInstanceMetadata.java b/labs/google-compute/src/main/java/org/jclouds/googlecompute/compute/functions/BuildInstanceMetadata.java deleted file mode 100644 index e867369b93..0000000000 --- a/labs/google-compute/src/main/java/org/jclouds/googlecompute/compute/functions/BuildInstanceMetadata.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.googlecompute.compute.functions; - -import com.google.common.base.Function; -import com.google.common.collect.ImmutableMap; -import org.jclouds.compute.options.TemplateOptions; - -import javax.inject.Singleton; - -import static com.google.common.base.Preconditions.checkNotNull; -import static java.lang.String.format; - -/** - * Prepares metadata from the provided TemplateOptions - * - * @author David Alves - */ -@Singleton -public class BuildInstanceMetadata implements Function> { - - @Override - public ImmutableMap.Builder apply(TemplateOptions input) { - ImmutableMap.Builder builder = ImmutableMap.builder(); - if (input.getPublicKey() != null) { - builder.put("sshKeys", format("%s:%s %s@localhost", checkNotNull(input.getLoginUser(), - "loginUser cannot be null"), input.getPublicKey(), input.getLoginUser())); - } - builder.putAll(input.getUserMetadata()); - return builder; - } - -} diff --git a/labs/google-compute/src/main/java/org/jclouds/googlecompute/compute/functions/GoogleComputeImageToImage.java b/labs/google-compute/src/main/java/org/jclouds/googlecompute/compute/functions/GoogleComputeImageToImage.java deleted file mode 100644 index dd781cbd4f..0000000000 --- a/labs/google-compute/src/main/java/org/jclouds/googlecompute/compute/functions/GoogleComputeImageToImage.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.googlecompute.compute.functions; - -import com.google.common.base.Function; -import com.google.common.collect.Lists; -import org.jclouds.compute.domain.ImageBuilder; -import org.jclouds.compute.domain.OperatingSystem; -import org.jclouds.compute.domain.OsFamily; -import org.jclouds.googlecompute.GoogleComputeConstants; -import org.jclouds.googlecompute.domain.Image; - -import java.util.List; - -import static com.google.common.base.Joiner.on; -import static com.google.common.collect.Iterables.getLast; -import static com.google.common.collect.Iterables.limit; -import static com.google.common.collect.Iterables.skip; -import static org.jclouds.compute.domain.Image.Status; -import static org.jclouds.googlecompute.GoogleComputeConstants.GOOGLE_PROVIDER_LOCATION; - -/** - * Transforms a google compute domain specific image to a generic Image object. - * - * @author David Alves - */ -public class GoogleComputeImageToImage implements Function { - - - @Override - public org.jclouds.compute.domain.Image apply(Image image) { - ImageBuilder builder = new ImageBuilder() - .id(image.getName()) - .name(image.getName()) - .providerId(image.getId()) - .description(image.getDescription().orNull()) - .status(Status.AVAILABLE) - .location(GOOGLE_PROVIDER_LOCATION) - .uri(image.getSelfLink()); - - List splits = Lists.newArrayList(image.getName().split("-")); - OperatingSystem.Builder osBuilder = defaultOperatingSystem(image); - if (splits == null || splits.size() == 0 || splits.size() < 3) { - return builder.operatingSystem(osBuilder.build()).build(); - } - - OsFamily family = OsFamily.fromValue(splits.get(0)); - if (family != OsFamily.UNRECOGNIZED) { - osBuilder.family(family); - } - - String version = on(".").join(limit(skip(splits, 1), splits.size() - 2)); - osBuilder.version(version); - - builder.version(getLast(splits)); - return builder.operatingSystem(osBuilder.build()).build(); - } - - private OperatingSystem.Builder defaultOperatingSystem(Image image) { - return OperatingSystem.builder() - .family(OsFamily.LINUX) - .is64Bit(true) - .description(image.getName()); - } - -} diff --git a/labs/google-compute/src/main/java/org/jclouds/googlecompute/compute/functions/InstanceToNodeMetadata.java b/labs/google-compute/src/main/java/org/jclouds/googlecompute/compute/functions/InstanceToNodeMetadata.java deleted file mode 100644 index 583430987e..0000000000 --- a/labs/google-compute/src/main/java/org/jclouds/googlecompute/compute/functions/InstanceToNodeMetadata.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.googlecompute.compute.functions; - -import com.google.common.base.Function; -import com.google.common.base.Supplier; -import com.google.common.collect.ImmutableSet; -import org.jclouds.collect.Memoized; -import org.jclouds.compute.domain.Hardware; -import org.jclouds.compute.domain.Image; -import org.jclouds.compute.domain.NodeMetadata; -import org.jclouds.compute.domain.NodeMetadataBuilder; -import org.jclouds.compute.functions.GroupNamingConvention; -import org.jclouds.domain.Location; -import org.jclouds.googlecompute.domain.Instance; - -import javax.inject.Inject; -import java.net.URI; -import java.util.Map; -import java.util.Set; - -import static com.google.common.base.Preconditions.checkNotNull; - -/** - * Transforms a google compute domain Instance into a generic NodeMetatada object. - * - * @author David Alves - */ -public class InstanceToNodeMetadata implements Function { - - private final Map toPortableNodeStatus; - private final GroupNamingConvention nodeNamingConvention; - private final Supplier> images; - private final Supplier> hardwares; - private final Supplier> locations; - - @Inject - public InstanceToNodeMetadata(Map toPortableNodeStatus, - GroupNamingConvention.Factory namingConvention, - @Memoized Supplier> images, - @Memoized Supplier> hardwares, - @Memoized Supplier> locations) { - this.toPortableNodeStatus = toPortableNodeStatus; - this.nodeNamingConvention = namingConvention.createWithoutPrefix(); - this.images = images; - this.hardwares = hardwares; - this.locations = locations; - } - - @Override - public NodeMetadata apply(Instance input) { - Map imagesMap = images.get(); - Image image = checkNotNull(imagesMap.get(checkNotNull(input.getImage(), "image")), - "no image for %s. images: %s", input.getImage(), imagesMap.values()); - - return new NodeMetadataBuilder() - .id(input.getName()) - .name(input.getName()) - .providerId(input.getId()) - .hostname(input.getName()) - .imageId(image.getId()) - .location(checkNotNull(locations.get().get(input.getZone()), "location for %s", input.getZone())) - .hardware(checkNotNull(hardwares.get().get(input.getMachineType()), "hardware type for %s", - input.getMachineType().toString())) - .operatingSystem(image.getOperatingSystem()) - .status(toPortableNodeStatus.get(input.getStatus())) - .tags(input.getTags()) - .uri(input.getSelfLink()) - .userMetadata(input.getMetadata()) - .group(nodeNamingConvention.groupInUniqueNameOrNull(input.getName())) - .privateAddresses(collectPrivateAddresses(input)) - .publicAddresses(collectPublicAddresses(input)) - .build(); - } - - private Set collectPrivateAddresses(Instance input) { - ImmutableSet.Builder privateAddressesBuilder = ImmutableSet.builder(); - for (Instance.NetworkInterface networkInterface : input.getNetworkInterfaces()) { - if (networkInterface.getNetworkIP().isPresent()) { - privateAddressesBuilder.add(networkInterface.getNetworkIP().get()); - } - } - return privateAddressesBuilder.build(); - } - - private Set collectPublicAddresses(Instance input) { - ImmutableSet.Builder publicAddressesBuilder = ImmutableSet.builder(); - for (Instance.NetworkInterface networkInterface : input.getNetworkInterfaces()) { - for (Instance.NetworkInterface.AccessConfig accessConfig : networkInterface.getAccessConfigs()) { - if (accessConfig.getNatIP().isPresent()) { - publicAddressesBuilder.add(accessConfig.getNatIP().get()); - } - } - } - return publicAddressesBuilder.build(); - } -} diff --git a/labs/google-compute/src/main/java/org/jclouds/googlecompute/compute/functions/MachineTypeToHardware.java b/labs/google-compute/src/main/java/org/jclouds/googlecompute/compute/functions/MachineTypeToHardware.java deleted file mode 100644 index 33d23fa634..0000000000 --- a/labs/google-compute/src/main/java/org/jclouds/googlecompute/compute/functions/MachineTypeToHardware.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.googlecompute.compute.functions; - -import com.google.common.base.Function; -import com.google.common.collect.ImmutableSet; -import org.jclouds.compute.domain.Hardware; -import org.jclouds.compute.domain.HardwareBuilder; -import org.jclouds.compute.domain.Processor; -import org.jclouds.compute.domain.Volume; -import org.jclouds.compute.domain.internal.VolumeImpl; -import org.jclouds.googlecompute.domain.MachineType; - -/** - * Transforms a google compute domain specific machine type to a generic Hardware object. - * - * @author David Alves - */ -public class MachineTypeToHardware implements Function { - - @Override - public Hardware apply(MachineType input) { - return new HardwareBuilder() - .id(input.getName()) - .name(input.getName()) - .hypervisor("kvm") - .processor(new Processor(input.getGuestCpus(), 1.0)) - .providerId(input.getId()) - .ram(input.getMemoryMb()) - .uri(input.getSelfLink()) - .volumes(collectVolumes(input)) - .build(); - } - - private Iterable collectVolumes(MachineType input) { - ImmutableSet.Builder volumes = ImmutableSet.builder(); - for (MachineType.EphemeralDisk disk : input.getEphemeralDisks()) { - volumes.add(new VolumeImpl(null, Volume.Type.LOCAL, new Integer(disk.getDiskGb()).floatValue(), null, true, - false)); - } - return volumes.build(); - } -} diff --git a/labs/google-compute/src/main/java/org/jclouds/googlecompute/compute/functions/OrphanedGroupsFromDeadNodes.java b/labs/google-compute/src/main/java/org/jclouds/googlecompute/compute/functions/OrphanedGroupsFromDeadNodes.java deleted file mode 100644 index f60397aa56..0000000000 --- a/labs/google-compute/src/main/java/org/jclouds/googlecompute/compute/functions/OrphanedGroupsFromDeadNodes.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.googlecompute.compute.functions; - -import com.google.common.base.Function; -import com.google.common.base.Predicate; -import com.google.common.collect.Sets; -import org.jclouds.compute.domain.NodeMetadata; - -import javax.inject.Inject; -import javax.inject.Singleton; -import java.util.Set; - -/** - * @author David Alves - */ -@Singleton -public class OrphanedGroupsFromDeadNodes implements Function, Set> { - - private final Predicate isOrphanedGroupPredicate; - - @Inject - public OrphanedGroupsFromDeadNodes(Predicate isOrphanedGroupPredicate) { - this.isOrphanedGroupPredicate = isOrphanedGroupPredicate; - } - - - @Override - public Set apply(Set deadNodes) { - Set groups = Sets.newLinkedHashSet(); - for (NodeMetadata deadNode : deadNodes) { - groups.add(deadNode.getGroup()); - } - Set orphanedGroups = Sets.newLinkedHashSet(); - for (String group : groups) { - if (isOrphanedGroupPredicate.apply(group)) { - orphanedGroups.add(group); - } - } - return orphanedGroups; - } - - -} diff --git a/labs/google-compute/src/main/java/org/jclouds/googlecompute/compute/functions/ZoneToLocation.java b/labs/google-compute/src/main/java/org/jclouds/googlecompute/compute/functions/ZoneToLocation.java deleted file mode 100644 index d6a8763c94..0000000000 --- a/labs/google-compute/src/main/java/org/jclouds/googlecompute/compute/functions/ZoneToLocation.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.googlecompute.compute.functions; - -import com.google.common.base.Function; -import com.google.common.collect.ImmutableMap; -import org.jclouds.domain.Location; -import org.jclouds.domain.LocationBuilder; -import org.jclouds.domain.LocationScope; -import org.jclouds.googlecompute.domain.Zone; - -import static com.google.common.base.Preconditions.checkNotNull; -import static org.jclouds.googlecompute.GoogleComputeConstants.GOOGLE_PROVIDER_LOCATION; - -/** - * Transforms a google compute domain specific zone to a generic Zone object. - * - * @author David Alves - */ -public class ZoneToLocation implements Function { - - @Override - public Location apply(Zone input) { - return new LocationBuilder() - .description(input.getDescription().orNull()) - .metadata(ImmutableMap.of("selfLink", (Object) checkNotNull(input.getSelfLink(), "zone URI"))) - .id(input.getName()) - .scope(LocationScope.ZONE) - .parent(GOOGLE_PROVIDER_LOCATION) - .build(); - } -} diff --git a/labs/google-compute/src/main/java/org/jclouds/googlecompute/compute/options/GoogleComputeTemplateOptions.java b/labs/google-compute/src/main/java/org/jclouds/googlecompute/compute/options/GoogleComputeTemplateOptions.java deleted file mode 100644 index 9f8d9c98ad..0000000000 --- a/labs/google-compute/src/main/java/org/jclouds/googlecompute/compute/options/GoogleComputeTemplateOptions.java +++ /dev/null @@ -1,280 +0,0 @@ -package org.jclouds.googlecompute.compute.options; - -import com.google.common.base.Optional; -import com.google.common.collect.Sets; -import org.jclouds.compute.options.TemplateOptions; -import org.jclouds.domain.LoginCredentials; -import org.jclouds.googlecompute.domain.Instance; -import org.jclouds.scriptbuilder.domain.Statement; - -import java.net.URI; -import java.util.Map; -import java.util.Set; - -import static com.google.common.base.Optional.fromNullable; -import static org.jclouds.googlecompute.domain.Instance.ServiceAccount; - -/** - * Instance options specific to Google Compute Engine. - * - * @author David Alves - */ -public class GoogleComputeTemplateOptions extends TemplateOptions { - - private Optional network = Optional.absent(); - private Optional networkName = Optional.absent(); - private Set serviceAccounts = Sets.newLinkedHashSet(); - private boolean enableNat = true; - - @Override - public GoogleComputeTemplateOptions clone() { - GoogleComputeTemplateOptions options = new GoogleComputeTemplateOptions(); - copyTo(options); - return options; - } - - @Override - public void copyTo(TemplateOptions to) { - super.copyTo(to); - if (to instanceof GoogleComputeTemplateOptions) { - GoogleComputeTemplateOptions eTo = GoogleComputeTemplateOptions.class.cast(to); - eTo.network(getNetwork().orNull()); - eTo.network(getNetworkName().orNull()); - eTo.serviceAccounts(getServiceAccounts()); - eTo.enableNat(isEnableNat()); - } - } - - /** - * @see #getNetworkName() - */ - public GoogleComputeTemplateOptions network(String networkName) { - this.networkName = fromNullable(networkName); - return this; - } - - /** - * @see #getNetwork() - */ - public GoogleComputeTemplateOptions network(URI network) { - this.network = fromNullable(network); - return this; - } - - /** - * @see #getServiceAccounts() - * @see ServiceAccount - */ - public GoogleComputeTemplateOptions addServiceAccount(ServiceAccount serviceAccout) { - this.serviceAccounts.add(serviceAccout); - return this; - } - - /** - * @see #getServiceAccounts() - * @see ServiceAccount - */ - public GoogleComputeTemplateOptions serviceAccounts(Set serviceAccounts) { - this.serviceAccounts = Sets.newLinkedHashSet(serviceAccounts); - return this; - } - - /** - * @see #isEnableNat() - */ - public GoogleComputeTemplateOptions enableNat(boolean enableNat) { - this.enableNat = enableNat; - return this; - } - - /** - * {@inheritDoc} - */ - @Override - public GoogleComputeTemplateOptions blockOnPort(int port, int seconds) { - return GoogleComputeTemplateOptions.class.cast(super.blockOnPort(port, seconds)); - } - - /** - * {@inheritDoc} - */ - @Override - public GoogleComputeTemplateOptions inboundPorts(int... ports) { - return GoogleComputeTemplateOptions.class.cast(super.inboundPorts(ports)); - } - - /** - * {@inheritDoc} - */ - @Override - public GoogleComputeTemplateOptions authorizePublicKey(String publicKey) { - return GoogleComputeTemplateOptions.class.cast(super.authorizePublicKey(publicKey)); - } - - /** - * {@inheritDoc} - */ - @Override - public GoogleComputeTemplateOptions installPrivateKey(String privateKey) { - return GoogleComputeTemplateOptions.class.cast(super.installPrivateKey(privateKey)); - } - - /** - * {@inheritDoc} - */ - @Override - public GoogleComputeTemplateOptions blockUntilRunning(boolean blockUntilRunning) { - return GoogleComputeTemplateOptions.class.cast(super.blockUntilRunning(blockUntilRunning)); - } - - /** - * {@inheritDoc} - */ - @Override - public GoogleComputeTemplateOptions dontAuthorizePublicKey() { - return GoogleComputeTemplateOptions.class.cast(super.dontAuthorizePublicKey()); - } - - /** - * {@inheritDoc} - */ - @Override - public GoogleComputeTemplateOptions nameTask(String name) { - return GoogleComputeTemplateOptions.class.cast(super.nameTask(name)); - } - - /** - * {@inheritDoc} - */ - @Override - public GoogleComputeTemplateOptions runAsRoot(boolean runAsRoot) { - return GoogleComputeTemplateOptions.class.cast(super.runAsRoot(runAsRoot)); - } - - /** - * {@inheritDoc} - */ - @Override - public GoogleComputeTemplateOptions runScript(Statement script) { - return GoogleComputeTemplateOptions.class.cast(super.runScript(script)); - } - - /** - * {@inheritDoc} - */ - @Override - public GoogleComputeTemplateOptions overrideLoginCredentials(LoginCredentials overridingCredentials) { - return GoogleComputeTemplateOptions.class.cast(super.overrideLoginCredentials(overridingCredentials)); - } - - /** - * {@inheritDoc} - */ - @Override - public GoogleComputeTemplateOptions overrideLoginPassword(String password) { - return GoogleComputeTemplateOptions.class.cast(super.overrideLoginPassword(password)); - } - - /** - * {@inheritDoc} - */ - @Override - public GoogleComputeTemplateOptions overrideLoginPrivateKey(String privateKey) { - return GoogleComputeTemplateOptions.class.cast(super.overrideLoginPrivateKey(privateKey)); - } - - /** - * {@inheritDoc} - */ - @Override - public GoogleComputeTemplateOptions overrideLoginUser(String loginUser) { - return GoogleComputeTemplateOptions.class.cast(super.overrideLoginUser(loginUser)); - } - - /** - * {@inheritDoc} - */ - @Override - public GoogleComputeTemplateOptions overrideAuthenticateSudo(boolean authenticateSudo) { - return GoogleComputeTemplateOptions.class.cast(super.overrideAuthenticateSudo(authenticateSudo)); - } - - /** - * {@inheritDoc} - */ - @Override - public GoogleComputeTemplateOptions userMetadata(Map userMetadata) { - return GoogleComputeTemplateOptions.class.cast(super.userMetadata(userMetadata)); - } - - /** - * {@inheritDoc} - */ - @Override - public GoogleComputeTemplateOptions userMetadata(String key, String value) { - return GoogleComputeTemplateOptions.class.cast(super.userMetadata(key, value)); - } - - /** - * {@inheritDoc} - */ - @Override - public GoogleComputeTemplateOptions tags(Iterable tags) { - return GoogleComputeTemplateOptions.class.cast(super.tags(tags)); - } - - /** - * {@inheritDoc} - */ - @Override - public GoogleComputeTemplateOptions wrapInInitScript(boolean wrapInInitScript) { - return GoogleComputeTemplateOptions.class.cast(super.wrapInInitScript(wrapInInitScript)); - } - - /** - * {@inheritDoc} - */ - @Override - public GoogleComputeTemplateOptions runScript(String script) { - return GoogleComputeTemplateOptions.class.cast(super.runScript(script)); - } - - /** - * {@inheritDoc} - */ - @Override - public GoogleComputeTemplateOptions blockOnComplete(boolean blockOnComplete) { - return GoogleComputeTemplateOptions.class.cast(super.blockOnComplete(blockOnComplete)); - } - - /** - * @return the ServiceAccounts to enable in the instances. - */ - public Set getServiceAccounts() { - return serviceAccounts; - } - - /** - * @return the URI of an existing network the instances will be attached to. If no network URI or network name are - * provided a new network will be created for the project. - */ - public Optional getNetwork() { - return network; - } - - /** - * @return the name of an existing network the instances will be attached to, the network is assumed to belong to - * user's project. If no network URI network name are provided a new network will be created for the project. - */ - public Optional getNetworkName() { - return networkName; - } - - /** - * @return whether an AccessConfig with Type ONE_TO_ONE_NAT should be enabled in the instances. When true - * instances will have a NAT address that will be publicly accessible. - */ - public boolean isEnableNat() { - return enableNat; - } -} diff --git a/labs/google-compute/src/main/java/org/jclouds/googlecompute/compute/predicates/AllNodesInGroupTerminated.java b/labs/google-compute/src/main/java/org/jclouds/googlecompute/compute/predicates/AllNodesInGroupTerminated.java deleted file mode 100644 index b03f26b001..0000000000 --- a/labs/google-compute/src/main/java/org/jclouds/googlecompute/compute/predicates/AllNodesInGroupTerminated.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.googlecompute.compute.predicates; - -import com.google.common.base.Predicate; -import org.jclouds.compute.ComputeService; - -import javax.inject.Inject; -import javax.inject.Singleton; - -import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.collect.Iterables.all; -import static com.google.common.collect.Sets.filter; -import static org.jclouds.compute.predicates.NodePredicates.TERMINATED; -import static org.jclouds.compute.predicates.NodePredicates.all; -import static org.jclouds.compute.predicates.NodePredicates.inGroup; - -/** - * @author David Alves - */ -@Singleton -public class AllNodesInGroupTerminated implements Predicate { - - private final ComputeService computeService; - - @Inject - public AllNodesInGroupTerminated(ComputeService computeService) { - this.computeService = checkNotNull(computeService, "compute service"); - } - - - @Override - public boolean apply(String groupName) { - return all(filter(computeService.listNodesDetailsMatching(all()), inGroup(groupName)), TERMINATED); - } -} diff --git a/labs/google-compute/src/main/java/org/jclouds/googlecompute/compute/strategy/ApplyTemplateOptionsCreateNodesWithGroupEncodedIntoNameThenAddToSet.java b/labs/google-compute/src/main/java/org/jclouds/googlecompute/compute/strategy/ApplyTemplateOptionsCreateNodesWithGroupEncodedIntoNameThenAddToSet.java deleted file mode 100644 index 8645ea9f22..0000000000 --- a/labs/google-compute/src/main/java/org/jclouds/googlecompute/compute/strategy/ApplyTemplateOptionsCreateNodesWithGroupEncodedIntoNameThenAddToSet.java +++ /dev/null @@ -1,200 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.googlecompute.compute.strategy; - -import com.google.common.base.Predicate; -import com.google.common.base.Supplier; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Multimap; -import com.google.common.util.concurrent.ListenableFuture; -import com.google.common.util.concurrent.ListeningExecutorService; -import org.jclouds.Constants; -import org.jclouds.compute.config.CustomizationResponse; -import org.jclouds.compute.domain.NodeMetadata; -import org.jclouds.compute.domain.Template; -import org.jclouds.compute.functions.GroupNamingConvention; -import org.jclouds.compute.strategy.CreateNodeWithGroupEncodedIntoName; -import org.jclouds.compute.strategy.CustomizeNodeAndAddToGoodMapOrPutExceptionIntoBadMap; -import org.jclouds.compute.strategy.ListNodesStrategy; -import org.jclouds.compute.strategy.impl.CreateNodesWithGroupEncodedIntoNameThenAddToSet; -import org.jclouds.googlecompute.GoogleComputeApi; -import org.jclouds.googlecompute.compute.options.GoogleComputeTemplateOptions; -import org.jclouds.googlecompute.config.UserProject; -import org.jclouds.googlecompute.domain.Firewall; -import org.jclouds.googlecompute.domain.Network; -import org.jclouds.googlecompute.domain.Operation; -import org.jclouds.googlecompute.options.FirewallOptions; - -import javax.inject.Inject; -import javax.inject.Named; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.atomic.AtomicReference; - -import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.collect.ImmutableSet.of; -import static java.util.concurrent.TimeUnit.MILLISECONDS; -import static org.jclouds.googlecompute.GoogleComputeConstants.OPERATION_COMPLETE_INTERVAL; -import static org.jclouds.googlecompute.GoogleComputeConstants.OPERATION_COMPLETE_TIMEOUT; -import static org.jclouds.util.Predicates2.retry; - -/** - * @author David Alves - */ -public class ApplyTemplateOptionsCreateNodesWithGroupEncodedIntoNameThenAddToSet extends - CreateNodesWithGroupEncodedIntoNameThenAddToSet { - - public static final String EXTERIOR_RANGE = "0.0.0.0/0"; - public static final String DEFAULT_INTERNAL_NETWORK_RANGE = "10.0.0.0/8"; - - private final GoogleComputeApi api; - private final Supplier userProject; - private final Predicate> operationDonePredicate; - private final long operationCompleteCheckInterval; - private final long operationCompleteCheckTimeout; - - @Inject - protected ApplyTemplateOptionsCreateNodesWithGroupEncodedIntoNameThenAddToSet( - CreateNodeWithGroupEncodedIntoName addNodeWithGroupStrategy, - ListNodesStrategy listNodesStrategy, - GroupNamingConvention.Factory namingConvention, - @Named(Constants.PROPERTY_USER_THREADS) - ListeningExecutorService userExecutor, - CustomizeNodeAndAddToGoodMapOrPutExceptionIntoBadMap.Factory - customizeNodeAndAddToGoodMapOrPutExceptionIntoBadMapFactory, - GoogleComputeApi api, - @UserProject Supplier userProject, - Predicate> operationDonePredicate, - @Named(OPERATION_COMPLETE_INTERVAL) Long operationCompleteCheckInterval, - @Named(OPERATION_COMPLETE_TIMEOUT) Long operationCompleteCheckTimeout) { - super(addNodeWithGroupStrategy, listNodesStrategy, namingConvention, userExecutor, - customizeNodeAndAddToGoodMapOrPutExceptionIntoBadMapFactory); - - this.api = checkNotNull(api, "google compute api"); - this.userProject = checkNotNull(userProject, "user project name"); - this.operationCompleteCheckInterval = checkNotNull(operationCompleteCheckInterval, - "operation completed check interval"); - this.operationCompleteCheckTimeout = checkNotNull(operationCompleteCheckTimeout, - "operation completed check timeout"); - this.operationDonePredicate = operationDonePredicate; - } - - @Override - public Map> execute(String group, int count, Template template, - Set goodNodes, Map badNodes, - Multimap customizationResponses) { - - String sharedResourceName = namingConvention.create().sharedNameForGroup(group); - Template mutableTemplate = template.clone(); - GoogleComputeTemplateOptions templateOptions = GoogleComputeTemplateOptions.class.cast(mutableTemplate - .getOptions()); - assert template.getOptions().equals(templateOptions) : "options didn't clone properly"; - - // get or create the network and create a firewall with the users configuration - Network network = getOrCreateNetwork(templateOptions, sharedResourceName); - createFirewall(templateOptions, network, sharedResourceName); - templateOptions.network(network.getSelfLink()); - - return super.execute(group, count, mutableTemplate, goodNodes, badNodes, customizationResponses); - } - - /** - * Try and find a network either previously created by jclouds or user defined. - */ - private Network getOrCreateNetwork(GoogleComputeTemplateOptions templateOptions, String sharedResourceName) { - - String networkName = templateOptions.getNetworkName().isPresent() ? templateOptions.getNetworkName().get() : - sharedResourceName; - - // check if the network was previously created (cache???) - Network network = api.getNetworkApiForProject(userProject.get()).get(networkName); - - if (network != null) { - return network; - } - - if (network == null && templateOptions.getNetwork().isPresent()) { - throw new IllegalStateException("user defined network does not exist: " + templateOptions.getNetwork().get()); - } - - AtomicReference operation = new AtomicReference(api.getNetworkApiForProject(userProject - .get()).createInIPv4Range(sharedResourceName, DEFAULT_INTERNAL_NETWORK_RANGE)); - retry(operationDonePredicate, operationCompleteCheckTimeout, operationCompleteCheckInterval, - MILLISECONDS).apply(operation); - if (operation.get().getHttpError().isPresent()) { - throw new IllegalStateException("Could not create network, operation failed" + operation); - } - - return checkNotNull(api.getNetworkApiForProject(userProject.get()).get(sharedResourceName), - "no network with name %s was found", sharedResourceName); - - } - - /** - * Tries to find if a firewall already exists for this group, if not it creates one. - * - * @see org.jclouds.googlecompute.features.FirewallAsyncApi#patch(String, org.jclouds.googlecompute.options.FirewallOptions) - */ - private void createFirewall(GoogleComputeTemplateOptions templateOptions, Network network, - String sharedResourceName) { - - Firewall firewall = api.getFirewallApiForProject(userProject.get()).get(sharedResourceName); - - if (firewall != null) { - return; - } - - ImmutableSet.Builder rules = ImmutableSet.builder(); - - Firewall.Rule.Builder tcpRule = Firewall.Rule.builder(); - tcpRule.IPProtocol(Firewall.Rule.IPProtocol.TCP); - Firewall.Rule.Builder udpRule = Firewall.Rule.builder(); - udpRule.IPProtocol(Firewall.Rule.IPProtocol.UDP); - for (Integer port : templateOptions.getInboundPorts()) { - tcpRule.addPort(port); - udpRule.addPort(port); - } - rules.add(tcpRule.build()); - rules.add(udpRule.build()); - - - FirewallOptions options = new FirewallOptions() - .name(sharedResourceName) - .network(network.getSelfLink()) - .sourceTags(templateOptions.getTags()) - .allowedRules(rules.build()) - .sourceRanges(of(DEFAULT_INTERNAL_NETWORK_RANGE, EXTERIOR_RANGE)); - - AtomicReference operation = new AtomicReference(api.getFirewallApiForProject(userProject - .get()).createInNetwork( - sharedResourceName, - network.getSelfLink(), - options)); - - retry(operationDonePredicate, operationCompleteCheckTimeout, operationCompleteCheckInterval, - MILLISECONDS).apply(operation); - - if (operation.get().getHttpError().isPresent()) { - throw new IllegalStateException("Could not create firewall, operation failed" + operation.get()); - } - } - - -} diff --git a/labs/google-compute/src/main/java/org/jclouds/googlecompute/compute/strategy/GoogleComputePopulateDefaultLoginCredentialsForImageStrategy.java b/labs/google-compute/src/main/java/org/jclouds/googlecompute/compute/strategy/GoogleComputePopulateDefaultLoginCredentialsForImageStrategy.java deleted file mode 100644 index 4f454e2648..0000000000 --- a/labs/google-compute/src/main/java/org/jclouds/googlecompute/compute/strategy/GoogleComputePopulateDefaultLoginCredentialsForImageStrategy.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.googlecompute.compute.strategy; - -import com.google.inject.Inject; -import org.jclouds.compute.domain.TemplateBuilderSpec; -import org.jclouds.compute.strategy.PopulateDefaultLoginCredentialsForImageStrategy; -import org.jclouds.domain.LoginCredentials; -import org.jclouds.ssh.internal.RsaSshKeyPairGenerator; - -import javax.annotation.PostConstruct; -import javax.inject.Named; -import javax.inject.Singleton; -import java.security.NoSuchAlgorithmException; -import java.util.Map; - -import static com.google.common.base.Preconditions.checkNotNull; -import static org.jclouds.compute.config.ComputeServiceProperties.TEMPLATE; - -/** - * @author David Alves - */ -@Singleton -public class GoogleComputePopulateDefaultLoginCredentialsForImageStrategy implements - PopulateDefaultLoginCredentialsForImageStrategy { - - private final TemplateBuilderSpec templateBuilder; - private final RsaSshKeyPairGenerator keyPairGenerator; - private String compoundKey; - - @Inject - GoogleComputePopulateDefaultLoginCredentialsForImageStrategy(@Named(TEMPLATE) String templateSpec, - RsaSshKeyPairGenerator keyPairGenerator) - throws NoSuchAlgorithmException { - this.templateBuilder = TemplateBuilderSpec.parse(checkNotNull(templateSpec, "template builder spec")); - checkNotNull(templateBuilder.getLoginUser(), "template builder spec must provide a loginUser"); - this.keyPairGenerator = checkNotNull(keyPairGenerator, "keypair generator"); - } - - @PostConstruct - private void generateKeys() { - Map keys = keyPairGenerator.get(); - // as we need to store both the pubk and the pk, store them separated by : (base64 does not contain that char) - compoundKey = String.format("%s:%s", checkNotNull(keys.get("public"), "public key cannot be null"), - checkNotNull(keys.get("private"), "private key cannot be null")); - } - - @Override - public LoginCredentials apply(Object image) { - return LoginCredentials.builder() - .authenticateSudo(templateBuilder.getAuthenticateSudo() != null ? - templateBuilder.getAuthenticateSudo() : false) - .privateKey(compoundKey) - .user(templateBuilder.getLoginUser()).build(); - } - -} diff --git a/labs/google-compute/src/main/java/org/jclouds/googlecompute/compute/strategy/UseNodeCredentialsButOverrideFromTemplate.java b/labs/google-compute/src/main/java/org/jclouds/googlecompute/compute/strategy/UseNodeCredentialsButOverrideFromTemplate.java deleted file mode 100644 index 0377539421..0000000000 --- a/labs/google-compute/src/main/java/org/jclouds/googlecompute/compute/strategy/UseNodeCredentialsButOverrideFromTemplate.java +++ /dev/null @@ -1,42 +0,0 @@ -package org.jclouds.googlecompute.compute.strategy; - -import com.google.common.base.Function; -import com.google.inject.Inject; -import com.google.inject.Singleton; -import org.jclouds.compute.domain.Template; -import org.jclouds.compute.options.RunScriptOptions; -import org.jclouds.compute.strategy.PrioritizeCredentialsFromTemplate; -import org.jclouds.domain.LoginCredentials; - -import static com.google.common.base.Preconditions.checkNotNull; - -/** - * GCE needs the credentials to create the node so the node credentials already take the Image credentials into account, - * as such only overriding the TemplateOptions credentials is required. - * - * @author David Alves - */ -@Singleton -public class UseNodeCredentialsButOverrideFromTemplate extends PrioritizeCredentialsFromTemplate { - - - @Inject - public UseNodeCredentialsButOverrideFromTemplate( - Function credentialsFromImageOrTemplateOptions) { - super(credentialsFromImageOrTemplateOptions); - } - - public LoginCredentials apply(Template template, LoginCredentials fromNode) { - RunScriptOptions options = checkNotNull(template.getOptions(), "template options are required"); - LoginCredentials.Builder builder = LoginCredentials.builder(fromNode); - if (options.getLoginUser() != null) - builder.user(template.getOptions().getLoginUser()); - if (options.getLoginPassword() != null) - builder.password(options.getLoginPassword()); - if (options.getLoginPrivateKey() != null) - builder.privateKey(options.getLoginPrivateKey()); - if (options.shouldAuthenticateSudo() != null && options.shouldAuthenticateSudo()) - builder.authenticateSudo(true); - return builder.build(); - } -} diff --git a/labs/google-compute/src/main/java/org/jclouds/googlecompute/config/GoogleComputeParserModule.java b/labs/google-compute/src/main/java/org/jclouds/googlecompute/config/GoogleComputeParserModule.java deleted file mode 100644 index 8fe8d9d0a6..0000000000 --- a/labs/google-compute/src/main/java/org/jclouds/googlecompute/config/GoogleComputeParserModule.java +++ /dev/null @@ -1,375 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.googlecompute.config; - -import com.google.common.collect.ForwardingMap; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.Range; -import com.google.gson.JsonArray; -import com.google.gson.JsonDeserializationContext; -import com.google.gson.JsonDeserializer; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParseException; -import com.google.gson.JsonPrimitive; -import com.google.gson.JsonSerializationContext; -import com.google.gson.JsonSerializer; -import com.google.inject.AbstractModule; -import com.google.inject.Provides; -import org.jclouds.googlecompute.domain.Firewall; -import org.jclouds.googlecompute.domain.Instance; -import org.jclouds.googlecompute.domain.InstanceTemplate; -import org.jclouds.googlecompute.domain.Operation; -import org.jclouds.googlecompute.domain.Project; -import org.jclouds.googlecompute.options.FirewallOptions; -import org.jclouds.json.config.GsonModule; -import org.jclouds.oauth.v2.domain.ClaimSet; -import org.jclouds.oauth.v2.domain.Header; -import org.jclouds.oauth.v2.json.ClaimSetTypeAdapter; -import org.jclouds.oauth.v2.json.HeaderTypeAdapter; - -import javax.inject.Singleton; -import java.beans.ConstructorProperties; -import java.lang.reflect.Type; -import java.net.URI; -import java.util.Date; -import java.util.Map; -import java.util.Set; - -import static org.jclouds.googlecompute.domain.Firewall.Rule; - -/** - * @author David Alves - */ -public class GoogleComputeParserModule extends AbstractModule { - - @Override - protected void configure() { - bind(GsonModule.DateAdapter.class).to(GsonModule.Iso8601DateAdapter.class); - } - - @Provides - @Singleton - public Map provideCustomAdapterBindings() { - return new ImmutableMap.Builder() - .put(Metadata.class, new MetadataTypeAdapter()) - .put(Operation.class, new OperationTypeAdapter()) - .put(Header.class, new HeaderTypeAdapter()) - .put(ClaimSet.class, new ClaimSetTypeAdapter()) - .put(Project.class, new ProjectTypeAdapter()) - .put(Instance.class, new InstanceTypeAdapter()) - .put(InstanceTemplate.class, new InstanceTemplateTypeAdapter()) - .put(FirewallOptions.class, new FirewallOptionsTypeAdapter()) - .put(Rule.class, new RuleTypeAdapter()) - .build(); - } - - /** - * Parser for operations that unwraps errors avoiding an extra intermediate object. - * - * @see - */ - @Singleton - private static class OperationTypeAdapter implements JsonDeserializer { - - @Override - public Operation deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws - JsonParseException { - Operation.Builder operationBuilder = ((Operation) context.deserialize(json, - OperationInternal.class)).toBuilder(); - JsonObject error = json.getAsJsonObject().getAsJsonObject("error"); - if (error != null) { - JsonArray array = error.getAsJsonArray("errors"); - if (array != null) { - for (JsonElement element : array) { - operationBuilder.addError((Operation.Error) context.deserialize(element, Operation.Error.class)); - } - } - } - return operationBuilder.build(); - } - - private static class OperationInternal extends Operation { - @ConstructorProperties({ - "id", "creationTimestamp", "selfLink", "name", "description", "targetLink", "targetId", - "clientOperationId", "status", "statusMessage", "user", "progress", "insertTime", "startTime", - "endTime", "httpErrorStatusCode", "httpErrorMessage", "operationType" - }) - private OperationInternal(String id, Date creationTimestamp, URI selfLink, String name, - String description, URI targetLink, String targetId, String clientOperationId, - Status status, String statusMessage, String user, int progress, Date insertTime, - Date startTime, Date endTime, int httpErrorStatusCode, String httpErrorMessage, - String operationType) { - super(id, creationTimestamp, selfLink, name, description, targetLink, targetId, clientOperationId, - status, statusMessage, user, progress, insertTime, startTime, endTime, httpErrorStatusCode, - httpErrorMessage, operationType, null); - } - } - } - - @Singleton - private static class InstanceTemplateTypeAdapter implements JsonSerializer { - - @Override - public JsonElement serialize(InstanceTemplate src, Type typeOfSrc, JsonSerializationContext context) { - InstanceTemplateInternal template = new InstanceTemplateInternal(src); - JsonObject instance = (JsonObject) context.serialize(template, InstanceTemplateInternal.class); - - // deal with network - JsonArray networkInterfaces = new JsonArray(); - for (InstanceTemplate.NetworkInterface networkInterface : template.getNetworkInterfaces()){ - networkInterfaces.add(context.serialize(networkInterface, InstanceTemplate.NetworkInterface.class)); - } - instance.add("networkInterfaces", networkInterfaces); - - // deal with persistent disks - if (src.getDisks() != null && !src.getDisks().isEmpty()) { - JsonArray disks = new JsonArray(); - for (InstanceTemplate.PersistentDisk persistentDisk : src.getDisks()) { - JsonObject disk = (JsonObject) context.serialize(persistentDisk, InstanceTemplate.PersistentDisk.class); - disk.addProperty("type", "PERSISTENT"); - disks.add(disk); - } - instance.add("disks", disks); - } - - // deal with metadata - if (src.getMetadata() != null && !src.getMetadata().isEmpty()) { - JsonObject metadata = (JsonObject) context.serialize(new Metadata(src.getMetadata())); - instance.add("metadata", metadata); - return instance; - } - - return instance; - } - - private static class InstanceTemplateInternal extends InstanceTemplate { - private InstanceTemplateInternal(InstanceTemplate template) { - super(template.getMachineType()); - name(template.getName()); - description(template.getDescription()); - zone(template.getZone()); - image(template.getImage()); - tags(template.getTags()); - serviceAccounts(template.getServiceAccounts()); - networkInterfaces(template.getNetworkInterfaces()); - } - } - } - - @Singleton - private static class InstanceTypeAdapter implements JsonDeserializer { - - @Override - public Instance deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws - JsonParseException { - Instance.Builder instanceBuilder = ((Instance) context.deserialize(json, - InstanceInternal.class)).toBuilder(); - JsonObject object = (JsonObject) json; - if (object.get("disks") != null) { - JsonArray disks = (JsonArray) object.get("disks"); - for (JsonElement element : disks) { - JsonObject disk = (JsonObject) element; - if (disk.get("type").getAsString().equals("PERSISTENT")) { - instanceBuilder.addDisk((Instance.PersistentAttachedDisk) context.deserialize(disk, - Instance.PersistentAttachedDisk.class)); - } else { - instanceBuilder.addDisk((Instance.AttachedDisk) context.deserialize(disk, - Instance.AttachedDisk.class)); - } - } - - } - - return Instance.builder().fromInstance(instanceBuilder.build()).build(); - } - - - private static class InstanceInternal extends Instance { - @ConstructorProperties({ - "id", "creationTimestamp", "selfLink", "name", "description", "tags", "image", "machineType", - "status", "statusMessage", "zone", "networkInterfaces", "metadata", "serviceAccounts" - }) - private InstanceInternal(String id, Date creationTimestamp, URI selfLink, String name, String description, - Set tags, URI image, URI machineType, Status status, String statusMessage, - URI zone, Set networkInterfaces, Metadata metadata, - Set serviceAccounts) { - super(id, creationTimestamp, selfLink, name, description, tags, image, machineType, - status, statusMessage, zone, networkInterfaces, null, metadata, serviceAccounts); - } - } - } - - /** - * Parser for Metadata. - */ - @Singleton - private static class MetadataTypeAdapter implements JsonDeserializer, JsonSerializer { - - - @Override - public Metadata deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws - JsonParseException { - ImmutableMap.Builder builder = ImmutableMap.builder(); - JsonObject metadata = json.getAsJsonObject(); - JsonArray items = metadata.getAsJsonArray("items"); - if (items != null) { - for (JsonElement element : items) { - JsonObject object = element.getAsJsonObject(); - builder.put(object.get("key").getAsString(), object.get("value").getAsString()); - } - } - return new Metadata(builder.build()); - } - - @Override - public JsonElement serialize(Metadata src, Type typeOfSrc, JsonSerializationContext context) { - JsonObject metadataObject = new JsonObject(); - metadataObject.add("kind", new JsonPrimitive("compute#metadata")); - JsonArray items = new JsonArray(); - for (Map.Entry entry : src.entrySet()) { - JsonObject object = new JsonObject(); - object.addProperty("key", entry.getKey()); - object.addProperty("value", entry.getValue()); - items.add(object); - } - metadataObject.add("items", items); - return metadataObject; - } - } - - public static class Metadata extends ForwardingMap { - - private final Map delegate; - - public Metadata(Map delegate) { - this.delegate = delegate; - } - - @Override - protected Map delegate() { - return delegate; - } - } - - @Singleton - private static class ProjectTypeAdapter implements JsonDeserializer { - - @Override - public Project deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws - JsonParseException { - return Project.builder().fromProject((Project) context.deserialize(json, ProjectInternal.class)).build(); - } - - private static class ProjectInternal extends Project { - - @ConstructorProperties({ - "id", "creationTimestamp", "selfLink", "name", "description", "commonInstanceMetadata", "quotas", - "externalIpAddresses" - }) - private ProjectInternal(String id, Date creationTimestamp, URI selfLink, String name, String description, - Metadata commonInstanceMetadata, Set quotas, Set externalIpAddresses) { - super(id, creationTimestamp, selfLink, name, description, commonInstanceMetadata, quotas, - externalIpAddresses); - } - - } - } - - @Singleton - private static class FirewallOptionsTypeAdapter implements JsonSerializer { - - @Override - public JsonElement serialize(FirewallOptions src, Type typeOfSrc, JsonSerializationContext context) { - JsonObject firewall = new JsonObject(); - if (src.getName() != null) { - firewall.addProperty("name", src.getName()); - } - if (src.getNetwork() != null) { - firewall.addProperty("network", src.getNetwork().toString()); - } - if (!src.getSourceRanges().isEmpty()) { - firewall.add("sourceRanges", buildArrayOfStrings(src.getSourceRanges())); - } - if (!src.getSourceTags().isEmpty()) { - firewall.add("sourceTags", buildArrayOfStrings(src.getSourceTags())); - } - if (!src.getTargetTags().isEmpty()) { - firewall.add("targetTags", buildArrayOfStrings(src.getTargetTags())); - } - if (!src.getAllowed().isEmpty()) { - JsonArray rules = new JsonArray(); - for (Rule rule : src.getAllowed()) { - rules.add(context.serialize(rule, Firewall.Rule.class)); - } - firewall.add("allowed", rules); - } - return firewall; - } - } - - private static JsonArray buildArrayOfStrings(Set strings) { - JsonArray array = new JsonArray(); - for (String string : strings) { - array.add(new JsonPrimitive(string)); - } - return array; - } - - - private static class RuleTypeAdapter implements JsonDeserializer, JsonSerializer { - - @Override - public Firewall.Rule deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws - JsonParseException { - JsonObject rule = json.getAsJsonObject(); - Rule.Builder builder = Rule.builder(); - builder.IPProtocol(Rule.IPProtocol.fromValue(rule.get("IPProtocol").getAsString())); - if (rule.get("ports") != null) { - JsonArray ports = (JsonArray) rule.get("ports"); - for (JsonElement port : ports) { - String portAsString = port.getAsString(); - if (portAsString.contains("-")) { - String[] split = portAsString.split("-"); - builder.addPortRange(Integer.parseInt(split[0]), Integer.parseInt(split[1])); - } else { - builder.addPort(Integer.parseInt(portAsString)); - } - } - } - return builder.build(); - } - - @Override - public JsonElement serialize(Firewall.Rule src, Type typeOfSrc, JsonSerializationContext context) { - JsonObject ruleObject = new JsonObject(); - ruleObject.addProperty("IPProtocol", src.getIPProtocol().value()); - if (src.getPorts() != null && !src.getPorts().isEmpty()) { - JsonArray ports = new JsonArray(); - for (Range range : src.getPorts().asRanges()) { - ports.add(new JsonPrimitive(range.lowerEndpoint() == range.upperEndpoint() ? range.lowerEndpoint() + "" : - range.lowerEndpoint() + "-" + range.upperEndpoint())); - } - ruleObject.add("ports", ports); - } - return ruleObject; - } - } -} diff --git a/labs/google-compute/src/main/java/org/jclouds/googlecompute/config/GoogleComputeRestClientModule.java b/labs/google-compute/src/main/java/org/jclouds/googlecompute/config/GoogleComputeRestClientModule.java deleted file mode 100644 index 97c7258e7e..0000000000 --- a/labs/google-compute/src/main/java/org/jclouds/googlecompute/config/GoogleComputeRestClientModule.java +++ /dev/null @@ -1,173 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.googlecompute.config; - -import com.google.common.base.Function; -import com.google.common.base.Predicate; -import com.google.common.base.Splitter; -import com.google.common.base.Supplier; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.Iterables; -import com.google.inject.Provides; -import com.google.inject.TypeLiteral; -import org.jclouds.domain.Credentials; -import org.jclouds.googlecompute.GoogleComputeApi; -import org.jclouds.googlecompute.GoogleComputeAsyncApi; -import org.jclouds.googlecompute.domain.Operation; -import org.jclouds.googlecompute.features.DiskApi; -import org.jclouds.googlecompute.features.DiskAsyncApi; -import org.jclouds.googlecompute.features.FirewallApi; -import org.jclouds.googlecompute.features.FirewallAsyncApi; -import org.jclouds.googlecompute.features.ImageApi; -import org.jclouds.googlecompute.features.ImageAsyncApi; -import org.jclouds.googlecompute.features.InstanceApi; -import org.jclouds.googlecompute.features.InstanceAsyncApi; -import org.jclouds.googlecompute.features.KernelApi; -import org.jclouds.googlecompute.features.KernelAsyncApi; -import org.jclouds.googlecompute.features.MachineTypeApi; -import org.jclouds.googlecompute.features.MachineTypeAsyncApi; -import org.jclouds.googlecompute.features.NetworkApi; -import org.jclouds.googlecompute.features.NetworkAsyncApi; -import org.jclouds.googlecompute.features.OperationApi; -import org.jclouds.googlecompute.features.OperationAsyncApi; -import org.jclouds.googlecompute.features.ProjectApi; -import org.jclouds.googlecompute.features.ProjectAsyncApi; -import org.jclouds.googlecompute.features.ZoneApi; -import org.jclouds.googlecompute.features.ZoneAsyncApi; -import org.jclouds.googlecompute.handlers.GoogleComputeErrorHandler; -import org.jclouds.googlecompute.predicates.OperationDonePredicate; -import org.jclouds.http.HttpErrorHandler; -import org.jclouds.http.Uris; -import org.jclouds.http.annotation.ClientError; -import org.jclouds.http.annotation.Redirection; -import org.jclouds.http.annotation.ServerError; -import org.jclouds.json.config.GsonModule.DateAdapter; -import org.jclouds.json.config.GsonModule.Iso8601DateAdapter; -import org.jclouds.location.Provider; -import org.jclouds.location.config.LocationModule; -import org.jclouds.rest.ConfiguresRestClient; -import org.jclouds.rest.config.RestClientModule; - -import javax.inject.Named; -import javax.inject.Singleton; -import java.net.URI; -import java.util.Map; -import java.util.concurrent.atomic.AtomicReference; - -import static com.google.common.base.Preconditions.checkState; -import static com.google.common.base.Suppliers.compose; - -/** - * Configures the GoogleCompute connection. - * - * @author David Alves - */ -@ConfiguresRestClient -public class GoogleComputeRestClientModule extends RestClientModule { - public static final Map, Class> DELEGATE_MAP = ImmutableMap., Class>builder() - .put(DiskApi.class, DiskAsyncApi.class) - .put(FirewallApi.class, FirewallAsyncApi.class) - .put(ImageApi.class, ImageAsyncApi.class) - .put(InstanceApi.class, InstanceAsyncApi.class) - .put(KernelApi.class, KernelAsyncApi.class) - .put(MachineTypeApi.class, MachineTypeAsyncApi.class) - .put(NetworkApi.class, NetworkAsyncApi.class) - .put(OperationApi.class, OperationAsyncApi.class) - .put(ProjectApi.class, ProjectAsyncApi.class) - .put(ZoneApi.class, ZoneAsyncApi.class) - .build(); - - public GoogleComputeRestClientModule() { - super(DELEGATE_MAP); - } - - @Override - protected void configure() { - bind(DateAdapter.class).to(Iso8601DateAdapter.class); - bind(new TypeLiteral>>() {}).to(OperationDonePredicate.class); - super.configure(); - } - - @Override - protected void bindErrorHandlers() { - bind(HttpErrorHandler.class).annotatedWith(Redirection.class).to(GoogleComputeErrorHandler.class); - bind(HttpErrorHandler.class).annotatedWith(ClientError.class).to(GoogleComputeErrorHandler.class); - bind(HttpErrorHandler.class).annotatedWith(ServerError.class).to(GoogleComputeErrorHandler.class); - } - - @Provides - @Singleton - @UserProject - public Supplier supplyProject(@org.jclouds.location.Provider final Supplier creds) { - return compose(new Function() { - public String apply(Credentials in) { - checkState(in.identity.indexOf("@") != 1, "identity should be in project_id@developer.gserviceaccount.com" + - " format"); - return Iterables.get(Splitter.on("@").split(in.identity), 0); - } - }, creds); - } - - @Provides - @Singleton - @Named("machineTypes") - public Function provideMachineTypeNameToURIFunction(final @Provider Supplier endpoint, - final @UserProject Supplier userProject) { - return new Function() { - @Override - public URI apply(String input) { - return Uris.uriBuilder(endpoint.get()).appendPath("/projects/").appendPath(userProject.get()).appendPath - ("/machineTypes/").appendPath(input).build(); - } - }; - } - - @Provides - @Singleton - @Named("networks") - public Function provideNetworkNameToURIFunction(final @Provider Supplier endpoint, - final @UserProject Supplier userProject) { - return new Function() { - @Override - public URI apply(String input) { - return Uris.uriBuilder(endpoint.get()).appendPath("/projects/").appendPath(userProject.get()).appendPath - ("/networks/").appendPath(input).build(); - } - }; - } - - @Provides - @Singleton - @Named("zones") - public Function provideZoneNameToURIFunction(final @Provider Supplier endpoint, - final @UserProject Supplier userProject) { - return new Function() { - @Override - public URI apply(String input) { - return Uris.uriBuilder(endpoint.get()).appendPath("/projects/").appendPath(userProject.get()).appendPath - ("/zones/").appendPath(input).build(); - } - }; - } - -// @Override -// protected void installLocations() { -// install(new LocationModule()); -// } -} diff --git a/labs/google-compute/src/main/java/org/jclouds/googlecompute/config/OAuthModuleWithoutTypeAdapters.java b/labs/google-compute/src/main/java/org/jclouds/googlecompute/config/OAuthModuleWithoutTypeAdapters.java deleted file mode 100644 index c611e35b18..0000000000 --- a/labs/google-compute/src/main/java/org/jclouds/googlecompute/config/OAuthModuleWithoutTypeAdapters.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.googlecompute.config; - -import com.google.common.base.Function; -import com.google.common.base.Supplier; -import com.google.inject.TypeLiteral; -import org.jclouds.oauth.v2.config.OAuthModule; -import org.jclouds.oauth.v2.domain.OAuthCredentials; -import org.jclouds.oauth.v2.domain.Token; -import org.jclouds.oauth.v2.domain.TokenRequest; -import org.jclouds.oauth.v2.functions.BuildTokenRequest; -import org.jclouds.oauth.v2.functions.FetchToken; -import org.jclouds.oauth.v2.functions.OAuthCredentialsSupplier; -import org.jclouds.oauth.v2.functions.SignOrProduceMacForToken; -import org.jclouds.rest.internal.GeneratedHttpRequest; - -/** - * Overrides OAuthModule leaving TypeAdapters bindings out. - *

- * TODO overcome this by using multibindings on GSonModule? - * - * @author David Alves - */ -public class OAuthModuleWithoutTypeAdapters extends OAuthModule { - - @Override - protected void configure() { - bind(new TypeLiteral>() {}).to(SignOrProduceMacForToken.class); - bind(new TypeLiteral>() {}).to(OAuthCredentialsSupplier.class); - bind(new TypeLiteral>() {}).to(BuildTokenRequest.class); - bind(new TypeLiteral>() {}).to(FetchToken.class); - } -} diff --git a/labs/google-compute/src/main/java/org/jclouds/googlecompute/config/UserProject.java b/labs/google-compute/src/main/java/org/jclouds/googlecompute/config/UserProject.java deleted file mode 100644 index 5852fc827c..0000000000 --- a/labs/google-compute/src/main/java/org/jclouds/googlecompute/config/UserProject.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.googlecompute.config; - -import javax.inject.Qualifier; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Qualifies a property as the user's project id. - * - * @author David Alves - */ -@Retention(value = RetentionPolicy.RUNTIME) -@Target(value = {ElementType.TYPE, ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD}) -@Qualifier -public @interface UserProject { -} diff --git a/labs/google-compute/src/main/java/org/jclouds/googlecompute/domain/Disk.java b/labs/google-compute/src/main/java/org/jclouds/googlecompute/domain/Disk.java deleted file mode 100644 index 493e8f1f29..0000000000 --- a/labs/google-compute/src/main/java/org/jclouds/googlecompute/domain/Disk.java +++ /dev/null @@ -1,154 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.googlecompute.domain; - -import com.google.common.annotations.Beta; -import com.google.common.base.Objects; - -import java.beans.ConstructorProperties; -import java.net.URI; -import java.util.Date; - -import static com.google.common.base.Preconditions.checkNotNull; - -/** - * A persistent disk resource - * - * @author David Alves - * @see - */ -@Beta -public final class Disk extends Resource { - - private final Integer sizeGb; - private final URI zone; - private final String status; - - @ConstructorProperties({ - "id", "creationTimestamp", "selfLink", "name", "description", "sizeGb", "zone", - "status" - }) - private Disk(String id, Date creationTimestamp, URI selfLink, String name, String description, - Integer sizeGb, URI zone, String status) { - super(Kind.DISK, id, creationTimestamp, selfLink, name, description); - this.sizeGb = checkNotNull(sizeGb, "sizeGb of %s", name); - this.zone = checkNotNull(zone, "zone of %s", name); - this.status = checkNotNull(status, "status of %s", name); - } - - /** - * @return size of the persistent disk, specified in GB. - */ - public int getSizeGb() { - return sizeGb; - } - - /** - * @return URL for the zone where the persistent disk resides. - */ - public URI getZone() { - return zone; - } - - /** - * @return the status of disk creation. - */ - public String getStatus() { - return status; - } - - /** - * {@inheritDoc} - */ - protected Objects.ToStringHelper string() { - return super.string() - .omitNullValues() - .add("sizeGb", sizeGb) - .add("zone", zone) - .add("status", status); - } - - /** - * {@inheritDoc} - */ - @Override - public String toString() { - return string().toString(); - } - - public static Builder builder() { - return new Builder(); - } - - public Builder toBuilder() { - return new Builder().fromDisk(this); - } - - public static final class Builder extends Resource.Builder { - - private Integer sizeGb; - private URI zone;; - private String status; - - /** - * @see Disk#getSizeGb() - */ - public Builder sizeGb(Integer sizeGb) { - this.sizeGb = sizeGb; - return this; - } - - /** - * @see Disk#getZone() - */ - public Builder zone(URI zone) { - this.zone = zone; - return this; - } - - /** - * @see Disk#getStatus() - */ - public Builder status(String status) { - this.status = status; - return this; - } - - - @Override - protected Builder self() { - return this; - } - - public Disk build() { - return new Disk(super.id, super.creationTimestamp, super.selfLink, super.name, - super.description, sizeGb, zone, status); - } - - public Builder fromDisk(Disk in) { - return super.fromResource(in) - .sizeGb(in.getSizeGb()) - .zone(in.getZone()) - .status(in.getStatus()); - } - - } - -} diff --git a/labs/google-compute/src/main/java/org/jclouds/googlecompute/domain/Firewall.java b/labs/google-compute/src/main/java/org/jclouds/googlecompute/domain/Firewall.java deleted file mode 100644 index b402995f36..0000000000 --- a/labs/google-compute/src/main/java/org/jclouds/googlecompute/domain/Firewall.java +++ /dev/null @@ -1,395 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.googlecompute.domain; - -import com.google.common.annotations.Beta; -import com.google.common.base.Objects; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.RangeSet; -import com.google.common.collect.TreeRangeSet; - -import java.beans.ConstructorProperties; -import java.net.URI; -import java.util.Date; -import java.util.Set; - -import static com.google.common.base.Objects.equal; -import static com.google.common.base.Objects.toStringHelper; -import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.base.Preconditions.checkState; -import static com.google.common.collect.Range.closed; -import static com.google.common.collect.Range.singleton; - -/** - * Represents a network firewall - * - * @author David Alves - * @see - * @see - */ -@Beta -public final class Firewall extends Resource { - - private final URI network; - private final Set sourceRanges; - private final Set sourceTags; - private final Set targetTags; - private final Set allowed; - - @ConstructorProperties({ - "id", "creationTimestamp", "selfLink", "name", "description", "network", "sourceRanges", - "sourceTags", "targetTags", "allowed" - }) - protected Firewall(String id, Date creationTimestamp, URI selfLink, String name, String description, - URI network, Set sourceRanges, Set sourceTags, Set targetTags, - Set allowed) { - super(Kind.FIREWALL, id, creationTimestamp, selfLink, name, description); - this.network = checkNotNull(network, "network of %s", name); - this.sourceRanges = sourceRanges == null ? ImmutableSet.of() : sourceRanges; - this.sourceTags = sourceTags == null ? ImmutableSet.of() : sourceTags; - this.targetTags = targetTags == null ? ImmutableSet.of() : targetTags; - this.allowed = allowed == null ? ImmutableSet.of() : allowed; - } - - /** - * @return URI of the network to which this firewall is applied; provided by the client when the firewall is created. - */ - public URI getNetwork() { - return network; - } - - /** - * One or both of sourceRanges and sourceTags may be set; an inbound connection is allowed if either the range or - * the tag of the source matches. - * - * @return a list of IP address blocks expressed in CIDR format which this rule applies to. - */ - public Set getSourceRanges() { - return sourceRanges; - } - - /** - * @return a list of instance tags which this rule applies to. One or both of sourceRanges and sourceTags may be - * set; an inbound connection is allowed if either the range or the tag of the source matches. - */ - public Set getSourceTags() { - return sourceTags; - } - - /** - * If no targetTags are specified, the firewall rule applies to all instances on the specified network. - * - * @return a list of instance tags indicating sets of instances located on network which may make network - * connections as specified in allowed. - */ - public Set getTargetTags() { - return targetTags; - } - - /** - * Each rule specifies a protocol and port-range tuple that describes a permitted connection. - * - * @return the list of rules specified by this firewall. - */ - public Set getAllowed() { - return allowed; - } - - /** - * {@inheritDoc} - */ - protected Objects.ToStringHelper string() { - return super.string() - .add("network", network) - .add("sourceRanges", sourceRanges) - .add("sourceTags", sourceTags) - .add("targetTags", targetTags) - .add("allowed", allowed); - } - - /** - * {@inheritDoc} - */ - @Override - public String toString() { - return string().toString(); - } - - public static Builder builder() { - return new Builder(); - } - - public Builder toBuilder() { - return new Builder().fromFirewall(this); - } - - public static final class Builder extends Resource.Builder { - - private URI network; - private ImmutableSet.Builder sourceRanges = ImmutableSet.builder(); - private ImmutableSet.Builder sourceTags = ImmutableSet.builder(); - private ImmutableSet.Builder targetTags = ImmutableSet.builder(); - private ImmutableSet.Builder allowed = ImmutableSet.builder(); - - /** - * @see Firewall#getNetwork() - */ - public Builder network(URI network) { - this.network = network; - return this; - } - - /** - * @see Firewall#getSourceRanges() - */ - public Builder addSourceRange(String sourceRange) { - this.sourceRanges.add(checkNotNull(sourceRange)); - return this; - } - - /** - * @see Firewall#getSourceRanges() - */ - public Builder sourceRanges(Set sourceRanges) { - this.sourceRanges.addAll(checkNotNull(sourceRanges)); - return this; - } - - /** - * @see Firewall#getSourceTags() - */ - public Builder addSourceTag(String sourceTag) { - this.sourceTags.add(checkNotNull(sourceTag)); - return this; - } - - /** - * @see Firewall#getSourceTags() - */ - public Builder sourceTags(Set sourceTags) { - this.sourceTags.addAll(checkNotNull(sourceTags)); - return this; - } - - /** - * @see Firewall#getTargetTags() - */ - public Builder addTargetTag(String targetTag) { - this.targetTags.add(checkNotNull(targetTag)); - return this; - } - - /** - * @see Firewall#getTargetTags() - */ - public Builder targetTags(Set targetTags) { - this.targetTags.addAll(checkNotNull(targetTags)); - return this; - } - - /** - * @see Firewall#getAllowed() - */ - public Builder addAllowed(Rule firewallRule) { - this.allowed.add(checkNotNull(firewallRule)); - return this; - } - - /** - * @see Firewall#getAllowed() - */ - public Builder allowed(Set firewallRules) { - this.allowed = ImmutableSet.builder(); - this.allowed.addAll(firewallRules); - return this; - } - - @Override - protected Builder self() { - return this; - } - - public Firewall build() { - return new Firewall(super.id, super.creationTimestamp, super.selfLink, super.name, - super.description, network, sourceRanges.build(), sourceTags.build(), targetTags.build(), - allowed.build()); - } - - public Builder fromFirewall(Firewall in) { - return super.fromResource(in).network(in.getNetwork()).sourceRanges(in.getSourceRanges()).sourceTags(in - .getSourceTags()).targetTags(in.getTargetTags()).allowed(in.getAllowed()); - } - - } - - /** - * A Firewall rule. Rule specifies a protocol and port-range tuple that describes a - * permitted connection. - * - * @author David Alves - * @see - */ - public static final class Rule { - - public enum IPProtocol { - - TCP, UDP, ICMP, UNKNOWN; - - public String value() { - return name().toLowerCase(); - } - - @Override - public String toString() { - return value(); - } - - public static IPProtocol fromValue(String protocol) { - return valueOf(protocol.toUpperCase()); - } - } - - private final IPProtocol ipProtocol; - private final RangeSet ports; - - @ConstructorProperties({ - "IPProtocol", "ports" - }) - private Rule(IPProtocol IPProtocol, RangeSet ports) { - this.ipProtocol = checkNotNull(IPProtocol); - this.ports = ports == null ? TreeRangeSet.create() : ports; - } - - /** - * This can either be a well known protocol string (tcp, udp or icmp) or the IP protocol number. - * - * @return this is the IP protocol that is allowed for this rule. - */ - public IPProtocol getIPProtocol() { - return ipProtocol; - } - - /** - * Each entry must be either an integer or a range. If not specified, connections through any port are allowed. - * Example inputs include: ["22"], ["80,"443"], and ["12345-12349"]. - *

- * It is an error to specify this for any protocol that isn't UDP or TCP. - * - * @return An optional list of ports which are allowed. - */ - public RangeSet getPorts() { - return ports; - } - - /** - * {@inheritDoc} - */ - @Override - public int hashCode() { - return Objects.hashCode(ipProtocol, ports); - } - - /** - * {@inheritDoc} - */ - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - Rule that = Rule.class.cast(obj); - return equal(this.ipProtocol, that.ipProtocol) - && equal(this.ports, that.ports); - } - - /** - * {@inheritDoc} - */ - public Objects.ToStringHelper string() { - return toStringHelper(this) - .add("IPProtocol", ipProtocol).add("ports", ports); - } - - /** - * {@inheritDoc} - */ - @Override - public String toString() { - return string().toString(); - } - - public static Builder builder() { - return new Builder(); - } - - public Builder toBuilder() { - return builder().fromFirewallRule(this); - } - - public static final class Builder { - - private IPProtocol ipProtocol; - private RangeSet ports = TreeRangeSet.create(); - - /** - * @see org.jclouds.googlecompute.domain.Firewall.Rule#getIPProtocol() - */ - public Builder IPProtocol(IPProtocol IPProtocol) { - this.ipProtocol = IPProtocol; - return this; - } - - /** - * @see org.jclouds.googlecompute.domain.Firewall.Rule#getPorts() - */ - public Builder addPort(Integer port) { - this.ports.add(singleton(checkNotNull(port, "port"))); - return this; - } - - /** - * @see org.jclouds.googlecompute.domain.Firewall.Rule#getPorts() - */ - public Builder addPortRange(Integer start, Integer end) { - checkState(checkNotNull(start, "start") < checkNotNull(end, "end"), - "start of range must be lower than end of range"); - this.ports.add(closed(start, end)); - return this; - } - - /** - * @see org.jclouds.googlecompute.domain.Firewall.Rule#getPorts() - */ - public Builder ports(RangeSet ports) { - this.ports = TreeRangeSet.create(); - this.ports.addAll(ports); - return this; - } - - public Rule build() { - return new Rule(ipProtocol, ports); - } - - public Builder fromFirewallRule(Rule firewallRule) { - return new Builder().IPProtocol(firewallRule.getIPProtocol()).ports(firewallRule.getPorts()); - } - } - - } -} diff --git a/labs/google-compute/src/main/java/org/jclouds/googlecompute/domain/Image.java b/labs/google-compute/src/main/java/org/jclouds/googlecompute/domain/Image.java deleted file mode 100644 index a847ceaacc..0000000000 --- a/labs/google-compute/src/main/java/org/jclouds/googlecompute/domain/Image.java +++ /dev/null @@ -1,290 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.googlecompute.domain; - -import com.google.common.annotations.Beta; -import com.google.common.base.Objects; -import com.google.common.base.Optional; - -import java.beans.ConstructorProperties; -import java.net.URI; -import java.util.Date; - -import static com.google.common.base.Objects.equal; -import static com.google.common.base.Objects.toStringHelper; -import static com.google.common.base.Optional.fromNullable; -import static com.google.common.base.Preconditions.checkNotNull; - -/** - * Represents a disk image to use on an instance. - * - * @author David Alves - * @see - */ -@Beta -public final class Image extends Resource { - - private final String sourceType; - private final Optional preferredKernel; - private final RawDisk rawDisk; - - @ConstructorProperties({ - "id", "creationTimestamp", "selfLink", "name", "description", "sourceType", "preferredKernel", - "rawDisk" - }) - protected Image(String id, Date creationTimestamp, URI selfLink, String name, String description, - String sourceType, URI preferredKernel, RawDisk rawDisk) { - super(Kind.IMAGE, id, creationTimestamp, selfLink, name, description); - this.sourceType = checkNotNull(sourceType, "sourceType of %s", name); - this.preferredKernel = fromNullable(preferredKernel); - this.rawDisk = checkNotNull(rawDisk, "rawDisk of %s", name); ; - } - - /** - * @return must be RAW; provided by the client when the disk image is created. - */ - public String getSourceType() { - return sourceType; - } - - /** - * @return An optional URL of the preferred kernel for use with this disk image. - */ - public Optional getPreferredKernel() { - return preferredKernel; - } - - /** - * @return the raw disk image parameters. - */ - public RawDisk getRawDisk() { - return rawDisk; - } - - /** - * {@inheritDoc} - */ - protected Objects.ToStringHelper string() { - return super.string() - .omitNullValues() - .add("sourceType", sourceType) - .add("preferredKernel", preferredKernel.orNull()) - .add("rawDisk", rawDisk); - } - - /** - * {@inheritDoc} - */ - @Override - public String toString() { - return string().toString(); - } - - public static Builder builder() { - return new Builder(); - } - - public Builder toBuilder() { - return new Builder().fromImage(this); - } - - public static final class Builder extends Resource.Builder { - - private String sourceType; - private URI preferredKernel; - private RawDisk rawDisk; - - /** - * @see Image#getSourceType() - */ - public Builder sourceType(String sourceType) { - this.sourceType = checkNotNull(sourceType, "sourceType"); - return this; - } - - /** - * @see Image#getPreferredKernel() - */ - public Builder preferredKernel(URI preferredKernel) { - this.preferredKernel = preferredKernel; - return this; - } - - /** - * @see Image#getRawDisk() - */ - public Builder rawDisk(RawDisk rawDisk) { - this.rawDisk = checkNotNull(rawDisk); - return this; - } - - @Override - protected Builder self() { - return this; - } - - public Image build() { - return new Image(super.id, super.creationTimestamp, super.selfLink, super.name, - super.description, sourceType, preferredKernel, rawDisk); - } - - public Builder fromImage(Image in) { - return super.fromResource(in) - .sourceType(in.getSourceType()) - .preferredKernel(in.getPreferredKernel().orNull()) - .rawDisk(in.getRawDisk()); - } - - } - - /** - * A raw disk image, usually the base for an image. - * - * @author David Alves - * @see - */ - public static class RawDisk { - - private final String source; - private final String containerType; - private final Optional sha1Checksum; - - @ConstructorProperties({ - "source", "containerType", "sha1Checksum" - }) - private RawDisk(String source, String containerType, String sha1Checksum) { - this.source = checkNotNull(source, "source"); - this.containerType = checkNotNull(containerType, "containerType"); - this.sha1Checksum = fromNullable(sha1Checksum); - } - - /** - * @return the full Google Cloud Storage URL where the disk image is stored; provided by the client when the disk - * image is created. - */ - public String getSource() { - return source; - } - - /** - * @return the format used to encode and transmit the block device. - */ - public String getContainerType() { - return containerType; - } - - /** - * @return an optional SHA1 checksum of the disk image before unpackaging; provided by the client when the disk - * image is created. - */ - public Optional getSha1Checksum() { - return sha1Checksum; - } - - /** - * {@inheritDoc} - */ - @Override - public int hashCode() { - return Objects.hashCode(source, containerType, sha1Checksum); - } - - /** - * {@inheritDoc} - */ - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - RawDisk that = RawDisk.class.cast(obj); - return equal(this.source, that.source) - && equal(this.containerType, that.containerType) - && equal(this.sha1Checksum, that.sha1Checksum); - } - - /** - * {@inheritDoc} - */ - protected Objects.ToStringHelper string() { - return toStringHelper(this) - .omitNullValues() - .add("source", source) - .add("containerType", containerType) - .add("sha1Checksum", sha1Checksum.orNull()); - } - - /** - * {@inheritDoc} - */ - @Override - public String toString() { - return string().toString(); - } - - public static Builder builder() { - return new Builder(); - } - - public Builder toBuilder() { - return builder().fromImageRawDisk(this); - } - - public static class Builder { - - private String source; - private String containerType; - private String sha1Checksum; - - /** - * @see org.jclouds.googlecompute.domain.Image.RawDisk#getSource() - */ - public Builder source(String source) { - this.source = checkNotNull(source); - return this; - } - - /** - * @see org.jclouds.googlecompute.domain.Image.RawDisk#getContainerType() - */ - public Builder containerType(String containerType) { - this.containerType = checkNotNull(containerType); - return this; - } - - /** - * @see org.jclouds.googlecompute.domain.Image.RawDisk#getSha1Checksum() - */ - public Builder sha1Checksum(String sha1Checksum) { - this.sha1Checksum = sha1Checksum; - return this; - } - - public RawDisk build() { - return new RawDisk(source, containerType, sha1Checksum); - } - - public Builder fromImageRawDisk(RawDisk rawDisk) { - return new Builder().source(rawDisk.getSource()) - .containerType(rawDisk.getContainerType()) - .sha1Checksum(rawDisk.getSha1Checksum().orNull()); - } - } - } -} diff --git a/labs/google-compute/src/main/java/org/jclouds/googlecompute/domain/Instance.java b/labs/google-compute/src/main/java/org/jclouds/googlecompute/domain/Instance.java deleted file mode 100644 index f2e58b6efd..0000000000 --- a/labs/google-compute/src/main/java/org/jclouds/googlecompute/domain/Instance.java +++ /dev/null @@ -1,1064 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.googlecompute.domain; - -import com.google.common.annotations.Beta; -import com.google.common.base.Objects; -import com.google.common.base.Optional; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; -import org.jclouds.javax.annotation.Nullable; - -import java.beans.ConstructorProperties; -import java.net.URI; -import java.util.Date; -import java.util.Map; -import java.util.Set; - -import static com.google.common.base.Objects.equal; -import static com.google.common.base.Objects.toStringHelper; -import static com.google.common.base.Optional.fromNullable; -import static com.google.common.base.Preconditions.checkNotNull; - -/** - * Represents a virtual machine. - * - * @author David Alves - * @see - */ -@Beta -public class Instance extends Resource { - - public enum Status { - PROVISIONING, - STAGING, - RUNNING, - STOPPING, - STOPPED, - TERMINATED - } - - protected final Set tags; - protected final URI image; - protected final URI machineType; - protected final Status status; - protected final Optional statusMessage; - protected final URI zone; - protected final Set networkInterfaces; - protected final Set disks; - protected final Map metadata; - protected final Set serviceAccounts; - - protected Instance(String id, Date creationTimestamp, URI selfLink, String name, String description, - Set tags, URI image, URI machineType, Status status, String statusMessage, - URI zone, Set networkInterfaces, Set disks, - Map metadata, Set serviceAccounts) { - super(Kind.INSTANCE, id, creationTimestamp, selfLink, name, description); - this.tags = tags == null ? ImmutableSet.of() : tags; - this.image = checkNotNull(image, "image"); - this.machineType = checkNotNull(machineType, "machineType of %s", name); - this.status = checkNotNull(status, "status"); - this.statusMessage = fromNullable(statusMessage); - this.zone = checkNotNull(zone, "zone of %s", name); - this.networkInterfaces = networkInterfaces == null ? ImmutableSet.of() : networkInterfaces; - this.disks = disks == null ? ImmutableSet.of() : disks; - this.metadata = metadata == null ? ImmutableMap.of() : metadata; - this.serviceAccounts = serviceAccounts == null ? ImmutableSet.of() : serviceAccounts; - } - - /** - * Used to identify valid sources or targets for network firewalls. Provided by the client when the instance is - * created. Each tag must be unique, must be 1-63 characters long, and comply with RFC1035. - * - * @return an optional set of tags applied to this instance. - */ - public Set getTags() { - return tags; - } - - /** - * @return the URL of the disk image resource to be to be installed on this instance. - */ - public URI getImage() { - return image; - } - - /** - * @return URL of the machine type resource describing which machine type to use to host the instance. - */ - public URI getMachineType() { - return machineType; - } - - /** - * @return Instance status - */ - public Status getStatus() { - return status; - } - - /** - * @return an optional, human-readable explanation of the status. - */ - @Nullable - public Optional getStatusMessage() { - return statusMessage; - } - - /** - * @return URL of the zone resource describing where this instance should be hosted; provided by the client when - * the instance is created. - */ - public URI getZone() { - return zone; - } - - /** - * @return set of NetworkInterfaces - * @see NetworkInterface - */ - public Set getNetworkInterfaces() { - return networkInterfaces; - } - - /** - * @return array of disks associated with this instance. Persistent disks must be created before - * you can assign them. - * @see org.jclouds.googlecompute.domain.Instance.AttachedDisk - */ - public Set getDisks() { - return disks; - } - - /** - * @return metadata for this instance - */ - public Map getMetadata() { - return metadata; - } - - /** - * @return list of service accounts each with specified scopes. - * @see ServiceAccount - */ - public Set getServiceAccounts() { - return serviceAccounts; - } - - /** - * {@inheritDoc} - */ - protected Objects.ToStringHelper string() { - return super.string() - .omitNullValues() - .add("tags", tags) - .add("image", image) - .add("machineType", machineType) - .add("status", status) - .add("statusMessage", statusMessage.orNull()) - .add("zone", zone) - .add("networkInterfaces", networkInterfaces) - .add("disks", disks) - .add("metadata", metadata) - .add("serviceAccounts", serviceAccounts); - } - - /** - * {@inheritDoc} - */ - @Override - public String toString() { - return string().toString(); - } - - public static Builder builder() { - return new Builder(); - } - - public Builder toBuilder() { - return new Builder().fromInstance(this); - } - - public static final class Builder extends Resource.Builder { - - private ImmutableSet.Builder tags = ImmutableSet.builder(); - private URI image; - private URI machineType; - private Status status; - private String statusMessage; - private URI zone; - private ImmutableSet.Builder networkInterfaces = ImmutableSet.builder(); - private ImmutableSet.Builder disks = ImmutableSet.builder(); - private ImmutableMap.Builder metadata = ImmutableMap.builder(); - private ImmutableSet.Builder serviceAccounts = ImmutableSet.builder(); - - /** - * @see Instance#getTags() - */ - public Builder addTag(String tag) { - this.tags.add(tag); - return this; - } - - /** - * @see Instance#getTags() - */ - public Builder tags(Set tags) { - this.tags.addAll(tags); - return this; - } - - /** - * @see Instance#getImage() - */ - public Builder image(URI image) { - this.image = image; - return this; - } - - /** - * @see Instance#getMachineType() - */ - public Builder machineType(URI machineType) { - this.machineType = machineType; - return this; - } - - /** - * @see Instance#getStatus() - */ - public Builder status(Status status) { - this.status = status; - return this; - } - - /** - * @see Instance#getStatusMessage() - */ - public Builder statusMessage(String statusMessage) { - this.statusMessage = statusMessage; - return this; - } - - /** - * @see Instance#getZone() - */ - public Builder zone(URI zone) { - this.zone = zone; - return this; - } - - /** - * @see Instance#getNetworkInterfaces() - */ - public Builder addNetworkInterface(NetworkInterface networkInterface) { - this.networkInterfaces.add(networkInterface); - return this; - } - - /** - * @see Instance#getNetworkInterfaces() - */ - public Builder networkInterfaces(Set networkInterfaces) { - this.networkInterfaces.addAll(networkInterfaces); - return this; - } - - /** - * @see Instance#getDisks() - */ - public Builder addDisk(AttachedDisk disk) { - this.disks.add(disk); - return this; - } - - /** - * @see Instance#getDisks() - */ - public Builder disks(Set disks) { - this.disks.addAll(disks); - return this; - } - - /** - * @see Instance#getMetadata() - */ - public Builder metadata(Map metadata) { - this.metadata = new ImmutableMap.Builder().putAll(metadata); - return this; - } - - /** - * @see Instance#getMetadata() - */ - public Builder addMetadata(String key, String value) { - this.metadata.put(checkNotNull(key, "key"), checkNotNull(value, "value of %s", key)); - return this; - } - - /** - * @see Instance#getServiceAccounts() - */ - public Builder addServiceAccount(ServiceAccount serviceAccount) { - this.serviceAccounts.add(serviceAccount); - return this; - } - - /** - * @see Instance#getServiceAccounts() - */ - public Builder serviceAccoutns(Set serviceAccounts) { - this.serviceAccounts.addAll(serviceAccounts); - return this; - } - - - @Override - protected Builder self() { - return this; - } - - public Instance build() { - return new Instance(super.id, super.creationTimestamp, super.selfLink, super.name, - super.description, tags.build(), image, machineType, status, statusMessage, zone, - networkInterfaces.build(), disks.build(), metadata.build(), serviceAccounts.build()); - } - - public Builder fromInstance(Instance in) { - return super.fromResource(in) - .tags(in.getTags()) - .image(in.getImage()) - .machineType(in.getMachineType()) - .status(in.getStatus()) - .statusMessage(in.getStatusMessage().orNull()) - .zone(in.getZone()) - .networkInterfaces(in.getNetworkInterfaces()) - .disks(in.getDisks()) - .metadata(in.getMetadata()) - .serviceAccoutns(in.getServiceAccounts()); - } - } - - /** - * A disk attached to an Instance. - * - * @see - */ - public static class AttachedDisk { - - private final int index; - - public AttachedDisk(Integer index) { - this.index = checkNotNull(index, "index"); - } - - public boolean isPersistent() { - return false; - } - - /** - * @return a zero-based index to assign to this disk, where 0 is reserved for the boot disk. - */ - public int getIndex() { - return index; - } - - - /** - * {@inheritDoc} - */ - @Override - public int hashCode() { - return Objects.hashCode(index); - } - - - /** - * {@inheritDoc} - */ - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - AttachedDisk that = AttachedDisk.class.cast(obj); - return equal(this.index, that.index); - } - - /** - * {@inheritDoc} - */ - protected Objects.ToStringHelper string() { - return toStringHelper(this).add("index", index); - } - - /** - * {@inheritDoc} - */ - @Override - public String toString() { - return string().toString(); - } - - public static AttachedDisk ephemeralDiskAtIndex(Integer index) { - return new AttachedDisk(index); - } - } - - public static class PersistentAttachedDisk extends AttachedDisk { - - public enum Mode { - READ_WRITE, - READ_ONLY - } - - @ConstructorProperties({"mode", "source", "deviceName", "index", "deleteOnTerminate"}) - public PersistentAttachedDisk(Mode mode, URI source, String deviceName, Integer index, - boolean deleteOnTerminate) { - super(index); - this.mode = checkNotNull(mode, "mode"); - this.source = checkNotNull(source, "source"); - this.deviceName = fromNullable(deviceName); - this.deleteOnTerminate = deleteOnTerminate; - } - - private final Mode mode; - private final URI source; - private final boolean deleteOnTerminate; - private final Optional deviceName; - - @Override - public boolean isPersistent() { - return true; - } - - /** - * @return the mode in which to attach this disk, either READ_WRITE or READ_ONLY. - */ - public Mode getMode() { - return mode; - } - - /** - * @return the URL of the persistent disk resource. - */ - public URI getSource() { - return source; - } - - /** - * @return Must be unique within the instance when specified. This represents a unique - * device name that is reflected into the /dev/ tree of a Linux operating system running within the - * instance. If not specified, a default will be chosen by the system. - */ - public Optional getDeviceName() { - return deviceName; - } - - - /** - * @return If true, delete the disk and all its data when the associated instance is deleted. - */ - public boolean isDeleteOnTerminate() { - return deleteOnTerminate; - } - - public static Builder builder() { - return new Builder(); - } - - public static final class Builder { - - private Mode mode; - private URI source; - private String deviceName; - private Integer index; - private boolean deleteOnTerminate; - - /** - * @see org.jclouds.googlecompute.domain.Instance.PersistentAttachedDisk#getMode() - */ - public Builder mode(Mode mode) { - this.mode = mode; - return this; - } - - /** - * @see org.jclouds.googlecompute.domain.Instance.PersistentAttachedDisk#getSource() - */ - public Builder source(URI source) { - this.source = source; - return this; - } - - /** - * @see org.jclouds.googlecompute.domain.Instance.PersistentAttachedDisk#getDeviceName() - */ - public Builder deviceName(String deviceName) { - this.deviceName = deviceName; - return this; - } - - /** - * @see org.jclouds.googlecompute.domain.Instance.AttachedDisk#getIndex() - */ - public Builder index(Integer index) { - this.index = index; - return this; - } - - /** - * @see org.jclouds.googlecompute.domain.Instance.PersistentAttachedDisk#isDeleteOnTerminate() - */ - public Builder deleteOnTerminate(Boolean deleteOnTerminate) { - this.deleteOnTerminate = deleteOnTerminate; - return this; - } - - public PersistentAttachedDisk build() { - return new PersistentAttachedDisk(this.mode, this.source, this.deviceName, this.index, - this.deleteOnTerminate); - } - - public Builder fromPersistentAttachedDisk(PersistentAttachedDisk in) { - return this.mode(in.getMode()) - .source(in.getSource()) - .deviceName(in.getDeviceName().orNull()) - .index(in.getIndex()) - .deleteOnTerminate(in.isDeleteOnTerminate()); - } - } - } - - /** - * A network interface for an Instance. - * - * @see - */ - public static final class NetworkInterface { - - private final String name; - private final URI network; - private final Optional networkIP; - private final Set accessConfigs; - - @ConstructorProperties({ - "name", "network", "networkIP", "accessConfigs" - }) - private NetworkInterface(String name, URI network, String networkIP, - Set accessConfigs) { - this.name = checkNotNull(name, "name"); - this.network = checkNotNull(network, "network"); - this.networkIP = fromNullable(networkIP); - this.accessConfigs = accessConfigs == null ? ImmutableSet.of() : accessConfigs; - } - - /** - * @return the name of the network interface - */ - public String getName() { - return name; - } - - /** - * @return URL of the network resource attached to this interface. - */ - public URI getNetwork() { - return network; - } - - /** - * @return An IPV4 internal network address to assign to this instance. - */ - public Optional getNetworkIP() { - return networkIP; - } - - /** - * @return array of access configurations for this interface. - */ - public Set getAccessConfigs() { - return accessConfigs; - } - - /** - * {@inheritDoc} - */ - @Override - public int hashCode() { - return Objects.hashCode(name, network, networkIP, accessConfigs); - } - - - /** - * {@inheritDoc} - */ - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - NetworkInterface that = NetworkInterface.class.cast(obj); - return equal(this.name, that.name) - && equal(this.network, that.network); - } - - /** - * {@inheritDoc} - */ - protected Objects.ToStringHelper string() { - return toStringHelper(this) - .add("name", name) - .add("network", network).add("networkIP", networkIP).add("accessConfigs", - accessConfigs); - } - - /** - * {@inheritDoc} - */ - @Override - public String toString() { - return string().toString(); - } - - public static Builder builder() { - return new Builder(); - } - - public Builder toBuilder() { - return builder().fromNetworkInterface(this); - } - - public static class Builder { - - private String name; - private URI network; - private String networkIP; - private ImmutableSet.Builder accessConfigs = ImmutableSet.builder(); - - /** - * @see org.jclouds.googlecompute.domain.Instance.NetworkInterface#getName() - */ - public Builder name(String name) { - this.name = name; - return this; - } - - /** - * @see org.jclouds.googlecompute.domain.Instance.NetworkInterface#getNetwork() - */ - public Builder network(URI network) { - this.network = network; - return this; - } - - /** - * @see org.jclouds.googlecompute.domain.Instance.NetworkInterface#getNetworkIP() - */ - public Builder networkIP(String networkIP) { - this.networkIP = networkIP; - return this; - } - - /** - * @see org.jclouds.googlecompute.domain.Instance.NetworkInterface#getAccessConfigs() - */ - public Builder addAccessConfig(AccessConfig accessConfig) { - this.accessConfigs.add(accessConfig); - return this; - } - - /** - * @see org.jclouds.googlecompute.domain.Instance.NetworkInterface#getAccessConfigs() - */ - public Builder accessConfigs(Set accessConfigs) { - this.accessConfigs = ImmutableSet.builder(); - this.accessConfigs.addAll(accessConfigs); - return this; - } - - public NetworkInterface build() { - return new NetworkInterface(this.name, this.network, this.networkIP, this.accessConfigs.build()); - } - - public Builder fromNetworkInterface(NetworkInterface in) { - return this.network(in.getNetwork()) - .networkIP(in.getNetworkIP().orNull()) - .accessConfigs(in.getAccessConfigs()); - } - } - - /** - * Access configuration to an instance's network. - *

- * This specifies how this interface is configured to interact with other network services, - * such as connecting to the internet. Currently, ONE_TO_ONE_NAT is the only access config supported. - */ - public static final class AccessConfig { - - public enum Type { - ONE_TO_ONE_NAT - } - - private Optional name; - private Type type; - private Optional natIP; - - @ConstructorProperties({ - "name", "type", "natIP" - }) - private AccessConfig(String name, Type type, String natIP) { - this.name = fromNullable(name); - this.type = checkNotNull(type, "type"); - this.natIP = fromNullable(natIP); - } - - /** - * @return name of this access configuration. - */ - public Optional getName() { - return name; - } - - /** - * @return type of configuration. Must be set to ONE_TO_ONE_NAT. This configures port-for-port NAT to the - * internet. - */ - public Type getType() { - return type; - } - - /** - * @return an external IP address associated with this instance, if there is one. - */ - @Nullable - public Optional getNatIP() { - return natIP; - } - - /** - * {@inheritDoc} - */ - @Override - public int hashCode() { - return Objects.hashCode(name, type, natIP); - } - - /** - * {@inheritDoc} - */ - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - AccessConfig that = AccessConfig.class.cast(obj); - return equal(this.name, that.name) - && equal(this.type, that.type) - && equal(this.natIP, that.natIP); - } - - /** - * {@inheritDoc} - */ - protected Objects.ToStringHelper string() { - return toStringHelper(this) - .add("name", name).add("type", type).add("natIP", natIP); - } - - /** - * {@inheritDoc} - */ - @Override - public String toString() { - return string().toString(); - } - - public static Builder builder() { - return new Builder(); - } - - public Builder toBuilder() { - return builder().fromAccessConfig(this); - } - - public static class Builder { - - private String name; - private Type type; - private String natIP; - - /** - * @see org.jclouds.googlecompute.domain.Instance.NetworkInterface.AccessConfig#getName() - */ - public Builder name(String name) { - this.name = name; - return this; - } - - /** - * @see org.jclouds.googlecompute.domain.Instance.NetworkInterface.AccessConfig#getType() - */ - public Builder type(Type type) { - this.type = type; - return this; - } - - /** - * @see org.jclouds.googlecompute.domain.Instance.NetworkInterface.AccessConfig#getNatIP() - */ - public Builder natIP(String natIP) { - this.natIP = natIP; - return this; - } - - public AccessConfig build() { - return new AccessConfig(name, type, natIP); - } - - public Builder fromAccessConfig(AccessConfig in) { - return this.name(in.getName().orNull()) - .type(in.getType()) - .natIP(in.getNatIP().orNull()); - } - } - } - } - - /** - * The output of an instance's serial port; - * - * @author David Alves - * @see - */ - public static final class SerialPortOutput { - - private final Optional selfLink; - private final String contents; - - @ConstructorProperties({ - "selfLink", "contents" - }) - public SerialPortOutput(String selfLink, String contents) { - this.selfLink = fromNullable(selfLink); - this.contents = checkNotNull(contents, "contents"); - } - - /** - * @return unique identifier for the resource; defined by the server (output only). - */ - public Optional getSelfLink() { - return selfLink; - } - - /** - * @return the contents of the console output. - */ - public String getContents() { - return contents; - } - - /** - * {@inheritDoc} - */ - @Override - public int hashCode() { - return Objects.hashCode(selfLink, contents); - } - - /** - * {@inheritDoc} - */ - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - SerialPortOutput that = SerialPortOutput.class.cast(obj); - return equal(this.selfLink, that.selfLink); - } - - /** - * {@inheritDoc} - */ - protected Objects.ToStringHelper string() { - return toStringHelper(this).add("selfLink", selfLink).add("contents", contents); - } - - /** - * {@inheritDoc} - */ - @Override - public String toString() { - return string().toString(); - } - - public static Builder builder() { - return new Builder(); - } - - public Builder toBuilder() { - return builder().fromInstanceSerialPortOutput(this); - } - - public static final class Builder { - - private String selfLink; - private String contents; - - /** - * @see org.jclouds.googlecompute.domain.Instance.SerialPortOutput#getSelfLink() - */ - public Builder selfLink(String selfLink) { - this.selfLink = checkNotNull(selfLink); - return this; - } - - /** - * @see org.jclouds.googlecompute.domain.Instance.SerialPortOutput#getContents() - */ - public Builder contents(String contents) { - this.contents = contents; - return this; - } - - public SerialPortOutput build() { - return new SerialPortOutput(selfLink, contents); - } - - public Builder fromInstanceSerialPortOutput(SerialPortOutput in) { - return this.selfLink(in.getSelfLink().orNull()) - .contents(in.getContents()); - } - } - - } - - /** - * A service account for which access tokens are to be made available to the instance through metadata queries. - * - * @author David Alves - * @see - */ - public static final class ServiceAccount { - - private final String email; - private final Set scopes; - - @ConstructorProperties({ - "email", "scopes" - }) - public ServiceAccount(String email, Set scopes) { - this.email = checkNotNull(email, "email"); - this.scopes = checkNotNull(scopes, "scopes"); - } - - /** - * @return email address of the service account. - */ - public String getEmail() { - return email; - } - - /** - * @return the list of scopes to be made available for this service account. - */ - public Set getScopes() { - return scopes; - } - - /** - * {@inheritDoc} - */ - @Override - public int hashCode() { - return Objects.hashCode(email, scopes); - } - - /** - * {@inheritDoc} - */ - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - ServiceAccount that = ServiceAccount.class.cast(obj); - return equal(this.email, that.email) - && equal(this.scopes, that.scopes); - } - - /** - * {@inheritDoc} - */ - protected Objects.ToStringHelper string() { - return toStringHelper(this).add("email", email).add("scopes", scopes); - } - - /** - * {@inheritDoc} - */ - @Override - public String toString() { - return string().toString(); - } - - public static Builder builder() { - return new Builder(); - } - - public Builder toBuilder() { - return builder().fromInstanceServiceAccount(this); - } - - public static final class Builder { - - private String email; - private ImmutableSet.Builder scopes = ImmutableSet.builder(); - - /** - * @see org.jclouds.googlecompute.domain.Instance.ServiceAccount#getEmail() - */ - public Builder email(String email) { - this.email = checkNotNull(email); - return this; - } - - /** - * @see org.jclouds.googlecompute.domain.Instance.ServiceAccount#getScopes() - */ - public Builder addScopes(String scopes) { - this.scopes.add(scopes); - return this; - } - - /** - * @see org.jclouds.googlecompute.domain.Instance.ServiceAccount#getScopes() - */ - public Builder scopes(Set scopes) { - this.scopes.addAll(scopes); - return this; - } - - public ServiceAccount build() { - return new ServiceAccount(email, scopes.build()); - } - - public Builder fromInstanceServiceAccount(ServiceAccount in) { - return this.email(in.getEmail()).scopes(in.getScopes()); - } - } - } -} diff --git a/labs/google-compute/src/main/java/org/jclouds/googlecompute/domain/InstanceTemplate.java b/labs/google-compute/src/main/java/org/jclouds/googlecompute/domain/InstanceTemplate.java deleted file mode 100644 index 0541f1beda..0000000000 --- a/labs/google-compute/src/main/java/org/jclouds/googlecompute/domain/InstanceTemplate.java +++ /dev/null @@ -1,483 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.googlecompute.domain; - -import com.google.common.base.Objects; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Maps; -import com.google.common.collect.Sets; - -import java.net.URI; -import java.util.Map; -import java.util.Set; - -import static com.google.common.base.Objects.equal; -import static com.google.common.base.Preconditions.checkNotNull; -import static org.jclouds.googlecompute.domain.Instance.NetworkInterface.AccessConfig.Type; - -/** - * Optional information for creating an instance. - * - * @author David Alves - */ -public class InstanceTemplate { - - protected String name; - protected String description; - protected URI machineType; - protected URI zone; - protected URI image; - protected Set tags = Sets.newLinkedHashSet(); - protected Set serviceAccounts = Sets.newLinkedHashSet(); - - protected transient Set disks = Sets.newLinkedHashSet(); - protected transient Set networkInterfaces = Sets.newLinkedHashSet(); - protected transient Map metadata = Maps.newLinkedHashMap(); - protected transient String machineTypeName; - protected transient String zoneName; - - - protected InstanceTemplate(URI machineType) { - this.machineType = checkNotNull(machineType, "machineType"); - } - - protected InstanceTemplate(String machineTypeName) { - this.machineTypeName = checkNotNull(machineTypeName, "machineTypeName"); - } - - /** - * @see org.jclouds.googlecompute.domain.Instance#getName() - */ - public InstanceTemplate name(String name) { - this.name = name; - return this; - } - - /** - * @see org.jclouds.googlecompute.domain.Instance#getDescription() - */ - public InstanceTemplate description(String description) { - this.description = description; - return this; - } - - /** - * @see org.jclouds.googlecompute.domain.Instance#getImage() - */ - public InstanceTemplate image(URI image) { - this.image = image; - return this; - } - - /** - * @see org.jclouds.googlecompute.domain.Instance#getMachineType() - */ - public InstanceTemplate machineType(URI machineType) { - this.machineType = machineType; - return this; - } - - /** - * @see org.jclouds.googlecompute.domain.Instance#getMachineType() - */ - public InstanceTemplate machineType(String machineTypeName) { - this.machineTypeName = machineTypeName; - return this; - } - - /** - * @see org.jclouds.googlecompute.domain.Instance#getZone() - */ - public InstanceTemplate zone(String zoneName) { - this.zoneName = zoneName; - return this; - } - - /** - * @see org.jclouds.googlecompute.domain.Instance#getZone() - */ - public InstanceTemplate zone(URI zone) { - this.zone = zone; - return this; - } - - /** - * @see org.jclouds.googlecompute.domain.Instance#getTags() - */ - public InstanceTemplate addTag(String tag) { - this.tags.add(checkNotNull(tag, "tag")); - return this; - } - - /** - * @see org.jclouds.googlecompute.domain.Instance#getTags() - */ - public InstanceTemplate tags(Set tags) { - this.tags = Sets.newLinkedHashSet(); - this.tags.addAll(checkNotNull(tags, "tags")); - return this; - } - - /** - * @see org.jclouds.googlecompute.domain.Instance#getDisks() - */ - public InstanceTemplate addDisk(PersistentDisk.Mode mode, URI source) { - this.disks.add(new PersistentDisk(mode, source, null, null)); - return this; - } - - /** - * @see org.jclouds.googlecompute.domain.Instance#getDisks() - */ - public InstanceTemplate addDisk(PersistentDisk.Mode mode, URI source, String deviceName, Boolean deleteOnTerminate) { - this.disks.add(new PersistentDisk(mode, source, deviceName, deleteOnTerminate)); - return this; - } - - /** - * @see org.jclouds.googlecompute.domain.Instance#getDisks() - */ - public InstanceTemplate disks(Set disks) { - this.disks = Sets.newLinkedHashSet(); - this.disks.addAll(checkNotNull(disks, "disks")); - return this; - } - - /** - * @see org.jclouds.googlecompute.domain.Instance#getNetworkInterfaces() - */ - public InstanceTemplate addNetworkInterface(URI network) { - this.networkInterfaces.add(new NetworkInterface(checkNotNull(network, "network"), null,null)); - return this; - } - - /** - * @see org.jclouds.googlecompute.domain.Instance#getNetworkInterfaces() - */ - public InstanceTemplate addNetworkInterface(URI network, Type type) { - this.networkInterfaces.add(new NetworkInterface(checkNotNull(network, "network"), null, - ImmutableSet.of(Instance.NetworkInterface.AccessConfig.builder() - .type(type) - .build()))); - return this; - } - - /** - * @see org.jclouds.googlecompute.domain.Instance#getNetworkInterfaces() - */ - public InstanceTemplate addNetworkInterface(NetworkInterface networkInterface) { - this.networkInterfaces.add(networkInterface); - return this; - } - - public InstanceTemplate networkInterfaces(Set networkInterfaces) { - this.networkInterfaces = Sets.newLinkedHashSet(networkInterfaces); - return this; - } - - - /** - * @see org.jclouds.googlecompute.domain.Instance#getMetadata() - */ - public InstanceTemplate addMetadata(String key, String value) { - this.metadata.put(checkNotNull(key, "key"), checkNotNull(value, "value of %", key)); - return this; - } - - /** - * @see org.jclouds.googlecompute.domain.Instance#getMetadata() - */ - public InstanceTemplate metadata(Map metadata) { - this.metadata = Maps.newLinkedHashMap(); - this.metadata.putAll(checkNotNull(metadata, "metadata")); - return this; - } - - /** - * @see org.jclouds.googlecompute.domain.Instance#getServiceAccounts() - */ - public InstanceTemplate addServiceAccount(Instance.ServiceAccount serviceAccount) { - this.serviceAccounts.add(checkNotNull(serviceAccount, "serviceAccount")); - return this; - } - - /** - * @see org.jclouds.googlecompute.domain.Instance#getServiceAccounts() - */ - public InstanceTemplate serviceAccounts(Set serviceAccounts) { - this.serviceAccounts = Sets.newLinkedHashSet(); - this.serviceAccounts.addAll(checkNotNull(serviceAccounts, "serviceAccounts")); - return this; - } - - /** - * @see org.jclouds.googlecompute.domain.Instance#getDescription() - */ - public String getDescription() { - return description; - } - - /** - * @see org.jclouds.googlecompute.domain.Instance#getDisks() - */ - public Set getDisks() { - return disks; - } - - /** - * @see org.jclouds.googlecompute.domain.Instance#getImage() - */ - public URI getImage() { - return image; - } - - /** - * @see org.jclouds.googlecompute.domain.Instance#getMachineType() - */ - public URI getMachineType() { - return machineType; - } - - /** - * @see org.jclouds.googlecompute.domain.Instance#getMachineType() - */ - public String getMachineTypeName() { - return machineTypeName; - } - - /** - * @see org.jclouds.googlecompute.domain.Instance#getMetadata() - */ - public Map getMetadata() { - return metadata; - } - - /** - * @see org.jclouds.googlecompute.domain.Instance#getNetworkInterfaces() - */ - public Set getNetworkInterfaces() { - return networkInterfaces; - } - - /** - * @see org.jclouds.googlecompute.domain.Instance#getServiceAccounts() - */ - public Set getServiceAccounts() { - return serviceAccounts; - } - - /** - * @see org.jclouds.googlecompute.domain.Instance#getTags() - */ - public Set getTags() { - return tags; - } - - /** - * @see org.jclouds.googlecompute.domain.Instance#getName() - */ - public String getName() { - return name; - } - - /** - * @see org.jclouds.googlecompute.domain.Instance#getZone() - */ - public URI getZone() { - return zone; - } - - /** - * @see org.jclouds.googlecompute.domain.Instance#getZone() - */ - public String getZoneName() { - return zoneName; - } - - public static Builder builder() { - return new Builder(); - } - - public static InstanceTemplate fromInstanceTemplate(InstanceTemplate instanceTemplate) { - return Builder.fromInstanceTemplate(instanceTemplate); - } - - public static class Builder { - - public InstanceTemplate forMachineType(URI machineType) { - return new InstanceTemplate(machineType); - } - - public InstanceTemplate forMachineType(String machineTypeName) { - return new InstanceTemplate(machineTypeName); - } - - public static InstanceTemplate fromInstanceTemplate(InstanceTemplate instanceTemplate) { - return InstanceTemplate.builder() - .forMachineType(instanceTemplate.getMachineType()) - .networkInterfaces(instanceTemplate.getNetworkInterfaces()) - .name(instanceTemplate.getName()) - .description(instanceTemplate.getDescription()) - .zone(instanceTemplate.getZone()) - .image(instanceTemplate.getImage()) - .tags(instanceTemplate.getTags()) - .disks(instanceTemplate.getDisks()) - .metadata(instanceTemplate.getMetadata()) - .serviceAccounts(instanceTemplate.getServiceAccounts()); - } - } - - - public static class PersistentDisk { - - public enum Mode { - READ_WRITE, - READ_ONLY - } - - public PersistentDisk(Mode mode, URI source, String deviceName, Boolean deleteOnTerminate) { - this.mode = checkNotNull(mode, "mode"); - this.source = checkNotNull(source, "source"); - this.deviceName = deviceName; - this.deleteOnTerminate = deleteOnTerminate; - } - - private final Mode mode; - private final URI source; - private final Boolean deleteOnTerminate; - private final String deviceName; - - /** - * @return the mode in which to attach this disk, either READ_WRITE or READ_ONLY. - */ - public Mode getMode() { - return mode; - } - - /** - * @return the URL of the persistent disk resource. - */ - public URI getSource() { - return source; - } - - /** - * @return Must be unique within the instance when specified. This represents a unique - * device name that is reflected into the /dev/ tree of a Linux operating system running within the - * instance. If not specified, a default will be chosen by the system. - */ - public String getDeviceName() { - return deviceName; - } - - - /** - * @return If true, delete the disk and all its data when the associated instance is deleted. - */ - public boolean isDeleteOnTerminate() { - return deleteOnTerminate; - } - } - - public static class NetworkInterface { - - private final URI network; - private final String networkIP; - private final Set accessConfigs; - - public NetworkInterface(URI network, String networkIP, Set - accessConfigs) { - this.networkIP = networkIP; - this.network = network; - this.accessConfigs = accessConfigs != null ? accessConfigs : ImmutableSet.of(); - } - - public Set getAccessConfigs() { - return accessConfigs; - } - - public URI getNetwork() { - return network; - } - - public String getNetworkIP() { - return networkIP; - } - } - - - /** - * {@inheritDoc} - */ - @Override - public boolean equals(Object object) { - if (this == object) { - return true; - } - if (object instanceof InstanceTemplate) { - final InstanceTemplate other = InstanceTemplate.class.cast(object); - return equal(description, other.description) - && equal(tags, other.tags) - && equal(image, other.image) - && equal(disks, other.disks) - && equal(networkInterfaces, other.networkInterfaces) - && equal(metadata, other.metadata) - && equal(serviceAccounts, other.serviceAccounts); - } else { - return false; - } - } - - /** - * {@inheritDoc} - */ - @Override - public int hashCode() { - return Objects.hashCode(description, tags, image, disks, networkInterfaces, metadata, serviceAccounts); - } - - /** - * {@inheritDoc} - */ - protected Objects.ToStringHelper string() { - Objects.ToStringHelper toString = Objects.toStringHelper("") - .omitNullValues(); - toString.add("description", description); - if (tags.size() > 0) - toString.add("tags", tags); - if (disks.size() > 0) - toString.add("disks", disks); - if (metadata.size() > 0) - toString.add("metadata", metadata); - if (serviceAccounts.size() > 0) - toString.add("serviceAccounts", serviceAccounts); - toString.add("image", image); - toString.add("networkInterfaces", networkInterfaces); - return toString; - } - - /** - * {@inheritDoc} - */ - @Override - public String toString() { - return string().toString(); - } -} diff --git a/labs/google-compute/src/main/java/org/jclouds/googlecompute/domain/Kernel.java b/labs/google-compute/src/main/java/org/jclouds/googlecompute/domain/Kernel.java deleted file mode 100644 index a4df83bd3d..0000000000 --- a/labs/google-compute/src/main/java/org/jclouds/googlecompute/domain/Kernel.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.googlecompute.domain; - -import com.google.common.annotations.Beta; - -import java.beans.ConstructorProperties; -import java.net.URI; -import java.util.Date; - -/** - * Represents a kernel. - * - * @author David Alves - * @see - */ -@Beta -public final class Kernel extends Resource { - - @ConstructorProperties({ - "id", "creationTimestamp", "selfLink", "name", "description" - }) - private Kernel(String id, Date creationTimestamp, URI selfLink, String name, String description) { - super(Kind.KERNEL, id, creationTimestamp, selfLink, name, description); - } - - public static Builder builder() { - return new Builder(); - } - - public Builder toBuilder() { - return new Builder().fromKernel(this); - } - - public static final class Builder extends Resource.Builder { - - @Override - protected Builder self() { - return this; - } - - public Kernel build() { - return new Kernel(super.id, super.creationTimestamp, super.selfLink, super.name, - super.description); - } - - public Builder fromKernel(Kernel in) { - return super.fromResource(in); - } - } - -} diff --git a/labs/google-compute/src/main/java/org/jclouds/googlecompute/domain/ListPage.java b/labs/google-compute/src/main/java/org/jclouds/googlecompute/domain/ListPage.java deleted file mode 100644 index 7893a1b8aa..0000000000 --- a/labs/google-compute/src/main/java/org/jclouds/googlecompute/domain/ListPage.java +++ /dev/null @@ -1,183 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.googlecompute.domain; - -import com.google.common.base.Objects; -import com.google.common.base.Optional; -import com.google.common.collect.ImmutableSet; -import org.jclouds.collect.IterableWithMarker; - -import java.beans.ConstructorProperties; -import java.net.URI; -import java.util.Iterator; - -import static com.google.common.base.Objects.equal; -import static com.google.common.base.Objects.toStringHelper; -import static com.google.common.base.Preconditions.checkNotNull; -import static org.jclouds.googlecompute.domain.Resource.Kind; - -/** - * The collection returned from any listFirstPage() method. - * - * @author David Alves - */ -public class ListPage extends IterableWithMarker { - - private final Kind kind; - private final String id; - private final URI selfLink; - private final String nextPageToken; - private final Iterable items; - - @ConstructorProperties({ - "kind", "id", "selfLink", "nextPageToken", "items" - }) - protected ListPage(Kind kind, String id, URI selfLink, String nextPageToken, Iterable items) { - this.id = checkNotNull(id, "id"); - this.kind = checkNotNull(kind, "kind of %id", id); - this.selfLink = checkNotNull(selfLink, "selfLink of %id", id); - this.nextPageToken = nextPageToken; - this.items = items != null ? ImmutableSet.copyOf(items) : ImmutableSet.of(); - } - - public Kind getKind() { - return kind; - } - - public String getId() { - return id; - } - - public URI getSelfLink() { - return selfLink; - } - - @Override - public Optional nextMarker() { - return Optional.fromNullable(nextPageToken); - } - - @Override - public Iterator iterator() { - return checkNotNull(items, "items").iterator(); - } - - /** - * {@inheritDoc} - */ - @Override - public int hashCode() { - return Objects.hashCode(kind, id); - } - - /** - * {@inheritDoc} - */ - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - ListPage that = ListPage.class.cast(obj); - return equal(this.kind, that.kind) - && equal(this.id, that.id); - } - - /** - * {@inheritDoc} - */ - protected Objects.ToStringHelper string() { - return toStringHelper(this) - .omitNullValues() - .add("kind", kind) - .add("id", id) - .add("selfLink", selfLink) - .add("nextPageToken", nextPageToken) - .add("items", items); - } - - /** - * {@inheritDoc} - */ - @Override - public String toString() { - return string().toString(); - } - - public static Builder builder() { - return new Builder(); - } - - public Builder toBuilder() { - return new Builder().fromPagedList(this); - } - - public static final class Builder { - - private Kind kind; - private String id; - private URI selfLink; - private String nextPageToken; - private ImmutableSet.Builder items = ImmutableSet.builder(); - - public Builder kind(Kind kind) { - this.kind = kind; - return this; - } - - public Builder id(String id) { - this.id = id; - return this; - } - - public Builder selfLink(URI selfLink) { - this.selfLink = selfLink; - return this; - } - - public Builder addItem(T item) { - this.items.add(item); - return this; - } - - public Builder items(Iterable items) { - this.items.addAll(items); - return this; - } - - public Builder nextPageToken(String nextPageToken) { - this.nextPageToken = nextPageToken; - return this; - } - - public ListPage build() { - return new ListPage(kind, id, selfLink, nextPageToken, items.build()); - } - - public Builder fromPagedList(ListPage in) { - return this - .kind(in.getKind()) - .id(in.getId()) - .selfLink(in.getSelfLink()) - .nextPageToken((String) in.nextMarker().orNull()) - .items(in); - - } - } -} diff --git a/labs/google-compute/src/main/java/org/jclouds/googlecompute/domain/MachineType.java b/labs/google-compute/src/main/java/org/jclouds/googlecompute/domain/MachineType.java deleted file mode 100644 index f0f8087e36..0000000000 --- a/labs/google-compute/src/main/java/org/jclouds/googlecompute/domain/MachineType.java +++ /dev/null @@ -1,337 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.googlecompute.domain; - -import com.google.common.annotations.Beta; -import com.google.common.base.Objects; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableSet; - -import java.beans.ConstructorProperties; -import java.net.URI; -import java.util.Date; -import java.util.List; -import java.util.Set; - -import static com.google.common.base.Objects.equal; -import static com.google.common.base.Objects.toStringHelper; -import static com.google.common.base.Preconditions.checkNotNull; - -/** - * Represents a machine type used to host an instance. - * - * @author David Alves - * @see - */ -@Beta -public final class MachineType extends Resource { - - private final Integer guestCpus; - private final Integer memoryMb; - private final Integer imageSpaceGb; - private final List ephemeralDisks; - private final Integer maximumPersistentDisks; - private final Long maximumPersistentDisksSizeGb; - private final Set availableZone; - - @ConstructorProperties({ - "id", "creationTimestamp", "selfLink", "name", "description", "guestCpus", "memoryMb", - "imageSpaceGb", "ephemeralDisks", "maximumPersistentDisks", "maximumPersistentDisksSizeGb", "availableZone" - }) - private MachineType(String id, Date creationTimestamp, URI selfLink, String name, String description, - int guestCpus, int memoryMb, int imageSpaceGb, List ephemeralDisks, - int maximumPersistentDisks, long maximumPersistentDisksSizeGb, Set availableZone) { - super(Kind.MACHINE_TYPE, id, creationTimestamp, selfLink, name, description); - this.guestCpus = checkNotNull(guestCpus, "guestCpus of %s", name); - this.memoryMb = checkNotNull(memoryMb, "memoryMb of %s", name); - this.imageSpaceGb = checkNotNull(imageSpaceGb, "imageSpaceGb of %s", name); - this.ephemeralDisks = ephemeralDisks == null ? ImmutableList.of() : ephemeralDisks; - this.maximumPersistentDisks = checkNotNull(maximumPersistentDisks, "maximumPersistentDisks of %s", name); - this.maximumPersistentDisksSizeGb = maximumPersistentDisksSizeGb; - this.availableZone = availableZone == null ? ImmutableSet.of() : availableZone; - } - - /** - * @return count of CPUs exposed to the instance. - */ - public int getGuestCpus() { - return guestCpus; - } - - /** - * @return physical memory assigned to the instance, defined in MB. - */ - public int getMemoryMb() { - return memoryMb; - } - - /** - * @return space allotted for the image, defined in GB. - */ - public int getImageSpaceGb() { - return imageSpaceGb; - } - - /** - * @return extended ephemeral disks assigned to the instance. - */ - public List getEphemeralDisks() { - return ephemeralDisks; - } - - /** - * @return maximum persistent disks allowed. - */ - public int getMaximumPersistentDisks() { - return maximumPersistentDisks; - } - - /** - * @return maximum total persistent disks size (GB) allowed. - */ - public long getMaximumPersistentDisksSizeGb() { - return maximumPersistentDisksSizeGb; - } - - /** - * @return the zones that this machine type can run in. - */ - public Set getAvailableZone() { - return availableZone; - } - - /** - * {@inheritDoc} - */ - protected Objects.ToStringHelper string() { - return super.string() - .add("guestCpus", guestCpus) - .add("memoryMb", memoryMb) - .add("imageSpaceGb", imageSpaceGb) - .add("ephemeralDisks", ephemeralDisks) - .add("maximumPersistentDisks", maximumPersistentDisks) - .add("maximumPersistentDisksSizeGb", maximumPersistentDisksSizeGb) - .add("availableZone", availableZone); - } - - /** - * {@inheritDoc} - */ - @Override - public String toString() { - return string().toString(); - } - - public static Builder builder() { - return new Builder(); - } - - public Builder toBuilder() { - return new Builder().fromMachineType(this); - } - - public static final class Builder extends Resource.Builder { - - private Integer guestCpus; - private Integer memoryMb; - private Integer imageSpaceGb; - private ImmutableList.Builder ephemeralDisks = ImmutableList.builder(); - private Integer maximumPersistentDisks; - private Long maximumPersistentDisksSizeGb; - private ImmutableSet.Builder availableZone = ImmutableSet.builder(); - - /** - * @see MachineType#getGuestCpus() - */ - public Builder guestCpus(int guesCpus) { - this.guestCpus = guesCpus; - return this; - } - - /** - * @see MachineType#getMemoryMb() - */ - public Builder memoryMb(int memoryMb) { - this.memoryMb = memoryMb; - return this; - } - - /** - * @see MachineType#getImageSpaceGb() - */ - public Builder imageSpaceGb(int imageSpaceGb) { - this.imageSpaceGb = imageSpaceGb; - return this; - } - - /** - * @see MachineType#getEphemeralDisks() - */ - public Builder addEphemeralDisk(int diskGb) { - this.ephemeralDisks.add(EphemeralDisk.builder().diskGb(diskGb).build()); - return this; - } - - /** - * @see MachineType#getEphemeralDisks() - */ - public Builder ephemeralDisks(List ephemeralDisks) { - this.ephemeralDisks.addAll(ephemeralDisks); - return this; - } - - /** - * @see MachineType#getMaximumPersistentDisks() - */ - public Builder maximumPersistentDisks(int maximumPersistentDisks) { - this.maximumPersistentDisks = maximumPersistentDisks; - return this; - } - - /** - * @see MachineType#getMaximumPersistentDisksSizeGb() - */ - public Builder maximumPersistentDisksSizeGb(long maximumPersistentDisksSizeGb) { - this.maximumPersistentDisksSizeGb = maximumPersistentDisksSizeGb; - return this; - } - - /** - * @see MachineType#getAvailableZone() - */ - public Builder addAvailableZone(String availableZone) { - this.availableZone.add(availableZone); - return this; - } - - /** - * @see MachineType#getAvailableZone() - */ - public Builder availableZones(Set availableZone) { - this.availableZone.addAll(availableZone); - return this; - } - - @Override - protected Builder self() { - return this; - } - - public MachineType build() { - return new MachineType(id, creationTimestamp, selfLink, name, description, guestCpus, memoryMb, - imageSpaceGb, ephemeralDisks.build(), maximumPersistentDisks, maximumPersistentDisksSizeGb, - availableZone.build()); - } - - - public Builder fromMachineType(MachineType in) { - return super.fromResource(in).memoryMb(in.getMemoryMb()).imageSpaceGb(in.getImageSpaceGb()).ephemeralDisks(in - .getEphemeralDisks()).maximumPersistentDisks(in.getMaximumPersistentDisks()) - .maximumPersistentDisksSizeGb(in.getMaximumPersistentDisksSizeGb()).availableZones(in - .getAvailableZone()); - } - } - - /** - * An ephemeral disk of a MachineType - */ - public static final class EphemeralDisk { - - private final int diskGb; - - @ConstructorProperties({ - "diskGb" - }) - private EphemeralDisk(int diskGb) { - this.diskGb = diskGb; - } - - /** - * @return size of the ephemeral disk, defined in GB. - */ - public int getDiskGb() { - return diskGb; - } - - /** - * {@inheritDoc} - */ - @Override - public int hashCode() { - return Objects.hashCode(diskGb); - } - - /** - * {@inheritDoc} - */ - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - EphemeralDisk that = EphemeralDisk.class.cast(obj); - return equal(this.diskGb, that.diskGb); - } - - /** - * {@inheritDoc} - */ - protected Objects.ToStringHelper string() { - return toStringHelper(this) - .add("diskGb", diskGb); - } - - /** - * {@inheritDoc} - */ - @Override - public String toString() { - return string().toString(); - } - - public static Builder builder() { - return new Builder(); - } - - public Builder toBuilder() { - return builder().fromEphemeralDisk(this); - } - - public static class Builder { - - private int diskGb; - - /** - * @see org.jclouds.googlecompute.domain.MachineType.EphemeralDisk#getDiskGb() - */ - public Builder diskGb(int diskGb) { - this.diskGb = diskGb; - return this; - } - - public EphemeralDisk build() { - return new EphemeralDisk(diskGb); - } - - public Builder fromEphemeralDisk(EphemeralDisk in) { - return new Builder().diskGb(in.getDiskGb()); - } - } - } -} diff --git a/labs/google-compute/src/main/java/org/jclouds/googlecompute/domain/Network.java b/labs/google-compute/src/main/java/org/jclouds/googlecompute/domain/Network.java deleted file mode 100644 index c406290096..0000000000 --- a/labs/google-compute/src/main/java/org/jclouds/googlecompute/domain/Network.java +++ /dev/null @@ -1,137 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.googlecompute.domain; - - -import com.google.common.annotations.Beta; -import com.google.common.base.Objects; -import com.google.common.base.Optional; - -import java.beans.ConstructorProperties; -import java.net.URI; -import java.util.Date; - -import static com.google.common.base.Optional.fromNullable; -import static com.google.common.base.Preconditions.checkNotNull; - -/** - * Represents a network used to enable instance communication. - * - * @author David Alves - * @see - */ -@Beta -public final class Network extends Resource { - - private final String IPv4Range; - private final Optional gatewayIPv4; - - @ConstructorProperties({ - "id", "creationTimestamp", "selfLink", "name", "description", "IPv4Range", - "gatewayIPv4" - }) - protected Network(String id, Date creationTimestamp, URI selfLink, String name, String description, - String IPv4Range, String gatewayIPv4) { - super(Kind.NETWORK, id, creationTimestamp, selfLink, name, description); - this.IPv4Range = checkNotNull(IPv4Range); - this.gatewayIPv4 = fromNullable(gatewayIPv4); - } - - /** - * @return Required; The range of internal addresses that are legal on this network. This range is a CIDR - * specification, for example: 192.168.0.0/16. - */ - public String getIPv4Range() { - return IPv4Range; - } - - /** - * This must be within the range specified by IPv4Range, and is typically the first usable address in that range. - * If not specified, the default value is the first usable address in IPv4Range. - * - * @return an optional address that is used for default routing to other networks. - */ - public Optional getGatewayIPv4() { - return gatewayIPv4; - } - - /** - * {@inheritDoc} - */ - protected Objects.ToStringHelper string() { - return super.string() - .omitNullValues() - .add("IPv4Range", IPv4Range) - .add("gatewayIPv4", gatewayIPv4.orNull()); - } - - /** - * {@inheritDoc} - */ - @Override - public String toString() { - return string().toString(); - } - - public static Builder builder() { - return new Builder(); - } - - public Builder toBuilder() { - return new Builder().fromNetwork(this); - } - - public static final class Builder extends Resource.Builder { - - private String IPv4Range; - private String gatewayIPv4; - - /** - * @see Network#getIPv4Range() - */ - public Builder IPv4Range(String IPv4Range) { - this.IPv4Range = IPv4Range; - return this; - } - - /** - * @see Network#getGatewayIPv4() - */ - public Builder gatewayIPv4(String gatewayIPv4) { - this.gatewayIPv4 = gatewayIPv4; - return this; - } - - @Override - protected Builder self() { - return this; - } - - public Network build() { - return new Network(super.id, super.creationTimestamp, super.selfLink, super.name, - super.description, IPv4Range, gatewayIPv4); - } - - public Builder fromNetwork(Network in) { - return super.fromResource(in); - } - } - -} diff --git a/labs/google-compute/src/main/java/org/jclouds/googlecompute/domain/Operation.java b/labs/google-compute/src/main/java/org/jclouds/googlecompute/domain/Operation.java deleted file mode 100644 index caccaf63d9..0000000000 --- a/labs/google-compute/src/main/java/org/jclouds/googlecompute/domain/Operation.java +++ /dev/null @@ -1,519 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.googlecompute.domain; - -import com.google.common.annotations.Beta; -import com.google.common.base.Objects; -import com.google.common.base.Optional; -import com.google.common.collect.ImmutableList; -import org.jclouds.http.HttpResponse; - -import java.beans.ConstructorProperties; -import java.net.URI; -import java.util.Date; -import java.util.List; - -import static com.google.common.base.Objects.equal; -import static com.google.common.base.Objects.toStringHelper; -import static com.google.common.base.Optional.fromNullable; -import static com.google.common.base.Preconditions.checkNotNull; - -/** - * Describes an operation being executed on some Resource - * - * @author David Alves - * @see - */ -@Beta -public class Operation extends Resource { - - public static enum Status { - PENDING, - RUNNING, - DONE - } - - private final URI targetLink; - private final Optional targetId; - private final Optional clientOperationId; - private final Status status; - private final Optional statusMessage; - private final String user; - private final Optional progress; - private final Date insertTime; - private final Optional startTime; - private final Optional endTime; - private final Optional httpError; - private final String operationType; - private final List errors; - - protected Operation(String id, Date creationTimestamp, URI selfLink, String name, String description, - URI targetLink, String targetId, String clientOperationId, Status status, - String statusMessage, String user, Integer progress, Date insertTime, Date startTime, - Date endTime, Integer httpErrorStatusCode, String httpErrorMessage, String operationType, - List errors) { - super(Kind.OPERATION, id, creationTimestamp, selfLink, name, description); - this.targetLink = checkNotNull(targetLink, "targetLink of %s", name); - this.targetId = fromNullable(targetId); - this.clientOperationId = fromNullable(clientOperationId); - this.status = checkNotNull(status, "status of %s", name); - this.statusMessage = fromNullable(statusMessage); - this.user = checkNotNull(user, "user of %s", name); - this.progress = fromNullable(progress); - this.insertTime = checkNotNull(insertTime, "insertTime of %s", name); - this.startTime = fromNullable(startTime); - this.endTime = fromNullable(endTime); - this.httpError = httpErrorStatusCode != null && httpErrorStatusCode != 0 ? - Optional.of(HttpResponse.builder() - .statusCode(httpErrorStatusCode) - .message(httpErrorMessage) - .build()) - : Optional.absent(); - this.operationType = checkNotNull(operationType, "insertTime of %s", name); - this.errors = errors == null ? ImmutableList.of() : ImmutableList.copyOf(errors); - } - - /** - * @return URL of the resource the operation is mutating. - */ - public URI getTargetLink() { - return targetLink; - } - - /** - * @return unique target id which identifies a particular incarnation of the target. - */ - public Optional getTargetId() { - return targetId; - } - - /** - * @return An optional identifier specified by the client when the mutation was initiated. Must be unique for all - * operation resources in the project. - */ - public Optional getClientOperationId() { - return clientOperationId; - } - - /** - * @return Status of the operation. Can be one of the following: PENDING, RUNNING, or DONE. - */ - public Status getStatus() { - return status; - } - - /** - * @return An optional textual description of the current status of the operation. - */ - public Optional getStatusMessage() { - return statusMessage; - } - - /** - * @return User who requested the operation, for example "user@example.com". - */ - public String getUser() { - return user; - } - - /** - * @return an optional progress indicator that ranges from 0 to 100. This should not be used to guess at when the - * operation will be complete. This number should be monotonically increasing as the operation progresses - * (output only). - */ - public Optional getProgress() { - return progress; - } - - /** - * @return the time that this operation was requested. - */ - public Date getInsertTime() { - return insertTime; - } - - /** - * @return the time that this operation was started by the server. - */ - public Optional getStartTime() { - return startTime; - } - - /** - * @return the time that this operation was completed. - */ - public Optional getEndTime() { - return endTime; - } - - /** - * @return if operation fails, the HttpResponse with error status code returned and the message, e.g. NOT_FOUND. - */ - public Optional getHttpError() { - return httpError; - } - - /** - * @return type of the operation. Examples include insert, update, and delete. - */ - public String getOperationType() { - return operationType; - } - - /** - * @return if error occurred during processing of this operation, this field will be populated. - */ - public List getErrors() { - return errors; - } - - /** - * {@inheritDoc} - */ - protected Objects.ToStringHelper string() { - return super.string() - .omitNullValues() - .add("targetLink", targetLink) - .add("targetId", targetId.orNull()) - .add("clientOperationId", clientOperationId.orNull()) - .add("status", status) - .add("statusMessage", statusMessage.orNull()) - .add("user", user) - .add("progress", progress.orNull()) - .add("insertTime", insertTime) - .add("startTime", startTime.orNull()) - .add("endTime", endTime.orNull()) - .add("httpError", httpError.orNull()) - .add("operationType", operationType) - .add("errors", errors); - } - - /** - * {@inheritDoc} - */ - @Override - public String toString() { - return string().toString(); - } - - public static Builder builder() { - return new Builder(); - } - - public Builder toBuilder() { - return new Builder().fromOperation(this); - } - - public static final class Builder extends Resource.Builder { - - private URI targetLink; - private String targetId; - private String clientOperationId; - private Status status; - private String statusMessage; - private String user; - private Integer progress; - private Date insertTime; - private Date startTime; - private Date endTime; - private Integer httpErrorStatusCode; - private String httpErrorMessage; - private String operationType; - private ImmutableList.Builder errors = ImmutableList.builder(); - - /** - * @see Operation#getTargetLink() - */ - public Builder targetLink(URI targetLink) { - this.targetLink = targetLink; - return self(); - } - - /** - * @see Operation#getTargetId() - */ - public Builder targetId(String targetId) { - this.targetId = targetId; - return self(); - } - - /** - * @see Operation#getClientOperationId() - */ - public Builder clientOperationId(String clientOperationId) { - this.clientOperationId = clientOperationId; - return self(); - } - - /** - * @see Operation#getStatus() - */ - public Builder status(Status status) { - this.status = status; - return self(); - } - - /** - * @see Operation#getStatusMessage() - */ - public Builder statusMessage(String statusMessage) { - this.statusMessage = statusMessage; - return self(); - } - - /** - * @see Operation#getUser() - */ - public Builder user(String user) { - this.user = user; - return self(); - } - - /** - * @see Operation#getProgress() - */ - public Builder progress(Integer progress) { - this.progress = progress; - return self(); - } - - /** - * @see Operation#getInsertTime() - */ - public Builder insertTime(Date insertTime) { - this.insertTime = insertTime; - return self(); - } - - /** - * @see Operation#getStartTime() - */ - public Builder startTime(Date startTime) { - this.startTime = startTime; - return self(); - } - - /** - * @see Operation#getEndTime() - */ - public Builder endTime(Date endTime) { - this.endTime = endTime; - return self(); - } - - /** - * @see Operation#getHttpError() - */ - public Builder httpErrorStatusCode(Integer httpErrorStatusCode) { - this.httpErrorStatusCode = httpErrorStatusCode; - return self(); - } - - /** - * @see Operation#getHttpError() - */ - public Builder httpErrorMessage(String httpErrorMessage) { - this.httpErrorMessage = httpErrorMessage; - return self(); - } - - /** - * @see Operation#getOperationType() - */ - public Builder operationType(String operationType) { - this.operationType = operationType; - return self(); - } - - /** - * @see Operation#getErrors() - */ - public Builder errors(Iterable errors) { - if (errors != null) - this.errors.addAll(errors); - return self(); - } - - /** - * @see Operation#getErrors() - */ - public Builder addError(Error error) { - this.errors.add(error); - return self(); - } - - @Override - protected Builder self() { - return this; - } - - public Operation build() { - return new Operation(super.id, super.creationTimestamp, super.selfLink, super.name, - super.description, targetLink, targetId, clientOperationId, status, statusMessage, user, progress, - insertTime, startTime, endTime, httpErrorStatusCode, httpErrorMessage, operationType, - errors.build()); - } - - public Builder fromOperation(Operation in) { - return super.fromResource(in) - .targetLink(in.getTargetLink()) - .targetId(in.getTargetId().orNull()) - .clientOperationId(in.getClientOperationId().orNull()) - .status(in.getStatus()) - .statusMessage(in.getStatusMessage().orNull()) - .user(in.getUser()) - .progress(in.getProgress().get()) - .insertTime(in.getInsertTime()) - .startTime(in.getStartTime().orNull()) - .endTime(in.getEndTime().orNull()) - .httpErrorStatusCode(in.getHttpError().isPresent() ? in.getHttpError().get().getStatusCode() : null) - .httpErrorMessage(in.getHttpError().isPresent() ? in.getHttpError().get().getMessage() : null) - .operationType(in.getOperationType()).errors(in.getErrors()); - } - } - - /** - * A particular error for an operation including the details. - */ - public static final class Error { - - private final String code; - private final Optional location; - private final Optional message; - - @ConstructorProperties({ - "code", "location", "message" - }) - private Error(String code, String location, String message) { - this.code = checkNotNull(code, "code"); - this.location = fromNullable(location); - this.message = fromNullable(message); - } - - /** - * @return the error type identifier for this error. - */ - public String getCode() { - return code; - } - - /** - * @return indicates the field in the request which caused the error.. - */ - public Optional getLocation() { - return location; - } - - /** - * @return an optional, human-readable error message. - */ - public Optional getMessage() { - return message; - } - - /** - * {@inheritDoc} - */ - @Override - public int hashCode() { - return Objects.hashCode(code, location, message); - } - - /** - * {@inheritDoc} - */ - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - Error that = Error.class.cast(obj); - return equal(this.code, that.code) - && equal(this.location, that.location) - && equal(this.message, that.message); - } - - /** - * {@inheritDoc} - */ - protected Objects.ToStringHelper string() { - return toStringHelper(this) - .omitNullValues() - .add("code", code) - .add("location", location.orNull()) - .add("message", message.orNull()); - } - - /** - * {@inheritDoc} - */ - @Override - public String toString() { - return string().toString(); - } - - public static Builder builder() { - return new Builder(); - } - - public Builder toBuilder() { - return builder().fromOperationErrorDetail(this); - } - - public static final class Builder { - - private String code; - private String location; - private String message; - - /** - * @see org.jclouds.googlecompute.domain.Operation.Error#getCode() - */ - public Builder code(String code) { - this.code = code; - return this; - } - - /** - * @see org.jclouds.googlecompute.domain.Operation.Error#getLocation() - */ - public Builder location(String location) { - this.location = location; - return this; - } - - /** - * @see org.jclouds.googlecompute.domain.Operation.Error#getMessage() - */ - public Builder message(String message) { - this.message = message; - return this; - } - - public Error build() { - return new Error(code, location, message); - } - - public Builder fromOperationErrorDetail(Error in) { - return new Builder().code(in.getCode()).location(in.getLocation().orNull()).message - (in.getMessage().orNull()); - } - } - } -} diff --git a/labs/google-compute/src/main/java/org/jclouds/googlecompute/domain/Project.java b/labs/google-compute/src/main/java/org/jclouds/googlecompute/domain/Project.java deleted file mode 100644 index dd48d48fc3..0000000000 --- a/labs/google-compute/src/main/java/org/jclouds/googlecompute/domain/Project.java +++ /dev/null @@ -1,305 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.googlecompute.domain; - -import com.google.common.annotations.Beta; -import com.google.common.base.Objects; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; -import org.jclouds.javax.annotation.Nullable; - -import java.beans.ConstructorProperties; -import java.net.URI; -import java.util.Date; -import java.util.Map; -import java.util.Set; - -import static com.google.common.base.Objects.equal; -import static com.google.common.base.Objects.toStringHelper; -import static com.google.common.base.Preconditions.checkNotNull; - -/** - * A Project resource is the root collection and settings resource for all Google Compute Engine resources. - * - * @author David Alves - * @see - */ -@Beta -public class Project extends Resource { - - private final Map commonInstanceMetadata; - private final Set quotas; - private final Set externalIpAddresses; - - protected Project(String id, Date creationTimestamp, URI selfLink, String name, String description, - Map commonInstanceMetadata, Set quotas, Set externalIpAddresses) { - super(Kind.PROJECT, id, creationTimestamp, selfLink, name, description); - this.commonInstanceMetadata = commonInstanceMetadata == null ? ImmutableMap.of() : ImmutableMap.copyOf(commonInstanceMetadata); - this.quotas = quotas == null ? ImmutableSet.of() : ImmutableSet.copyOf(quotas); - this.externalIpAddresses = externalIpAddresses == null ? ImmutableSet.of() : ImmutableSet.copyOf - (externalIpAddresses); - } - - /** - * @return metadata key/value pairs available to all instances contained in this project. - */ - public Map getCommonInstanceMetadata() { - return commonInstanceMetadata; - } - - /** - * @return quotas assigned to this project. - */ - public Set getQuotas() { - return quotas; - } - - /** - * @return internet available IP addresses available for use in this project. - */ - @Nullable - public Set getExternalIpAddresses() { - return externalIpAddresses; - } - - /** - * {@inheritDoc} - */ - protected Objects.ToStringHelper string() { - return super.string() - .add("commonInstanceMetadata", commonInstanceMetadata) - .add("quotas", quotas) - .add("externalIpAddresses", externalIpAddresses); - } - - /** - * {@inheritDoc} - */ - @Override - public String toString() { - return string().toString(); - } - - public static Builder builder() { - return new Builder(); - } - - public Builder toBuilder() { - return new Builder().fromProject(this); - } - - public static final class Builder extends Resource.Builder { - - private ImmutableMap.Builder commonInstanceMetadata = ImmutableMap.builder(); - private ImmutableSet.Builder quotas = ImmutableSet.builder(); - private ImmutableSet.Builder externalIpAddresses = ImmutableSet.builder(); - - /** - * @see Project#getCommonInstanceMetadata() - */ - public Builder addCommonInstanceMetadata(String key, String value) { - this.commonInstanceMetadata.put(key, value); - return this; - } - - /** - * @see Project#getCommonInstanceMetadata() - */ - public Builder commonInstanceMetadata(Map commonInstanceMetadata) { - this.commonInstanceMetadata.putAll(checkNotNull(commonInstanceMetadata, "commonInstanceMetadata")); - return this; - } - - /** - * @see Project#getQuotas() - */ - public Builder addQuota(String metric, double usage, double limit) { - this.quotas.add(Quota.builder().metric(metric).usage(usage).limit(limit).build()); - return this; - } - - /** - * @see Project#getQuotas() - */ - public Builder quotas(Set quotas) { - this.quotas.addAll(checkNotNull(quotas)); - return this; - } - - /** - * @see Project#getExternalIpAddresses() - */ - public Builder addExternalIpAddress(String externalIpAddress) { - this.externalIpAddresses.add(checkNotNull(externalIpAddress, "externalIpAddress")); - return this; - } - - /** - * @see Project#getExternalIpAddresses() - */ - public Builder externalIpAddresses(Set externalIpAddresses) { - this.externalIpAddresses.addAll(checkNotNull(externalIpAddresses, "externalIpAddresses")); - return this; - } - - @Override - protected Builder self() { - return this; - } - - public Project build() { - return new Project(super.id, super.creationTimestamp, super.selfLink, super.name, - super.description, commonInstanceMetadata.build(), quotas.build(), externalIpAddresses.build()); - } - - public Builder fromProject(Project in) { - return super.fromResource(in).commonInstanceMetadata(in.getCommonInstanceMetadata()).quotas(in.getQuotas()) - .externalIpAddresses(in.getExternalIpAddresses()); - } - } - - /** - * Quotas assigned to a given project - * - * @see - */ - public static final class Quota { - - private String metric; - private double usage; - private double limit; - - @ConstructorProperties({ - "metric", "usage", "limit" - }) - protected Quota(String metric, Double usage, Double limit) { - this.metric = checkNotNull(metric, "metric"); - this.usage = checkNotNull(usage, "usage"); - this.limit = checkNotNull(limit, "limit"); - } - - /** - * @return name of the quota metric. - */ - public String getMetric() { - return metric; - } - - /** - * @return current usage of this metric. - */ - public Double getUsage() { - return usage; - } - - /** - * @return quota limit for this metric. - */ - public Double getLimit() { - return limit; - } - - /** - * {@inheritDoc} - */ - @Override - public int hashCode() { - return Objects.hashCode(metric); - } - - /** - * {@inheritDoc} - */ - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - Quota that = Quota.class.cast(obj); - return equal(this.metric, that.metric); - } - - /** - * {@inheritDoc} - */ - protected Objects.ToStringHelper string() { - return toStringHelper(this) - .omitNullValues() - .add("metric", metric) - .add("usage", usage) - .add("limit", limit); - } - - /** - * {@inheritDoc} - */ - @Override - public String toString() { - return string().toString(); - } - - public static Builder builder() { - return new Builder(); - } - - public Builder toBuilder() { - return builder().fromQuota(this); - } - - public static class Builder { - - private String metric; - private Double usage; - private Double limit; - - /** - * @see org.jclouds.googlecompute.domain.Project.Quota#getMetric() - */ - public Builder metric(String metric) { - this.metric = checkNotNull(metric, "metric"); - return this; - } - - /** - * @see org.jclouds.googlecompute.domain.Project.Quota#getUsage() - */ - public Builder usage(Double usage) { - this.usage = usage; - return this; - } - - /** - * @see org.jclouds.googlecompute.domain.Project.Quota#getLimit() - */ - public Builder limit(Double limit) { - this.limit = limit; - return this; - } - - public Quota build() { - return new Quota(metric, usage, limit); - } - - public Builder fromQuota(Quota quota) { - return new Builder().metric(quota.getMetric()).usage(quota.getUsage()).limit(quota.getLimit()); - } - } - } -} diff --git a/labs/google-compute/src/main/java/org/jclouds/googlecompute/domain/Resource.java b/labs/google-compute/src/main/java/org/jclouds/googlecompute/domain/Resource.java deleted file mode 100644 index 17bb6695bd..0000000000 --- a/labs/google-compute/src/main/java/org/jclouds/googlecompute/domain/Resource.java +++ /dev/null @@ -1,281 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.googlecompute.domain; - -import com.google.common.annotations.Beta; -import com.google.common.base.CaseFormat; -import com.google.common.base.Joiner; -import com.google.common.base.Objects; -import com.google.common.base.Optional; -import com.google.common.base.Splitter; -import com.google.common.collect.Iterables; -import org.jclouds.javax.annotation.Nullable; - -import java.beans.ConstructorProperties; -import java.net.URI; -import java.util.Date; - -import static com.google.common.base.Objects.ToStringHelper; -import static com.google.common.base.Objects.equal; -import static com.google.common.base.Objects.toStringHelper; -import static com.google.common.base.Optional.fromNullable; -import static com.google.common.base.Preconditions.checkNotNull; - -/** - * Base class for Google Compute Engine resources. - * - * @author David Alves - */ -@Beta -public class Resource { - - public enum Kind { - DISK, - DISK_LIST, - FIREWALL, - FIREWALL_LIST, - IMAGE, - IMAGE_LIST, - OPERATION, - OPERATION_LIST, - INSTANCE, - INSTANCE_LIST, - KERNEL, - KERNEL_LIST, - MACHINE_TYPE, - MACHINE_TYPE_LIST, - PROJECT, - NETWORK, - NETWORK_LIST, - ZONE, - ZONE_LIST; - - public String value() { - return Joiner.on("#").join("compute", CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, name())); - } - - @Override - public String toString() { - return value(); - } - - public static Kind fromValue(String kind) { - return valueOf(CaseFormat.LOWER_CAMEL.to(CaseFormat - .UPPER_UNDERSCORE, - Iterables.getLast(Splitter.on("#").split(checkNotNull(kind, - "kind"))))); - } - } - - protected final Kind kind; - protected final String id; - protected final Optional creationTimestamp; - protected final URI selfLink; - protected final String name; - protected final Optional description; - - @ConstructorProperties({ - "kind", "id", "creationTimestamp", "selfLink", "name", "description" - }) - protected Resource(Kind kind, String id, Date creationTimestamp, URI selfLink, String name, - String description) { - this.kind = checkNotNull(kind, "kind"); - this.id = checkNotNull(id, "id"); - this.creationTimestamp = fromNullable(creationTimestamp); - this.selfLink = checkNotNull(selfLink, "selfLink"); - this.name = checkNotNull(name, "name"); - this.description = fromNullable(description); - } - - /** - * @return the Type of the resource - */ - public Kind getKind() { - return kind; - } - - /** - * @return unique identifier for the resource; defined by the server. - */ - public String getId() { - return id; - } - - /** - * @return creation timestamp in RFC3339 text format. - */ - public Optional getCreationTimestamp() { - return creationTimestamp; - } - - /** - * @return server defined URL for the resource. - */ - public URI getSelfLink() { - return selfLink; - } - - /** - * @return name of the resource. - */ - public String getName() { - return name; - } - - /** - * @return an optional textual description of the resource. - */ - @Nullable - public Optional getDescription() { - return description; - } - - /** - * {@inheritDoc} - */ - @Override - public int hashCode() { - return Objects.hashCode(kind, name); - } - - /** - * {@inheritDoc} - */ - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - Resource that = Resource.class.cast(obj); - return equal(this.kind, that.kind) - && equal(this.name, that.name); - } - - /** - * {@inheritDoc} - */ - protected ToStringHelper string() { - return toStringHelper(this) - .omitNullValues() - .add("kind", kind) - .add("id", id) - .add("name", name) - .add("creationTimestamp", creationTimestamp.orNull()) - .add("selfLink", selfLink) - .add("name", name) - .add("description", description.orNull()); - } - - /** - * {@inheritDoc} - */ - @Override - public String toString() { - return string().toString(); - } - - public static Builder builder() { - return new ConcreteBuilder(); - } - - public Builder toBuilder() { - return new ConcreteBuilder().fromResource(this); - } - - public abstract static class Builder> { - - protected abstract T self(); - - protected Kind kind; - protected String id; - protected Date creationTimestamp; - protected URI selfLink; - protected String name; - protected String description; - - /** - * @see Resource#getKind() - */ - protected T kind(Kind kind) { - this.kind = kind; - return self(); - } - - /** - * @see Resource#getId() - */ - public T id(String id) { - this.id = id; - return self(); - } - - /** - * @see Resource#getCreationTimestamp() - */ - public T creationTimestamp(Date creationTimestamp) { - this.creationTimestamp = creationTimestamp; - return self(); - } - - /** - * @see Resource#getSelfLink() - */ - public T selfLink(URI selfLink) { - this.selfLink = selfLink; - return self(); - } - - /** - * @see Resource#getName() - */ - public T name(String name) { - this.name = name; - return self(); - } - - /** - * @see Resource#getDescription() - */ - public T description(String description) { - this.description = description; - return self(); - } - - public Resource build() { - return new Resource(kind, id, creationTimestamp, selfLink, name, description); - } - - public T fromResource(Resource in) { - return this - .kind(in.getKind()) - .id(in.getId()) - .creationTimestamp(in.getCreationTimestamp().orNull()) - .selfLink(in.getSelfLink()) - .name(in.getName()) - .description(in.getDescription().orNull()); - } - } - - private static class ConcreteBuilder extends Builder { - @Override - protected ConcreteBuilder self() { - return this; - } - } -} diff --git a/labs/google-compute/src/main/java/org/jclouds/googlecompute/domain/Zone.java b/labs/google-compute/src/main/java/org/jclouds/googlecompute/domain/Zone.java deleted file mode 100644 index 4ea01b29f3..0000000000 --- a/labs/google-compute/src/main/java/org/jclouds/googlecompute/domain/Zone.java +++ /dev/null @@ -1,337 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.googlecompute.domain; - -import com.google.common.annotations.Beta; -import com.google.common.base.Objects; -import com.google.common.base.Optional; -import com.google.common.collect.ImmutableSet; -import org.jclouds.javax.annotation.Nullable; - -import java.beans.ConstructorProperties; -import java.net.URI; -import java.util.Date; -import java.util.Set; - -import static com.google.common.base.Objects.equal; -import static com.google.common.base.Objects.toStringHelper; -import static com.google.common.base.Optional.fromNullable; -import static com.google.common.base.Preconditions.checkNotNull; - -/** - * Represents a zone resource. - * - * @author David Alves - * @see - */ -@Beta -public final class Zone extends Resource { - - public enum Status { - UP, - DOWN - } - - private final Status status; - private final Set maintenanceWindows; - private final Set availableMachineTypes; - - @ConstructorProperties({ - "id", "creationTimestamp", "selfLink", "name", "description", "status", "maintenanceWindows", - "availableMachineTypes" - }) - private Zone(String id, Date creationTimestamp, URI selfLink, String name, String description, - Status status, Set maintenanceWindows, Set availableMachineTypes) { - super(Kind.ZONE, id, creationTimestamp, selfLink, name, description); - this.status = checkNotNull(status, "status of %name", name); - this.maintenanceWindows = maintenanceWindows == null ? ImmutableSet.of() : ImmutableSet - .copyOf(maintenanceWindows); - this.availableMachineTypes = availableMachineTypes == null ? ImmutableSet.of() : ImmutableSet - .copyOf(availableMachineTypes); - } - - /** - * @return Status of the zone. "UP" or "DOWN". - */ - public Status getStatus() { - return status; - } - - /** - * @return scheduled maintenance windows for the zone. When the zone is in a maintenance window, - * all resources which reside in the zone will be unavailable. - */ - public Set getMaintenanceWindows() { - return maintenanceWindows; - } - - /** - * @return the machine types that can be used in this zone. - */ - @Nullable - public Set getAvailableMachineTypes() { - return availableMachineTypes; - } - - /** - * {@inheritDoc} - */ - protected Objects.ToStringHelper string() { - return super.string() - .add("status", status) - .add("maintenanceWindows", maintenanceWindows) - .add("availableMachineTypes", availableMachineTypes); - } - - /** - * {@inheritDoc} - */ - @Override - public String toString() { - return string().toString(); - } - - public static Builder builder() { - return new Builder(); - } - - public Builder toBuilder() { - return new Builder().fromZone(this); - } - - public static final class Builder extends Resource.Builder { - - private Status status; - private ImmutableSet.Builder maintenanceWindows = ImmutableSet.builder(); - private ImmutableSet.Builder availableMachineTypes = ImmutableSet.builder(); - - /** - * @see Zone#getStatus() - */ - public Builder status(Status status) { - this.status = status; - return this; - } - - /** - * @see Zone#getMaintenanceWindows() - */ - public Builder addMaintenanceWindow(MaintenanceWindow maintenanceWindow) { - this.maintenanceWindows.add(checkNotNull(maintenanceWindow, "maintenanceWindow")); - return this; - } - - /** - * @see Zone#getMaintenanceWindows() - */ - public Builder maintenanceWindows(Set maintenanceWindows) { - this.maintenanceWindows.addAll(checkNotNull(maintenanceWindows, "maintenanceWindows")); - return this; - } - - /** - * @see Zone#getAvailableMachineTypes() - */ - public Builder addAvailableMachineType(String availableMachineType) { - this.availableMachineTypes.add(checkNotNull(availableMachineType, "availableMachineType")); - return this; - } - - /** - * @see Zone#getAvailableMachineTypes() - */ - public Builder availableMachineTypes(Set availableMachineTypes) { - this.availableMachineTypes.addAll(checkNotNull(availableMachineTypes, "availableMachineTypes")); - return this; - } - - @Override - protected Builder self() { - return this; - } - - public Zone build() { - return new Zone(super.id, super.creationTimestamp, super.selfLink, super.name, - super.description, status, maintenanceWindows.build(), availableMachineTypes.build()); - } - - public Builder fromZone(Zone in) { - return super.fromResource(in) - .status(in.getStatus()) - .maintenanceWindows(in.getMaintenanceWindows()) - .availableMachineTypes(in.getAvailableMachineTypes()); - } - } - - /** - * Scheduled maintenance windows for the zone. When the zone is in a maintenance window, - * all resources which reside in the zone will be unavailable. - * - * @see - */ - public static final class MaintenanceWindow { - - private final String name; - private final Optional description; - private final Date beginTime; - private final Date endTime; - - @ConstructorProperties({ - "name", "description", "beginTime", "endTime" - }) - private MaintenanceWindow(String name, String description, Date beginTime, Date endTime) { - this.name = checkNotNull(name, "name"); - this.description = fromNullable(description); - this.beginTime = checkNotNull(beginTime, "beginTime of %name", name); - this.endTime = checkNotNull(endTime, "endTime of %name", name); - } - - /** - * @return name of the maintenance window. - */ - public String getName() { - return name; - } - - /** - * @return textual description of the maintenance window. - */ - public Optional getDescription() { - return description; - } - - /** - * @return begin time of the maintenance window. - */ - public Date getBeginTime() { - return beginTime; - } - - /** - * @return end time of the maintenance window. - */ - public Date getEndTime() { - return endTime; - } - - /** - * {@inheritDoc} - */ - @Override - public int hashCode() { - return Objects.hashCode(name, description, beginTime, endTime); - } - - - /** - * {@inheritDoc} - */ - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - MaintenanceWindow that = MaintenanceWindow.class.cast(obj); - return equal(this.name, that.name) - && equal(this.beginTime, that.beginTime) - && equal(this.endTime, that.endTime); - } - - /** - * {@inheritDoc} - */ - protected Objects.ToStringHelper string() { - return toStringHelper(this) - .omitNullValues() - .add("name", name) - .add("description", description.orNull()) - .add("beginTime", beginTime) - .add("endTime", endTime); - } - - /** - * {@inheritDoc} - */ - @Override - public String toString() { - return string().toString(); - } - - public static Builder builder() { - return new Builder(); - } - - public Builder toBuilder() { - return builder().fromZoneMaintenanceWindow(this); - } - - public static final class Builder { - - private String name; - private String description; - private Date beginTime; - private Date endTime; - - /** - * @see org.jclouds.googlecompute.domain.Zone.MaintenanceWindow#getName() - */ - public Builder name(String name) { - this.name = name; - return this; - } - - /** - * @see org.jclouds.googlecompute.domain.Zone.MaintenanceWindow#getDescription() - */ - public Builder description(String description) { - this.description = description; - return this; - } - - /** - * @see org.jclouds.googlecompute.domain.Zone.MaintenanceWindow#getBeginTime() - */ - public Builder beginTime(Date beginTime) { - this.beginTime = beginTime; - return this; - } - - /** - * @see org.jclouds.googlecompute.domain.Zone.MaintenanceWindow#getEndTime() - */ - public Builder endTime(Date endTime) { - this.endTime = endTime; - return this; - } - - - public MaintenanceWindow build() { - return new MaintenanceWindow(name, description, beginTime, endTime); - } - - public Builder fromZoneMaintenanceWindow(MaintenanceWindow in) { - return new Builder() - .name(in.getName()) - .description(in.getDescription().orNull()) - .beginTime(in.getBeginTime()) - .endTime(in.getEndTime()); - } - } - } -} diff --git a/labs/google-compute/src/main/java/org/jclouds/googlecompute/features/DiskApi.java b/labs/google-compute/src/main/java/org/jclouds/googlecompute/features/DiskApi.java deleted file mode 100644 index 43324b2d4e..0000000000 --- a/labs/google-compute/src/main/java/org/jclouds/googlecompute/features/DiskApi.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.googlecompute.features; - -import org.jclouds.collect.PagedIterable; -import org.jclouds.googlecompute.domain.Disk; -import org.jclouds.googlecompute.domain.ListPage; -import org.jclouds.googlecompute.domain.Operation; -import org.jclouds.googlecompute.options.ListOptions; -import org.jclouds.javax.annotation.Nullable; - -import java.net.URI; - -/** - * Provides synchronous access to Disks via their REST API. - * - * @author David Alves - * @see DiskAsyncApi - * @see - */ -public interface DiskApi { - - /** - * Returns the specified persistent disk resource. - * - * @param diskName name of the persistent disk resource to return. - * @return a Disk resource. - */ - Disk get(String diskName); - - /** - * Creates a persistent disk resource in the specified project specifying the size of the disk. - * - * - * @param diskName the name of disk. - * @param sizeGb the size of the disk - * @param zone the URi of the zone where the disk is to be created. - * @return an Operation resource. To check on the status of an operation, poll the Operations resource returned to - * you, and look for the status field. - */ - Operation createInZone(String diskName, int sizeGb, URI zone); - - /** - * Deletes the specified persistent disk resource. - * - * @param diskName name of the persistent disk resource to delete. - * @return an Operation resource. To check on the status of an operation, poll the Operations resource returned to - * you, and look for the status field. - */ - Operation delete(String diskName); - - /** - * @see DiskApi#listAtMarker(String, org.jclouds.googlecompute.options.ListOptions) - */ - public ListPage listFirstPage(); - - /** - * @see DiskApi#listAtMarker(String, org.jclouds.googlecompute.options.ListOptions) - */ - public ListPage listAtMarker(@Nullable String marker); - - - /** - * Retrieves the listPage of persistent disk resources contained within the specified project. - * By default the listPage as a maximum size of 100, if no options are provided or ListOptions#getMaxResults() has - * not been set. - * - * @param marker marks the beginning of the next list page - * @param listOptions listing options - * @return a page of the listPage - * @see ListOptions - * @see org.jclouds.googlecompute.domain.ListPage - */ - ListPage listAtMarker(@Nullable String marker, ListOptions listOptions); - - /** - * @see DiskApi#list(org.jclouds.googlecompute.options.ListOptions) - */ - public PagedIterable list(); - - /** - * A paged version of DiskApi#listPage() - * - * @return a Paged, Fluent Iterable that is able to fetch additional pages when required - * @see PagedIterable - * @see DiskApi#listAtMarker(String, org.jclouds.googlecompute.options.ListOptions) - */ - PagedIterable list(ListOptions listOptions); -} diff --git a/labs/google-compute/src/main/java/org/jclouds/googlecompute/features/DiskAsyncApi.java b/labs/google-compute/src/main/java/org/jclouds/googlecompute/features/DiskAsyncApi.java deleted file mode 100644 index 829e87fa7f..0000000000 --- a/labs/google-compute/src/main/java/org/jclouds/googlecompute/features/DiskAsyncApi.java +++ /dev/null @@ -1,166 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.googlecompute.features; - -import com.google.common.util.concurrent.ListenableFuture; -import org.jclouds.collect.PagedIterable; -import org.jclouds.googlecompute.domain.Disk; -import org.jclouds.googlecompute.domain.ListPage; -import org.jclouds.googlecompute.domain.Operation; -import org.jclouds.googlecompute.functions.internal.ParseDisks; -import org.jclouds.googlecompute.options.ListOptions; -import org.jclouds.javax.annotation.Nullable; -import org.jclouds.oauth.v2.config.OAuthScopes; -import org.jclouds.oauth.v2.filters.OAuthAuthenticator; -import org.jclouds.rest.annotations.Fallback; -import org.jclouds.rest.annotations.MapBinder; -import org.jclouds.rest.annotations.PayloadParam; -import org.jclouds.rest.annotations.RequestFilters; -import org.jclouds.rest.annotations.ResponseParser; -import org.jclouds.rest.annotations.SkipEncoding; -import org.jclouds.rest.annotations.Transform; -import org.jclouds.rest.binders.BindToJsonPayload; - -import javax.inject.Named; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.MediaType; -import java.net.URI; - -import static org.jclouds.Fallbacks.EmptyIterableWithMarkerOnNotFoundOr404; -import static org.jclouds.Fallbacks.EmptyPagedIterableOnNotFoundOr404; -import static org.jclouds.Fallbacks.NullOnNotFoundOr404; -import static org.jclouds.googlecompute.GoogleComputeConstants.COMPUTE_READONLY_SCOPE; -import static org.jclouds.googlecompute.GoogleComputeConstants.COMPUTE_SCOPE; - -/** - * Provides asynchronous access to Disks via their REST API. - * - * @author David Alves - * @see DiskApi - */ -@SkipEncoding({'/', '='}) -@RequestFilters(OAuthAuthenticator.class) -public interface DiskAsyncApi { - - /** - * @see DiskApi#get(String) - */ - @Named("Disks:get") - @GET - @Consumes(MediaType.APPLICATION_JSON) - @Path("/disks/{disk}") - @OAuthScopes(COMPUTE_READONLY_SCOPE) - @Fallback(NullOnNotFoundOr404.class) - ListenableFuture get(@PathParam("disk") String diskName); - - /** - * @see DiskApi#createInZone(String, int, java.net.URI) - */ - @Named("Disks:insert") - @POST - @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.APPLICATION_JSON) - @Path("/disks") - @OAuthScopes({COMPUTE_SCOPE}) - @MapBinder(BindToJsonPayload.class) - ListenableFuture createInZone(@PayloadParam("name") String diskName, - @PayloadParam("sizeGb") int sizeGb, - @PayloadParam("zone") URI zone); - - /** - * @see DiskApi#delete(String) - */ - @Named("Disks:delete") - @DELETE - @Consumes(MediaType.APPLICATION_JSON) - @Path("/disks/{disk}") - @OAuthScopes(COMPUTE_SCOPE) - @Fallback(NullOnNotFoundOr404.class) - ListenableFuture delete(@PathParam("disk") String diskName); - - /** - * @see org.jclouds.googlecompute.features.DiskApi#listFirstPage() - */ - @Named("Disks:list") - @GET - @Consumes(MediaType.APPLICATION_JSON) - @Path("/disks") - @OAuthScopes(COMPUTE_READONLY_SCOPE) - @ResponseParser(ParseDisks.class) - @Fallback(EmptyIterableWithMarkerOnNotFoundOr404.class) - ListenableFuture> listFirstPage(); - - /** - * @see DiskApi#listAtMarker(String) - */ - @Named("Disks:list") - @GET - @Consumes(MediaType.APPLICATION_JSON) - @Path("/disks") - @OAuthScopes(COMPUTE_READONLY_SCOPE) - @ResponseParser(ParseDisks.class) - @Fallback(EmptyIterableWithMarkerOnNotFoundOr404.class) - ListenableFuture> listAtMarker(@QueryParam("pageToken") @Nullable String marker); - - /** - * @see DiskApi#listAtMarker(String, org.jclouds.googlecompute.options.ListOptions) - */ - @Named("Disks:list") - @GET - @Consumes(MediaType.APPLICATION_JSON) - @Path("/disks") - @OAuthScopes(COMPUTE_READONLY_SCOPE) - @ResponseParser(ParseDisks.class) - @Fallback(EmptyIterableWithMarkerOnNotFoundOr404.class) - ListenableFuture> listAtMarker(@QueryParam("pageToken") @Nullable String marker, ListOptions options); - - /** - * @see DiskApi#list(org.jclouds.googlecompute.options.ListOptions) - */ - @Named("Disks:list") - @GET - @Consumes(MediaType.APPLICATION_JSON) - @Path("/disks") - @OAuthScopes(COMPUTE_READONLY_SCOPE) - @ResponseParser(ParseDisks.class) - @Transform(ParseDisks.ToPagedIterable.class) - @Fallback(EmptyPagedIterableOnNotFoundOr404.class) - ListenableFuture> list(); - - /** - * @see DiskApi#list(org.jclouds.googlecompute.options.ListOptions) - */ - @Named("Disks:list") - @GET - @Consumes(MediaType.APPLICATION_JSON) - @Path("/disks") - @OAuthScopes(COMPUTE_READONLY_SCOPE) - @ResponseParser(ParseDisks.class) - @Transform(ParseDisks.ToPagedIterable.class) - @Fallback(EmptyPagedIterableOnNotFoundOr404.class) - ListenableFuture> list(ListOptions options); -} diff --git a/labs/google-compute/src/main/java/org/jclouds/googlecompute/features/FirewallApi.java b/labs/google-compute/src/main/java/org/jclouds/googlecompute/features/FirewallApi.java deleted file mode 100644 index 904841bdbd..0000000000 --- a/labs/google-compute/src/main/java/org/jclouds/googlecompute/features/FirewallApi.java +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.googlecompute.features; - -import org.jclouds.collect.PagedIterable; -import org.jclouds.googlecompute.domain.Firewall; -import org.jclouds.googlecompute.domain.ListPage; -import org.jclouds.googlecompute.domain.Operation; -import org.jclouds.googlecompute.options.FirewallOptions; -import org.jclouds.googlecompute.options.ListOptions; -import org.jclouds.javax.annotation.Nullable; - -import java.net.URI; - -/** - * Provides synchronous access to Firewalls via their REST API. - *

- * TODO support PATCH - * (GCE uses PATCH as a Http method. Using this method is the only way to partially update a firewall.) - * - * @author David Alves - * @see FirewallAsyncApi - * @see - */ -public interface FirewallApi { - - /** - * Returns the specified image resource. - * - * @param firewallName name of the firewall resource to return. - * @return an Firewall resource - */ - Firewall get(String firewallName); - - /** - * Creates a firewall resource in the specified project using the data included in the request. - * - * @param name the name of the firewall to be inserted. - * @param network the network to which to add the firewall - * @param firewallOptions the options of the firewall to add - * @return an Operation resource. To check on the status of an operation, poll the Operations resource returned to - * you, and look for the status field. - */ - Operation createInNetwork(String name, URI network, FirewallOptions firewallOptions); - - /** - * Updates the specified firewall resource with the data included in the request. - * - * @param firewallName the name firewall to be updated. - * @param firewallOptions the new firewall. - * @return an Operation resource. To check on the status of an operation, poll the Operations resource returned to - * you, and look for the status field. - */ - Operation update(String firewallName, FirewallOptions firewallOptions); - - /** - * Updates the specified firewall resource, with patch semantics, with the data included in the request. - * - * @param firewallName the name firewall to be updated. - * @param firewallOptions the new firewall. - * @return an Operation resource. To check on the status of an operation, poll the Operations resource returned to - * you, and look for the status field. - */ - Operation patch(String firewallName, FirewallOptions firewallOptions); - - /** - * Deletes the specified image resource. - * - * @param imageName name of the firewall resource to delete. - * @return an Operation resource. To check on the status of an operation, poll the Operations resource returned to - * you, and look for the status field. If the image did not exist the result is null. - */ - Operation delete(String imageName); - - /** - * @see FirewallApi#listAtMarker(String, org.jclouds.googlecompute.options.ListOptions) - */ - ListPage listFirstPage(); - - /** - * @see FirewallApi#listAtMarker(String, org.jclouds.googlecompute.options.ListOptions) - */ - ListPage listAtMarker(@Nullable String marker); - - /** - * Retrieves the list of firewall resources available to the specified project. - * By default the list as a maximum size of 100, if no options are provided or ListOptions#getMaxResults() has not - * been set. - * - * @param marker marks the beginning of the next list page - * @param listOptions listing options - * @return a page of the list - * @see ListOptions - * @see org.jclouds.googlecompute.domain.ListPage - */ - ListPage listAtMarker(@Nullable String marker, @Nullable ListOptions listOptions); - - /** - * @see FirewallApi#list(org.jclouds.googlecompute.options.ListOptions) - */ - public PagedIterable list(); - - /** - * A paged version of FirewallApi#list() - * - * @return a Paged, Fluent Iterable that is able to fetch additional pages when required - * @see PagedIterable - * @see FirewallApi#listAtMarker(String, org.jclouds.googlecompute.options.ListOptions) - */ - PagedIterable list(@Nullable ListOptions listOptions); - - -} diff --git a/labs/google-compute/src/main/java/org/jclouds/googlecompute/features/FirewallAsyncApi.java b/labs/google-compute/src/main/java/org/jclouds/googlecompute/features/FirewallAsyncApi.java deleted file mode 100644 index 302ce89160..0000000000 --- a/labs/google-compute/src/main/java/org/jclouds/googlecompute/features/FirewallAsyncApi.java +++ /dev/null @@ -1,199 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.googlecompute.features; - -import com.google.common.util.concurrent.ListenableFuture; -import org.jclouds.collect.PagedIterable; -import org.jclouds.googlecompute.domain.Firewall; -import org.jclouds.googlecompute.domain.ListPage; -import org.jclouds.googlecompute.domain.Operation; -import org.jclouds.googlecompute.functions.internal.PATCH; -import org.jclouds.googlecompute.functions.internal.ParseFirewalls; -import org.jclouds.googlecompute.handlers.FirewallBinder; -import org.jclouds.googlecompute.options.FirewallOptions; -import org.jclouds.googlecompute.options.ListOptions; -import org.jclouds.javax.annotation.Nullable; -import org.jclouds.oauth.v2.config.OAuthScopes; -import org.jclouds.oauth.v2.filters.OAuthAuthenticator; -import org.jclouds.rest.annotations.BinderParam; -import org.jclouds.rest.annotations.Fallback; -import org.jclouds.rest.annotations.MapBinder; -import org.jclouds.rest.annotations.PayloadParam; -import org.jclouds.rest.annotations.RequestFilters; -import org.jclouds.rest.annotations.ResponseParser; -import org.jclouds.rest.annotations.SkipEncoding; -import org.jclouds.rest.annotations.Transform; -import org.jclouds.rest.binders.BindToJsonPayload; - -import javax.inject.Named; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.MediaType; -import java.net.URI; - -import static org.jclouds.Fallbacks.EmptyIterableWithMarkerOnNotFoundOr404; -import static org.jclouds.Fallbacks.EmptyPagedIterableOnNotFoundOr404; -import static org.jclouds.Fallbacks.NullOnNotFoundOr404; -import static org.jclouds.googlecompute.GoogleComputeConstants.COMPUTE_READONLY_SCOPE; -import static org.jclouds.googlecompute.GoogleComputeConstants.COMPUTE_SCOPE; - -/** - * Provides asynchronous access to Firewalls via their REST API. - * - * @author David Alves - * @see FirewallApi - *

- * Note: Patch is unsupported, jclouds side, at the moment - */ -@SkipEncoding({'/', '='}) -@RequestFilters(OAuthAuthenticator.class) -public interface FirewallAsyncApi { - - /** - * @see FirewallApi#get(String) - */ - @Named("Firewalls:get") - @GET - @Consumes(MediaType.APPLICATION_JSON) - @Path("/firewalls/{firewall}") - @OAuthScopes(COMPUTE_READONLY_SCOPE) - @Fallback(NullOnNotFoundOr404.class) - ListenableFuture get(@PathParam("firewall") String firewallName); - - /** - * @see FirewallApi#createInNetwork(String, java.net.URI, org.jclouds.googlecompute.options.FirewallOptions) - */ - @Named("Firewalls:insert") - @POST - @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.APPLICATION_JSON) - @Path("/firewalls") - @OAuthScopes({COMPUTE_SCOPE}) - @MapBinder(FirewallBinder.class) - ListenableFuture createInNetwork(@PayloadParam("name") String name, - @PayloadParam("network") URI network, - @PayloadParam("options") FirewallOptions firewallOptions); - - /** - * @see FirewallApi#update(String, org.jclouds.googlecompute.options.FirewallOptions) - */ - @Named("Firewalls:update") - @PUT - @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.APPLICATION_JSON) - @Path("/firewalls/{firewall}") - @OAuthScopes({COMPUTE_SCOPE}) - ListenableFuture update(@PathParam("firewall") String firewallName, - @BinderParam(BindToJsonPayload.class) FirewallOptions firewallOptions); - - /** - * @see FirewallApi#patch(String, org.jclouds.googlecompute.options.FirewallOptions) - */ - @Named("Firewalls:patch") - @PATCH - @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.APPLICATION_JSON) - @Path("/firewalls/{firewall}") - @OAuthScopes({COMPUTE_SCOPE}) - ListenableFuture patch(@PathParam("firewall") String firewallName, - @BinderParam(BindToJsonPayload.class) FirewallOptions firewallOptions); - - /** - * @see FirewallApi#delete(String) - */ - @Named("Firewalls:delete") - @DELETE - @Consumes(MediaType.APPLICATION_JSON) - @Path("/firewalls/{firewall}") - @OAuthScopes(COMPUTE_SCOPE) - @Fallback(NullOnNotFoundOr404.class) - ListenableFuture delete(@PathParam("firewall") String firewallName); - - /** - * @see FirewallApi#listFirstPage() - */ - @Named("Firewalls:list") - @GET - @Consumes(MediaType.APPLICATION_JSON) - @Path("/firewalls") - @OAuthScopes(COMPUTE_READONLY_SCOPE) - @ResponseParser(ParseFirewalls.class) - @Fallback(EmptyIterableWithMarkerOnNotFoundOr404.class) - ListenableFuture> listFirstPage(); - - /** - * @see FirewallApi#listAtMarker(String) - */ - @Named("Firewalls:list") - @GET - @Consumes(MediaType.APPLICATION_JSON) - @Path("/firewalls") - @OAuthScopes(COMPUTE_READONLY_SCOPE) - @ResponseParser(ParseFirewalls.class) - @Fallback(EmptyIterableWithMarkerOnNotFoundOr404.class) - ListenableFuture> listAtMarker(@QueryParam("pageToken") @Nullable String marker); - - /** - * @see FirewallApi#listAtMarker(String, org.jclouds.googlecompute.options.ListOptions) - */ - @Named("Firewalls:list") - @GET - @Consumes(MediaType.APPLICATION_JSON) - @Path("/firewalls") - @OAuthScopes(COMPUTE_READONLY_SCOPE) - @ResponseParser(ParseFirewalls.class) - @Fallback(EmptyIterableWithMarkerOnNotFoundOr404.class) - ListenableFuture> listAtMarker(@QueryParam("pageToken") @Nullable String marker, - ListOptions options); - - /** - * @see FirewallApi#list() - */ - @Named("Firewalls:list") - @GET - @Consumes(MediaType.APPLICATION_JSON) - @Path("/firewalls") - @OAuthScopes(COMPUTE_READONLY_SCOPE) - @ResponseParser(ParseFirewalls.class) - @Transform(ParseFirewalls.ToPagedIterable.class) - @Fallback(EmptyPagedIterableOnNotFoundOr404.class) - ListenableFuture> list(); - - - /** - * @see FirewallApi#list(org.jclouds.googlecompute.options.ListOptions) - */ - @Named("Firewalls:list") - @GET - @Consumes(MediaType.APPLICATION_JSON) - @Path("/firewalls") - @OAuthScopes(COMPUTE_READONLY_SCOPE) - @ResponseParser(ParseFirewalls.class) - @Transform(ParseFirewalls.ToPagedIterable.class) - @Fallback(EmptyPagedIterableOnNotFoundOr404.class) - ListenableFuture> list(ListOptions options); -} diff --git a/labs/google-compute/src/main/java/org/jclouds/googlecompute/features/ImageApi.java b/labs/google-compute/src/main/java/org/jclouds/googlecompute/features/ImageApi.java deleted file mode 100644 index 5f57b83d54..0000000000 --- a/labs/google-compute/src/main/java/org/jclouds/googlecompute/features/ImageApi.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.googlecompute.features; - -import org.jclouds.collect.PagedIterable; -import org.jclouds.googlecompute.domain.Image; -import org.jclouds.googlecompute.domain.ListPage; -import org.jclouds.googlecompute.domain.Operation; -import org.jclouds.googlecompute.options.ListOptions; -import org.jclouds.javax.annotation.Nullable; - -/** - * Provides synchronous access to Images via their REST API. - *

- * - * @author David Alves - * @see ImageAsyncApi - * @see - */ -public interface ImageApi { - - /** - * Returns the specified image resource. - * - * @param imageName name of the image resource to return. - * @return an Image resource - */ - Image get(String imageName); - - /** - * @see ImageApi#listAtMarker(String, org.jclouds.googlecompute.options.ListOptions) - */ - public ListPage listFirstPage(); - - /** - * @see ImageApi#listAtMarker(String, org.jclouds.googlecompute.options.ListOptions) - */ - public ListPage listAtMarker(@Nullable String marker); - - /** - * Deletes the specified image resource. - * - * @param imageName name of the image resource to delete. - * @return an Operation resource. To check on the status of an operation, poll the Operations resource returned to - * you, and look for the status field. If the image did not exist the result is null. - */ - Operation delete(String imageName); - - /** - * Retrieves the list of image resources available to the specified project. - * By default the list as a maximum size of 100, if no options are provided or ListOptions#getMaxResults() has not - * been set. - * - * - * @param marker marks the beginning of the next list page - * @param listOptions listing options - * @return a page of the list - * @see ListOptions - * @see org.jclouds.googlecompute.domain.ListPage - */ - ListPage listAtMarker(String marker, @Nullable ListOptions listOptions); - - /** - * @see ImageApi#list(org.jclouds.googlecompute.options.ListOptions) - */ - public PagedIterable list(); - - /** - * A paged version of ImageApi#list() - * - * @return a Paged, Fluent Iterable that is able to fetch additional pages when required - * @see PagedIterable - * @see ImageApi#listAtMarker(String, org.jclouds.googlecompute.options.ListOptions) - */ - PagedIterable list(@Nullable ListOptions listOptions); -} diff --git a/labs/google-compute/src/main/java/org/jclouds/googlecompute/features/ImageAsyncApi.java b/labs/google-compute/src/main/java/org/jclouds/googlecompute/features/ImageAsyncApi.java deleted file mode 100644 index d03f9e0573..0000000000 --- a/labs/google-compute/src/main/java/org/jclouds/googlecompute/features/ImageAsyncApi.java +++ /dev/null @@ -1,147 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.googlecompute.features; - -import com.google.common.util.concurrent.ListenableFuture; -import org.jclouds.collect.PagedIterable; -import org.jclouds.googlecompute.domain.Image; -import org.jclouds.googlecompute.domain.ListPage; -import org.jclouds.googlecompute.domain.Operation; -import org.jclouds.googlecompute.functions.internal.ParseImages; -import org.jclouds.googlecompute.options.ListOptions; -import org.jclouds.javax.annotation.Nullable; -import org.jclouds.oauth.v2.config.OAuthScopes; -import org.jclouds.oauth.v2.filters.OAuthAuthenticator; -import org.jclouds.rest.annotations.Fallback; -import org.jclouds.rest.annotations.RequestFilters; -import org.jclouds.rest.annotations.ResponseParser; -import org.jclouds.rest.annotations.SkipEncoding; -import org.jclouds.rest.annotations.Transform; - -import javax.inject.Named; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.MediaType; - -import static org.jclouds.Fallbacks.EmptyIterableWithMarkerOnNotFoundOr404; -import static org.jclouds.Fallbacks.EmptyPagedIterableOnNotFoundOr404; -import static org.jclouds.Fallbacks.NullOnNotFoundOr404; -import static org.jclouds.googlecompute.GoogleComputeConstants.COMPUTE_READONLY_SCOPE; -import static org.jclouds.googlecompute.GoogleComputeConstants.COMPUTE_SCOPE; - -/** - * Provides asynchronous access to Images via their REST API. - * - * @author David Alves - * @see ImageApi - */ -@SkipEncoding({'/', '='}) -@RequestFilters(OAuthAuthenticator.class) -public interface ImageAsyncApi { - - /** - * @see ImageApi#get(String) - */ - @Named("Images:get") - @GET - @Consumes(MediaType.APPLICATION_JSON) - @Path("/images/{image}") - @OAuthScopes(COMPUTE_READONLY_SCOPE) - @Fallback(NullOnNotFoundOr404.class) - ListenableFuture get(@PathParam("image") String imageName); - - /** - * @see ImageApi#delete(String) - */ - @Named("Images:delete") - @DELETE - @Consumes(MediaType.APPLICATION_JSON) - @Path("/images/{image}") - @OAuthScopes(COMPUTE_SCOPE) - @Fallback(NullOnNotFoundOr404.class) - ListenableFuture delete(@PathParam("image") String imageName); - - /** - * @see ImageApi#listFirstPage() - */ - @Named("Images:list") - @GET - @Consumes(MediaType.APPLICATION_JSON) - @Path("/images") - @OAuthScopes(COMPUTE_READONLY_SCOPE) - @ResponseParser(ParseImages.class) - @Fallback(EmptyIterableWithMarkerOnNotFoundOr404.class) - ListenableFuture> listFirstPage(); - - /** - * @see ImageApi#listAtMarker(String) - */ - @Named("Images:list") - @GET - @Consumes(MediaType.APPLICATION_JSON) - @Path("/images") - @OAuthScopes(COMPUTE_READONLY_SCOPE) - @ResponseParser(ParseImages.class) - @Fallback(EmptyIterableWithMarkerOnNotFoundOr404.class) - ListenableFuture> listAtMarker(@QueryParam("pageToken") @Nullable String marker); - - /** - * @see ImageApi#listAtMarker(String, org.jclouds.googlecompute.options.ListOptions) - */ - @Named("Images:list") - @GET - @Consumes(MediaType.APPLICATION_JSON) - @Path("/images") - @OAuthScopes(COMPUTE_READONLY_SCOPE) - @ResponseParser(ParseImages.class) - @Fallback(EmptyIterableWithMarkerOnNotFoundOr404.class) - ListenableFuture> listAtMarker(@QueryParam("pageToken") @Nullable String marker, - ListOptions options); - - /** - * @see ImageApi#listAtMarker(String) - */ - @Named("Images:list") - @GET - @Consumes(MediaType.APPLICATION_JSON) - @Path("/images") - @OAuthScopes(COMPUTE_READONLY_SCOPE) - @ResponseParser(ParseImages.class) - @Transform(ParseImages.ToPagedIterable.class) - @Fallback(EmptyPagedIterableOnNotFoundOr404.class) - ListenableFuture> list(); - - /** - * @see ImageApi#listAtMarker(String, org.jclouds.googlecompute.options.ListOptions) - */ - @Named("Images:list") - @GET - @Consumes(MediaType.APPLICATION_JSON) - @Path("/images") - @OAuthScopes(COMPUTE_READONLY_SCOPE) - @ResponseParser(ParseImages.class) - @Transform(ParseImages.ToPagedIterable.class) - @Fallback(EmptyPagedIterableOnNotFoundOr404.class) - ListenableFuture> list(ListOptions options); -} diff --git a/labs/google-compute/src/main/java/org/jclouds/googlecompute/features/InstanceApi.java b/labs/google-compute/src/main/java/org/jclouds/googlecompute/features/InstanceApi.java deleted file mode 100644 index a5933795fc..0000000000 --- a/labs/google-compute/src/main/java/org/jclouds/googlecompute/features/InstanceApi.java +++ /dev/null @@ -1,136 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.googlecompute.features; - -import org.jclouds.collect.PagedIterable; -import org.jclouds.googlecompute.domain.Instance; -import org.jclouds.googlecompute.domain.ListPage; -import org.jclouds.googlecompute.domain.Operation; -import org.jclouds.googlecompute.domain.InstanceTemplate; -import org.jclouds.googlecompute.options.ListOptions; -import org.jclouds.javax.annotation.Nullable; - -/** - * Provides synchronous access to Instances via their REST API. - *

- * - * @author David Alves - * @see InstanceAsyncApi - * @see - */ -public interface InstanceApi { - - /** - * Returns the specified instance resource. - * - * @param instanceName name of the instance resource to return. - * @return an Instance resource - */ - public Instance get(String instanceName); - - /** - * Creates a instance resource in the specified project using the data included in the request. - * - * @param instanceName this name of the instance to be created - * @param template the instance template - * @param zone the name of the zone where the instance will be created - * @return an Operation resource. To check on the status of an operation, poll the Operations resource returned to - * you, and look for the status field. - */ - public Operation createInZone(String instanceName, InstanceTemplate template, String zone); - - /** - * Deletes the specified instance resource. - * - * @param instanceName name of the instance resource to delete. - * @return an Operation resource. To check on the status of an operation, poll the Operations resource returned to - * you, and look for the status field. If the instance did not exist the result is null. - */ - public Operation delete(String instanceName); - - /** - * @see InstanceApi#listAtMarker(String, org.jclouds.googlecompute.options.ListOptions) - */ - public ListPage listFirstPage(); - - /** - * @see InstanceApi#listAtMarker(String, org.jclouds.googlecompute.options.ListOptions) - */ - public ListPage listAtMarker(@Nullable String marker); - - /** - * Retrieves the list of instance resources available to the specified project. - * By default the list as a maximum size of 100, if no options are provided or ListOptions#getMaxResults() has not - * been set. - * - * @param marker marks the beginning of the next list page - * @param listOptions listing options - * @return a page of the list - * @see ListOptions - * @see org.jclouds.googlecompute.domain.ListPage - */ - public ListPage listAtMarker(@Nullable String marker, @Nullable ListOptions listOptions); - - /** - * @see InstanceApi#list(org.jclouds.googlecompute.options.ListOptions) - */ - public PagedIterable list(); - - /** - * A paged version of InstanceApi#list() - * - * @return a Paged, Fluent Iterable that is able to fetch additional pages when required - * @see PagedIterable - * @see InstanceApi#listAtMarker(String, org.jclouds.googlecompute.options.ListOptions) - */ - public PagedIterable list(@Nullable ListOptions listOptions); - - /** - * Adds an access config to an instance's network interface. - * - * @param instanceName the instance name. - * @param accessConfig the AccessConfig to add. - * @param networkInterfaceName network interface name. - * @return an Operation resource. To check on the status of an operation, poll the Operations resource returned to - * you, and look for the status field. If the instance did not exist the result is null. - */ - public Operation addAccessConfigToNic(String instanceName, Instance.NetworkInterface.AccessConfig accessConfig, - String networkInterfaceName); - - /** - * Deletes an access config from an instance's network interface. - * - * @param instanceName the instance name. - * @param accessConfigName the name of the access config to delete - * @param networkInterfaceName network interface name. - * @return an Operation resource. To check on the status of an operation, poll the Operations resource returned to - * you, and look for the status field. If the instance did not exist the result is null. - */ - public Operation deleteAccessConfigFromNic(String instanceName, String accessConfigName, - String networkInterfaceName); - - /** - * Returns the specified instance's serial port output. - * - * @param instanceName the instance name. - * @return if successful, this method returns a SerialPortOutput containing the instance's serial output. - */ - public Instance.SerialPortOutput getSerialPortOutput(String instanceName); -} diff --git a/labs/google-compute/src/main/java/org/jclouds/googlecompute/features/InstanceAsyncApi.java b/labs/google-compute/src/main/java/org/jclouds/googlecompute/features/InstanceAsyncApi.java deleted file mode 100644 index 39a28904e4..0000000000 --- a/labs/google-compute/src/main/java/org/jclouds/googlecompute/features/InstanceAsyncApi.java +++ /dev/null @@ -1,206 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.googlecompute.features; - -import com.google.common.util.concurrent.ListenableFuture; -import org.jclouds.collect.PagedIterable; -import org.jclouds.googlecompute.domain.Instance; -import org.jclouds.googlecompute.domain.InstanceTemplate; -import org.jclouds.googlecompute.domain.ListPage; -import org.jclouds.googlecompute.domain.Operation; -import org.jclouds.googlecompute.functions.internal.ParseInstances; -import org.jclouds.googlecompute.handlers.InstanceBinder; -import org.jclouds.googlecompute.options.ListOptions; -import org.jclouds.javax.annotation.Nullable; -import org.jclouds.oauth.v2.config.OAuthScopes; -import org.jclouds.oauth.v2.filters.OAuthAuthenticator; -import org.jclouds.rest.annotations.BinderParam; -import org.jclouds.rest.annotations.Fallback; -import org.jclouds.rest.annotations.MapBinder; -import org.jclouds.rest.annotations.PayloadParam; -import org.jclouds.rest.annotations.RequestFilters; -import org.jclouds.rest.annotations.ResponseParser; -import org.jclouds.rest.annotations.SkipEncoding; -import org.jclouds.rest.annotations.Transform; -import org.jclouds.rest.binders.BindToJsonPayload; - -import javax.inject.Named; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.MediaType; - -import static org.jclouds.Fallbacks.EmptyIterableWithMarkerOnNotFoundOr404; -import static org.jclouds.Fallbacks.EmptyPagedIterableOnNotFoundOr404; -import static org.jclouds.Fallbacks.NullOnNotFoundOr404; -import static org.jclouds.googlecompute.GoogleComputeConstants.COMPUTE_READONLY_SCOPE; -import static org.jclouds.googlecompute.GoogleComputeConstants.COMPUTE_SCOPE; - -/** - * Provides asynchronous access to Instances via their REST API. - * - * @author David Alves - * @see InstanceApi - */ -@SkipEncoding({'/', '='}) -@RequestFilters(OAuthAuthenticator.class) -public interface InstanceAsyncApi { - - /** - * @see InstanceApi#get(String) - */ - @Named("Instances:get") - @GET - @Consumes(MediaType.APPLICATION_JSON) - @Path("/instances/{instance}") - @OAuthScopes(COMPUTE_READONLY_SCOPE) - @Fallback(NullOnNotFoundOr404.class) - ListenableFuture get(@PathParam("instance") String instanceName); - - /** - * @see InstanceApi#createInZone(String, org.jclouds.googlecompute.domain.InstanceTemplate, String) - */ - @Named("Instances:insert") - @POST - @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.APPLICATION_JSON) - @Path("/instances") - @OAuthScopes({COMPUTE_SCOPE}) - @MapBinder(InstanceBinder.class) - ListenableFuture createInZone(@PayloadParam("name") String instanceName, - @PayloadParam("template") InstanceTemplate template, - @PayloadParam("zone") String zone); - - /** - * @see InstanceApi#delete(String) - */ - @Named("Instances:delete") - @DELETE - @Consumes(MediaType.APPLICATION_JSON) - @Path("/instances/{instance}") - @OAuthScopes(COMPUTE_SCOPE) - @Fallback(NullOnNotFoundOr404.class) - ListenableFuture delete(@PathParam("instance") String instanceName); - - /** - * @see InstanceApi#listFirstPage() - */ - @Named("Instances:list") - @GET - @Consumes(MediaType.APPLICATION_JSON) - @Path("/instances") - @OAuthScopes(COMPUTE_READONLY_SCOPE) - @ResponseParser(ParseInstances.class) - @Fallback(EmptyIterableWithMarkerOnNotFoundOr404.class) - ListenableFuture> listFirstPage(); - - /** - * @see InstanceApi#listAtMarker(String) - */ - @Named("Instances:list") - @GET - @Consumes(MediaType.APPLICATION_JSON) - @Path("/instances") - @OAuthScopes(COMPUTE_READONLY_SCOPE) - @ResponseParser(ParseInstances.class) - @Fallback(EmptyIterableWithMarkerOnNotFoundOr404.class) - ListenableFuture> listAtMarker(@Nullable String marker); - - /** - * @see InstanceApi#listAtMarker(String, org.jclouds.googlecompute.options.ListOptions) - */ - @Named("Instances:list") - @GET - @Consumes(MediaType.APPLICATION_JSON) - @Path("/instances") - @OAuthScopes(COMPUTE_READONLY_SCOPE) - @ResponseParser(ParseInstances.class) - @Fallback(EmptyIterableWithMarkerOnNotFoundOr404.class) - ListenableFuture> listAtMarker(@Nullable String marker, ListOptions options); - - /** - * @see InstanceApi#list() - */ - @Named("Instances:list") - @GET - @Consumes(MediaType.APPLICATION_JSON) - @Path("/instances") - @OAuthScopes(COMPUTE_READONLY_SCOPE) - @ResponseParser(ParseInstances.class) - @Transform(ParseInstances.ToPagedIterable.class) - @Fallback(EmptyPagedIterableOnNotFoundOr404.class) - ListenableFuture> list(); - - /** - * @see InstanceApi#list(org.jclouds.googlecompute.options.ListOptions) - */ - @Named("Instances:list") - @GET - @Consumes(MediaType.APPLICATION_JSON) - @Path("/instances") - @OAuthScopes(COMPUTE_READONLY_SCOPE) - @ResponseParser(ParseInstances.class) - @Transform(ParseInstances.ToPagedIterable.class) - @Fallback(EmptyPagedIterableOnNotFoundOr404.class) - ListenableFuture> list(ListOptions options); - - /** - * @see InstanceApi#addAccessConfigToNic(String, Instance.NetworkInterface.AccessConfig, String) - */ - @Named("Instances:addAccessConfig") - @POST - @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.APPLICATION_JSON) - @Path("/instances/{instance}/addAccessConfig") - @OAuthScopes({COMPUTE_SCOPE}) - ListenableFuture addAccessConfigToNic(@PathParam("instance") String instanceName, - @BinderParam(BindToJsonPayload.class) - Instance.NetworkInterface.AccessConfig accessConfig, - @QueryParam("network_interface") String networkInterfaceName); - - /** - * @see InstanceApi#deleteAccessConfigFromNic(String, String, String) - */ - @Named("Instances:deleteAccessConfig") - @DELETE - @Consumes(MediaType.APPLICATION_JSON) - @Path("/instances/{instance}/deleteAccessConfig") - @OAuthScopes(COMPUTE_SCOPE) - @Fallback(NullOnNotFoundOr404.class) - ListenableFuture deleteAccessConfigFromNic(@PathParam("instance") String instanceName, - @QueryParam("access_config") String accessConfigName, - @QueryParam("network_interface") String networkInterfaceName); - - /** - * @see InstanceApi#getSerialPortOutput(String) - */ - @Named("Instances:serialPort") - @GET - @Consumes(MediaType.APPLICATION_JSON) - @Path("/instances/{instance}/serialPort") - @OAuthScopes(COMPUTE_READONLY_SCOPE) - @Fallback(NullOnNotFoundOr404.class) - ListenableFuture getSerialPortOutput(@PathParam("instance") String instanceName); -} diff --git a/labs/google-compute/src/main/java/org/jclouds/googlecompute/features/KernelApi.java b/labs/google-compute/src/main/java/org/jclouds/googlecompute/features/KernelApi.java deleted file mode 100644 index 847715a8f4..0000000000 --- a/labs/google-compute/src/main/java/org/jclouds/googlecompute/features/KernelApi.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.googlecompute.features; - -import org.jclouds.collect.PagedIterable; -import org.jclouds.googlecompute.domain.Kernel; -import org.jclouds.googlecompute.domain.ListPage; -import org.jclouds.googlecompute.options.ListOptions; -import org.jclouds.javax.annotation.Nullable; - -/** - * Provides synchronous access to MachineTypes via their REST API. - *

- * - * @author David Alves - * @see - */ -public interface KernelApi { - - /** - * Returns the specified kernel resource - * - * @param kernelName name of the kernel resource to return. - * @return If successful, this method returns a Kernel resource - */ - public Kernel get(String kernelName); - - /** - * @see KernelApi#listAtMarker(String, org.jclouds.googlecompute.options.ListOptions) - */ - public ListPage listFirstPage(); - - /** - * @see KernelApi#listAtMarker(String, org.jclouds.googlecompute.options.ListOptions) - */ - public ListPage listAtMarker(@Nullable String marker); - - /** - * Retrieves the list of kernel resources available to the specified project. - * By default the list as a maximum size of 100, if no options are provided or ListOptions#getMaxResults() has not - * been set. - * - * @param marker marks the beginning of the next list page - * @param listOptions listing options - * @return a page of the list - * @see ListOptions - * @see org.jclouds.googlecompute.domain.ListPage - */ - public ListPage listAtMarker(String marker, ListOptions listOptions); - - /** - * @see KernelApi#list(org.jclouds.googlecompute.options.ListOptions) - */ - public PagedIterable list(); - - /** - * A paged version of KernelApi#list() - * - * @return a Paged, Fluent Iterable that is able to fetch additional pages when required - * @see PagedIterable - * @see KernelApi#listAtMarker(String, org.jclouds.googlecompute.options.ListOptions) - */ - public PagedIterable list(ListOptions listOptions); - -} diff --git a/labs/google-compute/src/main/java/org/jclouds/googlecompute/features/KernelAsyncApi.java b/labs/google-compute/src/main/java/org/jclouds/googlecompute/features/KernelAsyncApi.java deleted file mode 100644 index 24a9caff78..0000000000 --- a/labs/google-compute/src/main/java/org/jclouds/googlecompute/features/KernelAsyncApi.java +++ /dev/null @@ -1,128 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.googlecompute.features; - -import com.google.common.util.concurrent.ListenableFuture; -import org.jclouds.collect.PagedIterable; -import org.jclouds.googlecompute.domain.Kernel; -import org.jclouds.googlecompute.domain.ListPage; -import org.jclouds.googlecompute.functions.internal.ParseKernels; -import org.jclouds.googlecompute.options.ListOptions; -import org.jclouds.javax.annotation.Nullable; -import org.jclouds.oauth.v2.config.OAuthScopes; -import org.jclouds.oauth.v2.filters.OAuthAuthenticator; -import org.jclouds.rest.annotations.Fallback; -import org.jclouds.rest.annotations.RequestFilters; -import org.jclouds.rest.annotations.ResponseParser; -import org.jclouds.rest.annotations.SkipEncoding; -import org.jclouds.rest.annotations.Transform; - -import javax.inject.Named; -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.MediaType; - -import static org.jclouds.Fallbacks.EmptyIterableWithMarkerOnNotFoundOr404; -import static org.jclouds.Fallbacks.EmptyPagedIterableOnNotFoundOr404; -import static org.jclouds.Fallbacks.NullOnNotFoundOr404; -import static org.jclouds.googlecompute.GoogleComputeConstants.COMPUTE_READONLY_SCOPE; - -/** - * Provides asynchronous access to Kernels via their REST API. - * - * @author David Alves - */ -@SkipEncoding({'/', '='}) -@RequestFilters(OAuthAuthenticator.class) -@Consumes(MediaType.APPLICATION_JSON) -public interface KernelAsyncApi { - - /** - * @see KernelApi#get(String) - */ - @Named("Kernels:get") - @GET - @Path("/kernels/{kernel}") - @OAuthScopes(COMPUTE_READONLY_SCOPE) - @Fallback(NullOnNotFoundOr404.class) - ListenableFuture get(@PathParam("kernel") String kernelName); - - /** - * @see KernelApi#listFirstPage() - */ - @Named("Kernels:list") - @GET - @Path("/kernels") - @OAuthScopes(COMPUTE_READONLY_SCOPE) - @ResponseParser(ParseKernels.class) - @Fallback(EmptyIterableWithMarkerOnNotFoundOr404.class) - ListenableFuture> listFirstPage(); - - /** - * @see KernelApi#listAtMarker(String) - */ - @Named("Kernels:list") - @GET - @Path("/kernels") - @OAuthScopes(COMPUTE_READONLY_SCOPE) - @ResponseParser(ParseKernels.class) - @Fallback(EmptyIterableWithMarkerOnNotFoundOr404.class) - ListenableFuture> listAtMarker(@QueryParam("pageToken") @Nullable String marker); - - /** - * @see KernelApi#listAtMarker(String, org.jclouds.googlecompute.options.ListOptions) - */ - @Named("Kernels:list") - @GET - @Path("/kernels") - @OAuthScopes(COMPUTE_READONLY_SCOPE) - @ResponseParser(ParseKernels.class) - @Fallback(EmptyIterableWithMarkerOnNotFoundOr404.class) - ListenableFuture> listAtMarker(@QueryParam("pageToken") @Nullable String marker, - ListOptions listOptions); - - /** - * @see org.jclouds.googlecompute.features.KernelApi#list() - */ - @Named("Kernels:list") - @GET - @Path("/kernels") - @OAuthScopes(COMPUTE_READONLY_SCOPE) - @ResponseParser(ParseKernels.class) - @Transform(ParseKernels.ToPagedIterable.class) - @Fallback(EmptyPagedIterableOnNotFoundOr404.class) - ListenableFuture> list(); - - /** - * @see KernelApi#list(org.jclouds.googlecompute.options.ListOptions) - */ - @Named("Kernels:list") - @GET - @Path("/kernels") - @OAuthScopes(COMPUTE_READONLY_SCOPE) - @ResponseParser(ParseKernels.class) - @Transform(ParseKernels.ToPagedIterable.class) - @Fallback(EmptyPagedIterableOnNotFoundOr404.class) - ListenableFuture> list(ListOptions listOptions); - -} diff --git a/labs/google-compute/src/main/java/org/jclouds/googlecompute/features/MachineTypeApi.java b/labs/google-compute/src/main/java/org/jclouds/googlecompute/features/MachineTypeApi.java deleted file mode 100644 index fb34c09734..0000000000 --- a/labs/google-compute/src/main/java/org/jclouds/googlecompute/features/MachineTypeApi.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.googlecompute.features; - -import org.jclouds.collect.PagedIterable; -import org.jclouds.googlecompute.domain.ListPage; -import org.jclouds.googlecompute.domain.MachineType; -import org.jclouds.googlecompute.options.ListOptions; -import org.jclouds.javax.annotation.Nullable; - -/** - * Provides synchronous access to MachineTypes via their REST API. - *

- * - * @author David Alves - * @see - */ -public interface MachineTypeApi { - - /** - * Returns the specified machine type resource - * - * @param machineTypeName name of the machine type resource to return. - * @return If successful, this method returns a MachineType resource - */ - MachineType get(String machineTypeName); - - /** - * @see MachineTypeApi#listAtMarker(String, org.jclouds.googlecompute.options.ListOptions) - */ - ListPage listFirstPage(); - - /** - * @see MachineTypeApi#listAtMarker(String, org.jclouds.googlecompute.options.ListOptions) - */ - ListPage listAtMarker(@Nullable String marker); - - /** - * Retrieves the list of machine type resources available to the specified project. - * By default the list as a maximum size of 100, if no options are provided or ListOptions#getMaxResults() has not - * been set. - * - * - * @param marker marks the beginning of the next list page - * @param listOptions listing options - * @return a page of the list - * @see ListOptions - * @see org.jclouds.googlecompute.domain.ListPage - */ - ListPage listAtMarker(@Nullable String marker, ListOptions listOptions); - - /** - * @see MachineTypeApi#list(org.jclouds.googlecompute.options.ListOptions) - */ - PagedIterable list(); - - /** - * A paged version of MachineTypeApi#list() - * - * @return a Paged, Fluent Iterable that is able to fetch additional pages when required - * @see PagedIterable - * @see MachineTypeApi#listAtMarker(String, org.jclouds.googlecompute.options.ListOptions) - */ - PagedIterable list(ListOptions listOptions); - -} diff --git a/labs/google-compute/src/main/java/org/jclouds/googlecompute/features/MachineTypeAsyncApi.java b/labs/google-compute/src/main/java/org/jclouds/googlecompute/features/MachineTypeAsyncApi.java deleted file mode 100644 index 414a0a071e..0000000000 --- a/labs/google-compute/src/main/java/org/jclouds/googlecompute/features/MachineTypeAsyncApi.java +++ /dev/null @@ -1,129 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.googlecompute.features; - -import com.google.common.util.concurrent.ListenableFuture; -import org.jclouds.collect.PagedIterable; -import org.jclouds.googlecompute.domain.ListPage; -import org.jclouds.googlecompute.domain.MachineType; -import org.jclouds.googlecompute.functions.internal.ParseMachineTypes; -import org.jclouds.googlecompute.options.ListOptions; -import org.jclouds.javax.annotation.Nullable; -import org.jclouds.oauth.v2.config.OAuthScopes; -import org.jclouds.oauth.v2.filters.OAuthAuthenticator; -import org.jclouds.rest.annotations.Fallback; -import org.jclouds.rest.annotations.RequestFilters; -import org.jclouds.rest.annotations.ResponseParser; -import org.jclouds.rest.annotations.SkipEncoding; -import org.jclouds.rest.annotations.Transform; - -import javax.inject.Named; -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.MediaType; - -import static org.jclouds.Fallbacks.EmptyIterableWithMarkerOnNotFoundOr404; -import static org.jclouds.Fallbacks.EmptyPagedIterableOnNotFoundOr404; -import static org.jclouds.Fallbacks.NullOnNotFoundOr404; -import static org.jclouds.googlecompute.GoogleComputeConstants.COMPUTE_READONLY_SCOPE; - -/** - * Provides asynchronous access to MachineTypes via their REST API. - * - * @author David Alves - * @see MachineTypeApi - */ -@SkipEncoding({'/', '='}) -@RequestFilters(OAuthAuthenticator.class) -@Consumes(MediaType.APPLICATION_JSON) -public interface MachineTypeAsyncApi { - - /** - * @see MachineTypeApi#get(String) - */ - @Named("MachineTypes:get") - @GET - @Path("/machineTypes/{machineType}") - @OAuthScopes(COMPUTE_READONLY_SCOPE) - @Fallback(NullOnNotFoundOr404.class) - ListenableFuture get(@PathParam("machineType") String machineTypeName); - - /** - * @see MachineTypeApi#listFirstPage() - */ - @Named("MachineTypes:list") - @GET - @Path("/machineTypes") - @OAuthScopes(COMPUTE_READONLY_SCOPE) - @ResponseParser(ParseMachineTypes.class) - @Fallback(EmptyIterableWithMarkerOnNotFoundOr404.class) - ListenableFuture> listFirstPage(); - - /** - * @see MachineTypeApi#listAtMarker(String) - */ - @Named("MachineTypes:list") - @GET - @Path("/machineTypes") - @OAuthScopes(COMPUTE_READONLY_SCOPE) - @ResponseParser(ParseMachineTypes.class) - @Fallback(EmptyIterableWithMarkerOnNotFoundOr404.class) - ListenableFuture> listAtMarker(@QueryParam("pageToken") @Nullable String marker); - - /** - * @see MachineTypeApi#listAtMarker(String, org.jclouds.googlecompute.options.ListOptions) - */ - @Named("MachineTypes:list") - @GET - @Path("/machineTypes") - @OAuthScopes(COMPUTE_READONLY_SCOPE) - @ResponseParser(ParseMachineTypes.class) - @Fallback(EmptyIterableWithMarkerOnNotFoundOr404.class) - ListenableFuture> listAtMarker(@QueryParam("pageToken") @Nullable String marker, - ListOptions listOptions); - - /** - * @see org.jclouds.googlecompute.features.MachineTypeApi#list() - */ - @Named("MachineTypes:list") - @GET - @Path("/machineTypes") - @OAuthScopes(COMPUTE_READONLY_SCOPE) - @ResponseParser(ParseMachineTypes.class) - @Transform(ParseMachineTypes.ToPagedIterable.class) - @Fallback(EmptyPagedIterableOnNotFoundOr404.class) - ListenableFuture> list(); - - /** - * @see MachineTypeApi#list(org.jclouds.googlecompute.options.ListOptions) - */ - @Named("MachineTypes:list") - @GET - @Path("/machineTypes") - @OAuthScopes(COMPUTE_READONLY_SCOPE) - @ResponseParser(ParseMachineTypes.class) - @Transform(ParseMachineTypes.ToPagedIterable.class) - @Fallback(EmptyPagedIterableOnNotFoundOr404.class) - ListenableFuture> list(ListOptions listOptions); - -} diff --git a/labs/google-compute/src/main/java/org/jclouds/googlecompute/features/NetworkApi.java b/labs/google-compute/src/main/java/org/jclouds/googlecompute/features/NetworkApi.java deleted file mode 100644 index c1d717c842..0000000000 --- a/labs/google-compute/src/main/java/org/jclouds/googlecompute/features/NetworkApi.java +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.googlecompute.features; - -import org.jclouds.collect.PagedIterable; -import org.jclouds.googlecompute.domain.ListPage; -import org.jclouds.googlecompute.domain.Network; -import org.jclouds.googlecompute.domain.Operation; -import org.jclouds.googlecompute.options.ListOptions; -import org.jclouds.javax.annotation.Nullable; - -/** - * Provides synchronous access to Networks via their REST API. - * - * @author David Alves - * @see NetworkAsyncApi - * @see - */ -public interface NetworkApi { - - /** - * Returns the specified persistent network resource. - * - * @param networkName name of the persistent network resource to return. - * @return a Network resource. - */ - Network get(String networkName); - - /** - * Creates a persistent network resource in the specified project with the specified range. - * - * @param networkName the network name - * @param IPv4Range the range of the network to be inserted. - * @return an Operation resource. To check on the status of an operation, poll the Operations resource returned to - * you, and look for the status field. - */ - Operation createInIPv4Range(String networkName, String IPv4Range); - - /** - * Creates a persistent network resource in the specified project with the specified range and specified gateway. - * - * @param networkName the network name - * @param IPv4Range the range of the network to be inserted. - * @param gatewayIPv4 the range of the network to be inserted. - * @return an Operation resource. To check on the status of an operation, poll the Operations resource returned to - * you, and look for the status field. - */ - Operation createInIPv4RangeWithGateway(String networkName, String IPv4Range, String gatewayIPv4); - - /** - * Deletes the specified persistent network resource. - * - * @param networkName name of the persistent network resource to delete. - * @return an Operation resource. To check on the status of an operation, poll the Operations resource returned to - * you, and look for the status field. - */ - Operation delete(String networkName); - - /** - * @see NetworkApi#listAtMarker(String, org.jclouds.googlecompute.options.ListOptions) - */ - ListPage listFirstPage(); - - /** - * @see NetworkApi#listAtMarker(String, org.jclouds.googlecompute.options.ListOptions) - */ - ListPage listAtMarker(@Nullable String marker); - - /** - * Retrieves the list of persistent network resources contained within the specified project. - * By default the list as a maximum size of 100, if no options are provided or ListOptions#getMaxResults() has not - * been set. - * - * - * @param marker marks the beginning of the next list page - * @param listOptions listing options - * @return a page of the list - * @see ListOptions - * @see org.jclouds.googlecompute.domain.ListPage - */ - ListPage listAtMarker(@Nullable String marker, ListOptions listOptions); - - /** - * @see NetworkApi#list(org.jclouds.googlecompute.options.ListOptions) - */ - PagedIterable list(); - - /** - * A paged version of NetworkApi#list() - * - * @return a Paged, Fluent Iterable that is able to fetch additional pages when required - * @see PagedIterable - * @see NetworkApi#listAtMarker(String, org.jclouds.googlecompute.options.ListOptions) - */ - PagedIterable list(@Nullable ListOptions listOptions); -} diff --git a/labs/google-compute/src/main/java/org/jclouds/googlecompute/features/NetworkAsyncApi.java b/labs/google-compute/src/main/java/org/jclouds/googlecompute/features/NetworkAsyncApi.java deleted file mode 100644 index baa2624daa..0000000000 --- a/labs/google-compute/src/main/java/org/jclouds/googlecompute/features/NetworkAsyncApi.java +++ /dev/null @@ -1,179 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.googlecompute.features; - -import com.google.common.util.concurrent.ListenableFuture; -import org.jclouds.collect.PagedIterable; -import org.jclouds.googlecompute.domain.ListPage; -import org.jclouds.googlecompute.domain.Network; -import org.jclouds.googlecompute.domain.Operation; -import org.jclouds.googlecompute.functions.internal.ParseNetworks; -import org.jclouds.googlecompute.options.ListOptions; -import org.jclouds.javax.annotation.Nullable; -import org.jclouds.oauth.v2.config.OAuthScopes; -import org.jclouds.oauth.v2.filters.OAuthAuthenticator; -import org.jclouds.rest.annotations.Fallback; -import org.jclouds.rest.annotations.MapBinder; -import org.jclouds.rest.annotations.PayloadParam; -import org.jclouds.rest.annotations.RequestFilters; -import org.jclouds.rest.annotations.ResponseParser; -import org.jclouds.rest.annotations.SkipEncoding; -import org.jclouds.rest.annotations.Transform; -import org.jclouds.rest.binders.BindToJsonPayload; - -import javax.inject.Named; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.MediaType; - -import static org.jclouds.Fallbacks.EmptyIterableWithMarkerOnNotFoundOr404; -import static org.jclouds.Fallbacks.EmptyPagedIterableOnNotFoundOr404; -import static org.jclouds.Fallbacks.NullOnNotFoundOr404; -import static org.jclouds.googlecompute.GoogleComputeConstants.COMPUTE_READONLY_SCOPE; -import static org.jclouds.googlecompute.GoogleComputeConstants.COMPUTE_SCOPE; - -/** - * Provides asynchronous access to Networks via their REST API. - * - * @author David Alves - * @see NetworkApi - */ -@SkipEncoding({'/', '='}) -@RequestFilters(OAuthAuthenticator.class) -public interface NetworkAsyncApi { - - /** - * @see NetworkApi#get(String) - */ - @Named("Networks:get") - @GET - @Consumes(MediaType.APPLICATION_JSON) - @Path("/networks/{network}") - @OAuthScopes(COMPUTE_READONLY_SCOPE) - @Fallback(NullOnNotFoundOr404.class) - ListenableFuture get(@PathParam("network") String networkName); - - /** - * @see NetworkApi#createInIPv4Range(String, String) - */ - @Named("Networks:insert") - @POST - @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.APPLICATION_JSON) - @Path("/networks") - @OAuthScopes({COMPUTE_SCOPE}) - @MapBinder(BindToJsonPayload.class) - ListenableFuture createInIPv4Range(@PayloadParam("name") String networkName, - @PayloadParam("IPv4Range") String IPv4Range); - - /** - * @see NetworkApi#createInIPv4RangeWithGateway(String, String, String) - */ - @Named("Networks:insert") - @POST - @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.APPLICATION_JSON) - @Path("/networks") - @OAuthScopes({COMPUTE_SCOPE}) - @MapBinder(BindToJsonPayload.class) - ListenableFuture createInIPv4RangeWithGateway(@PayloadParam("name") String networkName, - @PayloadParam("IPv4Range") String IPv4Range, - @PayloadParam("gatewayIPv4") String gatewayIPv4); - - /** - * @see NetworkApi#delete(String) - */ - @Named("Networks:delete") - @DELETE - @Consumes(MediaType.APPLICATION_JSON) - @Path("/networks/{network}") - @OAuthScopes(COMPUTE_SCOPE) - @Fallback(NullOnNotFoundOr404.class) - ListenableFuture delete(@PathParam("network") String networkName); - - /** - * @see NetworkApi#listFirstPage() - */ - @Named("Networks:list") - @GET - @Consumes(MediaType.APPLICATION_JSON) - @Path("/networks") - @OAuthScopes(COMPUTE_READONLY_SCOPE) - @ResponseParser(ParseNetworks.class) - @Fallback(EmptyIterableWithMarkerOnNotFoundOr404.class) - ListenableFuture> listFirstPage(); - - /** - * @see NetworkApi#listAtMarker(String) - */ - @Named("Networks:list") - @GET - @Consumes(MediaType.APPLICATION_JSON) - @Path("/networks") - @OAuthScopes(COMPUTE_READONLY_SCOPE) - @ResponseParser(ParseNetworks.class) - @Fallback(EmptyIterableWithMarkerOnNotFoundOr404.class) - ListenableFuture> listAtMarker(@QueryParam("pageToken") @Nullable String marker); - - /** - * @see NetworkApi#listAtMarker(String, org.jclouds.googlecompute.options.ListOptions) - */ - @Named("Networks:list") - @GET - @Consumes(MediaType.APPLICATION_JSON) - @Path("/networks") - @OAuthScopes(COMPUTE_READONLY_SCOPE) - @ResponseParser(ParseNetworks.class) - @Fallback(EmptyIterableWithMarkerOnNotFoundOr404.class) - ListenableFuture> listAtMarker(@QueryParam("pageToken") @Nullable String marker, - ListOptions options); - - /** - * @see NetworkApi#list() - */ - @Named("Networks:list") - @GET - @Consumes(MediaType.APPLICATION_JSON) - @Path("/networks") - @OAuthScopes(COMPUTE_READONLY_SCOPE) - @ResponseParser(ParseNetworks.class) - @Transform(ParseNetworks.ToPagedIterable.class) - @Fallback(EmptyPagedIterableOnNotFoundOr404.class) - ListenableFuture> list(); - - /** - * @see NetworkApi#list(org.jclouds.googlecompute.options.ListOptions) - */ - @Named("Networks:list") - @GET - @Consumes(MediaType.APPLICATION_JSON) - @Path("/networks") - @OAuthScopes(COMPUTE_READONLY_SCOPE) - @ResponseParser(ParseNetworks.class) - @Transform(ParseNetworks.ToPagedIterable.class) - @Fallback(EmptyPagedIterableOnNotFoundOr404.class) - ListenableFuture> list(ListOptions options); -} diff --git a/labs/google-compute/src/main/java/org/jclouds/googlecompute/features/OperationApi.java b/labs/google-compute/src/main/java/org/jclouds/googlecompute/features/OperationApi.java deleted file mode 100644 index 5de9758585..0000000000 --- a/labs/google-compute/src/main/java/org/jclouds/googlecompute/features/OperationApi.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.googlecompute.features; - -import org.jclouds.collect.PagedIterable; -import org.jclouds.googlecompute.domain.ListPage; -import org.jclouds.googlecompute.domain.Operation; -import org.jclouds.googlecompute.options.ListOptions; -import org.jclouds.javax.annotation.Nullable; - -/** - * Provides synchronous access to Operations via their REST API. - *

- * - * @author David Alves - * @see - */ -public interface OperationApi { - - /** - * Retrieves the specified operation resource. - * - * @param operationName name of the operation resource to return. - * @return If successful, this method returns an Operation resource - */ - public Operation get(String operationName); - - /** - * Deletes the specified operation resource. - * - * @param operationName name of the operation resource to delete. - */ - public void delete(String operationName); - - /** - * @see OperationApi#listAtMarker(String, org.jclouds.googlecompute.options.ListOptions) - */ - public ListPage listFirstPage(); - - /** - * @see OperationApi#listAtMarker(String, org.jclouds.googlecompute.options.ListOptions) - */ - public ListPage listAtMarker(@Nullable String marker); - - /** - * Retrieves the listFirstPage of operation resources contained within the specified project. - * By default the listFirstPage as a maximum size of 100, if no options are provided or ListOptions#getMaxResults() - * has not been set. - * - * @param marker marks the beginning of the next list page - * @param listOptions listing options - * @return a page of the list, starting at marker - * @see ListOptions - * @see org.jclouds.googlecompute.domain.ListPage - */ - public ListPage listAtMarker(@Nullable String marker, ListOptions listOptions); - - - /** - * @see OperationApi#list(org.jclouds.googlecompute.options.ListOptions) - */ - public PagedIterable list(); - - /** - * A paged version of OperationApi#listFirstPage() - * - * @return a Paged, Fluent Iterable that is able to fetch additional pages when required - * @see PagedIterable - * @see OperationApi#listAtMarker(String, org.jclouds.googlecompute.options.ListOptions) - */ - public PagedIterable list(ListOptions listOptions); -} diff --git a/labs/google-compute/src/main/java/org/jclouds/googlecompute/features/OperationAsyncApi.java b/labs/google-compute/src/main/java/org/jclouds/googlecompute/features/OperationAsyncApi.java deleted file mode 100644 index 94a295f1f7..0000000000 --- a/labs/google-compute/src/main/java/org/jclouds/googlecompute/features/OperationAsyncApi.java +++ /dev/null @@ -1,146 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.googlecompute.features; - -import com.google.common.util.concurrent.ListenableFuture; -import org.jclouds.collect.PagedIterable; -import org.jclouds.googlecompute.domain.ListPage; -import org.jclouds.googlecompute.domain.Operation; -import org.jclouds.googlecompute.functions.internal.ParseOperations; -import org.jclouds.googlecompute.options.ListOptions; -import org.jclouds.javax.annotation.Nullable; -import org.jclouds.oauth.v2.config.OAuthScopes; -import org.jclouds.oauth.v2.filters.OAuthAuthenticator; -import org.jclouds.rest.annotations.Fallback; -import org.jclouds.rest.annotations.RequestFilters; -import org.jclouds.rest.annotations.ResponseParser; -import org.jclouds.rest.annotations.SkipEncoding; -import org.jclouds.rest.annotations.Transform; - -import javax.inject.Named; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.MediaType; - -import static org.jclouds.Fallbacks.EmptyIterableWithMarkerOnNotFoundOr404; -import static org.jclouds.Fallbacks.EmptyPagedIterableOnNotFoundOr404; -import static org.jclouds.Fallbacks.NullOnNotFoundOr404; -import static org.jclouds.googlecompute.GoogleComputeConstants.COMPUTE_READONLY_SCOPE; -import static org.jclouds.googlecompute.GoogleComputeConstants.COMPUTE_SCOPE; - -/** - * Provides asynchronous access to Operations via their REST API. - * - * @author David Alves - * @see OperationApi - */ -@SkipEncoding({'/', '='}) -@RequestFilters(OAuthAuthenticator.class) -public interface OperationAsyncApi { - - /** - * @see OperationApi#get(String) - */ - @Named("Operations:get") - @GET - @Path("/operations/{operation}") - @OAuthScopes(COMPUTE_READONLY_SCOPE) - @Consumes(MediaType.APPLICATION_JSON) - @Fallback(NullOnNotFoundOr404.class) - ListenableFuture get(@PathParam("operation") String operationName); - - /** - * @see OperationApi#delete(String) - */ - @Named("Operations:delete") - @DELETE - @Path("/operations/{operation}") - @OAuthScopes(COMPUTE_SCOPE) - @Fallback(NullOnNotFoundOr404.class) - ListenableFuture delete(@PathParam("operation") String operationName); - - /** - * @see OperationApi#listFirstPage() - */ - @Named("Operations:list") - @GET - @Path("/operations") - @OAuthScopes(COMPUTE_READONLY_SCOPE) - @Consumes(MediaType.APPLICATION_JSON) - @ResponseParser(ParseOperations.class) - @Fallback(EmptyIterableWithMarkerOnNotFoundOr404.class) - ListenableFuture> listFirstPage(); - - /** - * @see OperationApi#listAtMarker(String) - */ - @Named("Operations:list") - @GET - @Path("/operations") - @OAuthScopes(COMPUTE_READONLY_SCOPE) - @Consumes(MediaType.APPLICATION_JSON) - @ResponseParser(ParseOperations.class) - @Fallback(EmptyIterableWithMarkerOnNotFoundOr404.class) - ListenableFuture> listAtMarker(@QueryParam("pageToken") @Nullable String marker); - - /** - * @see OperationApi#listAtMarker(String, org.jclouds.googlecompute.options.ListOptions) - */ - @Named("Operations:list") - @GET - @Path("/operations") - @OAuthScopes(COMPUTE_READONLY_SCOPE) - @Consumes(MediaType.APPLICATION_JSON) - @ResponseParser(ParseOperations.class) - @Fallback(EmptyIterableWithMarkerOnNotFoundOr404.class) - ListenableFuture> listAtMarker(@QueryParam("pageToken") @Nullable String marker, - ListOptions listOptions); - - /** - * @see OperationApi#list() - */ - @Named("Operations:list") - @GET - @Path("/operations") - @OAuthScopes(COMPUTE_READONLY_SCOPE) - @Consumes(MediaType.APPLICATION_JSON) - @ResponseParser(ParseOperations.class) - @Transform(ParseOperations.ToPagedIterable.class) - @Fallback(EmptyPagedIterableOnNotFoundOr404.class) - ListenableFuture> list(); - - /** - * @see OperationApi#list(org.jclouds.googlecompute.options.ListOptions) - */ - @Named("Operations:list") - @GET - @Path("/operations") - @OAuthScopes(COMPUTE_READONLY_SCOPE) - @Consumes(MediaType.APPLICATION_JSON) - @ResponseParser(ParseOperations.class) - @Transform(ParseOperations.ToPagedIterable.class) - @Fallback(EmptyPagedIterableOnNotFoundOr404.class) - ListenableFuture> list(ListOptions listOptions); - -} diff --git a/labs/google-compute/src/main/java/org/jclouds/googlecompute/features/ProjectApi.java b/labs/google-compute/src/main/java/org/jclouds/googlecompute/features/ProjectApi.java deleted file mode 100644 index e5369462f4..0000000000 --- a/labs/google-compute/src/main/java/org/jclouds/googlecompute/features/ProjectApi.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.googlecompute.features; - -import org.jclouds.googlecompute.domain.Operation; -import org.jclouds.googlecompute.domain.Project; - -import java.util.Map; -/** - * Provides synchronous access to Projects via their REST API. - *

- * - * @author David Alves - * @see ProjectAsyncApi - * @see - */ -public interface ProjectApi { - - /** - * Returns the specified project resource. - * - * @param projectName name of the project to return - * @return if successful, this method returns a Project resource - */ - Project get(String projectName); - - /** - * Sets metadata common to all instances within the specified project using the data included in the request. - *

- * NOTE: This *sets* metadata items on the project (vs *adding* items to metadata), - * if there are pre-existing metadata items that must be kept these must be fetched first and then re-set on the - * new Metadata, e.g. - *


-    *    Metadata.Builder current = projectApi.get("myProject").getCommonInstanceMetadata().toBuilder();
-    *    current.addItem("newItem","newItemValue");
-    *    projectApi.setCommonInstanceMetadata(current.build());
-    * 
- * - * @param projectName name of the project to return - * @param commonInstanceMetadata the metadata to set - * @return an Operations resource. To check on the status of an operation, poll the Operations resource returned - * to you, and look for the status field. - */ - Operation setCommonInstanceMetadata(String projectName, Map commonInstanceMetadata); - -} diff --git a/labs/google-compute/src/main/java/org/jclouds/googlecompute/features/ProjectAsyncApi.java b/labs/google-compute/src/main/java/org/jclouds/googlecompute/features/ProjectAsyncApi.java deleted file mode 100644 index 7b219a54de..0000000000 --- a/labs/google-compute/src/main/java/org/jclouds/googlecompute/features/ProjectAsyncApi.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.googlecompute.features; - -import com.google.common.util.concurrent.ListenableFuture; -import org.jclouds.googlecompute.domain.Operation; -import org.jclouds.googlecompute.domain.Project; -import org.jclouds.googlecompute.handlers.MetadataBinder; -import org.jclouds.oauth.v2.config.OAuthScopes; -import org.jclouds.oauth.v2.filters.OAuthAuthenticator; -import org.jclouds.rest.annotations.BinderParam; -import org.jclouds.rest.annotations.Fallback; -import org.jclouds.rest.annotations.RequestFilters; -import org.jclouds.rest.annotations.SkipEncoding; - -import javax.inject.Named; -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.core.MediaType; -import java.util.Map; - -import static org.jclouds.Fallbacks.NullOnNotFoundOr404; -import static org.jclouds.googlecompute.GoogleComputeConstants.COMPUTE_READONLY_SCOPE; -import static org.jclouds.googlecompute.GoogleComputeConstants.COMPUTE_SCOPE; - -/** - * Provides asynchronous access to Projects via their REST API. - * - * @author David Alves - * @see ProjectApi - */ -@SkipEncoding({'/', '='}) -@RequestFilters(OAuthAuthenticator.class) -public interface ProjectAsyncApi { - - - /** - * @see ProjectApi#get(String) - */ - @Named("Projects:get") - @GET - @OAuthScopes(COMPUTE_READONLY_SCOPE) - @Consumes(MediaType.APPLICATION_JSON) - @Fallback(NullOnNotFoundOr404.class) - @Path("/projects/{project}") - ListenableFuture get(@PathParam("project") String projectName); - - /** - * @see ProjectApi#setCommonInstanceMetadata(String, java.util.Map) - */ - @Named("Projects:setCommonInstanceMetadata") - @POST - @Path("/projects/{project}/setCommonInstanceMetadata") - @OAuthScopes(COMPUTE_SCOPE) - @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.APPLICATION_JSON) - ListenableFuture setCommonInstanceMetadata(@PathParam("project") String projectName, - @BinderParam(MetadataBinder.class) - Map commonInstanceMetadata); -} diff --git a/labs/google-compute/src/main/java/org/jclouds/googlecompute/features/ZoneApi.java b/labs/google-compute/src/main/java/org/jclouds/googlecompute/features/ZoneApi.java deleted file mode 100644 index f02e5b3821..0000000000 --- a/labs/google-compute/src/main/java/org/jclouds/googlecompute/features/ZoneApi.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.googlecompute.features; - -import org.jclouds.collect.PagedIterable; -import org.jclouds.googlecompute.domain.ListPage; -import org.jclouds.googlecompute.domain.Zone; -import org.jclouds.googlecompute.options.ListOptions; -import org.jclouds.javax.annotation.Nullable; - -/** - * Provides synchronous access to Zones via their REST API. - *

- * - * @author David Alves - * @see - */ -public interface ZoneApi { - - /** - * Returns the specified zone resource - * - * @param zoneName name of the zone resource to return. - * @return If successful, this method returns a Zone resource - */ - Zone get(String zoneName); - - /** - * @see ZoneApi#listAtMarker(String, org.jclouds.googlecompute.options.ListOptions) - */ - ListPage listFirstPage(); - - /** - * @see ZoneApi#listAtMarker(String, org.jclouds.googlecompute.options.ListOptions) - */ - ListPage listAtMarker(@Nullable String marker); - - /** - * Retrieves the listFirstPage of zone resources available to the specified project. - * By default the listFirstPage as a maximum size of 100, if no options are provided or ListOptions#getMaxResults() - * has not been set. - * - * @param marker marks the beginning of the next list page - * @param listOptions listing options - * @return a page of the listFirstPage - * @see ListOptions - * @see ListPage - */ - ListPage listAtMarker(@Nullable String marker, ListOptions listOptions); - - /** - * @see ZoneApi#list(org.jclouds.googlecompute.options.ListOptions) - */ - PagedIterable list(); - - /** - * A paged version of ZoneApi#listFirstPage() - * - * @return a Paged, Fluent Iterable that is able to fetch additional pages when required - * @see ZoneApi#listAtMarker(String, org.jclouds.googlecompute.options.ListOptions) - * @see PagedIterable - */ - PagedIterable list(ListOptions listOptions); - -} diff --git a/labs/google-compute/src/main/java/org/jclouds/googlecompute/features/ZoneAsyncApi.java b/labs/google-compute/src/main/java/org/jclouds/googlecompute/features/ZoneAsyncApi.java deleted file mode 100644 index 7ca4b70334..0000000000 --- a/labs/google-compute/src/main/java/org/jclouds/googlecompute/features/ZoneAsyncApi.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.googlecompute.features; - -import com.google.common.util.concurrent.ListenableFuture; -import org.jclouds.collect.PagedIterable; -import org.jclouds.googlecompute.domain.ListPage; -import org.jclouds.googlecompute.domain.Zone; -import org.jclouds.googlecompute.functions.internal.ParseZones; -import org.jclouds.googlecompute.options.ListOptions; -import org.jclouds.oauth.v2.config.OAuthScopes; -import org.jclouds.oauth.v2.filters.OAuthAuthenticator; -import org.jclouds.rest.annotations.Fallback; -import org.jclouds.rest.annotations.RequestFilters; -import org.jclouds.rest.annotations.ResponseParser; -import org.jclouds.rest.annotations.SkipEncoding; -import org.jclouds.rest.annotations.Transform; - -import javax.inject.Named; -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.core.MediaType; - -import static org.jclouds.Fallbacks.EmptyIterableWithMarkerOnNotFoundOr404; -import static org.jclouds.Fallbacks.EmptyPagedIterableOnNotFoundOr404; -import static org.jclouds.Fallbacks.NullOnNotFoundOr404; -import static org.jclouds.googlecompute.GoogleComputeConstants.COMPUTE_READONLY_SCOPE; - -/** - * Provides asynchronous access to Zones via their REST API. - * - * @author David Alves - * @see ZoneApi - */ -@SkipEncoding({'/', '='}) -@RequestFilters(OAuthAuthenticator.class) -@Consumes(MediaType.APPLICATION_JSON) -public interface ZoneAsyncApi { - - /** - * @see ZoneApi#get(String) - */ - @Named("Zones:get") - @GET - @Path("/zones/{zone}") - @OAuthScopes(COMPUTE_READONLY_SCOPE) - @Fallback(NullOnNotFoundOr404.class) - ListenableFuture get(@PathParam("zone") String zoneName); - - /** - * @see ZoneApi#listFirstPage() - */ - @Named("Zones:list") - @GET - @Path("/zones") - @OAuthScopes(COMPUTE_READONLY_SCOPE) - @ResponseParser(ParseZones.class) - @Fallback(EmptyIterableWithMarkerOnNotFoundOr404.class) - ListenableFuture> listFirstPage(); - - /** - * @see ZoneApi#listAtMarker(String) - */ - @Named("Zones:list") - @GET - @Path("/zones") - @OAuthScopes(COMPUTE_READONLY_SCOPE) - @ResponseParser(ParseZones.class) - @Fallback(EmptyIterableWithMarkerOnNotFoundOr404.class) - ListenableFuture> listAtMarker(String marker); - - /** - * @see ZoneApi#listAtMarker(String, org.jclouds.googlecompute.options.ListOptions) - */ - @Named("Zones:list") - @GET - @Path("/zones") - @OAuthScopes(COMPUTE_READONLY_SCOPE) - @ResponseParser(ParseZones.class) - @Fallback(EmptyIterableWithMarkerOnNotFoundOr404.class) - ListenableFuture> listAtMarker(String marker, ListOptions listOptions); - - /** - * @see ZoneApi#list() - */ - @Named("Zones:list") - @GET - @Path("/zones") - @OAuthScopes(COMPUTE_READONLY_SCOPE) - @ResponseParser(ParseZones.class) - @Transform(ParseZones.ToPagedIterable.class) - @Fallback(EmptyPagedIterableOnNotFoundOr404.class) - ListenableFuture> list(); - - /** - * @see ZoneApi#list(org.jclouds.googlecompute.options.ListOptions) - */ - @Named("Zones:list") - @GET - @Path("/zones") - @OAuthScopes(COMPUTE_READONLY_SCOPE) - @ResponseParser(ParseZones.class) - @Transform(ParseZones.ToPagedIterable.class) - @Fallback(EmptyPagedIterableOnNotFoundOr404.class) - ListenableFuture> list(ListOptions listOptions); -} diff --git a/labs/google-compute/src/main/java/org/jclouds/googlecompute/functions/internal/BaseToPagedIterable.java b/labs/google-compute/src/main/java/org/jclouds/googlecompute/functions/internal/BaseToPagedIterable.java deleted file mode 100644 index d151ab2580..0000000000 --- a/labs/google-compute/src/main/java/org/jclouds/googlecompute/functions/internal/BaseToPagedIterable.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.googlecompute.functions.internal; - -import com.google.common.annotations.Beta; -import com.google.common.base.Function; -import com.google.common.base.Optional; -import org.jclouds.collect.IterableWithMarker; -import org.jclouds.collect.PagedIterable; -import org.jclouds.collect.PagedIterables; -import org.jclouds.googlecompute.domain.ListPage; -import org.jclouds.googlecompute.options.ListOptions; -import org.jclouds.http.HttpRequest; -import org.jclouds.rest.InvocationContext; -import org.jclouds.rest.internal.GeneratedHttpRequest; - -import static com.google.common.base.Predicates.instanceOf; -import static com.google.common.collect.Iterables.tryFind; - -/** - * @author Adrian Cole - */ -@Beta -public abstract class BaseToPagedIterable> implements - Function, PagedIterable>, InvocationContext { - - private GeneratedHttpRequest request; - - @Override - public PagedIterable apply(ListPage input) { - if (input.nextMarker() == null) - return PagedIterables.of(input); - - Optional project = tryFind(request.getCaller().get().getArgs(), instanceOf(String.class)); - - Optional listOptions = tryFind(request.getInvocation().getArgs(), instanceOf(ListOptions.class)); - - assert project.isPresent() : String.format("programming error, method %s should have a string param for the " - + "project", request.getCaller().get().getInvokable()); - - return PagedIterables.advance( - input, fetchNextPage(project.get().toString(), (ListOptions) listOptions.orNull())); - } - - protected abstract Function> fetchNextPage(String projectName, - ListOptions listOptions); - - @SuppressWarnings("unchecked") - @Override - public I setContext(HttpRequest request) { - this.request = GeneratedHttpRequest.class.cast(request); - return (I) this; - } -} diff --git a/labs/google-compute/src/main/java/org/jclouds/googlecompute/functions/internal/PATCH.java b/labs/google-compute/src/main/java/org/jclouds/googlecompute/functions/internal/PATCH.java deleted file mode 100644 index c638377c9c..0000000000 --- a/labs/google-compute/src/main/java/org/jclouds/googlecompute/functions/internal/PATCH.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.googlecompute.functions.internal; - -import javax.ws.rs.HttpMethod; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Indicates that the annotated method responds to HTTP PATCH requests - * - * @author David Alves - * @see javax.ws.rs.HttpMethod - */ -@Target({ElementType.METHOD}) -@Retention(RetentionPolicy.RUNTIME) -@HttpMethod("PATCH") -public @interface PATCH { -} diff --git a/labs/google-compute/src/main/java/org/jclouds/googlecompute/functions/internal/ParseDisks.java b/labs/google-compute/src/main/java/org/jclouds/googlecompute/functions/internal/ParseDisks.java deleted file mode 100644 index 05719d8801..0000000000 --- a/labs/google-compute/src/main/java/org/jclouds/googlecompute/functions/internal/ParseDisks.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.googlecompute.functions.internal; - -import com.google.common.base.Function; -import com.google.inject.TypeLiteral; -import org.jclouds.collect.IterableWithMarker; -import org.jclouds.googlecompute.GoogleComputeApi; -import org.jclouds.googlecompute.domain.Disk; -import org.jclouds.googlecompute.domain.ListPage; -import org.jclouds.googlecompute.options.ListOptions; -import org.jclouds.http.functions.ParseJson; -import org.jclouds.json.Json; - -import javax.inject.Inject; -import javax.inject.Singleton; - -import static com.google.common.base.Preconditions.checkNotNull; - -/** - * @author David Alves - */ -@Singleton -public class ParseDisks extends ParseJson> { - - @Inject - public ParseDisks(Json json) { - super(json, new TypeLiteral>() {}); - } - - public static class ToPagedIterable extends BaseToPagedIterable { - - private final GoogleComputeApi api; - - @Inject - protected ToPagedIterable(GoogleComputeApi api) { - this.api = checkNotNull(api, "api"); - } - - @Override - protected Function> fetchNextPage(final String projectName, - final ListOptions options) { - return new Function>() { - - @Override - public IterableWithMarker apply(Object input) { - return api.getDiskApiForProject(projectName).listAtMarker(input.toString(), options); - } - }; - } - } -} diff --git a/labs/google-compute/src/main/java/org/jclouds/googlecompute/functions/internal/ParseFirewalls.java b/labs/google-compute/src/main/java/org/jclouds/googlecompute/functions/internal/ParseFirewalls.java deleted file mode 100644 index 3f980ff9bf..0000000000 --- a/labs/google-compute/src/main/java/org/jclouds/googlecompute/functions/internal/ParseFirewalls.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.googlecompute.functions.internal; - -import com.google.common.base.Function; -import com.google.inject.TypeLiteral; -import org.jclouds.collect.IterableWithMarker; -import org.jclouds.googlecompute.GoogleComputeApi; -import org.jclouds.googlecompute.domain.Firewall; -import org.jclouds.googlecompute.domain.ListPage; -import org.jclouds.googlecompute.options.ListOptions; -import org.jclouds.http.functions.ParseJson; -import org.jclouds.json.Json; - -import javax.inject.Inject; - -import static com.google.common.base.Preconditions.checkNotNull; - -/** - * @author David Alves - */ -public class ParseFirewalls extends ParseJson> { - - @Inject - public ParseFirewalls(Json json) { - super(json, new TypeLiteral>() {}); - } - - public static class ToPagedIterable extends BaseToPagedIterable { - - private final GoogleComputeApi api; - - @Inject - protected ToPagedIterable(GoogleComputeApi api) { - this.api = checkNotNull(api, "api"); - } - - @Override - protected Function> fetchNextPage(final String projectName, - final ListOptions options) { - return new Function>() { - - @Override - public IterableWithMarker apply(Object input) { - return api.getFirewallApiForProject(projectName).listAtMarker(input.toString(), options); - } - }; - } - } -} diff --git a/labs/google-compute/src/main/java/org/jclouds/googlecompute/functions/internal/ParseImages.java b/labs/google-compute/src/main/java/org/jclouds/googlecompute/functions/internal/ParseImages.java deleted file mode 100644 index 54f54be0ba..0000000000 --- a/labs/google-compute/src/main/java/org/jclouds/googlecompute/functions/internal/ParseImages.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.googlecompute.functions.internal; - -import com.google.common.base.Function; -import com.google.inject.TypeLiteral; -import org.jclouds.collect.IterableWithMarker; -import org.jclouds.googlecompute.GoogleComputeApi; -import org.jclouds.googlecompute.domain.Image; -import org.jclouds.googlecompute.domain.ListPage; -import org.jclouds.googlecompute.options.ListOptions; -import org.jclouds.http.functions.ParseJson; -import org.jclouds.json.Json; - -import javax.inject.Inject; - -import static com.google.common.base.Preconditions.checkNotNull; - -/** - * @author David Alves - */ -public class ParseImages extends ParseJson> { - - @Inject - public ParseImages(Json json) { - super(json, new TypeLiteral>() {}); - } - - public static class ToPagedIterable extends BaseToPagedIterable { - - private final GoogleComputeApi api; - - @Inject - protected ToPagedIterable(GoogleComputeApi api) { - this.api = checkNotNull(api, "api"); - } - - @Override - protected Function> fetchNextPage(final String projectName, - final ListOptions options) { - return new Function>() { - - @Override - public IterableWithMarker apply(Object input) { - return api.getImageApiForProject(projectName).listAtMarker(input.toString(), options); - } - }; - } - } -} diff --git a/labs/google-compute/src/main/java/org/jclouds/googlecompute/functions/internal/ParseInstances.java b/labs/google-compute/src/main/java/org/jclouds/googlecompute/functions/internal/ParseInstances.java deleted file mode 100644 index 176b55a07d..0000000000 --- a/labs/google-compute/src/main/java/org/jclouds/googlecompute/functions/internal/ParseInstances.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.googlecompute.functions.internal; - -import com.google.common.base.Function; -import com.google.inject.TypeLiteral; -import org.jclouds.collect.IterableWithMarker; -import org.jclouds.googlecompute.GoogleComputeApi; -import org.jclouds.googlecompute.domain.Instance; -import org.jclouds.googlecompute.domain.ListPage; -import org.jclouds.googlecompute.options.ListOptions; -import org.jclouds.http.functions.ParseJson; -import org.jclouds.json.Json; - -import javax.inject.Inject; - -import static com.google.common.base.Preconditions.checkNotNull; - -/** - * @author David Alves - */ -public class ParseInstances extends ParseJson> { - - @Inject - public ParseInstances(Json json) { - super(json, new TypeLiteral>() {}); - } - - public static class ToPagedIterable extends BaseToPagedIterable { - - private final GoogleComputeApi api; - - @Inject - protected ToPagedIterable(GoogleComputeApi api) { - this.api = checkNotNull(api, "api"); - } - - @Override - protected Function> fetchNextPage(final String projectName, - final ListOptions options) { - return new Function>() { - - @Override - public IterableWithMarker apply(Object input) { - return api.getInstanceApiForProject(projectName).listAtMarker(input.toString(), options); - } - }; - } - } -} diff --git a/labs/google-compute/src/main/java/org/jclouds/googlecompute/functions/internal/ParseKernels.java b/labs/google-compute/src/main/java/org/jclouds/googlecompute/functions/internal/ParseKernels.java deleted file mode 100644 index e9f9d7c7e2..0000000000 --- a/labs/google-compute/src/main/java/org/jclouds/googlecompute/functions/internal/ParseKernels.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.googlecompute.functions.internal; - -import com.google.common.base.Function; -import com.google.inject.TypeLiteral; -import org.jclouds.collect.IterableWithMarker; -import org.jclouds.googlecompute.GoogleComputeApi; -import org.jclouds.googlecompute.domain.Kernel; -import org.jclouds.googlecompute.domain.ListPage; -import org.jclouds.googlecompute.options.ListOptions; -import org.jclouds.http.functions.ParseJson; -import org.jclouds.json.Json; - -import javax.inject.Inject; - -import static com.google.common.base.Preconditions.checkNotNull; - -/** - * @author David Alves - */ -public class ParseKernels extends ParseJson> { - - @Inject - public ParseKernels(Json json) { - super(json, new TypeLiteral>() {}); - } - - public static class ToPagedIterable extends BaseToPagedIterable { - - private final GoogleComputeApi api; - - @Inject - protected ToPagedIterable(GoogleComputeApi api) { - this.api = checkNotNull(api, "api"); - } - - @Override - protected Function> fetchNextPage(final String projectName, - final ListOptions options) { - return new Function>() { - - @Override - public IterableWithMarker apply(Object input) { - return api.getKernelApiForProject(projectName).listAtMarker(input.toString(), options); - } - }; - } - } -} diff --git a/labs/google-compute/src/main/java/org/jclouds/googlecompute/functions/internal/ParseMachineTypes.java b/labs/google-compute/src/main/java/org/jclouds/googlecompute/functions/internal/ParseMachineTypes.java deleted file mode 100644 index 596d28ad30..0000000000 --- a/labs/google-compute/src/main/java/org/jclouds/googlecompute/functions/internal/ParseMachineTypes.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.googlecompute.functions.internal; - -import com.google.common.base.Function; -import com.google.inject.TypeLiteral; -import org.jclouds.collect.IterableWithMarker; -import org.jclouds.googlecompute.GoogleComputeApi; -import org.jclouds.googlecompute.domain.ListPage; -import org.jclouds.googlecompute.domain.MachineType; -import org.jclouds.googlecompute.options.ListOptions; -import org.jclouds.http.functions.ParseJson; -import org.jclouds.json.Json; - -import javax.inject.Inject; - -import static com.google.common.base.Preconditions.checkNotNull; - -/** - * @author David Alves - */ -public class ParseMachineTypes extends ParseJson> { - - @Inject - public ParseMachineTypes(Json json) { - super(json, new TypeLiteral>() {}); - } - - public static class ToPagedIterable extends BaseToPagedIterable { - - private final GoogleComputeApi api; - - @Inject - protected ToPagedIterable(GoogleComputeApi api) { - this.api = checkNotNull(api, "api"); - } - - @Override - protected Function> fetchNextPage(final String projectName, - final ListOptions options) { - return new Function>() { - - @Override - public IterableWithMarker apply(Object input) { - return api.getMachineTypeApiForProject(projectName).listAtMarker(input.toString(), options); - } - }; - } - } -} diff --git a/labs/google-compute/src/main/java/org/jclouds/googlecompute/functions/internal/ParseNetworks.java b/labs/google-compute/src/main/java/org/jclouds/googlecompute/functions/internal/ParseNetworks.java deleted file mode 100644 index 1261826ad5..0000000000 --- a/labs/google-compute/src/main/java/org/jclouds/googlecompute/functions/internal/ParseNetworks.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.googlecompute.functions.internal; - -import com.google.common.base.Function; -import com.google.inject.TypeLiteral; -import org.jclouds.collect.IterableWithMarker; -import org.jclouds.googlecompute.GoogleComputeApi; -import org.jclouds.googlecompute.domain.ListPage; -import org.jclouds.googlecompute.domain.Network; -import org.jclouds.googlecompute.options.ListOptions; -import org.jclouds.http.functions.ParseJson; -import org.jclouds.json.Json; - -import javax.inject.Inject; - -import static com.google.common.base.Preconditions.checkNotNull; - -/** - * @author David Alves - */ -public class ParseNetworks extends ParseJson> { - - @Inject - public ParseNetworks(Json json) { - super(json, new TypeLiteral>() {}); - } - - public static class ToPagedIterable extends BaseToPagedIterable { - - private final GoogleComputeApi api; - - @Inject - protected ToPagedIterable(GoogleComputeApi api) { - this.api = checkNotNull(api, "api"); - } - - @Override - protected Function> fetchNextPage(final String projectName, - final ListOptions options) { - return new Function>() { - - @Override - public IterableWithMarker apply(Object input) { - return api.getNetworkApiForProject(projectName).listAtMarker(input.toString(), options); - } - }; - } - } -} diff --git a/labs/google-compute/src/main/java/org/jclouds/googlecompute/functions/internal/ParseOperations.java b/labs/google-compute/src/main/java/org/jclouds/googlecompute/functions/internal/ParseOperations.java deleted file mode 100644 index e940096825..0000000000 --- a/labs/google-compute/src/main/java/org/jclouds/googlecompute/functions/internal/ParseOperations.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.googlecompute.functions.internal; - -import com.google.common.base.Function; -import com.google.inject.TypeLiteral; -import org.jclouds.collect.IterableWithMarker; -import org.jclouds.googlecompute.GoogleComputeApi; -import org.jclouds.googlecompute.domain.ListPage; -import org.jclouds.googlecompute.domain.Operation; -import org.jclouds.googlecompute.options.ListOptions; -import org.jclouds.http.functions.ParseJson; -import org.jclouds.json.Json; - -import javax.inject.Inject; - -import static com.google.common.base.Preconditions.checkNotNull; - -/** - * @author David Alves - */ -public class ParseOperations extends ParseJson> { - - @Inject - public ParseOperations(Json json) { - super(json, new TypeLiteral>() {}); - } - - public static class ToPagedIterable extends BaseToPagedIterable { - - private final GoogleComputeApi api; - - @Inject - protected ToPagedIterable(GoogleComputeApi api) { - this.api = checkNotNull(api, "api"); - } - - @Override - protected Function> fetchNextPage(final String projectName, - final ListOptions options) { - return new Function>() { - - @Override - public IterableWithMarker apply(Object input) { - return api.getOperationApiForProject(projectName).listAtMarker(input.toString(), options); - } - }; - } - } -} diff --git a/labs/google-compute/src/main/java/org/jclouds/googlecompute/functions/internal/ParseZones.java b/labs/google-compute/src/main/java/org/jclouds/googlecompute/functions/internal/ParseZones.java deleted file mode 100644 index 43a217fb28..0000000000 --- a/labs/google-compute/src/main/java/org/jclouds/googlecompute/functions/internal/ParseZones.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.googlecompute.functions.internal; - -import com.google.common.base.Function; -import com.google.inject.TypeLiteral; -import org.jclouds.collect.IterableWithMarker; -import org.jclouds.googlecompute.GoogleComputeApi; -import org.jclouds.googlecompute.domain.ListPage; -import org.jclouds.googlecompute.domain.Zone; -import org.jclouds.googlecompute.options.ListOptions; -import org.jclouds.http.functions.ParseJson; -import org.jclouds.json.Json; - -import javax.inject.Inject; - -import static com.google.common.base.Preconditions.checkNotNull; - -/** - * @author David Alves - */ -public class ParseZones extends ParseJson> { - - @Inject - public ParseZones(Json json) { - super(json, new TypeLiteral>() {}); - } - - public static class ToPagedIterable extends BaseToPagedIterable { - - private final GoogleComputeApi api; - - @Inject - protected ToPagedIterable(GoogleComputeApi api) { - this.api = checkNotNull(api, "api"); - } - - @Override - protected Function> fetchNextPage(final String projectName, - final ListOptions options) { - return new Function>() { - - @Override - public IterableWithMarker apply(Object input) { - return api.getZoneApiForProject(projectName).listAtMarker(input.toString(), options); - } - }; - } - } -} diff --git a/labs/google-compute/src/main/java/org/jclouds/googlecompute/handlers/FirewallBinder.java b/labs/google-compute/src/main/java/org/jclouds/googlecompute/handlers/FirewallBinder.java deleted file mode 100644 index 38538fb936..0000000000 --- a/labs/google-compute/src/main/java/org/jclouds/googlecompute/handlers/FirewallBinder.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.googlecompute.handlers; - -import org.jclouds.googlecompute.options.FirewallOptions; -import org.jclouds.http.HttpRequest; -import org.jclouds.rest.MapBinder; -import org.jclouds.rest.binders.BindToJsonPayload; - -import javax.inject.Inject; -import java.net.URI; -import java.util.Map; - -import static com.google.common.base.Preconditions.checkNotNull; - -/** - * @author David Alves - */ -public class FirewallBinder implements MapBinder { - - @Inject - private BindToJsonPayload jsonBinder; - - /** - * {@inheritDoc} - */ - @Override - public R bindToRequest(R request, Map postParams) { - FirewallOptions options = (FirewallOptions) checkNotNull(postParams.get("options"), "firewallOptions"); - String name = (String) checkNotNull(postParams.get("name"), "name"); - URI network = (URI) checkNotNull(postParams.get("network"), "network"); - options.name(name); - options.network(network); - return bindToRequest(request, options); - } - - /** - * {@inheritDoc} - */ - @Override - public R bindToRequest(R request, Object input) { - return jsonBinder.bindToRequest(request, input); - } -} \ No newline at end of file diff --git a/labs/google-compute/src/main/java/org/jclouds/googlecompute/handlers/GoogleComputeErrorHandler.java b/labs/google-compute/src/main/java/org/jclouds/googlecompute/handlers/GoogleComputeErrorHandler.java deleted file mode 100644 index 108751d11d..0000000000 --- a/labs/google-compute/src/main/java/org/jclouds/googlecompute/handlers/GoogleComputeErrorHandler.java +++ /dev/null @@ -1,66 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.googlecompute.handlers; - -import org.jclouds.http.HttpCommand; -import org.jclouds.http.HttpErrorHandler; -import org.jclouds.http.HttpResponse; -import org.jclouds.http.HttpResponseException; -import org.jclouds.rest.AuthorizationException; -import org.jclouds.rest.ResourceNotFoundException; - -import javax.inject.Singleton; - -import static org.jclouds.http.HttpUtils.closeClientButKeepContentStream; - -/** - * This will parse and set an appropriate exception on the command object. - * - * @author Adrian Cole - */ -@Singleton -public class GoogleComputeErrorHandler implements HttpErrorHandler { - public void handleError(HttpCommand command, HttpResponse response) { - // it is important to always read fully and close streams - byte[] data = closeClientButKeepContentStream(response); - String message = data != null ? new String(data) : null; - - Exception exception = message != null ? new HttpResponseException(command, response, message) - : new HttpResponseException(command, response); - message = message != null ? message : String.format("%s -> %s", command.getCurrentRequest().getRequestLine(), - response.getStatusLine()); - switch (response.getStatusCode()) { - case 400: - break; - case 401: - case 403: - exception = new AuthorizationException(message, exception); - break; - case 404: - if (!command.getCurrentRequest().getMethod().equals("DELETE")) { - exception = new ResourceNotFoundException(message, exception); - } - break; - case 409: - exception = new IllegalStateException(message, exception); - break; - } - command.setException(exception); - } -} diff --git a/labs/google-compute/src/main/java/org/jclouds/googlecompute/handlers/InstanceBinder.java b/labs/google-compute/src/main/java/org/jclouds/googlecompute/handlers/InstanceBinder.java deleted file mode 100644 index 561df96395..0000000000 --- a/labs/google-compute/src/main/java/org/jclouds/googlecompute/handlers/InstanceBinder.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.googlecompute.handlers; - -import com.google.common.base.Function; -import org.jclouds.googlecompute.domain.InstanceTemplate; -import org.jclouds.http.HttpRequest; -import org.jclouds.rest.MapBinder; -import org.jclouds.rest.binders.BindToJsonPayload; - -import javax.inject.Inject; -import javax.inject.Named; -import java.net.URI; -import java.util.Map; -import java.util.Set; - -import static com.google.common.base.Preconditions.checkNotNull; -import static org.jclouds.googlecompute.domain.InstanceTemplate.NetworkInterface; - -/** - * @author David Alves - */ -public class InstanceBinder implements MapBinder { - - @Inject - private BindToJsonPayload jsonBinder; - - @Inject - @Named("machineTypes") - Function machineTypesToURI; - - @Inject - @Named("zones") - Function zonesToURI; - - /** - * {@inheritDoc} - */ - @Override - public R bindToRequest(R request, Map postParams) { - InstanceTemplate template = (InstanceTemplate) checkNotNull(postParams.get("template"), "template"); - template.name(checkNotNull(postParams.get("name"), "name").toString()); - template.zone(zonesToURI.apply((String) checkNotNull(postParams.get("zone"), "zone"))); - - if (template.getMachineTypeName() != null) { - template.machineType(machineTypesToURI.apply(template.getMachineTypeName())); - } - template.zone((String) null); - template.machineType((String) null); - return bindToRequest(request, template); - } - - /** - * {@inheritDoc} - */ - @Override - public R bindToRequest(R request, Object input) { - return jsonBinder.bindToRequest(request, input); - } -} diff --git a/labs/google-compute/src/main/java/org/jclouds/googlecompute/handlers/MetadataBinder.java b/labs/google-compute/src/main/java/org/jclouds/googlecompute/handlers/MetadataBinder.java deleted file mode 100644 index 79a7e96e79..0000000000 --- a/labs/google-compute/src/main/java/org/jclouds/googlecompute/handlers/MetadataBinder.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.googlecompute.handlers; - -import org.jclouds.googlecompute.config.GoogleComputeParserModule; -import org.jclouds.http.HttpRequest; -import org.jclouds.rest.Binder; -import org.jclouds.rest.binders.BindToJsonPayload; - -import javax.inject.Inject; -import java.util.Map; - -import static com.google.common.base.Preconditions.checkNotNull; - -/** - * @author David Alves - */ -public class MetadataBinder implements Binder { - - @Inject - private BindToJsonPayload jsonBinder; - - @Override - @SuppressWarnings("unchecked") - public R bindToRequest(R request, Object input) { - Map metadataEntries = (Map) checkNotNull(input, "input metadata"); - return jsonBinder.bindToRequest(request, new GoogleComputeParserModule.Metadata(metadataEntries)); - } -} diff --git a/labs/google-compute/src/main/java/org/jclouds/googlecompute/options/FirewallOptions.java b/labs/google-compute/src/main/java/org/jclouds/googlecompute/options/FirewallOptions.java deleted file mode 100644 index 46a9bd08d8..0000000000 --- a/labs/google-compute/src/main/java/org/jclouds/googlecompute/options/FirewallOptions.java +++ /dev/null @@ -1,168 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.googlecompute.options; - -import com.google.common.collect.ImmutableSet; -import org.jclouds.googlecompute.domain.Firewall; - -import java.net.URI; -import java.util.Set; - -/** - * Options to create a firewall. - * - * @see Firewall - * @author David Alves - */ -public class FirewallOptions { - - private String name; - private URI network; - private ImmutableSet.Builder sourceRanges = ImmutableSet.builder(); - private ImmutableSet.Builder sourceTags = ImmutableSet.builder(); - private ImmutableSet.Builder targetTags = ImmutableSet.builder(); - private ImmutableSet.Builder allowed = ImmutableSet.builder(); - - /** - * @see org.jclouds.googlecompute.domain.Firewall#getAllowed() - */ - public Set getAllowed() { - return allowed.build(); - } - - /** - * @see org.jclouds.googlecompute.domain.Firewall#getAllowed() - */ - public FirewallOptions addAllowedRule(Firewall.Rule allowedRule) { - this.allowed.add(allowedRule); - return this; - } - - /** - * @see org.jclouds.googlecompute.domain.Firewall#getAllowed() - */ - public FirewallOptions allowedRules(Set allowedRules) { - this.allowed = ImmutableSet.builder(); - this.allowed.addAll(allowedRules); - return this; - } - - /** - * @see org.jclouds.googlecompute.domain.Firewall#getName() - */ - public FirewallOptions name(String name) { - this.name = name; - return this; - } - - /** - * @see org.jclouds.googlecompute.domain.Firewall#getName() - */ - public String getName() { - return name; - } - - /** - * @see org.jclouds.googlecompute.domain.Firewall#getNetwork() - */ - public FirewallOptions network(URI network) { - this.network = network; - return this; - } - - /** - * @see org.jclouds.googlecompute.domain.Firewall#getNetwork() - */ - public URI getNetwork() { - return network; - } - - /** - * @see org.jclouds.googlecompute.domain.Firewall#getSourceRanges() - */ - public Set getSourceRanges() { - return sourceRanges.build(); - } - - /** - * @see org.jclouds.googlecompute.domain.Firewall#getSourceRanges() - */ - public FirewallOptions addSourceRange(String sourceRange) { - this.sourceRanges.add(sourceRange); - return this; - } - - /** - * @see org.jclouds.googlecompute.domain.Firewall#getSourceRanges() - */ - public FirewallOptions sourceRanges(Set sourceRanges) { - this.sourceRanges = ImmutableSet.builder(); - this.sourceRanges.addAll(sourceRanges); - return this; - } - - /** - * @see org.jclouds.googlecompute.domain.Firewall#getSourceTags() - */ - public Set getSourceTags() { - return sourceTags.build(); - } - - /** - * @see org.jclouds.googlecompute.domain.Firewall#getSourceTags() - */ - public FirewallOptions addSourceTag(String sourceTag) { - this.sourceTags.add(sourceTag); - return this; - } - - /** - * @see org.jclouds.googlecompute.domain.Firewall#getSourceTags() - */ - public FirewallOptions sourceTags(Set sourceTags) { - this.sourceTags = ImmutableSet.builder(); - return this; - } - - /** - * @see org.jclouds.googlecompute.domain.Firewall#getTargetTags() - */ - public Set getTargetTags() { - return targetTags.build(); - } - - /** - * @see org.jclouds.googlecompute.domain.Firewall#getTargetTags() - */ - public FirewallOptions addTargetTag(String targetTag) { - this.targetTags.add(targetTag); - return this; - } - - /** - * @see org.jclouds.googlecompute.domain.Firewall#getTargetTags() - */ - public FirewallOptions targetTags(Set targetTags) { - this.targetTags = ImmutableSet.builder(); - this.targetTags.addAll(targetTags); - return this; - } - -} diff --git a/labs/google-compute/src/main/java/org/jclouds/googlecompute/options/ListOptions.java b/labs/google-compute/src/main/java/org/jclouds/googlecompute/options/ListOptions.java deleted file mode 100644 index 80e7b6d0f0..0000000000 --- a/labs/google-compute/src/main/java/org/jclouds/googlecompute/options/ListOptions.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.googlecompute.options; - -import org.jclouds.http.options.BaseHttpRequestOptions; - -import static com.google.common.base.Preconditions.checkNotNull; - -/** - * Allows to optionally specify a filter, max results and a page token for listFirstPage() REST methods. - * - * @author David Alves - * @see - */ -public class ListOptions extends BaseHttpRequestOptions { - - /** - * Optional. Filter expression for filtering listed resources, in the form filter={expression}. Your {expression} - * must contain the following: - *

- * {@code } - *

    - *
  • {@code }: The name of the field you want to compare. The field name must be valid for the - * type of resource being filtered. Only atomic field types are supported (string, number, - * boolean). Array and object fields are not currently supported.
  • - *
  • {@code }: The comparison string, either eq (equals) or ne (not equals).
  • - *
  • {@code }: The literal string value to filter to. The literal value must be valid - * for the type of field (string, number, boolean). For string fields, the literal value is interpreted as a - * regular expression using RE2 syntax. The literal value must match the entire field. For example, - * when filtering instances, name eq my_instance won't work, but name eq .*my_instance will work.
  • - *
- *

- * For example: - *

- * {@code filter=status ne RUNNING} - *

- * The above filter returns only results whose status field does not equal RUNNING. You can also enclose your - * literal string in single, double, or no quotes. For example, all three of the following would be valid - * expressions: - *

- * {@code filter=status ne "RUNNING"}
- * {@code filter=status ne 'RUNNING'}
- * {@code filter=status ne RUNNING}
- *

- * Complex regular expressions can also be used, like the following: - * {@code name eq '."my_instance_[0-9]+'} - */ - public ListOptions filter(String filter) { - this.queryParameters.put("filter", checkNotNull(filter, "filter")); - return this; - } - - /** - * Sets Maximum count of results to be returned. Maximum and default value is 100. Acceptable values are 0 to - * 100, inclusive. (Default: 100) - */ - public ListOptions maxResults(Integer maxResults) { - this.queryParameters.put("maxResults", checkNotNull(maxResults, "maxResults") + ""); - return this; - } - - public static class Builder { - - /** - * @see ListOptions#filter(String) - */ - public ListOptions filter(String filter) { - return new ListOptions().filter(filter); - } - - /** - * @see ListOptions#maxResults(Integer) - */ - public ListOptions maxResults(Integer maxResults) { - return new ListOptions().maxResults(maxResults); - } - } -} diff --git a/labs/google-compute/src/main/java/org/jclouds/googlecompute/predicates/OperationDonePredicate.java b/labs/google-compute/src/main/java/org/jclouds/googlecompute/predicates/OperationDonePredicate.java deleted file mode 100644 index 579ccf2b0a..0000000000 --- a/labs/google-compute/src/main/java/org/jclouds/googlecompute/predicates/OperationDonePredicate.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.googlecompute.predicates; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.concurrent.atomic.AtomicReference; - -import org.jclouds.googlecompute.GoogleComputeApi; -import org.jclouds.googlecompute.config.UserProject; -import org.jclouds.googlecompute.domain.Operation; - -import com.google.common.base.Predicate; -import com.google.common.base.Supplier; -import com.google.inject.Inject; - -/** - * Tests that an Operation is done, returning the completed Operation when it is. - * - * @author David Alves - */ -public class OperationDonePredicate implements Predicate> { - - private final GoogleComputeApi api; - private final Supplier project; - - @Inject - OperationDonePredicate(GoogleComputeApi api, @UserProject Supplier project) { - this.api = api; - this.project = project; - } - - @Override - public boolean apply(AtomicReference input) { - checkNotNull(input, "input"); - Operation current = api.getOperationApiForProject(project.get()).get(input.get().getName()); - switch (current.getStatus()) { - case DONE: - input.set(current); - return true; - case PENDING: - case RUNNING: - default: - return false; - } - } -} diff --git a/labs/google-compute/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata b/labs/google-compute/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata deleted file mode 100644 index 27ee158885..0000000000 --- a/labs/google-compute/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata +++ /dev/null @@ -1 +0,0 @@ -org.jclouds.googlecompute.GoogleComputeApiMetadata diff --git a/labs/google-compute/src/test/java/org/jclouds/googlecompute/GoogleComputeApiMetadataTest.java b/labs/google-compute/src/test/java/org/jclouds/googlecompute/GoogleComputeApiMetadataTest.java deleted file mode 100644 index f27cfb6690..0000000000 --- a/labs/google-compute/src/test/java/org/jclouds/googlecompute/GoogleComputeApiMetadataTest.java +++ /dev/null @@ -1,41 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.googlecompute; - -import com.google.common.collect.ImmutableSet; -import com.google.common.reflect.TypeToken; -import org.jclouds.View; -import org.jclouds.apis.internal.BaseApiMetadataTest; -import org.testng.annotations.Test; - -/** - * Tests that GoogleComputeApiMetadata is properly registered in ServiceLoader - *

- *

- * META-INF/services/org.jclouds.apis.ApiMetadata
- * 
- * - * @author Adrian Cole - */ -@Test(groups = "unit", testName = "GoogleComputeApiMetadataTest") -public class GoogleComputeApiMetadataTest extends BaseApiMetadataTest { - public GoogleComputeApiMetadataTest() { - super(new GoogleComputeApiMetadata(), ImmutableSet.>of()); - } -} diff --git a/labs/google-compute/src/test/java/org/jclouds/googlecompute/GoogleComputeAuthenticatedRestContextLiveTest.java b/labs/google-compute/src/test/java/org/jclouds/googlecompute/GoogleComputeAuthenticatedRestContextLiveTest.java deleted file mode 100644 index 09e5668dbb..0000000000 --- a/labs/google-compute/src/test/java/org/jclouds/googlecompute/GoogleComputeAuthenticatedRestContextLiveTest.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.googlecompute; - -import com.google.common.reflect.TypeToken; -import org.jclouds.oauth.v2.BaseOauthAuthenticatedRestContextLiveTest; -import org.jclouds.rest.RestContext; -import org.testng.annotations.Test; - -/** - * @author David Alves - */ -@Test(groups = "live") -public class GoogleComputeAuthenticatedRestContextLiveTest extends BaseOauthAuthenticatedRestContextLiveTest { - - - public GoogleComputeAuthenticatedRestContextLiveTest() { - provider = "google-compute"; - } - - @Override - public String getScopes() { - return GoogleComputeConstants.COMPUTE_SCOPE; - } - - - @Override - protected TypeToken> contextType() { - return GoogleComputeApiMetadata.CONTEXT_TOKEN; - } -} diff --git a/labs/google-compute/src/test/java/org/jclouds/googlecompute/PageSystemExpectTest.java b/labs/google-compute/src/test/java/org/jclouds/googlecompute/PageSystemExpectTest.java deleted file mode 100644 index b726310c06..0000000000 --- a/labs/google-compute/src/test/java/org/jclouds/googlecompute/PageSystemExpectTest.java +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.googlecompute; - -import org.jclouds.collect.IterableWithMarker; -import org.jclouds.collect.PagedIterable; -import org.jclouds.googlecompute.domain.Image; -import org.jclouds.googlecompute.features.ImageApi; -import org.jclouds.googlecompute.internal.BaseGoogleComputeApiExpectTest; -import org.jclouds.googlecompute.options.ListOptions; -import org.jclouds.http.HttpRequest; -import org.jclouds.http.HttpResponse; -import org.testng.annotations.Test; - -import static org.jclouds.googlecompute.GoogleComputeConstants.COMPUTE_READONLY_SCOPE; -import static org.testng.Assert.assertSame; - -/** - * A test specifically for the paging system. The code used is common to all list() methods so we're using Images - * but it could be anything else. - * - * @author David Alves - */ -@Test(groups = "unit") -public class PageSystemExpectTest extends BaseGoogleComputeApiExpectTest { - - public void testGetSinglePage() { - HttpRequest list = HttpRequest - .builder() - .method("GET") - .endpoint("https://www.googleapis" + - ".com/compute/v1beta13/projects/myproject/images") - .addHeader("Accept", "application/json") - .addHeader("Authorization", "Bearer " + TOKEN).build(); - - HttpResponse operationResponse = HttpResponse.builder().statusCode(200) - .payload(payloadFromResource("/image_list_single_page.json")).build(); - - ImageApi imageApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE), - TOKEN_RESPONSE, list, operationResponse).getImageApiForProject("myproject"); - - PagedIterable images = imageApi.list(); - - // expect one page - assertSame(images.size(), 1); - // with three images - assertSame(images.concat().size(), 3); - } - - public void testGetMultiplePages() { - HttpRequest list1 = HttpRequest - .builder() - .method("GET") - .endpoint("https://www.googleapis" + - ".com/compute/v1beta13/projects/myproject/images?maxResults=3") - .addHeader("Accept", "application/json") - .addHeader("Authorization", "Bearer " + TOKEN).build(); - - HttpRequest list2 = HttpRequest - .builder() - .method("GET") - .endpoint("https://www.googleapis" + - ".com/compute/v1beta13/projects/myproject/images?pageToken" + - "=CgVJTUFHRRIbZ29vZ2xlLmNlbnRvcy02LTItdjIwMTIwNjIx&maxResults=3") - .addHeader("Accept", "application/json") - .addHeader("Authorization", "Bearer " + TOKEN).build(); - - HttpRequest list3 = HttpRequest - .builder() - .method("GET") - .endpoint("https://www.googleapis" + - ".com/compute/v1beta13/projects/myproject/images?pageToken" + - "=CgVJTUFHRRIbZ29vZ2xlLmdjZWwtMTAtMDQtdjIwMTIxMTA2&maxResults=3") - .addHeader("Accept", "application/json") - .addHeader("Authorization", "Bearer " + TOKEN).build(); - - HttpResponse list1response = HttpResponse.builder().statusCode(200) - .payload(payloadFromResource("/image_list_multiple_page_1.json")).build(); - - HttpResponse list2Response = HttpResponse.builder().statusCode(200) - .payload(payloadFromResource("/image_list_multiple_page_2.json")).build(); - - HttpResponse list3Response = HttpResponse.builder().statusCode(200) - .payload(payloadFromResource("/image_list_single_page.json")).build(); - - - ImageApi imageApi = orderedRequestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE), - TOKEN_RESPONSE, list1, list1response, list2, list2Response, list3, list3Response) - .getImageApiForProject("myproject"); - - PagedIterable images = imageApi.list(new ListOptions.Builder().maxResults(3)); - - int imageCounter = 0; - for (IterableWithMarker page : images) { - for (Image image : page) { - imageCounter++; - } - } - assertSame(imageCounter, 9); - } - -} diff --git a/labs/google-compute/src/test/java/org/jclouds/googlecompute/compute/GoogleComputeServiceExpectTest.java b/labs/google-compute/src/test/java/org/jclouds/googlecompute/compute/GoogleComputeServiceExpectTest.java deleted file mode 100644 index 439f3c1651..0000000000 --- a/labs/google-compute/src/test/java/org/jclouds/googlecompute/compute/GoogleComputeServiceExpectTest.java +++ /dev/null @@ -1,415 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.googlecompute.compute; - -import com.google.common.base.Throwables; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; -import org.jclouds.compute.ComputeService; -import org.jclouds.compute.RunNodesException; -import org.jclouds.compute.domain.Template; -import org.jclouds.domain.Location; -import org.jclouds.googlecompute.compute.options.GoogleComputeTemplateOptions; -import org.jclouds.googlecompute.domain.Instance; -import org.jclouds.googlecompute.features.InstanceApiExpectTest; -import org.jclouds.googlecompute.internal.BaseGoogleComputeServiceExpectTest; -import org.jclouds.http.HttpRequest; -import org.jclouds.http.HttpResponse; -import org.jclouds.util.Strings2; -import org.testng.annotations.Test; - -import javax.ws.rs.core.MediaType; -import java.io.IOException; -import java.util.List; -import java.util.Properties; -import java.util.Set; - -import static com.google.common.collect.Iterables.getOnlyElement; -import static org.jclouds.googlecompute.GoogleComputeConstants.COMPUTE_READONLY_SCOPE; -import static org.jclouds.googlecompute.GoogleComputeConstants.COMPUTE_SCOPE; -import static org.jclouds.googlecompute.features.FirewallApiExpectTest.GET_FIREWALL_REQUEST; -import static org.jclouds.googlecompute.features.ImageApiExpectTest.LIST_PROJECT_IMAGES_REQUEST; -import static org.jclouds.googlecompute.features.ImageApiExpectTest.LIST_PROJECT_IMAGES_RESPONSE; -import static org.jclouds.googlecompute.features.InstanceApiExpectTest.LIST_INSTANCES_REQUEST; -import static org.jclouds.googlecompute.features.InstanceApiExpectTest.LIST_INSTANCES_RESPONSE; -import static org.jclouds.googlecompute.features.MachineTypeApiExpectTest.LIST_MACHINE_TYPES_REQUEST; -import static org.jclouds.googlecompute.features.MachineTypeApiExpectTest.LIST_MACHINE_TYPES_RESPONSE; -import static org.jclouds.googlecompute.features.NetworkApiExpectTest.GET_NETWORK_REQUEST; -import static org.jclouds.googlecompute.features.OperationApiExpectTest.GET_OPERATION_REQUEST; -import static org.jclouds.googlecompute.features.OperationApiExpectTest.GET_OPERATION_RESPONSE; -import static org.jclouds.googlecompute.features.ZoneApiExpectTest.LIST_ZONES_REQ; -import static org.jclouds.googlecompute.features.ZoneApiExpectTest.LIST_ZONES_RESPONSE; -import static org.jclouds.util.Strings2.toStringAndClose; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; - - -/** - * @author David Alves - */ -@Test(groups = "unit") -public class GoogleComputeServiceExpectTest extends BaseGoogleComputeServiceExpectTest { - - public static final HttpRequest LIST_GOOGLE_IMAGES_REQUEST = HttpRequest - .builder() - .method("GET") - .endpoint("https://www.googleapis.com/compute/v1beta13/projects/google/images") - .addHeader("Accept", "application/json") - .addHeader("Authorization", "Bearer " + TOKEN).build(); - - public static final HttpResponse LIST_GOOGLE_IMAGES_RESPONSE = HttpResponse.builder().statusCode(200) - .payload(staticPayloadFromResource("/image_list_single_page.json")).build(); - - private HttpRequest INSERT_NETWORK_REQUEST = HttpRequest - .builder() - .method("POST") - .endpoint("https://www.googleapis.com/compute/v1beta13/projects/myproject/networks") - .addHeader("Accept", "application/json") - .addHeader("Authorization", "Bearer " + TOKEN) - .payload(payloadFromStringWithContentType("{\"name\":\"jclouds-test\",\"IPv4Range\":\"10.0.0.0/8\"}", - MediaType.APPLICATION_JSON)) - .build(); - - private HttpRequest INSERT_FIREWALL_REQUEST = HttpRequest - .builder() - .method("POST") - .endpoint("https://www.googleapis.com/compute/v1beta13/projects/myproject/firewalls") - .addHeader("Accept", "application/json") - .addHeader("Authorization", "Bearer " + TOKEN) - .payload(payloadFromStringWithContentType("{\"name\":\"jclouds-test\",\"network\":\"https://www.googleapis" + - ".com/compute/v1beta13/projects/myproject/networks/jclouds-test\"," + - "\"sourceRanges\":[\"10.0.0.0/8\",\"0.0.0.0/0\"],\"allowed\":[{\"IPProtocol\":\"tcp\"," + - "\"ports\":[\"22\"]}," + - "{\"IPProtocol\":\"udp\",\"ports\":[\"22\"]}]}", - MediaType.APPLICATION_JSON)) - .build(); - - private HttpResponse GET_NETWORK_RESPONSE = HttpResponse.builder().statusCode(200) - .payload(payloadFromStringWithContentType("{\n" + - " \"kind\": \"compute#network\",\n" + - " \"id\": \"13024414170909937976\",\n" + - " \"creationTimestamp\": \"2012-10-24T20:13:19.967\",\n" + - " \"selfLink\": \"https://www.googleapis" + - ".com/compute/v1beta13/projects/myproject/networks/jclouds-test\",\n" + - " \"name\": \"jclouds-test\",\n" + - " \"description\": \"test network\",\n" + - " \"IPv4Range\": \"10.0.0.0/8\",\n" + - " \"gatewayIPv4\": \"10.0.0.1\"\n" + - "}", MediaType.APPLICATION_JSON)).build(); - - private HttpResponse SUCESSFULL_OPERATION_RESPONSE = HttpResponse.builder().statusCode(200) - .payload(payloadFromResource("/operation.json")).build(); - - - private HttpResponse getInstanceResponseForInstanceAndNetworkAndStatus(String instanceName, String networkName, - String status) throws - IOException { - return HttpResponse.builder().statusCode(200) - .payload(payloadFromStringWithContentType( - replaceInstanceNameNetworkAndStatusOnResource("/instance_get.json", - instanceName, networkName, status), - "application/json")).build(); - } - - private HttpResponse getListInstancesResponseForSingleInstanceAndNetworkAndStatus(String instanceName, - String networkName, - String status) { - return HttpResponse.builder().statusCode(200) - .payload(payloadFromStringWithContentType( - replaceInstanceNameNetworkAndStatusOnResource("/instance_list.json", - instanceName, networkName, status), - "application/json")).build(); - } - - private String replaceInstanceNameNetworkAndStatusOnResource(String resourceName, String instanceName, - String networkName, String status) { - try { - return Strings2.toStringAndClose(this.getClass().getResourceAsStream(resourceName)).replace("test-0", - instanceName).replace("default", networkName).replace("RUNNING", status); - } catch (IOException e) { - throw Throwables.propagate(e); - } - } - - private HttpRequest createInstanceRequestForInstance(String instanceName, String networkName, String publicKey) { - return HttpRequest - .builder() - .method("POST") - .endpoint("https://www.googleapis.com/compute/v1beta13/projects/myproject/instances") - .addHeader("Accept", "application/json") - .addHeader("Authorization", "Bearer " + TOKEN) - .payload(payloadFromStringWithContentType("{\"name\":\"" + instanceName + "\"," + - "\"machineType\":\"https://www.googleapis" + - ".com/compute/v1beta13/projects/myproject/machineTypes/n1-standard-1\"," + - "\"zone\":\"https://www.googleapis" + - ".com/compute/v1beta13/projects/myproject/zones/us-central1-a\"," + - "\"image\":\"https://www.googleapis" + - ".com/compute/v1beta13/projects/google/images/gcel-12-04-v20121106\"," + - "\"tags\":[],\"serviceAccounts\":[]," + - "\"networkInterfaces\":[{\"network\":\"https://www.googleapis" + - ".com/compute/v1beta13/projects/myproject/networks/" + networkName + "\"," + - "\"accessConfigs\":[{\"type\":\"ONE_TO_ONE_NAT\"}]}]," + - "\"metadata\":{\"kind\":\"compute#metadata\",\"items\":[{\"key\":\"sshKeys\"," + - "\"value\":\"jclouds:" + - publicKey + " jclouds@localhost\"}]}}", - MediaType.APPLICATION_JSON)).build(); - } - - private HttpRequest getInstanceRequestForInstance(String instanceName) { - return HttpRequest - .builder() - .method("GET") - .endpoint("https://www.googleapis" + - ".com/compute/v1beta13/projects/myproject/instances/" + instanceName) - .addHeader("Accept", "application/json") - .addHeader("Authorization", "Bearer " + TOKEN).build(); - } - - - @Override - protected Properties setupProperties() { - Properties overrides = super.setupProperties(); - overrides.put("google-compute.identity", "myproject"); - try { - overrides.put("google-compute.credential", toStringAndClose(getClass().getResourceAsStream("/testpk.pem"))); - } catch (IOException e) { - Throwables.propagate(e); - } - return overrides; - } - - @Test(enabled = false) - public void testThrowsAuthorizationException() throws Exception { - - Properties properties = new Properties(); - properties.setProperty("oauth.identity", "MOMMA"); - properties.setProperty("oauth.credential", "MiA"); - - ComputeService client = requestsSendResponses(ImmutableMap.of(), createModule(), - properties); - Template template = client.templateBuilder().build(); - Template toMatch = client.templateBuilder().imageId(template.getImage().getId()).build(); - assertEquals(toMatch.getImage(), template.getImage()); - } - - @Test - public void testTemplateMatch() throws Exception { - ImmutableMap requestResponseMap = ImmutableMap. - builder() - .put(requestForScopes(COMPUTE_READONLY_SCOPE), TOKEN_RESPONSE) - .put(LIST_ZONES_REQ, LIST_ZONES_RESPONSE) - .put(LIST_PROJECT_IMAGES_REQUEST, LIST_PROJECT_IMAGES_RESPONSE) - .put(LIST_GOOGLE_IMAGES_REQUEST, LIST_GOOGLE_IMAGES_RESPONSE) - .put(LIST_MACHINE_TYPES_REQUEST, LIST_MACHINE_TYPES_RESPONSE) - .build(); - - ComputeService client = requestsSendResponses(requestResponseMap); - Template template = client.templateBuilder().build(); - Template toMatch = client.templateBuilder().imageId(template.getImage().getId()).build(); - assertEquals(toMatch.getImage(), template.getImage()); - } - - @Test - public void testNetworksAndFirewallDeletedWhenAllGroupNodesAreTerminated() throws IOException { - - HttpRequest deleteNodeRequest = HttpRequest.builder() - .method("DELETE") - .endpoint("https://www.googleapis" + - ".com/compute/v1beta13/projects/myproject/instances/test-delete-networks") - .addHeader("Accept", "application/json") - .addHeader("Authorization", "Bearer " + TOKEN).build(); - - HttpRequest deleteFirewallRequest = HttpRequest.builder() - .method("DELETE") - .endpoint("https://www.googleapis" + - ".com/compute/v1beta13/projects/myproject/firewalls/jclouds-test-delete") - .addHeader("Accept", "application/json") - .addHeader("Authorization", "Bearer " + TOKEN).build(); - - HttpRequest deleteNetworkReqquest = HttpRequest.builder() - .method("DELETE") - .endpoint("https://www.googleapis" + - ".com/compute/v1beta13/projects/myproject/networks/jclouds-test-delete") - .addHeader("Accept", "application/json") - .addHeader("Authorization", "Bearer " + TOKEN).build(); - - List orderedRequests = ImmutableList.builder() - .add(requestForScopes(COMPUTE_READONLY_SCOPE)) - .add(getInstanceRequestForInstance("test-delete-networks")) - .add(LIST_PROJECT_IMAGES_REQUEST) - .add(LIST_GOOGLE_IMAGES_REQUEST) - .add(LIST_ZONES_REQ) - .add(LIST_MACHINE_TYPES_REQUEST) - .add(requestForScopes(COMPUTE_SCOPE)) - .add(deleteNodeRequest) - .add(GET_OPERATION_REQUEST) - .add(getInstanceRequestForInstance("test-delete-networks")) - .add(LIST_PROJECT_IMAGES_REQUEST) - .add(LIST_GOOGLE_IMAGES_REQUEST) - .add(LIST_ZONES_REQ) - .add(LIST_MACHINE_TYPES_REQUEST) - .add(LIST_INSTANCES_REQUEST) - .add(LIST_PROJECT_IMAGES_REQUEST) - .add(LIST_GOOGLE_IMAGES_REQUEST) - .add(LIST_ZONES_REQ) - .add(LIST_MACHINE_TYPES_REQUEST) - .add(deleteFirewallRequest) - .add(GET_OPERATION_REQUEST) - .add(deleteNetworkReqquest) - .add(GET_OPERATION_REQUEST) - .build(); - - - List orderedResponses = ImmutableList.builder() - .add(TOKEN_RESPONSE) - .add(getInstanceResponseForInstanceAndNetworkAndStatus("test-delete-networks", "test-network", Instance - .Status.RUNNING.name())) - .add(LIST_PROJECT_IMAGES_RESPONSE) - .add(LIST_GOOGLE_IMAGES_RESPONSE) - .add(LIST_ZONES_RESPONSE) - .add(LIST_MACHINE_TYPES_RESPONSE) - .add(TOKEN_RESPONSE) - .add(SUCESSFULL_OPERATION_RESPONSE) - .add(GET_OPERATION_RESPONSE) - .add(getInstanceResponseForInstanceAndNetworkAndStatus("test-delete-networks", "test-network", Instance - .Status.TERMINATED.name())) - .add(LIST_PROJECT_IMAGES_RESPONSE) - .add(LIST_GOOGLE_IMAGES_RESPONSE) - .add(LIST_ZONES_RESPONSE) - .add(LIST_MACHINE_TYPES_RESPONSE) - .add(getListInstancesResponseForSingleInstanceAndNetworkAndStatus("test-delete-networks", - "test-network", Instance - .Status.TERMINATED.name())) - .add(LIST_PROJECT_IMAGES_RESPONSE) - .add(LIST_GOOGLE_IMAGES_RESPONSE) - .add(LIST_ZONES_RESPONSE) - .add(LIST_MACHINE_TYPES_RESPONSE) - .add(SUCESSFULL_OPERATION_RESPONSE) - .add(GET_OPERATION_RESPONSE) - .add(SUCESSFULL_OPERATION_RESPONSE) - .add(GET_OPERATION_RESPONSE) - .build(); - - ComputeService client = orderedRequestsSendResponses(orderedRequests, orderedResponses); - client.destroyNode("test-delete-networks"); - - } - - public void testListLocationsWhenResponseIs2xx() throws Exception { - - ImmutableMap requestResponseMap = ImmutableMap. - builder() - .put(requestForScopes(COMPUTE_READONLY_SCOPE), TOKEN_RESPONSE) - .put(LIST_ZONES_REQ, LIST_ZONES_RESPONSE) - .put(LIST_INSTANCES_REQUEST, LIST_INSTANCES_RESPONSE) - .put(LIST_PROJECT_IMAGES_REQUEST, LIST_PROJECT_IMAGES_RESPONSE) - .put(LIST_GOOGLE_IMAGES_REQUEST, LIST_GOOGLE_IMAGES_RESPONSE) - .put(LIST_MACHINE_TYPES_REQUEST, LIST_MACHINE_TYPES_RESPONSE) - .build(); - - ComputeService apiWhenServersExist = requestsSendResponses(requestResponseMap); - - Set locations = apiWhenServersExist.listAssignableLocations(); - - assertNotNull(locations); - assertEquals(locations.size(), 2); - assertEquals(locations.iterator().next().getId(), "us-central1-a"); - - assertNotNull(apiWhenServersExist.listNodes()); - assertEquals(apiWhenServersExist.listNodes().size(), 1); - assertEquals(apiWhenServersExist.listNodes().iterator().next().getId(), "test-0"); - assertEquals(apiWhenServersExist.listNodes().iterator().next().getName(), "test-0"); - } - - @Test(dependsOnMethods = "testListLocationsWhenResponseIs2xx") - public void testCreateNodeWhenNetworkNorFirewallExistDoesNotExist() throws RunNodesException, IOException { - - - String payload = Strings2.toStringAndClose(InstanceApiExpectTest.class.getResourceAsStream("/instance_get.json")); - payload = payload.replace("test-0", "test-1"); - - HttpResponse getInstanceResponse = HttpResponse.builder().statusCode(200) - .payload(payloadFromStringWithContentType(payload, "application/json")).build(); - - List orderedRequests = ImmutableList.builder() - .add(requestForScopes(COMPUTE_READONLY_SCOPE)) - .add(LIST_ZONES_REQ) - .add(LIST_PROJECT_IMAGES_REQUEST) - .add(LIST_GOOGLE_IMAGES_REQUEST) - .add(LIST_MACHINE_TYPES_REQUEST) - .add(GET_NETWORK_REQUEST) - .add(requestForScopes(COMPUTE_SCOPE)) - .add(INSERT_NETWORK_REQUEST) - .add(GET_OPERATION_REQUEST) - .add(GET_NETWORK_REQUEST) - .add(GET_FIREWALL_REQUEST) - .add(INSERT_FIREWALL_REQUEST) - .add(GET_OPERATION_REQUEST) - .add(LIST_INSTANCES_REQUEST) - .add(LIST_PROJECT_IMAGES_REQUEST) - .add(LIST_GOOGLE_IMAGES_REQUEST) - .add(LIST_ZONES_REQ) - .add(LIST_MACHINE_TYPES_REQUEST) - .add(createInstanceRequestForInstance("test-1", "jclouds-test", openSshKey)) - .add(GET_OPERATION_REQUEST) - .add(getInstanceRequestForInstance("test-1")) - .add(LIST_PROJECT_IMAGES_REQUEST) - .add(LIST_GOOGLE_IMAGES_REQUEST) - .add(LIST_ZONES_REQ) - .add(LIST_MACHINE_TYPES_REQUEST) - .build(); - - List orderedResponses = ImmutableList.builder() - .add(TOKEN_RESPONSE) - .add(LIST_ZONES_RESPONSE) - .add(LIST_PROJECT_IMAGES_RESPONSE) - .add(LIST_GOOGLE_IMAGES_RESPONSE) - .add(LIST_MACHINE_TYPES_RESPONSE) - .add(HttpResponse.builder().statusCode(404).build()) - .add(TOKEN_RESPONSE) - .add(SUCESSFULL_OPERATION_RESPONSE) - .add(GET_OPERATION_RESPONSE) - .add(GET_NETWORK_RESPONSE) - .add(HttpResponse.builder().statusCode(404).build()) - .add(SUCESSFULL_OPERATION_RESPONSE) - .add(GET_OPERATION_RESPONSE) - .add(LIST_INSTANCES_RESPONSE) - .add(LIST_PROJECT_IMAGES_RESPONSE) - .add(LIST_GOOGLE_IMAGES_RESPONSE) - .add(LIST_ZONES_RESPONSE) - .add(LIST_MACHINE_TYPES_RESPONSE) - .add(SUCESSFULL_OPERATION_RESPONSE) - .add(GET_OPERATION_RESPONSE) - .add(getInstanceResponse) - .add(LIST_PROJECT_IMAGES_RESPONSE) - .add(LIST_GOOGLE_IMAGES_RESPONSE) - .add(LIST_ZONES_RESPONSE) - .add(LIST_MACHINE_TYPES_RESPONSE) - .build(); - - - ComputeService computeService = orderedRequestsSendResponses(orderedRequests, orderedResponses); - - GoogleComputeTemplateOptions options = computeService.templateOptions().as(GoogleComputeTemplateOptions.class); - - getOnlyElement(computeService.createNodesInGroup("test", 1, options)); - } -} - diff --git a/labs/google-compute/src/test/java/org/jclouds/googlecompute/compute/GoogleComputeServiceLiveTest.java b/labs/google-compute/src/test/java/org/jclouds/googlecompute/compute/GoogleComputeServiceLiveTest.java deleted file mode 100644 index d2a05c7f06..0000000000 --- a/labs/google-compute/src/test/java/org/jclouds/googlecompute/compute/GoogleComputeServiceLiveTest.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.googlecompute.compute; - -import com.google.common.collect.ImmutableMap; -import com.google.inject.Module; -import org.jclouds.compute.domain.NodeMetadata; -import org.jclouds.compute.internal.BaseComputeServiceLiveTest; -import org.jclouds.oauth.v2.OAuthTestUtils; -import org.jclouds.sshj.config.SshjSshClientModule; -import org.testng.annotations.Test; - -import java.util.Properties; - -import static org.testng.Assert.assertTrue; - -/** - * @author David Alves - */ -@Test(groups = "live", singleThreaded = true) -public class GoogleComputeServiceLiveTest extends BaseComputeServiceLiveTest { - - public GoogleComputeServiceLiveTest() { - provider = "google-compute"; - } - - /** - * Nodes may have additional metadata entries (particularly they may have an "sshKeys" entry) - */ - protected void checkUserMetadataInNodeEquals(NodeMetadata node, ImmutableMap userMetadata) { - assertTrue(node.getUserMetadata().keySet().containsAll(userMetadata.keySet())); - } - - // do not run until the auth exception problem is figured out. - @Test(enabled = false) - @Override - public void testCorrectAuthException() throws Exception { - } - - // reboot is not supported by GCE - @Test(enabled = true, dependsOnMethods = "testGet") - public void testReboot() throws Exception { - } - - // suspend/Resume is not supported by GCE - @Test(enabled = true, dependsOnMethods = "testReboot") - public void testSuspendResume() throws Exception { - } - - @Test(enabled = true, dependsOnMethods = "testSuspendResume") - @Override - public void testGetNodesWithDetails() throws Exception { - super.testGetNodesWithDetails(); - } - - @Test(enabled = true, dependsOnMethods = "testSuspendResume") - @Override - public void testListNodes() throws Exception { - super.testListNodes(); - } - - @Test(enabled = true, dependsOnMethods = {"testListNodes", "testGetNodesWithDetails"}) - @Override - public void testDestroyNodes() { - super.testDestroyNodes(); - } - - @Override - protected Module getSshModule() { - return new SshjSshClientModule(); - } - - @Override - protected Properties setupProperties() { - Properties properties = super.setupProperties(); - OAuthTestUtils.setCredentialFromPemFile(properties, "google-compute.credential"); - return properties; - } -} diff --git a/labs/google-compute/src/test/java/org/jclouds/googlecompute/compute/functions/GoogleComputeImageToImageTest.java b/labs/google-compute/src/test/java/org/jclouds/googlecompute/compute/functions/GoogleComputeImageToImageTest.java deleted file mode 100644 index 4803e35298..0000000000 --- a/labs/google-compute/src/test/java/org/jclouds/googlecompute/compute/functions/GoogleComputeImageToImageTest.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.googlecompute.compute.functions; - -import org.jclouds.compute.domain.OsFamily; -import org.jclouds.googlecompute.domain.Image; -import org.testng.annotations.Test; - -import java.net.URI; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertSame; - -/** - * @author David Alves - */ -@Test(groups = "unit") -public class GoogleComputeImageToImageTest { - - Image.Builder imageBuilder = Image.builder() - .id("1234") - .selfLink(URI.create("http://test.com")) - .sourceType("RAW") - .description("") - .rawDisk(Image.RawDisk.builder().source("").containerType("TAR").build()); - - public void testArbitratyImageName() { - GoogleComputeImageToImage imageToImage = new GoogleComputeImageToImage(); - Image image = imageBuilder.name("arbitratyname").build(); - org.jclouds.compute.domain.Image transformed = imageToImage.apply(image); - assertEquals(transformed.getName(), image.getName()); - assertEquals(transformed.getId(), image.getName()); - assertEquals(transformed.getProviderId(), image.getId()); - assertSame(transformed.getOperatingSystem().getFamily(), OsFamily.LINUX); - } - - public void testWellFormedImageName() { - GoogleComputeImageToImage imageToImage = new GoogleComputeImageToImage(); - Image image = imageBuilder.name("ubuntu-12-04-v123123").build(); - org.jclouds.compute.domain.Image transformed = imageToImage.apply(image); - assertEquals(transformed.getName(), image.getName()); - assertEquals(transformed.getId(), image.getName()); - assertEquals(transformed.getProviderId(), image.getId()); - assertSame(transformed.getOperatingSystem().getFamily(), OsFamily.UBUNTU); - assertEquals(transformed.getOperatingSystem().getVersion(), "12.04"); - } - - -} diff --git a/labs/google-compute/src/test/java/org/jclouds/googlecompute/compute/functions/OrphanedGroupsFromDeadNodesTest.java b/labs/google-compute/src/test/java/org/jclouds/googlecompute/compute/functions/OrphanedGroupsFromDeadNodesTest.java deleted file mode 100644 index 7cfea107e5..0000000000 --- a/labs/google-compute/src/test/java/org/jclouds/googlecompute/compute/functions/OrphanedGroupsFromDeadNodesTest.java +++ /dev/null @@ -1,141 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.googlecompute.compute.functions; - -import com.google.common.base.Predicate; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Sets; -import org.easymock.EasyMock; -import org.jclouds.compute.ComputeService; -import org.jclouds.compute.domain.ComputeMetadata; -import org.jclouds.compute.domain.NodeMetadata; -import org.jclouds.compute.domain.internal.NodeMetadataImpl; -import org.jclouds.googlecompute.compute.predicates.AllNodesInGroupTerminated; -import org.testng.annotations.Test; - -import java.util.Set; - -import static org.easymock.EasyMock.createMock; -import static org.easymock.EasyMock.expect; -import static org.easymock.EasyMock.replay; -import static org.testng.Assert.assertSame; -import static org.testng.Assert.assertTrue; - -/** - * @author David Alves - */ -public class OrphanedGroupsFromDeadNodesTest { - - private static class IdAndGroupOnlyNodeMetadata extends NodeMetadataImpl { - - public IdAndGroupOnlyNodeMetadata(String id, String group, Status status) { - super(null, null, id, null, null, ImmutableMap.of(), ImmutableSet.of(), group, null, - null, null, status, null, 0, ImmutableSet.of(), ImmutableSet.of(), null, null); - } - } - - - @Test - public void testDetectsAllOrphanedGroupsWhenAllNodesTerminated() { - - Set deadNodesGroup1 = (Set) ImmutableSet.builder() - .add(new IdAndGroupOnlyNodeMetadata("a", "1", NodeMetadata.Status.TERMINATED)).build(); - - Set deadNodesGroup2 = (Set) ImmutableSet.builder() - .add(new IdAndGroupOnlyNodeMetadata("b", "2", NodeMetadata.Status.TERMINATED)).build(); - - Set allDeadNodes = Sets.union(deadNodesGroup1, deadNodesGroup2); - - ComputeService mock = createMock(ComputeService.class); - expect(mock.listNodesDetailsMatching(EasyMock.>anyObject())) - .andReturn((Set) deadNodesGroup1).once(); - expect(mock.listNodesDetailsMatching(EasyMock.>anyObject())) - .andReturn((Set) deadNodesGroup2).once(); - - replay(mock); - - OrphanedGroupsFromDeadNodes orphanedGroupsFromDeadNodes = new OrphanedGroupsFromDeadNodes(new - AllNodesInGroupTerminated(mock)); - - Set orphanedGroups = orphanedGroupsFromDeadNodes.apply(allDeadNodes); - - assertSame(orphanedGroups.size(), 2); - assertTrue(orphanedGroups.contains("1")); - assertTrue(orphanedGroups.contains("2")); - } - - @Test - public void testDetectsAllOrphanedGroupsWhenSomeNodesTerminatedAndOtherMissing() { - - Set deadNodesGroup1 = (Set) ImmutableSet.builder() - .add(new IdAndGroupOnlyNodeMetadata("a", "1", NodeMetadata.Status.TERMINATED)).build(); - - Set deadNodesGroup2 = (Set) ImmutableSet.builder() - .add(new IdAndGroupOnlyNodeMetadata("b", "2", NodeMetadata.Status.TERMINATED)).build(); - - Set allDeadNodes = Sets.union(deadNodesGroup1, deadNodesGroup2); - - ComputeService mock = createMock(ComputeService.class); - expect(mock.listNodesDetailsMatching(EasyMock.>anyObject())) - .andReturn((Set) deadNodesGroup1).once(); - expect(mock.listNodesDetailsMatching(EasyMock.>anyObject())) - .andReturn((Set) ImmutableSet.of()).once(); - - replay(mock); - - OrphanedGroupsFromDeadNodes orphanedGroupsFromDeadNodes = new OrphanedGroupsFromDeadNodes(new - AllNodesInGroupTerminated(mock)); - - Set orphanedGroups = orphanedGroupsFromDeadNodes.apply(allDeadNodes); - - assertSame(orphanedGroups.size(), 2); - assertTrue(orphanedGroups.contains("1")); - assertTrue(orphanedGroups.contains("2")); - } - - @Test - public void testDetectsAllOrphanedGroupsWhenSomeNodesAreAlive() { - - Set deadNodesGroup1 = (Set) ImmutableSet.builder() - .add(new IdAndGroupOnlyNodeMetadata("a", "1", NodeMetadata.Status.TERMINATED)).build(); - - Set deadNodesGroup2 = (Set) ImmutableSet.builder() - .add(new IdAndGroupOnlyNodeMetadata("b", "2", NodeMetadata.Status.RUNNING)).build(); - - Set allDeadNodes = Sets.union(deadNodesGroup1, deadNodesGroup2); - - ComputeService mock = createMock(ComputeService.class); - expect(mock.listNodesDetailsMatching(EasyMock.>anyObject())) - .andReturn((Set) deadNodesGroup1).once(); - expect(mock.listNodesDetailsMatching(EasyMock.>anyObject())) - .andReturn((Set) deadNodesGroup2).once(); - - replay(mock); - - OrphanedGroupsFromDeadNodes orphanedGroupsFromDeadNodes = new OrphanedGroupsFromDeadNodes(new - AllNodesInGroupTerminated(mock)); - - Set orphanedGroups = orphanedGroupsFromDeadNodes.apply(allDeadNodes); - - assertSame(orphanedGroups.size(), 1); - assertTrue(orphanedGroups.contains("1")); - } -} diff --git a/labs/google-compute/src/test/java/org/jclouds/googlecompute/features/DiskApiExpectTest.java b/labs/google-compute/src/test/java/org/jclouds/googlecompute/features/DiskApiExpectTest.java deleted file mode 100644 index 51f9141042..0000000000 --- a/labs/google-compute/src/test/java/org/jclouds/googlecompute/features/DiskApiExpectTest.java +++ /dev/null @@ -1,172 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.googlecompute.features; - -import org.jclouds.googlecompute.internal.BaseGoogleComputeApiExpectTest; -import org.jclouds.googlecompute.parse.ParseDiskListTest; -import org.jclouds.googlecompute.parse.ParseDiskTest; -import org.jclouds.googlecompute.parse.ParseOperationTest; -import org.jclouds.http.HttpRequest; -import org.jclouds.http.HttpResponse; -import org.testng.annotations.Test; - -import javax.ws.rs.core.MediaType; -import java.net.URI; - -import static org.jclouds.googlecompute.GoogleComputeConstants.COMPUTE_READONLY_SCOPE; -import static org.jclouds.googlecompute.GoogleComputeConstants.COMPUTE_SCOPE; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertTrue; -import static org.testng.AssertJUnit.assertNull; - -/** - * @author David Alves - */ -@Test(groups = "unit") -public class DiskApiExpectTest extends BaseGoogleComputeApiExpectTest { - - public void testGetDiskResponseIs2xx() throws Exception { - HttpRequest get = HttpRequest - .builder() - .method("GET") - .endpoint("https://www.googleapis.com/compute/v1beta13/projects/myproject/disks/testimage1") - .addHeader("Accept", "application/json") - .addHeader("Authorization", "Bearer " + TOKEN).build(); - - HttpResponse operationResponse = HttpResponse.builder().statusCode(200) - .payload(payloadFromResource("/disk_get.json")).build(); - - DiskApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE), - TOKEN_RESPONSE, get, operationResponse).getDiskApiForProject("myproject"); - - assertEquals(api.get("testimage1"), - new ParseDiskTest().expected()); - } - - public void testGetDiskResponseIs4xx() throws Exception { - HttpRequest get = HttpRequest - .builder() - .method("GET") - .endpoint("https://www.googleapis.com/compute/v1beta13/projects/myproject/disks/testimage1") - .addHeader("Accept", "application/json") - .addHeader("Authorization", "Bearer " + TOKEN).build(); - - HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build(); - - DiskApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE), - TOKEN_RESPONSE, get, operationResponse).getDiskApiForProject("myproject"); - - assertNull(api.get("testimage1")); - } - - public void testInsertDiskResponseIs2xx() { - HttpRequest insert = HttpRequest - .builder() - .method("POST") - .endpoint("https://www.googleapis.com/compute/v1beta13/projects/myproject/disks") - .addHeader("Accept", "application/json") - .addHeader("Authorization", "Bearer " + TOKEN) - .payload(payloadFromResourceWithContentType("/disk_insert.json", MediaType.APPLICATION_JSON)) - .build(); - - HttpResponse insertDiskResponse = HttpResponse.builder().statusCode(200) - .payload(payloadFromResource("/operation.json")).build(); - - DiskApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE), - TOKEN_RESPONSE, insert, - insertDiskResponse).getDiskApiForProject("myproject"); - - assertEquals(api.createInZone("testimage1", 1, URI.create("https://www.googleapis" + - ".com/compute/v1beta13/projects/myproject/zones/us-central1-a")) - , new ParseOperationTest().expected()); - } - - public void testDeleteDiskResponseIs2xx() { - HttpRequest delete = HttpRequest - .builder() - .method("DELETE") - .endpoint("https://www.googleapis" + - ".com/compute/v1beta13/projects/myproject/disks/testimage1") - .addHeader("Accept", "application/json") - .addHeader("Authorization", "Bearer " + TOKEN).build(); - - HttpResponse deleteResponse = HttpResponse.builder().statusCode(200) - .payload(payloadFromResource("/operation.json")).build(); - - DiskApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE), - TOKEN_RESPONSE, delete, deleteResponse).getDiskApiForProject("myproject"); - - assertEquals(api.delete("testimage1"), - new ParseOperationTest().expected()); - } - - public void testDeleteDiskResponseIs4xx() { - HttpRequest delete = HttpRequest - .builder() - .method("DELETE") - .endpoint("https://www.googleapis" + - ".com/compute/v1beta13/projects/myproject/disks/testimage1") - .addHeader("Accept", "application/json") - .addHeader("Authorization", "Bearer " + TOKEN).build(); - - HttpResponse deleteResponse = HttpResponse.builder().statusCode(404).build(); - - DiskApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE), - TOKEN_RESPONSE, delete, deleteResponse).getDiskApiForProject("myproject"); - - assertNull(api.delete("testimage1")); - } - - public void testListDisksResponseIs2xx() { - HttpRequest list = HttpRequest - .builder() - .method("GET") - .endpoint("https://www.googleapis" + - ".com/compute/v1beta13/projects/myproject/disks") - .addHeader("Accept", "application/json") - .addHeader("Authorization", "Bearer " + TOKEN).build(); - - HttpResponse operationResponse = HttpResponse.builder().statusCode(200) - .payload(payloadFromResource("/disk_list.json")).build(); - - DiskApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE), - TOKEN_RESPONSE, list, operationResponse).getDiskApiForProject("myproject"); - - assertEquals(api.listFirstPage().toString(), - new ParseDiskListTest().expected().toString()); - } - - public void testListDisksResponseIs4xx() { - HttpRequest list = HttpRequest - .builder() - .method("GET") - .endpoint("https://www.googleapis" + - ".com/compute/v1beta13/projects/myproject/disks") - .addHeader("Accept", "application/json") - .addHeader("Authorization", "Bearer " + TOKEN).build(); - - HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build(); - - DiskApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE), - TOKEN_RESPONSE, list, operationResponse).getDiskApiForProject("myproject"); - - assertTrue(api.list().concat().isEmpty()); - } -} diff --git a/labs/google-compute/src/test/java/org/jclouds/googlecompute/features/DiskApiLiveTest.java b/labs/google-compute/src/test/java/org/jclouds/googlecompute/features/DiskApiLiveTest.java deleted file mode 100644 index ddf626be3b..0000000000 --- a/labs/google-compute/src/test/java/org/jclouds/googlecompute/features/DiskApiLiveTest.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.googlecompute.features; - -import com.google.common.collect.Iterables; -import com.google.common.collect.Lists; -import org.jclouds.collect.PagedIterable; -import org.jclouds.googlecompute.domain.Disk; -import org.jclouds.googlecompute.domain.Project; -import org.jclouds.googlecompute.internal.BaseGoogleComputeApiLiveTest; -import org.jclouds.googlecompute.options.ListOptions; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -import java.net.URI; -import java.util.List; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; - -/** - * @author David Alves - */ -public class DiskApiLiveTest extends BaseGoogleComputeApiLiveTest { - - private static final String DISK_NAME = "disk-api-live-test-disk"; - private static final int TIME_WAIT = 10; - - private URI zoneUrl; - private int sizeGb; - - @BeforeClass(groups = {"integration", "live"}) - public void setupContext() { - super.setupContext(); - sizeGb = 1; - } - - private DiskApi api() { - return context.getApi().getDiskApiForProject( getUserProject()); - } - - @Test(groups = "live") - public void testInsertDisk() { - Project project = context.getApi().getProjectApi().get(getUserProject()); - zoneUrl = getDefaultZoneUrl(project.getName()); - assertOperationDoneSucessfully(api().createInZone(DISK_NAME, sizeGb, zoneUrl), TIME_WAIT); - - } - - @Test(groups = "live", dependsOnMethods = "testInsertDisk") - public void testGetDisk() { - - Disk disk = api().get(DISK_NAME); - assertNotNull(disk); - assertDiskEquals(disk); - } - - @Test(groups = "live", dependsOnMethods = "testGetDisk") - public void testListDisk() { - - PagedIterable disks = api().list(new ListOptions.Builder() - .filter("name eq " + DISK_NAME)); - - List disksAsList = Lists.newArrayList(disks.concat()); - - assertEquals(disksAsList.size(), 1); - - assertDiskEquals(Iterables.getOnlyElement(disksAsList)); - - } - - @Test(groups = "live", dependsOnMethods = "testListDisk") - public void testDeleteDisk() { - - assertOperationDoneSucessfully(api().delete(DISK_NAME), TIME_WAIT); - } - - private void assertDiskEquals(Disk result) { - assertEquals(result.getName(), DISK_NAME); - assertEquals(result.getSizeGb(), sizeGb); - assertEquals(result.getZone(), zoneUrl); - } - -} diff --git a/labs/google-compute/src/test/java/org/jclouds/googlecompute/features/FirewallApiExpectTest.java b/labs/google-compute/src/test/java/org/jclouds/googlecompute/features/FirewallApiExpectTest.java deleted file mode 100644 index dc133b5aa4..0000000000 --- a/labs/google-compute/src/test/java/org/jclouds/googlecompute/features/FirewallApiExpectTest.java +++ /dev/null @@ -1,305 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.googlecompute.features; - -import com.google.common.base.Function; -import com.google.common.collect.ImmutableSet; -import org.jclouds.googlecompute.domain.Firewall; -import org.jclouds.googlecompute.internal.BaseGoogleComputeApiExpectTest; -import org.jclouds.googlecompute.options.FirewallOptions; -import org.jclouds.googlecompute.parse.ParseFirewallListTest; -import org.jclouds.googlecompute.parse.ParseFirewallTest; -import org.jclouds.googlecompute.parse.ParseOperationTest; -import org.jclouds.http.HttpRequest; -import org.jclouds.http.HttpResponse; -import org.jclouds.io.Payload; -import org.testng.annotations.Test; - -import javax.ws.rs.core.MediaType; -import java.io.IOException; -import java.net.URI; -import java.util.Set; - -import static com.google.common.base.Joiner.on; -import static com.google.common.collect.Iterables.transform; -import static java.lang.String.format; -import static org.jclouds.googlecompute.GoogleComputeConstants.COMPUTE_READONLY_SCOPE; -import static org.jclouds.googlecompute.GoogleComputeConstants.COMPUTE_SCOPE; -import static org.jclouds.googlecompute.domain.Firewall.Rule.IPProtocol; -import static org.jclouds.io.Payloads.newStringPayload; -import static org.jclouds.util.Strings2.toStringAndClose; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertTrue; -import static org.testng.AssertJUnit.assertNull; - -/** - * @author David Alves - */ -@Test(groups = "unit") -public class FirewallApiExpectTest extends BaseGoogleComputeApiExpectTest { - - public static final HttpRequest GET_FIREWALL_REQUEST = HttpRequest - .builder() - .method("GET") - .endpoint("https://www.googleapis" + - ".com/compute/v1beta13/projects/myproject/firewalls/jclouds-test") - .addHeader("Accept", "application/json") - .addHeader("Authorization", "Bearer " + TOKEN).build(); - - public static HttpResponse GET_FIREWALL_RESPONSE = HttpResponse.builder().statusCode(200) - .payload(staticPayloadFromResource("/firewall_get.json")).build(); - - public void testGetFirewallResponseIs2xx() throws Exception { - - FirewallApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE), - TOKEN_RESPONSE, GET_FIREWALL_REQUEST, GET_FIREWALL_RESPONSE).getFirewallApiForProject("myproject"); - - assertEquals(api.get("jclouds-test"), new ParseFirewallTest().expected()); - } - - - public static Payload firewallPayloadFirewallOfName(String firewallName, - String networkName, - Set sourceRanges, - Set sourceTags, - Set targetTags, - Set portRanges) throws IOException { - Function addQuotes = new Function() { - @Override - public String apply(String input) { - return "\"" + input + "\""; - } - }; - - String ports = on(",").skipNulls().join(transform(portRanges, addQuotes)); - - Payload payload = newStringPayload( - format(toStringAndClose(FirewallApiExpectTest.class.getResourceAsStream("/firewall_insert.json")), - firewallName, - networkName, - on(",").skipNulls().join(transform(sourceRanges, addQuotes)), - on(",").skipNulls().join(transform(sourceTags, addQuotes)), - on(",").skipNulls().join(transform(targetTags, addQuotes)), - ports, - ports)); - payload.getContentMetadata().setContentType(MediaType.APPLICATION_JSON); - return payload; - } - - - public void testGetFirewallResponseIs4xx() throws Exception { - HttpRequest get = HttpRequest - .builder() - .method("GET") - .endpoint("https://www.googleapis" + - ".com/compute/v1beta13/projects/myproject/firewalls/jclouds-test") - .addHeader("Accept", "application/json") - .addHeader("Authorization", "Bearer " + TOKEN).build(); - - HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build(); - - FirewallApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE), - TOKEN_RESPONSE, get, operationResponse).getFirewallApiForProject("myproject"); - - assertNull(api.get("jclouds-test")); - } - - public void testInsertFirewallResponseIs2xx() throws IOException { - - HttpRequest request = HttpRequest - .builder() - .method("POST") - .endpoint("https://www.googleapis.com/compute/v1beta13/projects/myproject/firewalls") - .addHeader("Accept", "application/json") - .addHeader("Authorization", "Bearer " + TOKEN) - .payload(firewallPayloadFirewallOfName( - "myfw", - "default", - ImmutableSet.of("10.0.1.0/32"), - ImmutableSet.of("tag1"), - ImmutableSet.of("tag2"), - ImmutableSet.of("22", "23-24"))) - .build(); - - HttpResponse insertFirewallResponse = HttpResponse.builder().statusCode(200) - .payload(payloadFromResource("/operation.json")).build(); - - FirewallApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE), - TOKEN_RESPONSE, request, insertFirewallResponse).getFirewallApiForProject("myproject"); - - assertEquals(api.createInNetwork("myfw", URI.create("https://www.googleapis" + - ".com/compute/v1beta13/projects/myproject/networks/default"), - new FirewallOptions() - .addAllowedRule(Firewall.Rule.builder() - .IPProtocol(IPProtocol.TCP) - .addPort(22) - .addPortRange(23, 24).build()) - .addSourceTag("tag1") - .addSourceRange("10.0.1.0/32") - .addTargetTag("tag2")), new ParseOperationTest().expected()); - - } - - public void testUpdateFirewallResponseIs2xx() throws IOException { - HttpRequest update = HttpRequest - .builder() - .method("PUT") - .endpoint("https://www.googleapis.com/compute/v1beta13/projects/myproject/firewalls/myfw") - .addHeader("Accept", "application/json") - .addHeader("Authorization", "Bearer " + TOKEN) - .payload(firewallPayloadFirewallOfName( - "myfw", - "default", - ImmutableSet.of("10.0.1.0/32"), - ImmutableSet.of("tag1"), - ImmutableSet.of("tag2"), - ImmutableSet.of("22", "23-24"))) - .build(); - - HttpResponse updateFirewallResponse = HttpResponse.builder().statusCode(200) - .payload(payloadFromResource("/operation.json")).build(); - - FirewallApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE), - TOKEN_RESPONSE, update, - updateFirewallResponse).getFirewallApiForProject("myproject"); - - assertEquals(api.update("myfw", - new FirewallOptions() - .name("myfw") - .network(URI.create("https://www.googleapis" + - ".com/compute/v1beta13/projects/myproject/networks/default")) - .addAllowedRule(Firewall.Rule.builder() - .IPProtocol(IPProtocol.TCP) - .addPort(22) - .addPortRange(23, 24).build()) - .addSourceTag("tag1") - .addSourceRange("10.0.1.0/32") - .addTargetTag("tag2")), new ParseOperationTest().expected()); - } - - public void testPatchFirewallResponseIs2xx() throws IOException { - HttpRequest update = HttpRequest - .builder() - .method("PATCH") - .endpoint("https://www.googleapis.com/compute/v1beta13/projects/myproject/firewalls/myfw") - .addHeader("Accept", "application/json") - .addHeader("Authorization", "Bearer " + TOKEN) - .payload(firewallPayloadFirewallOfName( - "myfw", - "default", - ImmutableSet.of("10.0.1.0/32"), - ImmutableSet.of("tag1"), - ImmutableSet.of("tag2"), - ImmutableSet.of("22", "23-24"))) - .build(); - - HttpResponse updateFirewallResponse = HttpResponse.builder().statusCode(200) - .payload(payloadFromResource("/operation.json")).build(); - - FirewallApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE), - TOKEN_RESPONSE, update, - updateFirewallResponse).getFirewallApiForProject("myproject"); - - assertEquals(api.patch("myfw", - new FirewallOptions() - .name("myfw") - .network(URI.create("https://www.googleapis" + - ".com/compute/v1beta13/projects/myproject/networks/default")) - .addAllowedRule(Firewall.Rule.builder() - .IPProtocol(IPProtocol.TCP) - .addPort(22) - .addPortRange(23, 24).build()) - .addSourceTag("tag1") - .addSourceRange("10.0.1.0/32") - .addTargetTag("tag2")), new ParseOperationTest().expected()); - } - - public void testDeleteFirewallResponseIs2xx() { - HttpRequest delete = HttpRequest - .builder() - .method("DELETE") - .endpoint("https://www.googleapis" + - ".com/compute/v1beta13/projects/myproject/firewalls/default-allow-internal") - .addHeader("Accept", "application/json") - .addHeader("Authorization", "Bearer " + TOKEN).build(); - - HttpResponse deleteResponse = HttpResponse.builder().statusCode(200) - .payload(payloadFromResource("/operation.json")).build(); - - FirewallApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE), - TOKEN_RESPONSE, delete, deleteResponse).getFirewallApiForProject("myproject"); - - assertEquals(api.delete("default-allow-internal"), - new ParseOperationTest().expected()); - } - - public void testDeleteFirewallResponseIs4xx() { - HttpRequest delete = HttpRequest - .builder() - .method("DELETE") - .endpoint("https://www.googleapis" + - ".com/compute/v1beta13/projects/myproject/firewalls/default-allow-internal") - .addHeader("Accept", "application/json") - .addHeader("Authorization", "Bearer " + TOKEN).build(); - - HttpResponse deleteResponse = HttpResponse.builder().statusCode(404).build(); - - FirewallApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE), - TOKEN_RESPONSE, delete, deleteResponse).getFirewallApiForProject("myproject"); - - assertNull(api.delete("default-allow-internal")); - } - - public void testListFirewallsResponseIs2xx() { - HttpRequest list = HttpRequest - .builder() - .method("GET") - .endpoint("https://www.googleapis" + - ".com/compute/v1beta13/projects/myproject/firewalls") - .addHeader("Accept", "application/json") - .addHeader("Authorization", "Bearer " + TOKEN).build(); - - HttpResponse operationResponse = HttpResponse.builder().statusCode(200) - .payload(payloadFromResource("/firewall_list.json")).build(); - - FirewallApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE), - TOKEN_RESPONSE, list, operationResponse).getFirewallApiForProject("myproject"); - - assertEquals(api.listFirstPage().toString(), - new ParseFirewallListTest().expected().toString()); - } - - public void testListFirewallsResponseIs4xx() { - HttpRequest list = HttpRequest - .builder() - .method("GET") - .endpoint("https://www.googleapis" + - ".com/compute/v1beta13/projects/myproject/firewalls") - .addHeader("Accept", "application/json") - .addHeader("Authorization", "Bearer " + TOKEN).build(); - - HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build(); - - FirewallApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE), - TOKEN_RESPONSE, list, operationResponse).getFirewallApiForProject("myproject"); - - assertTrue(api.list().concat().isEmpty()); - } -} diff --git a/labs/google-compute/src/test/java/org/jclouds/googlecompute/features/FirewallApiLiveTest.java b/labs/google-compute/src/test/java/org/jclouds/googlecompute/features/FirewallApiLiveTest.java deleted file mode 100644 index dcc9d17332..0000000000 --- a/labs/google-compute/src/test/java/org/jclouds/googlecompute/features/FirewallApiLiveTest.java +++ /dev/null @@ -1,168 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.googlecompute.features; - -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Lists; -import org.jclouds.collect.PagedIterable; -import org.jclouds.googlecompute.domain.Firewall; -import org.jclouds.googlecompute.internal.BaseGoogleComputeApiLiveTest; -import org.jclouds.googlecompute.options.FirewallOptions; -import org.jclouds.googlecompute.options.ListOptions; -import org.testng.annotations.Test; - -import java.util.List; - -import static com.google.common.collect.Iterables.getOnlyElement; -import static org.jclouds.googlecompute.domain.Firewall.Rule.IPProtocol; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; - -/** - * @author David Alves - */ -public class FirewallApiLiveTest extends BaseGoogleComputeApiLiveTest { - - private static final String FIREWALL_NAME = "firewall-api-live-test-firewall"; - private static final String FIREWALL_NETWORK_NAME = "firewall-api-live-test-network"; - private static final String IPV4_RANGE = "10.0.0.0/8"; - private static final int TIME_WAIT = 30; - - private FirewallApi api() { - return context.getApi().getFirewallApiForProject(getUserProject()); - } - - @Test(groups = "live") - public void testInsertFirewall() { - - // need to create the network first - assertOperationDoneSucessfully(context.getApi().getNetworkApiForProject(getUserProject()).createInIPv4Range - (FIREWALL_NETWORK_NAME, IPV4_RANGE), TIME_WAIT); - - FirewallOptions firewall = new FirewallOptions() - .addAllowedRule( - Firewall.Rule.builder() - .IPProtocol(IPProtocol.TCP) - .addPort(22).build()) - .addSourceRange("10.0.0.0/8") - .addSourceTag("tag1") - .addTargetTag("tag2"); - - assertOperationDoneSucessfully(api().createInNetwork(FIREWALL_NAME, getNetworkUrl(getUserProject(), - FIREWALL_NETWORK_NAME), firewall), TIME_WAIT); - - } - - @Test(groups = "live", dependsOnMethods = "testInsertFirewall") - public void testUpdateFirewall() { - - FirewallOptions firewall = new FirewallOptions() - .name(FIREWALL_NAME) - .network(getNetworkUrl(getUserProject(),FIREWALL_NETWORK_NAME)) - .addSourceRange("10.0.0.0/8") - .addSourceTag("tag1") - .addTargetTag("tag2") - .allowedRules(ImmutableSet.of( - Firewall.Rule.builder() - .IPProtocol(IPProtocol.TCP) - .addPort(23) - .build())); - - - assertOperationDoneSucessfully(api().update(FIREWALL_NAME, firewall), TIME_WAIT); - - } - - @Test(groups = "live", dependsOnMethods = "testUpdateFirewall") - public void testPatchFirewall() { - - FirewallOptions firewall = new FirewallOptions() - .name(FIREWALL_NAME) - .network(getNetworkUrl(getUserProject(),FIREWALL_NETWORK_NAME)) - .allowedRules(ImmutableSet.of( - Firewall.Rule.builder() - .IPProtocol(IPProtocol.TCP) - .addPort(22) - .build(), - Firewall.Rule.builder() - .IPProtocol(IPProtocol.TCP) - .addPort(23) - .build())) - .addSourceRange("10.0.0.0/8") - .addSourceTag("tag1") - .addTargetTag("tag2"); - - assertOperationDoneSucessfully(api().update(FIREWALL_NAME, firewall), TIME_WAIT); - - } - - @Test(groups = "live", dependsOnMethods = "testPatchFirewall") - public void testGetFirewall() { - - FirewallOptions patchedFirewall = new FirewallOptions() - .name(FIREWALL_NAME) - .network(getNetworkUrl(getUserProject(), FIREWALL_NETWORK_NAME)) - .allowedRules(ImmutableSet.of( - Firewall.Rule.builder() - .IPProtocol(IPProtocol.TCP) - .addPort(22) - .build(), - Firewall.Rule.builder() - .IPProtocol(IPProtocol.TCP) - .addPort(23) - .build())) - .addSourceRange("10.0.0.0/8") - .addSourceTag("tag1") - .addTargetTag("tag2"); - - Firewall firewall = api().get(FIREWALL_NAME); - assertNotNull(firewall); - assertFirewallEquals(firewall, patchedFirewall); - } - - @Test(groups = "live", dependsOnMethods = "testGetFirewall") - public void testListFirewall() { - - PagedIterable firewalls = api().list(new ListOptions.Builder() - .filter("name eq " + FIREWALL_NAME)); - - List firewallsAsList = Lists.newArrayList(firewalls.concat()); - - assertEquals(firewallsAsList.size(), 1); - - } - - @Test(groups = "live", dependsOnMethods = "testListFirewall") - public void testDeleteFirewall() { - - assertOperationDoneSucessfully(api().delete(FIREWALL_NAME), TIME_WAIT); - assertOperationDoneSucessfully(context.getApi().getNetworkApiForProject(getUserProject()).delete - (FIREWALL_NETWORK_NAME), TIME_WAIT); - } - - private void assertFirewallEquals(Firewall result, FirewallOptions expected) { - assertEquals(result.getName(), expected.getName()); - assertEquals(getOnlyElement(result.getSourceRanges()), getOnlyElement(expected.getSourceRanges())); - assertEquals(getOnlyElement(result.getSourceTags()), getOnlyElement(expected.getSourceTags())); - assertEquals(getOnlyElement(result.getTargetTags()), getOnlyElement(expected.getTargetTags())); - assertEquals(result.getAllowed(), expected.getAllowed()); - } - -} diff --git a/labs/google-compute/src/test/java/org/jclouds/googlecompute/features/ImageApiExpectTest.java b/labs/google-compute/src/test/java/org/jclouds/googlecompute/features/ImageApiExpectTest.java deleted file mode 100644 index eb2db67854..0000000000 --- a/labs/google-compute/src/test/java/org/jclouds/googlecompute/features/ImageApiExpectTest.java +++ /dev/null @@ -1,144 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.googlecompute.features; - -import org.jclouds.googlecompute.internal.BaseGoogleComputeApiExpectTest; -import org.jclouds.googlecompute.parse.ParseImageListTest; -import org.jclouds.googlecompute.parse.ParseImageTest; -import org.jclouds.googlecompute.parse.ParseOperationTest; -import org.jclouds.http.HttpRequest; -import org.jclouds.http.HttpResponse; -import org.testng.annotations.Test; - -import static org.jclouds.googlecompute.GoogleComputeConstants.COMPUTE_READONLY_SCOPE; -import static org.jclouds.googlecompute.GoogleComputeConstants.COMPUTE_SCOPE; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertTrue; -import static org.testng.AssertJUnit.assertNull; - -/** - * @author David Alves - */ -@Test(groups = "unit") -public class ImageApiExpectTest extends BaseGoogleComputeApiExpectTest { - - public static final HttpRequest LIST_PROJECT_IMAGES_REQUEST = HttpRequest - .builder() - .method("GET") - .endpoint("https://www.googleapis" + - ".com/compute/v1beta13/projects/myproject/images") - .addHeader("Accept", "application/json") - .addHeader("Authorization", "Bearer " + TOKEN).build(); - - public static final HttpResponse LIST_PROJECT_IMAGES_RESPONSE = HttpResponse.builder().statusCode(200) - .payload(staticPayloadFromResource("/image_list.json")).build(); - - public void testGetImageResponseIs2xx() throws Exception { - HttpRequest get = HttpRequest - .builder() - .method("GET") - .endpoint("https://www.googleapis" + - ".com/compute/v1beta13/projects/google/images/centos-6-2-v20120326") - .addHeader("Accept", "application/json") - .addHeader("Authorization", "Bearer " + TOKEN).build(); - - HttpResponse operationResponse = HttpResponse.builder().statusCode(200) - .payload(payloadFromResource("/image_get.json")).build(); - - ImageApi imageApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE), - TOKEN_RESPONSE, get, operationResponse).getImageApiForProject("google"); - - assertEquals(imageApi.get("centos-6-2-v20120326"), - new ParseImageTest().expected()); - } - - public void testGetImageResponseIs4xx() throws Exception { - HttpRequest get = HttpRequest - .builder() - .method("GET") - .endpoint("https://www.googleapis" + - ".com/compute/v1beta13/projects/google/images/centos-6-2-v20120326") - .addHeader("Accept", "application/json") - .addHeader("Authorization", "Bearer " + TOKEN).build(); - - HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build(); - - ImageApi imageApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE), - TOKEN_RESPONSE, get, operationResponse).getImageApiForProject("google"); - - assertNull(imageApi.get("centos-6-2-v20120326")); - } - - public void testDeleteImageResponseIs2xx() { - HttpRequest delete = HttpRequest - .builder() - .method("DELETE") - .endpoint("https://www.googleapis" + - ".com/compute/v1beta13/projects/myproject/images/centos-6-2-v20120326") - .addHeader("Accept", "application/json") - .addHeader("Authorization", "Bearer " + TOKEN).build(); - - HttpResponse deleteResponse = HttpResponse.builder().statusCode(200) - .payload(payloadFromResource("/operation.json")).build(); - - ImageApi imageApi = requestsSendResponses(requestForScopes(COMPUTE_SCOPE), - TOKEN_RESPONSE, delete, deleteResponse).getImageApiForProject("myproject"); - - assertEquals(imageApi.delete("centos-6-2-v20120326"), - new ParseOperationTest().expected()); - } - - public void testDeleteImageResponseIs4xx() { - HttpRequest delete = HttpRequest - .builder() - .method("DELETE") - .endpoint("https://www.googleapis" + - ".com/compute/v1beta13/projects/myproject/images/centos-6-2-v20120326") - .addHeader("Accept", "application/json") - .addHeader("Authorization", "Bearer " + TOKEN).build(); - - HttpResponse deleteResponse = HttpResponse.builder().statusCode(404).build(); - - ImageApi imageApi = requestsSendResponses(requestForScopes(COMPUTE_SCOPE), - TOKEN_RESPONSE, delete, deleteResponse).getImageApiForProject("myproject"); - - assertNull(imageApi.delete("centos-6-2-v20120326")); - } - - public void testListImagesResponseIs2xx() { - - ImageApi imageApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE), - TOKEN_RESPONSE, LIST_PROJECT_IMAGES_REQUEST, LIST_PROJECT_IMAGES_RESPONSE).getImageApiForProject - ("myproject"); - - assertEquals(imageApi.listFirstPage().toString(), - new ParseImageListTest().expected().toString()); - } - - public void testListImagesResponseIs4xx() { - - HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build(); - - ImageApi imageApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE), - TOKEN_RESPONSE, LIST_PROJECT_IMAGES_REQUEST, operationResponse).getImageApiForProject("myproject"); - - assertTrue(imageApi.list().concat().isEmpty()); - } -} diff --git a/labs/google-compute/src/test/java/org/jclouds/googlecompute/features/ImageApiLiveTest.java b/labs/google-compute/src/test/java/org/jclouds/googlecompute/features/ImageApiLiveTest.java deleted file mode 100644 index 4f60864914..0000000000 --- a/labs/google-compute/src/test/java/org/jclouds/googlecompute/features/ImageApiLiveTest.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.googlecompute.features; - -import com.google.common.collect.Iterables; -import com.google.common.collect.Lists; -import org.jclouds.collect.IterableWithMarker; -import org.jclouds.collect.PagedIterable; -import org.jclouds.googlecompute.domain.Image; -import org.jclouds.googlecompute.internal.BaseGoogleComputeApiLiveTest; -import org.jclouds.googlecompute.options.ListOptions; -import org.testng.annotations.Test; - -import java.util.Iterator; -import java.util.List; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertSame; -import static org.testng.Assert.assertTrue; - -/** - * TODO figure out how to test insert and delete as this requires an image .tar.gz to be present in GCS - * - * @author David Alves - */ -public class ImageApiLiveTest extends BaseGoogleComputeApiLiveTest { - - private Image image; - - private ImageApi api() { - return context.getApi().getImageApiForProject("google"); - } - - @Test(groups = "live") - public void testListImage() { - - PagedIterable images = api().list(new ListOptions.Builder().maxResults(1)); - - Iterator> pageIterator = images.iterator(); - assertTrue(pageIterator.hasNext()); - - IterableWithMarker singlePageIterator = pageIterator.next(); - List imageAsList = Lists.newArrayList(singlePageIterator); - - assertSame(imageAsList.size(), 1); - - this.image = Iterables.getOnlyElement(imageAsList); - } - - - @Test(groups = "live", dependsOnMethods = "testListImage") - public void testGetImage() { - Image image = api().get(this.image.getName()); - assertNotNull(image); - assertImageEquals(image, this.image); - } - - private void assertImageEquals(Image result, Image expected) { - assertEquals(result.getName(), expected.getName()); - } - -} - diff --git a/labs/google-compute/src/test/java/org/jclouds/googlecompute/features/InstanceApiExpectTest.java b/labs/google-compute/src/test/java/org/jclouds/googlecompute/features/InstanceApiExpectTest.java deleted file mode 100644 index 9fed672295..0000000000 --- a/labs/google-compute/src/test/java/org/jclouds/googlecompute/features/InstanceApiExpectTest.java +++ /dev/null @@ -1,230 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.googlecompute.features; - -import org.jclouds.googlecompute.domain.Instance; -import org.jclouds.googlecompute.domain.InstanceTemplate; -import org.jclouds.googlecompute.internal.BaseGoogleComputeApiExpectTest; -import org.jclouds.googlecompute.parse.ParseInstanceListTest; -import org.jclouds.googlecompute.parse.ParseInstanceSerialOutputTest; -import org.jclouds.googlecompute.parse.ParseInstanceTest; -import org.jclouds.googlecompute.parse.ParseOperationTest; -import org.jclouds.http.HttpRequest; -import org.jclouds.http.HttpResponse; -import org.testng.annotations.Test; - -import javax.ws.rs.core.MediaType; -import java.net.URI; - -import static java.net.URI.create; -import static org.jclouds.googlecompute.GoogleComputeConstants.COMPUTE_READONLY_SCOPE; -import static org.jclouds.googlecompute.GoogleComputeConstants.COMPUTE_SCOPE; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertTrue; -import static org.testng.AssertJUnit.assertNull; - -/** - * @author David Alves - */ -@Test(groups = "unit") -public class InstanceApiExpectTest extends BaseGoogleComputeApiExpectTest { - - public static final HttpRequest GET_INSTANCE_REQUEST = HttpRequest - .builder() - .method("GET") - .endpoint("https://www.googleapis" + - ".com/compute/v1beta13/projects/myproject/instances/test-1") - .addHeader("Accept", "application/json") - .addHeader("Authorization", "Bearer " + TOKEN).build(); - - - public static final HttpResponse GET_INSTANCE_RESPONSE = HttpResponse.builder().statusCode(200) - .payload(staticPayloadFromResource("/instance_get.json")).build(); - - public static final HttpRequest LIST_INSTANCES_REQUEST = HttpRequest - .builder() - .method("GET") - .endpoint("https://www.googleapis" + - ".com/compute/v1beta13/projects/myproject/instances") - .addHeader("Accept", "application/json") - .addHeader("Authorization", "Bearer " + TOKEN).build(); - - public static final HttpResponse LIST_INSTANCES_RESPONSE = HttpResponse.builder().statusCode(200) - .payload(staticPayloadFromResource("/instance_list.json")).build(); - - public static final HttpResponse CREATE_INSTANCE_RESPONSE = HttpResponse.builder().statusCode(200) - .payload(staticPayloadFromResource("/operation.json")).build(); - - - public void testGetInstanceResponseIs2xx() throws Exception { - - InstanceApi api = requestsSendResponses( - requestForScopes(COMPUTE_READONLY_SCOPE), TOKEN_RESPONSE, - GET_INSTANCE_REQUEST, GET_INSTANCE_RESPONSE).getInstanceApiForProject("myproject"); - - assertEquals(api.get("test-1"), new ParseInstanceTest().expected()); - } - - public void testGetInstanceResponseIs4xx() throws Exception { - - HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build(); - - InstanceApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE), - TOKEN_RESPONSE, GET_INSTANCE_REQUEST, operationResponse).getInstanceApiForProject("myproject"); - - assertNull(api.get("test-1")); - } - - public void testGetInstanceSerialPortOutput() throws Exception { - HttpRequest get = HttpRequest - .builder() - .method("GET") - .endpoint("https://www.googleapis" + - ".com/compute/v1beta13/projects/myproject/instances/test-1/serialPort") - .addHeader("Accept", "application/json") - .addHeader("Authorization", "Bearer " + TOKEN).build(); - - HttpResponse operationResponse = HttpResponse.builder().statusCode(200) - .payload(payloadFromResource("/instance_serial_port.json")).build(); - - - InstanceApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE), - TOKEN_RESPONSE, get, operationResponse).getInstanceApiForProject("myproject"); - - assertEquals(api.getSerialPortOutput("test-1"), new ParseInstanceSerialOutputTest().expected()); - } - - public void testInsertInstanceResponseIs2xxNoOptions() { - HttpRequest insert = HttpRequest - .builder() - .method("POST") - .endpoint("https://www.googleapis.com/compute/v1beta13/projects/myproject/instances") - .addHeader("Accept", "application/json") - .addHeader("Authorization", "Bearer " + TOKEN) - .payload(payloadFromResourceWithContentType("/instance_insert_simple.json", MediaType.APPLICATION_JSON)) - .build(); - - InstanceApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE), - TOKEN_RESPONSE, insert, - CREATE_INSTANCE_RESPONSE).getInstanceApiForProject("myproject"); - - InstanceTemplate options = InstanceTemplate.builder().forMachineType("n1-standard-1") - .addNetworkInterface(URI.create("https://www.googleapis" + - ".com/compute/v1beta13/projects/myproject/networks/default")); - - assertEquals(api.createInZone("test-1", options, "us-central1-a"), new ParseOperationTest().expected()); - } - - public void testInsertInstanceResponseIs2xxAllOptions() { - HttpRequest insert = HttpRequest - .builder() - .method("POST") - .endpoint("https://www.googleapis.com/compute/v1beta13/projects/myproject/instances") - .addHeader("Accept", "application/json") - .addHeader("Authorization", "Bearer " + TOKEN) - .payload(payloadFromResourceWithContentType("/instance_insert.json", MediaType.APPLICATION_JSON)) - .build(); - - HttpResponse insertInstanceResponse = HttpResponse.builder().statusCode(200) - .payload(payloadFromResource("/operation.json")).build(); - - InstanceApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE), - TOKEN_RESPONSE, insert, insertInstanceResponse).getInstanceApiForProject("myproject"); - - InstanceTemplate options = InstanceTemplate.builder().forMachineType("n1-standard-1") - .addNetworkInterface(URI.create("https://www.googleapis" + - ".com/compute/v1beta13/projects/myproject/networks/default"), Instance.NetworkInterface.AccessConfig.Type.ONE_TO_ONE_NAT) - .description("desc") - .image(URI.create("https://www.googleapis" + - ".com/compute/v1beta13/projects/google/images/gcel-12-04-v20121106")) - .addDisk(InstanceTemplate.PersistentDisk.Mode.READ_WRITE, - create("https://www.googleapis.com/compute/v1beta13/projects/myproject/disks/test")) - .addTag("aTag") - .addServiceAccount(Instance.ServiceAccount.builder().email("default").addScopes("myscope").build()) - .addMetadata("aKey", "aValue"); - - assertEquals(api.createInZone("test-0", options, "us-central1-a"), - new ParseOperationTest().expected()); - } - - public void testDeleteInstanceResponseIs2xx() { - HttpRequest delete = HttpRequest - .builder() - .method("DELETE") - .endpoint("https://www.googleapis" + - ".com/compute/v1beta13/projects/myproject/instances/test-1") - .addHeader("Accept", "application/json") - .addHeader("Authorization", "Bearer " + TOKEN).build(); - - HttpResponse deleteResponse = HttpResponse.builder().statusCode(200) - .payload(payloadFromResource("/operation.json")).build(); - - InstanceApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE), - TOKEN_RESPONSE, delete, deleteResponse).getInstanceApiForProject("myproject"); - - assertEquals(api.delete("test-1"), - new ParseOperationTest().expected()); - } - - public void testDeleteInstanceResponseIs4xx() { - HttpRequest delete = HttpRequest - .builder() - .method("DELETE") - .endpoint("https://www.googleapis" + - ".com/compute/v1beta13/projects/myproject/instances/test-1") - .addHeader("Accept", "application/json") - .addHeader("Authorization", "Bearer " + TOKEN).build(); - - HttpResponse deleteResponse = HttpResponse.builder().statusCode(404).build(); - - InstanceApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE), - TOKEN_RESPONSE, delete, deleteResponse).getInstanceApiForProject("myproject"); - - assertNull(api.delete("test-1")); - } - - public void testListInstancesResponseIs2xx() { - - InstanceApi api = requestsSendResponses( - requestForScopes(COMPUTE_READONLY_SCOPE), TOKEN_RESPONSE, - LIST_INSTANCES_REQUEST, LIST_INSTANCES_RESPONSE).getInstanceApiForProject("myproject"); - - assertEquals(api.listFirstPage().toString(), - new ParseInstanceListTest().expected().toString()); - } - - public void testListInstancesResponseIs4xx() { - HttpRequest list = HttpRequest - .builder() - .method("GET") - .endpoint("https://www.googleapis" + - ".com/compute/v1beta13/projects/myproject/instances") - .addHeader("Accept", "application/json") - .addHeader("Authorization", "Bearer " + TOKEN).build(); - - HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build(); - - InstanceApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE), - TOKEN_RESPONSE, list, operationResponse).getInstanceApiForProject("myproject"); - - assertTrue(api.list().concat().isEmpty()); - } - -} diff --git a/labs/google-compute/src/test/java/org/jclouds/googlecompute/features/InstanceApiLiveTest.java b/labs/google-compute/src/test/java/org/jclouds/googlecompute/features/InstanceApiLiveTest.java deleted file mode 100644 index ec1f304fca..0000000000 --- a/labs/google-compute/src/test/java/org/jclouds/googlecompute/features/InstanceApiLiveTest.java +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.googlecompute.features; - -import com.google.common.collect.Iterables; -import com.google.common.collect.Lists; -import org.jclouds.collect.PagedIterable; -import org.jclouds.googlecompute.domain.Instance; -import org.jclouds.googlecompute.domain.InstanceTemplate; -import org.jclouds.googlecompute.internal.BaseGoogleComputeApiLiveTest; -import org.jclouds.googlecompute.options.ListOptions; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -import java.util.List; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; - -/** - * @author David Alves - */ -public class InstanceApiLiveTest extends BaseGoogleComputeApiLiveTest { - - private static final String INSTANCE_NETWORK_NAME = "instance-api-live-test-network"; - private static final String INSTANCE_NAME = "instance-api-live-test-instance"; - private static final String DISK_NAME = "instance-live-test-disk"; - private static final String IPV4_RANGE = "10.0.0.0/8"; - private static final int TIME_WAIT = 600; - - private InstanceTemplate instance; - - @BeforeClass(groups = {"integration", "live"}) - public void setupContext() { - super.setupContext(); - instance = InstanceTemplate.builder() - .forMachineType(getDefaultMachineTypekUrl(getUserProject())) - .addNetworkInterface(getNetworkUrl(getUserProject(), INSTANCE_NETWORK_NAME), - Instance.NetworkInterface.AccessConfig.Type.ONE_TO_ONE_NAT) - .addMetadata("mykey", "myvalue") - .addTag("atag") - .description("a description") - .addDisk(InstanceTemplate.PersistentDisk.Mode.READ_WRITE, getDiskUrl(getUserProject(), DISK_NAME)) - .zone(getDefaultZoneUrl(getUserProject())); - } - - private InstanceApi api() { - return context.getApi().getInstanceApiForProject(getUserProject()); - } - - @Test(groups = "live") - public void testInsertInstance() { - - // need to create the network first - assertOperationDoneSucessfully(context.getApi().getNetworkApiForProject(getUserProject()).createInIPv4Range - (INSTANCE_NETWORK_NAME, IPV4_RANGE), TIME_WAIT); - - assertOperationDoneSucessfully(context.getApi().getDiskApiForProject(getUserProject()).createInZone - ("instance-live-test-disk", 1, getDefaultZoneUrl(getUserProject())), TIME_WAIT); - - assertOperationDoneSucessfully(api().createInZone(INSTANCE_NAME, instance, DEFAULT_ZONE_NAME), TIME_WAIT); - - } - - @Test(groups = "live", dependsOnMethods = "testInsertInstance") - public void testGetInstance() { - - Instance instance = api().get(INSTANCE_NAME); - assertNotNull(instance); - assertInstanceEquals(instance, this.instance); - } - - @Test(groups = "live", dependsOnMethods = "testInsertInstance") - public void testListInstance() { - - PagedIterable instances = api().list(new ListOptions.Builder() - .filter("name eq " + INSTANCE_NAME)); - - List instancesAsList = Lists.newArrayList(instances.concat()); - - assertEquals(instancesAsList.size(), 1); - - assertInstanceEquals(Iterables.getOnlyElement(instancesAsList), instance); - - } - - @Test(groups = "live", dependsOnMethods = "testListInstance") - public void testDeleteInstance() { - - assertOperationDoneSucessfully(api().delete(INSTANCE_NAME), TIME_WAIT); - assertOperationDoneSucessfully(context.getApi().getDiskApiForProject(getUserProject()).delete(DISK_NAME), - TIME_WAIT); - assertOperationDoneSucessfully(context.getApi().getNetworkApiForProject(getUserProject()).delete - (INSTANCE_NETWORK_NAME), TIME_WAIT); - } - - private void assertInstanceEquals(Instance result, InstanceTemplate expected) { - assertEquals(result.getName(), expected.getName()); - assertEquals(result.getTags(), expected.getTags()); - assertEquals(result.getMetadata(), expected.getMetadata()); - } -} diff --git a/labs/google-compute/src/test/java/org/jclouds/googlecompute/features/KernelApiExpectTest.java b/labs/google-compute/src/test/java/org/jclouds/googlecompute/features/KernelApiExpectTest.java deleted file mode 100644 index cf30bec488..0000000000 --- a/labs/google-compute/src/test/java/org/jclouds/googlecompute/features/KernelApiExpectTest.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.googlecompute.features; - -import org.jclouds.googlecompute.internal.BaseGoogleComputeApiExpectTest; -import org.jclouds.googlecompute.parse.ParseKernelListTest; -import org.jclouds.googlecompute.parse.ParseKernelTest; -import org.jclouds.http.HttpRequest; -import org.jclouds.http.HttpResponse; -import org.testng.annotations.Test; - -import static org.jclouds.googlecompute.GoogleComputeConstants.COMPUTE_READONLY_SCOPE; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNull; -import static org.testng.Assert.assertTrue; - -/** - * @author David Alves - */ -@Test(groups = "unit") -public class KernelApiExpectTest extends BaseGoogleComputeApiExpectTest { - - public void testGetKernelResponseIs2xx() throws Exception { - HttpRequest get = HttpRequest - .builder() - .method("GET") - .endpoint("https://www.googleapis" + - ".com/compute/v1beta13/projects/myproject/kernels/12941177846308850718") - .addHeader("Accept", "application/json") - .addHeader("Authorization", "Bearer " + TOKEN).build(); - - HttpResponse operationResponse = HttpResponse.builder().statusCode(200) - .payload(payloadFromResource("/kernel.json")).build(); - - KernelApi kernelApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE), - TOKEN_RESPONSE, get, operationResponse).getKernelApiForProject("myproject"); - - assertEquals(kernelApi.get("12941177846308850718"), - new ParseKernelTest().expected()); - } - - public void testGetKernelResponseIs4xx() throws Exception { - HttpRequest get = HttpRequest - .builder() - .method("GET") - .endpoint("https://www.googleapis" + - ".com/compute/v1beta13/projects/myproject/kernels/12941177846308850718") - .addHeader("Accept", "application/json") - .addHeader("Authorization", "Bearer " + TOKEN).build(); - - HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build(); - - KernelApi kernelApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE), - TOKEN_RESPONSE, get, operationResponse).getKernelApiForProject("myproject"); - - assertNull(kernelApi.get("12941177846308850718")); - } - - public void testListKernelNoOptionsResponseIs2xx() throws Exception { - HttpRequest list = HttpRequest - .builder() - .method("GET") - .endpoint("https://www.googleapis" + - ".com/compute/v1beta13/projects/myproject/kernels") - .addHeader("Accept", "application/json") - .addHeader("Authorization", "Bearer " + TOKEN).build(); - - HttpResponse operationResponse = HttpResponse.builder().statusCode(200) - .payload(payloadFromResource("/kernel_list.json")).build(); - - KernelApi kernelApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE), - TOKEN_RESPONSE, list, operationResponse).getKernelApiForProject("myproject"); - - assertEquals(kernelApi.listFirstPage().toString(), - new ParseKernelListTest().expected().toString()); - } - - public void testListKernelsResponseIs4xx() { - HttpRequest list = HttpRequest - .builder() - .method("GET") - .endpoint("https://www.googleapis" + - ".com/compute/v1beta13/projects/myproject/kernels") - .addHeader("Accept", "application/json") - .addHeader("Authorization", "Bearer " + TOKEN).build(); - - HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build(); - - KernelApi kernelApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE), - TOKEN_RESPONSE, list, operationResponse).getKernelApiForProject("myproject"); - - assertTrue(kernelApi.list().concat().isEmpty()); - } - -} diff --git a/labs/google-compute/src/test/java/org/jclouds/googlecompute/features/KernelApiLiveTest.java b/labs/google-compute/src/test/java/org/jclouds/googlecompute/features/KernelApiLiveTest.java deleted file mode 100644 index c974d3bb31..0000000000 --- a/labs/google-compute/src/test/java/org/jclouds/googlecompute/features/KernelApiLiveTest.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.googlecompute.features; - -import com.google.common.collect.Iterables; -import com.google.common.collect.Lists; -import org.jclouds.collect.IterableWithMarker; -import org.jclouds.collect.PagedIterable; -import org.jclouds.googlecompute.domain.Kernel; -import org.jclouds.googlecompute.internal.BaseGoogleComputeApiLiveTest; -import org.jclouds.googlecompute.options.ListOptions; -import org.testng.annotations.Test; - -import java.util.Iterator; -import java.util.List; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertSame; -import static org.testng.Assert.assertTrue; - -/** - * @author David Alves - */ -public class KernelApiLiveTest extends BaseGoogleComputeApiLiveTest { - - private Kernel kernel; - - private KernelApi api() { - return context.getApi().getKernelApiForProject("google"); - } - - @Test(groups = "live") - public void testListKernel() { - - PagedIterable kernels = api().list(new ListOptions.Builder() - .maxResults(1)); - - Iterator> pageIterator = kernels.iterator(); - assertTrue(pageIterator.hasNext()); - - IterableWithMarker singlePageIterator = pageIterator.next(); - List kernelAsList = Lists.newArrayList(singlePageIterator); - - assertSame(kernelAsList.size(), 1); - - this.kernel = Iterables.getOnlyElement(kernelAsList); - } - - - @Test(groups = "live", dependsOnMethods = "testListKernel") - public void testGetKernel() { - Kernel kernel = api().get(this.kernel.getName()); - assertNotNull(kernel); - assertKernelEquals(kernel, this.kernel); - } - - private void assertKernelEquals(Kernel result, Kernel expected) { - assertEquals(result.getName(), expected.getName()); - } - -} \ No newline at end of file diff --git a/labs/google-compute/src/test/java/org/jclouds/googlecompute/features/MachineTypeApiExpectTest.java b/labs/google-compute/src/test/java/org/jclouds/googlecompute/features/MachineTypeApiExpectTest.java deleted file mode 100644 index 35ddb4968b..0000000000 --- a/labs/google-compute/src/test/java/org/jclouds/googlecompute/features/MachineTypeApiExpectTest.java +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.googlecompute.features; - -import org.jclouds.googlecompute.internal.BaseGoogleComputeApiExpectTest; -import org.jclouds.googlecompute.parse.ParseMachineTypeListTest; -import org.jclouds.googlecompute.parse.ParseMachineTypeTest; -import org.jclouds.http.HttpRequest; -import org.jclouds.http.HttpResponse; -import org.testng.annotations.Test; - -import static org.jclouds.googlecompute.GoogleComputeConstants.COMPUTE_READONLY_SCOPE; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNull; -import static org.testng.Assert.assertTrue; - -/** - * @author David Alves - */ -@Test(groups = "unit") -public class MachineTypeApiExpectTest extends BaseGoogleComputeApiExpectTest { - - public static final HttpRequest LIST_MACHINE_TYPES_REQUEST = HttpRequest - .builder() - .method("GET") - .endpoint("https://www.googleapis.com/compute/v1beta13/projects/myproject/machineTypes") - .addHeader("Accept", "application/json") - .addHeader("Authorization", "Bearer " + TOKEN).build(); - - public static final HttpResponse LIST_MACHINE_TYPES_RESPONSE = HttpResponse.builder() - .statusCode(200) - .payload(staticPayloadFromResource("/machinetype_list.json")) - .build(); - - public void testGetMachineTypeResponseIs2xx() throws Exception { - HttpRequest get = HttpRequest - .builder() - .method("GET") - .endpoint("https://www.googleapis" + - ".com/compute/v1beta13/projects/myproject/machineTypes/n1-standard-1") - .addHeader("Accept", "application/json") - .addHeader("Authorization", "Bearer " + TOKEN).build(); - - HttpResponse operationResponse = HttpResponse.builder().statusCode(200) - .payload(payloadFromResource("/machinetype.json")).build(); - - MachineTypeApi machineTypeApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE), - TOKEN_RESPONSE, get, operationResponse).getMachineTypeApiForProject("myproject"); - - assertEquals(machineTypeApi.get("n1-standard-1"), - new ParseMachineTypeTest().expected()); - } - - public void testGetMachineTypeResponseIs4xx() throws Exception { - HttpRequest get = HttpRequest - .builder() - .method("GET") - .endpoint("https://www.googleapis" + - ".com/compute/v1beta13/projects/myproject/machineTypes/n1-standard-1") - .addHeader("Accept", "application/json") - .addHeader("Authorization", "Bearer " + TOKEN).build(); - - HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build(); - - MachineTypeApi machineTypeApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE), - TOKEN_RESPONSE, get, operationResponse).getMachineTypeApiForProject("myproject"); - - assertNull(machineTypeApi.get("n1-standard-1")); - } - - public void testListMachineTypeNoOptionsResponseIs2xx() throws Exception { - - MachineTypeApi machineTypeApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE), - TOKEN_RESPONSE, LIST_MACHINE_TYPES_REQUEST, LIST_MACHINE_TYPES_RESPONSE).getMachineTypeApiForProject - ("myproject"); - - assertEquals(machineTypeApi.listFirstPage().toString(), - new ParseMachineTypeListTest().expected().toString()); - } - - public void testLisOperationWithPaginationOptionsResponseIs4xx() { - - HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build(); - - MachineTypeApi machineTypeApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE), - TOKEN_RESPONSE, LIST_MACHINE_TYPES_REQUEST, operationResponse).getMachineTypeApiForProject("myproject"); - - assertTrue(machineTypeApi.list().concat().isEmpty()); - } -} diff --git a/labs/google-compute/src/test/java/org/jclouds/googlecompute/features/MachineTypeApiLiveTest.java b/labs/google-compute/src/test/java/org/jclouds/googlecompute/features/MachineTypeApiLiveTest.java deleted file mode 100644 index f88cf517a0..0000000000 --- a/labs/google-compute/src/test/java/org/jclouds/googlecompute/features/MachineTypeApiLiveTest.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.googlecompute.features; - -import com.google.common.collect.Iterables; -import com.google.common.collect.Lists; -import org.jclouds.collect.IterableWithMarker; -import org.jclouds.collect.PagedIterable; -import org.jclouds.googlecompute.domain.MachineType; -import org.jclouds.googlecompute.internal.BaseGoogleComputeApiLiveTest; -import org.jclouds.googlecompute.options.ListOptions; -import org.testng.annotations.Test; - -import java.util.Iterator; -import java.util.List; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertSame; -import static org.testng.Assert.assertTrue; - -/** - * @author David Alves - */ -public class MachineTypeApiLiveTest extends BaseGoogleComputeApiLiveTest { - - private MachineType machineType; - - private MachineTypeApi api() { - return context.getApi().getMachineTypeApiForProject(getUserProject()); - } - - @Test(groups = "live") - public void testListMachineType() { - - PagedIterable machineTypes = api().list(new ListOptions.Builder() - .maxResults(1)); - - Iterator> pageIterator = machineTypes.iterator(); - assertTrue(pageIterator.hasNext()); - - IterableWithMarker singlePageIterator = pageIterator.next(); - List machineTypeAsList = Lists.newArrayList(singlePageIterator); - - assertSame(machineTypeAsList.size(), 1); - - this.machineType = Iterables.getOnlyElement(machineTypeAsList); - } - - - @Test(groups = "live", dependsOnMethods = "testListMachineType") - public void testGetMachineType() { - MachineType machineType = api().get(this.machineType.getName()); - assertNotNull(machineType); - assertMachineTypeEquals(machineType, this.machineType); - } - - private void assertMachineTypeEquals(MachineType result, MachineType expected) { - assertEquals(result.getName(), expected.getName()); - } -} diff --git a/labs/google-compute/src/test/java/org/jclouds/googlecompute/features/NetworkApiExpectTest.java b/labs/google-compute/src/test/java/org/jclouds/googlecompute/features/NetworkApiExpectTest.java deleted file mode 100644 index a3160fe215..0000000000 --- a/labs/google-compute/src/test/java/org/jclouds/googlecompute/features/NetworkApiExpectTest.java +++ /dev/null @@ -1,170 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.googlecompute.features; - -import org.jclouds.googlecompute.internal.BaseGoogleComputeApiExpectTest; -import org.jclouds.googlecompute.parse.ParseNetworkListTest; -import org.jclouds.googlecompute.parse.ParseNetworkTest; -import org.jclouds.googlecompute.parse.ParseOperationTest; -import org.jclouds.http.HttpRequest; -import org.jclouds.http.HttpResponse; -import org.testng.annotations.Test; - -import javax.ws.rs.core.MediaType; - -import static org.jclouds.googlecompute.GoogleComputeConstants.COMPUTE_READONLY_SCOPE; -import static org.jclouds.googlecompute.GoogleComputeConstants.COMPUTE_SCOPE; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertTrue; -import static org.testng.AssertJUnit.assertNull; - -/** - * @author David Alves - */ -@Test(groups = "unit") -public class NetworkApiExpectTest extends BaseGoogleComputeApiExpectTest { - - public static final HttpRequest GET_NETWORK_REQUEST = HttpRequest - .builder() - .method("GET") - .endpoint("https://www.googleapis.com/compute/v1beta13/projects/myproject/networks/jclouds-test") - .addHeader("Accept", "application/json") - .addHeader("Authorization", "Bearer " + TOKEN).build(); - - public static final HttpResponse GET_NETWORK_RESPONSE = HttpResponse.builder().statusCode(200) - .payload(staticPayloadFromResource("/network_get.json")).build(); - - public void testGetNetworkResponseIs2xx() throws Exception { - - NetworkApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE), - TOKEN_RESPONSE, GET_NETWORK_REQUEST, GET_NETWORK_RESPONSE).getNetworkApiForProject("myproject"); - - assertEquals(api.get("jclouds-test"), - new ParseNetworkTest().expected()); - } - - public void testGetNetworkResponseIs4xx() throws Exception { - HttpRequest get = HttpRequest - .builder() - .method("GET") - .endpoint("https://www.googleapis.com/compute/v1beta13/projects/myproject/networks/jclouds-test") - .addHeader("Accept", "application/json") - .addHeader("Authorization", "Bearer " + TOKEN).build(); - - HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build(); - - NetworkApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE), - TOKEN_RESPONSE, get, operationResponse).getNetworkApiForProject("myproject"); - - assertNull(api.get("jclouds-test")); - } - - public void testInsertNetworkResponseIs2xx() { - HttpRequest insert = HttpRequest - .builder() - .method("POST") - .endpoint("https://www.googleapis.com/compute/v1beta13/projects/myproject/networks") - .addHeader("Accept", "application/json") - .addHeader("Authorization", "Bearer " + TOKEN) - .payload(payloadFromResourceWithContentType("/network_insert.json", MediaType.APPLICATION_JSON)) - .build(); - - HttpResponse insertNetworkResponse = HttpResponse.builder().statusCode(200) - .payload(payloadFromResource("/operation.json")).build(); - - NetworkApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE), - TOKEN_RESPONSE, insert, - insertNetworkResponse).getNetworkApiForProject("myproject"); - - assertEquals(api.createInIPv4Range("test-network", "10.0.0.0/8"), new ParseOperationTest().expected()); - } - - public void testDeleteNetworkResponseIs2xx() { - HttpRequest delete = HttpRequest - .builder() - .method("DELETE") - .endpoint("https://www.googleapis" + - ".com/compute/v1beta13/projects/myproject/networks/jclouds-test") - .addHeader("Accept", "application/json") - .addHeader("Authorization", "Bearer " + TOKEN).build(); - - HttpResponse deleteResponse = HttpResponse.builder().statusCode(200) - .payload(payloadFromResource("/operation.json")).build(); - - NetworkApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE), - TOKEN_RESPONSE, delete, deleteResponse).getNetworkApiForProject("myproject"); - - assertEquals(api.delete("jclouds-test"), - new ParseOperationTest().expected()); - } - - public void testDeleteNetworkResponseIs4xx() { - HttpRequest delete = HttpRequest - .builder() - .method("DELETE") - .endpoint("https://www.googleapis" + - ".com/compute/v1beta13/projects/myproject/networks/jclouds-test") - .addHeader("Accept", "application/json") - .addHeader("Authorization", "Bearer " + TOKEN).build(); - - HttpResponse deleteResponse = HttpResponse.builder().statusCode(404).build(); - - NetworkApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE), - TOKEN_RESPONSE, delete, deleteResponse).getNetworkApiForProject("myproject"); - - assertNull(api.delete("jclouds-test")); - } - - public void testListNetworksResponseIs2xx() { - HttpRequest list = HttpRequest - .builder() - .method("GET") - .endpoint("https://www.googleapis" + - ".com/compute/v1beta13/projects/myproject/networks") - .addHeader("Accept", "application/json") - .addHeader("Authorization", "Bearer " + TOKEN).build(); - - HttpResponse operationResponse = HttpResponse.builder().statusCode(200) - .payload(payloadFromResource("/network_list.json")).build(); - - NetworkApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE), - TOKEN_RESPONSE, list, operationResponse).getNetworkApiForProject("myproject"); - - assertEquals(api.listFirstPage().toString(), - new ParseNetworkListTest().expected().toString()); - } - - public void testListNetworksResponseIs4xx() { - HttpRequest list = HttpRequest - .builder() - .method("GET") - .endpoint("https://www.googleapis" + - ".com/compute/v1beta13/projects/myproject/networks") - .addHeader("Accept", "application/json") - .addHeader("Authorization", "Bearer " + TOKEN).build(); - - HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build(); - - NetworkApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE), - TOKEN_RESPONSE, list, operationResponse).getNetworkApiForProject("myproject"); - - assertTrue(api.list().concat().isEmpty()); - } -} diff --git a/labs/google-compute/src/test/java/org/jclouds/googlecompute/features/NetworkApiLiveTest.java b/labs/google-compute/src/test/java/org/jclouds/googlecompute/features/NetworkApiLiveTest.java deleted file mode 100644 index f55ebb3292..0000000000 --- a/labs/google-compute/src/test/java/org/jclouds/googlecompute/features/NetworkApiLiveTest.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.googlecompute.features; - -import com.google.common.collect.Iterables; -import com.google.common.collect.Lists; -import org.jclouds.collect.PagedIterable; -import org.jclouds.googlecompute.domain.Network; -import org.jclouds.googlecompute.internal.BaseGoogleComputeApiLiveTest; -import org.jclouds.googlecompute.options.ListOptions; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -import java.util.List; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; - -/** - * @author David Alves - */ -public class NetworkApiLiveTest extends BaseGoogleComputeApiLiveTest { - - private static final String NETWORK_NAME = "network-api-live-test-network"; - private static final String IPV4_RANGE = "10.0.0.0/8"; - private static final int TIME_WAIT = 10; - - @BeforeClass(groups = {"integration", "live"}) - public void setupContext() { - super.setupContext(); - } - - private NetworkApi api() { - return context.getApi().getNetworkApiForProject(getUserProject()); - } - - @Test(groups = "live") - public void testInsertNetwork() { - - assertOperationDoneSucessfully(api().createInIPv4Range(NETWORK_NAME, IPV4_RANGE), TIME_WAIT); - - } - - @Test(groups = "live", dependsOnMethods = "testInsertNetwork") - public void testGetNetwork() { - - Network network = api().get(NETWORK_NAME); - assertNotNull(network); - assertNetworkEquals(network); - } - - @Test(groups = "live", dependsOnMethods = "testGetNetwork") - public void testListNetwork() { - - PagedIterable networks = api().list(new ListOptions.Builder() - .filter("name eq " + NETWORK_NAME)); - - List networksAsList = Lists.newArrayList(networks.concat()); - - assertEquals(networksAsList.size(), 1); - - assertNetworkEquals(Iterables.getOnlyElement(networksAsList)); - - } - - @Test(groups = "live", dependsOnMethods = "testListNetwork") - public void testDeleteNetwork() { - - assertOperationDoneSucessfully(api().delete(NETWORK_NAME), TIME_WAIT); - } - - private void assertNetworkEquals(Network result) { - assertEquals(result.getName(), NETWORK_NAME); - assertEquals(result.getIPv4Range(), IPV4_RANGE); - } - -} diff --git a/labs/google-compute/src/test/java/org/jclouds/googlecompute/features/OperationApiExpectTest.java b/labs/google-compute/src/test/java/org/jclouds/googlecompute/features/OperationApiExpectTest.java deleted file mode 100644 index 16e77ea426..0000000000 --- a/labs/google-compute/src/test/java/org/jclouds/googlecompute/features/OperationApiExpectTest.java +++ /dev/null @@ -1,164 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.googlecompute.features; - -import org.jclouds.googlecompute.internal.BaseGoogleComputeApiExpectTest; -import org.jclouds.googlecompute.options.ListOptions; -import org.jclouds.googlecompute.parse.ParseOperationListTest; -import org.jclouds.googlecompute.parse.ParseOperationTest; -import org.jclouds.http.HttpRequest; -import org.jclouds.http.HttpResponse; -import org.testng.annotations.Test; - -import static org.jclouds.googlecompute.GoogleComputeConstants.COMPUTE_READONLY_SCOPE; -import static org.jclouds.googlecompute.GoogleComputeConstants.COMPUTE_SCOPE; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNull; -import static org.testng.Assert.assertTrue; - -/** - * @author David Alves - */ -@Test(groups = "unit") -public class OperationApiExpectTest extends BaseGoogleComputeApiExpectTest { - - private static final String OPERATIONS_URL_PREFIX = "https://www.googleapis" + - ".com/compute/v1beta13/projects/myproject/operations"; - - public static final HttpRequest GET_OPERATION_REQUEST = HttpRequest - .builder() - .method("GET") - .endpoint(OPERATIONS_URL_PREFIX + "/operation-1354084865060-4cf88735faeb8-bbbb12cb") - .addHeader("Accept", "application/json") - .addHeader("Authorization", "Bearer " + TOKEN).build(); - - public static final HttpResponse GET_OPERATION_RESPONSE = HttpResponse.builder().statusCode(200) - .payload(staticPayloadFromResource("/operation.json")).build(); - - public void testGetOperationResponseIs2xx() throws Exception { - - OperationApi operationApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE), - TOKEN_RESPONSE, GET_OPERATION_REQUEST, GET_OPERATION_RESPONSE).getOperationApiForProject("myproject"); - - assertEquals(operationApi.get("operation-1354084865060-4cf88735faeb8-bbbb12cb"), - new ParseOperationTest().expected()); - } - - public void testGetOperationResponseIs4xx() throws Exception { - - HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build(); - - OperationApi operationApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE), - TOKEN_RESPONSE, GET_OPERATION_REQUEST, operationResponse).getOperationApiForProject("myproject"); - - assertNull(operationApi.get("operation-1354084865060-4cf88735faeb8-bbbb12cb")); - } - - public void testDeleteOperationResponseIs2xx() throws Exception { - HttpRequest delete = HttpRequest - .builder() - .method("DELETE") - .endpoint(OPERATIONS_URL_PREFIX + "/operation-1352178598164-4cdcc9d031510-4aa46279") - .addHeader("Authorization", "Bearer " + TOKEN).build(); - - HttpResponse operationResponse = HttpResponse.builder().statusCode(204).build(); - - OperationApi operationApi = requestsSendResponses(requestForScopes(COMPUTE_SCOPE), - TOKEN_RESPONSE, delete, operationResponse).getOperationApiForProject("myproject"); - - operationApi.delete("operation-1352178598164-4cdcc9d031510-4aa46279"); - } - - public void testDeleteOperationResponseIs4xx() throws Exception { - HttpRequest delete = HttpRequest - .builder() - .method("DELETE") - .endpoint(OPERATIONS_URL_PREFIX + "/operation-1352178598164-4cdcc9d031510-4aa46279") - .addHeader("Authorization", "Bearer " + TOKEN).build(); - - HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build(); - - OperationApi operationApi = requestsSendResponses(requestForScopes(COMPUTE_SCOPE), - TOKEN_RESPONSE, delete, operationResponse).getOperationApiForProject("myproject"); - - operationApi.delete("operation-1352178598164-4cdcc9d031510-4aa46279"); - } - - public void testLisOperationWithNoOptionsResponseIs2xx() { - HttpRequest get = HttpRequest - .builder() - .method("GET") - .endpoint(OPERATIONS_URL_PREFIX) - .addHeader("Accept", "application/json") - .addHeader("Authorization", "Bearer " + TOKEN).build(); - - HttpResponse operationResponse = HttpResponse.builder().statusCode(200) - .payload(payloadFromResource("/operation_list.json")).build(); - - OperationApi operationApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE), - TOKEN_RESPONSE, get, operationResponse).getOperationApiForProject("myproject"); - - assertEquals(operationApi.listFirstPage().toString(), - new ParseOperationListTest().expected().toString()); - } - - public void testListOperationWithPaginationOptionsResponseIs2xx() { - HttpRequest get = HttpRequest - .builder() - .method("GET") - .endpoint(OPERATIONS_URL_PREFIX + - "?pageToken=CglPUEVSQVRJT04SOzU5MDQyMTQ4Nzg1Mi5vcG" + - "VyYXRpb24tMTM1MjI0NDI1ODAzMC00Y2RkYmU2YTJkNmIwLWVkMzIyMzQz&" + - "filter=" + - "status%20eq%20done&" + - "maxResults=3") - .addHeader("Accept", "application/json") - .addHeader("Authorization", "Bearer " + TOKEN).build(); - - HttpResponse operationResponse = HttpResponse.builder().statusCode(200) - .payload(payloadFromResource("/operation_list.json")).build(); - - OperationApi operationApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE), - TOKEN_RESPONSE, get, operationResponse).getOperationApiForProject("myproject"); - - assertEquals(operationApi.listAtMarker("CglPUEVSQVRJT04SOzU5MDQyMTQ4Nzg1Mi5vcGVyYXRpb24tMTM1Mj" + - "I0NDI1ODAzMC00Y2RkYmU2YTJkNmIwLWVkMzIyMzQz", - new ListOptions.Builder().filter("status eq done").maxResults(3)).toString(), - new ParseOperationListTest().expected().toString()); - } - - public void testListOperationWithPaginationOptionsResponseIs4xx() { - HttpRequest get = HttpRequest - .builder() - .method("GET") - .endpoint(OPERATIONS_URL_PREFIX) - .addHeader("Accept", "application/json") - .addHeader("Authorization", "Bearer " + TOKEN).build(); - - HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build(); - - OperationApi operationApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE), - TOKEN_RESPONSE, get, operationResponse).getOperationApiForProject("myproject"); - - assertTrue(operationApi.list().concat().isEmpty()); - } - - -} diff --git a/labs/google-compute/src/test/java/org/jclouds/googlecompute/features/OperationApiLiveTest.java b/labs/google-compute/src/test/java/org/jclouds/googlecompute/features/OperationApiLiveTest.java deleted file mode 100644 index a1e6c81196..0000000000 --- a/labs/google-compute/src/test/java/org/jclouds/googlecompute/features/OperationApiLiveTest.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.googlecompute.features; - -import com.google.common.base.Predicate; -import com.google.common.collect.Iterables; -import org.jclouds.collect.IterableWithMarker; -import org.jclouds.collect.PagedIterable; -import org.jclouds.googlecompute.domain.Operation; -import org.jclouds.googlecompute.internal.BaseGoogleComputeApiLiveTest; -import org.jclouds.googlecompute.options.ListOptions; -import org.testng.annotations.Test; - -import java.util.concurrent.atomic.AtomicInteger; - -import static org.jclouds.googlecompute.features.ProjectApiLiveTest.addItemToMetadata; -import static org.jclouds.googlecompute.features.ProjectApiLiveTest.deleteItemFromMetadata; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; - -/** - * @author David Alves - */ -public class OperationApiLiveTest extends BaseGoogleComputeApiLiveTest { - - private static final String METADATA_ITEM_KEY = "operationLiveTestTestProp"; - private static final String METADATA_ITEM_VALUE = "operationLiveTestTestValue"; - private Operation addOperation; - private Operation deleteOperation; - - private OperationApi api() { - return context.getApi().getOperationApiForProject(getUserProject()); - } - - - @Test(groups = "live") - public void testCreateOperations() { - //create some operations by adding and deleting metadata items - // this will make sure there is stuff to listFirstPage - addOperation = assertOperationDoneSucessfully(addItemToMetadata(context.getApi().getProjectApi(), - getUserProject(), METADATA_ITEM_KEY, METADATA_ITEM_VALUE), 20); - deleteOperation = assertOperationDoneSucessfully(deleteItemFromMetadata(context.getApi() - .getProjectApi(), getUserProject(), METADATA_ITEM_KEY), 20); - - assertNotNull(addOperation); - assertNotNull(deleteOperation); - } - - @Test(groups = "live", dependsOnMethods = "testCreateOperations") - public void testGetOperation() { - Operation operation = api().get(addOperation.getName()); - assertNotNull(operation); - assertOperationEquals(operation, this.addOperation); - } - - @Test(groups = "live", dependsOnMethods = "testCreateOperations") - public void testListOperationsWithFiltersAndPagination() { - PagedIterable operations = api().list(new ListOptions.Builder() - .filter("operationType eq setMetadata") - .maxResults(1)); - - // make sure that in spite of having only one result per page we get at least two results - final AtomicInteger counter = new AtomicInteger(); - operations.firstMatch(new Predicate>() { - - @Override - public boolean apply(IterableWithMarker input) { - counter.addAndGet(Iterables.size(input)); - return counter.get() == 2; - } - }); - } - - private void assertOperationEquals(Operation result, Operation expected) { - assertEquals(result.getName(), expected.getName()); - } - - -} diff --git a/labs/google-compute/src/test/java/org/jclouds/googlecompute/features/ProjectApiExpectTest.java b/labs/google-compute/src/test/java/org/jclouds/googlecompute/features/ProjectApiExpectTest.java deleted file mode 100644 index 04a829fca4..0000000000 --- a/labs/google-compute/src/test/java/org/jclouds/googlecompute/features/ProjectApiExpectTest.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.googlecompute.features; - -import org.jclouds.googlecompute.GoogleComputeConstants; -import org.jclouds.googlecompute.internal.BaseGoogleComputeApiExpectTest; -import org.jclouds.googlecompute.parse.ParseMetadataTest; -import org.jclouds.googlecompute.parse.ParseOperationTest; -import org.jclouds.googlecompute.parse.ParseProjectTest; -import org.jclouds.http.HttpRequest; -import org.jclouds.http.HttpResponse; -import org.testng.annotations.Test; - -import javax.ws.rs.core.MediaType; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNull; - - -/** - * @author David Alves - */ -@Test(groups = "unit") -public class ProjectApiExpectTest extends BaseGoogleComputeApiExpectTest { - - public static final String PROJECTS_URL_PREFIX = "https://www.googleapis.com/compute/v1beta13/projects"; - - public void testGetProjectResponseIs2xx() throws Exception { - HttpRequest getProjectRequest = HttpRequest - .builder() - .method("GET") - .endpoint(PROJECTS_URL_PREFIX + "/myproject") - .addHeader("Accept", "application/json") - .addHeader("Authorization", "Bearer " + TOKEN).build(); - - HttpResponse getProjectResponse = HttpResponse.builder().statusCode(200) - .payload(payloadFromResource("/project.json")).build(); - - ProjectApi api = requestsSendResponses(requestForScopes(GoogleComputeConstants.COMPUTE_READONLY_SCOPE), - TOKEN_RESPONSE, getProjectRequest, - getProjectResponse).getProjectApi(); - - assertEquals(api.get("myproject"), new ParseProjectTest().expected()); - } - - public void testGetProjectResponseIs4xx() throws Exception { - HttpRequest getProjectRequest = HttpRequest - .builder() - .method("GET") - .endpoint(PROJECTS_URL_PREFIX + "/myproject") - .addHeader("Accept", "application/json") - .addHeader("Authorization", "Bearer " + TOKEN).build(); - - HttpResponse getProjectResponse = HttpResponse.builder().statusCode(404).build(); - - ProjectApi api = requestsSendResponses(requestForScopes(GoogleComputeConstants.COMPUTE_READONLY_SCOPE), - TOKEN_RESPONSE, getProjectRequest, - getProjectResponse).getProjectApi(); - - assertNull(api.get("myproject")); - } - - public void testSetCommonInstanceMetadata() { - HttpRequest setMetadata = HttpRequest - .builder() - .method("POST") - .endpoint(PROJECTS_URL_PREFIX + "/myproject/setCommonInstanceMetadata") - .addHeader("Accept", "application/json") - .addHeader("Authorization", "Bearer " + TOKEN) - .payload(payloadFromResourceWithContentType("/metadata.json", MediaType.APPLICATION_JSON)) - .build(); - - HttpResponse setMetadataResponse = HttpResponse.builder().statusCode(200) - .payload(payloadFromResource("/operation.json")).build(); - - ProjectApi api = requestsSendResponses(requestForScopes(GoogleComputeConstants.COMPUTE_SCOPE), - TOKEN_RESPONSE, setMetadata, - setMetadataResponse).getProjectApi(); - - assertEquals(api.setCommonInstanceMetadata("myproject", new ParseMetadataTest().expected()), - new ParseOperationTest().expected()); - } - -} diff --git a/labs/google-compute/src/test/java/org/jclouds/googlecompute/features/ProjectApiLiveTest.java b/labs/google-compute/src/test/java/org/jclouds/googlecompute/features/ProjectApiLiveTest.java deleted file mode 100644 index 99bec90c67..0000000000 --- a/labs/google-compute/src/test/java/org/jclouds/googlecompute/features/ProjectApiLiveTest.java +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.googlecompute.features; - -/** - * @author David Alves - */ - -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.Maps; -import org.jclouds.googlecompute.domain.Operation; -import org.jclouds.googlecompute.domain.Project; -import org.jclouds.googlecompute.internal.BaseGoogleComputeApiLiveTest; -import org.testng.annotations.Test; - -import static com.google.common.base.Predicates.equalTo; -import static com.google.common.base.Predicates.not; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertNull; -import static org.testng.Assert.assertSame; -import static org.testng.Assert.assertTrue; - -/** - * @author David Alves - */ -public class ProjectApiLiveTest extends BaseGoogleComputeApiLiveTest { - - private static final String METADATA_ITEM_KEY = "projectLiveTestTestProp"; - private static final String METADATA_ITEM_VALUE = "projectLiveTestTestValue"; - - private ProjectApi projectApi() { - return context.getApi().getProjectApi(); - } - - private Project project; - private int initialMetadataSize; - - @Test(groups = "live") - public void testGetProjectWhenExists() { - this.project = projectApi().get(getUserProject()); - assertNotNull(project); - assertNotNull(project.getId()); - assertNotNull(project.getName()); - } - - @Test(groups = "live") - public void testGetProjectWhenNotExists() { - Project project = projectApi().get("momma"); - assertNull(project); - } - - @Test(groups = "live", dependsOnMethods = "testGetProjectWhenExists") - public void addItemToMetadata() { - this.initialMetadataSize = project.getCommonInstanceMetadata().size(); - assertOperationDoneSucessfully(addItemToMetadata(projectApi(), getUserProject(), METADATA_ITEM_KEY, - METADATA_ITEM_VALUE), 20); - this.project = projectApi().get(getUserProject()); - assertNotNull(project); - assertTrue(this.project.getCommonInstanceMetadata().containsKey(METADATA_ITEM_KEY), - this.project.toString()); - assertEquals(this.project.getCommonInstanceMetadata().get(METADATA_ITEM_KEY), - METADATA_ITEM_VALUE); - } - - @Test(groups = "live", dependsOnMethods = "addItemToMetadata") - public void testDeleteItemFromMetadata() { - assertOperationDoneSucessfully(deleteItemFromMetadata(projectApi(), getUserProject(), METADATA_ITEM_KEY), 20); - this.project = projectApi().get(getUserProject()); - assertNotNull(project); - assertFalse(project.getCommonInstanceMetadata().containsKey(METADATA_ITEM_KEY)); - assertSame(this.project.getCommonInstanceMetadata().size(), initialMetadataSize); - } - - /** - * Adds an item to the Project's metadata - *

- * Beyond it's use here it is also used as a cheap way of generating Operations to both test the OperationApi and - * the pagination system. - */ - public static Operation addItemToMetadata(ProjectApi projectApi, String projectName, String key, String value) { - Project project = projectApi.get(projectName); - assertNotNull(project); - ImmutableMap.Builder metadataBuilder = ImmutableMap.builder(); - metadataBuilder.putAll(project.getCommonInstanceMetadata()); - metadataBuilder.put(key, value); - return projectApi.setCommonInstanceMetadata(projectName, metadataBuilder.build()); - } - - /** - * Deletes an item from the Project's metadata - *

- * Beyond it's use here it is also used as a cheap way of generating Operation's to both test the OperationApi and - * the pagination system. - */ - public static Operation deleteItemFromMetadata(ProjectApi projectApi, String projectName, String key) { - Project project = projectApi.get(projectName); - assertNotNull(project); - ImmutableMap.Builder metadataBuilder = ImmutableMap.builder(); - metadataBuilder.putAll(Maps.filterKeys(project.getCommonInstanceMetadata(), not(equalTo(key)))); - return projectApi.setCommonInstanceMetadata(projectName, metadataBuilder.build()); - } - - -} diff --git a/labs/google-compute/src/test/java/org/jclouds/googlecompute/features/ZoneApiExpectTest.java b/labs/google-compute/src/test/java/org/jclouds/googlecompute/features/ZoneApiExpectTest.java deleted file mode 100644 index ddac2a6f38..0000000000 --- a/labs/google-compute/src/test/java/org/jclouds/googlecompute/features/ZoneApiExpectTest.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.googlecompute.features; - -import org.jclouds.googlecompute.internal.BaseGoogleComputeApiExpectTest; -import org.jclouds.googlecompute.parse.ParseZoneListTest; -import org.jclouds.googlecompute.parse.ParseZoneTest; -import org.jclouds.http.HttpRequest; -import org.jclouds.http.HttpResponse; -import org.testng.annotations.Test; - -import static org.jclouds.googlecompute.GoogleComputeConstants.COMPUTE_READONLY_SCOPE; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNull; -import static org.testng.Assert.assertTrue; - -/** - * @author David Alves - */ -@Test(groups = "unit") -public class ZoneApiExpectTest extends BaseGoogleComputeApiExpectTest { - - public static final String ZONES_URL_PREFIX = "https://www.googleapis.com/compute/v1beta13/projects/myproject/zones"; - - public static final HttpRequest GET_ZONE_REQ = HttpRequest - .builder() - .method("GET") - .endpoint(ZONES_URL_PREFIX + "/us-central1-a") - .addHeader("Accept", "application/json") - .addHeader("Authorization", "Bearer " + TOKEN).build(); - - public static final HttpRequest LIST_ZONES_REQ = HttpRequest - .builder() - .method("GET") - .endpoint(ZONES_URL_PREFIX) - .addHeader("Accept", "application/json") - .addHeader("Authorization", "Bearer " + TOKEN).build(); - - public static final HttpResponse LIST_ZONES_RESPONSE = HttpResponse.builder().statusCode(200) - .payload(staticPayloadFromResource("/zone_list.json")).build(); - - - public void testGetZoneResponseIs2xx() throws Exception { - - - HttpResponse operationResponse = HttpResponse.builder().statusCode(200) - .payload(payloadFromResource("/zone_get.json")).build(); - - ZoneApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE), - TOKEN_RESPONSE, GET_ZONE_REQ, operationResponse).getZoneApiForProject("myproject"); - - assertEquals(api.get("us-central1-a"), - new ParseZoneTest().expected()); - } - - public void testGetZoneResponseIs4xx() throws Exception { - - HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build(); - - ZoneApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE), - TOKEN_RESPONSE, GET_ZONE_REQ, operationResponse).getZoneApiForProject("myproject"); - - assertNull(api.get("us-central1-a")); - } - - public void testListZoneNoOptionsResponseIs2xx() throws Exception { - - ZoneApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE), - TOKEN_RESPONSE, LIST_ZONES_REQ, LIST_ZONES_RESPONSE).getZoneApiForProject("myproject"); - - assertEquals(api.listFirstPage().toString(), - new ParseZoneListTest().expected().toString()); - } - - public void testListZoneWithPaginationOptionsResponseIs4xx() { - - HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build(); - - ZoneApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE), - TOKEN_RESPONSE, LIST_ZONES_REQ, operationResponse).getZoneApiForProject("myproject"); - - assertTrue(api.list().concat().isEmpty()); - } -} diff --git a/labs/google-compute/src/test/java/org/jclouds/googlecompute/features/ZoneApiLiveTest.java b/labs/google-compute/src/test/java/org/jclouds/googlecompute/features/ZoneApiLiveTest.java deleted file mode 100644 index 6e7b95688c..0000000000 --- a/labs/google-compute/src/test/java/org/jclouds/googlecompute/features/ZoneApiLiveTest.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.googlecompute.features; - -import com.google.common.collect.Iterables; -import com.google.common.collect.Lists; -import org.jclouds.collect.IterableWithMarker; -import org.jclouds.collect.PagedIterable; -import org.jclouds.googlecompute.domain.Zone; -import org.jclouds.googlecompute.internal.BaseGoogleComputeApiLiveTest; -import org.jclouds.googlecompute.options.ListOptions; -import org.testng.annotations.Test; - -import java.util.Iterator; -import java.util.List; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertSame; -import static org.testng.Assert.assertTrue; - -/** - * @author David Alves - */ -public class ZoneApiLiveTest extends BaseGoogleComputeApiLiveTest { - - private Zone zone; - - private ZoneApi api() { - return context.getApi().getZoneApiForProject(getUserProject()); - } - - @Test(groups = "live") - public void testListZone() { - - PagedIterable zones = api().list(new ListOptions.Builder() - .maxResults(1)); - - Iterator> pageIterator = zones.iterator(); - assertTrue(pageIterator.hasNext()); - - IterableWithMarker singlePageIterator = pageIterator.next(); - List zoneAsList = Lists.newArrayList(singlePageIterator); - - assertSame(zoneAsList.size(), 1); - - this.zone = Iterables.getOnlyElement(zoneAsList); - } - - - @Test(groups = "live", dependsOnMethods = "testListZone") - public void testGetZone() { - Zone zone = api().get(this.zone.getName()); - assertNotNull(zone); - assertZoneEquals(zone, this.zone); - } - - private void assertZoneEquals(Zone result, Zone expected) { - assertEquals(result.getName(), expected.getName()); - } - -} diff --git a/labs/google-compute/src/test/java/org/jclouds/googlecompute/handlers/GoogleComputeErrorHandlerTest.java b/labs/google-compute/src/test/java/org/jclouds/googlecompute/handlers/GoogleComputeErrorHandlerTest.java deleted file mode 100644 index 1fb6d7b799..0000000000 --- a/labs/google-compute/src/test/java/org/jclouds/googlecompute/handlers/GoogleComputeErrorHandlerTest.java +++ /dev/null @@ -1,97 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.googlecompute.handlers; - -import org.easymock.IArgumentMatcher; -import org.jclouds.http.HttpCommand; -import org.jclouds.http.HttpRequest; -import org.jclouds.http.HttpResponse; -import org.testng.annotations.Test; - -import java.net.URI; - -import static org.easymock.EasyMock.createMock; -import static org.easymock.EasyMock.expect; -import static org.easymock.EasyMock.replay; -import static org.easymock.EasyMock.reportMatcher; -import static org.easymock.EasyMock.verify; - -/** - * @author Adrian Cole - */ -@Test(groups = "unit", testName = "GoogleComputeErrorHandlerTest") -public class GoogleComputeErrorHandlerTest { - - @Test - public void test409MakesIllegalStateException() { - assertCodeMakes( - "POST", - URI.create("https://www.googleapis.com/compute/v1beta13"), - 409, - "HTTP/1.1 409 Conflict", - "\"{\"code\":\"InvalidState\",\"message\":\"An incompatible transition has already been queued for this" + - " resource\"}\"", - IllegalStateException.class); - } - - private void assertCodeMakes(String method, URI uri, int statusCode, String message, String content, - Class expected) { - assertCodeMakes(method, uri, statusCode, message, "application/json", content, expected); - } - - private void assertCodeMakes(String method, URI uri, int statusCode, String message, String contentType, - String content, Class expected) { - - GoogleComputeErrorHandler function = new GoogleComputeErrorHandler(); - - HttpCommand command = createMock(HttpCommand.class); - HttpRequest request = HttpRequest.builder().method(method).endpoint(uri).build(); - HttpResponse response = HttpResponse.builder().statusCode(statusCode).message(message).payload(content).build(); - response.getPayload().getContentMetadata().setContentType(contentType); - - expect(command.getCurrentRequest()).andReturn(request).atLeastOnce(); - command.setException(classEq(expected)); - - replay(command); - - function.handleError(command, response); - - verify(command); - } - - public static Exception classEq(final Class in) { - reportMatcher(new IArgumentMatcher() { - - @Override - public void appendTo(StringBuffer buffer) { - buffer.append("classEq("); - buffer.append(in); - buffer.append(")"); - } - - @Override - public boolean matches(Object arg) { - return arg.getClass() == in; - } - - }); - return null; - } - -} diff --git a/labs/google-compute/src/test/java/org/jclouds/googlecompute/internal/BaseGoogleComputeApiExpectTest.java b/labs/google-compute/src/test/java/org/jclouds/googlecompute/internal/BaseGoogleComputeApiExpectTest.java deleted file mode 100644 index 2c552e33b5..0000000000 --- a/labs/google-compute/src/test/java/org/jclouds/googlecompute/internal/BaseGoogleComputeApiExpectTest.java +++ /dev/null @@ -1,36 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.googlecompute.internal; - -import org.jclouds.googlecompute.GoogleComputeApi; - -import java.util.Properties; - -/** - * @author Adrian Cole - */ -public class BaseGoogleComputeApiExpectTest extends BaseGoogleComputeExpectTest { - - @Override - protected Properties setupProperties() { - Properties properties = super.setupProperties(); - properties.put("google-compute.identity", "myproject"); - return properties; - } -} diff --git a/labs/google-compute/src/test/java/org/jclouds/googlecompute/internal/BaseGoogleComputeApiLiveTest.java b/labs/google-compute/src/test/java/org/jclouds/googlecompute/internal/BaseGoogleComputeApiLiveTest.java deleted file mode 100644 index 0e0dfe0639..0000000000 --- a/labs/google-compute/src/test/java/org/jclouds/googlecompute/internal/BaseGoogleComputeApiLiveTest.java +++ /dev/null @@ -1,136 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.googlecompute.internal; - -import com.google.common.base.Predicate; -import com.google.common.base.Supplier; -import com.google.common.reflect.TypeToken; -import com.google.inject.Key; -import com.google.inject.TypeLiteral; -import org.jclouds.apis.BaseContextLiveTest; -import org.jclouds.googlecompute.GoogleComputeApi; -import org.jclouds.googlecompute.GoogleComputeApiMetadata; -import org.jclouds.googlecompute.GoogleComputeAsyncApi; -import org.jclouds.googlecompute.config.UserProject; -import org.jclouds.googlecompute.domain.Operation; -import org.jclouds.oauth.v2.OAuthTestUtils; -import org.jclouds.rest.RestContext; - -import java.net.URI; -import java.util.Properties; -import java.util.concurrent.atomic.AtomicReference; - -import static java.util.concurrent.TimeUnit.SECONDS; -import static org.jclouds.util.Predicates2.retry; -import static org.testng.Assert.assertEquals; -import static org.testng.AssertJUnit.assertTrue; - - -/** - * @author David Alves - */ -public class BaseGoogleComputeApiLiveTest extends BaseContextLiveTest> { - - protected static final String API_URL_PREFIX = "https://www.googleapis.com/compute/v1beta13/projects/"; - protected static final String ZONE_API_URL_SUFFIX = "/zones/"; - protected static final String DEFAULT_ZONE_NAME = "us-central1-a"; - - protected static final String NETWORK_API_URL_SUFFIX = "/networks/"; - protected static final String DEFAULT_NETWORK_NAME = "live-test-network"; - - protected static final String MACHINE_TYPE_API_URL_SUFFIX = "/machineTypes/"; - protected static final String DEFAULT_MACHINE_TYPE_NAME = "n1-standard-1"; - - protected static final String GOOGLE_PROJECT = "google"; - - - public BaseGoogleComputeApiLiveTest() { - provider = "google-compute"; - } - - @Override - protected Properties setupProperties() { - Properties properties = super.setupProperties(); - OAuthTestUtils.setCredentialFromPemFile(properties, "google-compute.credential"); - return properties; - } - - @Override - protected TypeToken> contextType() { - return GoogleComputeApiMetadata.CONTEXT_TOKEN; - } - - protected String getUserProject() { - return context.utils().injector().getInstance(Key.get(new TypeLiteral>() { - }, UserProject.class)).get(); - } - - protected Predicate> getOperationDonePredicate() { - return context.utils().getInjector().getInstance(Key.get(new TypeLiteral>> - () {})); - } - - protected Operation assertOperationDoneSucessfully(Operation operation, long maxWaitSeconds) { - operation = waitOperationDone(operation, maxWaitSeconds); - assertEquals(operation.getStatus(), Operation.Status.DONE); - assertTrue(operation.getErrors().isEmpty()); - return operation; - } - - protected Operation waitOperationDone(Operation operation, long maxWaitSeconds) { - return waitOperationDone(getOperationDonePredicate(), operation, maxWaitSeconds); - } - - protected URI getDefaultZoneUrl(String project) { - return getZoneUrl(project, DEFAULT_ZONE_NAME); - } - - protected URI getZoneUrl(String project, String zone) { - return URI.create(API_URL_PREFIX + project + ZONE_API_URL_SUFFIX + zone); - } - - protected URI getDefaultNetworkUrl(String project) { - return getNetworkUrl(project, DEFAULT_NETWORK_NAME); - } - - protected URI getNetworkUrl(String project, String network) { - return URI.create(API_URL_PREFIX + project + NETWORK_API_URL_SUFFIX + network); - } - - protected URI getDefaultMachineTypekUrl(String project) { - return gettMachineTypeUrl(project, DEFAULT_MACHINE_TYPE_NAME); - } - - protected URI gettMachineTypeUrl(String project, String machineType) { - return URI.create(API_URL_PREFIX + project + MACHINE_TYPE_API_URL_SUFFIX + machineType); - } - - protected URI getDiskUrl(String project, String diskName) { - return URI.create(API_URL_PREFIX + project + "/disks/" + diskName); - } - - protected static Operation waitOperationDone(Predicate> operationDonePredicate, - Operation operation, long maxWaitSeconds) { - AtomicReference operationReference = new AtomicReference(operation); - retry(operationDonePredicate, maxWaitSeconds, 1, SECONDS).apply(operationReference); - return operationReference.get(); - } -} - diff --git a/labs/google-compute/src/test/java/org/jclouds/googlecompute/internal/BaseGoogleComputeAsyncApiExpectTest.java b/labs/google-compute/src/test/java/org/jclouds/googlecompute/internal/BaseGoogleComputeAsyncApiExpectTest.java deleted file mode 100644 index ae928afd2e..0000000000 --- a/labs/google-compute/src/test/java/org/jclouds/googlecompute/internal/BaseGoogleComputeAsyncApiExpectTest.java +++ /dev/null @@ -1,36 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.googlecompute.internal; - -import com.google.common.base.Function; -import com.google.inject.Module; -import org.jclouds.googlecompute.GoogleComputeAsyncApi; -import org.jclouds.http.HttpRequest; -import org.jclouds.http.HttpResponse; - -import java.util.Properties; - -/** - * @author Adrian Cole - */ -public class BaseGoogleComputeAsyncApiExpectTest extends BaseGoogleComputeExpectTest { - public GoogleComputeAsyncApi createClient(Function fn, Module module, Properties props) { - return createInjector(fn, module, props).getInstance(GoogleComputeAsyncApi.class); - } -} diff --git a/labs/google-compute/src/test/java/org/jclouds/googlecompute/internal/BaseGoogleComputeExpectTest.java b/labs/google-compute/src/test/java/org/jclouds/googlecompute/internal/BaseGoogleComputeExpectTest.java deleted file mode 100644 index 68f17b0480..0000000000 --- a/labs/google-compute/src/test/java/org/jclouds/googlecompute/internal/BaseGoogleComputeExpectTest.java +++ /dev/null @@ -1,191 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.googlecompute.internal; - -import com.google.common.base.Joiner; -import com.google.common.base.Supplier; -import com.google.common.base.Ticker; -import com.google.inject.Binder; -import com.google.inject.Module; -import com.google.inject.TypeLiteral; -import org.jclouds.collect.PagedIterable; -import org.jclouds.collect.PagedIterables; -import org.jclouds.crypto.Crypto; -import org.jclouds.googlecompute.domain.ListPage; -import org.jclouds.http.HttpRequest; -import org.jclouds.http.HttpResponse; -import org.jclouds.io.Payload; -import org.jclouds.oauth.v2.OAuthConstants; -import org.jclouds.rest.internal.BaseRestApiExpectTest; -import org.jclouds.ssh.SshKeys; -import org.jclouds.util.Strings2; - -import javax.ws.rs.core.MediaType; -import java.io.IOException; -import java.net.URI; -import java.security.KeyFactory; -import java.security.KeyPair; -import java.security.KeyPairGenerator; -import java.security.NoSuchAlgorithmException; -import java.security.PrivateKey; -import java.security.PublicKey; -import java.security.SecureRandom; -import java.security.interfaces.RSAPublicKey; -import java.security.spec.InvalidKeySpecException; -import java.util.Properties; -import java.util.concurrent.atomic.AtomicInteger; - -import static com.google.common.base.Charsets.UTF_8; -import static com.google.common.base.Throwables.propagate; -import static com.google.common.io.BaseEncoding.base64Url; -import static org.easymock.EasyMock.createMock; -import static org.easymock.EasyMock.expect; -import static org.easymock.EasyMock.expectLastCall; -import static org.easymock.EasyMock.replay; -import static org.jclouds.crypto.Pems.privateKeySpec; -import static org.jclouds.crypto.Pems.publicKeySpec; -import static org.jclouds.crypto.PemsTest.PRIVATE_KEY; -import static org.jclouds.crypto.PemsTest.PUBLIC_KEY; -import static org.jclouds.io.Payloads.newStringPayload; - -/** - * @author Adrian Cole - */ -public class BaseGoogleComputeExpectTest extends BaseRestApiExpectTest { - - private static final String header = "{\"alg\":\"none\",\"typ\":\"JWT\"}"; - - private static final String CLAIMS_TEMPLATE = "{" + - "\"iss\":\"myproject\"," + - "\"scope\":\"%s\"," + - "\"aud\":\"https://accounts.google.com/o/oauth2/token\"," + - "\"exp\":3600," + - "\"iat\":0}"; - - protected static final String TOKEN = "1/8xbJqaOZXSUZbHLl5EOtu1pxz3fmmetKx9W8CV4t79M"; - - protected static final HttpResponse TOKEN_RESPONSE = HttpResponse.builder().statusCode(200).payload( - payloadFromString("{\n" + - " \"access_token\" : \"" + TOKEN + "\",\n" + - " \"token_type\" : \"Bearer\",\n" + - " \"expires_in\" : 3600\n" + - "}")).build(); - - protected String openSshKey; - - - public BaseGoogleComputeExpectTest() { - provider = "google-compute"; - } - - @Override - protected Module createModule() { - - - return new Module() { - @Override - public void configure(Binder binder) { - // predictable time - binder.bind(Ticker.class).toInstance(new Ticker() { - @Override - public long read() { - return 0; - } - }); - try { - KeyFactory keyfactory = KeyFactory.getInstance("RSA"); - PrivateKey privateKey = keyfactory.generatePrivate(privateKeySpec(newStringPayload - (PRIVATE_KEY))); - PublicKey publicKey = keyfactory.generatePublic(publicKeySpec(newStringPayload(PUBLIC_KEY))); - KeyPair keyPair = new KeyPair(publicKey, privateKey); - openSshKey = SshKeys.encodeAsOpenSSH(RSAPublicKey.class.cast(publicKey)); - final Crypto crypto = createMock(Crypto.class); - KeyPairGenerator rsaKeyPairGenerator = createMock(KeyPairGenerator.class); - final SecureRandom secureRandom = createMock(SecureRandom.class); - expect(crypto.rsaKeyPairGenerator()).andReturn(rsaKeyPairGenerator).anyTimes(); - rsaKeyPairGenerator.initialize(2048, secureRandom); - expectLastCall().anyTimes(); - expect(rsaKeyPairGenerator.genKeyPair()).andReturn(keyPair).anyTimes(); - replay(crypto, rsaKeyPairGenerator, secureRandom); - binder.bind(Crypto.class).toInstance(crypto); - binder.bind(SecureRandom.class).toInstance(secureRandom); - } catch (NoSuchAlgorithmException e) { - propagate(e); - } catch (InvalidKeySpecException e) { - propagate(e); - } catch (IOException e) { - propagate(e); - } - // predictable node names - final AtomicInteger suffix = new AtomicInteger(); - binder.bind(new TypeLiteral>() { - }).toInstance(new Supplier() { - @Override - public String get() { - return suffix.getAndIncrement() + ""; - } - }); - } - }; - } - - @Override - protected Properties setupProperties() { - Properties props = super.setupProperties(); - // use no sig algorithm for expect tests (means no credential is required either) - props.put("jclouds.oauth.signature-or-mac-algorithm", OAuthConstants.NO_ALGORITHM); - return props; - } - - protected HttpRequest requestForScopes(String... scopes) { - String claims = String.format(CLAIMS_TEMPLATE, Joiner.on(",").join(scopes)); - - String payload = "grant_type=urn%3Aietf%3Aparams%3Aoauth%3Agrant-type%3Ajwt-bearer&" + - // Base64 Encoded Header - "assertion=" + base64Url().omitPadding().encode(header.getBytes(UTF_8)) + "." + - // Base64 Encoded Claims - base64Url().omitPadding().encode(claims.getBytes(UTF_8)) + "."; - - return HttpRequest.builder() - .method("POST") - .endpoint(URI.create("https://accounts.google.com/o/oauth2/token")) - .addHeader("Accept", MediaType.APPLICATION_JSON) - .payload(payloadFromStringWithContentType(payload, "application/x-www-form-urlencoded")) - .build(); - } - - /** - * Parse tests don't apply @Transform so we need to apply the transformation to PagedIterable on the result of - * expected() - */ - protected PagedIterable toPagedIterable(ListPage list) { - return PagedIterables.of(list); - } - - protected static Payload staticPayloadFromResource(String resource) { - try { - return payloadFromString(Strings2.toStringAndClose(BaseGoogleComputeExpectTest.class.getResourceAsStream - (resource))); - } catch (IOException e) { - throw propagate(e); - } - } - - -} diff --git a/labs/google-compute/src/test/java/org/jclouds/googlecompute/internal/BaseGoogleComputeParseTest.java b/labs/google-compute/src/test/java/org/jclouds/googlecompute/internal/BaseGoogleComputeParseTest.java deleted file mode 100644 index b6f1657a07..0000000000 --- a/labs/google-compute/src/test/java/org/jclouds/googlecompute/internal/BaseGoogleComputeParseTest.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.googlecompute.internal; - -import com.google.inject.Guice; -import com.google.inject.Injector; -import org.jclouds.googlecompute.config.GoogleComputeParserModule; -import org.jclouds.json.BaseItemParserTest; -import org.jclouds.json.config.GsonModule; - -/** - * @author David Alves - */ -public abstract class BaseGoogleComputeParseTest extends BaseItemParserTest { - - @Override - protected Injector injector() { - return Guice.createInjector(new GsonModule(), new GoogleComputeParserModule()); - } - -} diff --git a/labs/google-compute/src/test/java/org/jclouds/googlecompute/internal/BaseGoogleComputeServiceContextExpectTest.java b/labs/google-compute/src/test/java/org/jclouds/googlecompute/internal/BaseGoogleComputeServiceContextExpectTest.java deleted file mode 100644 index 2474fbdc64..0000000000 --- a/labs/google-compute/src/test/java/org/jclouds/googlecompute/internal/BaseGoogleComputeServiceContextExpectTest.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.googlecompute.internal; - -import com.google.common.base.Function; -import com.google.inject.Module; -import org.jclouds.apis.ApiMetadata; -import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.googlecompute.GoogleComputeApiMetadata; -import org.jclouds.http.HttpRequest; -import org.jclouds.http.HttpResponse; - -import java.util.Properties; - -/** - * @author David Alves - */ -public abstract class BaseGoogleComputeServiceContextExpectTest extends BaseGoogleComputeExpectTest implements - Function { - - - @Override - public T createClient(Function fn, Module module, Properties props) { - return apply(createComputeServiceContext(fn, module, props)); - } - - private ComputeServiceContext createComputeServiceContext(Function fn, Module module, - Properties props) { - return createInjector(fn, module, props).getInstance(ComputeServiceContext.class); - } - - @Override - protected ApiMetadata createApiMetadata() { - return new GoogleComputeApiMetadata(); - } - -} diff --git a/labs/google-compute/src/test/java/org/jclouds/googlecompute/internal/BaseGoogleComputeServiceExpectTest.java b/labs/google-compute/src/test/java/org/jclouds/googlecompute/internal/BaseGoogleComputeServiceExpectTest.java deleted file mode 100644 index 156879da18..0000000000 --- a/labs/google-compute/src/test/java/org/jclouds/googlecompute/internal/BaseGoogleComputeServiceExpectTest.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.googlecompute.internal; - -import org.jclouds.compute.ComputeService; -import org.jclouds.compute.ComputeServiceContext; - -/** - * @author David Alves - */ -public class BaseGoogleComputeServiceExpectTest extends BaseGoogleComputeServiceContextExpectTest { - - @Override - public ComputeService apply(ComputeServiceContext input) { - return input.getComputeService(); - } -} diff --git a/labs/google-compute/src/test/java/org/jclouds/googlecompute/parse/ParseDiskListTest.java b/labs/google-compute/src/test/java/org/jclouds/googlecompute/parse/ParseDiskListTest.java deleted file mode 100644 index c18ada4cec..0000000000 --- a/labs/google-compute/src/test/java/org/jclouds/googlecompute/parse/ParseDiskListTest.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.googlecompute.parse; - -import com.google.common.collect.ImmutableSet; -import org.jclouds.date.internal.SimpleDateFormatDateService; -import org.jclouds.googlecompute.domain.Disk; -import org.jclouds.googlecompute.domain.ListPage; -import org.jclouds.googlecompute.domain.Resource; -import org.jclouds.googlecompute.internal.BaseGoogleComputeParseTest; -import org.testng.annotations.Test; - -import javax.ws.rs.Consumes; -import javax.ws.rs.core.MediaType; -import java.net.URI; - -/** - * @author David Alves - */ -@Test(groups = "unit") -public class ParseDiskListTest extends BaseGoogleComputeParseTest> { - - @Override - public String resource() { - return "/disk_list.json"; - } - - @Override - @Consumes(MediaType.APPLICATION_JSON) - public ListPage expected() { - return ListPage.builder() - .kind(Resource.Kind.DISK_LIST) - .id("projects/myproject/disks") - .selfLink(URI.create("https://www.googleapis.com/compute/v1beta13/projects/myproject/disks")) - .items(ImmutableSet.of(Disk.builder() - .id("13050421646334304115") - .creationTimestamp(new SimpleDateFormatDateService().iso8601DateParse("2012-11-25T01:38:48.306")) - .selfLink(URI.create("https://www.googleapis" + - ".com/compute/v1beta13/projects/myproject/disks/testimage1")) - .name("testimage1") - .sizeGb(1) - .zone(URI.create("https://www.googleapis" + - ".com/compute/v1beta13/projects/myproject/zones/us-central1-a")) - .status("READY") - .build()) - ).build(); - } -} diff --git a/labs/google-compute/src/test/java/org/jclouds/googlecompute/parse/ParseDiskTest.java b/labs/google-compute/src/test/java/org/jclouds/googlecompute/parse/ParseDiskTest.java deleted file mode 100644 index 3cd38d1e66..0000000000 --- a/labs/google-compute/src/test/java/org/jclouds/googlecompute/parse/ParseDiskTest.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.googlecompute.parse; - -import org.jclouds.date.internal.SimpleDateFormatDateService; -import org.jclouds.googlecompute.domain.Disk; -import org.jclouds.googlecompute.internal.BaseGoogleComputeParseTest; -import org.testng.annotations.Test; - -import javax.ws.rs.Consumes; -import javax.ws.rs.core.MediaType; -import java.net.URI; - -/** - * @author David Alves - */ -@Test(groups = "unit") -public class ParseDiskTest extends BaseGoogleComputeParseTest { - - @Override - public String resource() { - return "/disk_get.json"; - } - - @Override - @Consumes(MediaType.APPLICATION_JSON) - public Disk expected() { - return Disk.builder() - .id("13050421646334304115") - .creationTimestamp(new SimpleDateFormatDateService().iso8601DateParse("2012-11-25T01:38:48.306")) - .selfLink(URI.create("https://www.googleapis.com/compute/v1beta13/projects/myproject/disks/testimage1")) - .name("testimage1") - .sizeGb(1) - .zone(URI.create("https://www.googleapis.com/compute/v1beta13/projects/myproject/zones/us-central1-a")) - .status("READY") - .build(); - } -} diff --git a/labs/google-compute/src/test/java/org/jclouds/googlecompute/parse/ParseFirewallListTest.java b/labs/google-compute/src/test/java/org/jclouds/googlecompute/parse/ParseFirewallListTest.java deleted file mode 100644 index 4daf4d6736..0000000000 --- a/labs/google-compute/src/test/java/org/jclouds/googlecompute/parse/ParseFirewallListTest.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.googlecompute.parse; - -import com.google.common.collect.ImmutableSet; -import org.jclouds.date.internal.SimpleDateFormatDateService; -import org.jclouds.googlecompute.domain.Firewall; -import org.jclouds.googlecompute.domain.ListPage; -import org.jclouds.googlecompute.domain.Resource; -import org.jclouds.googlecompute.internal.BaseGoogleComputeParseTest; -import org.testng.annotations.Test; - -import javax.ws.rs.Consumes; -import javax.ws.rs.core.MediaType; -import java.net.URI; - -/** - * @author David Alves - */ -@Test(groups = "unit") -public class ParseFirewallListTest extends BaseGoogleComputeParseTest> { - - @Override - public String resource() { - return "/firewall_list.json"; - } - - @Override - @Consumes(MediaType.APPLICATION_JSON) - public ListPage expected() { - return ListPage.builder() - .kind(Resource.Kind.FIREWALL_LIST) - .id("projects/google/firewalls") - .selfLink(URI.create("https://www.googleapis.com/compute/v1beta13/projects/google/firewalls")) - .items(ImmutableSet.of( - new ParseFirewallTest().expected() - , Firewall.builder() - .id("12862241067393040785") - .creationTimestamp(new SimpleDateFormatDateService().iso8601DateParse("2012-04-13T03:05:04.365")) - .selfLink(URI.create("https://www.googleapis" + - ".com/compute/v1beta13/projects/google/firewalls/default-ssh")) - .name("default-ssh") - .description("SSH allowed from anywhere") - .network(URI.create("https://www.googleapis" + - ".com/compute/v1beta13/projects/google/networks/default")) - .addSourceRange("0.0.0.0/0") - .addAllowed(Firewall.Rule.builder() - .IPProtocol(Firewall.Rule.IPProtocol.TCP) - .addPort(22).build()) - .build() - )) - .build(); - } -} diff --git a/labs/google-compute/src/test/java/org/jclouds/googlecompute/parse/ParseFirewallTest.java b/labs/google-compute/src/test/java/org/jclouds/googlecompute/parse/ParseFirewallTest.java deleted file mode 100644 index e3e3a4910d..0000000000 --- a/labs/google-compute/src/test/java/org/jclouds/googlecompute/parse/ParseFirewallTest.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.googlecompute.parse; - -import org.jclouds.date.internal.SimpleDateFormatDateService; -import org.jclouds.googlecompute.domain.Firewall; -import org.jclouds.googlecompute.internal.BaseGoogleComputeParseTest; -import org.testng.annotations.Test; - -import javax.ws.rs.Consumes; -import javax.ws.rs.core.MediaType; -import java.net.URI; - -import static org.jclouds.googlecompute.domain.Firewall.Rule.IPProtocol; - -/** - * @author David Alves - */ -@Test(groups = "unit") -public class ParseFirewallTest extends BaseGoogleComputeParseTest { - - @Override - public String resource() { - return "/firewall_get.json"; - } - - @Override - @Consumes(MediaType.APPLICATION_JSON) - public Firewall expected() { - return Firewall.builder() - .id("12862241031274216284") - .creationTimestamp(new SimpleDateFormatDateService().iso8601DateParse("2012-04-13T03:05:02.855")) - .selfLink(URI.create("https://www.googleapis.com/compute/v1beta13/projects/myproject/firewalls/jclouds-test")) - .name("jclouds-test") - .description("Internal traffic from default allowed") - .network(URI.create("https://www.googleapis.com/compute/v1beta13/projects/myproject/networks/jclouds-test")) - .addSourceRange("10.0.0.0/8") - .addAllowed(Firewall.Rule.builder() - .IPProtocol(IPProtocol.TCP) - .addPortRange(1, 65535).build()) - .addAllowed(Firewall.Rule.builder() - .IPProtocol(IPProtocol.UDP) - .addPortRange(1, 65535).build()) - .addAllowed(Firewall.Rule.builder() - .IPProtocol(IPProtocol.ICMP).build()) - .build(); - - } -} diff --git a/labs/google-compute/src/test/java/org/jclouds/googlecompute/parse/ParseImageListTest.java b/labs/google-compute/src/test/java/org/jclouds/googlecompute/parse/ParseImageListTest.java deleted file mode 100644 index 6350c67b88..0000000000 --- a/labs/google-compute/src/test/java/org/jclouds/googlecompute/parse/ParseImageListTest.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.googlecompute.parse; - -import com.google.common.collect.ImmutableSet; -import org.jclouds.date.internal.SimpleDateFormatDateService; -import org.jclouds.googlecompute.domain.Image; -import org.jclouds.googlecompute.domain.ListPage; -import org.jclouds.googlecompute.domain.Resource; -import org.jclouds.googlecompute.internal.BaseGoogleComputeParseTest; -import org.testng.annotations.Test; - -import javax.ws.rs.Consumes; -import javax.ws.rs.core.MediaType; -import java.net.URI; - -/** - * @author David Alves - */ -@Test(groups = "unit") -public class ParseImageListTest extends BaseGoogleComputeParseTest> { - - @Override - public String resource() { - return "/image_list.json"; - } - - @Override - @Consumes(MediaType.APPLICATION_JSON) - public ListPage expected() { - return ListPage.builder() - .kind(Resource.Kind.IMAGE_LIST) - .id("projects/google/images") - .selfLink(URI.create("https://www.googleapis.com/compute/v1beta13/projects/google/images")) - .items(ImmutableSet.of(Image.builder() - .id("12941197498378735318") - .creationTimestamp(new SimpleDateFormatDateService().iso8601DateParse("2012-07-16T22:16:13.468")) - .selfLink(URI.create("https://www.googleapis" + - ".com/compute/v1beta13/projects/google/images/centos-6-2-v20120326")) - .name("centos-6-2-v20120326") - .description("DEPRECATED. CentOS 6.2 image; Created Mon, 26 Mar 2012 21:19:09 +0000") - .sourceType("RAW") - .preferredKernel(URI.create("https://www.googleapis" + - ".com/compute/v1beta13/projects/google/kernels/gce-20120326")) - .rawDisk( - Image.RawDisk.builder() - .source("") - .containerType("TAR") - .build() - ).build() - - )) - .build(); - } -} \ No newline at end of file diff --git a/labs/google-compute/src/test/java/org/jclouds/googlecompute/parse/ParseImageTest.java b/labs/google-compute/src/test/java/org/jclouds/googlecompute/parse/ParseImageTest.java deleted file mode 100644 index 4f25eb18d0..0000000000 --- a/labs/google-compute/src/test/java/org/jclouds/googlecompute/parse/ParseImageTest.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.googlecompute.parse; - -import org.jclouds.date.internal.SimpleDateFormatDateService; -import org.jclouds.googlecompute.domain.Image; -import org.jclouds.googlecompute.internal.BaseGoogleComputeParseTest; -import org.testng.annotations.Test; - -import javax.ws.rs.Consumes; -import javax.ws.rs.core.MediaType; -import java.net.URI; - -/** - * @author David Alves - */ -@Test(groups = "unit") -public class ParseImageTest extends BaseGoogleComputeParseTest { - - @Override - public String resource() { - return "/image_get.json"; - } - - @Override - @Consumes(MediaType.APPLICATION_JSON) - public Image expected() { - return Image.builder() - .id("12941197498378735318") - .creationTimestamp(new SimpleDateFormatDateService().iso8601DateParse("2012-07-16T22:16:13.468")) - .selfLink(URI.create("https://www.googleapis.com/compute/v1beta13/projects/google/images/centos-6-2" + - "-v20120326")) - .name("centos-6-2-v20120326") - .description("DEPRECATED. CentOS 6.2 image; Created Mon, 26 Mar 2012 21:19:09 +0000") - .sourceType("RAW") - .preferredKernel(URI.create("https://www.googleapis" + - ".com/compute/v1beta13/projects/google/kernels/gce-20120326")) - .rawDisk( - Image.RawDisk.builder() - .source("") - .containerType("TAR") - .build() - ).build(); - } -} diff --git a/labs/google-compute/src/test/java/org/jclouds/googlecompute/parse/ParseInstanceListTest.java b/labs/google-compute/src/test/java/org/jclouds/googlecompute/parse/ParseInstanceListTest.java deleted file mode 100644 index 0d3d046c2a..0000000000 --- a/labs/google-compute/src/test/java/org/jclouds/googlecompute/parse/ParseInstanceListTest.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.googlecompute.parse; - -import com.google.common.collect.ImmutableSet; -import org.jclouds.googlecompute.domain.Instance; -import org.jclouds.googlecompute.domain.ListPage; -import org.jclouds.googlecompute.domain.Resource; -import org.jclouds.googlecompute.internal.BaseGoogleComputeParseTest; - -import javax.ws.rs.Consumes; -import javax.ws.rs.core.MediaType; -import java.net.URI; - -/** - * @author David Alves - */ -public class ParseInstanceListTest extends BaseGoogleComputeParseTest> { - - @Override - public String resource() { - return "/instance_list.json"; - } - - @Override - @Consumes(MediaType.APPLICATION_JSON) - public ListPage expected() { - return ListPage.builder() - .kind(Resource.Kind.INSTANCE_LIST) - .id("projects/myproject/instances") - .selfLink(URI.create("https://www.googleapis.com/compute/v1beta13/projects/myproject/instances")) - .items(ImmutableSet.of(new ParseInstanceTest().expected())) - .build(); - } -} diff --git a/labs/google-compute/src/test/java/org/jclouds/googlecompute/parse/ParseInstanceSerialOutputTest.java b/labs/google-compute/src/test/java/org/jclouds/googlecompute/parse/ParseInstanceSerialOutputTest.java deleted file mode 100644 index c631f91f46..0000000000 --- a/labs/google-compute/src/test/java/org/jclouds/googlecompute/parse/ParseInstanceSerialOutputTest.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.googlecompute.parse; - -import org.jclouds.googlecompute.domain.Instance; -import org.jclouds.googlecompute.internal.BaseGoogleComputeParseTest; - -import javax.ws.rs.Consumes; -import javax.ws.rs.core.MediaType; - -/** - * @author David Alves - */ -public class ParseInstanceSerialOutputTest extends BaseGoogleComputeParseTest { - - @Override - public String resource() { - return "/instance_serial_port.json"; - } - - @Override - @Consumes(MediaType.APPLICATION_JSON) - public Instance.SerialPortOutput expected() { - return Instance.SerialPortOutput.builder() - .contents("console output").build(); - } -} \ No newline at end of file diff --git a/labs/google-compute/src/test/java/org/jclouds/googlecompute/parse/ParseInstanceTest.java b/labs/google-compute/src/test/java/org/jclouds/googlecompute/parse/ParseInstanceTest.java deleted file mode 100644 index 71195dfdad..0000000000 --- a/labs/google-compute/src/test/java/org/jclouds/googlecompute/parse/ParseInstanceTest.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.googlecompute.parse; - -import com.google.common.collect.ImmutableMap; -import org.jclouds.date.internal.SimpleDateFormatDateService; -import org.jclouds.googlecompute.domain.Instance; -import org.jclouds.googlecompute.internal.BaseGoogleComputeParseTest; - -import javax.ws.rs.Consumes; -import javax.ws.rs.core.MediaType; -import java.net.URI; - -/** - * @author David Alves - */ -public class ParseInstanceTest extends BaseGoogleComputeParseTest { - - @Override - public String resource() { - return "/instance_get.json"; - } - - @Override - @Consumes(MediaType.APPLICATION_JSON) - public Instance expected() { - return Instance.builder() - .id("13051190678907570425") - .creationTimestamp(new SimpleDateFormatDateService().iso8601DateParse("2012-11-25T23:48:20.758")) - .selfLink(URI.create("https://www.googleapis" + - ".com/compute/v1beta13/projects/myproject/instances/test-0")) - .description("desc") - .name("test-0") - .image(URI.create("https://www.googleapis" + - ".com/compute/v1beta13/projects/google/images/gcel-12-04-v20121106")) - .machineType(URI.create("https://www.googleapis.com/compute/v1beta13/projects/myproject/machineTypes/n1" + - "-standard-1")) - .status(Instance.Status.RUNNING) - .zone(URI.create("https://www.googleapis.com/compute/v1beta13/projects/myproject/zones/us-central1-a")) - .addNetworkInterface( - Instance.NetworkInterface.builder() - .name("nic0") - .networkIP("10.240.121.115") - .network(URI.create("https://www.googleapis" + - ".com/compute/v1beta13/projects/myproject/networks/default")) - .build() - ) - .addDisk( - Instance.PersistentAttachedDisk.builder() - .index(0) - .mode(Instance.PersistentAttachedDisk.Mode.READ_WRITE) - .deviceName("test") - .source(URI.create("https://www.googleapis" + - ".com/compute/v1beta13/projects/myproject/disks/test")) - .build() - ) - .addTag("aTag") - .metadata(ImmutableMap.of("aKey", "aValue")) - .addServiceAccount(Instance.ServiceAccount.builder().email("default").addScopes("myscope").build()) - .build(); - } -} diff --git a/labs/google-compute/src/test/java/org/jclouds/googlecompute/parse/ParseKernelListTest.java b/labs/google-compute/src/test/java/org/jclouds/googlecompute/parse/ParseKernelListTest.java deleted file mode 100644 index 28099a5d16..0000000000 --- a/labs/google-compute/src/test/java/org/jclouds/googlecompute/parse/ParseKernelListTest.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.googlecompute.parse; - -import com.google.common.collect.ImmutableSet; -import org.jclouds.date.internal.SimpleDateFormatDateService; -import org.jclouds.googlecompute.domain.Kernel; -import org.jclouds.googlecompute.domain.ListPage; -import org.jclouds.googlecompute.domain.Resource; -import org.jclouds.googlecompute.internal.BaseGoogleComputeParseTest; -import org.testng.annotations.Test; - -import javax.ws.rs.Consumes; -import javax.ws.rs.core.MediaType; -import java.net.URI; - -/** - * @author David Alves - */ -@Test(groups = "unit") -public class ParseKernelListTest extends BaseGoogleComputeParseTest> { - - @Override - public String resource() { - return "/kernel_list.json"; - } - - @Override - @Consumes(MediaType.APPLICATION_JSON) - public ListPage expected() { - return ListPage.builder() - .kind(Resource.Kind.KERNEL_LIST) - .id("projects/google/kernels") - .selfLink(URI.create("https://www.googleapis.com/compute/v1beta13/projects/google/kernels")) - .items(ImmutableSet.of( - Kernel.builder() - .id("12941177846308850718") - .creationTimestamp(new SimpleDateFormatDateService().iso8601DateParse - ("2012-07-16T21:42:16.950")) - .selfLink(URI.create("https://www.googleapis" + - ".com/compute/v1beta13/projects/google/kernels/gce-20110524")) - .name("gce-20110524") - .description("DEPRECATED. Created Tue, 24 May 2011 00:48:22 +0000").build(), - Kernel.builder() - .id("12941177983348179280") - .creationTimestamp(new SimpleDateFormatDateService().iso8601DateParse - ("2012-07-16T21:42:31.166")) - .selfLink(URI.create("https://www.googleapis" + - ".com/compute/v1beta13/projects/google/kernels/gce-20110728")) - .name("gce-20110728") - .description("DEPRECATED. Created Thu, 28 Jul 2011 16:44:38 +0000").build() - )).build(); - } -} diff --git a/labs/google-compute/src/test/java/org/jclouds/googlecompute/parse/ParseKernelTest.java b/labs/google-compute/src/test/java/org/jclouds/googlecompute/parse/ParseKernelTest.java deleted file mode 100644 index ee61479e4e..0000000000 --- a/labs/google-compute/src/test/java/org/jclouds/googlecompute/parse/ParseKernelTest.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.googlecompute.parse; - -import org.jclouds.date.internal.SimpleDateFormatDateService; -import org.jclouds.googlecompute.domain.Kernel; -import org.jclouds.googlecompute.internal.BaseGoogleComputeParseTest; -import org.testng.annotations.Test; - -import javax.ws.rs.Consumes; -import javax.ws.rs.core.MediaType; -import java.net.URI; - -/** - * @author David Alves - */ -@Test(groups = "unit") -public class ParseKernelTest extends BaseGoogleComputeParseTest { - - @Override - public String resource() { - return "/kernel.json"; - } - - @Override - @Consumes(MediaType.APPLICATION_JSON) - public Kernel expected() { - return Kernel.builder() - .id("12941177846308850718") - .creationTimestamp(new SimpleDateFormatDateService().iso8601DateParse("2012-07-16T21:42:16.950")) - .selfLink(URI.create("https://www.googleapis.com/compute/v1beta13/projects/google/kernels/gce-20110524")) - .name("gce-20110524") - .description("DEPRECATED. Created Tue, 24 May 2011 00:48:22 +0000") - .build(); - } -} diff --git a/labs/google-compute/src/test/java/org/jclouds/googlecompute/parse/ParseMachineTypeListTest.java b/labs/google-compute/src/test/java/org/jclouds/googlecompute/parse/ParseMachineTypeListTest.java deleted file mode 100644 index d3bc60e1be..0000000000 --- a/labs/google-compute/src/test/java/org/jclouds/googlecompute/parse/ParseMachineTypeListTest.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.googlecompute.parse; - -import org.jclouds.date.internal.SimpleDateFormatDateService; -import org.jclouds.googlecompute.domain.ListPage; -import org.jclouds.googlecompute.domain.MachineType; -import org.jclouds.googlecompute.internal.BaseGoogleComputeParseTest; - -import javax.ws.rs.Consumes; -import javax.ws.rs.core.MediaType; -import java.net.URI; - -import static org.jclouds.googlecompute.domain.Resource.Kind.MACHINE_TYPE_LIST; - -/** - * @author David Alves - */ -public class ParseMachineTypeListTest extends BaseGoogleComputeParseTest> { - - - @Override - public String resource() { - return "/machinetype_list.json"; - } - - @Override - @Consumes(MediaType.APPLICATION_JSON) - public ListPage expected() { - SimpleDateFormatDateService dateService = new SimpleDateFormatDateService(); - return ListPage.builder() - .kind(MACHINE_TYPE_LIST) - .id("projects/myproject/machineTypes") - .selfLink(URI.create("https://www.googleapis.com/compute/v1beta13/projects/myproject/machineTypes")) - .addItem(MachineType.builder() - .id("12907738072351752276") - .creationTimestamp(dateService.iso8601DateParse("2012-06-07T20:48:14.670")) - .selfLink(URI.create("https://www.googleapis" + - ".com/compute/v1beta13/projects/myproject/machineTypes/n1-standard-1")) - .name("n1-standard-1") - .description("1 vCPU, 3.75 GB RAM, and a 10 GB ephemeral root disk") - .guestCpus(1) - .memoryMb(3840) - .imageSpaceGb(10) - .maximumPersistentDisks(16) - .maximumPersistentDisksSizeGb(128) - .build()) - .addItem(MachineType.builder() - .id("12908560709887590691") - .creationTimestamp(dateService.iso8601DateParse("2012-06-07T20:51:19.936")) - .selfLink(URI.create("https://www.googleapis" + - ".com/compute/v1beta13/projects/myproject/machineTypes/n1-standard-8-d")) - .name("n1-standard-8-d") - .description("8 vCPUs, 30 GB RAM, a 10 GB ephemeral root disk, " + - "and 2 extra 1770 GB ephemeral disks") - .guestCpus(8) - .memoryMb(30720) - .imageSpaceGb(10) - .addEphemeralDisk(1770) - .addEphemeralDisk(1770) - .maximumPersistentDisks(16) - .maximumPersistentDisksSizeGb(1024) - .build()) - .build(); - } -} diff --git a/labs/google-compute/src/test/java/org/jclouds/googlecompute/parse/ParseMachineTypeTest.java b/labs/google-compute/src/test/java/org/jclouds/googlecompute/parse/ParseMachineTypeTest.java deleted file mode 100644 index 6a999f29f7..0000000000 --- a/labs/google-compute/src/test/java/org/jclouds/googlecompute/parse/ParseMachineTypeTest.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.googlecompute.parse; - -import org.jclouds.date.internal.SimpleDateFormatDateService; -import org.jclouds.googlecompute.domain.MachineType; -import org.jclouds.googlecompute.internal.BaseGoogleComputeParseTest; - -import javax.ws.rs.Consumes; -import javax.ws.rs.core.MediaType; -import java.net.URI; - -/** - * @author David Alves - */ -public class ParseMachineTypeTest extends BaseGoogleComputeParseTest { - - - @Override - public String resource() { - return "/machinetype.json"; - } - - @Override - @Consumes(MediaType.APPLICATION_JSON) - public MachineType expected() { - SimpleDateFormatDateService dateService = new SimpleDateFormatDateService(); - return MachineType.builder() - .id("12907738072351752276") - .creationTimestamp(dateService.iso8601DateParse("2012-06-07T20:48:14.670")) - .selfLink(URI.create("https://www.googleapis.com/compute/v1beta13/projects/myproject/machineTypes/n1" + - "-standard-1")) - .name("n1-standard-1") - .description("1 vCPU, 3.75 GB RAM, and a 10 GB ephemeral root disk") - .guestCpus(1) - .memoryMb(3840) - .imageSpaceGb(10) - .addEphemeralDisk(1770) - .addEphemeralDisk(1770) - .maximumPersistentDisks(16) - .maximumPersistentDisksSizeGb(128) - .build(); - } -} diff --git a/labs/google-compute/src/test/java/org/jclouds/googlecompute/parse/ParseMetadataTest.java b/labs/google-compute/src/test/java/org/jclouds/googlecompute/parse/ParseMetadataTest.java deleted file mode 100644 index 3dcbc272b5..0000000000 --- a/labs/google-compute/src/test/java/org/jclouds/googlecompute/parse/ParseMetadataTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.googlecompute.parse; - -import com.google.common.collect.ImmutableMap; -import org.jclouds.googlecompute.config.GoogleComputeParserModule; -import org.jclouds.googlecompute.internal.BaseGoogleComputeParseTest; -import org.testng.annotations.Test; - -import javax.ws.rs.Consumes; -import javax.ws.rs.core.MediaType; - -/** - * @author David Alves - */ -@Test(groups = "unit") -public class ParseMetadataTest extends BaseGoogleComputeParseTest { - - @Override - public String resource() { - return "/metadata.json"; - } - - @Override - @Consumes(MediaType.APPLICATION_JSON) - public GoogleComputeParserModule.Metadata expected() { - return new GoogleComputeParserModule.Metadata( - ImmutableMap.builder() - .put("propA", "valueA") - .put("propB", "valueB") - .build()); - } -} diff --git a/labs/google-compute/src/test/java/org/jclouds/googlecompute/parse/ParseNetworkListTest.java b/labs/google-compute/src/test/java/org/jclouds/googlecompute/parse/ParseNetworkListTest.java deleted file mode 100644 index b14c6980c3..0000000000 --- a/labs/google-compute/src/test/java/org/jclouds/googlecompute/parse/ParseNetworkListTest.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.googlecompute.parse; - -import com.google.common.collect.ImmutableSet; -import org.jclouds.googlecompute.domain.ListPage; -import org.jclouds.googlecompute.domain.Network; -import org.jclouds.googlecompute.domain.Resource; -import org.jclouds.googlecompute.internal.BaseGoogleComputeParseTest; - -import javax.ws.rs.Consumes; -import javax.ws.rs.core.MediaType; -import java.net.URI; - -/** - * @author David Alves - */ -public class ParseNetworkListTest extends BaseGoogleComputeParseTest> { - - @Override - public String resource() { - return "/network_list.json"; - } - - @Override - @Consumes(MediaType.APPLICATION_JSON) - public ListPage expected() { - return ListPage.builder() - .kind(Resource.Kind.NETWORK_LIST) - .id("projects/myproject/networks") - .selfLink(URI.create("https://www.googleapis.com/compute/v1beta13/projects/myproject/networks")) - .items(ImmutableSet.of(new ParseNetworkTest().expected())) - .build(); - - } -} diff --git a/labs/google-compute/src/test/java/org/jclouds/googlecompute/parse/ParseNetworkTest.java b/labs/google-compute/src/test/java/org/jclouds/googlecompute/parse/ParseNetworkTest.java deleted file mode 100644 index 7a7634abd2..0000000000 --- a/labs/google-compute/src/test/java/org/jclouds/googlecompute/parse/ParseNetworkTest.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.googlecompute.parse; - -import org.jclouds.date.internal.SimpleDateFormatDateService; -import org.jclouds.googlecompute.domain.Network; -import org.jclouds.googlecompute.internal.BaseGoogleComputeParseTest; - -import javax.ws.rs.Consumes; -import javax.ws.rs.core.MediaType; -import java.net.URI; - -/** - * @author David Alves - */ -public class ParseNetworkTest extends BaseGoogleComputeParseTest { - - @Override - public String resource() { - return "/network_get.json"; - } - - @Override - @Consumes(MediaType.APPLICATION_JSON) - public Network expected() { - return Network.builder() - .id("13024414170909937976") - .creationTimestamp(new SimpleDateFormatDateService().iso8601DateParse("2012-10-24T20:13:19.967")) - .selfLink(URI.create("https://www.googleapis.com/compute/v1beta13/projects/myproject/networks/jclouds-test")) - .name("default") - .description("Default network for the project") - .IPv4Range("10.0.0.0/8") - .gatewayIPv4("10.0.0.1") - .build(); - } -} diff --git a/labs/google-compute/src/test/java/org/jclouds/googlecompute/parse/ParseOperationListTest.java b/labs/google-compute/src/test/java/org/jclouds/googlecompute/parse/ParseOperationListTest.java deleted file mode 100644 index 6eb41578f3..0000000000 --- a/labs/google-compute/src/test/java/org/jclouds/googlecompute/parse/ParseOperationListTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.googlecompute.parse; - -import org.jclouds.googlecompute.domain.ListPage; -import org.jclouds.googlecompute.domain.Operation; -import org.jclouds.googlecompute.domain.Resource; -import org.jclouds.googlecompute.internal.BaseGoogleComputeParseTest; - -import javax.ws.rs.Consumes; -import javax.ws.rs.core.MediaType; -import java.net.URI; - -/** - * @author David Alves - */ -public class ParseOperationListTest extends BaseGoogleComputeParseTest> { - - @Override - public String resource() { - return "/operation_list.json"; - } - - @Override - @Consumes(MediaType.APPLICATION_JSON) - public ListPage expected() { - return ListPage.builder() - .kind(Resource.Kind.OPERATION_LIST) - .id("projects/myproject/operations") - .selfLink(URI.create("https://www.googleapis.com/compute/v1beta13/projects/myproject/operations")) - .addItem(new ParseOperationTest().expected()) - .build(); - } -} diff --git a/labs/google-compute/src/test/java/org/jclouds/googlecompute/parse/ParseOperationTest.java b/labs/google-compute/src/test/java/org/jclouds/googlecompute/parse/ParseOperationTest.java deleted file mode 100644 index 5908481d4e..0000000000 --- a/labs/google-compute/src/test/java/org/jclouds/googlecompute/parse/ParseOperationTest.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.googlecompute.parse; - -import org.jclouds.date.internal.SimpleDateFormatDateService; -import org.jclouds.googlecompute.domain.Operation; -import org.jclouds.googlecompute.internal.BaseGoogleComputeParseTest; -import org.testng.annotations.Test; - -import javax.ws.rs.Consumes; -import javax.ws.rs.core.MediaType; -import java.net.URI; - -/** - * @author David Alves - */ -@Test(groups = "unit") -public class ParseOperationTest extends BaseGoogleComputeParseTest { - - @Override - public String resource() { - return "/operation.json"; - } - - @Override - @Consumes(MediaType.APPLICATION_JSON) - public Operation expected() { - SimpleDateFormatDateService dateService = new SimpleDateFormatDateService(); - return Operation.builder().id("13053095055850848306") - .selfLink(URI.create("https://www.googleapis" + - ".com/compute/v1beta13/projects/myproject/operations/operation-1354084865060-4cf88735faeb8" + - "-bbbb12cb")) - .name("operation-1354084865060-4cf88735faeb8-bbbb12cb") - .targetLink(URI.create("https://www.googleapis" + - ".com/compute/v1beta13/projects/myproject/instances/instance-api-live" + - "-test-instance")) - .targetId("13053094017547040099") - .status(Operation.Status.DONE) - .user("user@developer.gserviceaccount.com") - .progress(100) - .insertTime(dateService.iso8601DateParse("2012-11-28T06:41:05.060")) - .startTime(dateService.iso8601DateParse("2012-11-28T06:41:05.142")) - .endTime(dateService.iso8601DateParse("2012-11-28T06:41:06.142")) - .operationType("insert") - .build(); - } -} diff --git a/labs/google-compute/src/test/java/org/jclouds/googlecompute/parse/ParseProjectTest.java b/labs/google-compute/src/test/java/org/jclouds/googlecompute/parse/ParseProjectTest.java deleted file mode 100644 index 922db730fe..0000000000 --- a/labs/google-compute/src/test/java/org/jclouds/googlecompute/parse/ParseProjectTest.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.googlecompute.parse; - -import com.google.common.collect.ImmutableMap; -import org.jclouds.googlecompute.domain.Project; -import org.jclouds.googlecompute.internal.BaseGoogleComputeParseTest; -import org.testng.annotations.Test; - -import javax.ws.rs.Consumes; -import javax.ws.rs.core.MediaType; -import java.net.URI; -import java.util.Date; - -/** - * @author David Alves - */ -@Test(groups = "unit") -public class ParseProjectTest extends BaseGoogleComputeParseTest { - - @Override - public String resource() { - return "/project.json"; - } - - @Override - @Consumes(MediaType.APPLICATION_JSON) - public Project expected() { - return Project.builder() - .id("13024414184846275913") - .creationTimestamp(new Date(Long.parseLong("1351109596252"))) - .selfLink(URI.create("https://www.googleapis.com/compute/v1beta13/projects/myproject")) - .name("myproject") - .description("") - .commonInstanceMetadata( - ImmutableMap.builder() - .put("propA", "valueA") - .put("propB", "valueB") - .build()) - .addQuota("INSTANCES", 0, 8) - .addQuota("CPUS", 0, 8) - .addQuota("EPHEMERAL_ADDRESSES", 0, 8) - .addQuota("DISKS", 0, 8) - .addQuota("DISKS_TOTAL_GB", 0, 100) - .addQuota("SNAPSHOTS", 0, 1000) - .addQuota("NETWORKS", 1, 5) - .addQuota("FIREWALLS", 2, 100) - .addQuota("IMAGES", 0, 100) - .build(); - } -} diff --git a/labs/google-compute/src/test/java/org/jclouds/googlecompute/parse/ParseQuotaTest.java b/labs/google-compute/src/test/java/org/jclouds/googlecompute/parse/ParseQuotaTest.java deleted file mode 100644 index b8fa1c1000..0000000000 --- a/labs/google-compute/src/test/java/org/jclouds/googlecompute/parse/ParseQuotaTest.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.googlecompute.parse; - -import org.jclouds.googlecompute.domain.Project; -import org.jclouds.googlecompute.internal.BaseGoogleComputeParseTest; -import org.testng.annotations.Test; - -import javax.ws.rs.Consumes; -import javax.ws.rs.core.MediaType; - -/** - * @author David Alves - */ -@Test(groups = "unit") -public class ParseQuotaTest extends BaseGoogleComputeParseTest { - - @Override - public String resource() { - return "/quota.json"; - } - - @Override - @Consumes(MediaType.APPLICATION_JSON) - public Project.Quota expected() { - return Project.Quota.builder().metric("INSTANCES").usage(0.0).limit(8.0).build(); - } -} diff --git a/labs/google-compute/src/test/java/org/jclouds/googlecompute/parse/ParseZoneListTest.java b/labs/google-compute/src/test/java/org/jclouds/googlecompute/parse/ParseZoneListTest.java deleted file mode 100644 index fe1777882b..0000000000 --- a/labs/google-compute/src/test/java/org/jclouds/googlecompute/parse/ParseZoneListTest.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.googlecompute.parse; - -import com.google.common.collect.ImmutableSet; -import org.jclouds.date.internal.SimpleDateFormatDateService; -import org.jclouds.googlecompute.domain.ListPage; -import org.jclouds.googlecompute.domain.Resource; -import org.jclouds.googlecompute.domain.Zone; -import org.jclouds.googlecompute.internal.BaseGoogleComputeParseTest; -import org.testng.annotations.Test; - -import javax.ws.rs.Consumes; -import javax.ws.rs.core.MediaType; -import java.net.URI; - -/** - * @author David Alves - */ -@Test(groups = "unit") -public class ParseZoneListTest extends BaseGoogleComputeParseTest> { - - @Override - public String resource() { - return "/zone_list.json"; - } - - @Override - @Consumes(MediaType.APPLICATION_JSON) - public ListPage expected() { - return ListPage.builder() - .kind(Resource.Kind.ZONE_LIST) - .id("projects/myproject/zones") - .selfLink(URI.create("https://www.googleapis.com/compute/v1beta13/projects/myproject/zones")) - .items(ImmutableSet.of( - new ParseZoneTest().expected() - , Zone.builder() - .id("13024414164050619686") - .creationTimestamp(new SimpleDateFormatDateService().iso8601DateParse - ("2012-10-24T20:13:19.271")) - .selfLink(URI.create("https://www.googleapis" + - ".com/compute/v1beta13/projects/myproject/zones/us-east1-a")) - .name("us-east1-a") - .description("us-east1-a") - .status(Zone.Status.UP) - .addMaintenanceWindow(Zone.MaintenanceWindow.builder() - .name("2013-02-17-planned-outage") - .description("maintenance zone") - .beginTime(new SimpleDateFormatDateService().iso8601DateParse - ("2013-02-17T08:00:00.000")) - .endTime(new SimpleDateFormatDateService().iso8601DateParse - ("2013-03-03T08:00:00.000")) - .build()) - .build())) - .build(); - } -} diff --git a/labs/google-compute/src/test/java/org/jclouds/googlecompute/parse/ParseZoneTest.java b/labs/google-compute/src/test/java/org/jclouds/googlecompute/parse/ParseZoneTest.java deleted file mode 100644 index ffdd6643e3..0000000000 --- a/labs/google-compute/src/test/java/org/jclouds/googlecompute/parse/ParseZoneTest.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.googlecompute.parse; - -import org.jclouds.date.internal.SimpleDateFormatDateService; -import org.jclouds.googlecompute.domain.Zone; -import org.jclouds.googlecompute.internal.BaseGoogleComputeParseTest; -import org.testng.annotations.Test; - -import javax.ws.rs.Consumes; -import javax.ws.rs.core.MediaType; -import java.net.URI; - -/** - * @author David Alves - */ -@Test(groups = "unit") -public class ParseZoneTest extends BaseGoogleComputeParseTest { - - @Override - public String resource() { - return "/zone_get.json"; - } - - @Override - @Consumes(MediaType.APPLICATION_JSON) - public Zone expected() { - return Zone.builder() - .id("13020128040171887099") - .creationTimestamp(new SimpleDateFormatDateService().iso8601DateParse("2012-10-19T16:42:54.131")) - .selfLink(URI.create("https://www.googleapis.com/compute/v1beta13/projects/myproject/zones/us-central1-a")) - .name("us-central1-a") - .description("us-central1-a") - .status(Zone.Status.DOWN) - .addMaintenanceWindow(Zone.MaintenanceWindow.builder() - .name("2012-11-10-planned-outage") - .description("maintenance zone") - .beginTime(new SimpleDateFormatDateService().iso8601DateParse("2012-11-10T20:00:00.000")) - .endTime(new SimpleDateFormatDateService().iso8601DateParse("2012-12-02T20:00:00.000")) - .build()) - .build(); - } -} diff --git a/labs/google-compute/src/test/resources/disk_get.json b/labs/google-compute/src/test/resources/disk_get.json deleted file mode 100644 index 5c7ce0c251..0000000000 --- a/labs/google-compute/src/test/resources/disk_get.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "kind": "compute#disk", - "id": "13050421646334304115", - "creationTimestamp": "2012-11-25T01:38:48.306", - "selfLink": "https://www.googleapis.com/compute/v1beta13/projects/myproject/disks/testimage1", - "name": "testimage1", - "sizeGb": "1", - "zone": "https://www.googleapis.com/compute/v1beta13/projects/myproject/zones/us-central1-a", - "status": "READY" -} \ No newline at end of file diff --git a/labs/google-compute/src/test/resources/disk_insert.json b/labs/google-compute/src/test/resources/disk_insert.json deleted file mode 100644 index 82522a7ef8..0000000000 --- a/labs/google-compute/src/test/resources/disk_insert.json +++ /dev/null @@ -1 +0,0 @@ -{"name":"testimage1","sizeGb":1,"zone":"https://www.googleapis.com/compute/v1beta13/projects/myproject/zones/us-central1-a"} \ No newline at end of file diff --git a/labs/google-compute/src/test/resources/disk_list.json b/labs/google-compute/src/test/resources/disk_list.json deleted file mode 100644 index 8b09831d77..0000000000 --- a/labs/google-compute/src/test/resources/disk_list.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "kind": "compute#diskList", - "id": "projects/myproject/disks", - "selfLink": "https://www.googleapis.com/compute/v1beta13/projects/myproject/disks", - "items": [ - { - "kind": "compute#disk", - "id": "13050421646334304115", - "creationTimestamp": "2012-11-25T01:38:48.306", - "selfLink": "https://www.googleapis.com/compute/v1beta13/projects/myproject/disks/testimage1", - "name": "testimage1", - "sizeGb": "1", - "zone": "https://www.googleapis.com/compute/v1beta13/projects/myproject/zones/us-central1-a", - "status": "READY" - } - ] -} \ No newline at end of file diff --git a/labs/google-compute/src/test/resources/firewall_get.json b/labs/google-compute/src/test/resources/firewall_get.json deleted file mode 100644 index cb981dd295..0000000000 --- a/labs/google-compute/src/test/resources/firewall_get.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - - "kind": "compute#firewall", - "id": "12862241031274216284", - "creationTimestamp": "2012-04-13T03:05:02.855", - "selfLink": "https://www.googleapis.com/compute/v1beta13/projects/myproject/firewalls/jclouds-test", - "name": "jclouds-test", - "description": "Internal traffic from default allowed", - "network": "https://www.googleapis.com/compute/v1beta13/projects/myproject/networks/jclouds-test", - "sourceRanges": [ - "10.0.0.0/8" - ], - "allowed": [ - { - "IPProtocol": "tcp", - "ports": [ - "1-65535" - ] - }, - { - "IPProtocol": "udp", - "ports": [ - "1-65535" - ] - }, - { - "IPProtocol": "icmp" - } - ] -} \ No newline at end of file diff --git a/labs/google-compute/src/test/resources/firewall_insert.json b/labs/google-compute/src/test/resources/firewall_insert.json deleted file mode 100644 index 0f6ddfa6ab..0000000000 --- a/labs/google-compute/src/test/resources/firewall_insert.json +++ /dev/null @@ -1 +0,0 @@ -{"name":"%s","network":"https://www.googleapis.com/compute/v1beta13/projects/myproject/networks/%s","sourceRanges":[%s],"sourceTags":[%s],"targetTags":[%s],"allowed":[{"IPProtocol":"tcp","ports":[%s]}]} \ No newline at end of file diff --git a/labs/google-compute/src/test/resources/firewall_list.json b/labs/google-compute/src/test/resources/firewall_list.json deleted file mode 100644 index 3bb1b22588..0000000000 --- a/labs/google-compute/src/test/resources/firewall_list.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "kind": "compute#firewallList", - "id": "projects/google/firewalls", - "selfLink": "https://www.googleapis.com/compute/v1beta13/projects/google/firewalls", - "items": [ - { - - "kind": "compute#firewall", - "id": "12862241031274216284", - "creationTimestamp": "2012-04-13T03:05:02.855", - "selfLink": "https://www.googleapis.com/compute/v1beta13/projects/myproject/firewalls/jclouds-test", - "name": "jclouds-test", - "description": "Internal traffic from default allowed", - "network": "https://www.googleapis.com/compute/v1beta13/projects/myproject/networks/jclouds-test", - "sourceRanges": [ - "10.0.0.0/8" - ], - "allowed": [ - { - "IPProtocol": "tcp", - "ports": [ - "1-65535" - ] - }, - { - "IPProtocol": "udp", - "ports": [ - "1-65535" - ] - }, - { - "IPProtocol": "icmp" - } - ] - }, - { - - "kind": "compute#firewall", - "id": "12862241067393040785", - "creationTimestamp": "2012-04-13T03:05:04.365", - "selfLink": "https://www.googleapis.com/compute/v1beta13/projects/google/firewalls/default-ssh", - "name": "default-ssh", - "description": "SSH allowed from anywhere", - "network": "https://www.googleapis.com/compute/v1beta13/projects/google/networks/default", - "sourceRanges": [ - "0.0.0.0/0" - ], - "allowed": [ - { - "IPProtocol": "tcp", - "ports": [ - "22" - ] - } - ] - } - ] -} \ No newline at end of file diff --git a/labs/google-compute/src/test/resources/image_get.json b/labs/google-compute/src/test/resources/image_get.json deleted file mode 100644 index 79d358e9bc..0000000000 --- a/labs/google-compute/src/test/resources/image_get.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "kind": "compute#image", - "id": "12941197498378735318", - "creationTimestamp": "2012-07-16T22:16:13.468", - "selfLink": "https://www.googleapis.com/compute/v1beta13/projects/google/images/centos-6-2-v20120326", - "name": "centos-6-2-v20120326", - "description": "DEPRECATED. CentOS 6.2 image; Created Mon, 26 Mar 2012 21:19:09 +0000", - "sourceType": "RAW", - "preferredKernel": "https://www.googleapis.com/compute/v1beta13/projects/google/kernels/gce-20120326", - "rawDisk": { - "source": "", - "containerType": "TAR" - } -} \ No newline at end of file diff --git a/labs/google-compute/src/test/resources/image_insert.json b/labs/google-compute/src/test/resources/image_insert.json deleted file mode 100644 index 787ffde56d..0000000000 --- a/labs/google-compute/src/test/resources/image_insert.json +++ /dev/null @@ -1 +0,0 @@ -{"sourceType":"RAW","rawDisk":{"source":"https://storage.googleapis.com/mybuket/myimage.image.tar.gz","containerType":"TAR"},"kind":"compute#image","name":"myimage"} \ No newline at end of file diff --git a/labs/google-compute/src/test/resources/image_list.json b/labs/google-compute/src/test/resources/image_list.json deleted file mode 100644 index 6095b29b9a..0000000000 --- a/labs/google-compute/src/test/resources/image_list.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "kind": "compute#imageList", - "id": "projects/google/images", - "selfLink": "https://www.googleapis.com/compute/v1beta13/projects/google/images", - "items": [ - { - "kind": "compute#image", - "id": "12941197498378735318", - "creationTimestamp": "2012-07-16T22:16:13.468", - "selfLink": "https://www.googleapis.com/compute/v1beta13/projects/google/images/centos-6-2-v20120326", - "name": "centos-6-2-v20120326", - "description": "DEPRECATED. CentOS 6.2 image; Created Mon, 26 Mar 2012 21:19:09 +0000", - "sourceType": "RAW", - "preferredKernel": "https://www.googleapis.com/compute/v1beta13/projects/google/kernels/gce-20120326", - "rawDisk": { - "source": "", - "containerType": "TAR" - } - } - ] -} \ No newline at end of file diff --git a/labs/google-compute/src/test/resources/image_list_multiple_page_1.json b/labs/google-compute/src/test/resources/image_list_multiple_page_1.json deleted file mode 100644 index afb794c1c0..0000000000 --- a/labs/google-compute/src/test/resources/image_list_multiple_page_1.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "kind": "compute#imageList", - "id": "projects/google/images", - "selfLink": "https://www.googleapis.com/compute/v1beta13/projects/google/images", - "nextPageToken": "CgVJTUFHRRIbZ29vZ2xlLmNlbnRvcy02LTItdjIwMTIwNjIx", - "items": [ - { - "kind": "compute#image", - "id": "12941197498378735318", - "creationTimestamp": "2012-07-16T15:16:13.468-07:00", - "selfLink": "https://www.googleapis.com/compute/v1beta13/projects/google/images/centos-6-2-v20120326", - "name": "centos-6-2-v20120326", - "description": "DEPRECATED. CentOS 6.2 image; Created Mon, 26 Mar 2012 21:19:09 +0000", - "sourceType": "RAW", - "preferredKernel": "https://www.googleapis.com/compute/v1beta13/projects/google/kernels/gce-20120326", - "rawDisk": { - "source": "", - "containerType": "TAR" - } - }, - { - "kind": "compute#image", - "id": "12894486577628239762", - "creationTimestamp": "2012-05-21T13:15:37.215-07:00", - "selfLink": "https://www.googleapis.com/compute/v1beta13/projects/google/images/centos-6-2-v20120503", - "name": "centos-6-2-v20120503", - "description": "CentOS 6.2; Created Wed, 09 May 2012 11:55:54 +0000", - "sourceType": "RAW", - "preferredKernel": "https://www.googleapis.com/compute/v1beta13/projects/google/kernels/gce-20120326", - "rawDisk": { - "source": "", - "containerType": "TAR" - } - }, - { - "kind": "compute#image", - "id": "12917726455664967299", - "creationTimestamp": "2012-06-18T11:05:30.664-07:00", - "selfLink": "https://www.googleapis.com/compute/v1beta13/projects/google/images/centos-6-2-v20120611", - "name": "centos-6-2-v20120611", - "description": "CentOS 6.2; Created Mon, 11 Jun 2012 13:15:44 +0000", - "sourceType": "RAW", - "preferredKernel": "https://www.googleapis.com/compute/v1beta13/projects/google/kernels/gce-20120611", - "rawDisk": { - "source": "", - "containerType": "TAR" - } - } - ] -} \ No newline at end of file diff --git a/labs/google-compute/src/test/resources/image_list_multiple_page_2.json b/labs/google-compute/src/test/resources/image_list_multiple_page_2.json deleted file mode 100644 index 71529d5ed6..0000000000 --- a/labs/google-compute/src/test/resources/image_list_multiple_page_2.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "kind": "compute#imageList", - "id": "projects/google/images", - "selfLink": "https://www.googleapis.com/compute/v1beta13/projects/google/images", - "nextPageToken": "CgVJTUFHRRIbZ29vZ2xlLmdjZWwtMTAtMDQtdjIwMTIxMTA2", - "items": [ - { - "kind": "compute#image", - "id": "12920641029336858796", - "creationTimestamp": "2012-06-21T22:59:56.392-07:00", - "selfLink": "https://www.googleapis.com/compute/v1beta13/projects/google/images/centos-6-2-v20120621", - "name": "centos-6-2-v20120621", - "description": "CentOS 6.2; Created Thu, 21 Jun 2012 14:22:21 +0000", - "sourceType": "RAW", - "preferredKernel": "https://www.googleapis.com/compute/v1beta13/projects/google/kernels/gce-20120621", - "rawDisk": { - "source": "", - "containerType": "TAR" - } - }, - { - "kind": "compute#image", - "id": "12994279803511049620", - "creationTimestamp": "2012-09-18T08:52:47.584-07:00", - "selfLink": "https://www.googleapis.com/compute/v1beta13/projects/google/images/centos-6-v20120912", - "name": "centos-6-v20120912", - "description": "CentOS 6; Created Wed, 12 Sep 2012 00:00:00 +0000", - "sourceType": "RAW", - "preferredKernel": "https://www.googleapis.com/compute/v1beta13/projects/google/kernels/gce-v20120912", - "rawDisk": { - "source": "", - "containerType": "TAR" - } - }, - { - "kind": "compute#image", - "id": "13037720516378381209", - "creationTimestamp": "2012-11-09T11:40:41.079-08:00", - "selfLink": "https://www.googleapis.com/compute/v1beta13/projects/google/images/centos-6-v20121106", - "name": "centos-6-v20121106", - "description": "SCSI-enabled CentOS 6; Created Tue, 06 Nov 2012 00:00:00 +0000", - "sourceType": "RAW", - "preferredKernel": "https://www.googleapis.com/compute/v1beta13/projects/google/kernels/gce-v20121106", - "rawDisk": { - "source": "", - "containerType": "TAR" - } - } - ] -} \ No newline at end of file diff --git a/labs/google-compute/src/test/resources/image_list_single_page.json b/labs/google-compute/src/test/resources/image_list_single_page.json deleted file mode 100644 index b28f9a6087..0000000000 --- a/labs/google-compute/src/test/resources/image_list_single_page.json +++ /dev/null @@ -1,49 +0,0 @@ -{ - "kind": "compute#imageList", - "id": "projects/google/images", - "selfLink": "https://www.googleapis.com/compute/v1beta13/projects/google/images", - "items": [ - { - "kind": "compute#image", - "id": "13037722963789596520", - "creationTimestamp": "2012-11-09T11:43:28.749-08:00", - "selfLink": "https://www.googleapis.com/compute/v1beta13/projects/google/images/gcel-10-04-v20121106", - "name": "gcel-10-04-v20121106", - "description": "SCSI-enabled GCEL 10.04 LTS; Created Tue, 06 Nov 2012 00:00:00 +0000", - "sourceType": "RAW", - "preferredKernel": "https://www.googleapis.com/compute/v1beta13/projects/google/kernels/gce-v20121106", - "rawDisk": { - "source": "", - "containerType": "TAR" - } - }, - { - "kind": "compute#image", - "id": "13037721421359523565", - "creationTimestamp": "2012-11-09T11:40:51.994-08:00", - "selfLink": "https://www.googleapis.com/compute/v1beta13/projects/google/images/gcel-12-04-v20121106", - "name": "gcel-12-04-v20121106", - "description": "SCSI-enabled GCEL 12.04 LTS; Created Tue, 06 Nov 2012 00:00:00 +0000", - "sourceType": "RAW", - "preferredKernel": "https://www.googleapis.com/compute/v1beta13/projects/google/kernels/gce-v20121106", - "rawDisk": { - "source": "", - "containerType": "TAR" - } - }, - { - "kind": "compute#image", - "id": "12941198995845323366", - "creationTimestamp": "2012-07-16T15:18:50.405-07:00", - "selfLink": "https://www.googleapis.com/compute/v1beta13/projects/google/images/ubuntu-10-04-v20110728", - "name": "ubuntu-10-04-v20110728", - "description": "DEPRECATED. GCEL 10.04 LTS; Created Thu, 28 Jul 2011 16:45:51 +0000", - "sourceType": "RAW", - "preferredKernel": "https://www.googleapis.com/compute/v1beta13/projects/google/kernels/gce-20110728", - "rawDisk": { - "source": "", - "containerType": "TAR" - } - } - ] -} \ No newline at end of file diff --git a/labs/google-compute/src/test/resources/instance_add_access_config.json b/labs/google-compute/src/test/resources/instance_add_access_config.json deleted file mode 100644 index 7530a7e768..0000000000 --- a/labs/google-compute/src/test/resources/instance_add_access_config.json +++ /dev/null @@ -1,11 +0,0 @@ -POST https://www.googleapis.com/compute/v1beta13/projects/jclouds-gce/instances/test-instance/addAccessConfig?network_interface=nic0&key={YOUR_API_KEY} - -Content-Type: application/json -Authorization: Bearer ya29.AHES6ZRyNKVHwnMPUvZitAuA8mR8b0lcWh1bMI5UQ5bgsJ4j -X-JavaScript-User-Agent: Google APIs Explorer - -{ - "name": "config1", - "natIP": "10.0.1.1", - "type": "ONE_TO_ONE_NAT" -} \ No newline at end of file diff --git a/labs/google-compute/src/test/resources/instance_get.json b/labs/google-compute/src/test/resources/instance_get.json deleted file mode 100644 index 19ca0c33d1..0000000000 --- a/labs/google-compute/src/test/resources/instance_get.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "kind": "compute#instance", - "id": "13051190678907570425", - "description": "desc", - "creationTimestamp": "2012-11-25T23:48:20.758", - "selfLink": "https://www.googleapis.com/compute/v1beta13/projects/myproject/instances/test-0", - "name": "test-0", - "image": "https://www.googleapis.com/compute/v1beta13/projects/google/images/gcel-12-04-v20121106", - "machineType": "https://www.googleapis.com/compute/v1beta13/projects/myproject/machineTypes/n1-standard-1", - "status": "RUNNING", - "zone": "https://www.googleapis.com/compute/v1beta13/projects/myproject/zones/us-central1-a", - "networkInterfaces": [ - { - "kind": "compute#instanceNetworkInterface", - "name": "nic0", - "networkIP": "10.240.121.115", - "network": "https://www.googleapis.com/compute/v1beta13/projects/myproject/networks/default" - } - ], - "disks": [ - { - "kind": "compute#instanceDisk", - "type": "PERSISTENT", - "mode": "READ_WRITE", - "deviceName": "test", - "source": "https://www.googleapis.com/compute/v1beta13/projects/myproject/disks/test", - "index": 0 - } - ], - "serviceAccounts": [ - { - "kind": "compute#serviceAccount", - "email": "default", - "scopes": [ - "myscope" - ] - } - ], - "metadata": { - "items": [ - { - "key": "aKey", - "value": "aValue" - } - ] - }, - "tags": [ - "aTag" - ] -} \ No newline at end of file diff --git a/labs/google-compute/src/test/resources/instance_insert.json b/labs/google-compute/src/test/resources/instance_insert.json deleted file mode 100644 index 6ec1efb5c7..0000000000 --- a/labs/google-compute/src/test/resources/instance_insert.json +++ /dev/null @@ -1 +0,0 @@ -{"name":"test-0","description":"desc","machineType":"https://www.googleapis.com/compute/v1beta13/projects/myproject/machineTypes/n1-standard-1","zone":"https://www.googleapis.com/compute/v1beta13/projects/myproject/zones/us-central1-a","image":"https://www.googleapis.com/compute/v1beta13/projects/google/images/gcel-12-04-v20121106","tags":["aTag"],"serviceAccounts":[{"email":"default","scopes":["myscope"]}],"networkInterfaces":[{"network":"https://www.googleapis.com/compute/v1beta13/projects/myproject/networks/default","accessConfigs":[{"type":"ONE_TO_ONE_NAT"}]}],"disks":[{"mode":"READ_WRITE","source":"https://www.googleapis.com/compute/v1beta13/projects/myproject/disks/test","type":"PERSISTENT"}],"metadata":{"kind":"compute#metadata","items":[{"key":"aKey","value":"aValue"}]}} \ No newline at end of file diff --git a/labs/google-compute/src/test/resources/instance_insert_simple.json b/labs/google-compute/src/test/resources/instance_insert_simple.json deleted file mode 100644 index 78b3e05f3b..0000000000 --- a/labs/google-compute/src/test/resources/instance_insert_simple.json +++ /dev/null @@ -1 +0,0 @@ -{"name":"test-1","machineType":"https://www.googleapis.com/compute/v1beta13/projects/myproject/machineTypes/n1-standard-1","zone":"https://www.googleapis.com/compute/v1beta13/projects/myproject/zones/us-central1-a","tags":[],"serviceAccounts":[],"networkInterfaces":[{"network":"https://www.googleapis.com/compute/v1beta13/projects/myproject/networks/default","accessConfigs":[]}]} \ No newline at end of file diff --git a/labs/google-compute/src/test/resources/instance_list.json b/labs/google-compute/src/test/resources/instance_list.json deleted file mode 100644 index fb3db8bd82..0000000000 --- a/labs/google-compute/src/test/resources/instance_list.json +++ /dev/null @@ -1,57 +0,0 @@ -{ - "kind": "compute#instanceList", - "id": "projects/myproject/instances", - "selfLink": "https://www.googleapis.com/compute/v1beta13/projects/myproject/instances", - "items": [ -{ - "kind": "compute#instance", - "id": "13051190678907570425", - "description": "desc", - "creationTimestamp": "2012-11-25T23:48:20.758", - "selfLink": "https://www.googleapis.com/compute/v1beta13/projects/myproject/instances/test-0", - "name": "test-0", - "image": "https://www.googleapis.com/compute/v1beta13/projects/google/images/gcel-12-04-v20121106", - "machineType": "https://www.googleapis.com/compute/v1beta13/projects/myproject/machineTypes/n1-standard-1", - "status": "RUNNING", - "zone": "https://www.googleapis.com/compute/v1beta13/projects/myproject/zones/us-central1-a", - "networkInterfaces": [ - { - "kind": "compute#instanceNetworkInterface", - "name": "nic0", - "networkIP": "10.240.121.115", - "network": "https://www.googleapis.com/compute/v1beta13/projects/myproject/networks/default" - } - ], - "disks": [ - { - "kind": "compute#instanceDisk", - "type": "PERSISTENT", - "mode": "READ_WRITE", - "deviceName": "test", - "source": "https://www.googleapis.com/compute/v1beta13/projects/myproject/disks/test", - "index": 0 - } - ], - "serviceAccounts": [ - { - "kind": "compute#serviceAccount", - "email": "default", - "scopes": [ - "myscope" - ] - } - ], - "metadata": { - "items": [ - { - "key": "aKey", - "value": "aValue" - } - ] - }, - "tags": [ - "aTag" - ] - } - ] -} \ No newline at end of file diff --git a/labs/google-compute/src/test/resources/instance_serial_port.json b/labs/google-compute/src/test/resources/instance_serial_port.json deleted file mode 100644 index 5813ce9791..0000000000 --- a/labs/google-compute/src/test/resources/instance_serial_port.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "kind": "compute#serialPortOutput", - "contents": "console output" -} \ No newline at end of file diff --git a/labs/google-compute/src/test/resources/kernel.json b/labs/google-compute/src/test/resources/kernel.json deleted file mode 100644 index a30b7a7e09..0000000000 --- a/labs/google-compute/src/test/resources/kernel.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "kind": "compute#kernel", - "id": "12941177846308850718", - "creationTimestamp": "2012-07-16T21:42:16.950", - "selfLink": "https://www.googleapis.com/compute/v1beta13/projects/google/kernels/gce-20110524", - "name": "gce-20110524", - "description": "DEPRECATED. Created Tue, 24 May 2011 00:48:22 +0000" -} \ No newline at end of file diff --git a/labs/google-compute/src/test/resources/kernel_list.json b/labs/google-compute/src/test/resources/kernel_list.json deleted file mode 100644 index 7c5ce61ba7..0000000000 --- a/labs/google-compute/src/test/resources/kernel_list.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "kind": "compute#kernelList", - "id": "projects/google/kernels", - "selfLink": "https://www.googleapis.com/compute/v1beta13/projects/google/kernels", - "items": [ - { - "kind": "compute#kernel", - "id": "12941177846308850718", - "creationTimestamp": "2012-07-16T21:42:16.950", - "selfLink": "https://www.googleapis.com/compute/v1beta13/projects/google/kernels/gce-20110524", - "name": "gce-20110524", - "description": "DEPRECATED. Created Tue, 24 May 2011 00:48:22 +0000" - }, - { - "kind": "compute#kernel", - "id": "12941177983348179280", - "creationTimestamp": "2012-07-16T21:42:31.166", - "selfLink": "https://www.googleapis.com/compute/v1beta13/projects/google/kernels/gce-20110728", - "name": "gce-20110728", - "description": "DEPRECATED. Created Thu, 28 Jul 2011 16:44:38 +0000" - } - ] -} \ No newline at end of file diff --git a/labs/google-compute/src/test/resources/logback.xml b/labs/google-compute/src/test/resources/logback.xml deleted file mode 100644 index dd4223c0d0..0000000000 --- a/labs/google-compute/src/test/resources/logback.xml +++ /dev/null @@ -1,38 +0,0 @@ - - - - target/test-data/jclouds.log - - - %d %-5p [%c] [%thread] %m%n - - - - - target/test-data/jclouds-wire.log - - - %d %-5p [%c] [%thread] %m%n - - - - - - - - - - - - - - - - - - - - - - - diff --git a/labs/google-compute/src/test/resources/machinetype.json b/labs/google-compute/src/test/resources/machinetype.json deleted file mode 100644 index 6f225723a7..0000000000 --- a/labs/google-compute/src/test/resources/machinetype.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "kind": "compute#machineType", - "id": "12907738072351752276", - "creationTimestamp": "2012-06-07T20:48:14.670", - "selfLink": "https://www.googleapis.com/compute/v1beta13/projects/myproject/machineTypes/n1-standard-1", - "name": "n1-standard-1", - "description": "1 vCPU, 3.75 GB RAM, and a 10 GB ephemeral root disk", - "guestCpus": 1, - "memoryMb": 3840, - "imageSpaceGb": 10, - "ephemeralDisks": [ - { - "diskGb": 1770 - }, - { - "diskGb": 1770 - } - ], - "maximumPersistentDisks": 16, - "maximumPersistentDisksSizeGb": "128" -} \ No newline at end of file diff --git a/labs/google-compute/src/test/resources/machinetype_list.json b/labs/google-compute/src/test/resources/machinetype_list.json deleted file mode 100644 index 14e7318ac9..0000000000 --- a/labs/google-compute/src/test/resources/machinetype_list.json +++ /dev/null @@ -1,41 +0,0 @@ -{ - "kind": "compute#machineTypeList", - "id": "projects/myproject/machineTypes", - "selfLink": "https://www.googleapis.com/compute/v1beta13/projects/myproject/machineTypes", - "items": [ - { - "kind": "compute#machineType", - "id": "12907738072351752276", - "creationTimestamp": "2012-06-07T20:48:14.670", - "selfLink": "https://www.googleapis.com/compute/v1beta13/projects/myproject/machineTypes/n1-standard-1", - "name": "n1-standard-1", - "description": "1 vCPU, 3.75 GB RAM, and a 10 GB ephemeral root disk", - "guestCpus": 1, - "memoryMb": 3840, - "imageSpaceGb": 10, - "maximumPersistentDisks": 16, - "maximumPersistentDisksSizeGb": "128" - }, - { - "kind": "compute#machineType", - "id": "12908560709887590691", - "creationTimestamp": "2012-06-07T20:51:19.936", - "selfLink": "https://www.googleapis.com/compute/v1beta13/projects/myproject/machineTypes/n1-standard-8-d", - "name": "n1-standard-8-d", - "description": "8 vCPUs, 30 GB RAM, a 10 GB ephemeral root disk, and 2 extra 1770 GB ephemeral disks", - "guestCpus": 8, - "memoryMb": 30720, - "imageSpaceGb": 10, - "ephemeralDisks": [ - { - "diskGb": 1770 - }, - { - "diskGb": 1770 - } - ], - "maximumPersistentDisks": 16, - "maximumPersistentDisksSizeGb": "1024" - } - ] -} \ No newline at end of file diff --git a/labs/google-compute/src/test/resources/metadata.json b/labs/google-compute/src/test/resources/metadata.json deleted file mode 100644 index 690133123e..0000000000 --- a/labs/google-compute/src/test/resources/metadata.json +++ /dev/null @@ -1 +0,0 @@ -{"kind":"compute#metadata","items":[{"key":"propA","value":"valueA"},{"key":"propB","value":"valueB"}]} \ No newline at end of file diff --git a/labs/google-compute/src/test/resources/network_get.json b/labs/google-compute/src/test/resources/network_get.json deleted file mode 100644 index 1a6a4b1ab3..0000000000 --- a/labs/google-compute/src/test/resources/network_get.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "kind": "compute#network", - "id": "13024414170909937976", - "creationTimestamp": "2012-10-24T20:13:19.967", - "selfLink": "https://www.googleapis.com/compute/v1beta13/projects/myproject/networks/jclouds-test", - "name": "default", - "description": "Default network for the project", - "IPv4Range": "10.0.0.0/8", - "gatewayIPv4": "10.0.0.1" -} \ No newline at end of file diff --git a/labs/google-compute/src/test/resources/network_insert.json b/labs/google-compute/src/test/resources/network_insert.json deleted file mode 100644 index 55e8331fc5..0000000000 --- a/labs/google-compute/src/test/resources/network_insert.json +++ /dev/null @@ -1 +0,0 @@ -{"name":"test-network","IPv4Range":"10.0.0.0/8"} \ No newline at end of file diff --git a/labs/google-compute/src/test/resources/network_list.json b/labs/google-compute/src/test/resources/network_list.json deleted file mode 100644 index 99ccc49b79..0000000000 --- a/labs/google-compute/src/test/resources/network_list.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "kind": "compute#networkList", - "id": "projects/myproject/networks", - "selfLink": "https://www.googleapis.com/compute/v1beta13/projects/myproject/networks", - "items": [ - { - - "kind": "compute#network", - "id": "13024414170909937976", - "creationTimestamp": "2012-10-24T20:13:19.967", - "selfLink": "https://www.googleapis.com/compute/v1beta13/projects/myproject/networks/jclouds-test", - "name": "default", - "description": "Default network for the project", - "IPv4Range": "10.0.0.0/8", - "gatewayIPv4": "10.0.0.1" - } - ] -} \ No newline at end of file diff --git a/labs/google-compute/src/test/resources/operation.json b/labs/google-compute/src/test/resources/operation.json deleted file mode 100644 index 68b16fbab1..0000000000 --- a/labs/google-compute/src/test/resources/operation.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "kind": "compute#operation", - "id": "13053095055850848306", - "selfLink": "https://www.googleapis.com/compute/v1beta13/projects/myproject/operations/operation-1354084865060-4cf88735faeb8-bbbb12cb", - "name": "operation-1354084865060-4cf88735faeb8-bbbb12cb", - "targetLink": "https://www.googleapis.com/compute/v1beta13/projects/myproject/instances/instance-api-live-test-instance", - "targetId": "13053094017547040099", - "status": "DONE", - "user": "user@developer.gserviceaccount.com", - "progress": 100, - "insertTime": "2012-11-28T06:41:05.060", - "startTime": "2012-11-28T06:41:05.142", - "endTime": "2012-11-28T06:41:06.142", - "operationType": "insert" - } \ No newline at end of file diff --git a/labs/google-compute/src/test/resources/operation_error.json b/labs/google-compute/src/test/resources/operation_error.json deleted file mode 100644 index f7f8e234f9..0000000000 --- a/labs/google-compute/src/test/resources/operation_error.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "kind": "compute#operation", - "id": "13053095055850848306", - "selfLink": "https://www.googleapis.com/compute/v1beta13/projects/myproject/operations/operation-1354084865060-4cf88735faeb8-bbbb12cb", - "name": "operation-1354084865060-4cf88735faeb8-bbbb12cb", - "targetLink": "https://www.googleapis.com/compute/v1beta13/projects/myproject/instances/instance-api-live-test-instance", - "targetId": "13053094017547040099", - "status": "DONE", - "user": "user@developer.gserviceaccount.com", - "progress": 100, - "insertTime": "2012-11-28T06:41:05.060", - "startTime": "2012-11-28T06:41:05.142", - "httpErrorStatusCode": 400, - "httpErrorMessage": "BAD REQUEST", - "error": { - "errors": [ - { - "code": "RESOURCE_ALREADY_EXISTS", - "message": "The resource 'projects/myproject/instances/instance-api-live-test-instance' already exists" - } - ] - }, - "operationType": "insert" - } \ No newline at end of file diff --git a/labs/google-compute/src/test/resources/operation_list.json b/labs/google-compute/src/test/resources/operation_list.json deleted file mode 100644 index 8bc3111339..0000000000 --- a/labs/google-compute/src/test/resources/operation_list.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "kind": "compute#operationList", - "id": "projects/myproject/operations", - "selfLink": "https://www.googleapis.com/compute/v1beta13/projects/myproject/operations", - "items": [ - { - "kind": "compute#operation", - "id": "13053095055850848306", - "selfLink": "https://www.googleapis.com/compute/v1beta13/projects/myproject/operations/operation-1354084865060-4cf88735faeb8-bbbb12cb", - "name": "operation-1354084865060-4cf88735faeb8-bbbb12cb", - "targetLink": "https://www.googleapis.com/compute/v1beta13/projects/myproject/instances/instance-api-live-test-instance", - "targetId": "13053094017547040099", - "status": "DONE", - "user": "user@developer.gserviceaccount.com", - "progress": 100, - "insertTime": "2012-11-28T06:41:05.060", - "startTime": "2012-11-28T06:41:05.142", - "endTime": "2012-11-28T06:41:06.142", - "operationType": "insert" - } - ] -} \ No newline at end of file diff --git a/labs/google-compute/src/test/resources/project.json b/labs/google-compute/src/test/resources/project.json deleted file mode 100644 index 6129ac4768..0000000000 --- a/labs/google-compute/src/test/resources/project.json +++ /dev/null @@ -1,68 +0,0 @@ -{ - "kind": "compute#project", - "id": "13024414184846275913", - "creationTimestamp": "2012-10-24T20:13:16.252", - "selfLink": "https://www.googleapis.com/compute/v1beta13/projects/myproject", - "name": "myproject", - "description": "", - "commonInstanceMetadata": { - "kind": "compute#metadata", - "items": [ - { - "key": "propA", - "value": "valueA" - }, - { - "key": "propB", - "value": "valueB" - } - ] - }, - "quotas": [ - { - "metric": "INSTANCES", - "usage": 0, - "limit": 8 - }, - { - "metric": "CPUS", - "usage": 0, - "limit": 8 - }, - { - "metric": "EPHEMERAL_ADDRESSES", - "usage": 0, - "limit": 8 - }, - { - "metric": "DISKS", - "usage": 0, - "limit": 8 - }, - { - "metric": "DISKS_TOTAL_GB", - "usage": 0, - "limit": 100 - }, - { - "metric": "SNAPSHOTS", - "usage": 0, - "limit": 1000 - }, - { - "metric": "NETWORKS", - "usage": 1, - "limit": 5 - }, - { - "metric": "FIREWALLS", - "usage": 2, - "limit": 100 - }, - { - "metric": "IMAGES", - "usage": 0, - "limit": 100 - } - ] -} \ No newline at end of file diff --git a/labs/google-compute/src/test/resources/quota.json b/labs/google-compute/src/test/resources/quota.json deleted file mode 100644 index b631ab33dd..0000000000 --- a/labs/google-compute/src/test/resources/quota.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "metric": "INSTANCES", - "usage": 0, - "limit": 8 -} \ No newline at end of file diff --git a/labs/google-compute/src/test/resources/zone_get.json b/labs/google-compute/src/test/resources/zone_get.json deleted file mode 100644 index cf3dc09152..0000000000 --- a/labs/google-compute/src/test/resources/zone_get.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "kind": "compute#zone", - "id": "13020128040171887099", - "creationTimestamp": "2012-10-19T16:42:54.131", - "selfLink": "https://www.googleapis.com/compute/v1beta13/projects/myproject/zones/us-central1-a", - "name": "us-central1-a", - "description": "us-central1-a", - "status": "DOWN", - "maintenanceWindows": [ - { - "name": "2012-11-10-planned-outage", - "description": "maintenance zone", - "beginTime": "2012-11-10T20:00:00.000", - "endTime": "2012-12-02T20:00:00.000" - } - ] -} \ No newline at end of file diff --git a/labs/google-compute/src/test/resources/zone_list.json b/labs/google-compute/src/test/resources/zone_list.json deleted file mode 100644 index 8d11f0d9b8..0000000000 --- a/labs/google-compute/src/test/resources/zone_list.json +++ /dev/null @@ -1,41 +0,0 @@ -{ - "kind": "compute#zoneList", - "id": "projects/myproject/zones", - "selfLink": "https://www.googleapis.com/compute/v1beta13/projects/myproject/zones", - "items": [ - { - "kind": "compute#zone", - "id": "13020128040171887099", - "creationTimestamp": "2012-10-19T16:42:54.131", - "selfLink": "https://www.googleapis.com/compute/v1beta13/projects/myproject/zones/us-central1-a", - "name": "us-central1-a", - "description": "us-central1-a", - "status": "DOWN", - "maintenanceWindows": [ - { - "name": "2012-11-10-planned-outage", - "description": "maintenance zone", - "beginTime": "2012-11-10T20:00:00.000", - "endTime": "2012-12-02T20:00:00.000" - } - ] - }, - { - "kind": "compute#zone", - "id": "13024414164050619686", - "creationTimestamp": "2012-10-24T20:13:19.271", - "selfLink": "https://www.googleapis.com/compute/v1beta13/projects/myproject/zones/us-east1-a", - "name": "us-east1-a", - "description": "us-east1-a", - "status": "UP", - "maintenanceWindows": [ - { - "name": "2013-02-17-planned-outage", - "description": "maintenance zone", - "beginTime": "2013-02-17T08:00:00.000", - "endTime": "2013-03-03T08:00:00.000" - } - ] - } - ] -} \ No newline at end of file diff --git a/labs/greenqloud-compute/pom.xml b/labs/greenqloud-compute/pom.xml deleted file mode 100644 index 08556b2d8d..0000000000 --- a/labs/greenqloud-compute/pom.xml +++ /dev/null @@ -1,131 +0,0 @@ - - - - 4.0.0 - - org.jclouds - jclouds-project - 1.7.0-SNAPSHOT - ../../project/pom.xml - - org.jclouds.labs - greenqloud-compute - jclouds Greenqloud compute provider - Compute implementation targeted to Greenqloud Web Services - bundle - - - https://api.greenqloud.com - 2010-06-15 - - ${test.greenqloud.identity} - ${test.greenqloud.credential} - - imageId=is-1/qmi-9ac92558 - - org.jclouds.greenqloud.compute*;version="${project.version}" - - org.jclouds.compute.internal;version="${project.version}", - org.jclouds.rest.internal;version="${project.version}", - org.jclouds*;version="${project.version}", - * - - - - - - org.jclouds.api - ec2 - ${project.version} - - - org.jclouds.api - ec2 - ${project.version} - test-jar - test - - - org.jclouds - jclouds-compute - ${project.version} - test-jar - test - - - org.jclouds - jclouds-core - ${project.version} - test-jar - test - - - org.jclouds.driver - jclouds-log4j - ${project.version} - test - - - org.jclouds.driver - jclouds-sshj - ${project.version} - test - - - - - - live - - - - org.apache.maven.plugins - maven-surefire-plugin - - - integration - integration-test - - test - - - 1 - - ${test.greenqloud-compute.endpoint} - ${test.greenqloud-compute.api-version} - ${test.greenqloud-compute.build-version} - ${test.greenqloud-compute.identity} - ${test.greenqloud-compute.credential} - ${test.greenqloud-compute.template} - ${test.greenqloud-compute.ebs-template} - - - - - - - - - - - - diff --git a/labs/greenqloud-compute/src/main/java/org/jclouds/greenqloud/compute/GreenQloudComputeProviderMetadata.java b/labs/greenqloud-compute/src/main/java/org/jclouds/greenqloud/compute/GreenQloudComputeProviderMetadata.java deleted file mode 100644 index 8cc5ae637c..0000000000 --- a/labs/greenqloud-compute/src/main/java/org/jclouds/greenqloud/compute/GreenQloudComputeProviderMetadata.java +++ /dev/null @@ -1,98 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.greenqloud.compute; - -import static org.jclouds.location.reference.LocationConstants.ISO3166_CODES; -import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGION; -import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGIONS; - -import java.net.URI; -import java.util.Properties; - -import org.jclouds.ec2.EC2ApiMetadata; -import org.jclouds.ec2.compute.config.EC2ResolveImagesModule; -import org.jclouds.ec2.config.EC2RestClientModule; -import org.jclouds.greenqloud.compute.config.GreenQloudComputeComputeServiceContextModule; -import org.jclouds.providers.ProviderMetadata; -import org.jclouds.providers.internal.BaseProviderMetadata; - -import com.google.common.collect.ImmutableSet; -import com.google.inject.Module; - -/** - * Implementation of {@link org.jclouds.providers.ProviderMetadata} for Greenqloud Compute Cloud. - * - * @author Adrian Cole - */ -public class GreenQloudComputeProviderMetadata extends BaseProviderMetadata { - - public static Builder builder() { - return new Builder(); - } - - @Override - public Builder toBuilder() { - return builder().fromProviderMetadata(this); - } - - public GreenQloudComputeProviderMetadata() { - super(builder()); - } - - public GreenQloudComputeProviderMetadata(Builder builder) { - super(builder); - } - - public static Properties defaultProperties() { - Properties properties = new Properties(); - properties.setProperty(PROPERTY_REGIONS, "is-1"); - properties.setProperty(PROPERTY_REGION + ".is-1." + ISO3166_CODES, "IS-1"); - return properties; - } - - public static class Builder extends BaseProviderMetadata.Builder { - - protected Builder(){ - id("greenqloud-compute") - .name("Greenqloud Compute Cloud") - .apiMetadata( - new EC2ApiMetadata().toBuilder() - .defaultModules(ImmutableSet.>of(EC2RestClientModule.class, EC2ResolveImagesModule.class, GreenQloudComputeComputeServiceContextModule.class)) - .build()) - .homepage(URI.create("http://www.greenqloud.com")) - .console(URI.create("https://manage.greenqloud.com")) - .linkedServices("greenqloud-compute", "greenqloud-storage") - .iso3166Codes("IS-1") - .endpoint("https://api.greenqloud.com") - .defaultProperties(GreenQloudComputeProviderMetadata.defaultProperties()); - } - - @Override - public GreenQloudComputeProviderMetadata build() { - return new GreenQloudComputeProviderMetadata(this); - } - - @Override - public Builder fromProviderMetadata( - ProviderMetadata in) { - super.fromProviderMetadata(in); - return this; - } - } -} diff --git a/labs/greenqloud-compute/src/main/java/org/jclouds/greenqloud/compute/config/GreenQloudComputeComputeServiceContextModule.java b/labs/greenqloud-compute/src/main/java/org/jclouds/greenqloud/compute/config/GreenQloudComputeComputeServiceContextModule.java deleted file mode 100644 index 6bff01b15e..0000000000 --- a/labs/greenqloud-compute/src/main/java/org/jclouds/greenqloud/compute/config/GreenQloudComputeComputeServiceContextModule.java +++ /dev/null @@ -1,37 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.greenqloud.compute.config; - -import org.jclouds.ec2.compute.config.EC2ComputeServiceContextModule; -import org.jclouds.ec2.compute.strategy.ReviseParsedImage; -import org.jclouds.greenqloud.compute.strategy.GreenQloudComputeReviseParsedImage; - -/** - * - * @author Adrian Cole - */ -public class GreenQloudComputeComputeServiceContextModule extends EC2ComputeServiceContextModule { - - @Override - protected void configure() { - super.configure(); - bind(ReviseParsedImage.class).to(GreenQloudComputeReviseParsedImage.class); - } - -} diff --git a/labs/greenqloud-compute/src/main/java/org/jclouds/greenqloud/compute/strategy/GreenQloudComputeReviseParsedImage.java b/labs/greenqloud-compute/src/main/java/org/jclouds/greenqloud/compute/strategy/GreenQloudComputeReviseParsedImage.java deleted file mode 100644 index 2be19223f2..0000000000 --- a/labs/greenqloud-compute/src/main/java/org/jclouds/greenqloud/compute/strategy/GreenQloudComputeReviseParsedImage.java +++ /dev/null @@ -1,65 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.greenqloud.compute.strategy; - -import java.util.Map; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import javax.inject.Inject; -import javax.inject.Named; -import javax.inject.Singleton; - -import org.jclouds.compute.domain.ImageBuilder; -import org.jclouds.compute.domain.OperatingSystem; -import org.jclouds.compute.domain.OsFamily; -import org.jclouds.compute.reference.ComputeServiceConstants; -import org.jclouds.compute.util.ComputeServiceUtils; -import org.jclouds.ec2.compute.strategy.ReviseParsedImage; -import org.jclouds.logging.Logger; - -/** - * @author Adrian Cole - */ -@Singleton -public class GreenQloudComputeReviseParsedImage implements ReviseParsedImage { - public static final Pattern DEFAULT_PATTERN = Pattern.compile("(([^ ]*) ([0-9.]+) ?.*)"); - - @javax.annotation.Resource - @Named(ComputeServiceConstants.COMPUTE_LOGGER) - protected Logger logger = Logger.NULL; - - private final Map> osVersionMap; - - @Inject - public GreenQloudComputeReviseParsedImage(Map> osVersionMap) { - this.osVersionMap = osVersionMap; - } - - public void reviseParsedImage(org.jclouds.ec2.domain.Image from, ImageBuilder builder, OsFamily family, - OperatingSystem.Builder osBuilder) { - if (from.getDescription() != null) - osBuilder.is64Bit(from.getDescription().contains("64-bit")); - - Matcher matcher = DEFAULT_PATTERN.matcher(from.getDescription()); - if (matcher.find() && matcher.groupCount() >= 3) { - osBuilder.version(ComputeServiceUtils.parseVersionOrReturnEmptyString(family, matcher.group(3), osVersionMap)); - } - } -} diff --git a/labs/greenqloud-compute/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata b/labs/greenqloud-compute/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata deleted file mode 100644 index ddcff31e7f..0000000000 --- a/labs/greenqloud-compute/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata +++ /dev/null @@ -1 +0,0 @@ -org.jclouds.greenqloud.compute.GreenQloudComputeProviderMetadata diff --git a/labs/greenqloud-compute/src/test/java/org/jclouds/greenqloud/compute/GreenQloudComputeComputeServiceLiveTestDisabled.java b/labs/greenqloud-compute/src/test/java/org/jclouds/greenqloud/compute/GreenQloudComputeComputeServiceLiveTestDisabled.java deleted file mode 100644 index 5f1ed49854..0000000000 --- a/labs/greenqloud-compute/src/test/java/org/jclouds/greenqloud/compute/GreenQloudComputeComputeServiceLiveTestDisabled.java +++ /dev/null @@ -1,34 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.greenqloud.compute; - -import org.jclouds.ec2.compute.EC2ComputeServiceLiveTest; -import org.testng.annotations.Test; - -/** - * - * @author Adrian Cole - */ -@Test(groups = "live", singleThreaded = true, testName = "GreenQloudComputeComputeServiceLiveTest") -public class GreenQloudComputeComputeServiceLiveTestDisabled extends EC2ComputeServiceLiveTest { - - public GreenQloudComputeComputeServiceLiveTestDisabled() { - provider = "greenqloud-compute"; - } -} diff --git a/labs/greenqloud-compute/src/test/java/org/jclouds/greenqloud/compute/GreenQloudComputeProviderTest.java b/labs/greenqloud-compute/src/test/java/org/jclouds/greenqloud/compute/GreenQloudComputeProviderTest.java deleted file mode 100644 index f3a230fc0c..0000000000 --- a/labs/greenqloud-compute/src/test/java/org/jclouds/greenqloud/compute/GreenQloudComputeProviderTest.java +++ /dev/null @@ -1,32 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.greenqloud.compute; - -import org.jclouds.ec2.EC2ApiMetadata; -import org.jclouds.providers.internal.BaseProviderMetadataTest; -import org.testng.annotations.Test; - -@Test(groups = "unit", testName = "GreenQloudComputeProviderTest") -public class GreenQloudComputeProviderTest extends BaseProviderMetadataTest { - - public GreenQloudComputeProviderTest() { - super(new GreenQloudComputeProviderMetadata(), new EC2ApiMetadata()); - } - -} diff --git a/labs/greenqloud-compute/src/test/java/org/jclouds/greenqloud/compute/GreenQloudComputeTemplateBuilderLiveTestDisabled.java b/labs/greenqloud-compute/src/test/java/org/jclouds/greenqloud/compute/GreenQloudComputeTemplateBuilderLiveTestDisabled.java deleted file mode 100644 index b28290f494..0000000000 --- a/labs/greenqloud-compute/src/test/java/org/jclouds/greenqloud/compute/GreenQloudComputeTemplateBuilderLiveTestDisabled.java +++ /dev/null @@ -1,96 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.greenqloud.compute; - -import static org.jclouds.compute.util.ComputeServiceUtils.getCores; -import static org.testng.Assert.assertEquals; - -import java.io.IOException; -import java.util.Set; - -import org.jclouds.aws.util.AWSUtils; -import org.jclouds.compute.domain.OsFamily; -import org.jclouds.compute.domain.OsFamilyVersion64Bit; -import org.jclouds.compute.domain.Template; -import org.jclouds.compute.internal.BaseTemplateBuilderLiveTest; -import org.jclouds.domain.LocationScope; -import org.testng.annotations.Test; - -import com.google.common.base.Predicate; -import com.google.common.base.Predicates; -import com.google.common.collect.ImmutableSet; - -/** - * - * @author Adrian Cole - */ -@Test(groups = "live", testName = "GreenQloudComputeTemplateBuilderLiveTest") -public class GreenQloudComputeTemplateBuilderLiveTestDisabled extends BaseTemplateBuilderLiveTest { - - public GreenQloudComputeTemplateBuilderLiveTestDisabled() { - provider = "greenqloud-compute"; - } - - @Override - protected Predicate defineUnsupportedOperatingSystems() { - return Predicates.not(new Predicate() { - - @Override - public boolean apply(OsFamilyVersion64Bit input) { - switch (input.family) { - case UBUNTU: - return (input.version.equals("") || input.version.equals("10.04") || input.version.equals("11.04") || input.version - .equals("11.10")) - && input.is64Bit; - case DEBIAN: - return (input.version.equals("") || input.version.equals("6.0")) && input.is64Bit; - case CENTOS: - return (input.version.equals("") || input.version.equals("5.5") || input.version.equals("5.6") || input.version - .equals("6.0")) - && input.is64Bit; - case FEDORA: - return input.version.equals("") && input.is64Bit; - default: - return false; - } - } - - }); - } - - @Test - public void testDefaultTemplateBuilder() throws IOException { - Template defaultTemplate = view.getComputeService().templateBuilder().build(); - assert (defaultTemplate.getImage().getProviderId().startsWith("qmi-")) : defaultTemplate; - assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), "11.10"); - assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true); - assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.UBUNTU); - assertEquals(defaultTemplate.getImage().getUserMetadata().get("rootDeviceType"), "ebs"); - assertEquals(defaultTemplate.getHardware().getId(), "m1.small"); - assertEquals(defaultTemplate.getLocation().getId(), "is-1"); - assertEquals(defaultTemplate.getLocation().getScope(), LocationScope.REGION); - assertEquals(AWSUtils.getRegionFromLocationOrNull(defaultTemplate.getLocation()), "is-1"); - assertEquals(getCores(defaultTemplate.getHardware()), 1.0d); - } - - @Override - protected Set getIso3166Codes() { - return ImmutableSet. of("IS-1"); - } -} diff --git a/labs/greenqloud-compute/src/test/java/org/jclouds/greenqloud/compute/parse/DescribeRegionsResponseHandlerTest.java b/labs/greenqloud-compute/src/test/java/org/jclouds/greenqloud/compute/parse/DescribeRegionsResponseHandlerTest.java deleted file mode 100644 index de89a84a66..0000000000 --- a/labs/greenqloud-compute/src/test/java/org/jclouds/greenqloud/compute/parse/DescribeRegionsResponseHandlerTest.java +++ /dev/null @@ -1,57 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.greenqloud.compute.parse; - -import static org.testng.Assert.assertEquals; - -import java.net.URI; -import java.util.Map; - -import org.jclouds.ec2.xml.DescribeRegionsResponseHandler; -import org.jclouds.http.functions.BaseHandlerTest; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableMap; - -/** - * @author Adrian Cole - */ -// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire -@Test(groups = "unit", testName = "DescribeRegionsResponseHandlerTest") -public class DescribeRegionsResponseHandlerTest extends BaseHandlerTest { - - public void test() { - String text = new StringBuilder() - .append("\n") - .append("0a5a6b4d-c0d7-4531-9ba9-bbc0b94d2007is-1api.greenqloud.com\n") - .toString(); - - Map expected = expected(); - - DescribeRegionsResponseHandler handler = injector.getInstance(DescribeRegionsResponseHandler.class); - Map result = factory.create(handler).parse(text); - - assertEquals(result.toString(), expected.toString()); - - } - - public Map expected() { - return ImmutableMap.of("is-1", URI.create("https://api.greenqloud.com")); - } -} diff --git a/labs/greenqloud-compute/src/test/java/org/jclouds/greenqloud/compute/services/GreenQloudAMIClientLiveTest.java b/labs/greenqloud-compute/src/test/java/org/jclouds/greenqloud/compute/services/GreenQloudAMIClientLiveTest.java deleted file mode 100644 index 5ef1684aac..0000000000 --- a/labs/greenqloud-compute/src/test/java/org/jclouds/greenqloud/compute/services/GreenQloudAMIClientLiveTest.java +++ /dev/null @@ -1,34 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.greenqloud.compute.services; - -import org.jclouds.ec2.services.AMIClientLiveTest; -import org.testng.annotations.Test; - -/** - * - * @author Adrian Cole - */ -@Test(groups = "live", singleThreaded = true, testName = "GreenQloudAMIClientLiveTest") -public class GreenQloudAMIClientLiveTest extends AMIClientLiveTest { - public GreenQloudAMIClientLiveTest() { - provider = "greenqloud-compute"; - } - -} diff --git a/labs/greenqloud-compute/src/test/java/org/jclouds/greenqloud/compute/services/GreenQloudAvailabilityZoneAndRegionClientLiveTest.java b/labs/greenqloud-compute/src/test/java/org/jclouds/greenqloud/compute/services/GreenQloudAvailabilityZoneAndRegionClientLiveTest.java deleted file mode 100644 index 347f065560..0000000000 --- a/labs/greenqloud-compute/src/test/java/org/jclouds/greenqloud/compute/services/GreenQloudAvailabilityZoneAndRegionClientLiveTest.java +++ /dev/null @@ -1,34 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.greenqloud.compute.services; - -import org.jclouds.ec2.services.AvailabilityZoneAndRegionClientLiveTest; -import org.testng.annotations.Test; - -/** - * - * @author Adrian Cole - */ -@Test(groups = "live", singleThreaded = true, testName = "GreenQloudAvailabilityZoneAndRegionClientLiveTest") -public class GreenQloudAvailabilityZoneAndRegionClientLiveTest extends AvailabilityZoneAndRegionClientLiveTest { - public GreenQloudAvailabilityZoneAndRegionClientLiveTest() { - provider = "greenqloud-compute"; - } - -} diff --git a/labs/greenqloud-compute/src/test/java/org/jclouds/greenqloud/compute/services/GreenQloudElasticBlockStoreClientLiveTest.java b/labs/greenqloud-compute/src/test/java/org/jclouds/greenqloud/compute/services/GreenQloudElasticBlockStoreClientLiveTest.java deleted file mode 100644 index 9c40ae9db2..0000000000 --- a/labs/greenqloud-compute/src/test/java/org/jclouds/greenqloud/compute/services/GreenQloudElasticBlockStoreClientLiveTest.java +++ /dev/null @@ -1,34 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.greenqloud.compute.services; - -import org.jclouds.ec2.services.ElasticBlockStoreClientLiveTest; -import org.testng.annotations.Test; - -/** - * - * @author Adrian Cole - */ -@Test(groups = "live", singleThreaded = true, testName = "GreenQloudElasticBlockStoreClientLiveTest") -public class GreenQloudElasticBlockStoreClientLiveTest extends ElasticBlockStoreClientLiveTest { - public GreenQloudElasticBlockStoreClientLiveTest() { - provider = "greenqloud-compute"; - } - -} diff --git a/labs/greenqloud-compute/src/test/java/org/jclouds/greenqloud/compute/services/GreenQloudElasticIPAddressClientLiveTest.java b/labs/greenqloud-compute/src/test/java/org/jclouds/greenqloud/compute/services/GreenQloudElasticIPAddressClientLiveTest.java deleted file mode 100644 index f54e5afa52..0000000000 --- a/labs/greenqloud-compute/src/test/java/org/jclouds/greenqloud/compute/services/GreenQloudElasticIPAddressClientLiveTest.java +++ /dev/null @@ -1,34 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.greenqloud.compute.services; - -import org.jclouds.ec2.services.ElasticIPAddressClientLiveTest; -import org.testng.annotations.Test; - -/** - * - * @author Adrian Cole - */ -@Test(groups = "live", singleThreaded = true, testName = "GreenQloudElasticIPAddressClientLiveTest") -public class GreenQloudElasticIPAddressClientLiveTest extends ElasticIPAddressClientLiveTest { - public GreenQloudElasticIPAddressClientLiveTest() { - provider = "greenqloud-compute"; - } - -} diff --git a/labs/greenqloud-compute/src/test/java/org/jclouds/greenqloud/compute/services/GreenQloudInstanceClientLiveTest.java b/labs/greenqloud-compute/src/test/java/org/jclouds/greenqloud/compute/services/GreenQloudInstanceClientLiveTest.java deleted file mode 100644 index 349711b5e5..0000000000 --- a/labs/greenqloud-compute/src/test/java/org/jclouds/greenqloud/compute/services/GreenQloudInstanceClientLiveTest.java +++ /dev/null @@ -1,34 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.greenqloud.compute.services; - -import org.jclouds.ec2.services.InstanceClientLiveTest; -import org.testng.annotations.Test; - -/** - * - * @author Adrian Cole - */ -@Test(groups = "live", singleThreaded = true, testName = "GreenQloudInstanceClientLiveTest") -public class GreenQloudInstanceClientLiveTest extends InstanceClientLiveTest { - public GreenQloudInstanceClientLiveTest() { - provider = "greenqloud-compute"; - } - -} diff --git a/labs/greenqloud-compute/src/test/java/org/jclouds/greenqloud/compute/services/GreenQloudKeyPairClientLiveTest.java b/labs/greenqloud-compute/src/test/java/org/jclouds/greenqloud/compute/services/GreenQloudKeyPairClientLiveTest.java deleted file mode 100644 index 7fa8e7098b..0000000000 --- a/labs/greenqloud-compute/src/test/java/org/jclouds/greenqloud/compute/services/GreenQloudKeyPairClientLiveTest.java +++ /dev/null @@ -1,34 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.greenqloud.compute.services; - -import org.jclouds.ec2.services.KeyPairClientLiveTest; -import org.testng.annotations.Test; - -/** - * - * @author Adrian Cole - */ -@Test(groups = "live", singleThreaded = true, testName = "GreenQloudKeyPairClientLiveTest") -public class GreenQloudKeyPairClientLiveTest extends KeyPairClientLiveTest { - public GreenQloudKeyPairClientLiveTest() { - provider = "greenqloud-compute"; - } - -} diff --git a/labs/greenqloud-compute/src/test/java/org/jclouds/greenqloud/compute/services/GreenQloudSecurityGroupClientLiveTest.java b/labs/greenqloud-compute/src/test/java/org/jclouds/greenqloud/compute/services/GreenQloudSecurityGroupClientLiveTest.java deleted file mode 100644 index 4ac23c44d2..0000000000 --- a/labs/greenqloud-compute/src/test/java/org/jclouds/greenqloud/compute/services/GreenQloudSecurityGroupClientLiveTest.java +++ /dev/null @@ -1,34 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.greenqloud.compute.services; - -import org.jclouds.ec2.services.SecurityGroupClientLiveTest; -import org.testng.annotations.Test; - -/** - * - * @author Adrian Cole - */ -@Test(groups = "live", singleThreaded = true, testName = "GreenQloudSecurityGroupClientLiveTest") -public class GreenQloudSecurityGroupClientLiveTest extends SecurityGroupClientLiveTest { - public GreenQloudSecurityGroupClientLiveTest() { - provider = "greenqloud-compute"; - } - -} diff --git a/labs/greenqloud-compute/src/test/java/org/jclouds/greenqloud/compute/strategy/GreenQloudComputeReviseParsedImageTest.java b/labs/greenqloud-compute/src/test/java/org/jclouds/greenqloud/compute/strategy/GreenQloudComputeReviseParsedImageTest.java deleted file mode 100644 index fac32a2966..0000000000 --- a/labs/greenqloud-compute/src/test/java/org/jclouds/greenqloud/compute/strategy/GreenQloudComputeReviseParsedImageTest.java +++ /dev/null @@ -1,256 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.greenqloud.compute.strategy; - -import static org.testng.Assert.assertEquals; - -import java.util.Map; -import java.util.Set; - -import org.jclouds.compute.config.BaseComputeServiceContextModule; -import org.jclouds.compute.domain.ImageBuilder; -import org.jclouds.compute.domain.OperatingSystem; -import org.jclouds.compute.domain.OsFamily; -import org.jclouds.compute.reference.ComputeServiceConstants; -import org.jclouds.domain.Location; -import org.jclouds.domain.LocationBuilder; -import org.jclouds.domain.LocationScope; -import org.jclouds.domain.LoginCredentials; -import org.jclouds.ec2.compute.config.EC2ComputeServiceDependenciesModule; -import org.jclouds.ec2.compute.functions.EC2ImageParser; -import org.jclouds.ec2.compute.strategy.EC2PopulateDefaultLoginCredentialsForImageStrategy; -import org.jclouds.ec2.domain.Image; -import org.jclouds.ec2.xml.DescribeImagesResponseHandlerTest; -import org.jclouds.greenqloud.compute.strategy.GreenQloudComputeReviseParsedImage; -import org.jclouds.json.Json; -import org.jclouds.json.config.GsonModule; -import org.testng.annotations.Test; - -import com.google.common.base.Predicates; -import com.google.common.base.Suppliers; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Iterables; -import com.google.common.collect.Sets; -import com.google.inject.Guice; - -/** - * @author Adrian Cole - */ -@Test(groups = "unit", testName = "GreenQloudComputeReviseParsedImageTest") -public class GreenQloudComputeReviseParsedImageTest { - - public void testParseGreenQloudImage() { - - Set result = convertImages("/greenqloud_images.xml"); - assertEquals(result.size(), 9); - - assertEquals( - Iterables.get(result, 0).toString(), - new ImageBuilder() - .operatingSystem( - OperatingSystem.builder().family(OsFamily.UBUNTU).version("10.04") - .description("Ubuntu Server 10.04 (64-bit)").is64Bit(true) - .arch("paravirtual").build()) - .description("Ubuntu Server 10.04 (64-bit)") - .name("Ubuntu Server 10.04.3") - .defaultCredentials(LoginCredentials.builder().user("root").build()) - .id("us-east-1/qmi-4e5b842f") - .providerId("qmi-4e5b842f") - .location(defaultLocation) - .userMetadata( - ImmutableMap.of("owner", "admin", "rootDeviceType", "ebs", "virtualizationType", - "paravirtual", "hypervisor", "xen")) - .status(org.jclouds.compute.domain.Image.Status.AVAILABLE).backendStatus("available").build().toString()); - assertEquals(Iterables.get(result, 0).getStatus(), org.jclouds.compute.domain.Image.Status.AVAILABLE); - - assertEquals( - Iterables.get(result, 1).toString(), - new ImageBuilder() - .operatingSystem( - OperatingSystem.builder().family(OsFamily.UBUNTU).version("11.10") - .description("Ubuntu Server 11.10 (64-bit)").is64Bit(true) - .arch("paravirtual").build()) - .description("Ubuntu Server 11.10 (64-bit)") - .name("Ubuntu Server 11.10") - .defaultCredentials(LoginCredentials.builder().user("root").build()) - .id("us-east-1/qmi-9ac92558") - .providerId("qmi-9ac92558") - .location(defaultLocation) - .userMetadata( - ImmutableMap.of("owner", "admin", "rootDeviceType", "ebs", "virtualizationType", - "paravirtual", "hypervisor", "xen")) - .status(org.jclouds.compute.domain.Image.Status.AVAILABLE).backendStatus("available").build().toString()); - assertEquals(Iterables.get(result, 1).getStatus(), org.jclouds.compute.domain.Image.Status.AVAILABLE); - - assertEquals( - Iterables.get(result, 2).toString(), - new ImageBuilder() - .operatingSystem( - OperatingSystem.builder().family(OsFamily.CENTOS).version("5.5") - .description("CentOS 5.5 Server 64-bit").is64Bit(true) - .arch("paravirtual").build()) - .description("CentOS 5.5 Server 64-bit") - .name("CentOS 5.5 Server") - .defaultCredentials(LoginCredentials.builder().user("root").build()) - .id("us-east-1/qmi-33a467aa") - .providerId("qmi-33a467aa") - .location(defaultLocation) - .userMetadata( - ImmutableMap.of("owner", "admin", "rootDeviceType", "ebs", "virtualizationType", - "paravirtual", "hypervisor", "xen")) - .status(org.jclouds.compute.domain.Image.Status.AVAILABLE).backendStatus("available").build().toString()); - assertEquals(Iterables.get(result, 2).getStatus(), org.jclouds.compute.domain.Image.Status.AVAILABLE); - - assertEquals( - Iterables.get(result, 3).toString(), - new ImageBuilder() - .operatingSystem( - OperatingSystem.builder().family(OsFamily.DEBIAN).version("6.0") - .description("Debian 6.0 (64-bit)").is64Bit(true) - .arch("paravirtual").build()) - .description("Debian 6.0 (64-bit)") - .name("Debian 6.0") - .defaultCredentials(LoginCredentials.builder().user("root").build()) - .id("us-east-1/qmi-f2a9d2ba") - .providerId("qmi-f2a9d2ba") - .location(defaultLocation) - .userMetadata( - ImmutableMap.of("owner", "admin", "rootDeviceType", "ebs", "virtualizationType", - "paravirtual", "hypervisor", "xen")) - .status(org.jclouds.compute.domain.Image.Status.AVAILABLE).backendStatus("available").build().toString()); - assertEquals(Iterables.get(result, 3).getStatus(), org.jclouds.compute.domain.Image.Status.AVAILABLE); - - assertEquals( - Iterables.get(result, 4).toString(), - new ImageBuilder() - .operatingSystem( - OperatingSystem.builder().family(OsFamily.CENTOS).version("6.0") - .description("CentOS 6.0 (64-bit)").is64Bit(true) - .arch("paravirtual").build()) - .description("CentOS 6.0 (64-bit)") - .name("CentOS 6.0") - .defaultCredentials(LoginCredentials.builder().user("root").build()) - .id("us-east-1/qmi-96f82145") - .providerId("qmi-96f82145") - .location(defaultLocation) - .userMetadata( - ImmutableMap.of("owner", "admin", "rootDeviceType", "ebs", "virtualizationType", - "paravirtual", "hypervisor", "xen")) - .status(org.jclouds.compute.domain.Image.Status.AVAILABLE).backendStatus("available").build().toString()); - assertEquals(Iterables.get(result, 4).getStatus(), org.jclouds.compute.domain.Image.Status.AVAILABLE); - - assertEquals( - Iterables.get(result, 5).toString(), - new ImageBuilder() - .operatingSystem( - OperatingSystem.builder().family(OsFamily.CENTOS).version("6.0") - .description("CentOS 6.0 GUI (64-bit)").is64Bit(true) - .arch("paravirtual").build()) - .description("CentOS 6.0 GUI (64-bit)") - .name("CentOS 6.0 GUI") - .defaultCredentials(LoginCredentials.builder().user("root").build()) - .id("us-east-1/qmi-42e877f6") - .providerId("qmi-42e877f6") - .location(defaultLocation) - .userMetadata( - ImmutableMap.of("owner", "admin", "rootDeviceType", "ebs", "virtualizationType", - "paravirtual", "hypervisor", "xen")) - .status(org.jclouds.compute.domain.Image.Status.AVAILABLE).backendStatus("available").build().toString()); - assertEquals(Iterables.get(result, 5).getStatus(), org.jclouds.compute.domain.Image.Status.AVAILABLE); - - assertEquals( - Iterables.get(result, 6).toString(), - new ImageBuilder() - .operatingSystem( - OperatingSystem.builder().family(OsFamily.UBUNTU).version("11.04") - .description("Ubuntu Server 11.04 (64-bit)").is64Bit(true) - .arch("paravirtual").build()) - .description("Ubuntu Server 11.04 (64-bit)") - .name("Ubuntu Server 11.04") - .defaultCredentials(LoginCredentials.builder().user("root").build()) - .id("us-east-1/qmi-eed8cea7") - .providerId("qmi-eed8cea7") - .location(defaultLocation) - .userMetadata( - ImmutableMap.of("owner", "admin", "rootDeviceType", "ebs", "virtualizationType", - "paravirtual", "hypervisor", "xen")) - .status(org.jclouds.compute.domain.Image.Status.AVAILABLE).backendStatus("available").build().toString()); - assertEquals(Iterables.get(result, 6).getStatus(), org.jclouds.compute.domain.Image.Status.AVAILABLE); - - assertEquals( - Iterables.get(result, 7).toString(), - new ImageBuilder() - .operatingSystem( - // fedora is not in the image version map, yet - OperatingSystem.builder().family(OsFamily.FEDORA).version("") - .description("Fedora 16 Server").is64Bit(false) - .arch("paravirtual").build()) - .description("Fedora 16 Server") - .name("Fedora 16 Server") - .defaultCredentials(LoginCredentials.builder().user("root").build()) - .id("us-east-1/qmi-fa4bdae0") - .providerId("qmi-fa4bdae0") - .location(defaultLocation) - .userMetadata( - ImmutableMap.of("owner", "admin", "rootDeviceType", "ebs", "virtualizationType", - "paravirtual", "hypervisor", "xen")) - .status(org.jclouds.compute.domain.Image.Status.AVAILABLE).backendStatus("available").build().toString()); - assertEquals(Iterables.get(result, 7).getStatus(), org.jclouds.compute.domain.Image.Status.AVAILABLE); - - assertEquals( - Iterables.get(result, 8).toString(), - new ImageBuilder() - .operatingSystem( - OperatingSystem.builder().family(OsFamily.CENTOS).version("5.6") - .description("CentOS 5.6 Server GUI 64-bit").is64Bit(true) - .arch("paravirtual").build()) - .description("CentOS 5.6 Server GUI 64-bit") - .name("CentOS 5.6 GUI") - .defaultCredentials(LoginCredentials.builder().user("root").build()) - .id("us-east-1/qmi-93271d32") - .providerId("qmi-93271d32") - .location(defaultLocation) - .userMetadata( - ImmutableMap.of("owner", "admin", "rootDeviceType", "ebs", "virtualizationType", - "paravirtual", "hypervisor", "xen")) - .status(org.jclouds.compute.domain.Image.Status.AVAILABLE).backendStatus("available").build().toString()); - assertEquals(Iterables.get(result, 8).getStatus(), org.jclouds.compute.domain.Image.Status.AVAILABLE); - - } - - static Location defaultLocation = new LocationBuilder().scope(LocationScope.REGION).id("us-east-1").description( - "us-east-1").build(); - - public static Set convertImages(String resource) { - - Map> map = new BaseComputeServiceContextModule() { - }.provideOsVersionMap(new ComputeServiceConstants.ReferenceData(), Guice.createInjector(new GsonModule()) - .getInstance(Json.class)); - - // note this method is what mandates the location id as us-east-1 - Set result = DescribeImagesResponseHandlerTest.parseImages(resource); - EC2ImageParser parser = new EC2ImageParser(EC2ComputeServiceDependenciesModule.toPortableImageStatus, - new EC2PopulateDefaultLoginCredentialsForImageStrategy(), map, Suppliers - .> ofInstance(ImmutableSet. of(defaultLocation)), Suppliers - .ofInstance(defaultLocation), new GreenQloudComputeReviseParsedImage(map)); - return Sets.newLinkedHashSet(Iterables.filter(Iterables.transform(result, parser), Predicates.notNull())); - } - -} diff --git a/labs/greenqloud-compute/src/test/resources/greenqloud_images.xml b/labs/greenqloud-compute/src/test/resources/greenqloud_images.xml deleted file mode 100644 index 80524457f7..0000000000 --- a/labs/greenqloud-compute/src/test/resources/greenqloud_images.xml +++ /dev/null @@ -1,257 +0,0 @@ - - 1c016525-12ae-4fc6-8d4e-754692412bbc - - - qmi-4e5b842f - Ubuntu Server 10.04 (64-bit) - available - admin - true - - - - - - - machine - - - - - - - - - Ubuntu Server 10.04.3 - Ubuntu Server 10.04 (64-bit) - ebs - - - xen - - - qmi-9ac92558 - Ubuntu Server 11.10 (64-bit) - available - admin - true - - - - - - - machine - - - - - - - - - Ubuntu Server 11.10 - Ubuntu Server 11.10 (64-bit) - ebs - - - xen - - - qmi-33a467aa - CentOS 5.5 Server 64-bit - available - admin - true - - - - - - - machine - - - - - - - - - CentOS 5.5 Server - CentOS 5.5 Server 64-bit - ebs - - - xen - - - qmi-f2a9d2ba - Debian 6.0 (64-bit) - available - admin - true - - - - - - - machine - - - - - - - - - Debian 6.0 - Debian 6.0 (64-bit) - ebs - - - xen - - - qmi-96f82145 - CentOS 6.0 (64-bit) - available - admin - true - - - - - - - machine - - - - - - - - - CentOS 6.0 - CentOS 6.0 (64-bit) - ebs - - - xen - - - qmi-42e877f6 - CentOS 6.0 GUI (64-bit) - available - admin - true - - - - - - - machine - - - - - - - - - CentOS 6.0 GUI - CentOS 6.0 GUI (64-bit) - ebs - - - xen - - - qmi-eed8cea7 - Ubuntu Server 11.04 (64-bit) - available - admin - true - - - - - - - machine - - - - - - - - - Ubuntu Server 11.04 - Ubuntu Server 11.04 (64-bit) - ebs - - - xen - - - qmi-fa4bdae0 - Fedora 16 Server - available - admin - true - - - - - - - machine - - - - - - - - - Fedora 16 Server - Fedora 16 Server - ebs - - - xen - - - qmi-93271d32 - CentOS 5.6 Server GUI 64-bit - available - admin - true - - - - - - - machine - - - - - - - - - CentOS 5.6 GUI - CentOS 5.6 Server GUI 64-bit - ebs - - - xen - - - \ No newline at end of file diff --git a/labs/greenqloud-storage/pom.xml b/labs/greenqloud-storage/pom.xml deleted file mode 100644 index caf61c9a47..0000000000 --- a/labs/greenqloud-storage/pom.xml +++ /dev/null @@ -1,123 +0,0 @@ - - - - 4.0.0 - - org.jclouds - jclouds-project - 1.7.0-SNAPSHOT - ../../project/pom.xml - - org.jclouds.labs - greenqloud-storage - jclouds GreenQloud Simple Storage Service (S3) provider - Simple Storage Service (S3) implementation targeted to GreenQloud Web Services - bundle - - - https://s.greenqloud.com - 2006-03-01 - - ${test.greenqloud.identity} - ${test.greenqloud.credential} - org.jclouds.greenqloud.storage*;version="${project.version}" - - org.jclouds*;version="${project.version}", - * - - - - - - org.jclouds.api - s3 - ${project.version} - - - org.jclouds - jclouds-core - ${project.version} - test-jar - test - - - org.jclouds - jclouds-blobstore - ${project.version} - test-jar - test - - - org.jclouds.api - s3 - ${project.version} - test-jar - test - - - org.jclouds.driver - jclouds-log4j - ${project.version} - test - - - log4j - log4j - test - - - - - - live - - - - org.apache.maven.plugins - maven-surefire-plugin - - - integration - integration-test - - test - - - - ${test.greenqloud-storage.endpoint} - ${test.greenqloud-storage.api-version} - ${test.greenqloud-storage.build-version} - ${test.greenqloud-storage.identity} - ${test.greenqloud-storage.credential} - ${jclouds.blobstore.httpstream.url} - ${jclouds.blobstore.httpstream.md5} - - - - - - - - - - - diff --git a/labs/greenqloud-storage/src/main/java/org/jclouds/greenqloud/storage/GreenQloudStorageProviderMetadata.java b/labs/greenqloud-storage/src/main/java/org/jclouds/greenqloud/storage/GreenQloudStorageProviderMetadata.java deleted file mode 100644 index 511d2b3adb..0000000000 --- a/labs/greenqloud-storage/src/main/java/org/jclouds/greenqloud/storage/GreenQloudStorageProviderMetadata.java +++ /dev/null @@ -1,91 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.greenqloud.storage; - -import static org.jclouds.location.reference.LocationConstants.ENDPOINT; -import static org.jclouds.location.reference.LocationConstants.ISO3166_CODES; -import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGION; -import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGIONS; - -import java.net.URI; -import java.util.Properties; - -import org.jclouds.providers.ProviderMetadata; -import org.jclouds.providers.internal.BaseProviderMetadata; -import org.jclouds.s3.S3ApiMetadata; - -/** - * Implementation of {@link org.jclouds.providers.ProviderMetadata} for GreenQloud Simple Storage Service (S3). - * - * @author Adrian Cole - */ -public class GreenQloudStorageProviderMetadata extends BaseProviderMetadata { - - public static Builder builder() { - return new Builder(); - } - - @Override - public Builder toBuilder() { - return builder().fromProviderMetadata(this); - } - - public GreenQloudStorageProviderMetadata() { - super(builder()); - } - - public GreenQloudStorageProviderMetadata(Builder builder) { - super(builder); - } - - public static Properties defaultProperties() { - Properties properties = new Properties(); - properties.setProperty(PROPERTY_REGIONS, "is-1"); - properties.setProperty(PROPERTY_REGION + ".is-1." + ISO3166_CODES, "IS-1"); - properties.setProperty(PROPERTY_REGION + "." + "is-1" + "." + ENDPOINT, "https://s.greenqloud.com"); - return properties; - } - - public static class Builder extends BaseProviderMetadata.Builder { - - protected Builder(){ - id("greenqloud-storage") - .name("GreenQloud Simple Storage Service (S3)") - .apiMetadata(new S3ApiMetadata()) - .homepage(URI.create("http://www.greenqloud.com")) - .console(URI.create("https://manage.greenqloud.com")) - .linkedServices("greenqloud-compute", "greenqloud-storage") - .iso3166Codes("IS-1") - .endpoint("https://s.greenqloud.com") - .defaultProperties(GreenQloudStorageProviderMetadata.defaultProperties()); - } - - @Override - public GreenQloudStorageProviderMetadata build() { - return new GreenQloudStorageProviderMetadata(this); - } - - @Override - public Builder fromProviderMetadata( - ProviderMetadata in) { - super.fromProviderMetadata(in); - return this; - } - } -} diff --git a/labs/greenqloud-storage/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata b/labs/greenqloud-storage/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata deleted file mode 100644 index a51135afc0..0000000000 --- a/labs/greenqloud-storage/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata +++ /dev/null @@ -1 +0,0 @@ -org.jclouds.greenqloud.storage.GreenQloudStorageProviderMetadata diff --git a/labs/greenqloud-storage/src/test/java/org/jclouds/greenqloud/storage/GreenQloudStorageClientLiveTest.java b/labs/greenqloud-storage/src/test/java/org/jclouds/greenqloud/storage/GreenQloudStorageClientLiveTest.java deleted file mode 100644 index d6329aa9b6..0000000000 --- a/labs/greenqloud-storage/src/test/java/org/jclouds/greenqloud/storage/GreenQloudStorageClientLiveTest.java +++ /dev/null @@ -1,34 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.greenqloud.storage; - -import org.jclouds.s3.S3ClientLiveTest; -import org.testng.annotations.Test; - -/** - * Tests behavior of {@code S3Client} - * - * @author Adrian Cole - */ -@Test(groups = "live", singleThreaded = true, testName = "GreenQloudStorageClientLiveTest") -public class GreenQloudStorageClientLiveTest extends S3ClientLiveTest { - public GreenQloudStorageClientLiveTest() { - provider = "greenqloud-storage"; - } -} diff --git a/labs/greenqloud-storage/src/test/java/org/jclouds/greenqloud/storage/GreenQloudStorageProviderTest.java b/labs/greenqloud-storage/src/test/java/org/jclouds/greenqloud/storage/GreenQloudStorageProviderTest.java deleted file mode 100644 index 559a090dc7..0000000000 --- a/labs/greenqloud-storage/src/test/java/org/jclouds/greenqloud/storage/GreenQloudStorageProviderTest.java +++ /dev/null @@ -1,37 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.greenqloud.storage; - -import org.jclouds.providers.internal.BaseProviderMetadataTest; -import org.jclouds.s3.S3ApiMetadata; -import org.testng.annotations.Test; - -/** - * The GreenQloudStorageProviderTest tests the {@link GreenQloudStorageProviderMetadata} class. - * - * @author Adrian Cole - */ -@Test(groups = "unit", testName = "GreenQloudStorageProviderTest") -public class GreenQloudStorageProviderTest extends BaseProviderMetadataTest { - - public GreenQloudStorageProviderTest() { - super(new GreenQloudStorageProviderMetadata(), new S3ApiMetadata()); - } - -} diff --git a/labs/greenqloud-storage/src/test/java/org/jclouds/greenqloud/storage/blobstore/GreenQloudStorageBlobIntegrationLiveTest.java b/labs/greenqloud-storage/src/test/java/org/jclouds/greenqloud/storage/blobstore/GreenQloudStorageBlobIntegrationLiveTest.java deleted file mode 100644 index 8a0d4bbde6..0000000000 --- a/labs/greenqloud-storage/src/test/java/org/jclouds/greenqloud/storage/blobstore/GreenQloudStorageBlobIntegrationLiveTest.java +++ /dev/null @@ -1,33 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.greenqloud.storage.blobstore; - -import org.jclouds.s3.blobstore.integration.S3BlobIntegrationLiveTest; -import org.testng.annotations.Test; - -/** - * @author Adrian Cole - */ -@Test(groups = "live", testName = "GreenQloudStorageBlobIntegrationLiveTest") -public class GreenQloudStorageBlobIntegrationLiveTest extends S3BlobIntegrationLiveTest { - - public GreenQloudStorageBlobIntegrationLiveTest() { - provider = "greenqloud-storage"; - } -} diff --git a/labs/greenqloud-storage/src/test/java/org/jclouds/greenqloud/storage/blobstore/GreenQloudStorageBlobLiveTest.java b/labs/greenqloud-storage/src/test/java/org/jclouds/greenqloud/storage/blobstore/GreenQloudStorageBlobLiveTest.java deleted file mode 100644 index 6a69b157d9..0000000000 --- a/labs/greenqloud-storage/src/test/java/org/jclouds/greenqloud/storage/blobstore/GreenQloudStorageBlobLiveTest.java +++ /dev/null @@ -1,33 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.greenqloud.storage.blobstore; - -import org.jclouds.s3.blobstore.integration.S3BlobLiveTest; -import org.testng.annotations.Test; - -/** - * @author Adrian Cole - */ -@Test(groups = "live", testName = "GreenQloudStorageBlobLiveTest") -public class GreenQloudStorageBlobLiveTest extends S3BlobLiveTest { - - public GreenQloudStorageBlobLiveTest() { - provider = "greenqloud-storage"; - } -} diff --git a/labs/greenqloud-storage/src/test/java/org/jclouds/greenqloud/storage/blobstore/GreenQloudStorageBlobMapIntegrationLiveTest.java b/labs/greenqloud-storage/src/test/java/org/jclouds/greenqloud/storage/blobstore/GreenQloudStorageBlobMapIntegrationLiveTest.java deleted file mode 100644 index d405dee809..0000000000 --- a/labs/greenqloud-storage/src/test/java/org/jclouds/greenqloud/storage/blobstore/GreenQloudStorageBlobMapIntegrationLiveTest.java +++ /dev/null @@ -1,33 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.greenqloud.storage.blobstore; - -import org.jclouds.s3.blobstore.integration.S3BlobMapIntegrationLiveTest; -import org.testng.annotations.Test; - -/** - * @author Adrian Cole - */ -@Test(groups = "live", testName = "GreenQloudStorageBlobMapIntegrationLiveTest") -public class GreenQloudStorageBlobMapIntegrationLiveTest extends S3BlobMapIntegrationLiveTest { - - public GreenQloudStorageBlobMapIntegrationLiveTest() { - provider = "greenqloud-storage"; - } -} diff --git a/labs/greenqloud-storage/src/test/java/org/jclouds/greenqloud/storage/blobstore/GreenQloudStorageBlobSignerLiveTest.java b/labs/greenqloud-storage/src/test/java/org/jclouds/greenqloud/storage/blobstore/GreenQloudStorageBlobSignerLiveTest.java deleted file mode 100644 index 32cbba3448..0000000000 --- a/labs/greenqloud-storage/src/test/java/org/jclouds/greenqloud/storage/blobstore/GreenQloudStorageBlobSignerLiveTest.java +++ /dev/null @@ -1,34 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.greenqloud.storage.blobstore; - -import org.jclouds.s3.blobstore.integration.S3BlobSignerLiveTest; -import org.testng.annotations.Test; - -/** - * - * @author Adrian Cole - */ -@Test(groups = "live", testName = "GreenQloudStorageBlobSignerLiveTest") -public class GreenQloudStorageBlobSignerLiveTest extends S3BlobSignerLiveTest { - - public GreenQloudStorageBlobSignerLiveTest() { - provider = "greenqloud-storage"; - } -} diff --git a/labs/greenqloud-storage/src/test/java/org/jclouds/greenqloud/storage/blobstore/GreenQloudStorageContainerIntegrationLiveTest.java b/labs/greenqloud-storage/src/test/java/org/jclouds/greenqloud/storage/blobstore/GreenQloudStorageContainerIntegrationLiveTest.java deleted file mode 100644 index 563a27e9be..0000000000 --- a/labs/greenqloud-storage/src/test/java/org/jclouds/greenqloud/storage/blobstore/GreenQloudStorageContainerIntegrationLiveTest.java +++ /dev/null @@ -1,33 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.greenqloud.storage.blobstore; - -import org.jclouds.s3.blobstore.integration.S3ContainerIntegrationLiveTest; -import org.testng.annotations.Test; - -/** - * @author Adrian Cole - */ -@Test(groups = "live", testName = "GreenQloudStorageContainerIntegrationLiveTest") -public class GreenQloudStorageContainerIntegrationLiveTest extends S3ContainerIntegrationLiveTest { - - public GreenQloudStorageContainerIntegrationLiveTest() { - provider = "greenqloud-storage"; - } -} diff --git a/labs/greenqloud-storage/src/test/java/org/jclouds/greenqloud/storage/blobstore/GreenQloudStorageContainerLiveTest.java b/labs/greenqloud-storage/src/test/java/org/jclouds/greenqloud/storage/blobstore/GreenQloudStorageContainerLiveTest.java deleted file mode 100644 index 4453084da7..0000000000 --- a/labs/greenqloud-storage/src/test/java/org/jclouds/greenqloud/storage/blobstore/GreenQloudStorageContainerLiveTest.java +++ /dev/null @@ -1,33 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.greenqloud.storage.blobstore; - -import org.jclouds.s3.blobstore.integration.S3ContainerLiveTest; -import org.testng.annotations.Test; - -/** - * @author Adrian Cole - */ -@Test(groups = "live", testName = "GreenQloudStorageContainerLiveTest") -public class GreenQloudStorageContainerLiveTest extends S3ContainerLiveTest { - - public GreenQloudStorageContainerLiveTest() { - provider = "greenqloud-storage"; - } -} diff --git a/labs/greenqloud-storage/src/test/java/org/jclouds/greenqloud/storage/blobstore/GreenQloudStorageInputStreamMapIntegrationLiveTest.java b/labs/greenqloud-storage/src/test/java/org/jclouds/greenqloud/storage/blobstore/GreenQloudStorageInputStreamMapIntegrationLiveTest.java deleted file mode 100644 index 611b739ec3..0000000000 --- a/labs/greenqloud-storage/src/test/java/org/jclouds/greenqloud/storage/blobstore/GreenQloudStorageInputStreamMapIntegrationLiveTest.java +++ /dev/null @@ -1,34 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.greenqloud.storage.blobstore; - -import org.jclouds.s3.blobstore.integration.S3InputStreamMapIntegrationLiveTest; -import org.testng.annotations.Test; - -/** - * @author Adrian Cole - */ -@Test(groups = "live", testName = "GreenQloudStorageInputStreamMapIntegrationLiveTest") -public class GreenQloudStorageInputStreamMapIntegrationLiveTest extends - S3InputStreamMapIntegrationLiveTest { - - public GreenQloudStorageInputStreamMapIntegrationLiveTest() { - provider = "greenqloud-storage"; - } -} diff --git a/labs/greenqloud-storage/src/test/java/org/jclouds/greenqloud/storage/blobstore/GreenQloudStorageServiceIntegrationLiveTest.java b/labs/greenqloud-storage/src/test/java/org/jclouds/greenqloud/storage/blobstore/GreenQloudStorageServiceIntegrationLiveTest.java deleted file mode 100644 index 7ea1a5f403..0000000000 --- a/labs/greenqloud-storage/src/test/java/org/jclouds/greenqloud/storage/blobstore/GreenQloudStorageServiceIntegrationLiveTest.java +++ /dev/null @@ -1,43 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.greenqloud.storage.blobstore; - -import java.util.Set; - -import org.jclouds.s3.blobstore.integration.S3ServiceIntegrationLiveTest; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableSet; - -/** - * @author Adrian Cole - */ -@Test(groups = "live", testName = "GreenQloudStorageServiceIntegrationLiveTest") -public class GreenQloudStorageServiceIntegrationLiveTest extends S3ServiceIntegrationLiveTest { - - public GreenQloudStorageServiceIntegrationLiveTest() { - provider = "greenqloud-storage"; - } - - @Override - protected Set getIso3166Codes() { - return ImmutableSet. of("IS-1"); - } - -} diff --git a/labs/iam/pom.xml b/labs/iam/pom.xml deleted file mode 100644 index e8e446d6ae..0000000000 --- a/labs/iam/pom.xml +++ /dev/null @@ -1,109 +0,0 @@ - - - - 4.0.0 - - org.jclouds.labs - jclouds-labs-project - 1.7.0-SNAPSHOT - ../project/pom.xml - - iam - jcloud iam api - jclouds components to access an implementation of Identity and Access Management (IAM) - bundle - - - https://iam.amazonaws.com - 2010-05-08 - - ${test.aws.identity} - ${test.aws.credential} - - org.jclouds.iam*;version="${project.version}" - - org.jclouds.labs*;version="${project.version}", - org.jclouds*;version="${jclouds.version}", - * - - - - - - org.jclouds.api - sts - ${jclouds.version} - - - org.jclouds - jclouds-core - ${jclouds.version} - test-jar - test - - - org.jclouds.driver - jclouds-slf4j - ${jclouds.version} - test - - - ch.qos.logback - logback-classic - test - - - - - - live - - - - org.apache.maven.plugins - maven-surefire-plugin - - - integration - integration-test - - test - - - - ${test.iam.endpoint} - ${test.iam.api-version} - ${test.iam.build-version} - ${test.iam.identity} - ${test.iam.credential} - - - - - - - - - - - - diff --git a/labs/iam/src/main/java/org/jclouds/iam/IAMApi.java b/labs/iam/src/main/java/org/jclouds/iam/IAMApi.java deleted file mode 100644 index c693ad2bf1..0000000000 --- a/labs/iam/src/main/java/org/jclouds/iam/IAMApi.java +++ /dev/null @@ -1,66 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.iam; - -import javax.ws.rs.FormParam; - -import org.jclouds.iam.domain.User; -import org.jclouds.iam.features.InstanceProfileApi; -import org.jclouds.iam.features.RoleApi; -import org.jclouds.iam.features.RolePolicyApi; -import org.jclouds.iam.features.UserApi; -import org.jclouds.rest.annotations.Delegate; - -/** - * Provides access to Amazon IAM via the Query API - *

- * - * @see - * @author Adrian Cole - */ -public interface IAMApi { - /** - * Retrieves information about the current user, including the user's path, GUID, and ARN. - */ - User getCurrentUser(); - - /** - * Provides synchronous access to User features. - */ - @Delegate - UserApi getUserApi(); - - /** - * Provides synchronous access to Role features. - */ - @Delegate - RoleApi getRoleApi(); - - /** - * Provides synchronous access to Role Policy features. - */ - @Delegate - RolePolicyApi getPolicyApiForRole(@FormParam("RoleName") String roleName); - - /** - * Provides synchronous access to Instance Profile features. - */ - @Delegate - InstanceProfileApi getInstanceProfileApi(); -} diff --git a/labs/iam/src/main/java/org/jclouds/iam/IAMApiMetadata.java b/labs/iam/src/main/java/org/jclouds/iam/IAMApiMetadata.java deleted file mode 100644 index 6225120022..0000000000 --- a/labs/iam/src/main/java/org/jclouds/iam/IAMApiMetadata.java +++ /dev/null @@ -1,90 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.iam; - -import static org.jclouds.aws.reference.AWSConstants.PROPERTY_AUTH_TAG; -import static org.jclouds.aws.reference.AWSConstants.PROPERTY_HEADER_TAG; - -import java.net.URI; -import java.util.Properties; - -import org.jclouds.apis.ApiMetadata; -import org.jclouds.iam.config.IAMRestClientModule; -import org.jclouds.rest.RestContext; -import org.jclouds.rest.internal.BaseRestApiMetadata; - -import com.google.common.reflect.TypeToken; - -/** - * Implementation of {@link ApiMetadata} for Amazon's IAM api. - * - * @author Adrian Cole - */ -public class IAMApiMetadata extends BaseRestApiMetadata { - - public static final TypeToken> CONTEXT_TOKEN = new TypeToken>() { - private static final long serialVersionUID = 1L; - }; - - @Override - public Builder toBuilder() { - return new Builder(getApi(), getAsyncApi()).fromApiMetadata(this); - } - - public IAMApiMetadata() { - this(new Builder(IAMApi.class, IAMAsyncApi.class)); - } - - protected IAMApiMetadata(Builder builder) { - super(Builder.class.cast(builder)); - } - - public static Properties defaultProperties() { - Properties properties = BaseRestApiMetadata.defaultProperties(); - properties.setProperty(PROPERTY_AUTH_TAG, "AWS"); - properties.setProperty(PROPERTY_HEADER_TAG, "amz"); - return properties; - } - - public static class Builder extends BaseRestApiMetadata.Builder { - - protected Builder(Class api, Class asyncApi) { - super(api, asyncApi); - id("iam") - .name("Amazon IAM Api") - .identityName("Access Key ID") - .credentialName("Secret Access Key") - .version("2010-05-08") - .documentation(URI.create("http://docs.amazonwebservices.com/IAM/latest/APIReference/")) - .defaultEndpoint("https://iam.amazonaws.com") - .defaultProperties(IAMApiMetadata.defaultProperties()) - .defaultModule(IAMRestClientModule.class); - } - - @Override - public IAMApiMetadata build() { - return new IAMApiMetadata(this); - } - - @Override - protected Builder self() { - return this; - } - } -} diff --git a/labs/iam/src/main/java/org/jclouds/iam/IAMAsyncApi.java b/labs/iam/src/main/java/org/jclouds/iam/IAMAsyncApi.java deleted file mode 100644 index 66784cb091..0000000000 --- a/labs/iam/src/main/java/org/jclouds/iam/IAMAsyncApi.java +++ /dev/null @@ -1,85 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.iam; - -import javax.inject.Named; -import javax.ws.rs.FormParam; -import javax.ws.rs.POST; -import javax.ws.rs.Path; - -import org.jclouds.aws.filters.FormSigner; -import org.jclouds.iam.domain.User; -import org.jclouds.iam.features.InstanceProfileAsyncApi; -import org.jclouds.iam.features.RoleAsyncApi; -import org.jclouds.iam.features.RolePolicyAsyncApi; -import org.jclouds.iam.features.UserAsyncApi; -import org.jclouds.iam.xml.UserHandler; -import org.jclouds.rest.annotations.Delegate; -import org.jclouds.rest.annotations.FormParams; -import org.jclouds.rest.annotations.RequestFilters; -import org.jclouds.rest.annotations.VirtualHost; -import org.jclouds.rest.annotations.XMLResponseParser; - -import com.google.common.util.concurrent.ListenableFuture; - -/** - * Provides access to Amazon IAM via the Query API - *

- * - * @see - * @author Adrian Cole - */ -@RequestFilters(FormSigner.class) -@VirtualHost -public interface IAMAsyncApi { - - /** - * @see IAMApi#getCurrentUser() - */ - @Named("GetUser") - @POST - @Path("/") - @XMLResponseParser(UserHandler.class) - @FormParams(keys = "Action", values = "GetUser") - ListenableFuture getCurrentUser(); - - /** - * Provides asynchronous access to User features. - */ - @Delegate - UserAsyncApi getUserApi(); - - /** - * Provides asynchronous access to Role features. - */ - @Delegate - RoleAsyncApi getRoleApi(); - - /** - * Provides asynchronous access to Role Policy features. - */ - @Delegate - RolePolicyAsyncApi getPolicyApiForRole(@FormParam("RoleName") String roleName); - - /** - * Provides asynchronous access to Instance Profile features. - */ - @Delegate - InstanceProfileAsyncApi getInstanceProfileApi(); -} diff --git a/labs/iam/src/main/java/org/jclouds/iam/config/IAMRestClientModule.java b/labs/iam/src/main/java/org/jclouds/iam/config/IAMRestClientModule.java deleted file mode 100644 index 6763557f8a..0000000000 --- a/labs/iam/src/main/java/org/jclouds/iam/config/IAMRestClientModule.java +++ /dev/null @@ -1,57 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.iam.config; - -import static org.jclouds.reflect.Reflection2.typeToken; - -import java.util.Map; - -import org.jclouds.aws.config.FormSigningRestClientModule; -import org.jclouds.iam.IAMApi; -import org.jclouds.iam.IAMAsyncApi; -import org.jclouds.iam.features.InstanceProfileApi; -import org.jclouds.iam.features.InstanceProfileAsyncApi; -import org.jclouds.iam.features.RoleApi; -import org.jclouds.iam.features.RoleAsyncApi; -import org.jclouds.iam.features.RolePolicyApi; -import org.jclouds.iam.features.RolePolicyAsyncApi; -import org.jclouds.iam.features.UserApi; -import org.jclouds.iam.features.UserAsyncApi; -import org.jclouds.rest.ConfiguresRestClient; - -import com.google.common.collect.ImmutableMap; - -/** - * Configures the Monitoring connection. - * - * @author Adrian Cole - */ -@ConfiguresRestClient -public class IAMRestClientModule extends FormSigningRestClientModule { - public static final Map, Class> DELEGATE_MAP = ImmutableMap., Class> builder()// - .put(UserApi.class, UserAsyncApi.class) - .put(RoleApi.class, RoleAsyncApi.class) - .put(RolePolicyApi.class, RolePolicyAsyncApi.class) - .put(InstanceProfileApi.class, InstanceProfileAsyncApi.class) - .build(); - - public IAMRestClientModule() { - super(typeToken(IAMApi.class), typeToken(IAMAsyncApi.class), DELEGATE_MAP); - } -} diff --git a/labs/iam/src/main/java/org/jclouds/iam/domain/InstanceProfile.java b/labs/iam/src/main/java/org/jclouds/iam/domain/InstanceProfile.java deleted file mode 100644 index 2e1d95682a..0000000000 --- a/labs/iam/src/main/java/org/jclouds/iam/domain/InstanceProfile.java +++ /dev/null @@ -1,197 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.iam.domain; - -import static com.google.common.base.Objects.equal; -import static com.google.common.base.Objects.toStringHelper; -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.Date; - -import com.google.common.base.Objects; -import com.google.common.collect.ImmutableList; - -/** - * @see - * - * @author Adrian Cole - */ -public final class InstanceProfile { - - private final String arn; - private final String id; - private final String name; - private final String path; - private final Date createDate; - private final ImmutableList roles; - - private InstanceProfile(String arn, String id, String name, String path, Date createDate, ImmutableList roles) { - this.arn = checkNotNull(arn, "arn"); - this.id = checkNotNull(id, "id for %s", arn); - this.name = checkNotNull(name, "name for %s", arn); - this.path = checkNotNull(path, "path for %s", arn); - this.createDate = checkNotNull(createDate, "createDate for %s", arn); - this.roles = checkNotNull(roles, "roles for %s", arn); - } - - /** - * how to specify the resource in the access policy language ex. - * {@code arn:aws::::} - */ - public String getArn() { - return arn; - } - - /** - * a globally unique identifier (GUID), returned from the api. - */ - public String getId() { - return id; - } - - /** - * friendly name ex. {@code Developers} - */ - public String getName() { - return name; - } - - /** - * path ex {@code /division_abc/subdivision_xyz/product_1234/engineering/} - */ - public String getPath() { - return path; - } - - /** - * Date the instance profile was created - */ - public Date getCreateDate() { - return createDate; - } - - /** - * The roles assigned to the instance profile - */ - public ImmutableList getRoles() { - return roles; - } - - @Override - public int hashCode() { - return Objects.hashCode(arn, id); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null || getClass() != obj.getClass()) - return false; - InstanceProfile that = InstanceProfile.class.cast(obj); - return equal(this.arn, that.arn) && equal(this.id, that.id); - } - - @Override - public String toString() { - return toStringHelper(this).add("arn", arn).add("id", id).add("name", name).add("path", path) - .add("createDate", createDate).add("roles", roles).toString(); - } - - public static Builder builder() { - return new Builder(); - } - - public Builder toBuilder() { - return builder().from(this); - } - - public static class Builder { - private String arn; - private String id; - private String name; - private String path; - private Date createDate; - private ImmutableList.Builder roles = ImmutableList. builder(); - - /** - * @see InstanceProfile#getArn() - */ - public Builder arn(String arn) { - this.arn = arn; - return this; - } - - /** - * @see InstanceProfile#getId() - */ - public Builder id(String id) { - this.id = id; - return this; - } - - /** - * @see InstanceProfile#getName() - */ - public Builder name(String name) { - this.name = name; - return this; - } - - /** - * @see InstanceProfile#getPath() - */ - public Builder path(String path) { - this.path = path; - return this; - } - - /** - * @see InstanceProfile#getCreateDate() - */ - public Builder createDate(Date createDate) { - this.createDate = createDate; - return this; - } - - /** - * @see InstanceProfile#getRoles() - */ - public Builder role(Role role) { - this.roles.add(checkNotNull(role, "role")); - return this; - } - - /** - * @see InstanceProfile#getRoles() - */ - public Builder roles(Iterable roles) { - this.roles.addAll(checkNotNull(roles, "roles")); - return this; - } - - public InstanceProfile build() { - return new InstanceProfile(arn, id, name, path, createDate, roles.build()); - } - - public Builder from(InstanceProfile in) { - return arn(in.arn).id(in.id).name(in.name).path(in.path).createDate(in.createDate).roles(in.roles); - } - } -} diff --git a/labs/iam/src/main/java/org/jclouds/iam/domain/Policy.java b/labs/iam/src/main/java/org/jclouds/iam/domain/Policy.java deleted file mode 100644 index a2d353c697..0000000000 --- a/labs/iam/src/main/java/org/jclouds/iam/domain/Policy.java +++ /dev/null @@ -1,130 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.iam.domain; - -import static com.google.common.base.Objects.equal; -import static com.google.common.base.Objects.toStringHelper; -import static com.google.common.base.Preconditions.checkNotNull; - -import com.google.common.base.Objects; - -/** - * @see - * - * @author Adrian Cole - */ -public final class Policy { - - private final String owner; - private final String name; - private final String document; - - private Policy(String owner, String name, String document) { - this.name = checkNotNull(name, "name"); - this.owner = checkNotNull(owner, "owner for %s", owner); - this.document = checkNotNull(document, "document for %s", owner); - } - - /** - * The group, user, or role the policy is associated with. - */ - public String getOwner() { - return owner; - } - - /** - * friendly name ex. {@code Developers} - */ - public String getName() { - return name; - } - - /** - * The policy document. - */ - public String getDocument() { - return document; - } - - @Override - public int hashCode() { - return Objects.hashCode(owner, name); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null || getClass() != obj.getClass()) - return false; - Policy that = Policy.class.cast(obj); - return equal(this.owner, that.owner) && equal(this.name, that.name); - } - - @Override - public String toString() { - return toStringHelper(this).add("owner", owner).add("name", name).add("document", document).toString(); - } - - public static Builder builder() { - return new Builder(); - } - - public Builder toBuilder() { - return builder().from(this); - } - - public static class Builder { - private String owner; - private String name; - private String document; - - /** - * @see Policy#getOwner() - */ - public Builder owner(String owner) { - this.owner = owner; - return this; - } - - /** - * @see Policy#getName() - */ - public Builder name(String name) { - this.name = name; - return this; - } - - /** - * @see Policy#getDocument() - */ - public Builder document(String document) { - this.document = document; - return this; - } - - public Policy build() { - return new Policy(owner, name, document); - } - - public Builder from(Policy in) { - return owner(in.owner).name(in.name).document(in.document); - } - } -} diff --git a/labs/iam/src/main/java/org/jclouds/iam/domain/Role.java b/labs/iam/src/main/java/org/jclouds/iam/domain/Role.java deleted file mode 100644 index 9e9f39a101..0000000000 --- a/labs/iam/src/main/java/org/jclouds/iam/domain/Role.java +++ /dev/null @@ -1,190 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.iam.domain; - -import static com.google.common.base.Objects.equal; -import static com.google.common.base.Objects.toStringHelper; -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.Date; - -import com.google.common.base.Objects; - -/** - * @see - * - * @author Adrian Cole - */ -public final class Role { - - private final String arn; - private final String id; - private final String name; - private final String path; - private final Date createDate; - private final String assumeRolePolicy; - - private Role(String arn, String id, String name, String path, Date createDate, String assumeRolePolicy) { - this.arn = checkNotNull(arn, "arn"); - this.id = checkNotNull(id, "id for %s", arn); - this.name = checkNotNull(name, "name for %s", arn); - this.path = checkNotNull(path, "path for %s", arn); - this.createDate = checkNotNull(createDate, "createDate for %s", arn); - this.assumeRolePolicy = checkNotNull(assumeRolePolicy, "assumeRolePolicy for %s", - assumeRolePolicy); - } - - /** - * how to specify the resource in the access policy language ex. - * {@code arn:aws::::} - */ - public String getArn() { - return arn; - } - - /** - * a globally unique identifier (GUID), returned from the api. - */ - public String getId() { - return id; - } - - /** - * friendly name ex. {@code Developers} - */ - public String getName() { - return name; - } - - /** - * path ex {@code /division_abc/subdivision_xyz/product_1234/engineering/} - */ - public String getPath() { - return path; - } - - /** - * Date the role was created - */ - public Date getCreateDate() { - return createDate; - } - - /** - * The policy that grants an entity permission to assume the role. - */ - public String getAssumeRolePolicy() { - return assumeRolePolicy; - } - - @Override - public int hashCode() { - return Objects.hashCode(arn, id); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null || getClass() != obj.getClass()) - return false; - Role that = Role.class.cast(obj); - return equal(this.arn, that.arn) && equal(this.id, that.id); - } - - @Override - public String toString() { - return toStringHelper(this).add("arn", arn).add("id", id).add("name", name).add("path", path) - .add("createDate", createDate).add("assumeRolePolicy", assumeRolePolicy).toString(); - } - - public static Builder builder() { - return new Builder(); - } - - public Builder toBuilder() { - return builder().from(this); - } - - public static class Builder { - private String arn; - private String id; - private String name; - private String path; - private Date createDate; - private String assumeRolePolicy; - - /** - * @see Role#getArn() - */ - public Builder arn(String arn) { - this.arn = arn; - return this; - } - - /** - * @see Role#getId() - */ - public Builder id(String id) { - this.id = id; - return this; - } - - /** - * @see Role#getName() - */ - public Builder name(String name) { - this.name = name; - return this; - } - - /** - * @see Role#getPath() - */ - public Builder path(String path) { - this.path = path; - return this; - } - - /** - * @see Role#getCreateDate() - */ - public Builder createDate(Date createDate) { - this.createDate = createDate; - return this; - } - - /** - * @see Role#getAssumeRolePolicy() - */ - public Builder assumeRolePolicy(String assumeRolePolicy) { - this.assumeRolePolicy = assumeRolePolicy; - return this; - } - - public Role build() { - return new Role(arn, id, name, path, createDate, assumeRolePolicy); - } - - public Builder from(Role in) { - return arn(in.arn).id(in.id).name(in.name).path(in.path).createDate(in.createDate) - .assumeRolePolicy(in.assumeRolePolicy); - } - } -} diff --git a/labs/iam/src/main/java/org/jclouds/iam/domain/User.java b/labs/iam/src/main/java/org/jclouds/iam/domain/User.java deleted file mode 100644 index 003355536f..0000000000 --- a/labs/iam/src/main/java/org/jclouds/iam/domain/User.java +++ /dev/null @@ -1,171 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.iam.domain; - -import static com.google.common.base.Objects.equal; -import static com.google.common.base.Objects.toStringHelper; -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.Date; - -import com.google.common.base.Objects; -import com.google.common.base.Optional; - -/** - * @see - * - * @author Adrian Cole - */ -public final class User { - - private final String arn; - private final String id; - private final Optional name; - private final Optional path; - private final Date createDate; - - private User(String arn, String id, Optional name, Optional path, Date createDate) { - this.arn = checkNotNull(arn, "arn"); - this.id = checkNotNull(id, "id for %s", arn); - this.name = checkNotNull(name, "name for %s", arn); - this.path = checkNotNull(path, "path for %s", arn); - this.createDate = checkNotNull(createDate, "createDate for %s", arn); - } - - /** - * how to specify the resource in the access policy language ex. - * {@code arn:aws::::} - */ - public String getArn() { - return arn; - } - - /** - * a globally unique identifier (GUID), returned from the api. - */ - public String getId() { - return id; - } - - /** - * friendly name ex. {@code Developers} - */ - public Optional getName() { - return name; - } - - /** - * path ex {@code /division_abc/subdivision_xyz/product_1234/engineering/} - */ - public Optional getPath() { - return path; - } - - /** - * Date the user was created - */ - public Date getCreateDate() { - return createDate; - } - - @Override - public int hashCode() { - return Objects.hashCode(arn, id); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null || getClass() != obj.getClass()) - return false; - User that = User.class.cast(obj); - return equal(this.arn, that.arn) && equal(this.id, that.id); - } - - @Override - public String toString() { - return toStringHelper(this).omitNullValues().add("arn", arn).add("id", id).add("name", name.orNull()) - .add("path", path.orNull()).add("createDate", createDate).toString(); - } - - public static Builder builder() { - return new Builder(); - } - - public Builder toBuilder() { - return builder().from(this); - } - - public static class Builder { - private String arn; - private String id; - private Optional name = Optional.absent(); - private Optional path = Optional.absent(); - private Date createDate; - - /** - * @see User#getArn() - */ - public Builder arn(String arn) { - this.arn = arn; - return this; - } - - /** - * @see User#getId() - */ - public Builder id(String id) { - this.id = id; - return this; - } - - /** - * @see User#getName() - */ - public Builder name(String name) { - this.name = Optional.fromNullable(name); - return this; - } - - /** - * @see User#getPath() - */ - public Builder path(String path) { - this.path = Optional.fromNullable(path); - return this; - } - - /** - * @see User#getCreateDate() - */ - public Builder createDate(Date createDate) { - this.createDate = createDate; - return this; - } - - public User build() { - return new User(arn, id, name, path, createDate); - } - - public Builder from(User in) { - return arn(in.arn).id(in.id).name(in.name.orNull()).path(in.path.orNull()).createDate(in.createDate); - } - } -} diff --git a/labs/iam/src/main/java/org/jclouds/iam/features/InstanceProfileApi.java b/labs/iam/src/main/java/org/jclouds/iam/features/InstanceProfileApi.java deleted file mode 100644 index 92e9c94684..0000000000 --- a/labs/iam/src/main/java/org/jclouds/iam/features/InstanceProfileApi.java +++ /dev/null @@ -1,127 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.iam.features; - -import org.jclouds.collect.IterableWithMarker; -import org.jclouds.collect.PagedIterable; -import org.jclouds.iam.domain.InstanceProfile; -import org.jclouds.javax.annotation.Nullable; - -/** - * @see InstanceProfileAsyncApi - * @author Adrian Cole - */ -public interface InstanceProfileApi { - - /** - * Creates a new instance profile for your AWS account - * - * @param name - * Name of the instance profile to create. - * @return the new instance profile - */ - InstanceProfile create(String name); - - /** - * like {@link #create(String)}, except you can specify a path. - */ - InstanceProfile createWithPath(String name, String path); - - /** - * returns all instance profiles in order. - */ - PagedIterable list(); - - /** - * retrieves up to 100 instance profiles in order. - */ - IterableWithMarker listFirstPage(); - - /** - * retrieves up to 100 instance profiles in order, starting at {@code marker} - * - * @param marker - * starting point to resume the list - */ - IterableWithMarker listAt(String marker); - - /** - * returns all instance profiles in order at the specified {@code pathPrefix}. - * - * @param pathPrefix - * ex. {@code /division_abc/subdivision_xyz/} - */ - PagedIterable listPathPrefix(String pathPrefix); - - /** - * retrieves up to 100 instance profiles in order at the specified {@code pathPrefix}. - * - * @param pathPrefix - * ex. {@code /division_abc/subdivision_xyz/} - */ - IterableWithMarker listPathPrefixFirstPage(String pathPrefix); - - /** - * retrieves up to 100 instance profiles in order at the specified {@code pathPrefix}, starting at {@code marker}. - * - * @param pathPrefix - * ex. {@code /division_abc/subdivision_xyz/} - * @param marker - * starting point to resume the list - */ - IterableWithMarker listPathPrefixAt(String pathPrefix, String marker); - - /** - * Retrieves information about the specified instance profile, including the instance profile's path, GUID, and ARN. - * - * @param name - * Name of the instance profile to get information about. - * @return null if not found - */ - @Nullable - InstanceProfile get(String name); - - /** - * Deletes the specified instanceProfile. The instance profile must not have any policies attached. - * - * @param name - * Name of the instance profile to delete - */ - void delete(String name); - - /** - * Adds the specified role to the specified instance profile. - * - * @param name - * Name of the instance profile to update. - * @param roleName - * Name of the role to add - */ - void addRole(String name, String roleName); - - /** - * Removes the specified role from the specified instance profile. - * - * @param name - * Name of the instance profile to update. - * @param roleName - * Name of the role to remove - */ - void removeRole(String name, String roleName); -} diff --git a/labs/iam/src/main/java/org/jclouds/iam/features/InstanceProfileAsyncApi.java b/labs/iam/src/main/java/org/jclouds/iam/features/InstanceProfileAsyncApi.java deleted file mode 100644 index e11998988b..0000000000 --- a/labs/iam/src/main/java/org/jclouds/iam/features/InstanceProfileAsyncApi.java +++ /dev/null @@ -1,180 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.iam.features; - -import javax.inject.Named; -import javax.ws.rs.FormParam; -import javax.ws.rs.POST; -import javax.ws.rs.Path; - -import org.jclouds.Fallbacks.NullOnNotFoundOr404; -import org.jclouds.Fallbacks.VoidOnNotFoundOr404; -import org.jclouds.aws.filters.FormSigner; -import org.jclouds.collect.IterableWithMarker; -import org.jclouds.collect.PagedIterable; -import org.jclouds.iam.domain.InstanceProfile; -import org.jclouds.iam.functions.InstanceProfilesToPagedIterable; -import org.jclouds.iam.xml.InstanceProfileHandler; -import org.jclouds.iam.xml.ListInstanceProfilesResultHandler; -import org.jclouds.rest.annotations.Fallback; -import org.jclouds.rest.annotations.FormParams; -import org.jclouds.rest.annotations.RequestFilters; -import org.jclouds.rest.annotations.Transform; -import org.jclouds.rest.annotations.VirtualHost; -import org.jclouds.rest.annotations.XMLResponseParser; - -import com.google.common.util.concurrent.ListenableFuture; - -/** - * Provides access to Amazon IAM via the Query API - *

- * - * @see - * @author Adrian Cole - */ -@RequestFilters(FormSigner.class) -@VirtualHost -public interface InstanceProfileAsyncApi { - /** - * @see InstanceProfileApi#create - */ - @Named("CreateInstanceProfile") - @POST - @Path("/") - @FormParams(keys = "Action", values = "CreateInstanceProfile") - @XMLResponseParser(InstanceProfileHandler.class) - ListenableFuture create(@FormParam("InstanceProfileName") String name); - - /** - * @see InstanceProfileApi#createWithPath - */ - @Named("CreateInstanceProfile") - @POST - @Path("/") - @FormParams(keys = "Action", values = "CreateInstanceProfile") - @XMLResponseParser(InstanceProfileHandler.class) - ListenableFuture createWithPath(@FormParam("InstanceProfileName") String name, - @FormParam("Path") String path); - - /** - * @see InstanceProfileApi#list() - */ - @Named("ListInstanceProfiles") - @POST - @Path("/") - @FormParams(keys = "Action", values = "ListInstanceProfiles") - @XMLResponseParser(ListInstanceProfilesResultHandler.class) - @Transform(InstanceProfilesToPagedIterable.class) - ListenableFuture> list(); - - /** - * @see InstanceProfileApi#listFirstPage - */ - @Named("ListInstanceProfiles") - @POST - @Path("/") - @FormParams(keys = "Action", values = "ListInstanceProfiles") - @XMLResponseParser(ListInstanceProfilesResultHandler.class) - ListenableFuture> listFirstPage(); - - /** - * @see InstanceProfileApi#listAt(String) - */ - @Named("ListInstanceProfiles") - @POST - @Path("/") - @FormParams(keys = "Action", values = "ListInstanceProfiles") - @XMLResponseParser(ListInstanceProfilesResultHandler.class) - ListenableFuture> listAt(@FormParam("Marker") String marker); - - /** - * @see InstanceProfileApi#listPathPrefix(String) - */ - @Named("ListInstanceProfiles") - @POST - @Path("/") - @FormParams(keys = "Action", values = "ListInstanceProfiles") - @XMLResponseParser(ListInstanceProfilesResultHandler.class) - @Transform(InstanceProfilesToPagedIterable.class) - ListenableFuture> listPathPrefix(@FormParam("PathPrefix") String pathPrefix); - - /** - * @see InstanceProfileApi#listPathPrefixFirstPage(String) - */ - @Named("ListInstanceProfiles") - @POST - @Path("/") - @FormParams(keys = "Action", values = "ListInstanceProfiles") - @XMLResponseParser(ListInstanceProfilesResultHandler.class) - ListenableFuture> listPathPrefixFirstPage( - @FormParam("PathPrefix") String pathPrefix); - - /** - * @see InstanceProfileApi#listPathPrefixAt(String, String) - */ - @Named("ListInstanceProfiles") - @POST - @Path("/") - @FormParams(keys = "Action", values = "ListInstanceProfiles") - @XMLResponseParser(ListInstanceProfilesResultHandler.class) - ListenableFuture> listPathPrefixAt(@FormParam("PathPrefix") String pathPrefix, - @FormParam("Marker") String marker); - - /** - * @see InstanceProfileApi#get() - */ - @Named("GetInstanceProfile") - @POST - @Path("/") - @XMLResponseParser(InstanceProfileHandler.class) - @FormParams(keys = "Action", values = "GetInstanceProfile") - @Fallback(NullOnNotFoundOr404.class) - ListenableFuture get(@FormParam("InstanceProfileName") String name); - - /** - * @see InstanceProfileApi#delete() - */ - @Named("DeleteInstanceProfile") - @POST - @Path("/") - @FormParams(keys = "Action", values = "DeleteInstanceProfile") - @Fallback(VoidOnNotFoundOr404.class) - ListenableFuture delete(@FormParam("InstanceProfileName") String name); - - /** - * @see InstanceProfileApi#addRole() - */ - @Named("AddRoleToInstanceProfile") - @POST - @Path("/") - @FormParams(keys = "Action", values = "AddRoleToInstanceProfile") - @Fallback(VoidOnNotFoundOr404.class) - ListenableFuture addRole(@FormParam("InstanceProfileName") String name, @FormParam("RoleName") String roleName); - - /** - * @see InstanceProfileApi#removeRole() - */ - @Named("RemoveRoleFromInstanceProfile") - @POST - @Path("/") - @FormParams(keys = "Action", values = "RemoveRoleFromInstanceProfile") - @Fallback(VoidOnNotFoundOr404.class) - ListenableFuture removeRole(@FormParam("InstanceProfileName") String name, - @FormParam("RoleName") String roleName); -} diff --git a/labs/iam/src/main/java/org/jclouds/iam/features/PolicyApi.java b/labs/iam/src/main/java/org/jclouds/iam/features/PolicyApi.java deleted file mode 100644 index 6f445b7ded..0000000000 --- a/labs/iam/src/main/java/org/jclouds/iam/features/PolicyApi.java +++ /dev/null @@ -1,76 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.iam.features; - -import org.jclouds.collect.IterableWithMarker; -import org.jclouds.collect.PagedIterable; -import org.jclouds.iam.domain.Policy; -import org.jclouds.javax.annotation.Nullable; - -/** - * @author Adrian Cole - */ -public interface PolicyApi { - - /** - * Adds (or updates) a policy document. - * - * @param name - * Name of the policy document. - * @param document - * The policy document. - */ - void create(String name, String document); - - /** - * returns all policy names in order. - */ - PagedIterable list(); - - /** - * retrieves up to 100 policy names in order. - */ - IterableWithMarker listFirstPage(); - - /** - * retrieves up to 100 policy names in order, starting at {@code marker} - * - * @param marker - * starting point to resume the list - */ - IterableWithMarker listAt(String marker); - - /** - * Retrieves the specified policy document. - * - * @param name - * Name of the policy to get information about. - * @return null if not found - */ - @Nullable - Policy get(String name); - - /** - * Deletes the specified policy. - * - * @param name - * Name of the policy to delete - */ - void delete(String name); -} diff --git a/labs/iam/src/main/java/org/jclouds/iam/features/RoleApi.java b/labs/iam/src/main/java/org/jclouds/iam/features/RoleApi.java deleted file mode 100644 index 78e278646c..0000000000 --- a/labs/iam/src/main/java/org/jclouds/iam/features/RoleApi.java +++ /dev/null @@ -1,136 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.iam.features; - -import org.jclouds.collect.IterableWithMarker; -import org.jclouds.collect.PagedIterable; -import org.jclouds.iam.domain.InstanceProfile; -import org.jclouds.iam.domain.Role; -import org.jclouds.javax.annotation.Nullable; - -/** - * @see RoleAsyncApi - * @author Adrian Cole - */ -public interface RoleApi { - - /** - * Creates a new role for your AWS account - * - * @param name - * Name of the role to create. - * @param assumeRolePolicy - * The policy that grants an entity permission to assume the role.} - * @return the new role - */ - Role createWithPolicy(String name, String assumeRolePolicy); - - /** - * like {@link #createWithPolicy(String, String)}, except you can specify a path. - */ - Role createWithPolicyAndPath(String name, String assumeRolePolicy, String path); - - /** - * returns all roles in order. - */ - PagedIterable list(); - - /** - * retrieves up to 100 roles in order. - */ - IterableWithMarker listFirstPage(); - - /** - * retrieves up to 100 roles in order, starting at {@code marker} - * - * @param marker - * starting point to resume the list - */ - IterableWithMarker listAt(String marker); - - /** - * returns all roles in order at the specified {@code pathPrefix}. - * - * @param pathPrefix - * ex. {@code /division_abc/subdivision_xyz/} - */ - PagedIterable listPathPrefix(String pathPrefix); - - /** - * retrieves up to 100 roles in order at the specified {@code pathPrefix}. - * - * @param pathPrefix - * ex. {@code /division_abc/subdivision_xyz/} - */ - IterableWithMarker listPathPrefixFirstPage(String pathPrefix); - - /** - * retrieves up to 100 roles in order at the specified {@code pathPrefix}, starting at {@code marker}. - * - * @param pathPrefix - * ex. {@code /division_abc/subdivision_xyz/} - * @param marker - * starting point to resume the list - */ - IterableWithMarker listPathPrefixAt(String pathPrefix, String marker); - - /** - * Retrieves information about the specified role, including the role's path, GUID, and ARN. - * - * @param name - * Name of the role to get information about. - * @return null if not found - */ - @Nullable - Role get(String name); - - /** - * returns all instance profiles in order for this role. - * - * @param name - * Name of the role to get instance profiles for. - */ - PagedIterable listInstanceProfiles(String name); - - /** - * retrieves up to 100 instance profiles in order for this role. - * - * @param name - * Name of the role to get instance profiles for. - */ - IterableWithMarker listFirstPageOfInstanceProfiles(String name); - - /** - * retrieves up to 100 instance profiles in order for this role, starting at {@code marker} - * - * @param name - * Name of the role to get instance profiles for. - * @param marker - * starting point to resume the list - */ - IterableWithMarker listInstanceProfilesAt(String name, String marker); - - /** - * Deletes the specified role. The role must not have any policies attached. - * - * @param name - * Name of the role to delete - */ - void delete(String name); -} diff --git a/labs/iam/src/main/java/org/jclouds/iam/features/RoleAsyncApi.java b/labs/iam/src/main/java/org/jclouds/iam/features/RoleAsyncApi.java deleted file mode 100644 index 20e5986e73..0000000000 --- a/labs/iam/src/main/java/org/jclouds/iam/features/RoleAsyncApi.java +++ /dev/null @@ -1,195 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.iam.features; - -import javax.inject.Named; -import javax.ws.rs.FormParam; -import javax.ws.rs.POST; -import javax.ws.rs.Path; - -import org.jclouds.Fallbacks.NullOnNotFoundOr404; -import org.jclouds.Fallbacks.VoidOnNotFoundOr404; -import org.jclouds.aws.filters.FormSigner; -import org.jclouds.collect.IterableWithMarker; -import org.jclouds.collect.PagedIterable; -import org.jclouds.iam.domain.InstanceProfile; -import org.jclouds.iam.domain.Role; -import org.jclouds.iam.functions.InstanceProfilesForRoleToPagedIterable; -import org.jclouds.iam.functions.RolesToPagedIterable; -import org.jclouds.iam.xml.ListInstanceProfilesResultHandler; -import org.jclouds.iam.xml.ListRolesResultHandler; -import org.jclouds.iam.xml.RoleHandler; -import org.jclouds.rest.annotations.Fallback; -import org.jclouds.rest.annotations.FormParams; -import org.jclouds.rest.annotations.RequestFilters; -import org.jclouds.rest.annotations.Transform; -import org.jclouds.rest.annotations.VirtualHost; -import org.jclouds.rest.annotations.XMLResponseParser; - -import com.google.common.util.concurrent.ListenableFuture; - -/** - * Provides access to Amazon IAM via the Query API - *

- * - * @see - * @author Adrian Cole - */ -@RequestFilters(FormSigner.class) -@VirtualHost -public interface RoleAsyncApi { - /** - * @see RoleApi#createWithPolicy - */ - @Named("CreateRole") - @POST - @Path("/") - @FormParams(keys = "Action", values = "CreateRole") - @XMLResponseParser(RoleHandler.class) - ListenableFuture createWithPolicy(@FormParam("RoleName") String name, - @FormParam("AssumeRolePolicyDocument") String assumeRolePolicy); - - /** - * @see RoleApi#createWithPolicyAndPath - */ - @Named("CreateRole") - @POST - @Path("/") - @FormParams(keys = "Action", values = "CreateRole") - @XMLResponseParser(RoleHandler.class) - ListenableFuture createWithPolicyAndPath(@FormParam("RoleName") String name, - @FormParam("AssumeRolePolicyDocument") String assumeRolePolicy, @FormParam("Path") String path); - - /** - * @see RoleApi#list() - */ - @Named("ListRoles") - @POST - @Path("/") - @FormParams(keys = "Action", values = "ListRoles") - @XMLResponseParser(ListRolesResultHandler.class) - @Transform(RolesToPagedIterable.class) - ListenableFuture> list(); - - /** - * @see RoleApi#listFirstPage - */ - @Named("ListRoles") - @POST - @Path("/") - @FormParams(keys = "Action", values = "ListRoles") - @XMLResponseParser(ListRolesResultHandler.class) - ListenableFuture> listFirstPage(); - - /** - * @see RoleApi#listAt(String) - */ - @Named("ListRoles") - @POST - @Path("/") - @FormParams(keys = "Action", values = "ListRoles") - @XMLResponseParser(ListRolesResultHandler.class) - ListenableFuture> listAt(@FormParam("Marker") String marker); - - /** - * @see RoleApi#listPathPrefix(String) - */ - @Named("ListRoles") - @POST - @Path("/") - @FormParams(keys = "Action", values = "ListRoles") - @XMLResponseParser(ListRolesResultHandler.class) - @Transform(RolesToPagedIterable.class) - ListenableFuture> listPathPrefix(@FormParam("PathPrefix") String pathPrefix); - - /** - * @see RoleApi#listPathPrefixFirstPage(String) - */ - @Named("ListRoles") - @POST - @Path("/") - @FormParams(keys = "Action", values = "ListRoles") - @XMLResponseParser(ListRolesResultHandler.class) - ListenableFuture> listPathPrefixFirstPage(@FormParam("PathPrefix") String pathPrefix); - - /** - * @see RoleApi#listPathPrefixAt(String, String) - */ - @Named("ListRoles") - @POST - @Path("/") - @FormParams(keys = "Action", values = "ListRoles") - @XMLResponseParser(ListRolesResultHandler.class) - ListenableFuture> listPathPrefixAt(@FormParam("PathPrefix") String pathPrefix, - @FormParam("Marker") String marker); - - /** - * @see RoleApi#get() - */ - @Named("GetRole") - @POST - @Path("/") - @XMLResponseParser(RoleHandler.class) - @FormParams(keys = "Action", values = "GetRole") - @Fallback(NullOnNotFoundOr404.class) - ListenableFuture get(@FormParam("RoleName") String name); - - /** - * @see RoleApi#listInstanceProfiles() - */ - @Named("ListInstanceProfilesForRole") - @POST - @Path("/") - @FormParams(keys = "Action", values = "ListInstanceProfilesForRole") - @XMLResponseParser(ListInstanceProfilesResultHandler.class) - @Transform(InstanceProfilesForRoleToPagedIterable.class) - ListenableFuture> listInstanceProfiles(@FormParam("RoleName") String name); - - /** - * @see RoleApi#listFirstPageOfInstanceProfiles - */ - @Named("ListInstanceProfilesForRole") - @POST - @Path("/") - @FormParams(keys = "Action", values = "ListInstanceProfilesForRole") - @XMLResponseParser(ListInstanceProfilesResultHandler.class) - ListenableFuture> listFirstPageOfInstanceProfiles( - @FormParam("RoleName") String name); - - /** - * @see RoleApi#listInstanceProfilesAt(String) - */ - @Named("ListInstanceProfilesForRole") - @POST - @Path("/") - @FormParams(keys = "Action", values = "ListInstanceProfilesForRole") - @XMLResponseParser(ListInstanceProfilesResultHandler.class) - ListenableFuture> listInstanceProfilesAt(@FormParam("RoleName") String name, - @FormParam("Marker") String marker); - - /** - * @see RoleApi#delete() - */ - @Named("DeleteRole") - @POST - @Path("/") - @FormParams(keys = "Action", values = "DeleteRole") - @Fallback(VoidOnNotFoundOr404.class) - ListenableFuture delete(@FormParam("RoleName") String name); -} diff --git a/labs/iam/src/main/java/org/jclouds/iam/features/RolePolicyApi.java b/labs/iam/src/main/java/org/jclouds/iam/features/RolePolicyApi.java deleted file mode 100644 index 1d376fb707..0000000000 --- a/labs/iam/src/main/java/org/jclouds/iam/features/RolePolicyApi.java +++ /dev/null @@ -1,29 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.iam.features; - - -/** - * @see RolePolicyAsyncApi - * - * @author Adrian Cole - */ -public interface RolePolicyApi extends PolicyApi { - -} diff --git a/labs/iam/src/main/java/org/jclouds/iam/features/RolePolicyAsyncApi.java b/labs/iam/src/main/java/org/jclouds/iam/features/RolePolicyAsyncApi.java deleted file mode 100644 index 6c19d51988..0000000000 --- a/labs/iam/src/main/java/org/jclouds/iam/features/RolePolicyAsyncApi.java +++ /dev/null @@ -1,113 +0,0 @@ -/** - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.iam.features; - -import javax.inject.Named; -import javax.ws.rs.FormParam; -import javax.ws.rs.POST; -import javax.ws.rs.Path; - -import org.jclouds.Fallbacks.NullOnNotFoundOr404; -import org.jclouds.Fallbacks.VoidOnNotFoundOr404; -import org.jclouds.aws.filters.FormSigner; -import org.jclouds.collect.IterableWithMarker; -import org.jclouds.collect.PagedIterable; -import org.jclouds.iam.domain.Policy; -import org.jclouds.iam.functions.PoliciesToPagedIterable.RolePoliciesToPagedIterable; -import org.jclouds.iam.xml.ListPoliciesResultHandler; -import org.jclouds.iam.xml.PolicyHandler; -import org.jclouds.rest.annotations.Fallback; -import org.jclouds.rest.annotations.FormParams; -import org.jclouds.rest.annotations.RequestFilters; -import org.jclouds.rest.annotations.Transform; -import org.jclouds.rest.annotations.VirtualHost; -import org.jclouds.rest.annotations.XMLResponseParser; - -import com.google.common.util.concurrent.ListenableFuture; - -/** - * Provides access to Amazon IAM via the Query API - *

- * - * @see - * @author Adrian Cole - */ -@RequestFilters(FormSigner.class) -@VirtualHost -public interface RolePolicyAsyncApi { - /** - * @see RolePolicyApi#create - */ - @Named("PutRolePolicy") - @POST - @Path("/") - @FormParams(keys = "Action", values = "PutRolePolicy") - ListenableFuture create(@FormParam("PolicyName") String name, @FormParam("PolicyDocument") String document); - - /** - * @see RolePolicyApi#list() - */ - @Named("ListRolePolicies") - @POST - @Path("/") - @FormParams(keys = "Action", values = "ListRolePolicies") - @XMLResponseParser(ListPoliciesResultHandler.class) - @Transform(RolePoliciesToPagedIterable.class) - ListenableFuture> list(); - - /** - * @see RolePolicyApi#listFirstPage - */ - @Named("ListRolePolicies") - @POST - @Path("/") - @FormParams(keys = "Action", values = "ListRolePolicies") - @XMLResponseParser(ListPoliciesResultHandler.class) - ListenableFuture> listFirstPage(); - - /** - * @see RolePolicyApi#listAt(String) - */ - @Named("ListRolePolicies") - @POST - @Path("/") - @FormParams(keys = "Action", values = "ListRolePolicies") - @XMLResponseParser(ListPoliciesResultHandler.class) - ListenableFuture> listAt(@FormParam("Marker") String marker); - - /** - * @see RolePolicyApi#get() - */ - @Named("GetRolePolicy") - @POST - @Path("/") - @XMLResponseParser(PolicyHandler.class) - @FormParams(keys = "Action", values = "GetRolePolicy") - @Fallback(NullOnNotFoundOr404.class) - ListenableFuture get(@FormParam("PolicyName") String name); - - /** - * @see RolePolicyApi#delete() - */ - @Named("DeleteRolePolicy") - @POST - @Path("/") - @FormParams(keys = "Action", values = "DeleteRolePolicy") - @Fallback(VoidOnNotFoundOr404.class) - ListenableFuture delete(@FormParam("PolicyName") String name); -} diff --git a/labs/iam/src/main/java/org/jclouds/iam/features/UserApi.java b/labs/iam/src/main/java/org/jclouds/iam/features/UserApi.java deleted file mode 100644 index 52f73fe51a..0000000000 --- a/labs/iam/src/main/java/org/jclouds/iam/features/UserApi.java +++ /dev/null @@ -1,90 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.iam.features; - -import org.jclouds.collect.IterableWithMarker; -import org.jclouds.collect.PagedIterable; -import org.jclouds.iam.domain.User; -import org.jclouds.javax.annotation.Nullable; - -/** - * - * @see UserAsyncApi - * @author Adrian Cole - */ -public interface UserApi { - /** - * Retrieves information about the current user, including the user's path, GUID, and ARN. - */ - User getCurrent(); - - /** - * returns all users in order. - */ - PagedIterable list(); - - /** - * retrieves up to 100 users in order. - */ - IterableWithMarker listFirstPage(); - - /** - * retrieves up to 100 users in order, starting at {@code marker} - * - * @param marker - * starting point to resume the list - */ - IterableWithMarker listAt(String marker); - - /** - * returns all users in order at the specified {@code pathPrefix}. - * - * @param pathPrefix - * ex. {@code /division_abc/subdivision_xyz/} - */ - PagedIterable listPathPrefix(String pathPrefix); - - /** - * retrieves up to 100 users in order at the specified {@code pathPrefix}. - * - * @param pathPrefix - * ex. {@code /division_abc/subdivision_xyz/} - */ - IterableWithMarker listPathPrefixFirstPage(String pathPrefix); - - /** - * retrieves up to 100 users in order at the specified {@code pathPrefix}, starting at {@code marker}. - * - * @param pathPrefix - * ex. {@code /division_abc/subdivision_xyz/} - * @param marker - * starting point to resume the list - */ - IterableWithMarker listPathPrefixAt(String pathPrefix, String marker); - - /** - * Retrieves information about the specified user, including the user's path, GUID, and ARN. - * - * @param name - * Name of the user to get information about. - * @return null if not found - */ - @Nullable - User get(String name); -} diff --git a/labs/iam/src/main/java/org/jclouds/iam/features/UserAsyncApi.java b/labs/iam/src/main/java/org/jclouds/iam/features/UserAsyncApi.java deleted file mode 100644 index e2cbb96dcd..0000000000 --- a/labs/iam/src/main/java/org/jclouds/iam/features/UserAsyncApi.java +++ /dev/null @@ -1,137 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.iam.features; - -import javax.inject.Named; -import javax.ws.rs.FormParam; -import javax.ws.rs.POST; -import javax.ws.rs.Path; - -import org.jclouds.Fallbacks.NullOnNotFoundOr404; -import org.jclouds.aws.filters.FormSigner; -import org.jclouds.collect.IterableWithMarker; -import org.jclouds.collect.PagedIterable; -import org.jclouds.iam.domain.User; -import org.jclouds.iam.functions.UsersToPagedIterable; -import org.jclouds.iam.xml.ListUsersResultHandler; -import org.jclouds.iam.xml.UserHandler; -import org.jclouds.rest.annotations.Fallback; -import org.jclouds.rest.annotations.FormParams; -import org.jclouds.rest.annotations.RequestFilters; -import org.jclouds.rest.annotations.Transform; -import org.jclouds.rest.annotations.VirtualHost; -import org.jclouds.rest.annotations.XMLResponseParser; - -import com.google.common.util.concurrent.ListenableFuture; - -/** - * Provides access to Amazon IAM via the Query API - *

- * - * @see - * @author Adrian Cole - */ -@RequestFilters(FormSigner.class) -@VirtualHost -public interface UserAsyncApi { - - /** - * @see UserApi#list() - */ - @Named("ListUsers") - @POST - @Path("/") - @FormParams(keys = "Action", values = "ListUsers") - @XMLResponseParser(ListUsersResultHandler.class) - @Transform(UsersToPagedIterable.class) - ListenableFuture> list(); - - /** - * @see UserApi#listFirstPage - */ - @Named("ListUsers") - @POST - @Path("/") - @FormParams(keys = "Action", values = "ListUsers") - @XMLResponseParser(ListUsersResultHandler.class) - ListenableFuture> listFirstPage(); - - /** - * @see UserApi#listAt(String) - */ - @Named("ListUsers") - @POST - @Path("/") - @FormParams(keys = "Action", values = "ListUsers") - @XMLResponseParser(ListUsersResultHandler.class) - ListenableFuture> listAt(@FormParam("Marker") String marker); - - /** - * @see UserApi#listPathPrefix(String) - */ - @Named("ListUsers") - @POST - @Path("/") - @FormParams(keys = "Action", values = "ListUsers") - @XMLResponseParser(ListUsersResultHandler.class) - @Transform(UsersToPagedIterable.class) - ListenableFuture> listPathPrefix(@FormParam("PathPrefix") String pathPrefix); - - /** - * @see UserApi#listPathPrefixFirstPage(String) - */ - @Named("ListUsers") - @POST - @Path("/") - @FormParams(keys = "Action", values = "ListUsers") - @XMLResponseParser(ListUsersResultHandler.class) - ListenableFuture> listPathPrefixFirstPage(@FormParam("PathPrefix") String pathPrefix); - - /** - * @see UserApi#listPathPrefixAt(String, String) - */ - @Named("ListUsers") - @POST - @Path("/") - @FormParams(keys = "Action", values = "ListUsers") - @XMLResponseParser(ListUsersResultHandler.class) - ListenableFuture> listPathPrefixAt(@FormParam("PathPrefix") String pathPrefix, - @FormParam("Marker") String marker); - - /** - * @see UserApi#getCurrent() - */ - @Named("GetUser") - @POST - @Path("/") - @XMLResponseParser(UserHandler.class) - @FormParams(keys = "Action", values = "GetUser") - ListenableFuture getCurrent(); - - /** - * @see UserApi#get() - */ - @Named("GetUser") - @POST - @Path("/") - @XMLResponseParser(UserHandler.class) - @FormParams(keys = "Action", values = "GetUser") - @Fallback(NullOnNotFoundOr404.class) - ListenableFuture get(@FormParam("UserName") String name); -} diff --git a/labs/iam/src/main/java/org/jclouds/iam/functions/InstanceProfilesForRoleToPagedIterable.java b/labs/iam/src/main/java/org/jclouds/iam/functions/InstanceProfilesForRoleToPagedIterable.java deleted file mode 100644 index b91fd56536..0000000000 --- a/labs/iam/src/main/java/org/jclouds/iam/functions/InstanceProfilesForRoleToPagedIterable.java +++ /dev/null @@ -1,73 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.iam.functions; - -import static com.google.common.base.Preconditions.checkNotNull; - -import javax.inject.Inject; - -import org.jclouds.collect.IterableWithMarker; -import org.jclouds.collect.internal.Arg0ToPagedIterable; -import org.jclouds.iam.IAMApi; -import org.jclouds.iam.domain.InstanceProfile; -import org.jclouds.iam.features.RoleApi; - -import com.google.common.annotations.Beta; -import com.google.common.base.Function; -import com.google.common.base.Optional; - -/** - * @author Adrian Cole - */ -@Beta -public class InstanceProfilesForRoleToPagedIterable extends - Arg0ToPagedIterable { - - private final RoleApi api; - - @Inject - protected InstanceProfilesForRoleToPagedIterable(IAMApi api) { - this.api = checkNotNull(api, "api").getRoleApi(); - } - - @Override - protected Function> markerToNextForArg0(Optional name) { - return new ListInstanceProfilesPrefixAtMarker(api, name.get().toString()); - } - - private static class ListInstanceProfilesPrefixAtMarker implements - Function> { - private final RoleApi api; - private final String name; - - @Inject - protected ListInstanceProfilesPrefixAtMarker(RoleApi api, String name) { - this.api = checkNotNull(api, "api"); - this.name = checkNotNull(name, "name"); - } - - public IterableWithMarker apply(Object input) { - return api.listInstanceProfilesAt(name, input.toString()); - } - - public String toString() { - return "ListInstanceProfilesPrefixAtMarker(" + name + ")"; - } - } -} diff --git a/labs/iam/src/main/java/org/jclouds/iam/functions/InstanceProfilesToPagedIterable.java b/labs/iam/src/main/java/org/jclouds/iam/functions/InstanceProfilesToPagedIterable.java deleted file mode 100644 index 77bf6b1432..0000000000 --- a/labs/iam/src/main/java/org/jclouds/iam/functions/InstanceProfilesToPagedIterable.java +++ /dev/null @@ -1,90 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.iam.functions; - -import static com.google.common.base.Preconditions.checkNotNull; - -import javax.inject.Inject; - -import org.jclouds.collect.IterableWithMarker; -import org.jclouds.collect.internal.Arg0ToPagedIterable; -import org.jclouds.iam.IAMApi; -import org.jclouds.iam.domain.InstanceProfile; -import org.jclouds.iam.features.InstanceProfileApi; - -import com.google.common.annotations.Beta; -import com.google.common.base.Function; -import com.google.common.base.Optional; - -/** - * @author Adrian Cole - */ -@Beta -public class InstanceProfilesToPagedIterable extends Arg0ToPagedIterable { - - private final InstanceProfileApi api; - - @Inject - protected InstanceProfilesToPagedIterable(IAMApi api) { - this.api = checkNotNull(api, "api").getInstanceProfileApi(); - } - - @Override - protected Function> markerToNextForArg0(Optional pathPrefix) { - if (pathPrefix.isPresent()) - return new ListInstanceProfilesUnderPathPrefixAtMarker(api, pathPrefix.get().toString()); - return new ListInstanceProfilesAtMarker(api); - } - - private static class ListInstanceProfilesUnderPathPrefixAtMarker implements Function> { - private final InstanceProfileApi api; - private final String pathPrefix; - - @Inject - protected ListInstanceProfilesUnderPathPrefixAtMarker(InstanceProfileApi api, String pathPrefix) { - this.api = checkNotNull(api, "api"); - this.pathPrefix = checkNotNull(pathPrefix, "pathPrefix"); - } - - public IterableWithMarker apply(Object input) { - return api.listPathPrefixAt(pathPrefix, input.toString()); - } - - public String toString() { - return "ListInstanceProfilesUnderPathPrefixAtMarker(" + pathPrefix + ")"; - } - } - - private static class ListInstanceProfilesAtMarker implements Function> { - private final InstanceProfileApi api; - - @Inject - protected ListInstanceProfilesAtMarker(InstanceProfileApi api) { - this.api = checkNotNull(api, "api"); - } - - public IterableWithMarker apply(Object input) { - return api.listAt(input.toString()); - } - - public String toString() { - return "listInstanceProfilesAtMarker()"; - } - } -} diff --git a/labs/iam/src/main/java/org/jclouds/iam/functions/PoliciesToPagedIterable.java b/labs/iam/src/main/java/org/jclouds/iam/functions/PoliciesToPagedIterable.java deleted file mode 100644 index a2c442dd86..0000000000 --- a/labs/iam/src/main/java/org/jclouds/iam/functions/PoliciesToPagedIterable.java +++ /dev/null @@ -1,70 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.iam.functions; - -import static com.google.common.base.Preconditions.checkNotNull; - -import javax.inject.Inject; - -import org.jclouds.collect.IterableWithMarker; -import org.jclouds.collect.internal.Arg0ToPagedIterable; -import org.jclouds.iam.IAMApi; -import org.jclouds.iam.features.PolicyApi; - -import com.google.common.annotations.Beta; -import com.google.common.base.Function; -import com.google.common.base.Optional; - -/** - * @author Adrian Cole - */ -@Beta -public class PoliciesToPagedIterable { - public static class RolePoliciesToPagedIterable extends Arg0ToPagedIterable.FromCaller { - - private final IAMApi api; - - @Inject - protected RolePoliciesToPagedIterable(IAMApi api) { - this.api = checkNotNull(api, "api"); - } - - @Override - protected Function> markerToNextForArg0(Optional roleName) { - return new ListPoliciesAtMarker(api.getPolicyApiForRole(roleName.get().toString())); - } - } - - private static class ListPoliciesAtMarker implements Function> { - private final PolicyApi api; - - @Inject - protected ListPoliciesAtMarker(PolicyApi api) { - this.api = checkNotNull(api, "api"); - } - - public IterableWithMarker apply(Object input) { - return api.listAt(input.toString()); - } - - public String toString() { - return "listPoliciesAtMarker()"; - } - } -} diff --git a/labs/iam/src/main/java/org/jclouds/iam/functions/RolesToPagedIterable.java b/labs/iam/src/main/java/org/jclouds/iam/functions/RolesToPagedIterable.java deleted file mode 100644 index afe260055a..0000000000 --- a/labs/iam/src/main/java/org/jclouds/iam/functions/RolesToPagedIterable.java +++ /dev/null @@ -1,90 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.iam.functions; - -import static com.google.common.base.Preconditions.checkNotNull; - -import javax.inject.Inject; - -import org.jclouds.collect.IterableWithMarker; -import org.jclouds.collect.internal.Arg0ToPagedIterable; -import org.jclouds.iam.IAMApi; -import org.jclouds.iam.domain.Role; -import org.jclouds.iam.features.RoleApi; - -import com.google.common.annotations.Beta; -import com.google.common.base.Function; -import com.google.common.base.Optional; - -/** - * @author Adrian Cole - */ -@Beta -public class RolesToPagedIterable extends Arg0ToPagedIterable { - - private final RoleApi api; - - @Inject - protected RolesToPagedIterable(IAMApi api) { - this.api = checkNotNull(api, "api").getRoleApi(); - } - - @Override - protected Function> markerToNextForArg0(Optional pathPrefix) { - if (pathPrefix.isPresent()) - return new ListRolesUnderPathPrefixAtMarker(api, pathPrefix.get().toString()); - return new ListRolesAtMarker(api); - } - - private static class ListRolesUnderPathPrefixAtMarker implements Function> { - private final RoleApi api; - private final String pathPrefix; - - @Inject - protected ListRolesUnderPathPrefixAtMarker(RoleApi api, String pathPrefix) { - this.api = checkNotNull(api, "api"); - this.pathPrefix = checkNotNull(pathPrefix, "pathPrefix"); - } - - public IterableWithMarker apply(Object input) { - return api.listPathPrefixAt(pathPrefix, input.toString()); - } - - public String toString() { - return "ListRolesUnderPathPrefixAtMarker(" + pathPrefix + ")"; - } - } - - private static class ListRolesAtMarker implements Function> { - private final RoleApi api; - - @Inject - protected ListRolesAtMarker(RoleApi api) { - this.api = checkNotNull(api, "api"); - } - - public IterableWithMarker apply(Object input) { - return api.listAt(input.toString()); - } - - public String toString() { - return "listRolesAtMarker()"; - } - } -} diff --git a/labs/iam/src/main/java/org/jclouds/iam/functions/UsersToPagedIterable.java b/labs/iam/src/main/java/org/jclouds/iam/functions/UsersToPagedIterable.java deleted file mode 100644 index 085f9005de..0000000000 --- a/labs/iam/src/main/java/org/jclouds/iam/functions/UsersToPagedIterable.java +++ /dev/null @@ -1,90 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.iam.functions; - -import static com.google.common.base.Preconditions.checkNotNull; - -import javax.inject.Inject; - -import org.jclouds.collect.IterableWithMarker; -import org.jclouds.collect.internal.Arg0ToPagedIterable; -import org.jclouds.iam.IAMApi; -import org.jclouds.iam.domain.User; -import org.jclouds.iam.features.UserApi; - -import com.google.common.annotations.Beta; -import com.google.common.base.Function; -import com.google.common.base.Optional; - -/** - * @author Adrian Cole - */ -@Beta -public class UsersToPagedIterable extends Arg0ToPagedIterable { - - private final UserApi api; - - @Inject - protected UsersToPagedIterable(IAMApi api) { - this.api = checkNotNull(api, "api").getUserApi(); - } - - @Override - protected Function> markerToNextForArg0(Optional pathPrefix) { - if (pathPrefix.isPresent()) - return new ListUsersUnderPathPrefixAtMarker(api, pathPrefix.get().toString()); - return new ListUsersAtMarker(api); - } - - private static class ListUsersUnderPathPrefixAtMarker implements Function> { - private final UserApi api; - private final String pathPrefix; - - @Inject - protected ListUsersUnderPathPrefixAtMarker(UserApi api, String pathPrefix) { - this.api = checkNotNull(api, "api"); - this.pathPrefix = checkNotNull(pathPrefix, "pathPrefix"); - } - - public IterableWithMarker apply(Object input) { - return api.listPathPrefixAt(pathPrefix, input.toString()); - } - - public String toString() { - return "ListUsersUnderPathPrefixAtMarker(" + pathPrefix + ")"; - } - } - - private static class ListUsersAtMarker implements Function> { - private final UserApi api; - - @Inject - protected ListUsersAtMarker(UserApi api) { - this.api = checkNotNull(api, "api"); - } - - public IterableWithMarker apply(Object input) { - return api.listAt(input.toString()); - } - - public String toString() { - return "listUsersAtMarker()"; - } - } -} diff --git a/labs/iam/src/main/java/org/jclouds/iam/xml/InstanceProfileHandler.java b/labs/iam/src/main/java/org/jclouds/iam/xml/InstanceProfileHandler.java deleted file mode 100644 index f90b594476..0000000000 --- a/labs/iam/src/main/java/org/jclouds/iam/xml/InstanceProfileHandler.java +++ /dev/null @@ -1,108 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.iam.xml; - -import static org.jclouds.util.SaxUtils.currentOrNull; -import static org.jclouds.util.SaxUtils.equalsOrSuffix; - -import javax.inject.Inject; - -import org.jclouds.date.DateService; -import org.jclouds.http.functions.ParseSax; -import org.jclouds.iam.domain.InstanceProfile; -import org.xml.sax.Attributes; - -/** - * @see - * - * @author Adrian Cole - */ -public class InstanceProfileHandler extends ParseSax.HandlerForGeneratedRequestWithResult { - - private final DateService dateService; - private final RoleHandler roleHandler; - - @Inject - protected InstanceProfileHandler(DateService dateService, RoleHandler roleHandler) { - this.dateService = dateService; - this.roleHandler = roleHandler; - } - - private StringBuilder currentText = new StringBuilder(); - private InstanceProfile.Builder builder = InstanceProfile.builder(); - - @Override - public InstanceProfile getResult() { - try { - return builder.build(); - } finally { - builder = InstanceProfile.builder(); - } - } - - private boolean inRoles; - - @Override - public void startElement(String url, String name, String qName, Attributes attributes) { - if (equalsOrSuffix(qName, "Roles")) { - inRoles = true; - } - if (inRoles) { - roleHandler.startElement(url, name, qName, attributes); - } - } - - @Override - public void endElement(String uri, String name, String qName) { - if (inRoles) { - if (qName.equals("Roles")) { - inRoles = false; - } else if (qName.equals("member")) { - builder.role(roleHandler.getResult()); - } else { - roleHandler.endElement(uri, name, qName); - } - } else if (qName.equals("Path")) { - builder.path(currentOrNull(currentText)); - } else if (qName.equals("InstanceProfileName")) { - builder.name(currentOrNull(currentText)); - } else if (qName.equals("InstanceProfileId")) { - builder.id(currentOrNull(currentText)); - } else if (qName.equals("Arn")) { - builder.arn(currentOrNull(currentText)); - } else if (qName.equals("CreateDate")) { - try { - builder.createDate(dateService.iso8601SecondsDateParse(currentOrNull(currentText))); - } catch (IllegalArgumentException e) { - // on create, milliseconds are present - builder.createDate(dateService.iso8601DateParse(currentOrNull(currentText))); - } - } - currentText = new StringBuilder(); - } - - @Override - public void characters(char ch[], int start, int length) { - if (inRoles) { - roleHandler.characters(ch, start, length); - } else { - currentText.append(ch, start, length); - } - } -} diff --git a/labs/iam/src/main/java/org/jclouds/iam/xml/ListInstanceProfilesResultHandler.java b/labs/iam/src/main/java/org/jclouds/iam/xml/ListInstanceProfilesResultHandler.java deleted file mode 100644 index ccc3e104da..0000000000 --- a/labs/iam/src/main/java/org/jclouds/iam/xml/ListInstanceProfilesResultHandler.java +++ /dev/null @@ -1,104 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.iam.xml; - -import static org.jclouds.util.SaxUtils.currentOrNull; -import static org.jclouds.util.SaxUtils.equalsOrSuffix; - -import org.jclouds.collect.IterableWithMarker; -import org.jclouds.collect.IterableWithMarkers; -import org.jclouds.http.functions.ParseSax; -import org.jclouds.iam.domain.InstanceProfile; -import org.xml.sax.Attributes; - -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableList.Builder; -import com.google.inject.Inject; - -/** - * @see - * - * @author Adrian Cole - */ -public class ListInstanceProfilesResultHandler extends - ParseSax.HandlerForGeneratedRequestWithResult> { - - private final InstanceProfileHandler instanceProfileHandler; - - private StringBuilder currentText = new StringBuilder(); - private Builder instanceProfiles = ImmutableList. builder(); - private String afterMarker; - - @Inject - public ListInstanceProfilesResultHandler(InstanceProfileHandler instanceProfileHandler) { - this.instanceProfileHandler = instanceProfileHandler; - } - - @Override - public IterableWithMarker getResult() { - try { - return IterableWithMarkers.from(instanceProfiles.build(), afterMarker); - } finally { - instanceProfiles = ImmutableList. builder(); - } - } - - private boolean inInstanceProfiles; - private boolean inRoles; - - @Override - public void startElement(String url, String name, String qName, Attributes attributes) { - if (equalsOrSuffix(qName, "InstanceProfiles")) { - inInstanceProfiles = true; - } else if (equalsOrSuffix(qName, "Roles")) { - inRoles = true; - } - if (inInstanceProfiles) { - instanceProfileHandler.startElement(url, name, qName, attributes); - } - } - - @Override - public void endElement(String uri, String name, String qName) { - if (inInstanceProfiles) { - if (qName.equals("Roles")) - inRoles = false; - if (qName.equals("InstanceProfiles")) { - inInstanceProfiles = false; - } else if (qName.equals("member") && !inRoles) { - instanceProfiles.add(instanceProfileHandler.getResult()); - } else { - instanceProfileHandler.endElement(uri, name, qName); - } - } else if (qName.equals("Marker")) { - afterMarker = currentOrNull(currentText); - } - - currentText = new StringBuilder(); - } - - @Override - public void characters(char ch[], int start, int length) { - if (inInstanceProfiles) { - instanceProfileHandler.characters(ch, start, length); - } else { - currentText.append(ch, start, length); - } - } -} diff --git a/labs/iam/src/main/java/org/jclouds/iam/xml/ListPoliciesResultHandler.java b/labs/iam/src/main/java/org/jclouds/iam/xml/ListPoliciesResultHandler.java deleted file mode 100644 index 3bb50845ac..0000000000 --- a/labs/iam/src/main/java/org/jclouds/iam/xml/ListPoliciesResultHandler.java +++ /dev/null @@ -1,77 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.iam.xml; - -import static org.jclouds.util.SaxUtils.currentOrNull; -import static org.jclouds.util.SaxUtils.equalsOrSuffix; - -import org.jclouds.collect.IterableWithMarker; -import org.jclouds.collect.IterableWithMarkers; -import org.jclouds.http.functions.ParseSax; -import org.xml.sax.Attributes; - -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableList.Builder; - -/** - * @see - * - * @author Adrian Cole - */ -public class ListPoliciesResultHandler extends - ParseSax.HandlerForGeneratedRequestWithResult> { - - private StringBuilder currentText = new StringBuilder(); - private Builder names = ImmutableList. builder(); - private boolean inPolicyNames; - private String afterMarker; - - @Override - public IterableWithMarker getResult() { - try { - return IterableWithMarkers.from(names.build(), afterMarker); - } finally { - names = ImmutableList. builder(); - } - } - - @Override - public void startElement(String url, String name, String qName, Attributes attributes) { - if (equalsOrSuffix(qName, "PolicyNames")) { - inPolicyNames = true; - } - } - - @Override - public void endElement(String uri, String name, String qName) { - if (inPolicyNames && qName.equals("PolicyNames")) { - inPolicyNames = false; - } else if (qName.equals("member")) { - names.add(currentOrNull(currentText)); - } else if (qName.equals("Marker")) { - afterMarker = currentOrNull(currentText); - } - currentText = new StringBuilder(); - } - - @Override - public void characters(char ch[], int start, int length) { - currentText.append(ch, start, length); - } -} diff --git a/labs/iam/src/main/java/org/jclouds/iam/xml/ListRolesResultHandler.java b/labs/iam/src/main/java/org/jclouds/iam/xml/ListRolesResultHandler.java deleted file mode 100644 index 022b9ade66..0000000000 --- a/labs/iam/src/main/java/org/jclouds/iam/xml/ListRolesResultHandler.java +++ /dev/null @@ -1,97 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.iam.xml; - -import static org.jclouds.util.SaxUtils.currentOrNull; -import static org.jclouds.util.SaxUtils.equalsOrSuffix; - -import org.jclouds.collect.IterableWithMarker; -import org.jclouds.collect.IterableWithMarkers; -import org.jclouds.http.functions.ParseSax; -import org.jclouds.iam.domain.Role; -import org.xml.sax.Attributes; - -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableList.Builder; -import com.google.inject.Inject; - -/** - * @see - * - * @author Adrian Cole - */ -public class ListRolesResultHandler extends ParseSax.HandlerForGeneratedRequestWithResult> { - - private final RoleHandler roleHandler; - - private StringBuilder currentText = new StringBuilder(); - private Builder roles = ImmutableList. builder(); - private boolean inRoles; - private String afterMarker; - - @Inject - public ListRolesResultHandler(RoleHandler roleHandler) { - this.roleHandler = roleHandler; - } - - @Override - public IterableWithMarker getResult() { - try { - return IterableWithMarkers.from(roles.build(), afterMarker); - } finally { - roles = ImmutableList. builder(); - } - } - - @Override - public void startElement(String url, String name, String qName, Attributes attributes) { - if (equalsOrSuffix(qName, "Roles")) { - inRoles = true; - } - if (inRoles) { - roleHandler.startElement(url, name, qName, attributes); - } - } - - @Override - public void endElement(String uri, String name, String qName) { - if (inRoles) { - if (qName.equals("Roles")) { - inRoles = false; - } else if (qName.equals("member")) { - roles.add(roleHandler.getResult()); - } else { - roleHandler.endElement(uri, name, qName); - } - } else if (qName.equals("Marker")) { - afterMarker = currentOrNull(currentText); - } - - currentText = new StringBuilder(); - } - - @Override - public void characters(char ch[], int start, int length) { - if (inRoles) { - roleHandler.characters(ch, start, length); - } else { - currentText.append(ch, start, length); - } - } -} diff --git a/labs/iam/src/main/java/org/jclouds/iam/xml/ListUsersResultHandler.java b/labs/iam/src/main/java/org/jclouds/iam/xml/ListUsersResultHandler.java deleted file mode 100644 index 980d24b0cc..0000000000 --- a/labs/iam/src/main/java/org/jclouds/iam/xml/ListUsersResultHandler.java +++ /dev/null @@ -1,97 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.iam.xml; - -import static org.jclouds.util.SaxUtils.currentOrNull; -import static org.jclouds.util.SaxUtils.equalsOrSuffix; - -import org.jclouds.collect.IterableWithMarker; -import org.jclouds.collect.IterableWithMarkers; -import org.jclouds.http.functions.ParseSax; -import org.jclouds.iam.domain.User; -import org.xml.sax.Attributes; - -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableList.Builder; -import com.google.inject.Inject; - -/** - * @see - * - * @author Adrian Cole - */ -public class ListUsersResultHandler extends ParseSax.HandlerForGeneratedRequestWithResult> { - - private final UserHandler userHandler; - - private StringBuilder currentText = new StringBuilder(); - private Builder users = ImmutableList. builder(); - private boolean inUsers; - private String afterMarker; - - @Inject - public ListUsersResultHandler(UserHandler userHandler) { - this.userHandler = userHandler; - } - - @Override - public IterableWithMarker getResult() { - try { - return IterableWithMarkers.from(users.build(), afterMarker); - } finally { - users = ImmutableList. builder(); - } - } - - @Override - public void startElement(String url, String name, String qName, Attributes attributes) { - if (equalsOrSuffix(qName, "Users")) { - inUsers = true; - } - if (inUsers) { - userHandler.startElement(url, name, qName, attributes); - } - } - - @Override - public void endElement(String uri, String name, String qName) { - if (inUsers) { - if (qName.equals("Users")) { - inUsers = false; - } else if (qName.equals("member")) { - users.add(userHandler.getResult()); - } else { - userHandler.endElement(uri, name, qName); - } - } else if (qName.equals("Marker")) { - afterMarker = currentOrNull(currentText); - } - - currentText = new StringBuilder(); - } - - @Override - public void characters(char ch[], int start, int length) { - if (inUsers) { - userHandler.characters(ch, start, length); - } else { - currentText.append(ch, start, length); - } - } -} diff --git a/labs/iam/src/main/java/org/jclouds/iam/xml/PolicyHandler.java b/labs/iam/src/main/java/org/jclouds/iam/xml/PolicyHandler.java deleted file mode 100644 index c38675441a..0000000000 --- a/labs/iam/src/main/java/org/jclouds/iam/xml/PolicyHandler.java +++ /dev/null @@ -1,67 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.iam.xml; - -import static org.jclouds.util.SaxUtils.currentOrNull; -import static org.jclouds.util.Strings2.urlDecode; - -import org.jclouds.http.functions.ParseSax; -import org.jclouds.iam.domain.Policy; -import org.xml.sax.Attributes; - -/** - * @see - * - * @author Adrian Cole - */ -public class PolicyHandler extends ParseSax.HandlerForGeneratedRequestWithResult { - - private StringBuilder currentText = new StringBuilder(); - private Policy.Builder builder = Policy.builder(); - - @Override - public Policy getResult() { - try { - return builder.build(); - } finally { - builder = Policy.builder(); - } - } - - @Override - public void startElement(String url, String name, String qName, Attributes attributes) { - } - - @Override - public void endElement(String uri, String name, String qName) { - if (qName.equals("PolicyName")) { - builder.name(currentOrNull(currentText)); - } else if (qName.endsWith("Name")) { - builder.owner(currentOrNull(currentText)); - } else if (qName.equals("PolicyDocument")) { - builder.document(urlDecode(currentOrNull(currentText))); - } - currentText = new StringBuilder(); - } - - @Override - public void characters(char ch[], int start, int length) { - currentText.append(ch, start, length); - } -} diff --git a/labs/iam/src/main/java/org/jclouds/iam/xml/RoleHandler.java b/labs/iam/src/main/java/org/jclouds/iam/xml/RoleHandler.java deleted file mode 100644 index 0c3357b445..0000000000 --- a/labs/iam/src/main/java/org/jclouds/iam/xml/RoleHandler.java +++ /dev/null @@ -1,87 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.iam.xml; - -import static org.jclouds.util.SaxUtils.currentOrNull; -import static org.jclouds.util.Strings2.urlDecode; - -import javax.inject.Inject; - -import org.jclouds.date.DateService; -import org.jclouds.http.functions.ParseSax; -import org.jclouds.iam.domain.Role; -import org.xml.sax.Attributes; - -/** - * @see - * - * @author Adrian Cole - */ -public class RoleHandler extends ParseSax.HandlerForGeneratedRequestWithResult { - private final DateService dateService; - - @Inject - protected RoleHandler(DateService dateService) { - this.dateService = dateService; - } - - private StringBuilder currentText = new StringBuilder(); - private Role.Builder builder = Role.builder(); - - @Override - public Role getResult() { - try { - return builder.build(); - } finally { - builder = Role.builder(); - } - } - - @Override - public void startElement(String url, String name, String qName, Attributes attributes) { - } - - @Override - public void endElement(String uri, String name, String qName) { - if (qName.equals("Path")) { - builder.path(currentOrNull(currentText)); - } else if (qName.equals("RoleName")) { - builder.name(currentOrNull(currentText)); - } else if (qName.equals("RoleId")) { - builder.id(currentOrNull(currentText)); - } else if (qName.equals("Arn")) { - builder.arn(currentOrNull(currentText)); - } else if (qName.equals("AssumeRolePolicyDocument")) { - builder.assumeRolePolicy(urlDecode(currentOrNull(currentText))); - } else if (qName.equals("CreateDate")) { - try { - builder.createDate(dateService.iso8601SecondsDateParse(currentOrNull(currentText))); - } catch (IllegalArgumentException e) { - // on create, milliseconds are present - builder.createDate(dateService.iso8601DateParse(currentOrNull(currentText))); - } - } - currentText = new StringBuilder(); - } - - @Override - public void characters(char ch[], int start, int length) { - currentText.append(ch, start, length); - } -} diff --git a/labs/iam/src/main/java/org/jclouds/iam/xml/UserHandler.java b/labs/iam/src/main/java/org/jclouds/iam/xml/UserHandler.java deleted file mode 100644 index 0c155a30d0..0000000000 --- a/labs/iam/src/main/java/org/jclouds/iam/xml/UserHandler.java +++ /dev/null @@ -1,79 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.iam.xml; - -import static org.jclouds.util.SaxUtils.currentOrNull; - -import javax.inject.Inject; - -import org.jclouds.date.DateService; -import org.jclouds.http.functions.ParseSax; -import org.jclouds.iam.domain.User; -import org.xml.sax.Attributes; - -/** - * @see - * - * @author Adrian Cole - */ -public class UserHandler extends ParseSax.HandlerForGeneratedRequestWithResult { - private final DateService dateService; - - @Inject - protected UserHandler(DateService dateService){ - this.dateService = dateService; - } - - private StringBuilder currentText = new StringBuilder(); - private User.Builder builder = User.builder(); - - @Override - public User getResult() { - try { - return builder.build(); - } finally { - builder = User.builder(); - } - } - - @Override - public void startElement(String url, String name, String qName, Attributes attributes) { - } - - @Override - public void endElement(String uri, String name, String qName) { - if (qName.equals("Path")) { - builder.path(currentOrNull(currentText)); - } else if (qName.equals("UserName")) { - builder.name(currentOrNull(currentText)); - } else if (qName.equals("UserId")) { - builder.id(currentOrNull(currentText)); - } else if (qName.equals("Arn")) { - builder.arn(currentOrNull(currentText)); - } else if (qName.equals("CreateDate")) { - builder.createDate(dateService.iso8601SecondsDateParse(currentOrNull(currentText))); - } - currentText = new StringBuilder(); - } - - @Override - public void characters(char ch[], int start, int length) { - currentText.append(ch, start, length); - } -} diff --git a/labs/iam/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata b/labs/iam/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata deleted file mode 100644 index 5dd93026e5..0000000000 --- a/labs/iam/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata +++ /dev/null @@ -1 +0,0 @@ -org.jclouds.iam.IAMApiMetadata \ No newline at end of file diff --git a/labs/iam/src/test/java/org/jclouds/iam/IAMApiLiveTest.java b/labs/iam/src/test/java/org/jclouds/iam/IAMApiLiveTest.java deleted file mode 100644 index 3f964785d1..0000000000 --- a/labs/iam/src/test/java/org/jclouds/iam/IAMApiLiveTest.java +++ /dev/null @@ -1,58 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.iam; - -import org.jclouds.apis.BaseContextLiveTest; -import org.jclouds.rest.RestContext; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -import com.google.common.reflect.TypeToken; - -/** - * Tests behavior of {@code IAM}. - * - * @author Adrian Cole - */ -public class IAMApiLiveTest extends BaseContextLiveTest> { - - public IAMApiLiveTest() { - provider = "iam"; - } - - private IAMApi api; - - @Override - @BeforeClass(groups = { "integration", "live" }) - public void setupContext() { - super.setupContext(); - api = context.getApi(); - } - - @Override - protected TypeToken> contextType() { - return IAMApiMetadata.CONTEXT_TOKEN; - } - - @Test - protected void testWired() { - api.getCurrentUser(); - } - -} diff --git a/labs/iam/src/test/java/org/jclouds/iam/IAMApiMetadataTest.java b/labs/iam/src/test/java/org/jclouds/iam/IAMApiMetadataTest.java deleted file mode 100644 index a637870591..0000000000 --- a/labs/iam/src/test/java/org/jclouds/iam/IAMApiMetadataTest.java +++ /dev/null @@ -1,39 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.iam; - -import org.jclouds.View; -import org.jclouds.rest.internal.BaseRestApiMetadataTest; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableSet; -import com.google.common.reflect.TypeToken; - -/** - * - * @author Adrian Cole - */ -@Test(groups = "unit", testName = "IAMApiMetadataTest") -public class IAMApiMetadataTest extends BaseRestApiMetadataTest { - - // no tenant abstraction, yet - public IAMApiMetadataTest() { - super(new IAMApiMetadata(), ImmutableSet.> of()); - } -} diff --git a/labs/iam/src/test/java/org/jclouds/iam/features/InstanceProfileApiExpectTest.java b/labs/iam/src/test/java/org/jclouds/iam/features/InstanceProfileApiExpectTest.java deleted file mode 100644 index 18a7a4e79c..0000000000 --- a/labs/iam/src/test/java/org/jclouds/iam/features/InstanceProfileApiExpectTest.java +++ /dev/null @@ -1,314 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unles required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either expres or implied. See the License for the - * specific language governing permisions and limitations - * under the License. - */ -package org.jclouds.iam.features; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNull; - -import org.jclouds.http.HttpRequest; -import org.jclouds.http.HttpResponse; -import org.jclouds.iam.IAMApi; -import org.jclouds.iam.internal.BaseIAMApiExpectTest; -import org.jclouds.iam.parse.GetInstanceProfileResponseTest; -import org.jclouds.iam.parse.ListInstanceProfilesResponseTest; -import org.jclouds.rest.ResourceNotFoundException; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableList; -import com.google.common.collect.Iterables; - -/** - * @author Adrian Cole - */ -@Test(groups = "unit", testName = "InstanceProfileApiExpectTest") -public class InstanceProfileApiExpectTest extends BaseIAMApiExpectTest { - HttpRequest create = HttpRequest.builder() - .method("POST") - .endpoint("https://iam.amazonaws.com/") - .addHeader("Host", "iam.amazonaws.com") - .addFormParam("Action", "CreateInstanceProfile") - .addFormParam("InstanceProfileName", "name") - .addFormParam("Signature", "UIosTnnvBVHY7m7rqz1489RQ90Mf81/aOXgh8x2mLWU%3D") - .addFormParam("SignatureMethod", "HmacSHA256") - .addFormParam("SignatureVersion", "2") - .addFormParam("Timestamp", "2009-11-08T15%3A54%3A08.897Z") - .addFormParam("Version", "2010-05-08") - .addFormParam("AWSAccessKeyId", "identity").build(); - - public void testCreateWhenResponseIs2xx() throws Exception { - - HttpResponse getResponse = HttpResponse.builder().statusCode(200) - .payload(payloadFromResourceWithContentType("/get_instance_profile.xml", "text/xml")).build(); - - IAMApi apiWhenExist = requestSendsResponse(create, getResponse); - - assertEquals(apiWhenExist.getInstanceProfileApi().create("name").toString(), new GetInstanceProfileResponseTest().expected().toString()); - } - - HttpRequest get = HttpRequest.builder() - .method("POST") - .endpoint("https://iam.amazonaws.com/") - .addHeader("Host", "iam.amazonaws.com") - .addFormParam("Action", "GetInstanceProfile") - .addFormParam("InstanceProfileName", "name") - .addFormParam("Signature", "uw5Ix/UFRqENsSWProK3%2BDMIezmvd3fFhTFMaooxFMg%3D") - .addFormParam("SignatureMethod", "HmacSHA256") - .addFormParam("SignatureVersion", "2") - .addFormParam("Timestamp", "2009-11-08T15%3A54%3A08.897Z") - .addFormParam("Version", "2010-05-08") - .addFormParam("AWSAccessKeyId", "identity").build(); - - public void testGetWhenResponseIs2xx() throws Exception { - - HttpResponse getResponse = HttpResponse.builder().statusCode(200) - .payload(payloadFromResourceWithContentType("/get_instance_profile.xml", "text/xml")).build(); - - IAMApi apiWhenExist = requestSendsResponse(get, getResponse); - - assertEquals(apiWhenExist.getInstanceProfileApi().get("name").toString(), new GetInstanceProfileResponseTest().expected().toString()); - } - - public void testGetWhenResponseIs404() throws Exception { - - HttpResponse getResponse = HttpResponse.builder().statusCode(404).build(); - - IAMApi apiWhenDontExist = requestSendsResponse( - get, getResponse); - - assertNull(apiWhenDontExist.getInstanceProfileApi().get("name")); - } - - HttpRequest delete = HttpRequest.builder() - .method("POST") - .endpoint("https://iam.amazonaws.com/") - .addHeader("Host", "iam.amazonaws.com") - .addFormParam("Action", "DeleteInstanceProfile") - .addFormParam("InstanceProfileName", "name") - .addFormParam("Signature", "7W47Gj/6NE6p6drXMtqozYOlUOQN7CzbXgrIup4iowk%3D") - .addFormParam("SignatureMethod", "HmacSHA256") - .addFormParam("SignatureVersion", "2") - .addFormParam("Timestamp", "2009-11-08T15%3A54%3A08.897Z") - .addFormParam("Version", "2010-05-08") - .addFormParam("AWSAccessKeyId", "identity").build(); - - public void testDeleteWhenResponseIs2xx() throws Exception { - - HttpResponse deleteResponse = HttpResponse.builder().statusCode(200) - .payload(payloadFromResourceWithContentType("/delete_instance_profile.xml", "text/xml")).build(); - - IAMApi apiWhenExist = requestSendsResponse(delete, deleteResponse); - - apiWhenExist.getInstanceProfileApi().delete("name"); - } - - public void testDeleteWhenResponseIs404() throws Exception { - - HttpResponse deleteResponse = HttpResponse.builder().statusCode(404).build(); - - IAMApi apiWhenDontExist = requestSendsResponse(delete, deleteResponse); - - apiWhenDontExist.getInstanceProfileApi().delete("name"); - } - - HttpRequest list = HttpRequest.builder() - .method("POST") - .endpoint("https://iam.amazonaws.com/") - .addHeader("Host", "iam.amazonaws.com") - .addFormParam("Action", "ListInstanceProfiles") - .addFormParam("Signature", "i2V6ZeplNRVaZ/9XfD4jv53Qh%2BNQdl3ZuoZc%2BLguf0o%3D") - .addFormParam("SignatureMethod", "HmacSHA256") - .addFormParam("SignatureVersion", "2") - .addFormParam("Timestamp", "2009-11-08T15%3A54%3A08.897Z") - .addFormParam("Version", "2010-05-08") - .addFormParam("AWSAccessKeyId", "identity").build(); - - public void testListWhenResponseIs2xx() throws Exception { - - HttpResponse listResponse = HttpResponse.builder().statusCode(200) - .payload(payloadFromResourceWithContentType("/list_instance_profiles.xml", "text/xml")).build(); - - IAMApi apiWhenExist = requestSendsResponse(list, listResponse); - - assertEquals(apiWhenExist.getInstanceProfileApi().list().get(0).toString(), new ListInstanceProfilesResponseTest().expected().toString()); - } - - public void testList2PagesWhenResponseIs2xx() throws Exception { - - HttpResponse listResponse = HttpResponse.builder().statusCode(200) - .payload(payloadFromResourceWithContentType("/list_instance_profiles_marker.xml", "text/xml")).build(); - - HttpRequest list2 = HttpRequest.builder() - .method("POST") - .endpoint("https://iam.amazonaws.com/") - .addHeader("Host", "iam.amazonaws.com") - .addFormParam("Action", "ListInstanceProfiles") - .addFormParam("Marker", "MARKER") - .addFormParam("Signature", "x7G5OvKxTIMEjl58OVurKrwf7wEA7exXSml63T89mSY%3D") - .addFormParam("SignatureMethod", "HmacSHA256") - .addFormParam("SignatureVersion", "2") - .addFormParam("Timestamp", "2009-11-08T15%3A54%3A08.897Z") - .addFormParam("Version", "2010-05-08") - .addFormParam("AWSAccessKeyId", "identity").build(); - - HttpResponse list2Response = HttpResponse.builder().statusCode(200) - .payload(payloadFromResourceWithContentType("/list_instance_profiles.xml", "text/xml")).build(); - - IAMApi apiWhenExist = requestsSendResponses(list, listResponse, list2, list2Response); - - assertEquals(apiWhenExist.getInstanceProfileApi().list().concat().toList(), - ImmutableList.copyOf(Iterables.concat(new ListInstanceProfilesResponseTest().expected(), new ListInstanceProfilesResponseTest().expected()))); - } - - HttpRequest listPathPrefix = HttpRequest.builder() - .method("POST") - .endpoint("https://iam.amazonaws.com/") - .addHeader("Host", "iam.amazonaws.com") - .addFormParam("Action", "ListInstanceProfiles") - .addFormParam("PathPrefix", "/subdivision") - .addFormParam("Signature", "EEVeWhJhORpibHahIj1skQ3rhHaVb/iaqD22vIFQH7o%3D") - .addFormParam("SignatureMethod", "HmacSHA256") - .addFormParam("SignatureVersion", "2") - .addFormParam("Timestamp", "2009-11-08T15%3A54%3A08.897Z") - .addFormParam("Version", "2010-05-08") - .addFormParam("AWSAccessKeyId", "identity").build(); - - public void testListPathPrefixWhenResponseIs2xx() throws Exception { - - HttpResponse listResponse = HttpResponse.builder().statusCode(200) - .payload(payloadFromResourceWithContentType("/list_instance_profiles.xml", "text/xml")).build(); - - IAMApi apiWhenExist = requestSendsResponse(listPathPrefix, listResponse); - - assertEquals(apiWhenExist.getInstanceProfileApi().listPathPrefix("/subdivision").get(0).toString(), new ListInstanceProfilesResponseTest().expected().toString()); - } - - public void testListPathPrefix2PagesWhenResponseIs2xx() throws Exception { - - HttpResponse listResponse = HttpResponse.builder().statusCode(200) - .payload(payloadFromResourceWithContentType("/list_instance_profiles_marker.xml", "text/xml")).build(); - - HttpRequest listPathPrefix2 = HttpRequest.builder() - .method("POST") - .endpoint("https://iam.amazonaws.com/") - .addHeader("Host", "iam.amazonaws.com") - .addFormParam("Action", "ListInstanceProfiles") - .addFormParam("Marker", "MARKER") - .addFormParam("PathPrefix", "/subdivision") - .addFormParam("Signature", "8xo94VlrqsoMoa6bpbqQbuVx8TLh8UmiQnc9QC58EhU%3D") - .addFormParam("SignatureMethod", "HmacSHA256") - .addFormParam("SignatureVersion", "2") - .addFormParam("Timestamp", "2009-11-08T15%3A54%3A08.897Z") - .addFormParam("Version", "2010-05-08") - .addFormParam("AWSAccessKeyId", "identity").build(); - - HttpResponse list2Response = HttpResponse.builder().statusCode(200) - .payload(payloadFromResourceWithContentType("/list_instance_profiles.xml", "text/xml")).build(); - - IAMApi apiWhenExist = requestsSendResponses(listPathPrefix, listResponse, listPathPrefix2, list2Response); - - assertEquals(apiWhenExist.getInstanceProfileApi().listPathPrefix("/subdivision").concat().toList(), - ImmutableList.copyOf(Iterables.concat(new ListInstanceProfilesResponseTest().expected(), new ListInstanceProfilesResponseTest().expected()))); - } - - // TODO: this should really be an empty set - @Test(expectedExceptions = ResourceNotFoundException.class) - public void testListWhenResponseIs404() throws Exception { - - HttpResponse listResponse = HttpResponse.builder().statusCode(404).build(); - - IAMApi apiWhenDontExist = requestSendsResponse( - list, listResponse); - - apiWhenDontExist.getInstanceProfileApi().list().get(0); - } - - public void testListPathPrefixAtWhenResponseIs2xx() throws Exception { - HttpRequest listWithOptions = - HttpRequest.builder() - .method("POST") - .endpoint("https://iam.amazonaws.com/") - .addHeader("Host", "iam.amazonaws.com") - .addFormParam("Action", "ListInstanceProfiles") - .addFormParam("Marker", "MARKER") - .addFormParam("PathPrefix", "/foo") - .addFormParam("Signature", "IBRktzqZ/GE8Y7DZqsjuOUNfJZTbkCnOZnHAmzwtju8%3D") - .addFormParam("SignatureMethod", "HmacSHA256") - .addFormParam("SignatureVersion", "2") - .addFormParam("Timestamp", "2009-11-08T15%3A54%3A08.897Z") - .addFormParam("Version", "2010-05-08") - .addFormParam("AWSAccessKeyId", "identity").build(); - - HttpResponse listWithOptionsResponse = HttpResponse.builder().statusCode(200) - .payload(payloadFromResourceWithContentType("/list_instance_profiles.xml", "text/xml")).build(); - - IAMApi apiWhenWithOptionsExist = requestSendsResponse(listWithOptions, - listWithOptionsResponse); - - assertEquals(apiWhenWithOptionsExist.getInstanceProfileApi().listPathPrefixAt("/foo", "MARKER").toString(), - new ListInstanceProfilesResponseTest().expected().toString()); - } - - HttpRequest addRole = HttpRequest.builder() - .method("POST") - .endpoint("https://iam.amazonaws.com/") - .addHeader("Host", "iam.amazonaws.com") - .addFormParam("Action", "AddRoleToInstanceProfile") - .addFormParam("InstanceProfileName", "name") - .addFormParam("RoleName", "WebServer") - .addFormParam("Signature", "QTM12yD9GwUKEE9wqbt03VlfZ/%2BfO0UWe9SbNoI9d3c%3D") - .addFormParam("SignatureMethod", "HmacSHA256") - .addFormParam("SignatureVersion", "2") - .addFormParam("Timestamp", "2009-11-08T15%3A54%3A08.897Z") - .addFormParam("Version", "2010-05-08") - .addFormParam("AWSAccessKeyId", "identity").build(); - - public void testAddRoleWhenResponseIs2xx() throws Exception { - - HttpResponse addRoleResponse = HttpResponse.builder().statusCode(200) - .payload(payloadFromResourceWithContentType("/delete_instance_profile.xml", "text/xml")).build(); - - IAMApi apiWhenExist = requestSendsResponse(addRole, addRoleResponse); - - apiWhenExist.getInstanceProfileApi().addRole("name", "WebServer"); - } - - HttpRequest removeRole = HttpRequest.builder() - .method("POST") - .endpoint("https://iam.amazonaws.com/") - .addHeader("Host", "iam.amazonaws.com") - .addFormParam("Action", "RemoveRoleFromInstanceProfile") - .addFormParam("InstanceProfileName", "name") - .addFormParam("RoleName", "WebServer") - .addFormParam("Signature", "o1Uz2bOwe8H3DOnyNL5TK9lNDoKvWo7CNhspN7ml5Sc%3D") - .addFormParam("SignatureMethod", "HmacSHA256") - .addFormParam("SignatureVersion", "2") - .addFormParam("Timestamp", "2009-11-08T15%3A54%3A08.897Z") - .addFormParam("Version", "2010-05-08") - .addFormParam("AWSAccessKeyId", "identity").build(); - - public void testRemoveRoleWhenResponseIs2xx() throws Exception { - - HttpResponse removeRoleResponse = HttpResponse.builder().statusCode(200) - .payload(payloadFromResourceWithContentType("/delete_instance_profile.xml", "text/xml")).build(); - - IAMApi apiWhenExist = requestSendsResponse(removeRole, removeRoleResponse); - - apiWhenExist.getInstanceProfileApi().removeRole("name", "WebServer"); - } -} diff --git a/labs/iam/src/test/java/org/jclouds/iam/features/InstanceProfileApiLiveTest.java b/labs/iam/src/test/java/org/jclouds/iam/features/InstanceProfileApiLiveTest.java deleted file mode 100644 index 2f5ad5d0a0..0000000000 --- a/labs/iam/src/test/java/org/jclouds/iam/features/InstanceProfileApiLiveTest.java +++ /dev/null @@ -1,124 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.iam.features; - -import static com.google.common.base.Preconditions.checkNotNull; -import static java.util.logging.Logger.getAnonymousLogger; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNull; -import static org.testng.Assert.assertTrue; - -import org.jclouds.iam.domain.InstanceProfile; -import org.jclouds.iam.domain.Role; -import org.jclouds.iam.internal.BaseIAMApiLiveTest; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableSet; - -/** - * @author Adrian Cole - */ -@Test(groups = "live", testName = "InstanceProfileApiLiveTest") -public class InstanceProfileApiLiveTest extends BaseIAMApiLiveTest { - - static void checkInstanceProfile(InstanceProfile instanceProfile) { - checkNotNull(instanceProfile.getArn(), "Arn cannot be null for InstanceProfile %s", instanceProfile); - checkNotNull(instanceProfile.getId(), "Id cannot be null for InstanceProfile %s", instanceProfile); - checkNotNull(instanceProfile.getName(), "Name cannot be null for InstanceProfile %s", instanceProfile); - checkNotNull(instanceProfile.getPath(), "Path cannot be null for InstanceProfile %s", instanceProfile); - checkNotNull(instanceProfile.getRoles(), "Roles cannot be null for InstanceProfile %s", instanceProfile); - checkNotNull(instanceProfile.getCreateDate(), - "CreateDate cannot be null for a InstanceProfile InstanceProfile %s", instanceProfile); - for (Role role : instanceProfile.getRoles()) { - RoleApiLiveTest.checkRole(role); - } - } - - @Test - protected void testListInstanceProfiles() { - ImmutableList instanceProfiles = api().list().concat().toList(); - getAnonymousLogger().info("instanceProfiles: " + instanceProfiles.size()); - - for (InstanceProfile instanceProfile : instanceProfiles) { - checkInstanceProfile(instanceProfile); - assertEquals(api().get(instanceProfile.getName()), instanceProfile); - ImmutableSet instanceProfilesAtPath = api().listPathPrefix(instanceProfile.getPath()) - .concat().toSet(); - assertTrue(instanceProfilesAtPath.contains(instanceProfile), instanceProfile + " not in " - + instanceProfilesAtPath); - } - } - - @Test - public void testGetInstanceProfileWhenNotFound() { - assertNull(api().get("AAAAAAAAAAAAAAAA")); - } - - @Test - public void testDeleteInstanceProfileWhenNotFound() { - api().delete("AAAAAAAAAAAAAAAA"); - } - - String name = System.getProperty("user.name").replace('.', '-') + ".instanceProfile.iamtest.jclouds.org."; - - @Test - public void testCreateInstanceProfile() { - InstanceProfile newInstanceProfile = api().create(name); - getAnonymousLogger().info("created instanceProfile: " + newInstanceProfile); - checkInstanceProfile(newInstanceProfile); - assertEquals(newInstanceProfile.getName(), name); - } - - @Test(dependsOnMethods = "testCreateInstanceProfile") - public void testAddRoleRemoveRoleFromInstanceProfile() { - try { - createRoleWithPolicy(name); - api().addRole(name, name); - InstanceProfile updated = api().get(name); - RoleApiLiveTest.checkRole(updated.getRoles().get(0)); - - api().removeRole(name, name); - updated = api().get(name); - assertEquals(updated.getRoles(), ImmutableList.of()); - } finally { - tearDownRoleWithPolicy(name); - } - } - - @Test(dependsOnMethods = "testAddRoleRemoveRoleFromInstanceProfile") - public void testDeleteInstanceProfile() { - api().delete(name); - assertNull(api().get(name)); - } - - protected InstanceProfileApi api() { - return context.getApi().getInstanceProfileApi(); - } - - void createRoleWithPolicy(String roleName) { - context.getApi().getRoleApi().createWithPolicy(roleName, RoleApiLiveTest.assumeRolePolicy); - context.getApi().getPolicyApiForRole(roleName).create("S3Access", RolePolicyApiLiveTest.s3Policy); - } - - void tearDownRoleWithPolicy(String roleName) { - context.getApi().getPolicyApiForRole(roleName).delete("S3Access"); - context.getApi().getRoleApi().delete(roleName); - } -} diff --git a/labs/iam/src/test/java/org/jclouds/iam/features/RoleApiExpectTest.java b/labs/iam/src/test/java/org/jclouds/iam/features/RoleApiExpectTest.java deleted file mode 100644 index 67c9476501..0000000000 --- a/labs/iam/src/test/java/org/jclouds/iam/features/RoleApiExpectTest.java +++ /dev/null @@ -1,324 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unles required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either expres or implied. See the License for the - * specific language governing permisions and limitations - * under the License. - */ -package org.jclouds.iam.features; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNull; - -import org.jclouds.http.HttpRequest; -import org.jclouds.http.HttpResponse; -import org.jclouds.iam.IAMApi; -import org.jclouds.iam.internal.BaseIAMApiExpectTest; -import org.jclouds.iam.parse.GetRoleResponseTest; -import org.jclouds.iam.parse.ListInstanceProfilesResponseTest; -import org.jclouds.iam.parse.ListRolesResponseTest; -import org.jclouds.rest.ResourceNotFoundException; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableList; -import com.google.common.collect.Iterables; - -/** - * @author Adrian Cole - */ -@Test(groups = "unit", testName = "RoleApiExpectTest") -public class RoleApiExpectTest extends BaseIAMApiExpectTest { - String policy = "{\"Version\":\"2008-10-17\",\"Statement\":[{\"Sid\":\"\",\"Effect\":\"Allow\",\"Principal\":{\"Service\":\"ec2.amazonaws.com\"},\"Action\":\"sts:AssumeRole\"}]}"; - - HttpRequest create = HttpRequest.builder() - .method("POST") - .endpoint("https://iam.amazonaws.com/") - .addHeader("Host", "iam.amazonaws.com") - .addFormParam("Action", "CreateRole") - .addFormParam("AssumeRolePolicyDocument", policy) - .addFormParam("RoleName", "name") - .addFormParam("Signature", "zl7UtZElpvnkjo81NmA%2BCvYu0xFEeXQlSRtqTgok2OU%3D") - .addFormParam("SignatureMethod", "HmacSHA256") - .addFormParam("SignatureVersion", "2") - .addFormParam("Timestamp", "2009-11-08T15%3A54%3A08.897Z") - .addFormParam("Version", "2010-05-08") - .addFormParam("AWSAccessKeyId", "identity").build(); - - public void testCreateWhenResponseIs2xx() throws Exception { - - HttpResponse getResponse = HttpResponse.builder().statusCode(200) - .payload(payloadFromResourceWithContentType("/get_role.xml", "text/xml")).build(); - - IAMApi apiWhenExist = requestSendsResponse(create, getResponse); - - assertEquals(apiWhenExist.getRoleApi().createWithPolicy("name", policy).toString(), new GetRoleResponseTest().expected().toString()); - } - - HttpRequest get = HttpRequest.builder() - .method("POST") - .endpoint("https://iam.amazonaws.com/") - .addHeader("Host", "iam.amazonaws.com") - .addFormParam("Action", "GetRole") - .addFormParam("RoleName", "name") - .addFormParam("Signature", "OhV4oxbGMEJtWEDOUhR5n4u5TfGT9YtX/nVXHRyxDrs%3D") - .addFormParam("SignatureMethod", "HmacSHA256") - .addFormParam("SignatureVersion", "2") - .addFormParam("Timestamp", "2009-11-08T15%3A54%3A08.897Z") - .addFormParam("Version", "2010-05-08") - .addFormParam("AWSAccessKeyId", "identity").build(); - - public void testGetWhenResponseIs2xx() throws Exception { - - HttpResponse getResponse = HttpResponse.builder().statusCode(200) - .payload(payloadFromResourceWithContentType("/get_role.xml", "text/xml")).build(); - - IAMApi apiWhenExist = requestSendsResponse( - get, getResponse); - - assertEquals(apiWhenExist.getRoleApi().get("name").toString(), new GetRoleResponseTest().expected().toString()); - } - - public void testGetWhenResponseIs404() throws Exception { - - HttpResponse getResponse = HttpResponse.builder().statusCode(404).build(); - - IAMApi apiWhenDontExist = requestSendsResponse( - get, getResponse); - - assertNull(apiWhenDontExist.getRoleApi().get("name")); - } - - HttpRequest delete = HttpRequest.builder() - .method("POST") - .endpoint("https://iam.amazonaws.com/") - .addHeader("Host", "iam.amazonaws.com") - .addFormParam("Action", "DeleteRole") - .addFormParam("RoleName", "name") - .addFormParam("Signature", "yhONyyLjFFtLgearEBrBNpSGTafh35LvRaaK8VagOVA%3D") - .addFormParam("SignatureMethod", "HmacSHA256") - .addFormParam("SignatureVersion", "2") - .addFormParam("Timestamp", "2009-11-08T15%3A54%3A08.897Z") - .addFormParam("Version", "2010-05-08") - .addFormParam("AWSAccessKeyId", "identity").build(); - - public void testDeleteWhenResponseIs2xx() throws Exception { - - HttpResponse deleteResponse = HttpResponse.builder().statusCode(200) - .payload(payloadFromResourceWithContentType("/delete_role.xml", "text/xml")).build(); - - IAMApi apiWhenExist = requestSendsResponse(delete, deleteResponse); - - apiWhenExist.getRoleApi().delete("name"); - } - - public void testDeleteWhenResponseIs404() throws Exception { - - HttpResponse deleteResponse = HttpResponse.builder().statusCode(404).build(); - - IAMApi apiWhenDontExist = requestSendsResponse(delete, deleteResponse); - - apiWhenDontExist.getRoleApi().delete("name"); - } - - HttpRequest list = HttpRequest.builder() - .method("POST") - .endpoint("https://iam.amazonaws.com/") - .addHeader("Host", "iam.amazonaws.com") - .addFormParam("Action", "ListRoles") - .addFormParam("Signature", "aUfKE6CqT%2BAiRMmcRWmGrw/6wNpzrKCwd35UufAVEbs%3D") - .addFormParam("SignatureMethod", "HmacSHA256") - .addFormParam("SignatureVersion", "2") - .addFormParam("Timestamp", "2009-11-08T15%3A54%3A08.897Z") - .addFormParam("Version", "2010-05-08") - .addFormParam("AWSAccessKeyId", "identity").build(); - - public void testListWhenResponseIs2xx() throws Exception { - - HttpResponse listResponse = HttpResponse.builder().statusCode(200) - .payload(payloadFromResourceWithContentType("/list_roles.xml", "text/xml")).build(); - - IAMApi apiWhenExist = requestSendsResponse( - list, listResponse); - - assertEquals(apiWhenExist.getRoleApi().list().get(0).toString(), new ListRolesResponseTest().expected().toString()); - } - - public void testList2PagesWhenResponseIs2xx() throws Exception { - - HttpResponse listResponse = HttpResponse.builder().statusCode(200) - .payload(payloadFromResourceWithContentType("/list_roles_marker.xml", "text/xml")).build(); - - HttpRequest list2 = HttpRequest.builder() - .method("POST") - .endpoint("https://iam.amazonaws.com/") - .addHeader("Host", "iam.amazonaws.com") - .addFormParam("Action", "ListRoles") - .addFormParam("Marker", "MARKER") - .addFormParam("Signature", "gOfxvq54UyrEck9AmMy4tm5zcNlRWwWtLBzGpKASskk%3D") - .addFormParam("SignatureMethod", "HmacSHA256") - .addFormParam("SignatureVersion", "2") - .addFormParam("Timestamp", "2009-11-08T15%3A54%3A08.897Z") - .addFormParam("Version", "2010-05-08") - .addFormParam("AWSAccessKeyId", "identity").build(); - - HttpResponse list2Response = HttpResponse.builder().statusCode(200) - .payload(payloadFromResourceWithContentType("/list_roles.xml", "text/xml")).build(); - - IAMApi apiWhenExist = requestsSendResponses(list, listResponse, list2, list2Response); - - assertEquals(apiWhenExist.getRoleApi().list().concat().toList(), - ImmutableList.copyOf(Iterables.concat(new ListRolesResponseTest().expected(), new ListRolesResponseTest().expected()))); - } - - HttpRequest listPathPrefix = HttpRequest.builder() - .method("POST") - .endpoint("https://iam.amazonaws.com/") - .addHeader("Host", "iam.amazonaws.com") - .addFormParam("Action", "ListRoles") - .addFormParam("PathPrefix", "/subdivision") - .addFormParam("Signature", "ELuhOLquxfQw5pv9381CBuUfqiXv5FHl836m31HA2BI%3D") - .addFormParam("SignatureMethod", "HmacSHA256") - .addFormParam("SignatureVersion", "2") - .addFormParam("Timestamp", "2009-11-08T15%3A54%3A08.897Z") - .addFormParam("Version", "2010-05-08") - .addFormParam("AWSAccessKeyId", "identity").build(); - - public void testListPathPrefixWhenResponseIs2xx() throws Exception { - - HttpResponse listResponse = HttpResponse.builder().statusCode(200) - .payload(payloadFromResourceWithContentType("/list_roles.xml", "text/xml")).build(); - - IAMApi apiWhenExist = requestSendsResponse( - listPathPrefix, listResponse); - - assertEquals(apiWhenExist.getRoleApi().listPathPrefix("/subdivision").get(0).toString(), new ListRolesResponseTest().expected().toString()); - } - - public void testListPathPrefix2PagesWhenResponseIs2xx() throws Exception { - - HttpResponse listResponse = HttpResponse.builder().statusCode(200) - .payload(payloadFromResourceWithContentType("/list_roles_marker.xml", "text/xml")).build(); - - HttpRequest listPathPrefix2 = HttpRequest.builder() - .method("POST") - .endpoint("https://iam.amazonaws.com/") - .addHeader("Host", "iam.amazonaws.com") - .addFormParam("Action", "ListRoles") - .addFormParam("Marker", "MARKER") - .addFormParam("PathPrefix", "/subdivision") - .addFormParam("Signature", "Y05M4vbhJpd35erXuhECszxjtx56cdIULGHnRaVr13s%3D") - .addFormParam("SignatureMethod", "HmacSHA256") - .addFormParam("SignatureVersion", "2") - .addFormParam("Timestamp", "2009-11-08T15%3A54%3A08.897Z") - .addFormParam("Version", "2010-05-08") - .addFormParam("AWSAccessKeyId", "identity").build(); - - HttpResponse list2Response = HttpResponse.builder().statusCode(200) - .payload(payloadFromResourceWithContentType("/list_roles.xml", "text/xml")).build(); - - IAMApi apiWhenExist = requestsSendResponses(listPathPrefix, listResponse, listPathPrefix2, list2Response); - - assertEquals(apiWhenExist.getRoleApi().listPathPrefix("/subdivision").concat().toList(), - ImmutableList.copyOf(Iterables.concat(new ListRolesResponseTest().expected(), new ListRolesResponseTest().expected()))); - } - - // TODO: this should really be an empty set - @Test(expectedExceptions = ResourceNotFoundException.class) - public void testListWhenResponseIs404() throws Exception { - - HttpResponse listResponse = HttpResponse.builder().statusCode(404).build(); - - IAMApi apiWhenDontExist = requestSendsResponse( - list, listResponse); - - apiWhenDontExist.getRoleApi().list().get(0); - } - - public void testListPathPrefixAtWhenResponseIs2xx() throws Exception { - HttpRequest listWithOptions = - HttpRequest.builder() - .method("POST") - .endpoint("https://iam.amazonaws.com/") - .addHeader("Host", "iam.amazonaws.com") - .addFormParam("Action", "ListRoles") - .addFormParam("Marker", "MARKER") - .addFormParam("PathPrefix", "/foo") - .addFormParam("Signature", "HUXPIey7u7ajfog4wFgJn59fcFWpMSjd5yjomenL7jc%3D") - .addFormParam("SignatureMethod", "HmacSHA256") - .addFormParam("SignatureVersion", "2") - .addFormParam("Timestamp", "2009-11-08T15%3A54%3A08.897Z") - .addFormParam("Version", "2010-05-08") - .addFormParam("AWSAccessKeyId", "identity").build(); - - HttpResponse listWithOptionsResponse = HttpResponse.builder().statusCode(200) - .payload(payloadFromResourceWithContentType("/list_roles.xml", "text/xml")).build(); - - IAMApi apiWhenWithOptionsExist = requestSendsResponse(listWithOptions, - listWithOptionsResponse); - - assertEquals(apiWhenWithOptionsExist.getRoleApi().listPathPrefixAt("/foo", "MARKER").toString(), - new ListRolesResponseTest().expected().toString()); - } - - HttpRequest listInstanceProfiles = HttpRequest.builder() - .method("POST") - .endpoint("https://iam.amazonaws.com/") - .addHeader("Host", "iam.amazonaws.com") - .addFormParam("Action", "ListInstanceProfilesForRole") - .addFormParam("RoleName", "WebServer") - .addFormParam("Signature", "WLWyoNHcR09MJ9JN0qGIzzPsZtlTX6UbqsAkaxp9utg%3D") - .addFormParam("SignatureMethod", "HmacSHA256") - .addFormParam("SignatureVersion", "2") - .addFormParam("Timestamp", "2009-11-08T15%3A54%3A08.897Z") - .addFormParam("Version", "2010-05-08") - .addFormParam("AWSAccessKeyId", "identity").build(); - - public void testListInstanceProfilesWhenResponseIs2xx() throws Exception { - - HttpResponse listInstanceProfilesResponse = HttpResponse.builder().statusCode(200) - .payload(payloadFromResourceWithContentType("/list_instance_profiles.xml", "text/xml")).build(); - - IAMApi apiWhenExist = requestSendsResponse(listInstanceProfiles, listInstanceProfilesResponse); - - assertEquals(apiWhenExist.getRoleApi().listInstanceProfiles("WebServer").get(0).toString(), new ListInstanceProfilesResponseTest().expected().toString()); - } - - public void testListInstanceProfiles2PagesWhenResponseIs2xx() throws Exception { - - HttpResponse listInstanceProfilesResponse = HttpResponse.builder().statusCode(200) - .payload(payloadFromResourceWithContentType("/list_instance_profiles_marker.xml", "text/xml")).build(); - - HttpRequest listInstanceProfiles2 = HttpRequest.builder() - .method("POST") - .endpoint("https://iam.amazonaws.com/") - .addHeader("Host", "iam.amazonaws.com") - .addFormParam("Action", "ListInstanceProfilesForRole") - .addFormParam("Marker", "MARKER") - .addFormParam("RoleName", "WebServer") - .addFormParam("Signature", "LHwKxeK/Hwqbv90tSG0tRJl/4BLrPqi%2BMvBnXvxUybs%3D") - .addFormParam("SignatureMethod", "HmacSHA256") - .addFormParam("SignatureVersion", "2") - .addFormParam("Timestamp", "2009-11-08T15%3A54%3A08.897Z") - .addFormParam("Version", "2010-05-08") - .addFormParam("AWSAccessKeyId", "identity").build(); - - HttpResponse listInstanceProfiles2Response = HttpResponse.builder().statusCode(200) - .payload(payloadFromResourceWithContentType("/list_instance_profiles.xml", "text/xml")).build(); - - IAMApi apiWhenExist = requestsSendResponses(listInstanceProfiles, listInstanceProfilesResponse, listInstanceProfiles2, listInstanceProfiles2Response); - - assertEquals(apiWhenExist.getRoleApi().listInstanceProfiles("WebServer").concat().toList(), - ImmutableList.copyOf(Iterables.concat(new ListInstanceProfilesResponseTest().expected(), new ListInstanceProfilesResponseTest().expected()))); - } -} diff --git a/labs/iam/src/test/java/org/jclouds/iam/features/RoleApiLiveTest.java b/labs/iam/src/test/java/org/jclouds/iam/features/RoleApiLiveTest.java deleted file mode 100644 index 574c8f88fd..0000000000 --- a/labs/iam/src/test/java/org/jclouds/iam/features/RoleApiLiveTest.java +++ /dev/null @@ -1,102 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.iam.features; - -import static com.google.common.base.Preconditions.checkNotNull; -import static java.util.logging.Logger.getAnonymousLogger; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNull; -import static org.testng.Assert.assertTrue; - -import org.jclouds.iam.domain.InstanceProfile; -import org.jclouds.iam.domain.Role; -import org.jclouds.iam.internal.BaseIAMApiLiveTest; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableSet; - -/** - * @author Adrian Cole - */ -@Test(groups = "live", testName = "RoleApiLiveTest") -public class RoleApiLiveTest extends BaseIAMApiLiveTest { - - static void checkRole(Role role) { - checkNotNull(role.getArn(), "Arn cannot be null for Role %s", role); - checkNotNull(role.getId(), "Id cannot be null for Role %s", role); - checkNotNull(role.getName(), "Name cannot be null for Role %s", role); - checkNotNull(role.getPath(), "Path cannot be null for Role %s", role); - checkNotNull(role.getAssumeRolePolicy(), "AssumeRolePolicy cannot be null for Role %s", role); - checkNotNull(role.getCreateDate(), "CreateDate cannot be null for a Role Role %s", role); - } - - @Test - protected void testListRoles() { - ImmutableList roles = api().list().concat().toList(); - getAnonymousLogger().info("roles: " + roles.size()); - - for (Role role : roles) { - checkRole(role); - assertEquals(api().get(role.getName()), role); - ImmutableSet rolesAtPath = api().listPathPrefix(role.getPath()).concat().toSet(); - assertTrue(rolesAtPath.contains(role), role + " not in " + rolesAtPath); - } - } - - @Test - protected void testListInstanceProfiles() { - for (Role role : api().list().concat()) { - for (InstanceProfile instanceProfile : api().listInstanceProfiles(role.getName()).concat()) { - InstanceProfileApiLiveTest.checkInstanceProfile(instanceProfile); - } - } - } - - @Test - public void testGetRoleWhenNotFound() { - assertNull(api().get("AAAAAAAAAAAAAAAA")); - } - - @Test - public void testDeleteRoleWhenNotFound() { - api().delete("AAAAAAAAAAAAAAAA"); - } - - static String assumeRolePolicy = "{\"Version\":\"2008-10-17\",\"Statement\":[{\"Sid\":\"\",\"Effect\":\"Allow\",\"Principal\":{\"Service\":\"ec2.amazonaws.com\"},\"Action\":\"sts:AssumeRole\"}]}"; - - @Test - public void testCreateAndDeleteRole() { - String name = System.getProperty("user.name").replace('.', '-') + ".role.iamtest.jclouds.org."; - Role newRole; - try { - newRole = api().createWithPolicy(name, assumeRolePolicy); - getAnonymousLogger().info("created role: " + newRole); - checkRole(newRole); - assertEquals(newRole.getAssumeRolePolicy(), assumeRolePolicy); - } finally { - api().delete(name); - assertNull(api().get(name)); - } - } - - protected RoleApi api() { - return context.getApi().getRoleApi(); - } -} diff --git a/labs/iam/src/test/java/org/jclouds/iam/features/RolePolicyApiExpectTest.java b/labs/iam/src/test/java/org/jclouds/iam/features/RolePolicyApiExpectTest.java deleted file mode 100644 index 1c203f8e17..0000000000 --- a/labs/iam/src/test/java/org/jclouds/iam/features/RolePolicyApiExpectTest.java +++ /dev/null @@ -1,199 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unles required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either expres or implied. See the License for the - * specific language governing permisions and limitations - * under the License. - */ -package org.jclouds.iam.features; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNull; - -import org.jclouds.http.HttpRequest; -import org.jclouds.http.HttpResponse; -import org.jclouds.iam.IAMApi; -import org.jclouds.iam.internal.BaseIAMApiExpectTest; -import org.jclouds.iam.parse.GetRolePolicyResponseTest; -import org.jclouds.iam.parse.ListRolePoliciesResponseTest; -import org.jclouds.rest.ResourceNotFoundException; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableList; -import com.google.common.collect.Iterables; - -/** - * @author Adrian Cole - */ -@Test(groups = "unit", testName = "RolePolicyApiExpectTest") -public class RolePolicyApiExpectTest extends BaseIAMApiExpectTest { - String policy = "{\"Version\":\"2008-10-17\",\"Statement\":[{\"Effect\":\"Allow\",\"Action\":[\"s3:*\"],\"Resource\":[\"*\"]}]}"; - - HttpRequest create = HttpRequest.builder() - .method("POST") - .endpoint("https://iam.amazonaws.com/") - .addHeader("Host", "iam.amazonaws.com") - .addFormParam("Action", "PutRolePolicy") - .addFormParam("PolicyDocument", policy) - .addFormParam("PolicyName", "S3AccessPolicy") - .addFormParam("RoleName", "S3Access") - .addFormParam("Signature", "CEf5SvDv%2BLBRwlZI/3nBghWXFHC1nMfOFccfAITNjOk%3D") - .addFormParam("SignatureMethod", "HmacSHA256") - .addFormParam("SignatureVersion", "2") - .addFormParam("Timestamp", "2009-11-08T15%3A54%3A08.897Z") - .addFormParam("Version", "2010-05-08") - .addFormParam("AWSAccessKeyId", "identity").build(); - - public void testCreateWhenResponseIs2xx() throws Exception { - - HttpResponse getResponse = HttpResponse.builder().statusCode(200) - .payload(payloadFromResourceWithContentType("/put_role_policy.xml", "text/xml")).build(); - - IAMApi apiWhenExist = requestSendsResponse(create, getResponse); - - apiWhenExist.getPolicyApiForRole("S3Access").create("S3AccessPolicy", policy); - } - - HttpRequest get = HttpRequest.builder() - .method("POST") - .endpoint("https://iam.amazonaws.com/") - .addHeader("Host", "iam.amazonaws.com") - .addFormParam("Action", "GetRolePolicy") - .addFormParam("PolicyName", "S3AccessPolicy") - .addFormParam("RoleName", "S3Access") - .addFormParam("Signature", "MBTj0PjbypNbE7%2ByD2CJ/4NnzLFzV8RQNFPMI7GH03k%3D") - .addFormParam("SignatureMethod", "HmacSHA256") - .addFormParam("SignatureVersion", "2") - .addFormParam("Timestamp", "2009-11-08T15%3A54%3A08.897Z") - .addFormParam("Version", "2010-05-08") - .addFormParam("AWSAccessKeyId", "identity").build(); - - public void testGetWhenResponseIs2xx() throws Exception { - - HttpResponse getResponse = HttpResponse.builder().statusCode(200) - .payload(payloadFromResourceWithContentType("/get_role_policy.xml", "text/xml")).build(); - - IAMApi apiWhenExist = requestSendsResponse(get, getResponse); - - assertEquals(apiWhenExist.getPolicyApiForRole("S3Access").get("S3AccessPolicy").toString(), - new GetRolePolicyResponseTest().expected().toString()); - } - - public void testGetWhenResponseIs404() throws Exception { - - HttpResponse getResponse = HttpResponse.builder().statusCode(404).build(); - - IAMApi apiWhenDontExist = requestSendsResponse( - get, getResponse); - - assertNull(apiWhenDontExist.getPolicyApiForRole("S3Access").get("S3AccessPolicy")); - } - - HttpRequest delete = HttpRequest.builder() - .method("POST") - .endpoint("https://iam.amazonaws.com/") - .addHeader("Host", "iam.amazonaws.com") - .addFormParam("Action", "DeleteRolePolicy") - .addFormParam("PolicyName", "S3AccessPolicy") - .addFormParam("RoleName", "S3Access") - .addFormParam("Signature", "eoLLlpvrOuh9MU4d9y1frBFc6RISnzejYwh0jgtKlhY%3D") - .addFormParam("SignatureMethod", "HmacSHA256") - .addFormParam("SignatureVersion", "2") - .addFormParam("Timestamp", "2009-11-08T15%3A54%3A08.897Z") - .addFormParam("Version", "2010-05-08") - .addFormParam("AWSAccessKeyId", "identity").build(); - - public void testDeleteWhenResponseIs2xx() throws Exception { - - HttpResponse deleteResponse = HttpResponse.builder().statusCode(200) - .payload(payloadFromResourceWithContentType("/delete_role_policy.xml", "text/xml")).build(); - - IAMApi apiWhenExist = requestSendsResponse(delete, deleteResponse); - - apiWhenExist.getPolicyApiForRole("S3Access").delete("S3AccessPolicy"); - } - - public void testDeleteWhenResponseIs404() throws Exception { - - HttpResponse deleteResponse = HttpResponse.builder().statusCode(404).build(); - - IAMApi apiWhenDontExist = requestSendsResponse(delete, deleteResponse); - - apiWhenDontExist.getPolicyApiForRole("S3Access").delete("S3AccessPolicy"); - } - - HttpRequest list = HttpRequest.builder() - .method("POST") - .endpoint("https://iam.amazonaws.com/") - .addHeader("Host", "iam.amazonaws.com") - .addFormParam("Action", "ListRolePolicies") - .addFormParam("RoleName", "S3Access") - .addFormParam("Signature", "qsfSpvDHNcMtKgnCiiYO1cikVVYrEHo/vqSt0tztvuY%3D") - .addFormParam("SignatureMethod", "HmacSHA256") - .addFormParam("SignatureVersion", "2") - .addFormParam("Timestamp", "2009-11-08T15%3A54%3A08.897Z") - .addFormParam("Version", "2010-05-08") - .addFormParam("AWSAccessKeyId", "identity").build(); - - public void testListWhenResponseIs2xx() throws Exception { - - HttpResponse listResponse = HttpResponse.builder().statusCode(200) - .payload(payloadFromResourceWithContentType("/list_role_policies.xml", "text/xml")).build(); - - IAMApi apiWhenExist = requestSendsResponse(list, listResponse); - - assertEquals(apiWhenExist.getPolicyApiForRole("S3Access").list().get(0).toString(), - new ListRolePoliciesResponseTest().expected().toString()); - } - - public void testList2PagesWhenResponseIs2xx() throws Exception { - - HttpResponse listResponse = HttpResponse.builder().statusCode(200) - .payload(payloadFromResourceWithContentType("/list_role_policies_marker.xml", "text/xml")).build(); - - HttpRequest list2 = HttpRequest.builder() - .method("POST") - .endpoint("https://iam.amazonaws.com/") - .addHeader("Host", "iam.amazonaws.com") - .addFormParam("Action", "ListRolePolicies") - .addFormParam("Marker", "MARKER") - .addFormParam("RoleName", "S3Access") - .addFormParam("Signature", "GdoVCf2QZ7rld%2BHvIgbSPhjgwYtigqYXdi/LfVzlWaM%3D") - .addFormParam("SignatureMethod", "HmacSHA256") - .addFormParam("SignatureVersion", "2") - .addFormParam("Timestamp", "2009-11-08T15%3A54%3A08.897Z") - .addFormParam("Version", "2010-05-08") - .addFormParam("AWSAccessKeyId", "identity").build(); - - HttpResponse list2Response = HttpResponse.builder().statusCode(200) - .payload(payloadFromResourceWithContentType("/list_role_policies.xml", "text/xml")).build(); - - IAMApi apiWhenExist = requestsSendResponses(list, listResponse, list2, list2Response); - - assertEquals(apiWhenExist.getPolicyApiForRole("S3Access").list().concat().toList(), - ImmutableList.copyOf(Iterables.concat(new ListRolePoliciesResponseTest().expected(), - new ListRolePoliciesResponseTest().expected()))); - } - - // TODO: this should really be an empty set - @Test(expectedExceptions = ResourceNotFoundException.class) - public void testListWhenResponseIs404() throws Exception { - - HttpResponse listResponse = HttpResponse.builder().statusCode(404).build(); - - IAMApi apiWhenDontExist = requestSendsResponse(list, listResponse); - - apiWhenDontExist.getPolicyApiForRole("S3Access").list().get(0); - } -} diff --git a/labs/iam/src/test/java/org/jclouds/iam/features/RolePolicyApiLiveTest.java b/labs/iam/src/test/java/org/jclouds/iam/features/RolePolicyApiLiveTest.java deleted file mode 100644 index 2b6f04a2f8..0000000000 --- a/labs/iam/src/test/java/org/jclouds/iam/features/RolePolicyApiLiveTest.java +++ /dev/null @@ -1,77 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.iam.features; - -import static com.google.common.base.Preconditions.checkNotNull; -import static java.util.logging.Logger.getAnonymousLogger; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNull; - -import org.jclouds.iam.domain.Policy; -import org.jclouds.iam.domain.Role; -import org.jclouds.iam.internal.BaseIAMApiLiveTest; -import org.testng.annotations.Test; - -/** - * @author Adrian Cole - */ -@Test(groups = "live", testName = "RolePolicyApiLiveTest") -public class RolePolicyApiLiveTest extends BaseIAMApiLiveTest { - - static void checkPolicy(Policy policy) { - checkNotNull(policy.getOwner(), "Owner cannot be null for Policy %s", policy); - checkNotNull(policy.getName(), "Name cannot be null for Policy %s", policy); - checkNotNull(policy.getDocument(), "Document cannot be null for Policy %s", policy); - } - - @Test - protected void testListRolePolicies() { - for (Role role : context.getApi().getRoleApi().list().concat()) { - for (String policy : api(role.getName()).list().concat()) { - checkPolicy(api(role.getName()).get(policy)); - } - } - } - - static String s3Policy = "{\"Statement\":[{\"Effect\":\"Allow\",\"Action\":\"s3:*\",\"Resource\":\"*\"}]}"; - - @Test - public void testCreateAndDeleteRolePolicy() { - String roleName = System.getProperty("user.name").replace('.', '-') + ".role_policy.iamtest.jclouds.org."; - Role newRole; - try { - newRole = context.getApi().getRoleApi().createWithPolicy(roleName, RoleApiLiveTest.assumeRolePolicy); - getAnonymousLogger().info("created role: " + newRole); - api(roleName).create("S3Access", s3Policy); - Policy newPolicy = api(roleName).get("S3Access"); - getAnonymousLogger().info("created policy: " + newPolicy); - checkPolicy(newPolicy); - assertEquals(newPolicy.getDocument(), s3Policy); - api(roleName).delete("S3Access"); - assertNull(api(roleName).get("S3Access")); - } finally { - api(roleName).delete("S3Access"); - context.getApi().getRoleApi().delete(roleName); - } - } - - protected RolePolicyApi api(String role) { - return context.getApi().getPolicyApiForRole(role); - } -} diff --git a/labs/iam/src/test/java/org/jclouds/iam/features/UserApiExpectTest.java b/labs/iam/src/test/java/org/jclouds/iam/features/UserApiExpectTest.java deleted file mode 100644 index 08b8fb0b9a..0000000000 --- a/labs/iam/src/test/java/org/jclouds/iam/features/UserApiExpectTest.java +++ /dev/null @@ -1,238 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unles required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either expres or implied. See the License for the - * specific language governing permisions and limitations - * under the License. - */ -package org.jclouds.iam.features; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNull; - -import org.jclouds.http.HttpRequest; -import org.jclouds.http.HttpResponse; -import org.jclouds.iam.IAMApi; -import org.jclouds.iam.internal.BaseIAMApiExpectTest; -import org.jclouds.iam.parse.GetUserResponseTest; -import org.jclouds.iam.parse.ListUsersResponseTest; -import org.jclouds.rest.ResourceNotFoundException; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableList; -import com.google.common.collect.Iterables; - -/** - * @author Adrian Cole - */ -@Test(groups = "unit", testName = "UserApiExpectTest") -public class UserApiExpectTest extends BaseIAMApiExpectTest { - - public void testGetCurrentWhenResponseIs2xx() throws Exception { - HttpRequest get = HttpRequest.builder() - .method("POST") - .endpoint("https://iam.amazonaws.com/") - .addHeader("Host", "iam.amazonaws.com") - .addFormParam("Action", "GetUser") - .addFormParam("Signature", "2UamWqKKgoSbaZpvixX0LKqGW/IIP9L319DLEUtYu3A%3D") - .addFormParam("SignatureMethod", "HmacSHA256") - .addFormParam("SignatureVersion", "2") - .addFormParam("Timestamp", "2009-11-08T15%3A54%3A08.897Z") - .addFormParam("Version", "2010-05-08") - .addFormParam("AWSAccessKeyId", "identity").build(); - - HttpResponse getResponse = HttpResponse.builder().statusCode(200) - .payload(payloadFromResourceWithContentType("/get_user.xml", "text/xml")).build(); - - IAMApi apiWhenExist = requestSendsResponse( - get, getResponse); - - assertEquals(apiWhenExist.getUserApi().getCurrent().toString(), new GetUserResponseTest().expected().toString()); - } - - HttpRequest get = HttpRequest.builder() - .method("POST") - .endpoint("https://iam.amazonaws.com/") - .addHeader("Host", "iam.amazonaws.com") - .addFormParam("Action", "GetUser") - .addFormParam("Signature", "cnY/AaG656cruOmb3y7YHtjnPB1qg3aavff6PPxIMs0%3D") - .addFormParam("SignatureMethod", "HmacSHA256") - .addFormParam("SignatureVersion", "2") - .addFormParam("Timestamp", "2009-11-08T15%3A54%3A08.897Z") - .addFormParam("UserName", "name") - .addFormParam("Version", "2010-05-08") - .addFormParam("AWSAccessKeyId", "identity").build(); - - - public void testGetWhenResponseIs2xx() throws Exception { - - HttpResponse getResponse = HttpResponse.builder().statusCode(200) - .payload(payloadFromResourceWithContentType("/get_user.xml", "text/xml")).build(); - - IAMApi apiWhenExist = requestSendsResponse( - get, getResponse); - - assertEquals(apiWhenExist.getUserApi().get("name").toString(), new GetUserResponseTest().expected().toString()); - } - - public void testGetWhenResponseIs404() throws Exception { - - HttpResponse getResponse = HttpResponse.builder().statusCode(404).build(); - - IAMApi apiWhenDontExist = requestSendsResponse( - get, getResponse); - - assertNull(apiWhenDontExist.getUserApi().get("name")); - } - - HttpRequest list = HttpRequest.builder() - .method("POST") - .endpoint("https://iam.amazonaws.com/") - .addHeader("Host", "iam.amazonaws.com") - .addFormParam("Action", "ListUsers") - .addFormParam("Signature", "ed4OrONGuVlGpHSY8u5X2m9LVwx6oiihu7HbvA0iZkY%3D") - .addFormParam("SignatureMethod", "HmacSHA256") - .addFormParam("SignatureVersion", "2") - .addFormParam("Timestamp", "2009-11-08T15%3A54%3A08.897Z") - .addFormParam("Version", "2010-05-08") - .addFormParam("AWSAccessKeyId", "identity").build(); - - public void testListWhenResponseIs2xx() throws Exception { - - HttpResponse listResponse = HttpResponse.builder().statusCode(200) - .payload(payloadFromResourceWithContentType("/list_users.xml", "text/xml")).build(); - - IAMApi apiWhenExist = requestSendsResponse( - list, listResponse); - - assertEquals(apiWhenExist.getUserApi().list().get(0).toString(), new ListUsersResponseTest().expected().toString()); - } - - public void testList2PagesWhenResponseIs2xx() throws Exception { - - HttpResponse listResponse = HttpResponse.builder().statusCode(200) - .payload(payloadFromResourceWithContentType("/list_users_marker.xml", "text/xml")).build(); - - HttpRequest list2 = HttpRequest.builder() - .method("POST") - .endpoint("https://iam.amazonaws.com/") - .addHeader("Host", "iam.amazonaws.com") - .addFormParam("Action", "ListUsers") - .addFormParam("Marker", "MARKER") - .addFormParam("Signature", "LKYao6Hll/plLDqOcgbNuJ6DhmOw0tZl4Sf3pPY%2By00%3D") - .addFormParam("SignatureMethod", "HmacSHA256") - .addFormParam("SignatureVersion", "2") - .addFormParam("Timestamp", "2009-11-08T15%3A54%3A08.897Z") - .addFormParam("Version", "2010-05-08") - .addFormParam("AWSAccessKeyId", "identity").build(); - - HttpResponse list2Response = HttpResponse.builder().statusCode(200) - .payload(payloadFromResourceWithContentType("/list_users.xml", "text/xml")).build(); - - IAMApi apiWhenExist = requestsSendResponses(list, listResponse, list2, list2Response); - - assertEquals(apiWhenExist.getUserApi().list().concat().toList(), - ImmutableList.copyOf(Iterables.concat(new ListUsersResponseTest().expected(), new ListUsersResponseTest().expected()))); - } - - HttpRequest listPathPrefix = HttpRequest.builder() - .method("POST") - .endpoint("https://iam.amazonaws.com/") - .addHeader("Host", "iam.amazonaws.com") - .addFormParam("Action", "ListUsers") - .addFormParam("PathPrefix", "/subdivision") - .addFormParam("Signature", "giw/28vFH9GZoqf60bP4Ka80kBXhJDcncC%2BWA0Dkg/o%3D") - .addFormParam("SignatureMethod", "HmacSHA256") - .addFormParam("SignatureVersion", "2") - .addFormParam("Timestamp", "2009-11-08T15%3A54%3A08.897Z") - .addFormParam("Version", "2010-05-08") - .addFormParam("AWSAccessKeyId", "identity").build(); - - public void testListPathPrefixWhenResponseIs2xx() throws Exception { - - HttpResponse listResponse = HttpResponse.builder().statusCode(200) - .payload(payloadFromResourceWithContentType("/list_users.xml", "text/xml")).build(); - - IAMApi apiWhenExist = requestSendsResponse( - listPathPrefix, listResponse); - - assertEquals(apiWhenExist.getUserApi().listPathPrefix("/subdivision").get(0).toString(), new ListUsersResponseTest().expected().toString()); - } - - public void testListPathPrefix2PagesWhenResponseIs2xx() throws Exception { - - HttpResponse listResponse = HttpResponse.builder().statusCode(200) - .payload(payloadFromResourceWithContentType("/list_users_marker.xml", "text/xml")).build(); - - HttpRequest listPathPrefix2 = HttpRequest.builder() - .method("POST") - .endpoint("https://iam.amazonaws.com/") - .addHeader("Host", "iam.amazonaws.com") - .addFormParam("Action", "ListUsers") - .addFormParam("Marker", "MARKER") - .addFormParam("PathPrefix", "/subdivision") - .addFormParam("Signature", "JSAWWjJdoz8Twn3CSjkuqWIJmmokjQyKPOdekNeVl30%3D") - .addFormParam("SignatureMethod", "HmacSHA256") - .addFormParam("SignatureVersion", "2") - .addFormParam("Timestamp", "2009-11-08T15%3A54%3A08.897Z") - .addFormParam("Version", "2010-05-08") - .addFormParam("AWSAccessKeyId", "identity").build(); - - HttpResponse list2Response = HttpResponse.builder().statusCode(200) - .payload(payloadFromResourceWithContentType("/list_users.xml", "text/xml")).build(); - - IAMApi apiWhenExist = requestsSendResponses(listPathPrefix, listResponse, listPathPrefix2, list2Response); - - assertEquals(apiWhenExist.getUserApi().listPathPrefix("/subdivision").concat().toList(), - ImmutableList.copyOf(Iterables.concat(new ListUsersResponseTest().expected(), new ListUsersResponseTest().expected()))); - } - - // TODO: this should really be an empty set - @Test(expectedExceptions = ResourceNotFoundException.class) - public void testListWhenResponseIs404() throws Exception { - - HttpResponse listResponse = HttpResponse.builder().statusCode(404).build(); - - IAMApi apiWhenDontExist = requestSendsResponse( - list, listResponse); - - apiWhenDontExist.getUserApi().list().get(0); - } - - public void testListPathPrefixAtWhenResponseIs2xx() throws Exception { - HttpRequest listWithOptions = - HttpRequest.builder() - .method("POST") - .endpoint("https://iam.amazonaws.com/") - .addHeader("Host", "iam.amazonaws.com") - .addFormParam("Action", "ListUsers") - .addFormParam("Marker", "MARKER") - .addFormParam("PathPrefix", "/foo") - .addFormParam("Signature", "1%2BeCgNIAjHr%2BraNdDd3rsVC5Qok3AuTrJOa5mZwmE7g%3D") - .addFormParam("SignatureMethod", "HmacSHA256") - .addFormParam("SignatureVersion", "2") - .addFormParam("Timestamp", "2009-11-08T15%3A54%3A08.897Z") - .addFormParam("Version", "2010-05-08") - .addFormParam("AWSAccessKeyId", "identity").build(); - - HttpResponse listWithOptionsResponse = HttpResponse.builder().statusCode(200) - .payload(payloadFromResourceWithContentType("/list_users.xml", "text/xml")).build(); - - IAMApi apiWhenWithOptionsExist = requestSendsResponse(listWithOptions, - listWithOptionsResponse); - - assertEquals(apiWhenWithOptionsExist.getUserApi().listPathPrefixAt("/foo", "MARKER").toString(), - new ListUsersResponseTest().expected().toString()); - } -} diff --git a/labs/iam/src/test/java/org/jclouds/iam/features/UserApiLiveTest.java b/labs/iam/src/test/java/org/jclouds/iam/features/UserApiLiveTest.java deleted file mode 100644 index 0982461b6d..0000000000 --- a/labs/iam/src/test/java/org/jclouds/iam/features/UserApiLiveTest.java +++ /dev/null @@ -1,71 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.iam.features; - -import static com.google.common.base.Preconditions.checkNotNull; -import static java.util.logging.Logger.getAnonymousLogger; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertTrue; - -import org.jclouds.iam.domain.User; -import org.jclouds.iam.internal.BaseIAMApiLiveTest; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableSet; - -/** - * @author Adrian Cole - */ -@Test(groups = "live", testName = "UserApiLiveTest") -public class UserApiLiveTest extends BaseIAMApiLiveTest { - - @Test - protected void testGetCurrentUser() { - User user = api().getCurrent(); - checkUser(user); - } - - static void checkUser(User user) { - checkNotNull(user.getArn(), "Arn cannot be null for User %s", user); - checkNotNull(user.getId(), "Id cannot be null for User %s", user); - checkNotNull(user.getName(), "While Name can be null for a User, its Optional wrapper cannot; user %s", user); - checkNotNull(user.getPath(), "While Path can be null for a User, its Optional wrapper cannot; user %s", user); - checkNotNull(user.getCreateDate(), "CreateDate cannot be null for a User User %s", user); - } - - @Test - protected void testListUsers() { - ImmutableList users = api().list().concat().toList(); - getAnonymousLogger().info("users: " + users.size()); - - for (User user : users) { - checkUser(user); - assertEquals(api().get(user.getId()), user); - if (user.getPath().isPresent()) { - ImmutableSet usersAtPath = api().listPathPrefix(user.getPath().get()).concat().toSet(); - assertTrue(usersAtPath.contains(user), user + " not in " + usersAtPath); - } - } - } - - protected UserApi api() { - return context.getApi().getUserApi(); - } -} diff --git a/labs/iam/src/test/java/org/jclouds/iam/internal/BaseIAMApiExpectTest.java b/labs/iam/src/test/java/org/jclouds/iam/internal/BaseIAMApiExpectTest.java deleted file mode 100644 index 8be851b555..0000000000 --- a/labs/iam/src/test/java/org/jclouds/iam/internal/BaseIAMApiExpectTest.java +++ /dev/null @@ -1,29 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.iam.internal; - -import org.jclouds.iam.IAMApi; - -/** - * - * @author Adrian Cole - */ -public class BaseIAMApiExpectTest extends BaseIAMExpectTest { - -} diff --git a/labs/iam/src/test/java/org/jclouds/iam/internal/BaseIAMApiLiveTest.java b/labs/iam/src/test/java/org/jclouds/iam/internal/BaseIAMApiLiveTest.java deleted file mode 100644 index d6b989f7a1..0000000000 --- a/labs/iam/src/test/java/org/jclouds/iam/internal/BaseIAMApiLiveTest.java +++ /dev/null @@ -1,47 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.iam.internal; - -import org.jclouds.apis.BaseContextLiveTest; -import org.jclouds.iam.IAMApiMetadata; -import org.jclouds.iam.IAMAsyncApi; -import org.jclouds.iam.IAMApi; -import org.jclouds.rest.RestContext; -import org.testng.annotations.Test; - -import com.google.common.reflect.TypeToken; - -/** - * - * @author Adrian Cole - */ -@Test(groups = "live") -public class BaseIAMApiLiveTest extends - BaseContextLiveTest> { - - public BaseIAMApiLiveTest() { - provider = "iam"; - } - - @Override - protected TypeToken> contextType() { - return IAMApiMetadata.CONTEXT_TOKEN; - } - -} diff --git a/labs/iam/src/test/java/org/jclouds/iam/internal/BaseIAMAsyncApiExpectTest.java b/labs/iam/src/test/java/org/jclouds/iam/internal/BaseIAMAsyncApiExpectTest.java deleted file mode 100644 index 39b46d2406..0000000000 --- a/labs/iam/src/test/java/org/jclouds/iam/internal/BaseIAMAsyncApiExpectTest.java +++ /dev/null @@ -1,38 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.iam.internal; - -import java.util.Properties; - -import org.jclouds.http.HttpRequest; -import org.jclouds.http.HttpResponse; -import org.jclouds.iam.IAMAsyncApi; - -import com.google.common.base.Function; -import com.google.inject.Module; - -/** - * - * @author Adrian Cole - */ -public class BaseIAMAsyncApiExpectTest extends BaseIAMExpectTest { - public IAMAsyncApi createApi(Function fn, Module module, Properties props) { - return createInjector(fn, module, props).getInstance(IAMAsyncApi.class); - } -} diff --git a/labs/iam/src/test/java/org/jclouds/iam/internal/BaseIAMExpectTest.java b/labs/iam/src/test/java/org/jclouds/iam/internal/BaseIAMExpectTest.java deleted file mode 100644 index b43af503e2..0000000000 --- a/labs/iam/src/test/java/org/jclouds/iam/internal/BaseIAMExpectTest.java +++ /dev/null @@ -1,54 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.iam.internal; - -import java.util.TimeZone; - -import org.jclouds.date.DateService; -import org.jclouds.iam.config.IAMRestClientModule; -import org.jclouds.rest.ConfiguresRestClient; -import org.jclouds.rest.internal.BaseRestApiExpectTest; - -import com.google.inject.Module; - -/** - * - * @author Adrian Cole - */ -public class BaseIAMExpectTest extends BaseRestApiExpectTest { - - public BaseIAMExpectTest() { - provider = "iam"; - TimeZone.setDefault(TimeZone.getTimeZone("America/Los_Angeles")); - } - - @ConfiguresRestClient - private static final class TestIAMRestClientModule extends IAMRestClientModule { - - @Override - protected String provideTimeStamp(final DateService dateService) { - return "2009-11-08T15:54:08.897Z"; - } - } - - @Override - protected Module createModule() { - return new TestIAMRestClientModule(); - } -} diff --git a/labs/iam/src/test/java/org/jclouds/iam/parse/GetInstanceProfileResponseTest.java b/labs/iam/src/test/java/org/jclouds/iam/parse/GetInstanceProfileResponseTest.java deleted file mode 100644 index 6d76371c7c..0000000000 --- a/labs/iam/src/test/java/org/jclouds/iam/parse/GetInstanceProfileResponseTest.java +++ /dev/null @@ -1,73 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.iam.parse; - -import static org.testng.Assert.assertEquals; - -import java.io.InputStream; - -import org.jclouds.date.DateService; -import org.jclouds.date.internal.SimpleDateFormatDateService; -import org.jclouds.http.functions.BaseHandlerTest; -import org.jclouds.iam.domain.InstanceProfile; -import org.jclouds.iam.domain.Role; -import org.jclouds.iam.xml.InstanceProfileHandler; -import org.testng.annotations.Test; - -/** - * @author Adrian Cole - */ -// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire -@Test(groups = "unit", testName = "GetInstanceProfileResponseTest") -public class GetInstanceProfileResponseTest extends BaseHandlerTest { - - public void test() { - InputStream is = getClass().getResourceAsStream("/get_instance_profile.xml"); - - InstanceProfile expected = expected(); - - InstanceProfileHandler handler = injector.getInstance(InstanceProfileHandler.class); - InstanceProfile result = factory.create(handler).parse(is); - - assertEquals(result, expected); - assertEquals(result.getPath(), expected.getPath()); - assertEquals(result.getName(), expected.getName()); - assertEquals(result.getCreateDate(), expected.getCreateDate()); - assertEquals(result.getRoles(), expected.getRoles()); - } - - DateService date = new SimpleDateFormatDateService(); - - public InstanceProfile expected() { - return InstanceProfile.builder() - .arn("arn:aws:iam::123456789012:instance-profile/application_abc/component_xyz/Webserver") - .id("AIPAD5ARO2C5EXAMPLE3G") - .name("Webserver") - .path("/application_abc/component_xyz/") - .role(Role.builder() - .arn("arn:aws:iam::123456789012:role/application_abc/component_xyz/S3Access") - .id("AROACVYKSVTSZFEXAMPLE") - .name("S3Access") - .path("/application_abc/component_xyz/") - .assumeRolePolicy("{\"Version\":\"2008-10-17\",\"Statement\":[{\"Effect\":\"Allow\",\"Principal\":{\"Service\":[\"ec2.amazonaws.com\"]},\"Action\":[\"sts:AssumeRole\"]}]}") - .createDate(date.iso8601SecondsDateParse("2012-05-09T15:45:35Z")).build()) - .createDate(date.iso8601SecondsDateParse("2012-05-09T16:11:10Z")).build(); - } - -} diff --git a/labs/iam/src/test/java/org/jclouds/iam/parse/GetRolePolicyResponseTest.java b/labs/iam/src/test/java/org/jclouds/iam/parse/GetRolePolicyResponseTest.java deleted file mode 100644 index 0303637540..0000000000 --- a/labs/iam/src/test/java/org/jclouds/iam/parse/GetRolePolicyResponseTest.java +++ /dev/null @@ -1,60 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.iam.parse; - -import static org.testng.Assert.assertEquals; - -import java.io.InputStream; - -import org.jclouds.http.functions.BaseHandlerTest; -import org.jclouds.iam.domain.Policy; -import org.jclouds.iam.xml.PolicyHandler; -import org.testng.annotations.Test; - -/** - * @author Adrian Cole - */ -// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire -@Test(groups = "unit", testName = "GetRolePolicyResponseTest") -public class GetRolePolicyResponseTest extends BaseHandlerTest { - - public void test() { - InputStream is = getClass().getResourceAsStream("/get_role_policy.xml"); - - Policy expected = expected(); - - PolicyHandler handler = injector.getInstance(PolicyHandler.class); - Policy result = factory.create(handler).parse(is); - - assertEquals(result, expected); - assertEquals(result.getOwner(), expected.getOwner()); - assertEquals(result.getName(), expected.getName()); - assertEquals(result.getDocument(), expected.getDocument()); - } - - public Policy expected() { - return Policy.builder() - .owner("S3Access") - .name("S3AccessPolicy") - .document( - "{\"Version\":\"2008-10-17\",\"Statement\":[{\"Effect\":\"Allow\",\"Action\":[\"s3:*\"],\"Resource\":[\"*\"]}]}") - .build(); - } - -} diff --git a/labs/iam/src/test/java/org/jclouds/iam/parse/GetRoleResponseTest.java b/labs/iam/src/test/java/org/jclouds/iam/parse/GetRoleResponseTest.java deleted file mode 100644 index 16bcfc4d2c..0000000000 --- a/labs/iam/src/test/java/org/jclouds/iam/parse/GetRoleResponseTest.java +++ /dev/null @@ -1,63 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.iam.parse; - -import static org.testng.Assert.assertEquals; - -import java.io.InputStream; - -import org.jclouds.date.internal.SimpleDateFormatDateService; -import org.jclouds.http.functions.BaseHandlerTest; -import org.jclouds.iam.domain.Role; -import org.jclouds.iam.xml.RoleHandler; -import org.testng.annotations.Test; - -/** - * @author Adrian Cole - */ -// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire -@Test(groups = "unit", testName = "GetRoleResponseTest") -public class GetRoleResponseTest extends BaseHandlerTest { - - public void test() { - InputStream is = getClass().getResourceAsStream("/get_role.xml"); - - Role expected = expected(); - - RoleHandler handler = injector.getInstance(RoleHandler.class); - Role result = factory.create(handler).parse(is); - - assertEquals(result, expected); - assertEquals(result.getPath(), expected.getPath()); - assertEquals(result.getName(), expected.getName()); - assertEquals(result.getCreateDate(), expected.getCreateDate()); - assertEquals(result.getAssumeRolePolicy(), expected.getAssumeRolePolicy()); - } - - public Role expected() { - return Role.builder() - .arn("arn:aws:iam::993194456877:role/foobie") - .id("AROAIBFDQ5TQHEMPBEUE4") - .name("foobie") - .path("/") - .assumeRolePolicy("{\"Version\":\"2008-10-17\",\"Statement\":[{\"Sid\":\"\",\"Effect\":\"Allow\",\"Principal\":{\"Service\":\"ec2.amazonaws.com\"},\"Action\":\"sts:AssumeRole\"}]}") - .createDate(new SimpleDateFormatDateService().iso8601SecondsDateParse("2013-02-25T01:51:35Z")).build(); - } - -} diff --git a/labs/iam/src/test/java/org/jclouds/iam/parse/GetUserResponseTest.java b/labs/iam/src/test/java/org/jclouds/iam/parse/GetUserResponseTest.java deleted file mode 100644 index d274cb9218..0000000000 --- a/labs/iam/src/test/java/org/jclouds/iam/parse/GetUserResponseTest.java +++ /dev/null @@ -1,60 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.iam.parse; - -import static org.testng.Assert.assertEquals; - -import java.io.InputStream; - -import org.jclouds.date.internal.SimpleDateFormatDateService; -import org.jclouds.http.functions.BaseHandlerTest; -import org.jclouds.iam.domain.User; -import org.jclouds.iam.xml.UserHandler; -import org.testng.annotations.Test; - -/** - * @author Adrian Cole - */ -// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire -@Test(groups = "unit", testName = "GetUserResponseTest") -public class GetUserResponseTest extends BaseHandlerTest { - - public void test() { - InputStream is = getClass().getResourceAsStream("/get_user.xml"); - - User expected = expected(); - - UserHandler handler = injector.getInstance(UserHandler.class); - User result = factory.create(handler).parse(is); - - assertEquals(result, expected); - assertEquals(result.getPath(), expected.getPath()); - assertEquals(result.getName(), expected.getName()); - } - - public User expected() { - return User.builder() - .path("/division_abc/subdivision_xyz/") - .name("Bob") - .id("AIDACKCEVSQ6C2EXAMPLE") - .arn("arn:aws:iam::123456789012:user/division_abc/subdivision_xyz/Bob") - .createDate(new SimpleDateFormatDateService().iso8601SecondsDateParse("2009-03-06T21:47:48Z")).build(); - } - -} diff --git a/labs/iam/src/test/java/org/jclouds/iam/parse/ListInstanceProfilesResponseTest.java b/labs/iam/src/test/java/org/jclouds/iam/parse/ListInstanceProfilesResponseTest.java deleted file mode 100644 index e33962b0d4..0000000000 --- a/labs/iam/src/test/java/org/jclouds/iam/parse/ListInstanceProfilesResponseTest.java +++ /dev/null @@ -1,80 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.iam.parse; - -import static org.testng.Assert.assertEquals; - -import java.io.InputStream; - -import org.jclouds.collect.IterableWithMarker; -import org.jclouds.collect.IterableWithMarkers; -import org.jclouds.date.DateService; -import org.jclouds.date.internal.SimpleDateFormatDateService; -import org.jclouds.http.functions.BaseHandlerTest; -import org.jclouds.iam.domain.InstanceProfile; -import org.jclouds.iam.domain.Role; -import org.jclouds.iam.xml.ListInstanceProfilesResultHandler; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableSet; - -/** - * @author Adrian Cole - */ -// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire -@Test(groups = "unit", testName = "ListInstanceProfilesResponseTest") -public class ListInstanceProfilesResponseTest extends BaseHandlerTest { - - public void test() { - InputStream is = getClass().getResourceAsStream("/list_instance_profiles.xml"); - - IterableWithMarker expected = expected(); - - ListInstanceProfilesResultHandler handler = injector.getInstance(ListInstanceProfilesResultHandler.class); - IterableWithMarker result = factory.create(handler).parse(is); - - assertEquals(result.toString(), expected.toString()); - - } - - DateService date = new SimpleDateFormatDateService(); - - public IterableWithMarker expected() { - return IterableWithMarkers.from(ImmutableSet.of( - InstanceProfile.builder() - .arn("arn:aws:iam::123456789012:instance-profile/application_abc/component_xyz/Database") - .id("AIPACIFN4OZXG7EXAMPLE") - .name("Database") - .path("/application_abc/component_xyz/") - .role(Role.builder() - .arn("arn:aws:iam::123456789012:role/application_abc/component_xyz/S3Access") - .id("AROACVYKSVTSZFEXAMPLE") - .name("S3Access") - .path("/application_abc/component_xyz/") - .assumeRolePolicy("{\"Version\":\"2008-10-17\",\"Statement\":[{\"Effect\":\"Allow\",\"Principal\":{\"Service\":[\"ec2.amazonaws.com\"]},\"Action\":[\"sts:AssumeRole\"]}]}") - .createDate(date.iso8601SecondsDateParse("2012-05-09T15:45:35Z")).build()) - .createDate(date.iso8601SecondsDateParse("2012-05-09T16:27:03Z")).build(), - InstanceProfile.builder() - .arn("arn:aws:iam::123456789012:instance-profile/application_abc/component_xyz/Webserver") - .id("AIPACZLSXM2EYYEXAMPLE") - .name("Webserver") - .path("/application_abc/component_xyz/") - .createDate(date.iso8601SecondsDateParse("2012-05-09T16:27:11Z")).build())); - } -} diff --git a/labs/iam/src/test/java/org/jclouds/iam/parse/ListRolePoliciesResponseTest.java b/labs/iam/src/test/java/org/jclouds/iam/parse/ListRolePoliciesResponseTest.java deleted file mode 100644 index b486760a18..0000000000 --- a/labs/iam/src/test/java/org/jclouds/iam/parse/ListRolePoliciesResponseTest.java +++ /dev/null @@ -1,56 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.iam.parse; - -import static org.testng.Assert.assertEquals; - -import java.io.InputStream; - -import org.jclouds.collect.IterableWithMarker; -import org.jclouds.collect.IterableWithMarkers; -import org.jclouds.http.functions.BaseHandlerTest; -import org.jclouds.iam.xml.ListPoliciesResultHandler; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableSet; - -/** - * @author Adrian Cole - */ -// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire -@Test(groups = "unit", testName = "ListRolePoliciesResponseTest") -public class ListRolePoliciesResponseTest extends BaseHandlerTest { - - public void test() { - InputStream is = getClass().getResourceAsStream("/list_role_policies.xml"); - - IterableWithMarker expected = expected(); - - ListPoliciesResultHandler handler = injector.getInstance(ListPoliciesResultHandler.class); - IterableWithMarker result = factory.create(handler).parse(is); - - assertEquals(result.toString(), expected.toString()); - - } - - public IterableWithMarker expected() { - return IterableWithMarkers.from(ImmutableSet.of("CloudwatchPutMetricPolicy", "S3AccessPolicy")); - } - -} diff --git a/labs/iam/src/test/java/org/jclouds/iam/parse/ListRolesResponseTest.java b/labs/iam/src/test/java/org/jclouds/iam/parse/ListRolesResponseTest.java deleted file mode 100644 index 9e57fe4022..0000000000 --- a/labs/iam/src/test/java/org/jclouds/iam/parse/ListRolesResponseTest.java +++ /dev/null @@ -1,72 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.iam.parse; - -import static org.testng.Assert.assertEquals; - -import java.io.InputStream; - -import org.jclouds.collect.IterableWithMarker; -import org.jclouds.collect.IterableWithMarkers; -import org.jclouds.date.internal.SimpleDateFormatDateService; -import org.jclouds.http.functions.BaseHandlerTest; -import org.jclouds.iam.domain.Role; -import org.jclouds.iam.xml.ListRolesResultHandler; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableSet; - -/** - * @author Adrian Cole - */ -// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire -@Test(groups = "unit", testName = "ListRolesResponseTest") -public class ListRolesResponseTest extends BaseHandlerTest { - - public void test() { - InputStream is = getClass().getResourceAsStream("/list_roles.xml"); - - IterableWithMarker expected = expected(); - - ListRolesResultHandler handler = injector.getInstance(ListRolesResultHandler.class); - IterableWithMarker result = factory.create(handler).parse(is); - - assertEquals(result.toString(), expected.toString()); - - } - - public IterableWithMarker expected() { - return IterableWithMarkers.from(ImmutableSet.of( - Role.builder() - .arn("arn:aws:iam::993194456877:role/foobie") - .id("AROAIBFDQ5TQHEMPBEUE4") - .name("foobie") - .path("/") - .assumeRolePolicy("{\"Version\":\"2008-10-17\",\"Statement\":[{\"Sid\":\"\",\"Effect\":\"Allow\",\"Principal\":{\"Service\":\"ec2.amazonaws.com\"},\"Action\":\"sts:AssumeRole\"}]}") - .createDate(new SimpleDateFormatDateService().iso8601SecondsDateParse("2013-02-25T01:51:35Z")).build(), - Role.builder() - .arn("arn:aws:iam::993194456877:role/s3-read-only") - .id("AROAJZ7NAM67BRSDAJ6PA") - .name("s3-read-only") - .path("/") - .assumeRolePolicy("{\"Version\":\"2008-10-17\",\"Statement\":[{\"Sid\":\"\",\"Effect\":\"Allow\",\"Principal\":{\"Service\":\"ec2.amazonaws.com\"},\"Action\":\"sts:AssumeRole\"}]}") - .createDate(new SimpleDateFormatDateService().iso8601SecondsDateParse("2013-02-25T01:48:59Z")).build())); - } - -} diff --git a/labs/iam/src/test/java/org/jclouds/iam/parse/ListUsersResponseTest.java b/labs/iam/src/test/java/org/jclouds/iam/parse/ListUsersResponseTest.java deleted file mode 100644 index 539de6fd07..0000000000 --- a/labs/iam/src/test/java/org/jclouds/iam/parse/ListUsersResponseTest.java +++ /dev/null @@ -1,70 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.iam.parse; - -import static org.testng.Assert.assertEquals; - -import java.io.InputStream; - -import org.jclouds.collect.IterableWithMarker; -import org.jclouds.collect.IterableWithMarkers; -import org.jclouds.date.internal.SimpleDateFormatDateService; -import org.jclouds.http.functions.BaseHandlerTest; -import org.jclouds.iam.domain.User; -import org.jclouds.iam.xml.ListUsersResultHandler; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableSet; - -/** - * @author Adrian Cole - */ -// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire -@Test(groups = "unit", testName = "ListUsersResponseTest") -public class ListUsersResponseTest extends BaseHandlerTest { - - public void test() { - InputStream is = getClass().getResourceAsStream("/list_users.xml"); - - IterableWithMarker expected = expected(); - - ListUsersResultHandler handler = injector.getInstance(ListUsersResultHandler.class); - IterableWithMarker result = factory.create(handler).parse(is); - - assertEquals(result.toString(), expected.toString()); - - } - - public IterableWithMarker expected() { - return IterableWithMarkers.from(ImmutableSet.of( - User.builder() - .path("/division_abc/subdivision_xyz/engineering/") - .name("Andrew") - .id("AID2MAB8DPLSRHEXAMPLE") - .arn("arn:aws:iam::123456789012:user/division_abc/subdivision_xyz/engineering/Andrew") - .createDate(new SimpleDateFormatDateService().iso8601SecondsDateParse("2009-03-06T21:47:48Z")).build(), - User.builder() - .path("/division_abc/subdivision_xyz/engineering/") - .name("Jackie") - .id("AIDIODR4TAW7CSEXAMPLE") - .arn("arn:aws:iam::123456789012:user/division_abc/subdivision_xyz/engineering/Jackie") - .createDate(new SimpleDateFormatDateService().iso8601SecondsDateParse("2009-03-06T21:47:48Z")).build())); - } - -} diff --git a/labs/iam/src/test/resources/create_role.xml b/labs/iam/src/test/resources/create_role.xml deleted file mode 100644 index a783a357b0..0000000000 --- a/labs/iam/src/test/resources/create_role.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - / - arn:aws:iam::993194456877:role/adriancole.role.iamtest.jclouds.org. - adriancole.role.iamtest.jclouds.org. - %7B%22Version%22%3A%222008-10-17%22%2C%22Statement%22%3A%5B%7B%22Sid%22%3A%22%22%2C%22Effect%22%3A%22Allow%22%2C%22Principal%22%3A%7B%22Service%22%3A%22ec2.amazonaws.com%22%7D%2C%22Action%22%3A%22sts%3AAssumeRole%22%7D%5D%7D - 2013-02-25T02:40:42.201Z - AROAICHA6NH3SOP6PEC72 - - - - bf56e8fb-7ef4-11e2-87c7-6b7f31e39cd7 - - \ No newline at end of file diff --git a/labs/iam/src/test/resources/delete_instance_profile.xml b/labs/iam/src/test/resources/delete_instance_profile.xml deleted file mode 100644 index defab565c0..0000000000 --- a/labs/iam/src/test/resources/delete_instance_profile.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - 913e3f37-99ed-11e1-a4c3-270EXAMPLE04 - - \ No newline at end of file diff --git a/labs/iam/src/test/resources/delete_role.xml b/labs/iam/src/test/resources/delete_role.xml deleted file mode 100644 index ecaa1ab7bb..0000000000 --- a/labs/iam/src/test/resources/delete_role.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - 913e3f37-99ed-11e1-a4c3-270EXAMPLE04 - - \ No newline at end of file diff --git a/labs/iam/src/test/resources/delete_role_policy.xml b/labs/iam/src/test/resources/delete_role_policy.xml deleted file mode 100644 index 1a038d4392..0000000000 --- a/labs/iam/src/test/resources/delete_role_policy.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - c749ee7f-99ef-11e1-a4c3-27EXAMPLE804 - - \ No newline at end of file diff --git a/labs/iam/src/test/resources/get_instance_profile.xml b/labs/iam/src/test/resources/get_instance_profile.xml deleted file mode 100644 index 71c57d545e..0000000000 --- a/labs/iam/src/test/resources/get_instance_profile.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - AIPAD5ARO2C5EXAMPLE3G - - - /application_abc/component_xyz/ - arn:aws:iam::123456789012:role/application_abc/component_xyz/S3Access - S3Access - {"Version":"2008-10-17","Statement":[{"Effect":"Allow","Principal":{"Service":["ec2.amazonaws.com"]},"Action":["sts:AssumeRole"]}]} - 2012-05-09T15:45:35Z - AROACVYKSVTSZFEXAMPLE - - - Webserver - /application_abc/component_xyz/ - arn:aws:iam::123456789012:instance-profile/application_abc/component_xyz/Webserver - 2012-05-09T16:11:10Z - - - - 37289fda-99f2-11e1-a4c3-27EXAMPLE804 - - \ No newline at end of file diff --git a/labs/iam/src/test/resources/get_role.xml b/labs/iam/src/test/resources/get_role.xml deleted file mode 100644 index a658234fc1..0000000000 --- a/labs/iam/src/test/resources/get_role.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - / - arn:aws:iam::993194456877:role/foobie - foobie - %7B%22Version%22%3A%222008-10-17%22%2C%22Statement%22%3A%5B%7B%22Sid%22%3A%22%22%2C%22Effect%22%3A%22Allow%22%2C%22Principal%22%3A%7B%22Service%22%3A%22ec2.amazonaws.com%22%7D%2C%22Action%22%3A%22sts%3AAssumeRole%22%7D%5D%7D - 2013-02-25T01:51:35Z - AROAIBFDQ5TQHEMPBEUE4 - - - - 22fda32f-7eee-11e2-87c7-6b7f31e39cd7 - - \ No newline at end of file diff --git a/labs/iam/src/test/resources/get_role_policy.xml b/labs/iam/src/test/resources/get_role_policy.xml deleted file mode 100644 index a29ded2cee..0000000000 --- a/labs/iam/src/test/resources/get_role_policy.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - S3AccessPolicy - S3Access - {"Version":"2008-10-17","Statement":[{"Effect":"Allow","Action":["s3:*"],"Resource":["*"]}]} - - - 7e7cd8bc-99ef-11e1-a4c3-27EXAMPLE804 - - diff --git a/labs/iam/src/test/resources/get_user.xml b/labs/iam/src/test/resources/get_user.xml deleted file mode 100644 index f4d1704843..0000000000 --- a/labs/iam/src/test/resources/get_user.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - /division_abc/subdivision_xyz/ - Bob - AIDACKCEVSQ6C2EXAMPLE - - arn:aws:iam::123456789012:user/division_abc/subdivision_xyz/Bob - - 2009-03-06T21:47:48Z - - - - 7a62c49f-347e-4fc4-9331-6e8eEXAMPLE - - \ No newline at end of file diff --git a/labs/iam/src/test/resources/list_instance_profiles.xml b/labs/iam/src/test/resources/list_instance_profiles.xml deleted file mode 100644 index 9477982faf..0000000000 --- a/labs/iam/src/test/resources/list_instance_profiles.xml +++ /dev/null @@ -1,37 +0,0 @@ - - - false - - - AIPACIFN4OZXG7EXAMPLE - - - /application_abc/component_xyz/ - arn:aws:iam::123456789012:role/application_abc/component_xyz/S3Access - S3Access - {"Version":"2008-10-17","Statement":[{"Effect":"Allow","Principal":{"Service":["ec2.amazonaws.com"]},"Action":["sts:AssumeRole"]}]} - - 2012-05-09T15:45:35Z - AROACVYKSVTSZFEXAMPLE - - - Database - /application_abc/component_xyz/ - arn:aws:iam::123456789012:instance-profile/application_abc/component_xyz/Database - 2012-05-09T16:27:03Z - - - AIPACZLSXM2EYYEXAMPLE - - Webserver - /application_abc/component_xyz/ - arn:aws:iam::123456789012:instance-profile/application_abc/component_xyz/Webserver - 2012-05-09T16:27:11Z - - - - - fd74fa8d-99f3-11e1-a4c3-27EXAMPLE804 - - \ No newline at end of file diff --git a/labs/iam/src/test/resources/list_instance_profiles_marker.xml b/labs/iam/src/test/resources/list_instance_profiles_marker.xml deleted file mode 100644 index c300affea5..0000000000 --- a/labs/iam/src/test/resources/list_instance_profiles_marker.xml +++ /dev/null @@ -1,39 +0,0 @@ - - - false - - - AIPACIFN4OZXG7EXAMPLE - - - /application_abc/component_xyz/ - arn:aws:iam::123456789012:role/application_abc/component_xyz/S3Access - S3Access - {"Version":"2008-10-17","Statement":[{"Effect":"Allow","Principal":{"Service":["ec2.amazonaws.com"]},"Action":["sts:AssumeRole"]}]} - - 2012-05-09T15:45:35Z - AROACVYKSVTSZFEXAMPLE - - - Database - /application_abc/component_xyz/ - arn:aws:iam::123456789012:instance-profile/application_abc/component_xyz/Database - 2012-05-09T16:27:03Z - - - AIPACZLSXM2EYYEXAMPLE - - Webserver - /application_abc/component_xyz/ - arn:aws:iam::123456789012:instance-profile/application_abc/component_xyz/Webserver - 2012-05-09T16:27:11Z - - - MARKER - false - - - fd74fa8d-99f3-11e1-a4c3-27EXAMPLE804 - - diff --git a/labs/iam/src/test/resources/list_role_policies.xml b/labs/iam/src/test/resources/list_role_policies.xml deleted file mode 100644 index 3605cdf46b..0000000000 --- a/labs/iam/src/test/resources/list_role_policies.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - CloudwatchPutMetricPolicy - S3AccessPolicy - - false - - - 8c7e1816-99f0-11e1-a4c3-27EXAMPLE804 - - \ No newline at end of file diff --git a/labs/iam/src/test/resources/list_role_policies_marker.xml b/labs/iam/src/test/resources/list_role_policies_marker.xml deleted file mode 100644 index cb8ee22c5e..0000000000 --- a/labs/iam/src/test/resources/list_role_policies_marker.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - CloudwatchPutMetricPolicy - S3AccessPolicy - - MARKER - false - - - 8c7e1816-99f0-11e1-a4c3-27EXAMPLE804 - - \ No newline at end of file diff --git a/labs/iam/src/test/resources/list_roles.xml b/labs/iam/src/test/resources/list_roles.xml deleted file mode 100644 index e641d3a754..0000000000 --- a/labs/iam/src/test/resources/list_roles.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - / - arn:aws:iam::993194456877:role/foobie - foobie - %7B%22Version%22%3A%222008-10-17%22%2C%22Statement%22%3A%5B%7B%22Sid%22%3A%22%22%2C%22Effect%22%3A%22Allow%22%2C%22Principal%22%3A%7B%22Service%22%3A%22ec2.amazonaws.com%22%7D%2C%22Action%22%3A%22sts%3AAssumeRole%22%7D%5D%7D - - 2013-02-25T01:51:35Z - AROAIBFDQ5TQHEMPBEUE4 - - - / - arn:aws:iam::993194456877:role/s3-read-only - s3-read-only - %7B%22Version%22%3A%222008-10-17%22%2C%22Statement%22%3A%5B%7B%22Sid%22%3A%22%22%2C%22Effect%22%3A%22Allow%22%2C%22Principal%22%3A%7B%22Service%22%3A%22ec2.amazonaws.com%22%7D%2C%22Action%22%3A%22sts%3AAssumeRole%22%7D%5D%7D - - 2013-02-25T01:48:59Z - AROAJZ7NAM67BRSDAJ6PA - - - false - - - 7a62c49f-347e-4fc4-9331-6e8eEXAMPLE - - \ No newline at end of file diff --git a/labs/iam/src/test/resources/list_roles_marker.xml b/labs/iam/src/test/resources/list_roles_marker.xml deleted file mode 100644 index f2b7fdd46e..0000000000 --- a/labs/iam/src/test/resources/list_roles_marker.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - / - arn:aws:iam::993194456877:role/foobie - foobie - %7B%22Version%22%3A%222008-10-17%22%2C%22Statement%22%3A%5B%7B%22Sid%22%3A%22%22%2C%22Effect%22%3A%22Allow%22%2C%22Principal%22%3A%7B%22Service%22%3A%22ec2.amazonaws.com%22%7D%2C%22Action%22%3A%22sts%3AAssumeRole%22%7D%5D%7D - - 2013-02-25T01:51:35Z - AROAIBFDQ5TQHEMPBEUE4 - - - / - arn:aws:iam::993194456877:role/s3-read-only - s3-read-only - %7B%22Version%22%3A%222008-10-17%22%2C%22Statement%22%3A%5B%7B%22Sid%22%3A%22%22%2C%22Effect%22%3A%22Allow%22%2C%22Principal%22%3A%7B%22Service%22%3A%22ec2.amazonaws.com%22%7D%2C%22Action%22%3A%22sts%3AAssumeRole%22%7D%5D%7D - - 2013-02-25T01:48:59Z - AROAJZ7NAM67BRSDAJ6PA - - - MARKER - false - - - 7a62c49f-347e-4fc4-9331-6e8eEXAMPLE - - \ No newline at end of file diff --git a/labs/iam/src/test/resources/list_users.xml b/labs/iam/src/test/resources/list_users.xml deleted file mode 100644 index a5e36af2d0..0000000000 --- a/labs/iam/src/test/resources/list_users.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - /division_abc/subdivision_xyz/engineering/ - Andrew - AID2MAB8DPLSRHEXAMPLE - arn:aws:iam::123456789012:user/division_abc/subdivision_xyz/engineering/Andrew - 2009-03-06T21:47:48Z - - - /division_abc/subdivision_xyz/engineering/ - Jackie - AIDIODR4TAW7CSEXAMPLE - arn:aws:iam::123456789012:user/division_abc/subdivision_xyz/engineering/Jackie - 2009-03-06T21:47:48Z - - - false - - - 7a62c49f-347e-4fc4-9331-6e8eEXAMPLE - - \ No newline at end of file diff --git a/labs/iam/src/test/resources/list_users_marker.xml b/labs/iam/src/test/resources/list_users_marker.xml deleted file mode 100644 index 3233ad25e5..0000000000 --- a/labs/iam/src/test/resources/list_users_marker.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - /division_abc/subdivision_xyz/engineering/ - Andrew - AID2MAB8DPLSRHEXAMPLE - arn:aws:iam::123456789012:user/division_abc/subdivision_xyz/engineering/Andrew - 2009-03-06T21:47:48Z - - - /division_abc/subdivision_xyz/engineering/ - Jackie - AIDIODR4TAW7CSEXAMPLE - arn:aws:iam::123456789012:user/division_abc/subdivision_xyz/engineering/Jackie - 2009-03-06T21:47:48Z - - - MARKER - false - - - 7a62c49f-347e-4fc4-9331-6e8eEXAMPLE - - \ No newline at end of file diff --git a/labs/iam/src/test/resources/logback.xml b/labs/iam/src/test/resources/logback.xml deleted file mode 100644 index 9679b2e03a..0000000000 --- a/labs/iam/src/test/resources/logback.xml +++ /dev/null @@ -1,38 +0,0 @@ - - - - target/test-data/jclouds.log - - - %d %-5p [%c] [%thread] %m%n - - - - - target/test-data/jclouds-wire.log - - - %d %-5p [%c] [%thread] %m%n - - - - - - - - - - - - - - - - - - - - - - - diff --git a/labs/iam/src/test/resources/put_role_policy.xml b/labs/iam/src/test/resources/put_role_policy.xml deleted file mode 100644 index 9a6aa55aa6..0000000000 --- a/labs/iam/src/test/resources/put_role_policy.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - 3a03c24e-7f1d-11e2-8529-1d90c00d4f52 - - \ No newline at end of file diff --git a/labs/jenkins/pom.xml b/labs/jenkins/pom.xml deleted file mode 100644 index f1775d7a38..0000000000 --- a/labs/jenkins/pom.xml +++ /dev/null @@ -1,109 +0,0 @@ - - - - 4.0.0 - - org.jclouds - jclouds-project - 1.7.0-SNAPSHOT - ../../project/pom.xml - - org.jclouds.labs - jenkins - jcloud jenkins api - jclouds components to access an implementation of Jenkins - bundle - - - http://localhost:8080 - 1.0 - 1.460 - ANONYMOUS - ANONYMOUS - - org.jclouds.jenkins.v1*;version="${project.version}" - - org.jclouds.rest.internal;version="${project.version}", - org.jclouds*;version="${project.version}", - * - - - - - - org.jclouds - jclouds-core - ${project.version} - - - org.jclouds - jclouds-core - ${project.version} - test-jar - test - - - org.jclouds.driver - jclouds-slf4j - ${project.version} - test - - - ch.qos.logback - logback-classic - test - - - - - - live - - - - org.apache.maven.plugins - maven-surefire-plugin - - - integration - integration-test - - test - - - - ${test.jenkins.endpoint} - ${test.jenkins.api-version} - ${test.jenkins.build-version} - ${test.jenkins.identity} - ${test.jenkins.credential} - - - - - - - - - - - diff --git a/labs/jenkins/src/main/java/org/jclouds/jenkins/v1/JenkinsApi.java b/labs/jenkins/src/main/java/org/jclouds/jenkins/v1/JenkinsApi.java deleted file mode 100644 index 21b2143c1f..0000000000 --- a/labs/jenkins/src/main/java/org/jclouds/jenkins/v1/JenkinsApi.java +++ /dev/null @@ -1,51 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.jenkins.v1; - -import org.jclouds.jenkins.v1.domain.Node; -import org.jclouds.jenkins.v1.features.ComputerApi; -import org.jclouds.jenkins.v1.features.JobApi; -import org.jclouds.rest.annotations.Delegate; - -/** - * Provides synchronous access to Jenkins. - *

- * - * @see JenkinsAsyncApi - * @see api doc - * @author Adrian Cole - */ -public interface JenkinsApi { - /** - * @return the master computer - */ - Node getMaster(); - - /** - * Provides synchronous access to Computer features. - */ - @Delegate - ComputerApi getComputerApi(); - - /** - * Provides synchronous access to Job features. - */ - @Delegate - JobApi getJobApi(); -} diff --git a/labs/jenkins/src/main/java/org/jclouds/jenkins/v1/JenkinsApiMetadata.java b/labs/jenkins/src/main/java/org/jclouds/jenkins/v1/JenkinsApiMetadata.java deleted file mode 100644 index c7729d14bd..0000000000 --- a/labs/jenkins/src/main/java/org/jclouds/jenkins/v1/JenkinsApiMetadata.java +++ /dev/null @@ -1,91 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.jenkins.v1; - -import java.net.URI; -import java.util.Properties; - -import org.jclouds.apis.ApiMetadata; -import org.jclouds.jenkins.v1.config.JenkinsRestClientModule; -import org.jclouds.rest.RestContext; -import org.jclouds.rest.internal.BaseRestApiMetadata; - -import com.google.common.collect.ImmutableSet; -import com.google.common.reflect.TypeToken; -import com.google.inject.Module; - -/** - * Implementation of {@link ApiMetadata} for Jenkins 1.0 API - * - * @author Adrian Cole - */ -public class JenkinsApiMetadata extends BaseRestApiMetadata { - - public static final String ANONYMOUS_IDENTITY = "ANONYMOUS"; - - public static final TypeToken> CONTEXT_TOKEN = new TypeToken>() { - private static final long serialVersionUID = 1L; - }; - - @Override - public Builder toBuilder() { - return new Builder().fromApiMetadata(this); - } - - public JenkinsApiMetadata() { - this(new Builder()); - } - - protected JenkinsApiMetadata(Builder builder) { - super(builder); - } - - public static Properties defaultProperties() { - Properties properties = BaseRestApiMetadata.defaultProperties(); - return properties; - } - - public static class Builder extends BaseRestApiMetadata.Builder { - - protected Builder() { - super(JenkinsApi.class, JenkinsAsyncApi.class); - id("jenkins") - .name("Jenkins API") - .identityName("Username (or " + ANONYMOUS_IDENTITY + " if anonymous)") - .defaultIdentity(ANONYMOUS_IDENTITY) - .credentialName("Password") - .defaultCredential(ANONYMOUS_IDENTITY) - .documentation(URI.create("https://wiki.jenkins-ci.org/display/JENKINS/Remote+access+API")) - .version("1.0") - .defaultEndpoint("http://localhost:8080") - .defaultProperties(JenkinsApiMetadata.defaultProperties()) - .defaultModules(ImmutableSet.>of(JenkinsRestClientModule.class)); - } - - @Override - public JenkinsApiMetadata build() { - return new JenkinsApiMetadata(this); - } - - @Override - protected Builder self() { - return this; - } - } -} diff --git a/labs/jenkins/src/main/java/org/jclouds/jenkins/v1/JenkinsAsyncApi.java b/labs/jenkins/src/main/java/org/jclouds/jenkins/v1/JenkinsAsyncApi.java deleted file mode 100644 index d097195d43..0000000000 --- a/labs/jenkins/src/main/java/org/jclouds/jenkins/v1/JenkinsAsyncApi.java +++ /dev/null @@ -1,70 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.jenkins.v1; - -import javax.inject.Named; -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.core.MediaType; - -import org.jclouds.Fallbacks.NullOnNotFoundOr404; -import org.jclouds.jenkins.v1.domain.Node; -import org.jclouds.jenkins.v1.features.ComputerAsyncApi; -import org.jclouds.jenkins.v1.features.JobAsyncApi; -import org.jclouds.jenkins.v1.filters.BasicAuthenticationUnlessAnonymous; -import org.jclouds.rest.annotations.Delegate; -import org.jclouds.rest.annotations.Fallback; -import org.jclouds.rest.annotations.RequestFilters; - -import com.google.common.util.concurrent.ListenableFuture; - -/** - * Provides asynchronous access to Jenkins via their REST API. - *

- * - * @see JenkinsApi - * @see api doc - * @author Adrian Cole - */ -@RequestFilters(BasicAuthenticationUnlessAnonymous.class) -public interface JenkinsAsyncApi { - - /** - * @see JenkinsApi#getMaster - */ - @Named("GetMaster") - @GET - @Path("/api/json") - @Consumes(MediaType.APPLICATION_JSON) - @Fallback(NullOnNotFoundOr404.class) - ListenableFuture getMaster(); - - /** - * Provides asynchronous access to Computer features. - */ - @Delegate - ComputerAsyncApi getComputerApi(); - - /** - * Provides asynchronous access to Job features. - */ - @Delegate - JobAsyncApi getJobApi(); -} diff --git a/labs/jenkins/src/main/java/org/jclouds/jenkins/v1/JenkinsFallbacks.java b/labs/jenkins/src/main/java/org/jclouds/jenkins/v1/JenkinsFallbacks.java deleted file mode 100644 index 54a6033311..0000000000 --- a/labs/jenkins/src/main/java/org/jclouds/jenkins/v1/JenkinsFallbacks.java +++ /dev/null @@ -1,56 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.jenkins.v1; - -import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.base.Predicates.equalTo; -import static com.google.common.base.Throwables.propagate; -import static com.google.common.util.concurrent.Futures.immediateFuture; -import static org.jclouds.http.HttpUtils.returnValueOnCodeOrNull; - -import org.jclouds.Fallback; - -import com.google.common.base.Predicates; -import com.google.common.util.concurrent.ListenableFuture; - -/** - * - * @author Adrian Cole - */ -public final class JenkinsFallbacks { - private JenkinsFallbacks() { - } - - public static final class VoidOn302Or404 implements Fallback { - @Override - public ListenableFuture create(Throwable t) throws Exception { - return immediateFuture(createOrPropagate(t)); - } - - @Override - public Void createOrPropagate(Throwable t) throws Exception { - Boolean returnVal = returnValueOnCodeOrNull(checkNotNull(t, "throwable"), true, - Predicates. or(equalTo(302), equalTo(404))); - if (returnVal != null && returnVal) - return null; - throw propagate(t); - } - - } -} diff --git a/labs/jenkins/src/main/java/org/jclouds/jenkins/v1/binders/BindMapToOptionalParams.java b/labs/jenkins/src/main/java/org/jclouds/jenkins/v1/binders/BindMapToOptionalParams.java deleted file mode 100644 index 9b788056fb..0000000000 --- a/labs/jenkins/src/main/java/org/jclouds/jenkins/v1/binders/BindMapToOptionalParams.java +++ /dev/null @@ -1,46 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.jenkins.v1.binders; - -import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.Map; - -import org.jclouds.http.HttpRequest; -import org.jclouds.rest.Binder; - -import com.google.common.collect.Multimaps; - -/** - * Binds the map to parameters. - * - * @author Andrea Turli - */ -public class BindMapToOptionalParams implements Binder { - - @SuppressWarnings("unchecked") - @Override - public R bindToRequest(R request, Object input) { - checkArgument(checkNotNull(input, "input") instanceof Map, "this binder is only valid for Maps!"); - Map map = (Map) input; - return (R) request.toBuilder().replaceQueryParams(Multimaps.forMap(map)).build(); - } - -} diff --git a/labs/jenkins/src/main/java/org/jclouds/jenkins/v1/config/JenkinsProperties.java b/labs/jenkins/src/main/java/org/jclouds/jenkins/v1/config/JenkinsProperties.java deleted file mode 100644 index 473db99e68..0000000000 --- a/labs/jenkins/src/main/java/org/jclouds/jenkins/v1/config/JenkinsProperties.java +++ /dev/null @@ -1,28 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.jenkins.v1.config; - -/** - * Configuration properties and constants used in Jenkins connections. - * - * @author Adrian Cole - */ -public class JenkinsProperties { - -} diff --git a/labs/jenkins/src/main/java/org/jclouds/jenkins/v1/config/JenkinsRestClientModule.java b/labs/jenkins/src/main/java/org/jclouds/jenkins/v1/config/JenkinsRestClientModule.java deleted file mode 100644 index 61c47b25db..0000000000 --- a/labs/jenkins/src/main/java/org/jclouds/jenkins/v1/config/JenkinsRestClientModule.java +++ /dev/null @@ -1,62 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.jenkins.v1.config; - -import java.util.Map; - -import org.jclouds.http.HttpErrorHandler; -import org.jclouds.http.annotation.ClientError; -import org.jclouds.http.annotation.Redirection; -import org.jclouds.http.annotation.ServerError; -import org.jclouds.jenkins.v1.JenkinsAsyncApi; -import org.jclouds.jenkins.v1.JenkinsApi; -import org.jclouds.jenkins.v1.features.ComputerAsyncApi; -import org.jclouds.jenkins.v1.features.ComputerApi; -import org.jclouds.jenkins.v1.features.JobAsyncApi; -import org.jclouds.jenkins.v1.features.JobApi; -import org.jclouds.jenkins.v1.handlers.JenkinsErrorHandler; -import org.jclouds.rest.ConfiguresRestClient; -import org.jclouds.rest.config.RestClientModule; - -import com.google.common.collect.ImmutableMap; - -/** - * Configures the Jenkins connection. - * - * @author Adrian Cole - */ -@ConfiguresRestClient -public class JenkinsRestClientModule extends RestClientModule { - - public static final Map, Class> DELEGATE_MAP = ImmutableMap., Class> builder() - .put(ComputerApi.class, ComputerAsyncApi.class) - .put(JobApi.class, JobAsyncApi.class) - .build(); - - public JenkinsRestClientModule() { - super(DELEGATE_MAP); - } - - @Override - protected void bindErrorHandlers() { - bind(HttpErrorHandler.class).annotatedWith(Redirection.class).to(JenkinsErrorHandler.class); - bind(HttpErrorHandler.class).annotatedWith(ClientError.class).to(JenkinsErrorHandler.class); - bind(HttpErrorHandler.class).annotatedWith(ServerError.class).to(JenkinsErrorHandler.class); - } -} diff --git a/labs/jenkins/src/main/java/org/jclouds/jenkins/v1/domain/Computer.java b/labs/jenkins/src/main/java/org/jclouds/jenkins/v1/domain/Computer.java deleted file mode 100644 index 065adde340..0000000000 --- a/labs/jenkins/src/main/java/org/jclouds/jenkins/v1/domain/Computer.java +++ /dev/null @@ -1,134 +0,0 @@ -package org.jclouds.jenkins.v1.domain; - -import static com.google.common.base.Objects.equal; -import static com.google.common.base.Objects.toStringHelper; -import static com.google.common.base.Preconditions.checkNotNull; - -import com.google.common.base.Objects; -import com.google.common.base.Objects.ToStringHelper; - -/** - * @author Adrian Cole - * @see api - * doc - */ -public class Computer implements Comparable { - - public static Builder builder() { - return new Builder(); - } - - public Builder toBuilder() { - return builder().fromComputerMetadata(this); - } - - public static class Builder { - protected String displayName; - protected boolean idle; - protected boolean offline; - - /** - * @see Computer#getDisplayName() - */ - public Builder displayName(String displayName) { - this.displayName = checkNotNull(displayName, "displayName"); - return this; - } - - /** - * @see Computer#isIdle() - */ - public Builder idle(boolean idle) { - this.idle = idle; - return this; - } - - /** - * @see Computer#isOffline() - */ - public Builder offline(boolean offline) { - this.offline = offline; - return this; - } - - public Computer build() { - return new Computer(displayName, idle, offline); - } - - public Builder fromComputerMetadata(Computer from) { - return displayName(from.getDisplayName()).idle(from.isIdle()).offline(from.isOffline()); - } - } - - protected final String displayName; - protected final boolean idle; - protected final boolean offline; - - public Computer(String displayName, boolean idle, boolean offline) { - this.displayName = checkNotNull(displayName, "displayName"); - this.idle = idle; - this.offline = offline; - } - - /** - * - * @return the displayName of the computer - */ - public String getDisplayName() { - return displayName; - } - - /** - * - * @return the number of objects in the computer - */ - public boolean isIdle() { - return idle; - } - - /** - * @return the total offline stored in this computer - */ - public boolean isOffline() { - return offline; - } - - @Override - public boolean equals(Object object) { - if (this == object) { - return true; - } - if (object instanceof Computer) { - final Computer other = Computer.class.cast(object); - return equal(getDisplayName(), other.getDisplayName()) && equal(isIdle(), other.isIdle()) - && equal(isOffline(), other.isOffline()); - } else { - return false; - } - } - - @Override - public int hashCode() { - return Objects.hashCode(getDisplayName(), isIdle(), isOffline()); - } - - @Override - public String toString() { - return string().toString(); - } - - protected ToStringHelper string() { - return toStringHelper("").add("displayName", getDisplayName()).add("idle", isIdle()).add("offline", isOffline()); - } - - @Override - public int compareTo(Computer that) { - if (that == null) - return 1; - if (this == that) - return 0; - return this.getDisplayName().compareTo(that.getDisplayName()); - } - -} diff --git a/labs/jenkins/src/main/java/org/jclouds/jenkins/v1/domain/ComputerView.java b/labs/jenkins/src/main/java/org/jclouds/jenkins/v1/domain/ComputerView.java deleted file mode 100644 index 3c505f7c27..0000000000 --- a/labs/jenkins/src/main/java/org/jclouds/jenkins/v1/domain/ComputerView.java +++ /dev/null @@ -1,168 +0,0 @@ -package org.jclouds.jenkins.v1.domain; - -import static com.google.common.base.Objects.equal; -import static com.google.common.base.Objects.toStringHelper; -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.Set; - -import com.google.common.base.Objects; -import com.google.common.base.Objects.ToStringHelper; -import com.google.common.collect.ImmutableSet; -import com.google.gson.annotations.SerializedName; - -/** - * @author Adrian Cole - * @see api - * doc - */ -public class ComputerView implements Comparable { - - public static Builder builder() { - return new Builder(); - } - - public Builder toBuilder() { - return builder().fromComputerMetadata(this); - } - - public static class Builder { - protected String displayName; - protected int busyExecutors; - protected int totalExecutors; - protected Set computers = ImmutableSet.of(); - - /** - * @see ComputerView#getDisplayName() - */ - public Builder displayName(String displayName) { - this.displayName = checkNotNull(displayName, "displayName"); - return this; - } - - /** - * @see ComputerView#getBusyExecutors() - */ - public Builder busyExecutors(int busyExecutors) { - this.busyExecutors = busyExecutors; - return this; - } - - /** - * @see ComputerView#getTotalExecutors() - */ - public Builder totalExecutors(int totalExecutors) { - this.totalExecutors = totalExecutors; - return this; - } - - /** - * @see ComputerView#getLinks() - */ - public Builder computers(Computer... computers) { - return computers(ImmutableSet.copyOf(checkNotNull(computers, "computers"))); - } - - /** - * @see ComputerView#getLinks() - */ - public Builder computers(Set computers) { - this.computers = ImmutableSet.copyOf(checkNotNull(computers, "computers")); - return this; - } - - public ComputerView build() { - return new ComputerView(displayName, busyExecutors, totalExecutors, computers); - } - - public Builder fromComputerMetadata(ComputerView from) { - return displayName(from.getDisplayName()).busyExecutors(from.getBusyExecutors()).totalExecutors(from.getTotalExecutors()).computers(from.getComputers()); - } - } - - protected final String displayName; - protected final int busyExecutors; - protected final int totalExecutors; - @SerializedName("computer") - protected final Set computers; - - public ComputerView(String displayName, int busyExecutors, int totalExecutors, Set computers) { - this.displayName = checkNotNull(displayName, "displayName"); - this.busyExecutors = busyExecutors; - this.totalExecutors = totalExecutors; - this.computers = ImmutableSet.copyOf(checkNotNull(computers, "computers")); - } - - /** - * - * @return the displayName of the computer - */ - public String getDisplayName() { - return displayName; - } - - /** - * - * @return the number of objects in the computer - */ - public int getBusyExecutors() { - return busyExecutors; - } - - /** - * @return the total totalExecutors stored in this computer - */ - public int getTotalExecutors() { - return totalExecutors; - } - - /** - * @return the computers in this set - */ - //TODO: create type adapter for gson that understands ForwardingSet so that we can implement the Set interface - public Set getComputers() { - return computers; - } - - @Override - public boolean equals(Object object) { - if (this == object) { - return true; - } - if (object instanceof ComputerView) { - final ComputerView other = ComputerView.class.cast(object); - return equal(getDisplayName(), other.getDisplayName()) && equal(getBusyExecutors(), other.getBusyExecutors()) - && equal(getTotalExecutors(), other.getTotalExecutors()) && equal(getComputers(), other.getComputers()); - } else { - return false; - } - } - - @Override - public int hashCode() { - return Objects.hashCode(getDisplayName(), getBusyExecutors(), getTotalExecutors(), getComputers()); - } - - @Override - public String toString() { - return string().toString(); - } - - protected ToStringHelper string() { - return toStringHelper("").add("displayName", getDisplayName()).add("busyExecutors", getBusyExecutors()).add( - "totalExecutors", getTotalExecutors()).add("computers", getComputers()); - } - - @Override - public int compareTo(ComputerView that) { - if (that == null) - return 1; - if (this == that) - return 0; - return this.getDisplayName().compareTo(that.getDisplayName()); - } - - - -} diff --git a/labs/jenkins/src/main/java/org/jclouds/jenkins/v1/domain/Job.java b/labs/jenkins/src/main/java/org/jclouds/jenkins/v1/domain/Job.java deleted file mode 100644 index 88b7c0c7e2..0000000000 --- a/labs/jenkins/src/main/java/org/jclouds/jenkins/v1/domain/Job.java +++ /dev/null @@ -1,157 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.jenkins.v1.domain; - -import static com.google.common.base.Objects.equal; -import static com.google.common.base.Preconditions.checkNotNull; - -import java.net.URI; - -import com.google.common.base.Objects; -import com.google.common.base.Objects.ToStringHelper; - -/** - * Minimal info about a Job - * - * @author Adrian Cole - */ -public class Job { - - public static Builder builder() { - return new ConcreteBuilder(); - } - - public Builder toBuilder() { - return builder().fromJob(this); - } - - private static class ConcreteBuilder extends Builder { - } - - public abstract static class Builder> { - private String name; - private URI url; - private String color; - - @SuppressWarnings("unchecked") - protected B self() { - return (B) this; - } - - /** - * @see Job#getName() - */ - public B name(String name) { - this.name = name; - return self(); - } - - /** - * @see Job#getUrl() - */ - public B url(URI url) { - this.url = url; - return self(); - } - - /** - * @see Job#getColor() - */ - public B color(String color) { - this.color = color; - return self(); - } - - public Job build() { - return new Job(this); - } - - protected B fromJob(Job in) { - return name(in.getName()).color(in.getColor()).url(in.getUrl()); - } - } - - private final String name; - private final String color; - private final URI url; - - protected Job(Builder builder) { - this.name = checkNotNull(builder.name, "name"); - this.color = checkNotNull(builder.color, "color"); - this.url = checkNotNull(builder.url, "url"); - } - - /** - * name of the job - */ - public String getName() { - return name; - } - - /** - * - * color of the job - */ - public String getColor() { - return color; - } - - /** - * - * url of the job - */ - public URI getUrl() { - return url; - } - - @Override - public boolean equals(Object o) { - if (this == o) - return true; - if (o == null || getClass() != o.getClass()) - return false; - Job that = Job.class.cast(o); - return equal(this.name, that.name) && equal(this.url, that.url) - && equal(this.color, that.color); - } - - public boolean clone(Object o) { - if (this == o) - return false; - if (o == null || getClass() != o.getClass()) - return false; - Job that = Job.class.cast(o); - return equal(this.color, that.color); - } - - @Override - public int hashCode() { - return Objects.hashCode(name, url, color); - } - - @Override - public String toString() { - return string().toString(); - } - - protected ToStringHelper string() { - return Objects.toStringHelper("").add("name", name).add("url", url).add("color", - color); - } -} diff --git a/labs/jenkins/src/main/java/org/jclouds/jenkins/v1/domain/JobDetails.java b/labs/jenkins/src/main/java/org/jclouds/jenkins/v1/domain/JobDetails.java deleted file mode 100644 index 09519baae2..0000000000 --- a/labs/jenkins/src/main/java/org/jclouds/jenkins/v1/domain/JobDetails.java +++ /dev/null @@ -1,62 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.jenkins.v1.domain; - -import com.google.common.base.Objects.ToStringHelper; - -/** - * - * @author Adrian Cole - */ -public class JobDetails extends Job { - - public static Builder builder() { - return new ConcreteBuilder(); - } - - @Override - public Builder toBuilder() { - return builder().fromJobDetails(this); - } - - public static class Builder> extends Job.Builder { - - @Override - public JobDetails build() { - return new JobDetails(this); - } - - public B fromJobDetails(JobDetails in) { - return fromJob(in); - } - } - - private static class ConcreteBuilder extends Builder { - } - - protected JobDetails(Builder builder) { - super(builder); - } - - @Override - public ToStringHelper string() { - return super.string(); // .add("field", field); - } - -} diff --git a/labs/jenkins/src/main/java/org/jclouds/jenkins/v1/domain/LastBuild.java b/labs/jenkins/src/main/java/org/jclouds/jenkins/v1/domain/LastBuild.java deleted file mode 100644 index cf66707db7..0000000000 --- a/labs/jenkins/src/main/java/org/jclouds/jenkins/v1/domain/LastBuild.java +++ /dev/null @@ -1,289 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.jenkins.v1.domain; - -import static com.google.common.base.Objects.equal; -import static com.google.common.base.Preconditions.checkNotNull; - -import java.net.URI; - -import com.google.common.base.Objects; -import com.google.common.base.Objects.ToStringHelper; - -/** - * Minimal info about a LastBuild - * - * GET http://host/job/project/lastBuild/api/json - * - * @author Andrea Turli - */ -public class LastBuild { - - public static Builder builder() { - return new ConcreteBuilder(); - } - - public Builder toBuilder() { - return builder().fromJob(this); - } - - private static class ConcreteBuilder extends Builder { - } - - public abstract static class Builder> { - private String id; - private URI url; - private String description; - private String building; - private String duration; - private String estimatedDuration; - private String fullDisplayName; - private String result; - private String timestamp; - - @SuppressWarnings("unchecked") - protected B self() { - return (B) this; - } - - /** - * @see LastBuild#getId() - */ - public B id(String id) { - this.id = id; - return self(); - } - - /** - * @see LastBuild#getUrl() - */ - public B url(URI url) { - this.url = url; - return self(); - } - - /** - * @see LastBuild#getDescription() - */ - public B description(String description) { - this.description = description; - return self(); - } - - /** - * @see LastBuild#getBuilding() - */ - public B building(String building) { - this.building = building; - return self(); - } - - /** - * @see LastBuild#getDuration() - */ - public B duration(String duration) { - this.duration = duration; - return self(); - } - - /** - * @see LastBuild#getEstimatedDuration() - */ - public B estimatedDuration(String estimatedDuration) { - this.estimatedDuration = estimatedDuration; - return self(); - } - - /** - * @see LastBuild#getFullDisplayName() - */ - public B fullDisplayName(String fullDisplayName) { - this.fullDisplayName = fullDisplayName; - return self(); - } - - /** - * @see LastBuild#getResult() - */ - public B result(String result) { - this.result = result; - return self(); - } - - /** - * @see LastBuild#getTimestamp() - */ - public B timestamp(String timestamp) { - this.timestamp = timestamp; - return self(); - } - - public LastBuild build() { - return new LastBuild(this); - } - - protected B fromJob(LastBuild in) { - return id(in.getId()).url(in.getUrl()).description(in.getDescription()).building(in.getBuilding()) - .duration(in.getDuration()).estimatedDuration(in.getEstimatedDuration()) - .fullDisplayName(in.getFullDisplayName()).result(in.getResult()).timestamp(in.getTimestamp()); - } - } - - private final String id; - private final URI url; - private final String description; - private final String building; - private final String duration; - private final String estimatedDuration; - private final String fullDisplayName; - private final String result; - private final String timestamp; - - protected LastBuild(Builder builder) { - this.id = checkNotNull(builder.id, "id"); - this.url = checkNotNull(builder.url, "url"); - this.description = checkNotNull(builder.description, "description"); - this.building = checkNotNull(builder.building, "building"); - this.duration = checkNotNull(builder.duration, "duration"); - this.estimatedDuration = checkNotNull(builder.estimatedDuration, "estimatedDuration"); - this.fullDisplayName = checkNotNull(builder.fullDisplayName, "fullDisplayName"); - this.result = checkNotNull(builder.result, "result"); - this.timestamp = checkNotNull(builder.timestamp, "timestamp"); - } - - /** - * id of the lastBuild - */ - public String getId() { - return id; - } - - /** - * - * url of the lastBuild - */ - public URI getUrl() { - return url; - } - - /** - * - * building of the lastBuild - */ - public String getBuilding() { - return building; - } - - /** - * - * description of the lastBuild - */ - public String getDescription() { - return description; - } - - /** - * - * duration of the lastBuild - */ - public String getDuration() { - return duration; - } - - /** - * - * estimated duration of the lastBuild - */ - public String getEstimatedDuration() { - return estimatedDuration; - } - - /** - * - * full Display Name of the lastBuild - */ - public String getFullDisplayName() { - return fullDisplayName; - } - - /** - * - * result of the lastBuild - */ - public String getResult() { - return result; - } - - /** - * - * timestamp of the lastBuild - */ - public String getTimestamp() { - return timestamp; - } - - @Override - public boolean equals(Object o) { - if (this == o) - return true; - if (o == null || getClass() != o.getClass()) - return false; - LastBuild that = LastBuild.class.cast(o); - return equal(this.id, that.id) - && equal(this.url, that.url) - && equal(this.building, that.building) - && equal(this.description, that.description) - && equal(this.duration, that.duration) - && equal(this.estimatedDuration, that.estimatedDuration) - && equal(this.fullDisplayName, that.fullDisplayName) - && equal(this.result, that.result) - && equal(this.timestamp, that.timestamp); - } - - public boolean clone(Object o) { - if (this == o) - return false; - if (o == null || getClass() != o.getClass()) - return false; - LastBuild that = LastBuild.class.cast(o); - return equal(this.description, that.description); - } - - @Override - public int hashCode() { - return Objects.hashCode(id, url, description, duration, estimatedDuration, fullDisplayName, result, timestamp); - } - - @Override - public String toString() { - return string().toString(); - } - - protected ToStringHelper string() { - return Objects.toStringHelper("") - .add("id", id) - .add("url", url) - .add("description", description) - .add("duration", duration) - .add("estimatedDuration", estimatedDuration) - .add("fullDisplayName", fullDisplayName) - .add("result", result) - .add("timestamp", timestamp); - } -} diff --git a/labs/jenkins/src/main/java/org/jclouds/jenkins/v1/domain/Node.java b/labs/jenkins/src/main/java/org/jclouds/jenkins/v1/domain/Node.java deleted file mode 100644 index ab4f15cd6c..0000000000 --- a/labs/jenkins/src/main/java/org/jclouds/jenkins/v1/domain/Node.java +++ /dev/null @@ -1,147 +0,0 @@ -package org.jclouds.jenkins.v1.domain; - -import static com.google.common.base.Objects.equal; -import static com.google.common.base.Objects.toStringHelper; -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.Set; - -import com.google.common.base.Objects; -import com.google.common.base.Objects.ToStringHelper; -import com.google.common.collect.ImmutableSet; -import com.google.gson.annotations.SerializedName; - -/** - * @author Adrian Cole - * @see api - * doc - */ -public class Node implements Comparable { - - public static Builder builder() { - return new Builder(); - } - - public Builder toBuilder() { - return builder().fromNodeMetadata(this); - } - - public static class Builder { - protected String name; - protected String description; - protected Set jobs = ImmutableSet.of(); - - /** - * @see Node#getName() - */ - public Builder name(String name) { - this.name = checkNotNull(name, "name"); - return this; - } - - /** - * @see Node#getDescription() - */ - public Builder description(String description) { - this.description = description; - return this; - } - - /** - * @see Node#getJobs() - */ - public Builder jobs(Job... jobs) { - return jobs(ImmutableSet.copyOf(checkNotNull(jobs, "jobs"))); - } - - /** - * @see Node#getJobs() - */ - public Builder jobs(Set jobs) { - this.jobs = ImmutableSet.copyOf(checkNotNull(jobs, "jobs")); - return this; - } - - public Node build() { - return new Node(name, description, jobs); - } - - public Builder fromNodeMetadata(Node from) { - return name(from.getName()).description(from.getDescription()).jobs(from.getJobs()); - } - } - - @SerializedName("nodeName") - protected final String name; - @SerializedName("nodeDescription") - protected final String description; - protected final Set jobs; - - public Node(String name, String description, Set jobs) { - this.name = checkNotNull(name, "name"); - this.description = description; - this.jobs = ImmutableSet.copyOf(checkNotNull(jobs, "jobs")); - } - - /** - * - * @return the name of the node - */ - public String getName() { - return name; - } - - /** - * - * @return the description of the node - */ - public String getDescription() { - return description; - } - - /** - * @return the jobs on this node - */ - public Set getJobs() { - return jobs; - } - - @Override - public boolean equals(Object object) { - if (this == object) { - return true; - } - if (object instanceof Node) { - final Node other = Node.class.cast(object); - return equal(getName(), other.getName()) && equal(getDescription(), other.getDescription()) - && equal(getJobs(), other.getJobs()); - } else { - return false; - } - } - - @Override - public int hashCode() { - return Objects.hashCode(getName(), getDescription(), getJobs()); - } - - @Override - public String toString() { - return string().toString(); - } - - protected ToStringHelper string() { - return toStringHelper("").add("name", getName()).add("description", getDescription()).add("jobs", getJobs()); - } - - @Override - public int compareTo(Node that) { - if (that == null) - return 1; - if (this == that) - return 0; - return this.getName().compareTo(that.getName()); - } - -} diff --git a/labs/jenkins/src/main/java/org/jclouds/jenkins/v1/features/ComputerApi.java b/labs/jenkins/src/main/java/org/jclouds/jenkins/v1/features/ComputerApi.java deleted file mode 100644 index 494c60f2d1..0000000000 --- a/labs/jenkins/src/main/java/org/jclouds/jenkins/v1/features/ComputerApi.java +++ /dev/null @@ -1,45 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.jenkins.v1.features; - -import org.jclouds.jenkins.v1.domain.Computer; -import org.jclouds.jenkins.v1.domain.ComputerView; - -/** - * Computer Services - * - * @see ComputerAsyncApi - * @author Adrian Cole - * @see api doc - */ -public interface ComputerApi { - - /** - * @return overview of all configured computers - */ - ComputerView getView(); - - /** - * - * @param displayName display name of the computer - * @return computer or null if not found - */ - Computer get(String displayName); - -} diff --git a/labs/jenkins/src/main/java/org/jclouds/jenkins/v1/features/ComputerAsyncApi.java b/labs/jenkins/src/main/java/org/jclouds/jenkins/v1/features/ComputerAsyncApi.java deleted file mode 100644 index 81607f74b9..0000000000 --- a/labs/jenkins/src/main/java/org/jclouds/jenkins/v1/features/ComputerAsyncApi.java +++ /dev/null @@ -1,68 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.jenkins.v1.features; - -import javax.inject.Named; -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.core.MediaType; - -import org.jclouds.Fallbacks.NullOnNotFoundOr404; -import org.jclouds.jenkins.v1.domain.Computer; -import org.jclouds.jenkins.v1.domain.ComputerView; -import org.jclouds.jenkins.v1.filters.BasicAuthenticationUnlessAnonymous; -import org.jclouds.rest.annotations.Fallback; -import org.jclouds.rest.annotations.RequestFilters; - -import com.google.common.util.concurrent.ListenableFuture; - -/** - * Computer Services - * - * @see ComputerApi - * @author Adrian Cole - * @see api doc - */ -@RequestFilters(BasicAuthenticationUnlessAnonymous.class) -public interface ComputerAsyncApi { - - /** - * @see ComputerApi#getView - */ - @Named("ListComputers") - @GET - @Path("/computer/api/json") - @Consumes(MediaType.APPLICATION_JSON) - ListenableFuture getView(); - - /** - * @see ComputerApi#get - */ - @Named("GetComputer") - @GET - @Path("/computer/{displayName}/api/json") - @Consumes(MediaType.APPLICATION_JSON) - @Fallback(NullOnNotFoundOr404.class) - ListenableFuture get(@PathParam("displayName") String displayName); - -} diff --git a/labs/jenkins/src/main/java/org/jclouds/jenkins/v1/features/JobApi.java b/labs/jenkins/src/main/java/org/jclouds/jenkins/v1/features/JobApi.java deleted file mode 100644 index 59bf360c41..0000000000 --- a/labs/jenkins/src/main/java/org/jclouds/jenkins/v1/features/JobApi.java +++ /dev/null @@ -1,61 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.jenkins.v1.features; - -import java.util.Map; -import org.jclouds.jenkins.v1.domain.JobDetails; -import org.jclouds.jenkins.v1.domain.LastBuild; - -/** - * Job Services - * - * @see JobAsyncApi - * @author Adrian Cole - * @see api doc - */ -public interface JobApi { - - /** - * creates a job, given the payload - * - * @param displayName - * @param xml - */ - void createFromXML(String displayName, String xml); - - JobDetails get(String displayName); - - void delete(String displayName); - - /** - * Build a job via API - * - * If security is enabled, provide username/password of an account with build permission in the request. - * Another alternative (but deprecated) is to configure the 'Trigger builds remotely' section in the job configuration. - * - * @param displayName - */ - void build(String displayName); - - void buildWithParameters(String displayName, Map parameters); - - String fetchConfigXML(String displayName); - - LastBuild lastBuild(String displayName); -} diff --git a/labs/jenkins/src/main/java/org/jclouds/jenkins/v1/features/JobAsyncApi.java b/labs/jenkins/src/main/java/org/jclouds/jenkins/v1/features/JobAsyncApi.java deleted file mode 100644 index 4dd8ea15c9..0000000000 --- a/labs/jenkins/src/main/java/org/jclouds/jenkins/v1/features/JobAsyncApi.java +++ /dev/null @@ -1,121 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.jenkins.v1.features; - -import java.util.Map; - -import javax.inject.Named; -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.MediaType; - -import org.jclouds.Fallbacks.NullOnNotFoundOr404; -import org.jclouds.jenkins.v1.JenkinsFallbacks.VoidOn302Or404; -import org.jclouds.jenkins.v1.binders.BindMapToOptionalParams; -import org.jclouds.jenkins.v1.domain.JobDetails; -import org.jclouds.jenkins.v1.domain.LastBuild; -import org.jclouds.jenkins.v1.filters.BasicAuthenticationUnlessAnonymous; -import org.jclouds.rest.annotations.BinderParam; -import org.jclouds.rest.annotations.Fallback; -import org.jclouds.rest.annotations.RequestFilters; -import org.jclouds.rest.binders.BindToStringPayload; - -import com.google.common.util.concurrent.ListenableFuture; - -/** - * Job Services - * - * @see JobApi - * @author Adrian Cole - * @see api doc - */ -@RequestFilters(BasicAuthenticationUnlessAnonymous.class) -public interface JobAsyncApi { - - /** - * @see JobApi#createFromXML - */ - @Named("CreateItem") - @POST - @Path("/createItem") - @Produces(MediaType.TEXT_XML) - ListenableFuture createFromXML(@QueryParam("name") String displayName, @BinderParam(BindToStringPayload.class) String xml); - - /** - * @see JobApi#get - */ - @Named("GetJob") - @GET - @Path("/job/{displayName}/api/json") - @Consumes(MediaType.APPLICATION_JSON) - @Fallback(NullOnNotFoundOr404.class) - ListenableFuture get(@PathParam("displayName") String displayName); - - /** - * @see JobApi#delete - */ - @Named("DeleteJob") - @POST - @Path("/job/{displayName}/doDelete") - @Fallback(VoidOn302Or404.class) - ListenableFuture delete(@PathParam("displayName") String displayName); - - /** - * @see JobApi#buildJob - */ - @Named("Build") - @POST - @Path("/job/{displayName}/build") - @Fallback(NullOnNotFoundOr404.class) - ListenableFuture build(@PathParam("displayName") String displayName); - - /** - * @see JobApi#buildJobWithParameters - */ - @Named("BuildWithParameters") - @POST - @Path("/job/{displayName}/buildWithParameters") - @Fallback(NullOnNotFoundOr404.class) - ListenableFuture buildWithParameters(@PathParam("displayName") String displayName, - @BinderParam(BindMapToOptionalParams.class) Map parameters); - - /** - * @see JobApi#fetchConfigXML - */ - @Named("GetConfigXML") - @GET - @Path("/job/{displayName}/config.xml") - @Fallback(NullOnNotFoundOr404.class) - ListenableFuture fetchConfigXML(@PathParam("displayName") String displayName); - - /** - * @see JobApi#lastBuild - */ - @Named("GetLastBuild") - @GET - @Path("/job/{displayName}/lastBuild/api/json") - @Consumes(MediaType.APPLICATION_JSON) - @Fallback(NullOnNotFoundOr404.class) - ListenableFuture lastBuild(@PathParam("displayName") String displayName); -} diff --git a/labs/jenkins/src/main/java/org/jclouds/jenkins/v1/filters/BasicAuthenticationUnlessAnonymous.java b/labs/jenkins/src/main/java/org/jclouds/jenkins/v1/filters/BasicAuthenticationUnlessAnonymous.java deleted file mode 100644 index 9a9acd30bf..0000000000 --- a/labs/jenkins/src/main/java/org/jclouds/jenkins/v1/filters/BasicAuthenticationUnlessAnonymous.java +++ /dev/null @@ -1,58 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.jenkins.v1.filters; - -import static com.google.common.base.Preconditions.checkNotNull; -import static org.jclouds.jenkins.v1.JenkinsApiMetadata.ANONYMOUS_IDENTITY; - -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jclouds.domain.Credentials; -import org.jclouds.http.HttpException; -import org.jclouds.http.HttpRequest; -import org.jclouds.http.HttpRequestFilter; -import org.jclouds.http.filters.BasicAuthentication; -import org.jclouds.location.Provider; - -import com.google.common.base.Supplier; - -/** - * @author Adrian Cole - * - */ -@Singleton -public class BasicAuthenticationUnlessAnonymous implements HttpRequestFilter { - - private final Supplier creds; - private final BasicAuthentication auth; - - @Inject - public BasicAuthenticationUnlessAnonymous(@Provider Supplier creds, BasicAuthentication auth) { - this.creds = checkNotNull(creds, "creds"); - this.auth = checkNotNull(auth, "auth"); - } - - @Override - public HttpRequest filter(HttpRequest request) throws HttpException { - if (ANONYMOUS_IDENTITY.equals(checkNotNull(creds.get().identity, "user"))) - return request; - return auth.filter(request); - } -} diff --git a/labs/jenkins/src/main/java/org/jclouds/jenkins/v1/handlers/JenkinsErrorHandler.java b/labs/jenkins/src/main/java/org/jclouds/jenkins/v1/handlers/JenkinsErrorHandler.java deleted file mode 100644 index 3fa8b80ce0..0000000000 --- a/labs/jenkins/src/main/java/org/jclouds/jenkins/v1/handlers/JenkinsErrorHandler.java +++ /dev/null @@ -1,66 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.jenkins.v1.handlers; - -import static org.jclouds.http.HttpUtils.closeClientButKeepContentStream; - -import javax.inject.Singleton; - -import org.jclouds.http.HttpCommand; -import org.jclouds.http.HttpErrorHandler; -import org.jclouds.http.HttpResponse; -import org.jclouds.http.HttpResponseException; -import org.jclouds.rest.AuthorizationException; -import org.jclouds.rest.ResourceNotFoundException; - -/** - * This will parse and set an appropriate exception on the command object. - * - * @author Adrian Cole - * - */ -// TODO: is there error spec someplace? let's type errors, etc. -@Singleton -public class JenkinsErrorHandler implements HttpErrorHandler { - - public void handleError(HttpCommand command, HttpResponse response) { - // it is important to always read fully and close streams - byte[] data = closeClientButKeepContentStream(response); - String message = data != null ? new String(data) : null; - - Exception exception = message != null ? new HttpResponseException(command, response, message) - : new HttpResponseException(command, response); - message = message != null ? message : String.format("%s -> %s", command.getCurrentRequest().getRequestLine(), - response.getStatusLine()); - switch (response.getStatusCode()) { - case 400: - break; - case 401: - case 403: - exception = new AuthorizationException(message, exception); - break; - case 404: - if (!command.getCurrentRequest().getMethod().equals("DELETE")) { - exception = new ResourceNotFoundException(message, exception); - } - break; - } - command.setException(exception); - } -} diff --git a/labs/jenkins/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata b/labs/jenkins/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata deleted file mode 100644 index c80a7f32a8..0000000000 --- a/labs/jenkins/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata +++ /dev/null @@ -1 +0,0 @@ -org.jclouds.jenkins.v1.JenkinsApiMetadata diff --git a/labs/jenkins/src/test/java/org/jclouds/jenkins/v1/JenkinsApiExpectTest.java b/labs/jenkins/src/test/java/org/jclouds/jenkins/v1/JenkinsApiExpectTest.java deleted file mode 100644 index 5b5e3f6ca2..0000000000 --- a/labs/jenkins/src/test/java/org/jclouds/jenkins/v1/JenkinsApiExpectTest.java +++ /dev/null @@ -1,52 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.jenkins.v1; - -import static org.testng.Assert.assertEquals; - -import org.jclouds.http.HttpRequest; -import org.jclouds.http.HttpResponse; -import org.jclouds.jenkins.v1.internal.BaseJenkinsApiExpectTest; -import org.jclouds.jenkins.v1.parse.ParseNodeTest; -import org.testng.annotations.Test; - -/** - * - * @author Adrian Cole - */ -@Test(groups = "unit", testName = "JenkinsApiExpectTest") -public class JenkinsApiExpectTest extends BaseJenkinsApiExpectTest { - - public void testGetMasterWhenResponseIs2xx() { - HttpRequest getMaster = HttpRequest - .builder() - .method("GET") - .endpoint("http://localhost:8080/api/json") - .addHeader("Accept", "application/json") - .addHeader("Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==").build(); - - HttpResponse getMasterResponse = HttpResponse.builder().statusCode(200) - .payload(payloadFromResource("/master.json")).build(); - - JenkinsApi apiWhenMasterExists = requestSendsResponse(getMaster, getMasterResponse); - - assertEquals(apiWhenMasterExists.getMaster().toString(), - new ParseNodeTest().expected().toString()); - } -} diff --git a/labs/jenkins/src/test/java/org/jclouds/jenkins/v1/JenkinsApiLiveTest.java b/labs/jenkins/src/test/java/org/jclouds/jenkins/v1/JenkinsApiLiveTest.java deleted file mode 100644 index 903b0af2bb..0000000000 --- a/labs/jenkins/src/test/java/org/jclouds/jenkins/v1/JenkinsApiLiveTest.java +++ /dev/null @@ -1,41 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.jenkins.v1; - -import static org.testng.Assert.assertNotNull; - -import org.jclouds.jenkins.v1.domain.Node; -import org.jclouds.jenkins.v1.internal.BaseJenkinsApiLiveTest; -import org.testng.annotations.Test; - -/** - * - * @author Adrian Cole - */ -@Test(groups = "live", testName = "JenkinsApiLiveTest") -public class JenkinsApiLiveTest extends BaseJenkinsApiLiveTest { - - public void testGetMaster(){ - Node master = context.getApi().getMaster(); - assertNotNull(master); - assertNotNull(master.getName()); - assertNotNull(master.getJobs()); - } - -} diff --git a/labs/jenkins/src/test/java/org/jclouds/jenkins/v1/JenkinsApiMetadataTest.java b/labs/jenkins/src/test/java/org/jclouds/jenkins/v1/JenkinsApiMetadataTest.java deleted file mode 100644 index 707c42ea37..0000000000 --- a/labs/jenkins/src/test/java/org/jclouds/jenkins/v1/JenkinsApiMetadataTest.java +++ /dev/null @@ -1,37 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.jenkins.v1; - -import org.jclouds.View; -import org.jclouds.apis.internal.BaseApiMetadataTest; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableSet; -import com.google.common.reflect.TypeToken; - -/** - * - * @author Adrian Cole - */ -@Test(groups = "unit", testName = "JenkinsApiMetadataTest") -public class JenkinsApiMetadataTest extends BaseApiMetadataTest { - public JenkinsApiMetadataTest() { - super(new JenkinsApiMetadata(), ImmutableSet.> of()); - } -} diff --git a/labs/jenkins/src/test/java/org/jclouds/jenkins/v1/JenkinsErrorHandlerTest.java b/labs/jenkins/src/test/java/org/jclouds/jenkins/v1/JenkinsErrorHandlerTest.java deleted file mode 100644 index f6be30b25c..0000000000 --- a/labs/jenkins/src/test/java/org/jclouds/jenkins/v1/JenkinsErrorHandlerTest.java +++ /dev/null @@ -1,95 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.jenkins.v1; - -import static org.easymock.EasyMock.createMock; -import static org.easymock.EasyMock.expect; -import static org.easymock.EasyMock.replay; -import static org.easymock.EasyMock.reportMatcher; -import static org.easymock.EasyMock.verify; - -import java.net.URI; - -import org.easymock.IArgumentMatcher; -import org.jclouds.http.HttpCommand; -import org.jclouds.http.HttpRequest; -import org.jclouds.http.HttpResponse; -import org.jclouds.jenkins.v1.handlers.JenkinsErrorHandler; -import org.jclouds.rest.ResourceNotFoundException; -import org.testng.annotations.Test; - -/** - * - * @author Adrian Cole - */ -@Test(groups = "unit", testName = "JenkinsErrorHandlerTest") -public class JenkinsErrorHandlerTest { - - @Test - public void test404WithHTMLDoesntBustParserAndMakesResourceNotFoundException() { - assertCodeMakes("GET", URI - .create("http://ci.jruby.org/computer/master/api/json"), - 404, "Not Found", "", ResourceNotFoundException.class); - } - - private void assertCodeMakes(String method, URI uri, int statusCode, String message, String content, - Class expected) { - assertCodeMakes(method, uri, statusCode, message, "text/plain", content, expected); - } - - private void assertCodeMakes(String method, URI uri, int statusCode, String message, String contentType, - String content, Class expected) { - - JenkinsErrorHandler function = new JenkinsErrorHandler(); - - HttpCommand command = createMock(HttpCommand.class); - HttpRequest request = HttpRequest.builder().method(method).endpoint(uri).build(); - HttpResponse response = HttpResponse.builder().statusCode(statusCode).message(message).payload(content).build(); - response.getPayload().getContentMetadata().setContentType(contentType); - - expect(command.getCurrentRequest()).andReturn(request).atLeastOnce(); - command.setException(classEq(expected)); - - replay(command); - - function.handleError(command, response); - - verify(command); - } - - public static Exception classEq(final Class in) { - reportMatcher(new IArgumentMatcher() { - - @Override - public void appendTo(StringBuffer buffer) { - buffer.append("classEq("); - buffer.append(in); - buffer.append(")"); - } - - @Override - public boolean matches(Object arg) { - return arg.getClass() == in; - } - - }); - return null; - } - -} diff --git a/labs/jenkins/src/test/java/org/jclouds/jenkins/v1/features/ComputerApiExpectTest.java b/labs/jenkins/src/test/java/org/jclouds/jenkins/v1/features/ComputerApiExpectTest.java deleted file mode 100644 index b17eab014a..0000000000 --- a/labs/jenkins/src/test/java/org/jclouds/jenkins/v1/features/ComputerApiExpectTest.java +++ /dev/null @@ -1,71 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.jenkins.v1.features; - -import static org.testng.Assert.assertEquals; - -import org.jclouds.http.HttpRequest; -import org.jclouds.http.HttpResponse; -import org.jclouds.jenkins.v1.JenkinsApi; -import org.jclouds.jenkins.v1.internal.BaseJenkinsApiExpectTest; -import org.jclouds.jenkins.v1.parse.ParseComputerTest; -import org.jclouds.jenkins.v1.parse.ParseComputerViewTest; -import org.testng.annotations.Test; - -/** - * - * @author Adrian Cole - */ -@Test(groups = "unit", testName = "ComputerApiExpectTest") -public class ComputerApiExpectTest extends BaseJenkinsApiExpectTest { - - public void testGetComputerViewWhenResponseIs2xx() { - HttpRequest getComputerView = HttpRequest - .builder() - .method("GET") - .endpoint("http://localhost:8080/computer/api/json") - .addHeader("Accept", "application/json") - .addHeader("Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==").build(); - - HttpResponse getComputerViewResponse = HttpResponse.builder().statusCode(200) - .payload(payloadFromResource("/computerview.json")).build(); - - JenkinsApi apiWhenServersExist = requestSendsResponse(getComputerView, getComputerViewResponse); - - assertEquals(apiWhenServersExist.getComputerApi().getView().toString(), - new ParseComputerViewTest().expected().toString()); - } - - public void testGetComputerWhenResponseIs2xx() { - HttpRequest getComputer = HttpRequest - .builder() - .method("GET") - .endpoint("http://localhost:8080/computer/Ruboto/api/json") - .addHeader("Accept", "application/json") - .addHeader("Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==").build(); - - HttpResponse getComputerResponse = HttpResponse.builder().statusCode(200) - .payload(payloadFromResource("/computer.json")).build(); - - JenkinsApi apiWhenServersExist = requestSendsResponse(getComputer, getComputerResponse); - - assertEquals(apiWhenServersExist.getComputerApi().get("Ruboto").toString(), - new ParseComputerTest().expected().toString()); - } -} diff --git a/labs/jenkins/src/test/java/org/jclouds/jenkins/v1/features/ComputerApiLiveTest.java b/labs/jenkins/src/test/java/org/jclouds/jenkins/v1/features/ComputerApiLiveTest.java deleted file mode 100644 index 5d06f270c0..0000000000 --- a/labs/jenkins/src/test/java/org/jclouds/jenkins/v1/features/ComputerApiLiveTest.java +++ /dev/null @@ -1,52 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.jenkins.v1.features; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; - -import org.jclouds.jenkins.v1.domain.Computer; -import org.jclouds.jenkins.v1.domain.ComputerView; -import org.jclouds.jenkins.v1.internal.BaseJenkinsApiLiveTest; -import org.testng.annotations.Test; - -/** - * - * @author Adrian Cole - */ -@Test(groups = "live", testName = "ComputerApiLiveTest") -public class ComputerApiLiveTest extends BaseJenkinsApiLiveTest { - - public void testGetComputerView(){ - ComputerView view = getApi().getView(); - assertNotNull(view); - assertNotNull(view.getDisplayName()); - for (Computer computerFromView : view.getComputers()) { - assertNotNull(computerFromView.getDisplayName()); - if (!"master".equals(computerFromView.getDisplayName())) { - Computer computerFromGetRequest = getApi().get(computerFromView.getDisplayName()); - assertEquals(computerFromGetRequest, computerFromView); - } - } - } - - private ComputerApi getApi() { - return context.getApi().getComputerApi(); - } -} diff --git a/labs/jenkins/src/test/java/org/jclouds/jenkins/v1/features/JobApiExpectTest.java b/labs/jenkins/src/test/java/org/jclouds/jenkins/v1/features/JobApiExpectTest.java deleted file mode 100644 index cc5692b403..0000000000 --- a/labs/jenkins/src/test/java/org/jclouds/jenkins/v1/features/JobApiExpectTest.java +++ /dev/null @@ -1,166 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.jenkins.v1.features; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNull; - -import java.io.IOException; - -import org.jclouds.http.HttpRequest; -import org.jclouds.http.HttpResponse; -import org.jclouds.jenkins.v1.JenkinsApi; -import org.jclouds.jenkins.v1.internal.BaseJenkinsApiExpectTest; -import org.jclouds.jenkins.v1.parse.LastBuildTest; -import org.jclouds.jenkins.v1.parse.ParseJobDetailsTest; -import org.jclouds.util.Strings2; -import org.testng.annotations.Test; - -/** - * - * @author Adrian Cole - */ -@Test(groups = "unit", testName = "JobApiExpectTest") -public class JobApiExpectTest extends BaseJenkinsApiExpectTest { - - public void testCreateJobStringWhenResponseIs2xx() throws IOException { - HttpRequest createJob = HttpRequest.builder() - .method("POST") - .endpoint("http://localhost:8080/createItem?name=blagoo") - .addHeader("Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==") - .payload(payloadFromResourceWithContentType("/sample_job.xml", "text/xml")) - .build(); - - HttpResponse createJobResponse = HttpResponse.builder().statusCode(200).build(); - - JenkinsApi createJobWhenCreated = requestSendsResponse(createJob, createJobResponse); - - createJobWhenCreated.getJobApi().createFromXML("blagoo", Strings2.toStringAndClose(getClass().getResourceAsStream("/sample_job.xml"))); - } - - public void testDeleteJobWhenResponseIs2xx() { - HttpRequest deleteJob = HttpRequest.builder() - .method("POST") - .endpoint("http://localhost:8080/job/blagoo/doDelete") - .addHeader("Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==") - .build(); - - HttpResponse deleteJobResponse = HttpResponse.builder().statusCode(200).build(); - - JenkinsApi deleteJobWhenDeleted = requestSendsResponse(deleteJob, deleteJobResponse); - - deleteJobWhenDeleted.getJobApi().delete("blagoo"); - } - - public void testDeleteJobWhenResponseIs404() { - HttpRequest deleteJob = HttpRequest.builder() - .method("POST") - .endpoint("http://localhost:8080/job/blagoo/doDelete") - .addHeader("Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==") - .build(); - - HttpResponse deleteJobResponse = HttpResponse.builder().statusCode(404).build(); - - JenkinsApi deleteJobWhenDeleted = requestSendsResponse(deleteJob, deleteJobResponse); - - deleteJobWhenDeleted.getJobApi().delete("blagoo"); - } - - HttpRequest getJob = HttpRequest.builder() - .method("GET") - .endpoint("http://localhost:8080/job/ddd/api/json") - .addHeader("Accept", "application/json") - .addHeader("Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==") - .build(); - - public void testGetJobWhenResponseIs2xx() { - HttpResponse getJobResponse = HttpResponse.builder().statusCode(200) - .payload(payloadFromResource("/job.json")).build(); - JenkinsApi apiWhenJobExists = requestSendsResponse(getJob, getJobResponse); - assertEquals(apiWhenJobExists.getJobApi().get("ddd").toString(), - new ParseJobDetailsTest().expected().toString()); - } - - public void testGetJobWhenResponseIs404() { - HttpResponse getJobResponse = HttpResponse.builder().statusCode(404).build(); - JenkinsApi getJobWhenGetd = requestSendsResponse(getJob, getJobResponse); - assertNull(getJobWhenGetd.getJobApi().get("ddd")); - } - - HttpRequest buildJob = HttpRequest.builder() - .method("POST") - .endpoint("http://localhost:8080/job/ddd/build") - .addHeader("Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==") - .build(); - - public void testBuildJobWhenResponseIs2xx() { - HttpResponse buildJobResponse = HttpResponse.builder().statusCode(200).build(); - JenkinsApi apiWhenJobExists = requestSendsResponse(buildJob, buildJobResponse); - apiWhenJobExists.getJobApi().build("ddd"); - } - - public void testBuildJobWhenResponseIs404() { - HttpResponse getJobResponse = HttpResponse.builder().statusCode(404).build(); - JenkinsApi getJobWhenGetd = requestSendsResponse(buildJob, getJobResponse); - getJobWhenGetd.getJobApi().build("ddd"); - } - - HttpRequest fetchConfig = HttpRequest.builder() - .method("GET") - .endpoint("http://localhost:8080/job/ddd/config.xml") - .addHeader("Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==") - .build(); - - public void testFetchConfigXMLWhenResponseIs2xx() { - HttpResponse fetchConfigResponse = HttpResponse.builder().statusCode(200) - .payload(payloadFromResourceWithContentType("/sample_job.xml", "text/xml")).build(); - JenkinsApi apiWhenJobExists = requestSendsResponse(fetchConfig, fetchConfigResponse); - String configXML = apiWhenJobExists.getJobApi().fetchConfigXML("ddd"); - //TODO enable this assertion - //assertEquals(configXML, Strings2.toStringAndClose(getClass().getResourceAsStream("/sample_job.xml"))); - } - - public void testFetchConfigXMLWhenResponseIs404() { - HttpResponse fetchConfigResponse = HttpResponse.builder().statusCode(404).build(); - JenkinsApi getJobWhenGetd = requestSendsResponse(fetchConfig, fetchConfigResponse); - getJobWhenGetd.getJobApi().fetchConfigXML("ddd"); - } - - - HttpRequest lastBuild = HttpRequest.builder() - .method("GET") - .endpoint("http://localhost:8080/job/ddd/lastBuild/api/json") - .addHeader("Accept", "application/json") - .addHeader("Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==") - .build(); - - public void testLastBuildWhenResponseIs2xx() { - HttpResponse lastBuildResponse = HttpResponse.builder().statusCode(200) - .payload(payloadFromResource("/lastBuild.json")).build(); - JenkinsApi apiWhenJobExists = requestSendsResponse(lastBuild, lastBuildResponse); - assertEquals(apiWhenJobExists.getJobApi().lastBuild("ddd").toString(), - new LastBuildTest().expected().toString()); - } - - public void testLastBuildWhenResponseIs404() { - HttpResponse lastBuildResponse = HttpResponse.builder().statusCode(404).build(); - JenkinsApi getJobWhenGetd = requestSendsResponse(lastBuild, lastBuildResponse); - assertNull(getJobWhenGetd.getJobApi().lastBuild("ddd")); - } -} diff --git a/labs/jenkins/src/test/java/org/jclouds/jenkins/v1/features/JobApiLiveTest.java b/labs/jenkins/src/test/java/org/jclouds/jenkins/v1/features/JobApiLiveTest.java deleted file mode 100644 index 4f87c6f674..0000000000 --- a/labs/jenkins/src/test/java/org/jclouds/jenkins/v1/features/JobApiLiveTest.java +++ /dev/null @@ -1,110 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.jenkins.v1.features; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; - -import java.io.IOException; -import java.util.Map; - -import org.jclouds.jenkins.v1.domain.JobDetails; -import org.jclouds.jenkins.v1.domain.LastBuild; -import org.jclouds.jenkins.v1.internal.BaseJenkinsApiLiveTest; -import org.jclouds.util.Strings2; -import org.testng.annotations.AfterClass; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableMap; - -/** - * - * @author Adrian Cole - */ -@Test(groups = "live", testName = "JobApiLiveTest") -public class JobApiLiveTest extends BaseJenkinsApiLiveTest { - - public void testCreateJob() throws IOException { - getApi().delete("blagoo"); - getApi().createFromXML("blagoo", Strings2.toStringAndClose(getClass().getResourceAsStream("/sample_job.xml"))); - } - - @Test(dependsOnMethods = "testCreateJob") - public void testFetchConfigXML() throws IOException { - String configXML = getApi().fetchConfigXML("blagoo"); - assertNotNull(configXML); - //TODO enable this assertion - //assertEquals(configXML, Strings2.toStringAndClose(getClass().getResourceAsStream("/sample_job.xml"))); - } - - @Test(dependsOnMethods = "testFetchConfigXML") - public void testGetJob() throws IOException { - JobDetails job = getApi().get("blagoo"); - assertNotNull(job); - assertEquals(job.getName(), "blagoo"); - } - - @Test(dependsOnMethods = "testGetJob") - public void testBuildJob() throws IOException { - getApi().build("blagoo"); - } - - @Test(dependsOnMethods = "testBuildJob") - public void testDeleteJob() { - getApi().delete("blagoo"); - } - - @Test(dependsOnMethods = "testDeleteJob") - public void testCreateJobWithParameters() throws IOException { - getApi().delete("jobWithParameters"); - getApi().createFromXML("jobWithParameters", Strings2.toStringAndClose(getClass().getResourceAsStream("/sample_job_with_parameters.xml"))); - } - - @Test(dependsOnMethods = "testCreateJobWithParameters") - public void testBuildJobWithParameters() throws IOException { - Map parameters = ImmutableMap.of("name", "test1", "password", "secret"); - getApi().buildWithParameters("jobWithParameters", parameters); - } - - @Test(dependsOnMethods = "testBuildJobWithParameters") - public void testLastBuild() throws IOException { - LastBuild lastBuild = getApi().lastBuild("jobWithParameters"); - while(lastBuild == null || lastBuild.getResult() == null) { - lastBuild = getApi().lastBuild("jobWithParameters"); - } - assertEquals(lastBuild.getResult(), "SUCCESS"); - } - - @Test(dependsOnMethods = "testLastBuild") - public void testDeleteJobWithParameters() { - getApi().delete("jobWithParameters"); - } - - @AfterClass(groups = { "integration", "live" }) - @Override - protected void tearDownContext() { - getApi().delete("blagoo"); - getApi().delete("jobWithParameters"); - super.tearDownContext(); - } - - private JobApi getApi() { - return context.getApi().getJobApi(); - } -} diff --git a/labs/jenkins/src/test/java/org/jclouds/jenkins/v1/filters/BasicAuthenticationUnlessAnonymousExpectTest.java b/labs/jenkins/src/test/java/org/jclouds/jenkins/v1/filters/BasicAuthenticationUnlessAnonymousExpectTest.java deleted file mode 100644 index 0b8dd7c208..0000000000 --- a/labs/jenkins/src/test/java/org/jclouds/jenkins/v1/filters/BasicAuthenticationUnlessAnonymousExpectTest.java +++ /dev/null @@ -1,57 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.jenkins.v1.filters; - -import static org.testng.Assert.assertEquals; - -import org.jclouds.http.HttpRequest; -import org.jclouds.http.HttpResponse; -import org.jclouds.jenkins.v1.JenkinsApiMetadata; -import org.jclouds.jenkins.v1.JenkinsApi; -import org.jclouds.jenkins.v1.internal.BaseJenkinsApiExpectTest; -import org.jclouds.jenkins.v1.parse.ParseComputerViewTest; -import org.testng.annotations.Test; - -/** - * - * @author Adrian Cole - */ -@Test(groups = "unit", testName = "BasicAuthenticationUnlessAnonymousExpectTest") -public class BasicAuthenticationUnlessAnonymousExpectTest extends BaseJenkinsApiExpectTest { - - public BasicAuthenticationUnlessAnonymousExpectTest(){ - identity = JenkinsApiMetadata.ANONYMOUS_IDENTITY; - } - - public void testWhenIdentityIsAnonymousNoAuthorizationHeader() { - HttpRequest getComputerView = HttpRequest - .builder() - .method("GET") - .endpoint("http://localhost:8080/computer/api/json") - .addHeader("Accept", "application/json").build(); - - HttpResponse getComputerViewResponse = HttpResponse.builder().statusCode(200) - .payload(payloadFromResource("/computerview.json")).build(); - - JenkinsApi apiWhenServersExist = requestSendsResponse(getComputerView, getComputerViewResponse); - - assertEquals(apiWhenServersExist.getComputerApi().getView().toString(), - new ParseComputerViewTest().expected().toString()); - } -} diff --git a/labs/jenkins/src/test/java/org/jclouds/jenkins/v1/internal/BaseJenkinsApiExpectTest.java b/labs/jenkins/src/test/java/org/jclouds/jenkins/v1/internal/BaseJenkinsApiExpectTest.java deleted file mode 100644 index 93c99306ba..0000000000 --- a/labs/jenkins/src/test/java/org/jclouds/jenkins/v1/internal/BaseJenkinsApiExpectTest.java +++ /dev/null @@ -1,30 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.jenkins.v1.internal; - -import org.jclouds.jenkins.v1.JenkinsApi; - -/** - * Base class for writing Jenkins Expect tests - * - * @author Adrian Cole - */ -public class BaseJenkinsApiExpectTest extends BaseJenkinsExpectTest { - -} diff --git a/labs/jenkins/src/test/java/org/jclouds/jenkins/v1/internal/BaseJenkinsApiLiveTest.java b/labs/jenkins/src/test/java/org/jclouds/jenkins/v1/internal/BaseJenkinsApiLiveTest.java deleted file mode 100644 index 0b86a75e9f..0000000000 --- a/labs/jenkins/src/test/java/org/jclouds/jenkins/v1/internal/BaseJenkinsApiLiveTest.java +++ /dev/null @@ -1,57 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.jenkins.v1.internal; - -import org.jclouds.apis.BaseContextLiveTest; -import org.jclouds.jenkins.v1.JenkinsApiMetadata; -import org.jclouds.jenkins.v1.JenkinsAsyncApi; -import org.jclouds.jenkins.v1.JenkinsApi; -import org.jclouds.rest.RestContext; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -import com.google.common.reflect.TypeToken; - -/** - * Tests behavior of {@code JenkinsApi} - * - * @author Adrian Cole - */ -@Test(groups = "live") -public class BaseJenkinsApiLiveTest extends BaseContextLiveTest> { - - public BaseJenkinsApiLiveTest() { - provider = "jenkins"; - } - - protected RestContext jenkinsContext; - - @BeforeClass(groups = { "integration", "live" }) - @Override - public void setupContext() { - super.setupContext(); - jenkinsContext = context; - } - - @Override - protected TypeToken> contextType() { - return JenkinsApiMetadata.CONTEXT_TOKEN; - } - -} diff --git a/labs/jenkins/src/test/java/org/jclouds/jenkins/v1/internal/BaseJenkinsAsyncApiExpectTest.java b/labs/jenkins/src/test/java/org/jclouds/jenkins/v1/internal/BaseJenkinsAsyncApiExpectTest.java deleted file mode 100644 index e7167f3c95..0000000000 --- a/labs/jenkins/src/test/java/org/jclouds/jenkins/v1/internal/BaseJenkinsAsyncApiExpectTest.java +++ /dev/null @@ -1,39 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.jenkins.v1.internal; - -import java.util.Properties; - -import org.jclouds.http.HttpRequest; -import org.jclouds.http.HttpResponse; -import org.jclouds.jenkins.v1.JenkinsAsyncApi; - -import com.google.common.base.Function; -import com.google.inject.Module; - -/** - * Base class for writing KeyStone Rest Api Expect tests - * - * @author Adrian Cole - */ -public class BaseJenkinsAsyncApiExpectTest extends BaseJenkinsExpectTest { - public JenkinsAsyncApi createClient(Function fn, Module module, Properties props) { - return createInjector(fn, module, props).getInstance(JenkinsAsyncApi.class); - } -} diff --git a/labs/jenkins/src/test/java/org/jclouds/jenkins/v1/internal/BaseJenkinsExpectTest.java b/labs/jenkins/src/test/java/org/jclouds/jenkins/v1/internal/BaseJenkinsExpectTest.java deleted file mode 100644 index 9354740a2a..0000000000 --- a/labs/jenkins/src/test/java/org/jclouds/jenkins/v1/internal/BaseJenkinsExpectTest.java +++ /dev/null @@ -1,32 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.jenkins.v1.internal; - -import org.jclouds.rest.internal.BaseRestApiExpectTest; - -/** - * Base class for writing Jenkins Expect tests - * - * @author Adrian Cole - */ -public class BaseJenkinsExpectTest extends BaseRestApiExpectTest { - public BaseJenkinsExpectTest() { - provider = "jenkins"; - } -} diff --git a/labs/jenkins/src/test/java/org/jclouds/jenkins/v1/parse/LastBuildTest.java b/labs/jenkins/src/test/java/org/jclouds/jenkins/v1/parse/LastBuildTest.java deleted file mode 100644 index 81cdd56aef..0000000000 --- a/labs/jenkins/src/test/java/org/jclouds/jenkins/v1/parse/LastBuildTest.java +++ /dev/null @@ -1,57 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.jenkins.v1.parse; - -import java.net.URI; - -import javax.ws.rs.Consumes; -import javax.ws.rs.core.MediaType; - -import org.jclouds.jenkins.v1.domain.LastBuild; -import org.jclouds.json.BaseItemParserTest; -import org.testng.annotations.Test; - -/** - * - * @author Andrea Turli - */ -@Test(groups = "unit", testName = "LastBuildTest") -public class LastBuildTest extends BaseItemParserTest { - - @Override - public String resource() { - return "/lastBuild.json"; - } - - @Override - @Consumes(MediaType.APPLICATION_JSON) - public LastBuild expected() { - return LastBuild.builder() - .id("2012-07-11_04-02-37") - .url(URI.create("http://dal36.poweredman.com:8080/job/poweredman-web-build/139/")) - .description("test") - .duration("505777") - .building("false") - .estimatedDuration("942619") - .fullDisplayName("poweredman-web-build #139") - .timestamp("1341997357461") - .result("SUCCESS") - .build(); - } -} diff --git a/labs/jenkins/src/test/java/org/jclouds/jenkins/v1/parse/ParseComputerTest.java b/labs/jenkins/src/test/java/org/jclouds/jenkins/v1/parse/ParseComputerTest.java deleted file mode 100644 index 05c4e6a859..0000000000 --- a/labs/jenkins/src/test/java/org/jclouds/jenkins/v1/parse/ParseComputerTest.java +++ /dev/null @@ -1,49 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.jenkins.v1.parse; - -import javax.ws.rs.Consumes; -import javax.ws.rs.core.MediaType; - -import org.jclouds.jenkins.v1.domain.Computer; -import org.jclouds.json.BaseItemParserTest; -import org.testng.annotations.Test; - -/** - * - * @author Adrian Cole - */ -@Test(groups = "unit", testName = "ParseComputerTest") -public class ParseComputerTest extends BaseItemParserTest { - - @Override - public String resource() { - return "/computer.json"; - } - - @Override - @Consumes(MediaType.APPLICATION_JSON) - public Computer expected() { - return Computer.builder() - .displayName("Ruboto") - .idle(true) - .offline(false) - .build(); - } -} diff --git a/labs/jenkins/src/test/java/org/jclouds/jenkins/v1/parse/ParseComputerViewTest.java b/labs/jenkins/src/test/java/org/jclouds/jenkins/v1/parse/ParseComputerViewTest.java deleted file mode 100644 index c45296610e..0000000000 --- a/labs/jenkins/src/test/java/org/jclouds/jenkins/v1/parse/ParseComputerViewTest.java +++ /dev/null @@ -1,64 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.jenkins.v1.parse; - -import javax.ws.rs.Consumes; -import javax.ws.rs.core.MediaType; - -import org.jclouds.jenkins.v1.domain.Computer; -import org.jclouds.jenkins.v1.domain.ComputerView; -import org.jclouds.json.BaseItemParserTest; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableSet; - -/** - * - * @author Adrian Cole - */ -@Test(groups = "unit", testName = "ParseComputerViewTest") -public class ParseComputerViewTest extends BaseItemParserTest { - - @Override - public String resource() { - return "/computerview.json"; - } - - @Override - @Consumes(MediaType.APPLICATION_JSON) - public ComputerView expected() { - return ComputerView.builder() - .displayName("nodes") - .totalExecutors(4) - .busyExecutors(0) - .computers(ImmutableSet.builder() - .add(Computer.builder() - .displayName("master") - .idle(true) - .offline(false).build()) - .add(Computer.builder() - .displayName("Ruboto") - .idle(true) - .offline(false).build()) - .add(Computer.builder() - .displayName("winserver2008-x86") - .idle(true) - .offline(false).build()).build()).build(); - } -} diff --git a/labs/jenkins/src/test/java/org/jclouds/jenkins/v1/parse/ParseJobDetailsTest.java b/labs/jenkins/src/test/java/org/jclouds/jenkins/v1/parse/ParseJobDetailsTest.java deleted file mode 100644 index cf2934fc76..0000000000 --- a/labs/jenkins/src/test/java/org/jclouds/jenkins/v1/parse/ParseJobDetailsTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.jenkins.v1.parse; - -import java.net.URI; - -import javax.ws.rs.Consumes; -import javax.ws.rs.core.MediaType; - -import org.jclouds.jenkins.v1.domain.JobDetails; -import org.jclouds.json.BaseItemParserTest; -import org.testng.annotations.Test; - -/** - * - * @author Adrian Cole - */ -@Test(groups = "unit", testName = "ParseJobDetailsTest") -public class ParseJobDetailsTest extends BaseItemParserTest { - - @Override - public String resource() { - return "/job.json"; - } - - @Override - @Consumes(MediaType.APPLICATION_JSON) - public JobDetails expected() { - return JobDetails.builder() - .name("ddd") - .url(URI.create("http://localhost:8080/job/ddd/")) - .color("grey").build(); - } -} diff --git a/labs/jenkins/src/test/java/org/jclouds/jenkins/v1/parse/ParseNodeTest.java b/labs/jenkins/src/test/java/org/jclouds/jenkins/v1/parse/ParseNodeTest.java deleted file mode 100644 index d2ec328d32..0000000000 --- a/labs/jenkins/src/test/java/org/jclouds/jenkins/v1/parse/ParseNodeTest.java +++ /dev/null @@ -1,55 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.jenkins.v1.parse; - -import java.net.URI; - -import javax.ws.rs.Consumes; -import javax.ws.rs.core.MediaType; - -import org.jclouds.jenkins.v1.domain.Job; -import org.jclouds.jenkins.v1.domain.Node; -import org.jclouds.json.BaseItemParserTest; -import org.testng.annotations.Test; - -/** - * - * @author Adrian Cole - */ -@Test(groups = "unit", testName = "ParseNodeTest") -public class ParseNodeTest extends BaseItemParserTest { - - @Override - public String resource() { - return "/master.json"; - } - - @Override - @Consumes(MediaType.APPLICATION_JSON) - public Node expected() { - return Node.builder() - .name("") - .description("the master Jenkins node") - .jobs(Job.builder() - .name("ddd") - .url(URI.create("http://localhost:8080/job/ddd/")) - .color("grey").build()) - .build(); - } -} diff --git a/labs/jenkins/src/test/resources/computer.json b/labs/jenkins/src/test/resources/computer.json deleted file mode 100644 index 610126b49a..0000000000 --- a/labs/jenkins/src/test/resources/computer.json +++ /dev/null @@ -1,37 +0,0 @@ -{ - "actions": [], - "displayName": "Ruboto", - "executors": [{}], - "icon": "computer.png", - "idle": true, - "jnlpAgent": true, - "launchSupported": false, - "loadStatistics": {}, - "manualLaunchAllowed": true, - "monitorData": { - "hudson.node_monitors.SwapSpaceMonitor": { - "availablePhysicalMemory": 1697591296, - "availableSwapSpace": 5626036224, - "totalPhysicalMemory": 4157317120, - "totalSwapSpace": 6568271872 - }, - "hudson.node_monitors.ArchitectureMonitor": "Linux (amd64)", - "hudson.node_monitors.ResponseTimeMonitor": { - "average": 955 - }, - "hudson.node_monitors.TemporarySpaceMonitor": { - "size": 53646782464 - }, - "hudson.node_monitors.DiskSpaceMonitor": { - "size": 53646782464 - }, - "hudson.node_monitors.ClockMonitor": { - "diff": -309 - } - }, - "numExecutors": 1, - "offline": false, - "offlineCause": null, - "oneOffExecutors": [], - "temporarilyOffline": false -} \ No newline at end of file diff --git a/labs/jenkins/src/test/resources/computerview.json b/labs/jenkins/src/test/resources/computerview.json deleted file mode 100644 index e9b070469e..0000000000 --- a/labs/jenkins/src/test/resources/computerview.json +++ /dev/null @@ -1,114 +0,0 @@ -{ - "busyExecutors": 0, - "computer": [{ - "actions": [], - "displayName": "master", - "executors": [{}, {}], - "icon": "computer.png", - "idle": true, - "jnlpAgent": false, - "launchSupported": true, - "loadStatistics": {}, - "manualLaunchAllowed": true, - "monitorData": { - "hudson.node_monitors.SwapSpaceMonitor": { - "availablePhysicalMemory": 1385115648, - "availableSwapSpace": 32208396288, - "totalPhysicalMemory": 8053207040, - "totalSwapSpace": 32218378240 - }, - "hudson.node_monitors.ArchitectureMonitor": "Linux (amd64)", - "hudson.node_monitors.ResponseTimeMonitor": { - "average": 1 - }, - "hudson.node_monitors.TemporarySpaceMonitor": { - "size": 6235500544 - }, - "hudson.node_monitors.DiskSpaceMonitor": { - "size": 79292284928 - }, - "hudson.node_monitors.ClockMonitor": { - "diff": 0 - } - }, - "numExecutors": 2, - "offline": false, - "offlineCause": null, - "oneOffExecutors": [], - "temporarilyOffline": false - }, { - "actions": [], - "displayName": "Ruboto", - "executors": [{}], - "icon": "computer.png", - "idle": true, - "jnlpAgent": true, - "launchSupported": false, - "loadStatistics": {}, - "manualLaunchAllowed": true, - "monitorData": { - "hudson.node_monitors.SwapSpaceMonitor": { - "availablePhysicalMemory": 1684832256, - "availableSwapSpace": 5625421824, - "totalPhysicalMemory": 4157317120, - "totalSwapSpace": 6568271872 - }, - "hudson.node_monitors.ArchitectureMonitor": "Linux (amd64)", - "hudson.node_monitors.ResponseTimeMonitor": { - "average": 856 - }, - "hudson.node_monitors.TemporarySpaceMonitor": { - "size": 53648973824 - }, - "hudson.node_monitors.DiskSpaceMonitor": { - "size": 53648969728 - }, - "hudson.node_monitors.ClockMonitor": { - "diff": -462 - } - }, - "numExecutors": 1, - "offline": false, - "offlineCause": null, - "oneOffExecutors": [], - "temporarilyOffline": false - }, { - "actions": [], - "displayName": "winserver2008-x86", - "executors": [{}], - "icon": "computer.png", - "idle": true, - "jnlpAgent": true, - "launchSupported": false, - "loadStatistics": {}, - "manualLaunchAllowed": true, - "monitorData": { - "hudson.node_monitors.SwapSpaceMonitor": { - "availablePhysicalMemory": 1117851648, - "availableSwapSpace": 1429299200, - "totalPhysicalMemory": 1781420032, - "totalSwapSpace": 1994350592 - }, - "hudson.node_monitors.ArchitectureMonitor": "Windows Server 2008 (x86)", - "hudson.node_monitors.ResponseTimeMonitor": { - "average": 1 - }, - "hudson.node_monitors.TemporarySpaceMonitor": { - "size": 19072663552 - }, - "hudson.node_monitors.DiskSpaceMonitor": { - "size": 19072663552 - }, - "hudson.node_monitors.ClockMonitor": { - "diff": 71 - } - }, - "numExecutors": 1, - "offline": false, - "offlineCause": null, - "oneOffExecutors": [], - "temporarilyOffline": false - }], - "displayName": "nodes", - "totalExecutors": 4 -} \ No newline at end of file diff --git a/labs/jenkins/src/test/resources/job.json b/labs/jenkins/src/test/resources/job.json deleted file mode 100644 index ebf43f35fb..0000000000 --- a/labs/jenkins/src/test/resources/job.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "actions": [], - "description": "", - "displayName": "ddd", - "displayNameOrNull": null, - "name": "ddd", - "url": "http://localhost:8080/job/ddd/", - "buildable": true, - "builds": [], - "color": "grey", - "firstBuild": null, - "healthReport": [], - "inQueue": false, - "keepDependencies": false, - "lastBuild": null, - "lastCompletedBuild": null, - "lastFailedBuild": null, - "lastStableBuild": null, - "lastSuccessfulBuild": null, - "lastUnstableBuild": null, - "lastUnsuccessfulBuild": null, - "nextBuildNumber": 1, - "property": [], - "queueItem": null, - "concurrentBuild": false, - "downstreamProjects": [], - "scm": {}, - "upstreamProjects": [] -} \ No newline at end of file diff --git a/labs/jenkins/src/test/resources/lastBuild.json b/labs/jenkins/src/test/resources/lastBuild.json deleted file mode 100644 index 3843687aae..0000000000 --- a/labs/jenkins/src/test/resources/lastBuild.json +++ /dev/null @@ -1,127 +0,0 @@ -{ - "actions": [ - { - "causes": [ - { - "shortDescription": "Started by GitHub push by " - } - ] - }, - { - }, - { - "buildsByBranchName": { - "origin/master": { - "buildNumber": 139, - "buildResult": null, - "revision": { - "SHA1": "aabf3da75ef2f4169de1136a93d5eec609314436", - "branch": [ - { - "SHA1": "aabf3da75ef2f4169de1136a93d5eec609314436", - "name": "origin/HEAD" - }, - { - "SHA1": "aabf3da75ef2f4169de1136a93d5eec609314436", - "name": "origin/master" - } - ] - } - }, - "origin/HEAD": { - "buildNumber": 139, - "buildResult": null, - "revision": { - "SHA1": "aabf3da75ef2f4169de1136a93d5eec609314436", - "branch": [ - { - "SHA1": "aabf3da75ef2f4169de1136a93d5eec609314436", - "name": "origin/HEAD" - }, - { - "SHA1": "aabf3da75ef2f4169de1136a93d5eec609314436", - "name": "origin/master" - } - ] - } - } - }, - "lastBuiltRevision": { - "SHA1": "aabf3da75ef2f4169de1136a93d5eec609314436", - "branch": [ - { - "SHA1": "aabf3da75ef2f4169de1136a93d5eec609314436", - "name": "origin/HEAD" - }, - { - "SHA1": "aabf3da75ef2f4169de1136a93d5eec609314436", - "name": "origin/master" - } - ] - }, - "scmName": "" - }, - { - }, - { - }, - { - } - ], - "artifacts": [ - { - "displayPath": "poweredman-webapp-0.0.1-SNAPSHOT.zip", - "fileName": "poweredman-webapp-0.0.1-SNAPSHOT.zip", - "relativePath": "webapp/dist/poweredman-webapp-0.0.1-SNAPSHOT.zip" - } - ], - "building": false, - "description": "test", - "duration": 505777, - "estimatedDuration": 942619, - "fullDisplayName": "poweredman-web-build #139", - "id": "2012-07-11_04-02-37", - "keepLog": false, - "number": 139, - "result": "SUCCESS", - "timestamp": 1341997357461, - "url": "http://dal36.poweredman.com:8080/job/poweredman-web-build/139/", - "builtOn": "", - "changeSet": { - "items": [ - { - "affectedPaths": [ - "webapp/app/controllers/Application.java" - ], - "author": { - "absoluteUrl": "http://dal36.poweredman.com:8080/user/andrea.turli", - "fullName": "andrea.turli" - }, - "commitId": "aabf3da75ef2f4169de1136a93d5eec609314436", - "msg": "fixed signup process removing refuse Ebean.saveManyToManyAssociations(currentUser, \"companies\")", - "timestamp": 1341997059000, - "author (new)": { - "absoluteUrl": "http://dal36.poweredman.com:8080/user/andrea.turli", - "fullName": "andrea.turli" - }, - "comment": "fixed signup process removing refuse Ebean.saveManyToManyAssociations(currentUser, \"companies\")\n", - "date": "2012-07-11 03:57:39 +0200", - "id": "aabf3da75ef2f4169de1136a93d5eec609314436", - "msg (new)": "fixed signup process removing refuse Ebean.saveManyToManyAssociations(currentUser, \"companies\")", - "paths": [ - { - "editType": "edit", - "file": "webapp/app/controllers/Application.java" - } - ] - } - ], - "kind": null - }, - "culprits": [ - { - "absoluteUrl": "http://dal36.poweredman.com:8080/user/andrea.turli", - "fullName": "andrea.turli" - } - ] -} \ No newline at end of file diff --git a/labs/jenkins/src/test/resources/logback.xml b/labs/jenkins/src/test/resources/logback.xml deleted file mode 100644 index 9679b2e03a..0000000000 --- a/labs/jenkins/src/test/resources/logback.xml +++ /dev/null @@ -1,38 +0,0 @@ - - - - target/test-data/jclouds.log - - - %d %-5p [%c] [%thread] %m%n - - - - - target/test-data/jclouds-wire.log - - - %d %-5p [%c] [%thread] %m%n - - - - - - - - - - - - - - - - - - - - - - - diff --git a/labs/jenkins/src/test/resources/master.json b/labs/jenkins/src/test/resources/master.json deleted file mode 100644 index 8e5c622b95..0000000000 --- a/labs/jenkins/src/test/resources/master.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "assignedLabels": [{}], - "mode": "NORMAL", - "nodeDescription": "the master Jenkins node", - "nodeName": "", - "numExecutors": 2, - "description": null, - "jobs": [{ - "name": "ddd", - "url": "http://localhost:8080/job/ddd/", - "color": "grey" - }], - "overallLoad": {}, - "primaryView": { - "name": "All", - "url": "http://localhost:8080/" - }, - "quietingDown": false, - "slaveAgentPort": 0, - "useCrumbs": false, - "useSecurity": false, - "views": [{ - "name": "All", - "url": "http://localhost:8080/" - }] -} \ No newline at end of file diff --git a/labs/jenkins/src/test/resources/sample_job.xml b/labs/jenkins/src/test/resources/sample_job.xml deleted file mode 100644 index 9b74eb35a0..0000000000 --- a/labs/jenkins/src/test/resources/sample_job.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - false - - - true - false - false - false - - false - - - echo hello - - - - - \ No newline at end of file diff --git a/labs/jenkins/src/test/resources/sample_job_with_parameters.xml b/labs/jenkins/src/test/resources/sample_job_with_parameters.xml deleted file mode 100644 index 3c65002ea7..0000000000 --- a/labs/jenkins/src/test/resources/sample_job_with_parameters.xml +++ /dev/null @@ -1,37 +0,0 @@ - - - - - false - - - - - name - - - - - password - - - - - - - - true - false - false - - false - - false - - - echo hello - - - - - \ No newline at end of file diff --git a/labs/joyent-cloudapi/pom.xml b/labs/joyent-cloudapi/pom.xml deleted file mode 100644 index dd4eec53fe..0000000000 --- a/labs/joyent-cloudapi/pom.xml +++ /dev/null @@ -1,121 +0,0 @@ - - - - 4.0.0 - - org.jclouds.labs - jclouds-labs-project - 1.7.0-SNAPSHOT - ../project/pom.xml - - joyent-cloudapi - jcloud joyent-cloudapi api - jclouds components to access an implementation of Joyent SDC - bundle - - - https://api.joyentcloud.com - ~6.5 - - FIXME_IDENTITY - FIXME_CREDENTIALS - org.jclouds.joyent.cloudapi.v6_5*;version="${project.version}" - - org.jclouds.rest.internal;version="${jclouds.version}", - org.jclouds.labs*;version="${project.version}", - org.jclouds*;version="${jclouds.version}", - * - - - - - - org.jclouds - jclouds-compute - ${jclouds.version} - - - org.jclouds - jclouds-compute - ${jclouds.version} - test-jar - test - - - org.jclouds - jclouds-core - ${jclouds.version} - test-jar - test - - - org.jclouds.driver - jclouds-slf4j - ${jclouds.version} - test - - - org.jclouds.driver - jclouds-sshj - ${jclouds.version} - test - - - ch.qos.logback - logback-classic - test - - - - - - live - - - - org.apache.maven.plugins - maven-surefire-plugin - - - integration - integration-test - - test - - - - ${test.joyent-cloudapi.endpoint} - ${test.joyent-cloudapi.api-version} - ${test.joyent-cloudapi.build-version} - ${test.joyent-cloudapi.identity} - ${test.joyent-cloudapi.credential} - - - - - - - - - - - diff --git a/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/JoyentCloudApi.java b/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/JoyentCloudApi.java deleted file mode 100644 index be9d46e949..0000000000 --- a/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/JoyentCloudApi.java +++ /dev/null @@ -1,85 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.joyent.cloudapi.v6_5; - -import java.util.Set; -import org.jclouds.javax.annotation.Nullable; -import org.jclouds.joyent.cloudapi.v6_5.features.DatacenterApi; -import org.jclouds.joyent.cloudapi.v6_5.features.DatasetApi; -import org.jclouds.joyent.cloudapi.v6_5.features.KeyApi; -import org.jclouds.joyent.cloudapi.v6_5.features.MachineApi; -import org.jclouds.joyent.cloudapi.v6_5.features.PackageApi; -import org.jclouds.location.Zone; -import org.jclouds.location.functions.ZoneToEndpoint; -import org.jclouds.rest.annotations.Delegate; -import org.jclouds.rest.annotations.EndpointParam; - -import com.google.inject.Provides; - -/** - * Provides synchronous access to JoyentCloud. - *

- * - * @see JoyentCloudAsyncApi - * @see api doc - * @author Adrian Cole - */ -public interface JoyentCloudApi { - - /** - * - * @return the datacenter codes configured - */ - @Provides - @Zone - Set getConfiguredDatacenters(); - - /** - * Provides synchronous access to Datacenter features. - */ - @Delegate - DatacenterApi getDatacenterApi(); - - /** - * Provides synchronous access to Key features. - */ - @Delegate - KeyApi getKeyApi(); - - /** - * Provides synchronous access to Machine features. - */ - @Delegate - MachineApi getMachineApiForDatacenter( - @EndpointParam(parser = ZoneToEndpoint.class) @Nullable String datacenter); - - /** - * Provides synchronous access to Dataset features. - */ - @Delegate - DatasetApi getDatasetApiForDatacenter( - @EndpointParam(parser = ZoneToEndpoint.class) @Nullable String datacenter); - - /** - * Provides synchronous access to Package features. - */ - @Delegate - PackageApi getPackageApiForDatacenter( - @EndpointParam(parser = ZoneToEndpoint.class) @Nullable String datacenter); -} diff --git a/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/JoyentCloudApiMetadata.java b/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/JoyentCloudApiMetadata.java deleted file mode 100644 index b7fb3a5819..0000000000 --- a/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/JoyentCloudApiMetadata.java +++ /dev/null @@ -1,98 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.joyent.cloudapi.v6_5; -import static org.jclouds.reflect.Reflection2.typeToken; - -import java.net.URI; -import java.util.Properties; - -import org.jclouds.apis.ApiMetadata; -import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.joyent.cloudapi.v6_5.compute.config.JoyentCloudComputeServiceContextModule; -import org.jclouds.joyent.cloudapi.v6_5.config.DatacentersAreZonesModule; -import org.jclouds.joyent.cloudapi.v6_5.config.JoyentCloudProperties; -import org.jclouds.joyent.cloudapi.v6_5.config.JoyentCloudRestClientModule; -import org.jclouds.rest.RestContext; -import org.jclouds.rest.internal.BaseRestApiMetadata; - -import com.google.common.collect.ImmutableSet; -import com.google.common.reflect.TypeToken; -import com.google.inject.Module; - -/** - * Implementation of {@link ApiMetadata} for JoyentCloud ~6.5 API - * - * @author Adrian Cole - */ -public class JoyentCloudApiMetadata extends BaseRestApiMetadata { - - public static final TypeToken> CONTEXT_TOKEN = new TypeToken>() { - private static final long serialVersionUID = 1L; - }; - - @Override - public Builder toBuilder() { - return new Builder().fromApiMetadata(this); - } - - public JoyentCloudApiMetadata() { - this(new Builder()); - } - - protected JoyentCloudApiMetadata(Builder builder) { - super(builder); - } - - public static Properties defaultProperties() { - Properties properties = BaseRestApiMetadata.defaultProperties(); - // auth fail sometimes happens, as the rc.local script that injects the - // authorized key executes after ssh has started. - properties.setProperty("jclouds.ssh.max-retries", "7"); - properties.setProperty("jclouds.ssh.retry-auth", "true"); - properties.setProperty(JoyentCloudProperties.AUTOGENERATE_KEYS, "true"); - return properties; - } - - public static class Builder extends BaseRestApiMetadata.Builder { - - protected Builder() { - super(JoyentCloudApi.class, JoyentCloudAsyncApi.class); - id("joyent-cloudapi") - .name("Joyent Cloud API") - .identityName("username") - .credentialName("password") - .documentation(URI.create("http://cloudApi.joyent.org/cloudApiapi.html")) - .version("~6.5") - .defaultEndpoint("https://api.joyentcloud.com") - .defaultProperties(JoyentCloudApiMetadata.defaultProperties()) - .view(typeToken(ComputeServiceContext.class)) - .defaultModules(ImmutableSet.> of(DatacentersAreZonesModule.class, JoyentCloudRestClientModule.class, JoyentCloudComputeServiceContextModule.class)); - } - - @Override - public JoyentCloudApiMetadata build() { - return new JoyentCloudApiMetadata(this); - } - - @Override - protected Builder self() { - return this; - } - } -} diff --git a/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/JoyentCloudAsyncApi.java b/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/JoyentCloudAsyncApi.java deleted file mode 100644 index cca4e65812..0000000000 --- a/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/JoyentCloudAsyncApi.java +++ /dev/null @@ -1,86 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.joyent.cloudapi.v6_5; - -import java.util.Set; - -import org.jclouds.javax.annotation.Nullable; -import org.jclouds.joyent.cloudapi.v6_5.features.DatacenterAsyncApi; -import org.jclouds.joyent.cloudapi.v6_5.features.DatasetAsyncApi; -import org.jclouds.joyent.cloudapi.v6_5.features.KeyAsyncApi; -import org.jclouds.joyent.cloudapi.v6_5.features.MachineAsyncApi; -import org.jclouds.joyent.cloudapi.v6_5.features.PackageAsyncApi; -import org.jclouds.location.Zone; -import org.jclouds.location.functions.ZoneToEndpoint; -import org.jclouds.rest.annotations.Delegate; -import org.jclouds.rest.annotations.EndpointParam; - -import com.google.inject.Provides; - -/** - * Provides asynchronous access to JoyentCloud via their REST API. - *

- * - * @see JoyentCloudApi - * @see api doc - * @author Adrian Cole - */ -public interface JoyentCloudAsyncApi { - - /** - * - * @return the datacenter codes configured - */ - @Provides - @Zone - Set getConfiguredDatacenters(); - - /** - * Provides asynchronous access to Datacenter features. - */ - @Delegate - DatacenterAsyncApi getDatacenterApi(); - - /** - * Provides asynchronous access to Key features. - */ - @Delegate - KeyAsyncApi getKeyApi(); - - /** - * Provides asynchronous access to Machine features. - */ - @Delegate - MachineAsyncApi getMachineApiForDatacenter( - @EndpointParam(parser = ZoneToEndpoint.class) @Nullable String datacenter); - - /** - * Provides asynchronous access to Dataset features. - */ - @Delegate - DatasetAsyncApi getDatasetApiForDatacenter( - @EndpointParam(parser = ZoneToEndpoint.class) @Nullable String datacenter); - - /** - * Provides asynchronous access to Package features. - */ - @Delegate - PackageAsyncApi getPackageApiForDatacenter( - @EndpointParam(parser = ZoneToEndpoint.class) @Nullable String datacenter); -} diff --git a/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/compute/JoyentCloudComputeService.java b/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/compute/JoyentCloudComputeService.java deleted file mode 100644 index 3bd95e2566..0000000000 --- a/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/compute/JoyentCloudComputeService.java +++ /dev/null @@ -1,154 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.joyent.cloudapi.v6_5.compute; - -import static com.google.common.base.Preconditions.checkNotNull; -import static org.jclouds.compute.config.ComputeServiceProperties.TIMEOUT_NODE_RUNNING; -import static org.jclouds.compute.config.ComputeServiceProperties.TIMEOUT_NODE_SUSPENDED; -import static org.jclouds.compute.config.ComputeServiceProperties.TIMEOUT_NODE_TERMINATED; - -import java.util.Collection; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.atomic.AtomicReference; - -import javax.inject.Inject; -import javax.inject.Named; -import javax.inject.Provider; -import javax.inject.Singleton; - -import org.jclouds.Constants; -import org.jclouds.collect.Memoized; -import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.compute.callables.RunScriptOnNode; -import org.jclouds.compute.domain.Hardware; -import org.jclouds.compute.domain.Image; -import org.jclouds.compute.domain.NodeMetadata; -import org.jclouds.compute.domain.TemplateBuilder; -import org.jclouds.compute.extensions.ImageExtension; -import org.jclouds.compute.functions.GroupNamingConvention; -import org.jclouds.compute.internal.BaseComputeService; -import org.jclouds.compute.internal.PersistNodeCredentials; -import org.jclouds.compute.options.TemplateOptions; -import org.jclouds.compute.reference.ComputeServiceConstants.Timeouts; -import org.jclouds.compute.strategy.CreateNodesInGroupThenAddToSet; -import org.jclouds.compute.strategy.DestroyNodeStrategy; -import org.jclouds.compute.strategy.GetImageStrategy; -import org.jclouds.compute.strategy.GetNodeMetadataStrategy; -import org.jclouds.compute.strategy.InitializeRunScriptOnNodeOrPlaceInBadMap; -import org.jclouds.compute.strategy.ListNodesStrategy; -import org.jclouds.compute.strategy.RebootNodeStrategy; -import org.jclouds.compute.strategy.ResumeNodeStrategy; -import org.jclouds.compute.strategy.SuspendNodeStrategy; -import org.jclouds.domain.Credentials; -import org.jclouds.domain.Location; -import org.jclouds.joyent.cloudapi.v6_5.JoyentCloudApi; -import org.jclouds.joyent.cloudapi.v6_5.compute.internal.KeyAndPrivateKey; -import org.jclouds.joyent.cloudapi.v6_5.compute.options.JoyentCloudTemplateOptions; -import org.jclouds.joyent.cloudapi.v6_5.domain.Key; -import org.jclouds.joyent.cloudapi.v6_5.domain.datacenterscoped.DatacenterAndName; -import org.jclouds.joyent.cloudapi.v6_5.features.KeyApi; -import org.jclouds.joyent.cloudapi.v6_5.predicates.KeyPredicates; -import org.jclouds.scriptbuilder.functions.InitAdminAccess; - -import com.google.common.base.Function; -import com.google.common.base.Optional; -import com.google.common.base.Predicate; -import com.google.common.base.Supplier; -import com.google.common.cache.LoadingCache; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Iterables; -import com.google.common.collect.Multimap; -import com.google.common.util.concurrent.ListeningExecutorService; - -/** - * @author Adrian Cole - */ -@Singleton -public class JoyentCloudComputeService extends BaseComputeService { - protected final JoyentCloudApi novaApi; - protected final LoadingCache keyCache; - protected final Function, Multimap> orphanedGroupsByDatacenterId; - protected final GroupNamingConvention.Factory namingConvention; - - @Inject - protected JoyentCloudComputeService(ComputeServiceContext context, Map credentialStore, - @Memoized Supplier> images, @Memoized Supplier> sizes, - @Memoized Supplier> locations, ListNodesStrategy listNodesStrategy, - GetImageStrategy getImageStrategy, GetNodeMetadataStrategy getNodeMetadataStrategy, - CreateNodesInGroupThenAddToSet runNodesAndAddToSetStrategy, RebootNodeStrategy rebootNodeStrategy, - DestroyNodeStrategy destroyNodeStrategy, ResumeNodeStrategy startNodeStrategy, - SuspendNodeStrategy stopNodeStrategy, Provider templateBuilderProvider, - @Named("DEFAULT") Provider templateOptionsProvider, - @Named(TIMEOUT_NODE_RUNNING) Predicate> nodeRunning, - @Named(TIMEOUT_NODE_TERMINATED) Predicate> nodeTerminated, - @Named(TIMEOUT_NODE_SUSPENDED) Predicate> nodeSuspended, - InitializeRunScriptOnNodeOrPlaceInBadMap.Factory initScriptRunnerFactory, - RunScriptOnNode.Factory runScriptOnNodeFactory, InitAdminAccess initAdminAccess, - PersistNodeCredentials persistNodeCredentials, Timeouts timeouts, - @Named(Constants.PROPERTY_USER_THREADS) ListeningExecutorService userExecutor, JoyentCloudApi novaApi, - LoadingCache keyCache, - Function, Multimap> orphanedGroupsByDatacenterId, - GroupNamingConvention.Factory namingConvention, Optional imageExtension) { - super(context, credentialStore, images, sizes, locations, listNodesStrategy, getImageStrategy, - getNodeMetadataStrategy, runNodesAndAddToSetStrategy, rebootNodeStrategy, destroyNodeStrategy, - startNodeStrategy, stopNodeStrategy, templateBuilderProvider, templateOptionsProvider, nodeRunning, - nodeTerminated, nodeSuspended, initScriptRunnerFactory, initAdminAccess, runScriptOnNodeFactory, - persistNodeCredentials, timeouts, userExecutor, imageExtension); - this.novaApi = checkNotNull(novaApi, "novaApi"); - this.keyCache = checkNotNull(keyCache, "keyCache"); - this.orphanedGroupsByDatacenterId = checkNotNull(orphanedGroupsByDatacenterId, "orphanedGroupsByDatacenterId"); - this.namingConvention = checkNotNull(namingConvention, "namingConvention"); - } - - @Override - protected void cleanUpIncidentalResourcesOfDeadNodes(Set deadNodes) { - Multimap zoneToZoneAndGroupNames = orphanedGroupsByDatacenterId.apply(deadNodes); - for (Map.Entry> entry : zoneToZoneAndGroupNames.asMap().entrySet()) { - cleanupOrphanedKeysInZone(ImmutableSet.copyOf(entry.getValue()), entry.getKey()); - } - } - - private void cleanupOrphanedKeysInZone(Set groups, String datacenterId) { - KeyApi keyApi = novaApi.getKeyApi(); - for (String group : groups) { - for (Key key : Iterables.filter(keyApi.list(), - KeyPredicates.nameMatches(namingConvention.create().containsGroup(group)))) { - DatacenterAndName datacenterAndName = DatacenterAndName.fromDatacenterAndName(datacenterId, key.getName()); - logger.debug(">> deleting key(%s)", datacenterAndName); - keyApi.delete(key.getName()); - // TODO: test this clear happens - keyCache.invalidate(datacenterAndName); - logger.debug("<< deleted key(%s)", datacenterAndName); - } - - keyCache.invalidate(DatacenterAndName.fromDatacenterAndName(datacenterId, namingConvention.create() - .sharedNameForGroup(group))); - } - } - - /** - * returns template options, except of type {@link JoyentCloudTemplateOptions}. - */ - @Override - public JoyentCloudTemplateOptions templateOptions() { - return JoyentCloudTemplateOptions.class.cast(super.templateOptions()); - } - -} diff --git a/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/compute/JoyentCloudComputeServiceAdapter.java b/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/compute/JoyentCloudComputeServiceAdapter.java deleted file mode 100644 index 2040a561f8..0000000000 --- a/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/compute/JoyentCloudComputeServiceAdapter.java +++ /dev/null @@ -1,217 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.joyent.cloudapi.v6_5.compute; - -import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.base.Preconditions.checkState; -import static com.google.common.collect.Iterables.transform; -import static org.jclouds.compute.reference.ComputeServiceConstants.COMPUTE_LOGGER; -import static org.jclouds.compute.util.ComputeServiceUtils.metadataAndTagsAsCommaDelimitedValue; -import static org.jclouds.util.Predicates2.retry; - -import java.util.Set; -import java.util.concurrent.atomic.AtomicReference; - -import javax.annotation.Resource; -import javax.inject.Inject; -import javax.inject.Named; - -import org.jclouds.compute.ComputeServiceAdapter; -import org.jclouds.compute.domain.Template; -import org.jclouds.compute.reference.ComputeServiceConstants.Timeouts; -import org.jclouds.domain.Location; -import org.jclouds.domain.LoginCredentials; -import org.jclouds.joyent.cloudapi.v6_5.JoyentCloudApi; -import org.jclouds.joyent.cloudapi.v6_5.domain.Dataset; -import org.jclouds.joyent.cloudapi.v6_5.domain.Machine; -import org.jclouds.joyent.cloudapi.v6_5.domain.Machine.State; -import org.jclouds.joyent.cloudapi.v6_5.domain.datacenterscoped.DatacenterAndId; -import org.jclouds.joyent.cloudapi.v6_5.domain.datacenterscoped.DatasetInDatacenter; -import org.jclouds.joyent.cloudapi.v6_5.domain.datacenterscoped.MachineInDatacenter; -import org.jclouds.joyent.cloudapi.v6_5.domain.datacenterscoped.PackageInDatacenter; -import org.jclouds.joyent.cloudapi.v6_5.options.CreateMachineOptions; -import org.jclouds.location.Zone; -import org.jclouds.logging.Logger; - -import com.google.common.base.Function; -import com.google.common.base.Predicate; -import com.google.common.base.Supplier; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.ImmutableSet.Builder; - -/** - * The adapter used by the JoyentCloudComputeServiceContextModule to interface the - * JoyentCloud-specific domain model to the computeService generic domain model. - * - * @author Adrian Cole - */ -public class JoyentCloudComputeServiceAdapter implements - ComputeServiceAdapter { - - @Resource - @Named(COMPUTE_LOGGER) - private Logger logger = Logger.NULL; - - private final JoyentCloudApi cloudApiApi; - private final Supplier> datacenterIds; - private final Timeouts timeouts; - - @Inject - public JoyentCloudComputeServiceAdapter(JoyentCloudApi cloudApiApi, @Zone Supplier> datacenterIds, - Timeouts timeouts) { - this.cloudApiApi = checkNotNull(cloudApiApi, "cloudApiApi"); - this.datacenterIds = checkNotNull(datacenterIds, "datacenterIds"); - this.timeouts = checkNotNull(timeouts, "timeouts"); - } - - @Override - public NodeAndInitialCredentials createNodeWithGroupEncodedIntoName(String group, String name, - Template template) { - - LoginCredentials.Builder credentialsBuilder = LoginCredentials.builder(); - - CreateMachineOptions options = new CreateMachineOptions(); - options.name(name); - options.packageName(template.getHardware().getProviderId()); - options.metadata(metadataAndTagsAsCommaDelimitedValue(template.getOptions())); - - String datacenterId = template.getLocation().getId(); - String datasetURN = template.getImage().getProviderId(); - - logger.debug(">> creating new machine datacenter(%s) datasetURN(%s) options(%s)", datacenterId, datasetURN, - options); - Machine machine = cloudApiApi.getMachineApiForDatacenter(datacenterId).createWithDataset(datasetURN, options); - - logger.trace("<< machine(%s)", machine.getId()); - - MachineInDatacenter machineInDatacenter = new MachineInDatacenter(machine, datacenterId); - - //TODO machineInDatacenter.metadata for password - if (template.getOptions().getLoginPrivateKey() != null){ - credentialsBuilder.privateKey(template.getOptions().getLoginPrivateKey()); - } - return new NodeAndInitialCredentials(machineInDatacenter, machineInDatacenter.slashEncode(), - credentialsBuilder.build()); - } - - @Override - public Iterable listHardwareProfiles() { - Builder builder = ImmutableSet.builder(); - for (final String datacenterId : datacenterIds.get()) { - builder.addAll(transform(cloudApiApi.getPackageApiForDatacenter(datacenterId).list(), - new Function() { - public PackageInDatacenter apply(org.jclouds.joyent.cloudapi.v6_5.domain.Package arg0) { - return new PackageInDatacenter(arg0, datacenterId); - } - })); - } - return builder.build(); - } - - @Override - public Iterable listImages() { - Builder builder = ImmutableSet.builder(); - for (final String datacenterId : datacenterIds.get()) { - builder.addAll(transform(cloudApiApi.getDatasetApiForDatacenter(datacenterId).list(), - new Function() { - public DatasetInDatacenter apply(Dataset arg0) { - return new DatasetInDatacenter(arg0, datacenterId); - } - })); - } - return builder.build(); - } - - @Override - public Iterable listNodes() { - Builder builder = ImmutableSet.builder(); - for (final String datacenterId : datacenterIds.get()) { - builder.addAll(transform(cloudApiApi.getMachineApiForDatacenter(datacenterId).list(), - new Function() { - public MachineInDatacenter apply(Machine arg0) { - return new MachineInDatacenter(arg0, datacenterId); - } - })); - } - return builder.build(); - } - - @Override - public Iterable listLocations() { - // locations provided by guice - return ImmutableSet.of(); - } - - @Override - public MachineInDatacenter getNode(String id) { - DatacenterAndId datacenterAndId = DatacenterAndId.fromSlashEncoded(id); - Machine machine = cloudApiApi.getMachineApiForDatacenter(datacenterAndId.getDatacenter()).get( - datacenterAndId.getId()); - return machine == null ? null : new MachineInDatacenter(machine, datacenterAndId.getDatacenter()); - } - - @Override - public DatasetInDatacenter getImage(String id) { - DatacenterAndId datacenterAndId = DatacenterAndId.fromSlashEncoded(id); - Dataset dataset = cloudApiApi.getDatasetApiForDatacenter(datacenterAndId.getDatacenter()).get( - datacenterAndId.getId()); - return dataset == null ? null : new DatasetInDatacenter(dataset, datacenterAndId.getDatacenter()); - } - - @Override - public void destroyNode(String id) { - final AtomicReference machine = new AtomicReference(getNode(id)); - if (machine.get() == null) - return; - if (machine.get().get().getState() == State.RUNNING) { - logger.debug(">> stopping machine(%s) current state(%s)", machine.get().getId(), machine.get().get() - .getState()); - cloudApiApi.getMachineApiForDatacenter(machine.get().getDatacenter()).stop(machine.get().getId()); - } - - checkState(retry(new Predicate() { - public boolean apply(String id) { - machine.set(getNode(id)); - return machine == null || machine.get().get().getState() != State.RUNNING; - } - }, timeouts.nodeSuspended).apply(id), "<< unable to stop machine(%s) current state(%s)", machine.get().getId(), - machine.get().get().getState()); - - logger.debug(">> deleting machine(%s) current state(%s)", machine.get().getId(), machine.get().get().getState()); - cloudApiApi.getMachineApiForDatacenter(machine.get().getDatacenter()).delete(machine.get().getId()); - } - - @Override - public void rebootNode(String id) { - DatacenterAndId datacenterAndId = DatacenterAndId.fromSlashEncoded(id); - cloudApiApi.getMachineApiForDatacenter(datacenterAndId.getDatacenter()).reboot(datacenterAndId.getId()); - } - - @Override - public void resumeNode(String id) { - DatacenterAndId datacenterAndId = DatacenterAndId.fromSlashEncoded(id); - cloudApiApi.getMachineApiForDatacenter(datacenterAndId.getDatacenter()).start(datacenterAndId.getId()); - } - - @Override - public void suspendNode(String id) { - DatacenterAndId datacenterAndId = DatacenterAndId.fromSlashEncoded(id); - cloudApiApi.getMachineApiForDatacenter(datacenterAndId.getDatacenter()).stop(datacenterAndId.getId()); - } -} diff --git a/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/compute/config/JoyentCloudComputeServiceContextModule.java b/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/compute/config/JoyentCloudComputeServiceContextModule.java deleted file mode 100644 index b04ff14053..0000000000 --- a/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/compute/config/JoyentCloudComputeServiceContextModule.java +++ /dev/null @@ -1,171 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.joyent.cloudapi.v6_5.compute.config; - -import static org.jclouds.joyent.cloudapi.v6_5.config.JoyentCloudProperties.AUTOGENERATE_KEYS; - -import java.util.Map; -import java.util.Set; - -import javax.inject.Singleton; - -import org.jclouds.collect.Memoized; -import org.jclouds.compute.ComputeService; -import org.jclouds.compute.ComputeServiceAdapter; -import org.jclouds.compute.config.ComputeServiceAdapterContextModule; -import org.jclouds.compute.domain.Hardware; -import org.jclouds.compute.domain.Image; -import org.jclouds.compute.domain.NodeMetadata; -import org.jclouds.compute.domain.OperatingSystem; -import org.jclouds.compute.options.TemplateOptions; -import org.jclouds.compute.strategy.impl.CreateNodesWithGroupEncodedIntoNameThenAddToSet; -import org.jclouds.domain.Location; -import org.jclouds.functions.IdentityFunction; -import org.jclouds.joyent.cloudapi.v6_5.compute.JoyentCloudComputeService; -import org.jclouds.joyent.cloudapi.v6_5.compute.JoyentCloudComputeServiceAdapter; -import org.jclouds.joyent.cloudapi.v6_5.compute.functions.DatasetInDatacenterToImage; -import org.jclouds.joyent.cloudapi.v6_5.compute.functions.DatasetToOperatingSystem; -import org.jclouds.joyent.cloudapi.v6_5.compute.functions.MachineInDatacenterToNodeMetadata; -import org.jclouds.joyent.cloudapi.v6_5.compute.functions.OrphanedGroupsByDatacenterId; -import org.jclouds.joyent.cloudapi.v6_5.compute.functions.PackageInDatacenterToHardware; -import org.jclouds.joyent.cloudapi.v6_5.compute.internal.KeyAndPrivateKey; -import org.jclouds.joyent.cloudapi.v6_5.compute.loaders.CreateUniqueKey; -import org.jclouds.joyent.cloudapi.v6_5.compute.options.JoyentCloudTemplateOptions; -import org.jclouds.joyent.cloudapi.v6_5.compute.strategy.ApplyJoyentCloudTemplateOptionsCreateNodesWithGroupEncodedIntoNameThenAddToSet; -import org.jclouds.joyent.cloudapi.v6_5.domain.Dataset; -import org.jclouds.joyent.cloudapi.v6_5.domain.Machine; -import org.jclouds.joyent.cloudapi.v6_5.domain.datacenterscoped.DatacenterAndName; -import org.jclouds.joyent.cloudapi.v6_5.domain.datacenterscoped.DatasetInDatacenter; -import org.jclouds.joyent.cloudapi.v6_5.domain.datacenterscoped.MachineInDatacenter; -import org.jclouds.joyent.cloudapi.v6_5.domain.datacenterscoped.PackageInDatacenter; - -import com.google.common.annotations.VisibleForTesting; -import com.google.common.base.Function; -import com.google.common.base.Supplier; -import com.google.common.base.Suppliers; -import com.google.common.cache.CacheBuilder; -import com.google.common.cache.CacheLoader; -import com.google.common.cache.LoadingCache; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Maps; -import com.google.common.collect.Multimap; -import com.google.inject.Injector; -import com.google.inject.Provides; -import com.google.inject.TypeLiteral; -import com.google.inject.name.Names; - -/** - * Module for building a compute service context for Cloud Api - * - * @author Adrian Cole - */ -public class JoyentCloudComputeServiceContextModule extends - ComputeServiceAdapterContextModule { - - @SuppressWarnings("unchecked") - @Override - protected void configure() { - super.configure(); - bind( - new TypeLiteral>() { - }).to(JoyentCloudComputeServiceAdapter.class); - - bind(new TypeLiteral>() { - }).to(MachineInDatacenterToNodeMetadata.class); - - bind(new TypeLiteral>() { - }).to(DatasetInDatacenterToImage.class); - bind(new TypeLiteral>() { - }).to(DatasetToOperatingSystem.class); - - bind(new TypeLiteral>() { - }).to(PackageInDatacenterToHardware.class); - - // we aren't converting location from a provider-specific type - bind(new TypeLiteral>() { - }).to(Class.class.cast(IdentityFunction.class)); - - // how to figure out if a group in a datacenter is no longer in use - bind(new TypeLiteral, Multimap>>() { - }).to(OrphanedGroupsByDatacenterId.class); - - bind(ComputeService.class).to(JoyentCloudComputeService.class); - bind(TemplateOptions.class).to(JoyentCloudTemplateOptions.class); - - bind(CreateNodesWithGroupEncodedIntoNameThenAddToSet.class).to( - ApplyJoyentCloudTemplateOptionsCreateNodesWithGroupEncodedIntoNameThenAddToSet.class); - - bind(new TypeLiteral>() { - }).to(CreateUniqueKey.class); - } - - @Override - protected TemplateOptions provideTemplateOptions(Injector injector, TemplateOptions options) { - boolean generateKey = injector.getInstance(com.google.inject.Key.get(boolean.class, - Names.named(AUTOGENERATE_KEYS))); - return options.as(JoyentCloudTemplateOptions.class).generateKey(generateKey); - } - - @Provides - @Singleton - protected LoadingCache keyMap( - CacheLoader in) { - return CacheBuilder.newBuilder().build(in); - } - - @Provides - @Singleton - protected Supplier> createLocationIndexedById( - @Memoized Supplier> locations) { - return Suppliers.compose(new Function, Map>() { - - @Override - public Map apply(Set arg0) { - return Maps.uniqueIndex(ImmutableSet. copyOf(arg0), new Function() { - - @Override - public String apply(Location arg0) { - return arg0.getId(); - } - - }); - } - }, locations); - - } - - @VisibleForTesting - public static final Map toPortableNodeStatus = ImmutableMap - . builder() - .put(Machine.State.PROVISIONING, NodeMetadata.Status.PENDING) - .put(Machine.State.RUNNING, NodeMetadata.Status.RUNNING) - .put(Machine.State.STOPPING, NodeMetadata.Status.PENDING) - .put(Machine.State.OFFLINE, NodeMetadata.Status.PENDING) - .put(Machine.State.STOPPED, NodeMetadata.Status.SUSPENDED) - .put(Machine.State.DELETED, NodeMetadata.Status.TERMINATED) - .put(Machine.State.UNRECOGNIZED, NodeMetadata.Status.UNRECOGNIZED).build(); - - @Singleton - @Provides - protected Map toPortableNodeStatus() { - return toPortableNodeStatus; - } - -} diff --git a/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/compute/functions/DatasetInDatacenterToImage.java b/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/compute/functions/DatasetInDatacenterToImage.java deleted file mode 100644 index 0b63d01df8..0000000000 --- a/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/compute/functions/DatasetInDatacenterToImage.java +++ /dev/null @@ -1,71 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.joyent.cloudapi.v6_5.compute.functions; - -import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.base.Preconditions.checkState; - -import java.util.Map; - -import javax.inject.Inject; - -import org.jclouds.compute.domain.Image; -import org.jclouds.compute.domain.ImageBuilder; -import org.jclouds.compute.domain.OperatingSystem; -import org.jclouds.domain.Location; -import org.jclouds.joyent.cloudapi.v6_5.domain.Dataset; -import org.jclouds.joyent.cloudapi.v6_5.domain.datacenterscoped.DatasetInDatacenter; - -import com.google.common.base.Function; -import com.google.common.base.Supplier; - -/** - * A function for transforming a cloudApi-specific Image into a generic Image object. - * - * @author Adrian Cole - */ -public class DatasetInDatacenterToImage implements Function { - private final Function imageToOs; - private final Supplier> locationIndex; - - @Inject - public DatasetInDatacenterToImage(Function imageToOs, - Supplier> locationIndex) { - this.imageToOs = checkNotNull(imageToOs, "imageToOs"); - this.locationIndex = checkNotNull(locationIndex, "locationIndex"); - } - - @Override - public Image apply(DatasetInDatacenter datasetInDatacenter) { - Location location = locationIndex.get().get(datasetInDatacenter.getDatacenter()); - checkState(location != null, "location %s not in locationIndex: %s", datasetInDatacenter.getDatacenter(), - locationIndex.get()); - Dataset dataset = datasetInDatacenter.get(); - return new ImageBuilder() - .id(datasetInDatacenter.slashEncode()) - // note that it is urn that is the expected value! - .providerId(dataset.getUrn()) - .name(dataset.getName()) - .operatingSystem(imageToOs.apply(dataset)) - .description(dataset.getDescription()) - .version(dataset.getVersion()) - .location(location) - .status(Image.Status.AVAILABLE).build(); - } -} diff --git a/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/compute/functions/DatasetToOperatingSystem.java b/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/compute/functions/DatasetToOperatingSystem.java deleted file mode 100644 index 332ad65347..0000000000 --- a/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/compute/functions/DatasetToOperatingSystem.java +++ /dev/null @@ -1,84 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.joyent.cloudapi.v6_5.compute.functions; - -import static org.jclouds.compute.domain.OsFamily.UNRECOGNIZED; -import static org.jclouds.compute.domain.OsFamily.fromValue; -import static org.jclouds.compute.util.ComputeServiceUtils.parseVersionOrReturnEmptyString; - -import java.util.List; -import java.util.Map; - -import javax.inject.Inject; - -import org.jclouds.compute.domain.OperatingSystem; -import org.jclouds.compute.domain.OperatingSystem.Builder; -import org.jclouds.compute.domain.OsFamily; -import org.jclouds.joyent.cloudapi.v6_5.domain.Dataset; - -import com.google.common.base.Function; -import com.google.common.base.Splitter; -import com.google.common.collect.ImmutableList; - -/** - * A function for transforming a cloudApi specific Dataset into a generic OperatingSystem object. - * - * @author Adrian Cole - */ -public class DatasetToOperatingSystem implements Function { - - private final Map> osVersionMap; - - @Inject - public DatasetToOperatingSystem(Map> osVersionMap) { - this.osVersionMap = osVersionMap; - } - - public OperatingSystem apply(Dataset from) { - Builder builder = OperatingSystem.builder(); - builder.name(from.getName()); - builder.description(from.getUrn()); - builder.is64Bit(true);// TODO: verify - String os = from.getOs(); - OsFamily family = UNRECOGNIZED; - String version = ""; - if (os.compareTo("smartos") == 0) { - family = fromValue(os); - version = from.getVersion(); - } - else { - List pieces = ImmutableList.copyOf(Splitter.on(':').split(from.getUrn())); - if (pieces.get(2).indexOf('-') != -1) { - List osFamVersion = ImmutableList.copyOf(Splitter.on('-').split(pieces.get(2))); - family = fromValue(osFamVersion.get(0)); - if (family != UNRECOGNIZED) - version = osFamVersion.get(1); - } else { - family = fromValue(pieces.get(2)); - } - } - builder.family(family); - if (family != UNRECOGNIZED) - version = parseVersionOrReturnEmptyString(family, version, osVersionMap); - if ("".equals(version)) - version = from.getVersion(); - builder.version(version); - return builder.build(); - } -} diff --git a/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/compute/functions/MachineInDatacenterToNodeMetadata.java b/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/compute/functions/MachineInDatacenterToNodeMetadata.java deleted file mode 100644 index ffc2b5f3c8..0000000000 --- a/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/compute/functions/MachineInDatacenterToNodeMetadata.java +++ /dev/null @@ -1,150 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.joyent.cloudapi.v6_5.compute.functions; -import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.base.Preconditions.checkState; -import static com.google.common.base.Predicates.not; -import static com.google.common.collect.Iterables.filter; -import static com.google.common.collect.Iterables.tryFind; -import static com.google.common.collect.Maps.filterKeys; -import static org.jclouds.compute.util.ComputeServiceUtils.addMetadataAndParseTagsFromCommaDelimitedValue; -import static org.jclouds.compute.util.ComputeServiceUtils.getSpace; - -import java.util.Map; -import java.util.Set; - -import javax.annotation.Resource; -import javax.inject.Inject; -import javax.inject.Named; - -import org.jclouds.collect.Memoized; -import org.jclouds.compute.domain.ComputeMetadata; -import org.jclouds.compute.domain.Hardware; -import org.jclouds.compute.domain.Image; -import org.jclouds.compute.domain.NodeMetadata; -import org.jclouds.compute.domain.NodeMetadataBuilder; -import org.jclouds.compute.domain.OperatingSystem; -import org.jclouds.compute.functions.GroupNamingConvention; -import org.jclouds.compute.reference.ComputeServiceConstants; -import org.jclouds.domain.Location; -import org.jclouds.joyent.cloudapi.v6_5.domain.Machine; -import org.jclouds.joyent.cloudapi.v6_5.domain.datacenterscoped.DatacenterAndId; -import org.jclouds.joyent.cloudapi.v6_5.domain.datacenterscoped.DatacenterAndName; -import org.jclouds.joyent.cloudapi.v6_5.domain.datacenterscoped.MachineInDatacenter; -import org.jclouds.joyent.cloudapi.v6_5.reference.Metadata; -import org.jclouds.logging.Logger; -import org.jclouds.util.InetAddresses2; - -import com.google.common.base.Function; -import com.google.common.base.Predicate; -import com.google.common.base.Supplier; - -/** - * A function for transforming a cloudApi-specific Machine into a generic - * NodeMetadata object. - * - * @author Adrian Cole - */ -public class MachineInDatacenterToNodeMetadata implements Function { - @Resource - @Named(ComputeServiceConstants.COMPUTE_LOGGER) - protected Logger logger = Logger.NULL; - - protected Map toPortableNodeStatus; - protected final Supplier> locationIndex; - protected final Supplier> images; - protected final Supplier> hardwares; - protected final GroupNamingConvention nodeNamingConvention; - - @Inject - public MachineInDatacenterToNodeMetadata(Map toPortableNodeStatus, - Supplier> locationIndex, @Memoized Supplier> images, - @Memoized Supplier> hardwares, GroupNamingConvention.Factory namingConvention) { - this.toPortableNodeStatus = checkNotNull(toPortableNodeStatus, "toPortableNodeStatus"); - this.nodeNamingConvention = checkNotNull(namingConvention, "namingConvention").createWithoutPrefix(); - this.locationIndex = checkNotNull(locationIndex, "locationIndex"); - this.images = checkNotNull(images, "images"); - this.hardwares = checkNotNull(hardwares, "hardwares"); - } - - @Override - public NodeMetadata apply(MachineInDatacenter machineInDatacenter) { - Location zone = locationIndex.get().get(machineInDatacenter.getDatacenter()); - checkState(zone != null, "location %s not in locationIndex: %s", machineInDatacenter.getDatacenter(), - locationIndex.get()); - Machine from = machineInDatacenter.get(); - - NodeMetadataBuilder builder = new NodeMetadataBuilder(); - builder.id(machineInDatacenter.slashEncode()); - builder.providerId(from.getId()); - builder.name(from.getName()); - builder.hostname(from.getId()); - builder.location(zone); - addMetadataAndParseTagsFromCommaDelimitedValue(builder, filterKeys(from.getMetadata(), new Predicate() { - - @Override - public boolean apply(String input) { - // TODO make this more efficient - for (Metadata key : Metadata.values()) - if (key.key().equals(input)) - return false; - return true; - } - - })); - builder.group(nodeNamingConvention.groupInUniqueNameOrNull(from.getName())); - builder.imageId(DatacenterAndName.fromDatacenterAndName(machineInDatacenter.getDatacenter(), from.getDatasetURN()) - .slashEncode()); - builder.operatingSystem(findOperatingSystemForMachineOrNull(machineInDatacenter)); - builder.hardware(findHardwareForMachineOrNull(machineInDatacenter)); - builder.status(toPortableNodeStatus.get(from.getState())); - builder.publicAddresses(filter(from.getIps(), not(InetAddresses2.IsPrivateIPAddress.INSTANCE))); - builder.privateAddresses(filter(from.getIps(), InetAddresses2.IsPrivateIPAddress.INSTANCE)); - return builder.build(); - } - - protected Hardware findHardwareForMachineOrNull(final MachineInDatacenter machineInDatacenter) { - return tryFind(hardwares.get(), new Predicate() { - @Override - public boolean apply(Hardware input) { - return input.getRam() == machineInDatacenter.get().getMemorySizeMb() - && getSpace(input) == machineInDatacenter.get().getDiskSizeGb() - && input.getLocation().getId().equals(machineInDatacenter.getDatacenter()); - } - }).orNull(); - } - - protected OperatingSystem findOperatingSystemForMachineOrNull(MachineInDatacenter machineInDatacenter) { - Image image = findObjectOfTypeForMachineOrNull(images.get(), "image", machineInDatacenter.get() - .getDatasetURN(), machineInDatacenter); - return (image != null) ? image.getOperatingSystem() : null; - } - - public T findObjectOfTypeForMachineOrNull(Set supply, String type, - final String objectId, final DatacenterAndId machineInDatacenter) { - return tryFind(supply, new Predicate() { - @Override - public boolean apply(T input) { - return input.getId().equals( - DatacenterAndId.fromDatacenterAndId(machineInDatacenter.getDatacenter(), objectId).slashEncode()); - } - }).orNull(); - } - -} diff --git a/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/compute/functions/OrphanedGroupsByDatacenterId.java b/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/compute/functions/OrphanedGroupsByDatacenterId.java deleted file mode 100644 index ddfc99b862..0000000000 --- a/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/compute/functions/OrphanedGroupsByDatacenterId.java +++ /dev/null @@ -1,76 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.joyent.cloudapi.v6_5.compute.functions; - -import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.collect.Iterables.filter; -import static com.google.common.collect.Iterables.transform; - -import java.util.Set; - -import javax.inject.Inject; - -import org.jclouds.compute.ComputeService; -import org.jclouds.compute.domain.NodeMetadata; -import org.jclouds.compute.predicates.NodePredicates; -import org.jclouds.joyent.cloudapi.v6_5.compute.predicates.AllNodesInGroupTerminated; -import org.jclouds.joyent.cloudapi.v6_5.domain.datacenterscoped.DatacenterAndName; - -import com.google.common.annotations.VisibleForTesting; -import com.google.common.base.Function; -import com.google.common.base.Predicate; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Multimap; -import com.google.common.collect.Multimaps; - -/** - * - * @author Adrian Cole - */ -public class OrphanedGroupsByDatacenterId implements Function, Multimap> { - private final Predicate allNodesInGroupTerminated; - - @Inject - protected OrphanedGroupsByDatacenterId(ComputeService computeService) { - this(new AllNodesInGroupTerminated(checkNotNull(computeService, "computeService"))); - } - - @VisibleForTesting - OrphanedGroupsByDatacenterId(Predicate allNodesInGroupTerminated) { - this.allNodesInGroupTerminated = checkNotNull(allNodesInGroupTerminated, "allNodesInGroupTerminated"); - } - - public Multimap apply(Set deadNodes) { - Iterable nodesWithGroup = filter(deadNodes, NodePredicates.hasGroup()); - Set datacenterAndGroupNames = ImmutableSet.copyOf(filter(transform(nodesWithGroup, - new Function() { - - @Override - public DatacenterAndName apply(NodeMetadata input) { - String datacenterId = input.getLocation().getId(); - return DatacenterAndName.fromDatacenterAndName(datacenterId, input.getGroup()); - } - - }), allNodesInGroupTerminated)); - Multimap datacenterToDatacenterAndGroupNames = Multimaps.transformValues(Multimaps.index(datacenterAndGroupNames, - DatacenterAndName.DATACENTER_FUNCTION), DatacenterAndName.NAME_FUNCTION); - return datacenterToDatacenterAndGroupNames; - } - -} diff --git a/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/compute/functions/PackageInDatacenterToHardware.java b/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/compute/functions/PackageInDatacenterToHardware.java deleted file mode 100644 index 64bd24ce32..0000000000 --- a/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/compute/functions/PackageInDatacenterToHardware.java +++ /dev/null @@ -1,66 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.joyent.cloudapi.v6_5.compute.functions; - -import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.base.Preconditions.checkState; - -import java.util.Map; - -import javax.inject.Inject; - -import org.jclouds.compute.domain.Hardware; -import org.jclouds.compute.domain.HardwareBuilder; -import org.jclouds.compute.domain.Processor; -import org.jclouds.compute.domain.internal.VolumeImpl; -import org.jclouds.domain.Location; -import org.jclouds.joyent.cloudapi.v6_5.domain.datacenterscoped.PackageInDatacenter; - -import com.google.common.base.Function; -import com.google.common.base.Supplier; - -/** - * A function for transforming the cloudApi specific PackageInDatacenter object to - * the generic Hardware object. - * - * @author Adrian Cole - */ -public class PackageInDatacenterToHardware implements Function { - - private final Supplier> locationIndex; - - @Inject - public PackageInDatacenterToHardware(Supplier> locationIndex) { - this.locationIndex = checkNotNull(locationIndex, "locationIndex"); - } - - @Override - public Hardware apply(PackageInDatacenter pkgInDatacenter) { - Location location = locationIndex.get().get(pkgInDatacenter.getDatacenter()); - checkState(location != null, "location %s not in locationIndex: %s", pkgInDatacenter.getDatacenter(), - locationIndex.get()); - org.jclouds.joyent.cloudapi.v6_5.domain.Package pkg = pkgInDatacenter.get(); - return new HardwareBuilder().id(pkgInDatacenter.slashEncode()).providerId(pkg.getName()).name(pkg.getName()) - .ram(pkg.getMemorySizeMb()) - // TODO: no api call to get processors.. either hard-code or - // calculate - .processor(new Processor(1, 1.0)).volume(new VolumeImpl(Float.valueOf(pkg.getDiskSizeGb()), true, true)) - .location(location).build(); - } -} diff --git a/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/compute/internal/KeyAndPrivateKey.java b/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/compute/internal/KeyAndPrivateKey.java deleted file mode 100644 index 3318d5431e..0000000000 --- a/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/compute/internal/KeyAndPrivateKey.java +++ /dev/null @@ -1,74 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.joyent.cloudapi.v6_5.compute.internal; - -import static com.google.common.base.Preconditions.checkNotNull; - -import org.jclouds.joyent.cloudapi.v6_5.domain.Key; - -import com.google.common.base.Objects; - -/** - * @author Adrian Cole - */ -public class KeyAndPrivateKey { - - public static KeyAndPrivateKey fromKeyAndPrivateKey(Key key, String privateKey) { - return new KeyAndPrivateKey(key, privateKey); - } - - protected final Key key; - protected final String privateKey; - - protected KeyAndPrivateKey(Key key, String privateKey) { - this.key = checkNotNull(key, "key"); - this.privateKey = checkNotNull(privateKey, "privateKey"); - } - - @Override - public int hashCode() { - return Objects.hashCode(key, privateKey); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - KeyAndPrivateKey other = (KeyAndPrivateKey) obj; - return Objects.equal(key, other.key) && Objects.equal(privateKey, other.privateKey); - } - - public Key getKey() { - return key; - } - - public String getPrivateKey() { - return privateKey; - } - - @Override - public String toString() { - return "[key=" + key + ", privateKey=" + privateKey + "]"; - } - -} diff --git a/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/compute/loaders/CreateUniqueKey.java b/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/compute/loaders/CreateUniqueKey.java deleted file mode 100644 index 7e092efbad..0000000000 --- a/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/compute/loaders/CreateUniqueKey.java +++ /dev/null @@ -1,86 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.joyent.cloudapi.v6_5.compute.loaders; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.Map; - -import javax.annotation.Resource; -import javax.inject.Named; -import javax.inject.Singleton; - -import org.jclouds.compute.functions.GroupNamingConvention; -import org.jclouds.compute.reference.ComputeServiceConstants; -import org.jclouds.joyent.cloudapi.v6_5.JoyentCloudApi; -import org.jclouds.joyent.cloudapi.v6_5.compute.internal.KeyAndPrivateKey; -import org.jclouds.joyent.cloudapi.v6_5.domain.Key; -import org.jclouds.joyent.cloudapi.v6_5.domain.datacenterscoped.DatacenterAndName; -import org.jclouds.logging.Logger; -import org.jclouds.ssh.SshKeyPairGenerator; - -import com.google.common.cache.CacheLoader; -import com.google.inject.Inject; - -/** - * @author Adrian Cole - */ -@Singleton -public class CreateUniqueKey extends CacheLoader { - @Resource - @Named(ComputeServiceConstants.COMPUTE_LOGGER) - protected Logger logger = Logger.NULL; - protected final JoyentCloudApi cloudApiApi; - protected final GroupNamingConvention.Factory namingConvention; - protected final SshKeyPairGenerator sshKeyPairGenerator; - - @Inject - public CreateUniqueKey(JoyentCloudApi cloudApiApi, GroupNamingConvention.Factory namingConvention, - SshKeyPairGenerator sshKeyPairGenerator) { - this.cloudApiApi = checkNotNull(cloudApiApi, "cloudApiApi"); - this.namingConvention = checkNotNull(namingConvention, "namingConvention"); - this.sshKeyPairGenerator = checkNotNull(sshKeyPairGenerator, "sshKeyPairGenerator"); - } - - @Override - public KeyAndPrivateKey load(DatacenterAndName datacenterAndName) { - String datacenterId = checkNotNull(datacenterAndName, "datacenterAndName").getDatacenter(); - String prefix = datacenterAndName.getName(); - - Map keyPair = sshKeyPairGenerator.get(); - String publicKey = keyPair.get("public"); - String privateKey = keyPair.get("private"); - - logger.debug(">> creating key datacenter(%s) prefix(%s)", datacenterId, prefix); - - Key key = null; - while (key == null) { - String name = namingConvention.createWithoutPrefix().uniqueNameForGroup(prefix); - try { - key = cloudApiApi.getKeyApi().create(Key.builder().name(name).key(publicKey).build()); - } catch (IllegalStateException e) { - logger.trace("error creating keypair named %s, %s", name, e.getMessage()); - } - } - - logger.debug("<< created key(%s)", key.getName()); - return KeyAndPrivateKey.fromKeyAndPrivateKey(key, privateKey); - } - -} diff --git a/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/compute/options/JoyentCloudTemplateOptions.java b/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/compute/options/JoyentCloudTemplateOptions.java deleted file mode 100644 index 1e296135c6..0000000000 --- a/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/compute/options/JoyentCloudTemplateOptions.java +++ /dev/null @@ -1,338 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.joyent.cloudapi.v6_5.compute.options; - -import static com.google.common.base.Objects.equal; - -import java.util.Map; - -import org.jclouds.compute.options.TemplateOptions; -import org.jclouds.domain.LoginCredentials; -import org.jclouds.scriptbuilder.domain.Statement; - -import com.google.common.base.Objects; -import com.google.common.base.Objects.ToStringHelper; -import com.google.common.base.Optional; - -/** - * Contains options supported in the {@code ComputeService#createNodesInGroup} operation on the - * "joyent-cloudapi" provider. - * - *

Usage

The recommended way to instantiate a - * JoyentCloudTemplateOptions object is to statically import JoyentCloudTemplateOptions.Builder.* and - * invoke a static creation method followed by an instance mutator (if needed): - *

- * - * import static org.jclouds.joyent.cloudapi.v6_5.compute.options.JoyentCloudTemplateOptions.Builder.*; - *

- * ComputeService api = // get connection - * templateBuilder.options(inboundPorts(22, 80, 8080, 443)); - * Set set = api.createNodesInGroup(tag, 2, templateBuilder.build()); - * - * - * @author Adrian Cole - */ -public class JoyentCloudTemplateOptions extends TemplateOptions implements Cloneable { - - @Override - public JoyentCloudTemplateOptions clone() { - JoyentCloudTemplateOptions options = new JoyentCloudTemplateOptions(); - copyTo(options); - return options; - } - - @Override - public void copyTo(TemplateOptions to) { - super.copyTo(to); - if (to instanceof JoyentCloudTemplateOptions) { - JoyentCloudTemplateOptions eTo = JoyentCloudTemplateOptions.class.cast(to); - eTo.generateKey = generateKey; - } - } - - protected Optional generateKey = Optional.absent(); - - @Override - public boolean equals(Object o) { - if (this == o) - return true; - if (o == null || getClass() != o.getClass()) - return false; - JoyentCloudTemplateOptions that = JoyentCloudTemplateOptions.class.cast(o); - return super.equals(that) && equal(this.generateKey, that.generateKey); - } - - @Override - public int hashCode() { - return Objects.hashCode(super.hashCode(), generateKey); - } - - @Override - public ToStringHelper string() { - return super.string().add("generateKey", generateKey.orNull()); - } - - /** - * @see #shouldGenerateKey() - */ - public JoyentCloudTemplateOptions generateKey(boolean enable) { - this.generateKey = Optional.of(enable); - return this; - } - - /** - * - * @return true if auto generation of keys is enabled - */ - public Optional shouldGenerateKey() { - return generateKey; - } - - public static class Builder { - - /** - * @see JoyentCloudTemplateOptions#shouldGenerateKey() - */ - public static JoyentCloudTemplateOptions generateKey(boolean enable) { - return new JoyentCloudTemplateOptions().generateKey(enable); - } - - // methods that only facilitate returning the correct object type - - /** - * @see TemplateOptions#inboundPorts - */ - public static JoyentCloudTemplateOptions inboundPorts(int... ports) { - JoyentCloudTemplateOptions options = new JoyentCloudTemplateOptions(); - return JoyentCloudTemplateOptions.class.cast(options.inboundPorts(ports)); - } - - /** - * @see TemplateOptions#port - */ - public static JoyentCloudTemplateOptions blockOnPort(int port, int seconds) { - JoyentCloudTemplateOptions options = new JoyentCloudTemplateOptions(); - return JoyentCloudTemplateOptions.class.cast(options.blockOnPort(port, seconds)); - } - - /** - * @see TemplateOptions#installPrivateKey - */ - public static JoyentCloudTemplateOptions installPrivateKey(String rsaKey) { - JoyentCloudTemplateOptions options = new JoyentCloudTemplateOptions(); - return JoyentCloudTemplateOptions.class.cast(options.installPrivateKey(rsaKey)); - } - - /** - * @see TemplateOptions#authorizePublicKey - */ - public static JoyentCloudTemplateOptions authorizePublicKey(String rsaKey) { - JoyentCloudTemplateOptions options = new JoyentCloudTemplateOptions(); - return JoyentCloudTemplateOptions.class.cast(options.authorizePublicKey(rsaKey)); - } - - /** - * @see TemplateOptions#userMetadata - */ - public static JoyentCloudTemplateOptions userMetadata(Map userMetadata) { - JoyentCloudTemplateOptions options = new JoyentCloudTemplateOptions(); - return JoyentCloudTemplateOptions.class.cast(options.userMetadata(userMetadata)); - } - - /** - * @see TemplateOptions#overrideLoginUser - */ - public static JoyentCloudTemplateOptions overrideLoginUser(String user) { - JoyentCloudTemplateOptions options = new JoyentCloudTemplateOptions(); - return options.overrideLoginUser(user); - } - - /** - * @see TemplateOptions#overrideLoginPassword - */ - public static JoyentCloudTemplateOptions overrideLoginPassword(String password) { - JoyentCloudTemplateOptions options = new JoyentCloudTemplateOptions(); - return options.overrideLoginPassword(password); - } - - /** - * @see TemplateOptions#overrideLoginPrivateKey - */ - public static JoyentCloudTemplateOptions overrideLoginPrivateKey(String privateKey) { - JoyentCloudTemplateOptions options = new JoyentCloudTemplateOptions(); - return options.overrideLoginPrivateKey(privateKey); - } - - /** - * @see TemplateOptions#overrideAuthenticateSudo - */ - public static JoyentCloudTemplateOptions overrideAuthenticateSudo(boolean authenticateSudo) { - JoyentCloudTemplateOptions options = new JoyentCloudTemplateOptions(); - return options.overrideAuthenticateSudo(authenticateSudo); - } - - /** - * @see TemplateOptions#overrideLoginCredentials - */ - public static JoyentCloudTemplateOptions overrideLoginCredentials(LoginCredentials credentials) { - JoyentCloudTemplateOptions options = new JoyentCloudTemplateOptions(); - return options.overrideLoginCredentials(credentials); - } - - /** - * @see TemplateOptions#blockUntilRunning - */ - public static JoyentCloudTemplateOptions blockUntilRunning(boolean blockUntilRunning) { - JoyentCloudTemplateOptions options = new JoyentCloudTemplateOptions(); - return options.blockUntilRunning(blockUntilRunning); - } - - } - - // methods that only facilitate returning the correct object type - - /** - * {@inheritDoc} - */ - @Override - public JoyentCloudTemplateOptions blockOnPort(int port, int seconds) { - return JoyentCloudTemplateOptions.class.cast(super.blockOnPort(port, seconds)); - } - - /** - * {@inheritDoc} - */ - @Override - public JoyentCloudTemplateOptions inboundPorts(int... ports) { - return JoyentCloudTemplateOptions.class.cast(super.inboundPorts(ports)); - } - - /** - * {@inheritDoc} - */ - @Override - public JoyentCloudTemplateOptions authorizePublicKey(String publicKey) { - return JoyentCloudTemplateOptions.class.cast(super.authorizePublicKey(publicKey)); - } - - /** - * {@inheritDoc} - */ - @Override - public JoyentCloudTemplateOptions installPrivateKey(String privateKey) { - return JoyentCloudTemplateOptions.class.cast(super.installPrivateKey(privateKey)); - } - - /** - * {@inheritDoc} - */ - @Override - public JoyentCloudTemplateOptions blockUntilRunning(boolean blockUntilRunning) { - return JoyentCloudTemplateOptions.class.cast(super.blockUntilRunning(blockUntilRunning)); - } - - /** - * {@inheritDoc} - */ - @Override - public JoyentCloudTemplateOptions dontAuthorizePublicKey() { - return JoyentCloudTemplateOptions.class.cast(super.dontAuthorizePublicKey()); - } - - /** - * {@inheritDoc} - */ - @Override - public JoyentCloudTemplateOptions nameTask(String name) { - return JoyentCloudTemplateOptions.class.cast(super.nameTask(name)); - } - - /** - * {@inheritDoc} - */ - @Override - public JoyentCloudTemplateOptions runAsRoot(boolean runAsRoot) { - return JoyentCloudTemplateOptions.class.cast(super.runAsRoot(runAsRoot)); - } - - /** - * {@inheritDoc} - */ - @Override - public JoyentCloudTemplateOptions runScript(Statement script) { - return JoyentCloudTemplateOptions.class.cast(super.runScript(script)); - } - - /** - * {@inheritDoc} - */ - @Override - public JoyentCloudTemplateOptions overrideLoginCredentials(LoginCredentials overridingCredentials) { - return JoyentCloudTemplateOptions.class.cast(super.overrideLoginCredentials(overridingCredentials)); - } - - /** - * {@inheritDoc} - */ - @Override - public JoyentCloudTemplateOptions overrideLoginPassword(String password) { - return JoyentCloudTemplateOptions.class.cast(super.overrideLoginPassword(password)); - } - - /** - * {@inheritDoc} - */ - @Override - public JoyentCloudTemplateOptions overrideLoginPrivateKey(String privateKey) { - return JoyentCloudTemplateOptions.class.cast(super.overrideLoginPrivateKey(privateKey)); - } - - /** - * {@inheritDoc} - */ - @Override - public JoyentCloudTemplateOptions overrideLoginUser(String loginUser) { - return JoyentCloudTemplateOptions.class.cast(super.overrideLoginUser(loginUser)); - } - - /** - * {@inheritDoc} - */ - @Override - public JoyentCloudTemplateOptions overrideAuthenticateSudo(boolean authenticateSudo) { - return JoyentCloudTemplateOptions.class.cast(super.overrideAuthenticateSudo(authenticateSudo)); - } - - /** - * {@inheritDoc} - */ - @Override - public JoyentCloudTemplateOptions userMetadata(Map userMetadata) { - return JoyentCloudTemplateOptions.class.cast(super.userMetadata(userMetadata)); - } - - /** - * {@inheritDoc} - */ - @Override - public JoyentCloudTemplateOptions userMetadata(String key, String value) { - return JoyentCloudTemplateOptions.class.cast(super.userMetadata(key, value)); - } - -} diff --git a/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/compute/predicates/AllNodesInGroupTerminated.java b/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/compute/predicates/AllNodesInGroupTerminated.java deleted file mode 100644 index e77918e89f..0000000000 --- a/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/compute/predicates/AllNodesInGroupTerminated.java +++ /dev/null @@ -1,52 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.joyent.cloudapi.v6_5.compute.predicates; - -import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.base.Predicates.and; -import static com.google.common.collect.Iterables.all; -import static org.jclouds.compute.predicates.NodePredicates.TERMINATED; -import static org.jclouds.compute.predicates.NodePredicates.inGroup; -import static org.jclouds.compute.predicates.NodePredicates.locationId; - -import javax.inject.Inject; - -import org.jclouds.compute.ComputeService; -import org.jclouds.joyent.cloudapi.v6_5.domain.datacenterscoped.DatacenterAndName; - -import com.google.common.base.Predicate; - -/** - * @author Adrian Cole - */ -public class AllNodesInGroupTerminated implements Predicate { - private final ComputeService computeService; - - - //TODO: TESTME - @Inject - public AllNodesInGroupTerminated(ComputeService computeService) { - this.computeService = checkNotNull(computeService, "computeService"); - } - - @Override - public boolean apply(DatacenterAndName input) { - return all(computeService.listNodesDetailsMatching(locationId(input.getDatacenter())), and(inGroup(input.getName()), TERMINATED)); - } -} diff --git a/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/compute/strategy/ApplyJoyentCloudTemplateOptionsCreateNodesWithGroupEncodedIntoNameThenAddToSet.java b/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/compute/strategy/ApplyJoyentCloudTemplateOptionsCreateNodesWithGroupEncodedIntoNameThenAddToSet.java deleted file mode 100644 index b0d7dfa076..0000000000 --- a/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/compute/strategy/ApplyJoyentCloudTemplateOptionsCreateNodesWithGroupEncodedIntoNameThenAddToSet.java +++ /dev/null @@ -1,102 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.joyent.cloudapi.v6_5.compute.strategy; - -import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.base.Preconditions.checkNotNull; -import static org.jclouds.joyent.cloudapi.v6_5.config.JoyentCloudProperties.AUTOGENERATE_KEYS; - -import java.util.Map; -import java.util.Set; - -import javax.inject.Inject; -import javax.inject.Named; -import javax.inject.Singleton; - -import org.jclouds.Constants; -import org.jclouds.compute.config.CustomizationResponse; -import org.jclouds.compute.domain.NodeMetadata; -import org.jclouds.compute.domain.Template; -import org.jclouds.compute.functions.GroupNamingConvention; -import org.jclouds.compute.strategy.CreateNodeWithGroupEncodedIntoName; -import org.jclouds.compute.strategy.CustomizeNodeAndAddToGoodMapOrPutExceptionIntoBadMap; -import org.jclouds.compute.strategy.ListNodesStrategy; -import org.jclouds.compute.strategy.impl.CreateNodesWithGroupEncodedIntoNameThenAddToSet; -import org.jclouds.joyent.cloudapi.v6_5.compute.internal.KeyAndPrivateKey; -import org.jclouds.joyent.cloudapi.v6_5.compute.options.JoyentCloudTemplateOptions; -import org.jclouds.joyent.cloudapi.v6_5.domain.datacenterscoped.DatacenterAndName; - -import com.google.common.cache.LoadingCache; -import com.google.common.collect.Multimap; -import com.google.common.util.concurrent.ListenableFuture; -import com.google.common.util.concurrent.ListeningExecutorService; - -/** - * - * @author Adrian Cole - */ -@Singleton -public class ApplyJoyentCloudTemplateOptionsCreateNodesWithGroupEncodedIntoNameThenAddToSet extends - CreateNodesWithGroupEncodedIntoNameThenAddToSet { - - private final LoadingCache keyCache; - private final boolean defaultToAutogenerateKeys; - - @Inject - protected ApplyJoyentCloudTemplateOptionsCreateNodesWithGroupEncodedIntoNameThenAddToSet( - CreateNodeWithGroupEncodedIntoName addNodeWithTagStrategy, - ListNodesStrategy listNodesStrategy, - GroupNamingConvention.Factory namingConvention, - CustomizeNodeAndAddToGoodMapOrPutExceptionIntoBadMap.Factory customizeNodeAndAddToGoodMapOrPutExceptionIntoBadMapFactory, - @Named(Constants.PROPERTY_USER_THREADS) ListeningExecutorService userExecutor, - LoadingCache keyCache, - @Named(AUTOGENERATE_KEYS) boolean defaultToAutogenerateKeys) { - super(addNodeWithTagStrategy, listNodesStrategy, namingConvention, userExecutor, - customizeNodeAndAddToGoodMapOrPutExceptionIntoBadMapFactory); - this.keyCache = checkNotNull(keyCache, "keyCache"); - this.defaultToAutogenerateKeys = defaultToAutogenerateKeys; - } - - @Override - public Map> execute(String group, int count, Template template, Set goodNodes, - Map badNodes, Multimap customizationResponses) { - - Template mutableTemplate = template.clone(); - - JoyentCloudTemplateOptions templateOptions = JoyentCloudTemplateOptions.class.cast(mutableTemplate.getOptions()); - - assert template.getOptions().equals(templateOptions) : "options didn't clone properly"; - - String datacenter = mutableTemplate.getLocation().getId(); - - if (!templateOptions.shouldGenerateKey().isPresent()) - templateOptions.generateKey(defaultToAutogenerateKeys); - - if (templateOptions.shouldGenerateKey().get()) { - KeyAndPrivateKey keyPair = keyCache.getUnchecked(DatacenterAndName.fromDatacenterAndName(datacenter, namingConvention.create() - .sharedNameForGroup(group))); - // in order to delete the key later - keyCache.asMap().put(DatacenterAndName.fromDatacenterAndName(datacenter, keyPair.getKey().getName()), keyPair); - templateOptions.overrideLoginPrivateKey(keyPair.getPrivateKey()); - } - checkArgument(templateOptions.getRunScript() == null || templateOptions.getLoginPrivateKey() != null, - "when specifying runScript, you must either set overrideLoginPrivateKey, or generateKey(true)"); - return super.execute(group, count, mutableTemplate, goodNodes, badNodes, customizationResponses); - } -} diff --git a/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/config/DatacentersAreZonesModule.java b/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/config/DatacentersAreZonesModule.java deleted file mode 100644 index eafea1abd9..0000000000 --- a/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/config/DatacentersAreZonesModule.java +++ /dev/null @@ -1,49 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.joyent.cloudapi.v6_5.config; - -import static org.jclouds.rest.config.BinderUtils.bindHttpApi; - -import org.jclouds.joyent.cloudapi.v6_5.features.DatacenterAsyncApi; -import org.jclouds.joyent.cloudapi.v6_5.features.DatacenterApi; -import org.jclouds.joyent.cloudapi.v6_5.suppliers.ZoneIdToURIFromDatacentersApi; -import org.jclouds.location.suppliers.ImplicitLocationSupplier; -import org.jclouds.location.suppliers.ZoneIdToURISupplier; -import org.jclouds.location.suppliers.ZoneIdsSupplier; -import org.jclouds.location.suppliers.derived.ZoneIdsFromZoneIdToURIKeySet; -import org.jclouds.location.suppliers.implicit.OnlyLocationOrFirstZone; - -import com.google.inject.AbstractModule; -import com.google.inject.Scopes; - -/** - * - * @author Adrian Cole - */ -public class DatacentersAreZonesModule extends AbstractModule { - - @Override - protected void configure() { - // datacenter api is needed for obtaining zone ids - bindHttpApi(binder(), DatacenterApi.class, DatacenterAsyncApi.class); - bind(ImplicitLocationSupplier.class).to(OnlyLocationOrFirstZone.class).in(Scopes.SINGLETON); - bind(ZoneIdToURISupplier.class).to(ZoneIdToURIFromDatacentersApi.class).in(Scopes.SINGLETON); - bind(ZoneIdsSupplier.class).to(ZoneIdsFromZoneIdToURIKeySet.class).in(Scopes.SINGLETON); - } -} diff --git a/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/config/JoyentCloudProperties.java b/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/config/JoyentCloudProperties.java deleted file mode 100644 index 299a5def8a..0000000000 --- a/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/config/JoyentCloudProperties.java +++ /dev/null @@ -1,34 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.joyent.cloudapi.v6_5.config; - -/** - * Configuration properties and constants used in joyent JoyentCloud connections. - * - * @author Adrian Cole - */ -public class JoyentCloudProperties { - - /** - * Whenever a node is created, automatically generate keys for groups, as needed, also - * delete the key(s) when the last node in the group is destroyed. - */ - public static final String AUTOGENERATE_KEYS = "jclouds.joyent-cloudapi.autogenerate-keys"; - -} diff --git a/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/config/JoyentCloudRestClientModule.java b/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/config/JoyentCloudRestClientModule.java deleted file mode 100644 index 33fbf47a43..0000000000 --- a/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/config/JoyentCloudRestClientModule.java +++ /dev/null @@ -1,78 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.joyent.cloudapi.v6_5.config; - -import java.util.Map; - -import org.jclouds.http.HttpErrorHandler; -import org.jclouds.http.annotation.ClientError; -import org.jclouds.http.annotation.Redirection; -import org.jclouds.http.annotation.ServerError; -import org.jclouds.joyent.cloudapi.v6_5.JoyentCloudAsyncApi; -import org.jclouds.joyent.cloudapi.v6_5.JoyentCloudApi; -import org.jclouds.joyent.cloudapi.v6_5.features.DatacenterAsyncApi; -import org.jclouds.joyent.cloudapi.v6_5.features.DatacenterApi; -import org.jclouds.joyent.cloudapi.v6_5.features.DatasetAsyncApi; -import org.jclouds.joyent.cloudapi.v6_5.features.DatasetApi; -import org.jclouds.joyent.cloudapi.v6_5.features.KeyAsyncApi; -import org.jclouds.joyent.cloudapi.v6_5.features.KeyApi; -import org.jclouds.joyent.cloudapi.v6_5.features.MachineAsyncApi; -import org.jclouds.joyent.cloudapi.v6_5.features.MachineApi; -import org.jclouds.joyent.cloudapi.v6_5.features.PackageAsyncApi; -import org.jclouds.joyent.cloudapi.v6_5.features.PackageApi; -import org.jclouds.joyent.cloudapi.v6_5.handlers.JoyentCloudErrorHandler; -import org.jclouds.json.config.GsonModule.DateAdapter; -import org.jclouds.json.config.GsonModule.Iso8601DateAdapter; -import org.jclouds.rest.ConfiguresRestClient; -import org.jclouds.rest.config.RestClientModule; - -import com.google.common.collect.ImmutableMap; - -/** - * Configures the JoyentCloud connection. - * - * @author Adrian Cole - */ -@ConfiguresRestClient -public class JoyentCloudRestClientModule extends RestClientModule { - public static final Map, Class> DELEGATE_MAP = ImmutableMap., Class> builder() - .put(DatacenterApi.class, DatacenterAsyncApi.class) - .put(KeyApi.class, KeyAsyncApi.class) - .put(MachineApi.class, MachineAsyncApi.class) - .put(DatasetApi.class, DatasetAsyncApi.class) - .put(PackageApi.class, PackageAsyncApi.class).build(); - - public JoyentCloudRestClientModule() { - super(DELEGATE_MAP); - } - - @Override - protected void configure() { - bind(DateAdapter.class).to(Iso8601DateAdapter.class); - super.configure(); - } - - @Override - protected void bindErrorHandlers() { - bind(HttpErrorHandler.class).annotatedWith(Redirection.class).to(JoyentCloudErrorHandler.class); - bind(HttpErrorHandler.class).annotatedWith(ClientError.class).to(JoyentCloudErrorHandler.class); - bind(HttpErrorHandler.class).annotatedWith(ServerError.class).to(JoyentCloudErrorHandler.class); - } - -} diff --git a/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/domain/Dataset.java b/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/domain/Dataset.java deleted file mode 100644 index 5e57eb72af..0000000000 --- a/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/domain/Dataset.java +++ /dev/null @@ -1,345 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.joyent.cloudapi.v6_5.domain; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.beans.ConstructorProperties; -import java.util.Date; -import java.util.Map; - -import javax.inject.Named; - -import org.jclouds.domain.JsonBall; -import org.jclouds.joyent.cloudapi.v6_5.domain.Machine.Type; - -import com.google.common.annotations.VisibleForTesting; -import com.google.common.base.Function; -import com.google.common.base.Functions; -import com.google.common.base.Objects; -import com.google.common.collect.ComparisonChain; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.Maps; - -/** - * A dataset is the image of the software on your machine. It contains the software packages that - * will be available on newly provisioned machines. In the case of virtual machines, the dataset - * also includes the operating system. - * - * @author Gerald Pereira - * @see docs - */ -public class Dataset implements Comparable { - - public static Builder builder() { - return new Builder(); - } - - public Builder toBuilder() { - return new Builder().fromDataset(this); - } - - public static class Builder { - private String id; - private String urn; - private String name; - private String os; - private Type type; - private String description; - private boolean isDefault; - private ImmutableMap.Builder requirements = ImmutableMap.builder(); - private String version; - private Date created; - - /** - * @see Dataset#getId() - */ - public Builder id(String id) { - this.id = id; - return this; - } - - /** - * @see Dataset#getUrn() - */ - public Builder urn(String urn) { - this.urn = urn; - return this; - } - - /** - * @see Dataset#getName() - */ - public Builder name(String name) { - this.name = name; - return this; - } - - /** - * @see Dataset#getOs() - */ - public Builder os(String os) { - this.os = os; - return this; - } - - /** - * @see Dataset#getType() - */ - public Builder type(Type type) { - this.type = type; - return this; - } - - /** - * @see Dataset#getDescription() - */ - public Builder description(String description) { - this.description = description; - return this; - } - - /** - * @see Dataset#isDefault() - */ - public Builder isDefault(boolean isDefault) { - this.isDefault = isDefault; - return this; - } - - - /** - * @see Dataset#getRequirements() - */ - public Builder requirements(Map requirements) { - this.requirements = ImmutableMap. builder(); - this.requirements.putAll(checkNotNull(requirements, "requirements")); - return this; - } - - /** - * @see Dataset#getRequirements() - */ - public Builder addRequirement(String name, JsonBall values) { - this.requirements.put(checkNotNull(name, "name"), checkNotNull(values, "value of %s", name)); - return this; - } - - /** - * @see Dataset#getVersion() - */ - public Builder version(String version) { - this.version = version; - return this; - } - - /** - * @see Dataset#getCreated() - */ - public Builder created(Date created) { - this.created = created; - return this; - } - - public Dataset build() { - return new Dataset(id, urn, name, os, type, description, isDefault, requirements.build(), version, - created); - } - - public Builder fromDataset(Dataset in) { - return id(in.getId()).urn(in.getUrn()).name(in.getName()).os(in.getOs()).type(in.getType()).description(in.getDescription()) - .isDefault(in.isDefault()).requirements(in.requirements).version(in.getVersion()).created(in.getCreated()); - } - } - - private final String id; - private final String name; - private final String os; - private final String urn; - private final Type type; - private final String description; - @Named("default") - private final boolean isDefault; - private final Map requirements; - private final String version; - private final Date created; - - @ConstructorProperties({ "id", "urn", "name", "os", "type", "description", "default", "requirements", "version", - "created" }) - public Dataset(String id, String urn, String name, String os, Type type, String description, boolean isDefault, - Map requirements, String version, Date created) { - this.id = checkNotNull(id, "id"); - this.urn = checkNotNull(urn, "urn of dataset(%s)", id); - this.name = checkNotNull(name, "name of dataset(%s)", id); - this.os = checkNotNull(os, "os of dataset(%s)", id); - this.type = checkNotNull(type, "type of dataset(%s)", id); - this.description = checkNotNull(description, "description of dataset(%s)", id); - this.isDefault = isDefault; - this.requirements = ImmutableMap.copyOf(checkNotNull(requirements, "requirements of dataset(%s)", id)); - this.version = checkNotNull(version, "version of dataset(%s)", id); - this.created = checkNotNull(created, "created of dataset(%s)", id); - } - - /** - * The globally unique id for this dataset - */ - public String getId() { - return id; - } - - /** - * The full URN for this dataset - */ - public String getUrn() { - return urn; - } - - /** - * The friendly name for this dataset - */ - public String getName() { - return name; - } - - /** - * The underlying operating system for this dataset - */ - public String getOs() { - return os; - } - - /** - * Whether this is a smartmachine or virtualmachine dataset - */ - public Type getType() { - return type; - } - - /** - * The description of this dataset - */ - public String getDescription() { - return description; - } - - /** - * Whether this is the default dataset in this datacenter - */ - public boolean isDefault() { - return isDefault; - } - - /** - * If the value is a string, it will be quoted, as that's how json strings are represented. - * - * @return key to a json literal of the value - * @see #getRequirements - * @see Json#fromJson - */ - public Map getRequirementsAsJsonLiterals() { - return Maps.transformValues(requirements, Functions.toStringFunction()); - } - - /** - * Contains a grouping of various minimum requirements for provisioning a machine with this - * dataset. For example 'password' indicates that a password must be provided. - * - *

Note

- * - * requirements can contain arbitrarily complex values. If the value has structure, you should - * use {@link #getRequirementsAsJsonLiterals} - */ - public Map getRequirements() { - return Maps.transformValues(requirements, Functions.compose(Functions.toStringFunction(), unquoteString)); - } - - /** - * The version for this dataset - */ - public String getVersion() { - return version; - } - - /** - * When the dataset was created - */ - public Date getCreated() { - return created; - } - - @VisibleForTesting - static final Function unquoteString = new Function() { - - @Override - public String apply(JsonBall input) { - String value = input.toString(); - if (value.length() >= 2 && value.charAt(0) == '"' && value.charAt(input.length() - 1) == '"') - return value.substring(1, input.length() - 1); - return value; - } - - }; - - @Override - public boolean equals(Object object) { - if (this == object) { - return true; - } - if (object instanceof Dataset) { - Dataset that = Dataset.class.cast(object); - return Objects.equal(id, that.id); - } else { - return false; - } - } - - @Override - public int hashCode() { - return Objects.hashCode(id); - } - - @Override - public String toString() { - return Objects.toStringHelper("").omitNullValues() - .add("id", id) - .add("urn", urn) - .add("name", name) - .add("os", os) - .add("type", type) - .add("description", description) - .add("default", isDefault) - .add("requirements", requirements) - .add("version", version) - .add("created", created).toString(); - } - - @Override - public int compareTo(Dataset that) { - return ComparisonChain.start() - .compare(this.urn, that.urn) - .compare(this.name, that.name) - .compare(this.os, that.os) - .compare(this.type, that.type) - .compare(this.description, that.description) - .compare(this.version, that.version) - .compare(this.created, that.created) - .compare(this.id, that.id).result(); - } - -} diff --git a/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/domain/Key.java b/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/domain/Key.java deleted file mode 100644 index f3e6f3aa34..0000000000 --- a/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/domain/Key.java +++ /dev/null @@ -1,149 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.joyent.cloudapi.v6_5.domain; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.beans.ConstructorProperties; -import java.util.Date; - -import com.google.common.base.Objects; -import com.google.common.collect.ComparisonChain; - -/** - * Keys are the means by which you operate on your SSH/signing keys. Currently - * CloudAPI supports uploads of public keys in the OpenSSH format. - * - * @author Adrian Cole - * @see docs - */ -public class Key implements Comparable { - - public static Builder builder() { - return new Builder(); - } - - public Builder toBuilder() { - return builder().fromKey(this); - } - - public static class Builder { - private String name; - private String key; - private Date created = new Date(); - - /** - * @see Key#getName() - */ - public Builder name(String name) { - this.name = name; - return this; - } - - /** - * @see Key#get() - */ - public Builder key(String key) { - this.key = key; - return this; - } - - /** - * @see Key#getCreated() - */ - public Builder created(Date created) { - this.created = created; - return this; - } - - public Key build() { - return new Key(name, key, created); - } - - public Builder fromKey(Key in) { - return name(in.getName()).key(in.get()).created(in.getCreated()); - } - } - - protected final String name; - protected final String key; - // don't include created in the http request - protected final transient Date created; - - @ConstructorProperties({ "name", "key", "created" }) - public Key(String name, String key, Date created) { - this.name = checkNotNull(name, "name"); - this.key = checkNotNull(key, "key: OpenSSH formatted public key of key(%s)", name); - this.created = checkNotNull(created, "created date of key(%s)", name); - } - - /** - * Name for this key - */ - public String getName() { - return name; - } - - /** - * OpenSSH formatted public key - */ - public String get() { - return key; - } - - /** - * Date the key was created - */ - public Date getCreated() { - return created; - } - - @Override - public boolean equals(Object object) { - if (this == object) { - return true; - } - if (object instanceof Key) { - Key that = Key.class.cast(object); - return Objects.equal(name, that.name); - } else { - return false; - } - } - - @Override - public int hashCode() { - return Objects.hashCode(name); - } - - @Override - public String toString() { - return Objects.toStringHelper("").omitNullValues() - .add("name", name) - .add("key", key) - .add("created", created).toString(); - } - - @Override - public int compareTo(Key that) { - return ComparisonChain.start() - .compare(this.name, that.name) - .compare(this.created, that.created).result(); - } -} diff --git a/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/domain/Machine.java b/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/domain/Machine.java deleted file mode 100644 index 91f3487541..0000000000 --- a/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/domain/Machine.java +++ /dev/null @@ -1,411 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.joyent.cloudapi.v6_5.domain; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.beans.ConstructorProperties; -import java.util.Date; -import java.util.Map; -import java.util.Set; - -import javax.inject.Named; - -import org.jclouds.domain.JsonBall; - -import com.google.common.annotations.VisibleForTesting; -import com.google.common.base.CaseFormat; -import com.google.common.base.Function; -import com.google.common.base.Functions; -import com.google.common.base.Objects; -import com.google.common.collect.ComparisonChain; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Maps; - -/** - * a SmartMachine or traditional Virtual Machine - * - * @author Gerald Pereira - * @see - */ -public class Machine implements Comparable { - - public static enum Type { - VIRTUALMACHINE, SMARTMACHINE, UNRECOGNIZED; - - public static Type fromValue(String type) { - try { - return valueOf(CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, checkNotNull(type, "type"))); - } catch (IllegalArgumentException e) { - return UNRECOGNIZED; - } - } - - public String value() { - return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, name()); - } - - @Override - public String toString() { - return value(); - } - } - - public static enum State { - PROVISIONING, RUNNING, STOPPING, STOPPED, OFFLINE, DELETED, UNRECOGNIZED; - - public static State fromValue(String state) { - try { - return valueOf(CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, checkNotNull(state, "state"))); - } catch (IllegalArgumentException e) { - return UNRECOGNIZED; - } - } - - public String value() { - return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, name()); - } - - @Override - public String toString() { - return value(); - } - } - - public static Builder builder() { - return new Builder(); - } - - public Builder toBuilder() { - return new Builder().fromMachine(this); - } - - public static class Builder { - private String id; - private String name; - private Type type; - private State state; - private String dataset; - private int memorySizeMb; - private int diskSizeGb; - private ImmutableSet.Builder ips = ImmutableSet. builder(); - private Date created; - private Date updated; - private ImmutableMap.Builder metadata = ImmutableMap.builder(); - - /** - * @see Machine#getId() - */ - public Builder id(String id) { - this.id = id; - return this; - } - - /** - * @see Machine#getName() - */ - public Builder name(String name) { - this.name = name; - return this; - } - - /** - * @see Machine#getType() - */ - public Builder type(Type type) { - this.type = type; - return this; - } - - /** - * @see Machine#getState() - */ - public Builder state(State state) { - this.state = state; - return this; - } - - /** - * @see Machine#getDatasetURN() - */ - public Builder dataset(String dataset) { - this.dataset = dataset; - return this; - } - - /** - * @see Machine#getMemorySizeMb() - */ - public Builder memorySizeMb(int memorySizeMb) { - this.memorySizeMb = memorySizeMb; - return this; - } - - /** - * @see Machine#getDiskSizeGb() - */ - public Builder diskSizeGb(int diskSizeGb) { - this.diskSizeGb = diskSizeGb; - return this; - } - - /** - * @see Machine#getIps() - */ - public Builder ips(Set ips) { - this.ips = ImmutableSet. builder(); - this.ips.addAll(checkNotNull(ips, "ips")); - return this; - } - - /** - * @see Machine#getIps() - */ - public Builder addIp(String ip) { - this.ips.add(checkNotNull(ip, "ip")); - return this; - } - - /** - * @see Machine#getCreated() - */ - public Builder created(Date created) { - this.created = created; - return this; - } - - /** - * @see Machine#getUpdated() - */ - public Builder updated(Date updated) { - this.updated = updated; - return this; - } - - /** - * @see Machine#getMetadata() - */ - public Builder metadata(Map metadata) { - this.metadata = ImmutableMap. builder(); - this.metadata.putAll(checkNotNull(metadata, "metadata")); - return this; - } - - /** - * @see Machine#getMetadata() - */ - public Builder addMetadata(String name, JsonBall values) { - this.metadata.put(checkNotNull(name, "name"), checkNotNull(values, "value of %s", name)); - return this; - } - - public Machine build() { - return new Machine(id, name, type, state, dataset, memorySizeMb, diskSizeGb, ips.build(), created, updated, metadata.build()); - } - - public Builder fromMachine(Machine in) { - return id(in.getId()).name(in.getName()).type(in.getType()).state(in.getState()).dataset(in.getDatasetURN()) - .memorySizeMb(in.getMemorySizeMb()).diskSizeGb(in.getDiskSizeGb()).ips(in.getIps()) - .metadata(in.metadata).created(in.getCreated()).updated(in.getUpdated()); - } - } - - protected final String id; - protected final String name; - protected final Type type; - protected final State state; - protected final String dataset; - @Named("memory") - protected final int memorySizeMb; - @Named("disk") - protected final int diskSizeGb; - protected final Set ips; - protected final Date created; - protected final Date updated; - - // metadata Object[String => String] Any "extra" metadata this machine has - private final Map metadata; - - @ConstructorProperties({ "id", "name", "type", "state", "dataset", "memory", "disk", "ips", "created", "updated", "metadata" }) - public Machine(String id, String name, Type type, State state, String dataset, int memorySizeMb, int diskSizeGb, - Set ips, Date created, Date updated, final Map metadata) { - this.id = checkNotNull(id, "id"); - this.name = checkNotNull(name, "name of machine(%s)", id); - this.type = checkNotNull(type, "type of machine(%s)", id); - this.state = checkNotNull(state, "state of machine(%s)", id); - this.dataset = checkNotNull(dataset, "dataset of machine(%s)", id); - this.memorySizeMb = memorySizeMb; - this.diskSizeGb = diskSizeGb; - this.ips = ImmutableSet. copyOf(checkNotNull(ips, "ips of machine(%s)", id)); - this.created = checkNotNull(created, "created date of machine(%s)", id); - this.updated = checkNotNull(created, "updated date of machine(%s)", id); - this.metadata = ImmutableMap. copyOf(checkNotNull(metadata, "metadata of machine(%s)", id)); - } - - /** - * The globally unique id for this machine - */ - public String getId() { - return id; - } - - /** - * The "friendly" name for this machine - */ - public String getName() { - return name; - } - - /** - * Whether this is a smartmachine or virtualmachine - */ - public Type getType() { - return type; - } - - /** - * The current state of this machine - */ - public State getState() { - return state; - } - - /** - * The dataset urn this machine was provisioned with - */ - public String getDatasetURN() { - return dataset; - } - - /** - * The amount of memory this machine has (Mb) - */ - public int getMemorySizeMb() { - return memorySizeMb; - } - - /** - * The amount of disk this machine has (Gb) - */ - public int getDiskSizeGb() { - return diskSizeGb; - } - - /** - * The IP addresses this machine has - */ - public Set getIps() { - return ips; - } - - /** - * When this machine was created - */ - public Date getCreated() { - return created; - } - - /** - * When this machine was updated - */ - public Date getUpdated() { - return updated; - } - - /** - * - *

note

- * - * If the value is a string, it will be quoted, as that's how json strings are represented. - * - * @return key to a json literal of the value - * @see Metadata#valueType - * @see Json#fromJson - */ - public Map getMetadataAsJsonLiterals() { - return Maps.transformValues(metadata, Functions.toStringFunction()); - } - - /** - * Any "extra" metadata this machine has - * - *

note

- * - * metadata can contain arbitrarily complex values. If the value has structure, you should use - * {@link #getMetadataAsJsonLiterals} - * - */ - public Map getMetadata() { - return Maps.transformValues(metadata, Functions.compose(Functions.toStringFunction(), unquoteString)); - } - - @VisibleForTesting - static final Function unquoteString = new Function() { - - @Override - public String apply(JsonBall input) { - String value = input.toString(); - if (value.length() >= 2 && value.charAt(0) == '"' && value.charAt(input.length() - 1) == '"') - return value.substring(1, input.length() - 1); - return value; - } - - }; - - @Override - public boolean equals(Object object) { - if (this == object) { - return true; - } - if (object instanceof Machine) { - Machine that = Machine.class.cast(object); - return Objects.equal(id, that.id); - } else { - return false; - } - } - - @Override - public int hashCode() { - return Objects.hashCode(id); - } - - @Override - public String toString() { - return Objects.toStringHelper("").omitNullValues() - .add("id", id) - .add("name", name) - .add("type", type) - .add("state", state) - .add("memorySizeMb", memorySizeMb) - .add("diskSizeGb", diskSizeGb) - .add("ips", ips) - .add("created", created) - .add("updated", updated).toString(); - } - - @Override - public int compareTo(Machine that) { - return ComparisonChain.start() - .compare(this.name, that.name) - .compare(this.created, that.created) - .compare(this.id, that.id).result(); - } -} diff --git a/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/domain/Package.java b/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/domain/Package.java deleted file mode 100644 index 745cc23b04..0000000000 --- a/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/domain/Package.java +++ /dev/null @@ -1,195 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.joyent.cloudapi.v6_5.domain; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.beans.ConstructorProperties; - -import javax.inject.Named; - -import com.google.common.base.Objects; -import com.google.common.collect.ComparisonChain; - -/** - * Packages are named collections of resources that are used to describe the ‘sizes’ of either a - * smart machine or a virtual machine. These resources include (but are not limited to) RAM, CPUs, - * CPU Caps, Lightweight Threads, Disk Space, Swap size, and Logical Networks. - * - * @author Gerald Pereira - * @see
docs - */ -public class Package implements Comparable { - - public static Builder builder() { - return new Builder(); - } - - public Builder toBuilder() { - return new Builder().fromPackage(this); - } - - public static class Builder { - private String name; - private int memorySizeMb; - private int diskSizeGb; - private int swapSizeMb; - private boolean isDefault; - - /** - * @see Package#getName() - */ - public Builder name(String name) { - this.name = name; - return this; - } - - /** - * @see Package#getMemorySizeMb() - */ - public Builder memorySizeMb(int memorySizeMb) { - this.memorySizeMb = memorySizeMb; - return this; - } - - /** - * @see Package#getDiskSizeGb() - */ - public Builder diskSizeGb(int diskSizeGb) { - this.diskSizeGb = diskSizeGb; - return this; - } - - /** - * @see Package#getSwapSizeMb() - */ - public Builder swapSizeMb(int swapSizeMb) { - this.swapSizeMb = swapSizeMb; - return this; - } - - /** - * @see Package#isDefault() - */ - public Builder isDefault(boolean isDefault) { - this.isDefault = isDefault; - return this; - } - - public Package build() { - return new Package(name, memorySizeMb, diskSizeGb, swapSizeMb, isDefault); - } - - public Builder fromPackage(Package in) { - return name(in.getName()).memorySizeMb(in.getMemorySizeMb()).diskSizeGb(in.getDiskSizeGb()) - .swapSizeMb(in.getSwapSizeMb()).isDefault(in.isDefault()); - } - } - - protected final String name; - @Named("memory") - protected final int memorySizeMb; - @Named("disk") - protected final int diskSizeGb; - @Named("swap") - protected final int swapSizeMb; - @Named("default") - protected final boolean isDefault; - - @ConstructorProperties({ "name", "memory", "disk", "swap", "default" }) - public Package(String name, int memorySizeMb, int diskSizeGb, int swapSizeMb, boolean isDefault) { - this.name = checkNotNull(name, "name"); - this.memorySizeMb = memorySizeMb; - this.diskSizeGb = diskSizeGb; - this.swapSizeMb = swapSizeMb; - this.isDefault = isDefault; - } - - /** - * The "friendly name for this package - */ - public String getName() { - return name; - } - - /** - * How much memory will by available (in Mb) - */ - public int getMemorySizeMb() { - return memorySizeMb; - } - - /** - * How much disk space will be available (in Gb) - */ - public int getDiskSizeGb() { - return diskSizeGb; - } - - /** - * How much swap memory will be available (in Mb) - */ - public int getSwapSizeMb() { - return swapSizeMb; - } - - /** - * Whether this is the default package in this datacenter - */ - public boolean isDefault() { - return isDefault; - } - - @Override - public boolean equals(Object object) { - if (this == object) { - return true; - } - if (object instanceof Package) { - Package that = Package.class.cast(object); - return Objects.equal(name, that.name); - } else { - return false; - } - } - - @Override - public int hashCode() { - return Objects.hashCode(name); - } - - @Override - public String toString() { - return Objects.toStringHelper("").omitNullValues() - .add("name", name) - .add("memorySizeMb", memorySizeMb) - .add("diskSizeGb", diskSizeGb) - .add("swapSizeMb", swapSizeMb) - .add("isDefault", isDefault).toString(); - } - - @Override - public int compareTo(Package that) { - return ComparisonChain.start() - .compare(this.name, that.name) - .compare(this.memorySizeMb, that.memorySizeMb) - .compare(this.diskSizeGb, that.diskSizeGb) - .compare(this.swapSizeMb, that.swapSizeMb).result(); - } -} diff --git a/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/domain/datacenterscoped/DatacenterAndId.java b/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/domain/datacenterscoped/DatacenterAndId.java deleted file mode 100644 index 93c1a5b145..0000000000 --- a/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/domain/datacenterscoped/DatacenterAndId.java +++ /dev/null @@ -1,88 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.joyent.cloudapi.v6_5.domain.datacenterscoped; - -import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.base.Preconditions.checkNotNull; - -import com.google.common.base.Objects; -import com.google.common.base.Splitter; -import com.google.common.collect.Iterables; - -/** - * @author Adrian Cole - */ -public class DatacenterAndId { - public static DatacenterAndId fromSlashEncoded(String id) { - Iterable parts = Splitter.on('/').split(checkNotNull(id, "id")); - checkArgument(Iterables.size(parts) == 2, "id must be in format datacenterId/id"); - return new DatacenterAndId(Iterables.get(parts, 0), Iterables.get(parts, 1)); - } - - public static DatacenterAndId fromDatacenterAndId(String datacenterId, String id) { - return new DatacenterAndId(datacenterId, id); - } - - private static String slashEncodeDatacenterAndId(String datacenterId, String id) { - return checkNotNull(datacenterId, "datacenterId") + "/" + checkNotNull(id, "id"); - } - - public String slashEncode() { - return slashEncodeDatacenterAndId(datacenterId, id); - } - - protected final String datacenterId; - protected final String id; - - protected DatacenterAndId(String datacenterId, String id) { - this.datacenterId = checkNotNull(datacenterId, "datacenterId"); - this.id = checkNotNull(id, "id"); - } - - @Override - public int hashCode() { - return Objects.hashCode(datacenterId, id); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - DatacenterAndId other = (DatacenterAndId) obj; - return Objects.equal(datacenterId, other.datacenterId) && Objects.equal(id, other.id); - } - - public String getDatacenter() { - return datacenterId; - } - - public String getId() { - return id; - } - - @Override - public String toString() { - return "[datacenterId=" + datacenterId + ", id=" + id + "]"; - } - -} diff --git a/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/domain/datacenterscoped/DatacenterAndName.java b/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/domain/datacenterscoped/DatacenterAndName.java deleted file mode 100644 index bb3092261f..0000000000 --- a/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/domain/datacenterscoped/DatacenterAndName.java +++ /dev/null @@ -1,113 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.joyent.cloudapi.v6_5.domain.datacenterscoped; - -import static com.google.common.base.Objects.equal; -import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.base.Preconditions.checkNotNull; - -import com.google.common.base.Function; -import com.google.common.base.Objects; -import com.google.common.base.Splitter; -import com.google.common.base.Objects.ToStringHelper; -import com.google.common.collect.Iterables; - -/** - * Helpful when looking for resources by datacenter and name - * - * @author Adrian Cole - */ -public class DatacenterAndName { - - public static final Function NAME_FUNCTION = new Function(){ - - @Override - public String apply(DatacenterAndName input) { - return input.getName(); - } - - }; - - public static final Function DATACENTER_FUNCTION = new Function(){ - - @Override - public String apply(DatacenterAndName input) { - return input.getDatacenter(); - } - - }; - - public static DatacenterAndName fromSlashEncoded(String name) { - Iterable parts = Splitter.on('/').split(checkNotNull(name, "name")); - checkArgument(Iterables.size(parts) == 2, "name must be in format datacenterId/name"); - return new DatacenterAndName(Iterables.get(parts, 0), Iterables.get(parts, 1)); - } - - public static DatacenterAndName fromDatacenterAndName(String datacenterId, String name) { - return new DatacenterAndName(datacenterId, name); - } - - private static String slashEncodeDatacenterAndName(String datacenterId, String name) { - return checkNotNull(datacenterId, "datacenterId") + "/" + checkNotNull(name, "name"); - } - - public String slashEncode() { - return slashEncodeDatacenterAndName(datacenterId, name); - } - - protected final String datacenterId; - protected final String name; - - protected DatacenterAndName(String datacenterId, String name) { - this.datacenterId = checkNotNull(datacenterId, "datacenterId"); - this.name = checkNotNull(name, "name"); - } - - public String getDatacenter() { - return datacenterId; - } - - public String getName() { - return name; - } - - @Override - public boolean equals(Object o) { - if (this == o) - return true; - if (o == null || getClass() != o.getClass()) - return false; - DatacenterAndName that = DatacenterAndName.class.cast(o); - return equal(this.datacenterId, that.datacenterId) && equal(this.name, that.name); - } - - @Override - public int hashCode() { - return Objects.hashCode(datacenterId, name); - } - - @Override - public String toString() { - return string().toString(); - } - - protected ToStringHelper string() { - return Objects.toStringHelper("").add("datacenterId", datacenterId).add("name", name); - } -} diff --git a/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/domain/datacenterscoped/DatasetInDatacenter.java b/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/domain/datacenterscoped/DatasetInDatacenter.java deleted file mode 100644 index d164787ced..0000000000 --- a/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/domain/datacenterscoped/DatasetInDatacenter.java +++ /dev/null @@ -1,48 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.joyent.cloudapi.v6_5.domain.datacenterscoped; - -import static com.google.common.base.Preconditions.checkNotNull; - -import org.jclouds.joyent.cloudapi.v6_5.domain.Dataset; - -/** - * @author Adrian Cole - */ -public class DatasetInDatacenter extends DatacenterAndId { - protected final Dataset dataset; - - public DatasetInDatacenter(Dataset dataset, String datacenterId) { - super(datacenterId, checkNotNull(dataset, "dataset").getUrn()); - this.dataset = dataset; - } - - public Dataset get() { - return dataset; - } - - // superclass hashCode/equals are good enough, and help us use DatacenterAndId and DatasetInDatacenter - // interchangeably as Map keys - - @Override - public String toString() { - return "[dataset=" + dataset + ", datacenterId=" + datacenterId + "]"; - } - -} diff --git a/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/domain/datacenterscoped/KeyInDatacenter.java b/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/domain/datacenterscoped/KeyInDatacenter.java deleted file mode 100644 index 62206dbd38..0000000000 --- a/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/domain/datacenterscoped/KeyInDatacenter.java +++ /dev/null @@ -1,48 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.joyent.cloudapi.v6_5.domain.datacenterscoped; - -import static com.google.common.base.Preconditions.checkNotNull; - -import org.jclouds.joyent.cloudapi.v6_5.domain.Key; - -/** - * @author Adrian Cole - */ -public class KeyInDatacenter extends DatacenterAndName { - protected final Key key; - - public KeyInDatacenter(Key key, String datacenterId) { - super(datacenterId, checkNotNull(key, "key").getName()); - this.key = key; - } - - public Key get() { - return key; - } - - // superclass hashCode/equals are good enough, and help us use DatacenterAndId and PackageInDatacenter - // interchangeably as Map keys - - @Override - public String toString() { - return "[key=" + key + ", datacenterId=" + datacenterId + "]"; - } - -} diff --git a/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/domain/datacenterscoped/MachineInDatacenter.java b/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/domain/datacenterscoped/MachineInDatacenter.java deleted file mode 100644 index 5fc4eed2b3..0000000000 --- a/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/domain/datacenterscoped/MachineInDatacenter.java +++ /dev/null @@ -1,48 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.joyent.cloudapi.v6_5.domain.datacenterscoped; - -import static com.google.common.base.Preconditions.checkNotNull; - -import org.jclouds.joyent.cloudapi.v6_5.domain.Machine; - -/** - * @author Adrian Cole - */ -public class MachineInDatacenter extends DatacenterAndId { - protected final Machine machine; - - public MachineInDatacenter(Machine machine, String datacenterId) { - super(datacenterId, checkNotNull(machine, "machine").getId()); - this.machine = machine; - } - - public Machine get() { - return machine; - } - - // superclass hashCode/equals are good enough, and help us use DatacenterAndId and MachineInDatacenter - // interchangeably as Map keys - - @Override - public String toString() { - return "[machine=" + machine + ", datacenterId=" + datacenterId + "]"; - } - -} diff --git a/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/domain/datacenterscoped/PackageInDatacenter.java b/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/domain/datacenterscoped/PackageInDatacenter.java deleted file mode 100644 index 672c94ee5a..0000000000 --- a/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/domain/datacenterscoped/PackageInDatacenter.java +++ /dev/null @@ -1,46 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.joyent.cloudapi.v6_5.domain.datacenterscoped; - -import static com.google.common.base.Preconditions.checkNotNull; - -/** - * @author Adrian Cole - */ -public class PackageInDatacenter extends DatacenterAndName { - protected final org.jclouds.joyent.cloudapi.v6_5.domain.Package pkg; - - public PackageInDatacenter(org.jclouds.joyent.cloudapi.v6_5.domain.Package pkg, String datacenterId) { - super(datacenterId, checkNotNull(pkg, "pkg").getName()); - this.pkg = pkg; - } - - public org.jclouds.joyent.cloudapi.v6_5.domain.Package get() { - return pkg; - } - - // superclass hashCode/equals are good enough, and help us use DatacenterAndId and PackageInDatacenter - // interchangeably as Map keys - - @Override - public String toString() { - return "[pkg=" + pkg + ", datacenterId=" + datacenterId + "]"; - } - -} diff --git a/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/features/DatacenterApi.java b/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/features/DatacenterApi.java deleted file mode 100644 index 7d3f345d1e..0000000000 --- a/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/features/DatacenterApi.java +++ /dev/null @@ -1,38 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.joyent.cloudapi.v6_5.features; - -import java.net.URI; -import java.util.Map; -/** - * Datacenter Services - * - * @see DatacenterAsyncApi - * @author Adrian Cole - * @see api doc - */ -public interface DatacenterApi { - - /** - * Provides a list of all datacenters this cloud is aware of. - * - * @return keys are the datacenter name, and the value is the URL. - */ - Map getDatacenters(); -} diff --git a/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/features/DatacenterAsyncApi.java b/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/features/DatacenterAsyncApi.java deleted file mode 100644 index d01a6eccbf..0000000000 --- a/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/features/DatacenterAsyncApi.java +++ /dev/null @@ -1,58 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.joyent.cloudapi.v6_5.features; - -import java.net.URI; -import java.util.Map; - -import javax.inject.Named; -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.core.MediaType; - -import org.jclouds.Fallbacks.EmptyMapOnNotFoundOr404; -import org.jclouds.http.filters.BasicAuthentication; -import org.jclouds.rest.annotations.Fallback; -import org.jclouds.rest.annotations.Headers; -import org.jclouds.rest.annotations.RequestFilters; - -import com.google.common.util.concurrent.ListenableFuture; - -/** - * Datacenter Services - * - * @see DatacenterApi - * @author Adrian Cole - * @see api doc - */ -@Headers(keys = "X-Api-Version", values = "{jclouds.api-version}") -@RequestFilters(BasicAuthentication.class) -public interface DatacenterAsyncApi { - - /** - * @see DatacenterApi#getDatacenters - */ - @Named("ListDataCenters") - @GET - @Path("/my/datacenters") - @Consumes(MediaType.APPLICATION_JSON) - @Fallback(EmptyMapOnNotFoundOr404.class) - ListenableFuture> getDatacenters(); -} diff --git a/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/features/DatasetApi.java b/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/features/DatasetApi.java deleted file mode 100644 index 20894294dd..0000000000 --- a/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/features/DatasetApi.java +++ /dev/null @@ -1,31 +0,0 @@ -package org.jclouds.joyent.cloudapi.v6_5.features; - -import java.util.Set; -import org.jclouds.joyent.cloudapi.v6_5.domain.Dataset; - -/** - * Provides synchronous access to Datasets. - *

- * - * @author Gerald Pereira - * @see DatasetAsyncApi - * @see api doc - */ -public interface DatasetApi { - - /** - * Provides a list of datasets available in this datacenter. - * - * @return - */ - Set list(); - - /** - * Gets an individual dataset by id. - * - * @param id - * the id of the dataset - * @return - */ - Dataset get(String id); -} diff --git a/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/features/DatasetAsyncApi.java b/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/features/DatasetAsyncApi.java deleted file mode 100644 index c7fb3e6e7a..0000000000 --- a/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/features/DatasetAsyncApi.java +++ /dev/null @@ -1,52 +0,0 @@ -package org.jclouds.joyent.cloudapi.v6_5.features; - -import java.util.Set; - -import javax.inject.Named; -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.core.MediaType; - -import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404; -import org.jclouds.Fallbacks.NullOnNotFoundOr404; -import org.jclouds.http.filters.BasicAuthentication; -import org.jclouds.joyent.cloudapi.v6_5.domain.Dataset; -import org.jclouds.rest.annotations.Fallback; -import org.jclouds.rest.annotations.Headers; -import org.jclouds.rest.annotations.RequestFilters; - -import com.google.common.util.concurrent.ListenableFuture; - -/** - * Provides asynchronous access to Dataset via their REST API. - *

- * - * @author Gerald Pereira - * @see DatasetApi - * @see api doc - */ -@Headers(keys = "X-Api-Version", values = "{jclouds.api-version}") -@RequestFilters(BasicAuthentication.class) -public interface DatasetAsyncApi { - /** - * @see DatasetApi#list - */ - @Named("ListDatasets") - @GET - @Path("/my/datasets") - @Consumes(MediaType.APPLICATION_JSON) - @Fallback(EmptySetOnNotFoundOr404.class) - ListenableFuture> list(); - - /** - * @see DatasetApi#get - */ - @Named("GetDataset") - @GET - @Path("/my/datasets/{id}") - @Consumes(MediaType.APPLICATION_JSON) - @Fallback(NullOnNotFoundOr404.class) - ListenableFuture get(@PathParam("id") String id); -} diff --git a/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/features/KeyApi.java b/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/features/KeyApi.java deleted file mode 100644 index b070160f3e..0000000000 --- a/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/features/KeyApi.java +++ /dev/null @@ -1,36 +0,0 @@ -package org.jclouds.joyent.cloudapi.v6_5.features; - -import java.util.Set; -import org.jclouds.joyent.cloudapi.v6_5.domain.Key; - -/** - * Keys are the means by which you operate on your SSH/signing keys. Currently - * CloudAPI supports uploads of public keys in the OpenSSH format. - * - * @author Adrian Cole - * @see KeyAsyncApi - * @see api doc - */ -public interface KeyApi { - - /** - * Lists all public keys we have on record for the specified account. - */ - Set list(); - - /** - * Retrieves an individual key record. - */ - Key get(String name); - - /** - * Uploads a new OpenSSH key to SmartDataCenter for use in SSH and HTTP - * signing. - */ - Key create(Key key); - - /** - * Deletes an SSH key by name. - */ - void delete(String name); -} diff --git a/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/features/KeyAsyncApi.java b/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/features/KeyAsyncApi.java deleted file mode 100644 index b2e5d2f998..0000000000 --- a/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/features/KeyAsyncApi.java +++ /dev/null @@ -1,74 +0,0 @@ -package org.jclouds.joyent.cloudapi.v6_5.features; - -import java.util.Set; - -import javax.inject.Named; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.core.MediaType; - -import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404; -import org.jclouds.Fallbacks.NullOnNotFoundOr404; -import org.jclouds.Fallbacks.VoidOnNotFoundOr404; -import org.jclouds.http.filters.BasicAuthentication; -import org.jclouds.joyent.cloudapi.v6_5.domain.Key; -import org.jclouds.rest.annotations.BinderParam; -import org.jclouds.rest.annotations.Fallback; -import org.jclouds.rest.annotations.Headers; -import org.jclouds.rest.annotations.RequestFilters; -import org.jclouds.rest.binders.BindToJsonPayload; - -import com.google.common.util.concurrent.ListenableFuture; - -/** - * @author Adrian Cole - * @see KeyApi - * @see api doc - */ -@Headers(keys = "X-Api-Version", values = "{jclouds.api-version}") -@RequestFilters(BasicAuthentication.class) -public interface KeyAsyncApi { - /** - * @see KeyApi#list - */ - @Named("ListKeys") - @GET - @Path("/my/keys") - @Consumes(MediaType.APPLICATION_JSON) - @Fallback(EmptySetOnNotFoundOr404.class) - ListenableFuture> list(); - - /** - * @see KeyApi#get - */ - @Named("GetKey") - @GET - @Path("/my/keys/{name}") - @Consumes(MediaType.APPLICATION_JSON) - @Fallback(NullOnNotFoundOr404.class) - ListenableFuture get(@PathParam("name") String name); - - /** - * @see KeyApi#create - */ - @Named("CreateKey") - @POST - @Path("/my/keys") - @Consumes(MediaType.APPLICATION_JSON) - ListenableFuture create(@BinderParam(BindToJsonPayload.class) Key key); - - /** - * @see KeyApi#delete - */ - @Named("DeleteKey") - @DELETE - @Consumes(MediaType.APPLICATION_JSON) - @Path("/my/keys/{name}") - @Fallback(VoidOnNotFoundOr404.class) - ListenableFuture delete(@PathParam("name") String name); - -} diff --git a/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/features/MachineApi.java b/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/features/MachineApi.java deleted file mode 100644 index c1b317db4b..0000000000 --- a/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/features/MachineApi.java +++ /dev/null @@ -1,134 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.joyent.cloudapi.v6_5.features; - -import java.util.Set; -import org.jclouds.joyent.cloudapi.v6_5.domain.Machine; -import org.jclouds.joyent.cloudapi.v6_5.options.CreateMachineOptions; - -/** - * Provides synchronous access to Machine. - *

- * - * @author Gerald Pereira - * @see MachineAsyncApi - * @see api doc - */ -public interface MachineApi { - - /** - * Lists all machines we have on record for your account. - * - * @return an account's associated machine objects. - */ - Set list(); - - /** - * Gets the details for an individual machine. - * - * @param id - * the id of the machine - * @return - */ - Machine get(String id); - - /** - * Allows you to provision a machine. Note that if you do not specify a - * package, you'll get the datacenter defaults for it. If - * you do not specify a name, CloudAPI will generate a random one for you. - * Your machine will initially be not available for login (SmartDataCenter - * must provision and boot it). You can poll {@link #get} for status. When the - * state field is equal to running, you can login. - * - *

- * With regards to login, if the machine is of type smartmachine, you can use - * any of the SSH keys managed under the keys section of CloudAPI to login, - * as any POSIX user on the OS. You can add/remove them over time, and the - * machine will automatically work with that set. - * - *

- * If the the machine is a virtualmachine, and of a UNIX-derived OS (e.g. - * Linux), you must have keys uploaded before provisioning; that entire set - * of keys will be written out to /root/.ssh/authorized_keys, and you can ssh - * in using one of those. Changing the keys over time under your account will - * not affect the running virtual machine in any way; those keys are - * statically written at provisioning-time only, and you will need to - * manually manage them. - * - *

- * If the dataset you create a machine from is set to generate passwords for - * you, the username/password pairs will be returned in the metadata response - * as a nested object, like: - * - * @param datasetURN urn of the dataset to install - * - * @return the newly created machine - */ - Machine createWithDataset(String datasetURN, CreateMachineOptions options); - - /** - * - * @see #createWithDataset(CreateMachineOptions) - */ - Machine createWithDataset(String datasetURN); - - /** - * Allows you to shut down a machine. - * - * @param id - * the id of the machine to stop - */ - void stop(String id); - - /** - * Allows you to boot up a machine. - * - * @param id - * the id of the machine to start - */ - void start(String id); - - /** - * Allows you to reboot a machine. - * - * @param id - * the id of the machine to reboot - */ - void reboot(String id); - - /** - * Allows you to resize a machine. (Works only for smart machines) - * - * @param id - * the id of the machine to resize - * @param packageJoyentCloud - * the package to use for the machine - */ - void resize(String id, String packageJoyentCloud); - - /** - * Allows you to delete a machine (the machine must be stopped before it can - * be deleted). - * - * @param id - * the id of the machine to delete - */ - void delete(String id); - -} diff --git a/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/features/MachineAsyncApi.java b/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/features/MachineAsyncApi.java deleted file mode 100644 index 492564de26..0000000000 --- a/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/features/MachineAsyncApi.java +++ /dev/null @@ -1,152 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.joyent.cloudapi.v6_5.features; - -import java.util.Set; - -import javax.inject.Named; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.MediaType; - -import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404; -import org.jclouds.Fallbacks.NullOnNotFoundOr404; -import org.jclouds.Fallbacks.VoidOnNotFoundOr404; -import org.jclouds.http.filters.BasicAuthentication; -import org.jclouds.joyent.cloudapi.v6_5.domain.Machine; -import org.jclouds.joyent.cloudapi.v6_5.options.CreateMachineOptions; -import org.jclouds.rest.annotations.Fallback; -import org.jclouds.rest.annotations.Headers; -import org.jclouds.rest.annotations.Payload; -import org.jclouds.rest.annotations.PayloadParam; -import org.jclouds.rest.annotations.RequestFilters; - -import com.google.common.util.concurrent.ListenableFuture; - -/** - * Provides asynchronous access to Machine via their REST API. - *

- * - * @author Gerald Pereira - * @see MachineApi - * @see api doc - */ -@Headers(keys = "X-Api-Version", values = "{jclouds.api-version}") -@RequestFilters(BasicAuthentication.class) -public interface MachineAsyncApi { - - /** - * @see MachineApi#list - */ - @Named("ListMachines") - @GET - @Path("/my/machines") - @Consumes(MediaType.APPLICATION_JSON) - @Fallback(EmptySetOnNotFoundOr404.class) - ListenableFuture> list(); - - /** - * @see MachineApi#get - */ - @Named("GetMachine") - @GET - @Path("/my/machines/{id}") - @Consumes(MediaType.APPLICATION_JSON) - @Fallback(NullOnNotFoundOr404.class) - ListenableFuture get(@PathParam("id") String id); - - /** - * @see MachineApi#createWithDataset(String) - */ - @Named("CreateMachine") - @POST - @Path("/my/machines") - @Consumes(MediaType.APPLICATION_JSON) - ListenableFuture createWithDataset(@QueryParam("dataset") String datasetURN); - - /** - * @see MachineApi#createWithDataset(String, CreateMachineOptions) - */ - @Named("CreateMachine") - @POST - @Path("/my/machines") - @Consumes(MediaType.APPLICATION_JSON) - ListenableFuture createWithDataset(@QueryParam("dataset") String datasetURN, CreateMachineOptions options); - - /** - * @see MachineApi#stop - */ - @Named("StopMachine") - @POST - @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.APPLICATION_FORM_URLENCODED) - @Path("/my/machines/{id}") - @Payload("action=stop") - ListenableFuture stop(@PathParam("id") String id); - - /** - * @see MachineApi#start - */ - @Named("StartMachine") - @POST - @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.APPLICATION_FORM_URLENCODED) - @Path("/my/machines/{id}") - @Payload("action=start") - ListenableFuture start(@PathParam("id") String id); - - /** - * @see MachineApi#reboot - */ - @Named("RestartMachine") - @POST - @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.APPLICATION_FORM_URLENCODED) - @Path("/my/machines/{id}") - @Payload("action=reboot") - ListenableFuture reboot(@PathParam("id") String id); - - /** - * @see MachineApi#resize - */ - @Named("ResizeMachine") - @POST - @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.APPLICATION_FORM_URLENCODED) - @Path("/my/machines/{id}") - @Payload("action=resize&package={package}") - ListenableFuture resize(@PathParam("id") String id, @PayloadParam("package") String packageJoyentCloud); - - /** - * @see MachineApi#delete - */ - @Named("DeleteMachine") - @DELETE - @Consumes(MediaType.APPLICATION_JSON) - @Path("/my/machines/{id}") - @Fallback(VoidOnNotFoundOr404.class) - ListenableFuture delete(@PathParam("id") String id); - -} diff --git a/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/features/PackageApi.java b/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/features/PackageApi.java deleted file mode 100644 index a03d23d220..0000000000 --- a/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/features/PackageApi.java +++ /dev/null @@ -1,29 +0,0 @@ -package org.jclouds.joyent.cloudapi.v6_5.features; - -import java.util.Set; -/** - * Provides synchronous access to Packages. - *

- * - * @author Gerald Pereira - * @see PackageAsyncApi - * @see api doc - */ -public interface PackageApi { - - /** - * Provides a list of packages available in this datacenter. - * - * @return - */ - Set list(); - - /** - * Gets an individual package by id. - * - * @param name - * the name of the package - * @return - */ - org.jclouds.joyent.cloudapi.v6_5.domain.Package get(String name); -} diff --git a/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/features/PackageAsyncApi.java b/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/features/PackageAsyncApi.java deleted file mode 100644 index 6b84f975f5..0000000000 --- a/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/features/PackageAsyncApi.java +++ /dev/null @@ -1,51 +0,0 @@ -package org.jclouds.joyent.cloudapi.v6_5.features; - -import java.util.Set; - -import javax.inject.Named; -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.core.MediaType; - -import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404; -import org.jclouds.Fallbacks.NullOnNotFoundOr404; -import org.jclouds.http.filters.BasicAuthentication; -import org.jclouds.rest.annotations.Fallback; -import org.jclouds.rest.annotations.Headers; -import org.jclouds.rest.annotations.RequestFilters; - -import com.google.common.util.concurrent.ListenableFuture; - -/** - * Provides asynchronous access to Dataset via their REST API. - *

- * - * @author Gerald Pereira - * @see PackageApi - * @see api doc - */ -@Headers(keys = "X-Api-Version", values = "{jclouds.api-version}") -@RequestFilters(BasicAuthentication.class) -public interface PackageAsyncApi { - /** - * @see PackageApi#list - */ - @Named("ListPackages") - @GET - @Path("/my/packages") - @Consumes(MediaType.APPLICATION_JSON) - @Fallback(EmptySetOnNotFoundOr404.class) - ListenableFuture> list(); - - /** - * @see PackageApi#get - */ - @Named("GetPackage") - @GET - @Path("/my/packages/{name}") - @Consumes(MediaType.APPLICATION_JSON) - @Fallback(NullOnNotFoundOr404.class) - ListenableFuture get(@PathParam("name") String name); -} diff --git a/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/handlers/JoyentCloudErrorHandler.java b/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/handlers/JoyentCloudErrorHandler.java deleted file mode 100644 index dee1693a77..0000000000 --- a/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/handlers/JoyentCloudErrorHandler.java +++ /dev/null @@ -1,67 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.joyent.cloudapi.v6_5.handlers; - -import static org.jclouds.http.HttpUtils.closeClientButKeepContentStream; - -import javax.inject.Singleton; - -import org.jclouds.http.HttpCommand; -import org.jclouds.http.HttpErrorHandler; -import org.jclouds.http.HttpResponse; -import org.jclouds.http.HttpResponseException; -import org.jclouds.rest.AuthorizationException; -import org.jclouds.rest.ResourceNotFoundException; - -/** - * This will parse and set an appropriate exception on the command object. - * - * @author Adrian Cole - * - */ -@Singleton -public class JoyentCloudErrorHandler implements HttpErrorHandler { - public void handleError(HttpCommand command, HttpResponse response) { - // it is important to always read fully and close streams - byte[] data = closeClientButKeepContentStream(response); - String message = data != null ? new String(data) : null; - - Exception exception = message != null ? new HttpResponseException(command, response, message) - : new HttpResponseException(command, response); - message = message != null ? message : String.format("%s -> %s", command.getCurrentRequest().getRequestLine(), - response.getStatusLine()); - switch (response.getStatusCode()) { - case 400: - break; - case 401: - case 403: - exception = new AuthorizationException(message, exception); - break; - case 404: - if (!command.getCurrentRequest().getMethod().equals("DELETE")) { - exception = new ResourceNotFoundException(message, exception); - } - break; - case 409: - exception = new IllegalStateException(message, exception); - break; - } - command.setException(exception); - } -} diff --git a/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/options/CreateMachineOptions.java b/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/options/CreateMachineOptions.java deleted file mode 100644 index a11c02dbc0..0000000000 --- a/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/options/CreateMachineOptions.java +++ /dev/null @@ -1,145 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.joyent.cloudapi.v6_5.options; - -import static com.google.common.base.Objects.equal; -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.Map; - -import org.jclouds.http.options.BaseHttpRequestOptions; -import org.jclouds.util.Maps2; - -import com.google.common.base.Function; -import com.google.common.base.Objects; -import com.google.common.base.Objects.ToStringHelper; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.Multimap; -import com.google.common.collect.Multimaps; - -/** - * - * @author Adrian Cole - * - */ -public class CreateMachineOptions extends BaseHttpRequestOptions { - private String name; - private String pkg; - private Map metadata = ImmutableMap.of(); - - @Override - public boolean equals(Object object) { - if (this == object) { - return true; - } - if (object instanceof CreateMachineOptions) { - final CreateMachineOptions other = CreateMachineOptions.class.cast(object); - return equal(name, other.name) && equal(pkg, other.pkg) && equal(metadata, other.metadata); - } else { - return false; - } - } - - @Override - public int hashCode() { - return Objects.hashCode(name, pkg, metadata); - } - - @Override - public String toString() { - ToStringHelper toString = Objects.toStringHelper("").omitNullValues(); - toString.add("name", name).add("package", name); - if (metadata.size() > 0) - toString.add("metadata", metadata); - return toString.toString(); - } - - @Override - public Multimap buildQueryParameters() { - Multimap params = super.buildQueryParameters(); - if (name != null) - params.put("name", name); - if (pkg != null) - params.put("package", pkg); - params.putAll(Multimaps.forMap(Maps2.transformKeys(metadata, new Function() { - - @Override - public String apply(String input) { - return "metadata." + input; - } - - }))); - return params; - } - - /** - * friendly name for this machine; default is a randomly generated name - */ - public CreateMachineOptions name(String name) { - this.name = checkNotNull(name, "name"); - return this; - } - - /** - * Name of the package to use on provisioning; default is indicated in - * {@link PackageApi#list} - */ - public CreateMachineOptions packageName(String packageName) { - this.pkg = checkNotNull(packageName, "packageName"); - return this; - } - - /** - * An arbitrary set of metadata key/value pairs. - */ - public CreateMachineOptions metadata(Map metadata) { - checkNotNull(metadata, "metadata"); - this.metadata = ImmutableMap.copyOf(metadata); - return this; - } - - public static class Builder { - - /** - * @see CreateMachineOptions#name - */ - public static CreateMachineOptions name(String name) { - CreateMachineOptions options = new CreateMachineOptions(); - return options.name(name); - } - - /** - * @see CreateMachineOptions#packageName - */ - public static CreateMachineOptions packageName(String packageName) { - CreateMachineOptions options = new CreateMachineOptions(); - return options.packageName(packageName); - } - - /** - * @see CreateMachineOptions#metadata(Map) - */ - public static CreateMachineOptions metadata(Map metadata) { - CreateMachineOptions options = new CreateMachineOptions(); - return options.metadata(metadata); - } - - } - -} diff --git a/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/predicates/KeyPredicates.java b/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/predicates/KeyPredicates.java deleted file mode 100644 index 9f28c7b3c9..0000000000 --- a/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/predicates/KeyPredicates.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.joyent.cloudapi.v6_5.predicates; - -import static com.google.common.base.Preconditions.checkNotNull; - -import org.jclouds.joyent.cloudapi.v6_5.domain.Key; - -import com.google.common.base.Predicate; - -/** - * Predicates handy when working with Keys - * - * @author Adrian Cole - */ - -public class KeyPredicates { - - - /** - * matches name of the given key pair - * - * @param name - * @return predicate that matches name - */ - public static Predicate nameMatches(final Predicate name) { - checkNotNull(name, "name must be defined"); - - return new Predicate() { - @Override - public boolean apply(Key ext) { - return name.apply(ext.getName()); - } - - @Override - public String toString() { - return "nameMatches(" + name + ")"; - } - }; - } - -} diff --git a/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/reference/Metadata.java b/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/reference/Metadata.java deleted file mode 100644 index 84b498fd4e..0000000000 --- a/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/reference/Metadata.java +++ /dev/null @@ -1,69 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.joyent.cloudapi.v6_5.reference; - -import static org.jclouds.reflect.Reflection2.typeToken; - -import java.lang.reflect.Type; -import java.util.Map; - -import com.google.common.base.CaseFormat; -import com.google.common.reflect.TypeToken; - -/** - * Known keys for metadata - * - * @author Adrian Cole - */ -public enum Metadata { - ROOT_AUTHORIZED_KEYS(typeToken(String.class).getType()), - /** - * If the dataset you create a machine from is set to generate passwords for - * you, the username/password pairs will be returned in the metadata response - * as a nested object, like: - * - *

-    * "credentials": {
-    *     "root": "s8v9kuht5e",
-    *     "admin": "mf4bteqhpy"
-    *   }
-    * 
- */ - CREDENTIALS(new TypeToken>() { - private static final long serialVersionUID = 1L; - }.getType()); - - private final Type valueType; - - Metadata(Type valueType) { - this.valueType = valueType; - } - - public String key() { - return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_UNDERSCORE, name()); - } - - /** - * type of the value; - */ - public Type type() { - return valueType; - } - -} diff --git a/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/suppliers/ZoneIdToURIFromDatacentersApi.java b/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/suppliers/ZoneIdToURIFromDatacentersApi.java deleted file mode 100644 index 085c9e5c16..0000000000 --- a/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/suppliers/ZoneIdToURIFromDatacentersApi.java +++ /dev/null @@ -1,58 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.joyent.cloudapi.v6_5.suppliers; - -import static com.google.common.collect.Maps.filterKeys; -import static com.google.common.collect.Maps.transformValues; - -import java.net.URI; -import java.util.Map; - -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jclouds.joyent.cloudapi.v6_5.features.DatacenterApi; -import org.jclouds.location.predicates.fromconfig.AnyOrConfiguredZoneId; -import org.jclouds.location.suppliers.ZoneIdToURISupplier; -import org.jclouds.util.Suppliers2; - -import com.google.common.base.Supplier; - -@Singleton -public class ZoneIdToURIFromDatacentersApi implements ZoneIdToURISupplier { - - private final DatacenterApi api; - private final AnyOrConfiguredZoneId filter; - - @Inject - public ZoneIdToURIFromDatacentersApi(DatacenterApi api, AnyOrConfiguredZoneId filter) { - this.api = api; - this.filter = filter; - } - - @Override - public Map> get() { - return filterKeys(transformValues(api.getDatacenters(), Suppliers2. ofInstanceFunction()), filter); - } - - @Override - public String toString() { - return "getDatacenters()"; - } -} diff --git a/labs/joyent-cloudapi/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata b/labs/joyent-cloudapi/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata deleted file mode 100644 index 8deea9e7f4..0000000000 --- a/labs/joyent-cloudapi/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata +++ /dev/null @@ -1 +0,0 @@ -org.jclouds.joyent.cloudapi.v6_5.JoyentCloudApiMetadata diff --git a/labs/joyent-cloudapi/src/test/java/org/jclouds/joyent/cloudapi/v6_5/JoyentCloudApiExpectTest.java b/labs/joyent-cloudapi/src/test/java/org/jclouds/joyent/cloudapi/v6_5/JoyentCloudApiExpectTest.java deleted file mode 100644 index 30f20880e1..0000000000 --- a/labs/joyent-cloudapi/src/test/java/org/jclouds/joyent/cloudapi/v6_5/JoyentCloudApiExpectTest.java +++ /dev/null @@ -1,48 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unles required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either expres or implied. See the License for the - * specific language governing permisions and limitations - * under the License. - */ -package org.jclouds.joyent.cloudapi.v6_5; - -import static org.testng.Assert.assertEquals; - -import org.jclouds.joyent.cloudapi.v6_5.JoyentCloudApi; -import org.jclouds.joyent.cloudapi.v6_5.internal.BaseJoyentCloudApiExpectTest; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableSet; - -/** - * @author Adrian Cole - */ -@Test(groups = "unit", testName = "JoyentCloudApiExpectTest") -public class JoyentCloudApiExpectTest extends BaseJoyentCloudApiExpectTest { - - public void testGetConfiguredDatacenters() { - - JoyentCloudApi apiWhenDatacentersExists = requestSendsResponse(getDatacenters, getDatacentersResponse); - - assertEquals( - apiWhenDatacentersExists.getConfiguredDatacenters(), - ImmutableSet. builder() - .add("us-east-1") - .add("us-west-1") - .add("us-sw-1") - .add("eu-ams-1").build()); - } - -} diff --git a/labs/joyent-cloudapi/src/test/java/org/jclouds/joyent/cloudapi/v6_5/JoyentCloudApiLiveTest.java b/labs/joyent-cloudapi/src/test/java/org/jclouds/joyent/cloudapi/v6_5/JoyentCloudApiLiveTest.java deleted file mode 100644 index cee591999f..0000000000 --- a/labs/joyent-cloudapi/src/test/java/org/jclouds/joyent/cloudapi/v6_5/JoyentCloudApiLiveTest.java +++ /dev/null @@ -1,38 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.joyent.cloudapi.v6_5; - -import static org.testng.Assert.assertEquals; - -import java.util.Set; - -import org.jclouds.joyent.cloudapi.v6_5.internal.BaseJoyentCloudApiLiveTest; -import org.testng.annotations.Test; - -/** - * @author Adrian Cole - */ -@Test(groups = "live", testName = "JoyentCloudApiLiveTest") -public class JoyentCloudApiLiveTest extends BaseJoyentCloudApiLiveTest { - - public void testGetDatacenters() { - Set dcs = cloudApiContext.getApi().getConfiguredDatacenters(); - assertEquals(dcs, cloudApiContext.getApi().getDatacenterApi().getDatacenters().keySet()); - } -} diff --git a/labs/joyent-cloudapi/src/test/java/org/jclouds/joyent/cloudapi/v6_5/JoyentCloudApiMetadataTest.java b/labs/joyent-cloudapi/src/test/java/org/jclouds/joyent/cloudapi/v6_5/JoyentCloudApiMetadataTest.java deleted file mode 100644 index e2d98e068c..0000000000 --- a/labs/joyent-cloudapi/src/test/java/org/jclouds/joyent/cloudapi/v6_5/JoyentCloudApiMetadataTest.java +++ /dev/null @@ -1,38 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.joyent.cloudapi.v6_5; - -import org.jclouds.View; -import org.jclouds.apis.internal.BaseApiMetadataTest; -import org.jclouds.joyent.cloudapi.v6_5.JoyentCloudApiMetadata; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableSet; -import com.google.common.reflect.TypeToken; - -/** - * - * @author Adrian Cole - */ -@Test(groups = "unit", testName = "JoyentCloudApiMetadataTest") -public class JoyentCloudApiMetadataTest extends BaseApiMetadataTest { - public JoyentCloudApiMetadataTest() { - super(new JoyentCloudApiMetadata(), ImmutableSet.> of()); - } -} diff --git a/labs/joyent-cloudapi/src/test/java/org/jclouds/joyent/cloudapi/v6_5/compute/JoyentCloudComputeServiceExpectTest.java b/labs/joyent-cloudapi/src/test/java/org/jclouds/joyent/cloudapi/v6_5/compute/JoyentCloudComputeServiceExpectTest.java deleted file mode 100644 index 2ff5bca9c9..0000000000 --- a/labs/joyent-cloudapi/src/test/java/org/jclouds/joyent/cloudapi/v6_5/compute/JoyentCloudComputeServiceExpectTest.java +++ /dev/null @@ -1,141 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.joyent.cloudapi.v6_5.compute; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertTrue; - -import java.util.Map; -import java.util.Properties; -import java.util.concurrent.atomic.AtomicInteger; - -import org.jclouds.compute.ComputeService; -import org.jclouds.compute.domain.NodeMetadata; -import org.jclouds.compute.options.TemplateOptions; -import org.jclouds.http.HttpRequest; -import org.jclouds.http.HttpResponse; -import org.jclouds.joyent.cloudapi.v6_5.compute.internal.BaseJoyentCloudComputeServiceExpectTest; -import org.jclouds.joyent.cloudapi.v6_5.compute.options.JoyentCloudTemplateOptions; -import org.jclouds.joyent.cloudapi.v6_5.features.DatasetApiExpectTest; -import org.jclouds.joyent.cloudapi.v6_5.features.MachineApiExpectTest; -import org.jclouds.joyent.cloudapi.v6_5.features.PackageApiExpectTest; -import org.jclouds.location.reference.LocationConstants; -import org.jclouds.ssh.SshKeyPairGenerator; -import org.testng.annotations.Test; - -import com.google.common.base.Supplier; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableMap.Builder; -import com.google.common.collect.Iterables; -import com.google.inject.AbstractModule; -import com.google.inject.TypeLiteral; - -/** - * - * @author Adrian Cole - */ -@Test(groups = "unit", testName = "JoyentCloudComputeServiceExpectTest") -public class JoyentCloudComputeServiceExpectTest extends BaseJoyentCloudComputeServiceExpectTest { - Properties onlySW = new Properties(); - - public JoyentCloudComputeServiceExpectTest(){ - onlySW.setProperty(LocationConstants.PROPERTY_ZONES, "us-sw-1"); - } - private ImmutableMap keyPair = ImmutableMap.of("public", "ssh-rsa AAAAB3NzaC...", "private", - "-----BEGIN RSA PRIVATE KEY-----\n"); - - DatasetApiExpectTest datasets = new DatasetApiExpectTest(); - PackageApiExpectTest packages = new PackageApiExpectTest(); - MachineApiExpectTest machines = new MachineApiExpectTest(); - - @Test - public void testCreateNodeWithGeneratedKeyPairInWestRegion() throws Exception { - Builder requestResponseMap = ImmutableMap. builder(); - requestResponseMap.put(getDatacenters, getDatacentersResponse); - requestResponseMap.put(datasets.list, datasets.listResponse); - requestResponseMap.put(packages.list, packages.listResponse); - - HttpRequest createKey = HttpRequest.builder().method("POST") - .endpoint("https://api.joyentcloud.com/my/keys") - .addHeader("X-Api-Version", "~6.5") - .addHeader("Accept", "application/json") - .addHeader("Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==") - .payload( - payloadFromStringWithContentType( - "{\"name\":\"jclouds-test-0\",\"key\":\"" + keyPair.get("public") + "\"}", - "application/json")).build(); - - HttpResponse createKeyResponse = HttpResponse.builder().statusCode(202).message("HTTP/1.1 202 Accepted") - .payload(payloadFromResourceWithContentType("/key.json", "application/json; charset=UTF-8")) - .build(); - - requestResponseMap.put(createKey, createKeyResponse); - - // look for number to start count at - requestResponseMap.put(machines.list, machines.listResponse); - - HttpRequest createMachine = HttpRequest.builder().method("POST") - .endpoint("https://us-sw-1.api.joyentcloud.com/my/machines?dataset=sdc%3Asdc%3Aubuntu-10.04%3A1.0.1&name=test-1&package=Small%201GB") - .addHeader("X-Api-Version", "~6.5") - .addHeader("Accept", "application/json") - .addHeader("Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==").build(); - - HttpResponse createMachineResponse = HttpResponse.builder().statusCode(202).message("HTTP/1.1 202 Accepted") - .payload(payloadFromResourceWithContentType("/new_machine.json", "application/json; charset=UTF-8")) - .build(); - - requestResponseMap.put(createMachine, createMachineResponse); - - ComputeService apiThatCreatesNode = requestsSendResponses(requestResponseMap.build(), new AbstractModule() { - - @Override - protected void configure() { - // predicatable node names - final AtomicInteger suffix = new AtomicInteger(); - bind(new TypeLiteral>() { - }).toInstance(new Supplier() { - - @Override - public String get() { - return suffix.getAndIncrement() + ""; - } - - }); - bind(SshKeyPairGenerator.class).toInstance(new SshKeyPairGenerator() { - - @Override - public Map get() { - return keyPair; - } - - }); - - } - - }, onlySW); - - TemplateOptions options = apiThatCreatesNode.templateOptions().blockUntilRunning(false); - - assertTrue(options.as(JoyentCloudTemplateOptions.class).shouldGenerateKey().get()); - - NodeMetadata node = Iterables.getOnlyElement(apiThatCreatesNode.createNodesInGroup("test", 1, options)); - - assertEquals(node.getCredentials().getPrivateKey(), keyPair.get("private")); - } -} diff --git a/labs/joyent-cloudapi/src/test/java/org/jclouds/joyent/cloudapi/v6_5/compute/JoyentCloudComputeServiceLiveTest.java b/labs/joyent-cloudapi/src/test/java/org/jclouds/joyent/cloudapi/v6_5/compute/JoyentCloudComputeServiceLiveTest.java deleted file mode 100644 index b271e1f824..0000000000 --- a/labs/joyent-cloudapi/src/test/java/org/jclouds/joyent/cloudapi/v6_5/compute/JoyentCloudComputeServiceLiveTest.java +++ /dev/null @@ -1,43 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.joyent.cloudapi.v6_5.compute; - -import org.jclouds.compute.internal.BaseComputeServiceLiveTest; -import org.jclouds.sshj.config.SshjSshClientModule; -import org.testng.annotations.Test; - -import com.google.inject.Module; - -/** - * - * @author Adrian Cole - */ -@Test(groups = "live", singleThreaded = true, testName = "JoyentCloudComputeServiceLiveTest") -public class JoyentCloudComputeServiceLiveTest extends BaseComputeServiceLiveTest { - - public JoyentCloudComputeServiceLiveTest() { - provider = "joyent-cloudapi"; - } - - @Override - protected Module getSshModule() { - return new SshjSshClientModule(); - } - -} diff --git a/labs/joyent-cloudapi/src/test/java/org/jclouds/joyent/cloudapi/v6_5/compute/functions/DatasetInDatacenterToImageTest.java b/labs/joyent-cloudapi/src/test/java/org/jclouds/joyent/cloudapi/v6_5/compute/functions/DatasetInDatacenterToImageTest.java deleted file mode 100644 index f751b01274..0000000000 --- a/labs/joyent-cloudapi/src/test/java/org/jclouds/joyent/cloudapi/v6_5/compute/functions/DatasetInDatacenterToImageTest.java +++ /dev/null @@ -1,95 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.joyent.cloudapi.v6_5.compute.functions; - -import static org.testng.Assert.assertEquals; - -import java.util.Map; - -import org.jclouds.compute.domain.OperatingSystem; -import org.jclouds.compute.domain.OsFamily; -import org.jclouds.domain.Location; -import org.jclouds.domain.LocationBuilder; -import org.jclouds.domain.LocationScope; -import org.jclouds.joyent.cloudapi.v6_5.compute.functions.DatasetInDatacenterToImage; -import org.jclouds.joyent.cloudapi.v6_5.domain.Dataset; -import org.jclouds.joyent.cloudapi.v6_5.domain.datacenterscoped.DatasetInDatacenter; -import org.jclouds.joyent.cloudapi.v6_5.parse.ParseDatasetTest; -import org.testng.annotations.Test; - -import com.google.common.base.Function; -import com.google.common.base.Functions; -import com.google.common.base.Supplier; -import com.google.common.base.Suppliers; -import com.google.common.collect.ImmutableMap; - -/** - * Tests the function that transforms cloudApi-specific images to generic images. - * - * @author Adrian Cole - */ -@Test(testName = "DatasetInDatacenterToImageTest") -public class DatasetInDatacenterToImageTest { - - Location provider = new LocationBuilder().scope(LocationScope.PROVIDER).id("joyent-cloudapi") - .description("joyent-cloudapi").build(); - Location zone = new LocationBuilder().id("us-sw-1").description("us-sw-1").scope(LocationScope.ZONE) - .parent(provider).build(); - Supplier> locationIndex = Suppliers.> ofInstance(ImmutableMap - . of("us-sw-1", zone)); - - Dataset datasetToConvert = new ParseDatasetTest().expected(); - - @Test - public void testConversionWhereLocationFound() { - OperatingSystem operatingSystem = new OperatingSystem(OsFamily.UBUNTU, "My Test OS", "My Test Version", "x86", - "My Test OS", true); - DatasetInDatacenterToImage converter = new DatasetInDatacenterToImage(constant(operatingSystem), locationIndex); - - DatasetInDatacenter datasetInZoneToConvert = new DatasetInDatacenter(datasetToConvert, "us-sw-1"); - - org.jclouds.compute.domain.Image convertedImage = converter.apply(datasetInZoneToConvert); - - assertEquals(convertedImage.getId(), "us-sw-1/" + datasetToConvert.getUrn()); - assertEquals(convertedImage.getProviderId(), datasetToConvert.getUrn()); - assertEquals(convertedImage.getLocation(), locationIndex.get().get("us-sw-1")); - - assertEquals(convertedImage.getName(), datasetToConvert.getName()); - assertEquals(convertedImage.getStatus(), org.jclouds.compute.domain.Image.Status.AVAILABLE); - assertEquals(convertedImage.getOperatingSystem(), operatingSystem); - assertEquals(convertedImage.getDescription(), datasetToConvert.getDescription()); - assertEquals(convertedImage.getVersion(), datasetToConvert.getVersion()); - } - - @Test(expectedExceptions = IllegalStateException.class) - public void testConversionWhereLocationNotFound() { - OperatingSystem operatingSystem = new OperatingSystem(OsFamily.UBUNTU, "My Test OS", "My Test Version", "x86", - "My Test OS", true); - DatasetInDatacenterToImage converter = new DatasetInDatacenterToImage(constant(operatingSystem), locationIndex); - - DatasetInDatacenter datasetInZoneToConvert = new DatasetInDatacenter(datasetToConvert, "South"); - - converter.apply(datasetInZoneToConvert); - } - - @SuppressWarnings("unchecked") - private static Function constant(OperatingSystem operatingSystem) { - return Function.class.cast(Functions.constant(operatingSystem)); - } -} diff --git a/labs/joyent-cloudapi/src/test/java/org/jclouds/joyent/cloudapi/v6_5/compute/functions/DatasetToOperatingSystemTest.java b/labs/joyent-cloudapi/src/test/java/org/jclouds/joyent/cloudapi/v6_5/compute/functions/DatasetToOperatingSystemTest.java deleted file mode 100644 index 2ef805b3b9..0000000000 --- a/labs/joyent-cloudapi/src/test/java/org/jclouds/joyent/cloudapi/v6_5/compute/functions/DatasetToOperatingSystemTest.java +++ /dev/null @@ -1,59 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.joyent.cloudapi.v6_5.compute.functions; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertTrue; - -import java.util.Map; - -import org.jclouds.compute.domain.OperatingSystem; -import org.jclouds.compute.domain.OsFamily; -import org.jclouds.joyent.cloudapi.v6_5.compute.functions.DatasetToOperatingSystem; -import org.jclouds.joyent.cloudapi.v6_5.domain.Dataset; -import org.jclouds.joyent.cloudapi.v6_5.parse.ParseDatasetTest; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableMap; - -/** - * Tests for the function for transforming a cloudApi specific Image into a generic - * OperatingSystem object. - * - * @author Adrian Cole - */ -@Test(testName = "DatasetToOperatingSystemTest") -public class DatasetToOperatingSystemTest { - - public void testCentos6() { - - Dataset datasetToConvert = new ParseDatasetTest().expected(); - - OperatingSystem convertedOs = new DatasetToOperatingSystem(ImmutableMap.> of( - OsFamily.CENTOS, ImmutableMap.of("6", "6.0"))).apply(datasetToConvert); - - assertEquals(convertedOs.getName(), datasetToConvert.getName()); - assertEquals(convertedOs.getFamily(), OsFamily.CENTOS); - assertEquals(convertedOs.getDescription(), datasetToConvert.getUrn()); - assertEquals(convertedOs.getVersion(), "6.0"); - assertEquals(convertedOs.getArch(), null); - assertTrue(convertedOs.is64Bit()); - } - -} diff --git a/labs/joyent-cloudapi/src/test/java/org/jclouds/joyent/cloudapi/v6_5/compute/functions/MachineInDatacenterToNodeMetadataTest.java b/labs/joyent-cloudapi/src/test/java/org/jclouds/joyent/cloudapi/v6_5/compute/functions/MachineInDatacenterToNodeMetadataTest.java deleted file mode 100644 index 197572c6f0..0000000000 --- a/labs/joyent-cloudapi/src/test/java/org/jclouds/joyent/cloudapi/v6_5/compute/functions/MachineInDatacenterToNodeMetadataTest.java +++ /dev/null @@ -1,143 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.joyent.cloudapi.v6_5.compute.functions; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; - -import java.util.Map; -import java.util.Set; - -import org.jclouds.compute.domain.Hardware; -import org.jclouds.compute.domain.HardwareBuilder; -import org.jclouds.compute.domain.Image; -import org.jclouds.compute.domain.ImageBuilder; -import org.jclouds.compute.domain.NodeMetadata; -import org.jclouds.compute.domain.OperatingSystem; -import org.jclouds.compute.domain.OsFamily; -import org.jclouds.compute.domain.internal.VolumeImpl; -import org.jclouds.compute.functions.GroupNamingConvention; -import org.jclouds.domain.Location; -import org.jclouds.domain.LocationBuilder; -import org.jclouds.domain.LocationScope; -import org.jclouds.joyent.cloudapi.v6_5.compute.config.JoyentCloudComputeServiceContextModule; -import org.jclouds.joyent.cloudapi.v6_5.compute.functions.MachineInDatacenterToNodeMetadata; -import org.jclouds.joyent.cloudapi.v6_5.domain.Machine; -import org.jclouds.joyent.cloudapi.v6_5.domain.datacenterscoped.MachineInDatacenter; -import org.jclouds.joyent.cloudapi.v6_5.parse.ParseCreatedMachineTest; -import org.testng.annotations.Test; - -import com.google.common.base.Supplier; -import com.google.common.base.Suppliers; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; -import com.google.inject.Guice; - -/** - * Tests for the function for transforming a cloudApi specific Machine into a generic - * NodeMetadata object. - * - * @author Adrian Cole - */ -@Test(testName = "MachineInDatacenterToNodeMetadataTest") -public class MachineInDatacenterToNodeMetadataTest { - - Location provider = new LocationBuilder().scope(LocationScope.PROVIDER).id("joyent-cloudapi") - .description("joyent-cloudapi").build(); - Location zone = new LocationBuilder().id("us-sw-1").description("us-sw-1").scope(LocationScope.ZONE) - .parent(provider).build(); - Supplier> locationIndex = Suppliers.> ofInstance(ImmutableMap - . of("us-sw-1", zone)); - - GroupNamingConvention.Factory namingConvention = Guice.createInjector().getInstance( - GroupNamingConvention.Factory.class); - - @Test - public void testWhenNoHardwareOrImageMatchImageIdIsStillSet() { - - Hardware existingHardware = new HardwareBuilder().id("us-sw-1/FOOOOOOOO").providerId("FOOOOOOOO").location(zone) - .build(); - Image existingImage = new ImageBuilder().id("us-sw-1/FOOOOOOOO") - .operatingSystem(OperatingSystem.builder().family(OsFamily.LINUX).description("foobuntu").build()) - .providerId("FOOOOOOOO").description("foobuntu").location(zone).status(Image.Status.AVAILABLE).build(); - - checkHardwareAndImageStatus(null, existingHardware, "us-sw-1/sdc:sdc:centos-5.7:1.2.1", null, existingImage); - } - - @Test - public void testWhenHardwareAndImageMatchHardwareOperatingSystemAndImageIdAreSet() { - - Hardware existingHardware = new HardwareBuilder().id("us-sw-1/Small 1GB").providerId("Small 1GB").ram(1024) - .volume(new VolumeImpl(Float.valueOf(61440), true, true)).location(zone).build(); - Image existingImage = new ImageBuilder().id("us-sw-1/sdc:sdc:centos-5.7:1.2.1") - .operatingSystem(OperatingSystem.builder().family(OsFamily.LINUX).description("foobuntu").build()) - .providerId("sdc:sdc:centos-5.7:1.2.1").description("foobuntu").status(Image.Status.AVAILABLE) - .location(zone).build(); - - checkHardwareAndImageStatus(existingHardware, existingHardware, existingImage.getId(), - existingImage.getOperatingSystem(), existingImage); - } - - // TODO: clean up this syntax - private void checkHardwareAndImageStatus(Hardware expectedHardware, Hardware existingHardware, - String expectedImageId, OperatingSystem expectedOs, Image existingImage) { - - Set images = existingImage == null ? ImmutableSet. of() : ImmutableSet.of(existingImage); - Set hardwares = existingHardware == null ? ImmutableSet. of() : ImmutableSet - .of(existingHardware); - Machine machineToConvert = new ParseCreatedMachineTest().expected(); - - MachineInDatacenter machineInDatacenterToConvert = new MachineInDatacenter(machineToConvert, "us-sw-1"); - - MachineInDatacenterToNodeMetadata converter = new MachineInDatacenterToNodeMetadata( - JoyentCloudComputeServiceContextModule.toPortableNodeStatus, locationIndex, - Suppliers.> ofInstance(images), - Suppliers.> ofInstance(hardwares), namingConvention); - - NodeMetadata convertedNodeMetadata = converter.apply(machineInDatacenterToConvert); - - assertEquals(machineInDatacenterToConvert.slashEncode(), convertedNodeMetadata.getId()); - assertEquals(machineToConvert.getId(), convertedNodeMetadata.getProviderId()); - - assertEquals(convertedNodeMetadata.getLocation().getScope(), LocationScope.ZONE); - assertEquals(convertedNodeMetadata.getLocation().getId(), "us-sw-1"); - - assertEquals(machineToConvert.getName(), convertedNodeMetadata.getName()); - assertEquals(convertedNodeMetadata.getGroup(), "sample"); - - assertEquals(convertedNodeMetadata.getImageId(), expectedImageId); - assertEquals(convertedNodeMetadata.getOperatingSystem(), expectedOs); - - assertEquals(convertedNodeMetadata.getHardware(), expectedHardware); - - assertEquals(JoyentCloudComputeServiceContextModule.toPortableNodeStatus.get(machineToConvert.getState()), - convertedNodeMetadata.getStatus()); - - assertNotNull(convertedNodeMetadata.getPrivateAddresses()); - assertEquals(convertedNodeMetadata.getPrivateAddresses(), ImmutableSet.of("10.224.0.63")); - - assertNotNull(convertedNodeMetadata.getPublicAddresses()); - assertEquals(convertedNodeMetadata.getPublicAddresses(), ImmutableSet.of("37.153.96.62")); - - assertNotNull(convertedNodeMetadata.getUserMetadata()); - // ensure filtered out root_authorized_keys! - assertEquals(convertedNodeMetadata.getUserMetadata(), ImmutableMap. of()); - } - -} diff --git a/labs/joyent-cloudapi/src/test/java/org/jclouds/joyent/cloudapi/v6_5/compute/functions/OrphanedGroupsByDatacenterIdTest.java b/labs/joyent-cloudapi/src/test/java/org/jclouds/joyent/cloudapi/v6_5/compute/functions/OrphanedGroupsByDatacenterIdTest.java deleted file mode 100644 index 2b3f8c146c..0000000000 --- a/labs/joyent-cloudapi/src/test/java/org/jclouds/joyent/cloudapi/v6_5/compute/functions/OrphanedGroupsByDatacenterIdTest.java +++ /dev/null @@ -1,102 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.joyent.cloudapi.v6_5.compute.functions; - -import static org.testng.Assert.assertEquals; - -import java.util.Map; -import java.util.Set; - -import org.jclouds.compute.domain.Hardware; -import org.jclouds.compute.domain.Image; -import org.jclouds.compute.domain.NodeMetadata; -import org.jclouds.compute.functions.GroupNamingConvention; -import org.jclouds.domain.Location; -import org.jclouds.domain.LocationBuilder; -import org.jclouds.domain.LocationScope; -import org.jclouds.joyent.cloudapi.v6_5.compute.config.JoyentCloudComputeServiceContextModule; -import org.jclouds.joyent.cloudapi.v6_5.compute.functions.MachineInDatacenterToNodeMetadata; -import org.jclouds.joyent.cloudapi.v6_5.compute.functions.OrphanedGroupsByDatacenterId; -import org.jclouds.joyent.cloudapi.v6_5.domain.Machine.State; -import org.jclouds.joyent.cloudapi.v6_5.domain.datacenterscoped.DatacenterAndName; -import org.jclouds.joyent.cloudapi.v6_5.domain.datacenterscoped.MachineInDatacenter; -import org.jclouds.joyent.cloudapi.v6_5.parse.ParseMachineTest; -import org.testng.annotations.Test; - -import com.google.common.base.Predicates; -import com.google.common.base.Supplier; -import com.google.common.base.Suppliers; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableMultimap; -import com.google.common.collect.ImmutableSet; -import com.google.inject.Guice; - -/** - * - * - * @author Adrian Cole - */ -@Test(testName = "OrphanedGroupsByDatacenterIdTest") -public class OrphanedGroupsByDatacenterIdTest { - - Location provider = new LocationBuilder().scope(LocationScope.PROVIDER).id("joyent-cloudapi").description( - "joyent-cloudapi").build(); - Location datacenter = new LocationBuilder().id("us-east-1").description("us-east-1").scope( - LocationScope.ZONE).parent(provider).build(); - Supplier> locationIndex = Suppliers.> ofInstance(ImmutableMap - . of("us-east-1", datacenter)); - - GroupNamingConvention.Factory namingConvention = Guice.createInjector().getInstance(GroupNamingConvention.Factory.class); - - MachineInDatacenter machine1 = new MachineInDatacenter(new ParseMachineTest().expected().toBuilder().name("test-fe2").state(State.DELETED).build(), "us-east-1"); - MachineInDatacenter machine2 = new MachineInDatacenter(new ParseMachineTest().expected().toBuilder().name("sample-fe1").state(State.DELETED).build(), "us-east-1"); - - @Test - public void testWhenComputeServiceSaysAllNodesAreDeadBothGroupsAreReturned() { - - - MachineInDatacenterToNodeMetadata converter = new MachineInDatacenterToNodeMetadata( - JoyentCloudComputeServiceContextModule.toPortableNodeStatus, locationIndex, Suppliers - .> ofInstance(ImmutableSet. of()), Suppliers - .> ofInstance(ImmutableSet. of()), namingConvention); - - Set set = ImmutableSet.of(converter.apply(machine2), converter.apply(machine1)); - - assertEquals(new OrphanedGroupsByDatacenterId(Predicates. alwaysTrue()).apply(set), ImmutableMultimap - . builder().putAll("us-east-1", "sample", "test").build()); - } - - @Test - public void testWhenComputeServiceSaysAllNodesAreDeadNoGroupsAreReturned() { - - MachineInDatacenter machine1 = new MachineInDatacenter(new ParseMachineTest().expected(), "us-east-1"); - MachineInDatacenter machine2 = new MachineInDatacenter(new ParseMachineTest().expected(), "us-east-1"); - - MachineInDatacenterToNodeMetadata converter = new MachineInDatacenterToNodeMetadata( - JoyentCloudComputeServiceContextModule.toPortableNodeStatus, locationIndex, Suppliers - .> ofInstance(ImmutableSet. of()), Suppliers - .> ofInstance(ImmutableSet. of()), namingConvention); - - Set set = ImmutableSet.of(converter.apply(machine2), converter.apply(machine1)); - - assertEquals(new OrphanedGroupsByDatacenterId(Predicates. alwaysFalse()).apply(set), ImmutableMultimap - . of()); - - } -} diff --git a/labs/joyent-cloudapi/src/test/java/org/jclouds/joyent/cloudapi/v6_5/compute/functions/PackageInDatacenterToHardwareTest.java b/labs/joyent-cloudapi/src/test/java/org/jclouds/joyent/cloudapi/v6_5/compute/functions/PackageInDatacenterToHardwareTest.java deleted file mode 100644 index fea8e824c1..0000000000 --- a/labs/joyent-cloudapi/src/test/java/org/jclouds/joyent/cloudapi/v6_5/compute/functions/PackageInDatacenterToHardwareTest.java +++ /dev/null @@ -1,89 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.joyent.cloudapi.v6_5.compute.functions; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertNotNull; - -import java.util.Map; - -import org.jclouds.compute.domain.Hardware; -import org.jclouds.domain.Location; -import org.jclouds.domain.LocationBuilder; -import org.jclouds.domain.LocationScope; -import org.jclouds.joyent.cloudapi.v6_5.compute.functions.PackageInDatacenterToHardware; -import org.jclouds.joyent.cloudapi.v6_5.domain.Package; -import org.jclouds.joyent.cloudapi.v6_5.domain.datacenterscoped.PackageInDatacenter; -import org.testng.annotations.Test; - -import com.google.common.base.Supplier; -import com.google.common.base.Suppliers; -import com.google.common.collect.ImmutableMap; - -/** - * Tests the function used to transform Package objects into Hardware objects - * - * @author Adrian Cole - */ -@Test(testName = "PackageInDatacenterToHardwareTest") -public class PackageInDatacenterToHardwareTest { - Location provider = new LocationBuilder().scope(LocationScope.PROVIDER).id("joyent-cloudapi").description( - "joyent-cloudapi").build(); - Location zone = new LocationBuilder().id("us-sw-1").description("us-sw-1").scope( - LocationScope.ZONE).parent(provider).build(); - Supplier> locationIndex = Suppliers.> ofInstance(ImmutableMap - . of("us-sw-1", zone)); - - Package packageToConvert = org.jclouds.joyent.cloudapi.v6_5.domain.Package.builder().name("Small 1GB").memorySizeMb(1024) - .diskSizeGb(30720).swapSizeMb(2048).isDefault(true).build(); - - @Test - public void testConversionWhereLocationFound() { - - PackageInDatacenter packageInZoneToConvert = new PackageInDatacenter(packageToConvert, "us-sw-1"); - - Hardware converted = new PackageInDatacenterToHardware(locationIndex).apply(packageInZoneToConvert); - - assertEquals(converted.getName(), packageToConvert.getName()); - assertEquals(converted.getId(), packageInZoneToConvert.slashEncode()); - assertEquals(converted.getProviderId(), packageToConvert.getName()); - assertEquals(converted.getLocation(), locationIndex.get().get("us-sw-1")); - - assertEquals(converted.getRam(), packageToConvert.getMemorySizeMb()); - -//TODO! -// assertNotNull(converted.getProcessors()); -// assertFalse(converted.getProcessors().isEmpty()); -// assertEquals(converted.getProcessors().iterator().next().getCores(), (double) packageToConvert.getVcpus()); - - assertNotNull(converted.getVolumes()); - assertFalse(converted.getVolumes().isEmpty()); - assertEquals(converted.getVolumes().iterator().next().getSize(), Float.valueOf(packageToConvert.getDiskSizeGb())); - - } - - @Test(expectedExceptions = IllegalStateException.class) - public void testConversionWhereLocationNotFound() { - - PackageInDatacenter packageInZoneToConvert = new PackageInDatacenter(packageToConvert, "South"); - new PackageInDatacenterToHardware(locationIndex).apply(packageInZoneToConvert); - } - -} diff --git a/labs/joyent-cloudapi/src/test/java/org/jclouds/joyent/cloudapi/v6_5/compute/internal/BaseJoyentCloudComputeServiceContextExpectTest.java b/labs/joyent-cloudapi/src/test/java/org/jclouds/joyent/cloudapi/v6_5/compute/internal/BaseJoyentCloudComputeServiceContextExpectTest.java deleted file mode 100644 index da53581f12..0000000000 --- a/labs/joyent-cloudapi/src/test/java/org/jclouds/joyent/cloudapi/v6_5/compute/internal/BaseJoyentCloudComputeServiceContextExpectTest.java +++ /dev/null @@ -1,57 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.joyent.cloudapi.v6_5.compute.internal; - -import java.util.Properties; - -import org.jclouds.apis.ApiMetadata; -import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.http.HttpRequest; -import org.jclouds.http.HttpResponse; -import org.jclouds.joyent.cloudapi.v6_5.JoyentCloudApiMetadata; -import org.jclouds.joyent.cloudapi.v6_5.internal.BaseJoyentCloudExpectTest; - -import com.google.common.base.Function; -import com.google.inject.Module; - -/** - * Base class for writing Expect tests with the ComputeService abstraction - * - * @author Adrian Cole - */ -public abstract class BaseJoyentCloudComputeServiceContextExpectTest extends BaseJoyentCloudExpectTest implements - Function { - - - @Override - public T createClient(Function fn, Module module, Properties props) { - return apply(createComputeServiceContext(fn, module, props)); - } - - private ComputeServiceContext createComputeServiceContext(Function fn, Module module, - Properties props) { - return createInjector(fn, module, props).getInstance(ComputeServiceContext.class); - } - - @Override - protected ApiMetadata createApiMetadata() { - return new JoyentCloudApiMetadata(); - } - -} diff --git a/labs/joyent-cloudapi/src/test/java/org/jclouds/joyent/cloudapi/v6_5/compute/internal/BaseJoyentCloudComputeServiceExpectTest.java b/labs/joyent-cloudapi/src/test/java/org/jclouds/joyent/cloudapi/v6_5/compute/internal/BaseJoyentCloudComputeServiceExpectTest.java deleted file mode 100644 index beae2e2077..0000000000 --- a/labs/joyent-cloudapi/src/test/java/org/jclouds/joyent/cloudapi/v6_5/compute/internal/BaseJoyentCloudComputeServiceExpectTest.java +++ /dev/null @@ -1,35 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.joyent.cloudapi.v6_5.compute.internal; - -import org.jclouds.compute.ComputeService; -import org.jclouds.compute.ComputeServiceContext; - -/** - * - * @author Adrian Cole - */ -public class BaseJoyentCloudComputeServiceExpectTest extends BaseJoyentCloudComputeServiceContextExpectTest { - - @Override - public ComputeService apply(ComputeServiceContext input) { - return input.getComputeService(); - } - -} diff --git a/labs/joyent-cloudapi/src/test/java/org/jclouds/joyent/cloudapi/v6_5/compute/loaders/CreateUniqueKeyTest.java b/labs/joyent-cloudapi/src/test/java/org/jclouds/joyent/cloudapi/v6_5/compute/loaders/CreateUniqueKeyTest.java deleted file mode 100644 index e60d73d4f8..0000000000 --- a/labs/joyent-cloudapi/src/test/java/org/jclouds/joyent/cloudapi/v6_5/compute/loaders/CreateUniqueKeyTest.java +++ /dev/null @@ -1,101 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.joyent.cloudapi.v6_5.compute.loaders; - -import static org.easymock.EasyMock.createMock; -import static org.easymock.EasyMock.expect; -import static org.easymock.EasyMock.replay; -import static org.easymock.EasyMock.verify; -import static org.testng.Assert.assertEquals; - -import java.io.IOException; -import java.security.NoSuchAlgorithmException; -import java.security.spec.InvalidKeySpecException; -import java.util.Map; - -import org.jclouds.compute.functions.GroupNamingConvention; -import org.jclouds.compute.functions.GroupNamingConvention.Factory; -import org.jclouds.joyent.cloudapi.v6_5.JoyentCloudApi; -import org.jclouds.joyent.cloudapi.v6_5.compute.internal.KeyAndPrivateKey; -import org.jclouds.joyent.cloudapi.v6_5.domain.Key; -import org.jclouds.joyent.cloudapi.v6_5.domain.datacenterscoped.DatacenterAndName; -import org.jclouds.joyent.cloudapi.v6_5.features.KeyApi; -import org.jclouds.ssh.SshKeyPairGenerator; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -import com.google.common.base.Supplier; -import com.google.common.base.Suppliers; -import com.google.common.collect.ImmutableMap; -import com.google.inject.AbstractModule; -import com.google.inject.Guice; -import com.google.inject.TypeLiteral; - -/** - * @author Adrian Cole - */ -@Test(groups = "unit", testName = "CreateUniqueKeyTest") -public class CreateUniqueKeyTest { - private ImmutableMap keyPair = ImmutableMap.of("public", "ssh-rsa AAAAB3NzaC...", "private", - "-----BEGIN RSA PRIVATE KEY-----\n"); - - private Factory namingConvention; - - @BeforeClass - public void setup() throws InvalidKeySpecException, NoSuchAlgorithmException, IOException { - namingConvention = Guice.createInjector(new AbstractModule() { - - @Override - protected void configure() { - bind(new TypeLiteral>() { - }).toInstance(Suppliers.ofInstance("foo")); - } - }).getInstance(GroupNamingConvention.Factory.class); - - } - - @Test - public void testApply() { - JoyentCloudApi cloudApiApi = createMock(JoyentCloudApi.class); - SshKeyPairGenerator sshKeyPairGenerator = new SshKeyPairGenerator() { - - @Override - public Map get() { - return keyPair; - } - - }; - KeyApi keyApi = createMock(KeyApi.class); - Key key = Key.builder().name("group-foo").key(keyPair.get("public")).build(); - - expect(cloudApiApi.getKeyApi()).andReturn(keyApi); - - expect(keyApi.create(key)).andReturn(key); - - replay(cloudApiApi, keyApi); - - CreateUniqueKey parser = new CreateUniqueKey(cloudApiApi, namingConvention, sshKeyPairGenerator); - - assertEquals(parser.load(DatacenterAndName.fromDatacenterAndName("datacenter", "group")), - KeyAndPrivateKey.fromKeyAndPrivateKey(key, keyPair.get("private"))); - - verify(cloudApiApi, keyApi); - } - -} diff --git a/labs/joyent-cloudapi/src/test/java/org/jclouds/joyent/cloudapi/v6_5/compute/options/JoyentCloudTemplateOptionsTest.java b/labs/joyent-cloudapi/src/test/java/org/jclouds/joyent/cloudapi/v6_5/compute/options/JoyentCloudTemplateOptionsTest.java deleted file mode 100644 index 99522cd71b..0000000000 --- a/labs/joyent-cloudapi/src/test/java/org/jclouds/joyent/cloudapi/v6_5/compute/options/JoyentCloudTemplateOptionsTest.java +++ /dev/null @@ -1,182 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.joyent.cloudapi.v6_5.compute.options; - -import static org.jclouds.joyent.cloudapi.v6_5.compute.options.JoyentCloudTemplateOptions.Builder.authorizePublicKey; -import static org.jclouds.joyent.cloudapi.v6_5.compute.options.JoyentCloudTemplateOptions.Builder.blockOnPort; -import static org.jclouds.joyent.cloudapi.v6_5.compute.options.JoyentCloudTemplateOptions.Builder.generateKey; -import static org.jclouds.joyent.cloudapi.v6_5.compute.options.JoyentCloudTemplateOptions.Builder.inboundPorts; -import static org.jclouds.joyent.cloudapi.v6_5.compute.options.JoyentCloudTemplateOptions.Builder.installPrivateKey; -import static org.testng.Assert.assertEquals; - -import java.io.IOException; - -import org.jclouds.compute.options.TemplateOptions; -import org.jclouds.joyent.cloudapi.v6_5.compute.options.JoyentCloudTemplateOptions; -import org.testng.annotations.Test; - -/** - * Tests possible uses of JoyentCloudTemplateOptions and JoyentCloudTemplateOptions.Builder.* - * - * @author Adrian Cole - */ -@Test(testName = "JoyentCloudTemplateOptionsTest") -public class JoyentCloudTemplateOptionsTest { - - public void testAs() { - TemplateOptions options = new JoyentCloudTemplateOptions(); - assertEquals(options.as(JoyentCloudTemplateOptions.class), options); - } - - @Test - public void testGenerateKeyDefault() { - JoyentCloudTemplateOptions options = new JoyentCloudTemplateOptions(); - assert !options.shouldGenerateKey().isPresent(); - } - - @Test - public void testGenerateKey() { - JoyentCloudTemplateOptions options = new JoyentCloudTemplateOptions().generateKey(true); - assert options.shouldGenerateKey().get(); - } - - @Test - public void testGenerateKeyStatic() { - JoyentCloudTemplateOptions options = generateKey(true); - assert options.shouldGenerateKey().get(); - } - - // superclass tests - @Test(expectedExceptions = IllegalArgumentException.class) - public void testinstallPrivateKeyBadFormat() { - JoyentCloudTemplateOptions options = new JoyentCloudTemplateOptions(); - options.installPrivateKey("whompy"); - } - - @Test - public void testinstallPrivateKey() throws IOException { - JoyentCloudTemplateOptions options = new JoyentCloudTemplateOptions(); - options.installPrivateKey("-----BEGIN RSA PRIVATE KEY-----"); - assertEquals(options.getPrivateKey(), "-----BEGIN RSA PRIVATE KEY-----"); - } - - @Test - public void testNullinstallPrivateKey() { - JoyentCloudTemplateOptions options = new JoyentCloudTemplateOptions(); - assertEquals(options.getPrivateKey(), null); - } - - @Test - public void testinstallPrivateKeyStatic() throws IOException { - JoyentCloudTemplateOptions options = installPrivateKey("-----BEGIN RSA PRIVATE KEY-----"); - assertEquals(options.getPrivateKey(), "-----BEGIN RSA PRIVATE KEY-----"); - } - - @Test(expectedExceptions = NullPointerException.class) - public void testinstallPrivateKeyNPE() { - installPrivateKey(null); - } - - @Test(expectedExceptions = IllegalArgumentException.class) - public void testauthorizePublicKeyBadFormat() { - JoyentCloudTemplateOptions options = new JoyentCloudTemplateOptions(); - options.authorizePublicKey("whompy"); - } - - @Test - public void testauthorizePublicKey() throws IOException { - JoyentCloudTemplateOptions options = new JoyentCloudTemplateOptions(); - options.authorizePublicKey("ssh-rsa"); - assertEquals(options.getPublicKey(), "ssh-rsa"); - } - - @Test - public void testNullauthorizePublicKey() { - JoyentCloudTemplateOptions options = new JoyentCloudTemplateOptions(); - assertEquals(options.getPublicKey(), null); - } - - @Test - public void testauthorizePublicKeyStatic() throws IOException { - JoyentCloudTemplateOptions options = authorizePublicKey("ssh-rsa"); - assertEquals(options.getPublicKey(), "ssh-rsa"); - } - - @Test(expectedExceptions = NullPointerException.class) - public void testauthorizePublicKeyNPE() { - authorizePublicKey(null); - } - - @Test(expectedExceptions = IllegalArgumentException.class) - public void testblockOnPortBadFormat() { - JoyentCloudTemplateOptions options = new JoyentCloudTemplateOptions(); - options.blockOnPort(-1, -1); - } - - @Test - public void testblockOnPort() { - JoyentCloudTemplateOptions options = new JoyentCloudTemplateOptions(); - options.blockOnPort(22, 30); - assertEquals(options.getPort(), 22); - assertEquals(options.getSeconds(), 30); - - } - - @Test - public void testNullblockOnPort() { - JoyentCloudTemplateOptions options = new JoyentCloudTemplateOptions(); - assertEquals(options.getPort(), -1); - assertEquals(options.getSeconds(), -1); - } - - @Test - public void testblockOnPortStatic() { - JoyentCloudTemplateOptions options = blockOnPort(22, 30); - assertEquals(options.getPort(), 22); - assertEquals(options.getSeconds(), 30); - } - - @Test(expectedExceptions = IllegalArgumentException.class) - public void testinboundPortsBadFormat() { - JoyentCloudTemplateOptions options = new JoyentCloudTemplateOptions(); - options.inboundPorts(-1, -1); - } - - @Test - public void testinboundPorts() { - JoyentCloudTemplateOptions options = new JoyentCloudTemplateOptions(); - options.inboundPorts(22, 30); - assertEquals(options.getInboundPorts()[0], 22); - assertEquals(options.getInboundPorts()[1], 30); - - } - - @Test - public void testDefaultOpen22() { - JoyentCloudTemplateOptions options = new JoyentCloudTemplateOptions(); - assertEquals(options.getInboundPorts()[0], 22); - } - - @Test - public void testinboundPortsStatic() { - JoyentCloudTemplateOptions options = inboundPorts(22, 30); - assertEquals(options.getInboundPorts()[0], 22); - assertEquals(options.getInboundPorts()[1], 30); - } -} diff --git a/labs/joyent-cloudapi/src/test/java/org/jclouds/joyent/cloudapi/v6_5/features/DatacenterApiExpectTest.java b/labs/joyent-cloudapi/src/test/java/org/jclouds/joyent/cloudapi/v6_5/features/DatacenterApiExpectTest.java deleted file mode 100644 index cba2b75c3c..0000000000 --- a/labs/joyent-cloudapi/src/test/java/org/jclouds/joyent/cloudapi/v6_5/features/DatacenterApiExpectTest.java +++ /dev/null @@ -1,57 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unles required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either expres or implied. See the License for the - * specific language governing permisions and limitations - * under the License. - */ -package org.jclouds.joyent.cloudapi.v6_5.features; - -import static org.testng.Assert.assertEquals; - -import java.net.URI; - -import org.jclouds.http.HttpResponse; -import org.jclouds.joyent.cloudapi.v6_5.JoyentCloudApi; -import org.jclouds.joyent.cloudapi.v6_5.internal.BaseJoyentCloudApiExpectTest; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableMap; - -/** - * @author Adrian Cole - */ -@Test(groups = "unit", testName = "DatacenterApiExpectTest") -public class DatacenterApiExpectTest extends BaseJoyentCloudApiExpectTest { - - public void testGetDatacentersWhenResponseIs2xx() { - - JoyentCloudApi apiWhenDatacentersExists = requestSendsResponse(getDatacenters, getDatacentersResponse); - - assertEquals( - apiWhenDatacentersExists.getDatacenterApi().getDatacenters(), - ImmutableMap. builder().put("us-east-1", URI.create("https://us-east-1.api.joyentcloud.com")) - .put("us-west-1", URI.create("https://us-west-1.api.joyentcloud.com")) - .put("us-sw-1", URI.create("https://us-sw-1.api.joyentcloud.com")) - .put("eu-ams-1", URI.create("https://eu-ams-1.api.joyentcloud.com")).build()); - } - - public void testGetDatacentersWhenResponseIs404() { - HttpResponse getDatacentersResponse = HttpResponse.builder().statusCode(404).build(); - - JoyentCloudApi getDatacentersWhenNone = requestSendsResponse(getDatacenters, getDatacentersResponse); - - assertEquals(getDatacentersWhenNone.getDatacenterApi().getDatacenters(), ImmutableMap.of()); - } -} diff --git a/labs/joyent-cloudapi/src/test/java/org/jclouds/joyent/cloudapi/v6_5/features/DatacenterApiLiveTest.java b/labs/joyent-cloudapi/src/test/java/org/jclouds/joyent/cloudapi/v6_5/features/DatacenterApiLiveTest.java deleted file mode 100644 index 05ad7d4b0e..0000000000 --- a/labs/joyent-cloudapi/src/test/java/org/jclouds/joyent/cloudapi/v6_5/features/DatacenterApiLiveTest.java +++ /dev/null @@ -1,41 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.joyent.cloudapi.v6_5.features; - -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertTrue; - -import java.net.URI; -import java.util.Map; - -import org.jclouds.joyent.cloudapi.v6_5.internal.BaseJoyentCloudApiLiveTest; -import org.testng.annotations.Test; - -/** - * @author Adrian Cole - */ -@Test(groups = "live", testName = "DatacenterApiLiveTest") -public class DatacenterApiLiveTest extends BaseJoyentCloudApiLiveTest { - - public void testGetDatacenters() { - Map dcs = cloudApiContext.getApi().getDatacenterApi().getDatacenters(); - assertNotNull(dcs); - assertTrue(dcs.size() > 0); - } -} diff --git a/labs/joyent-cloudapi/src/test/java/org/jclouds/joyent/cloudapi/v6_5/features/DatasetApiExpectTest.java b/labs/joyent-cloudapi/src/test/java/org/jclouds/joyent/cloudapi/v6_5/features/DatasetApiExpectTest.java deleted file mode 100644 index af5dac9cd7..0000000000 --- a/labs/joyent-cloudapi/src/test/java/org/jclouds/joyent/cloudapi/v6_5/features/DatasetApiExpectTest.java +++ /dev/null @@ -1,61 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unles required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either expres or implied. See the License for the - * specific language governing permisions and limitations - * under the License. - */ -package org.jclouds.joyent.cloudapi.v6_5.features; - -import static org.testng.Assert.assertEquals; - -import org.jclouds.http.HttpRequest; -import org.jclouds.http.HttpResponse; -import org.jclouds.joyent.cloudapi.v6_5.JoyentCloudApi; -import org.jclouds.joyent.cloudapi.v6_5.internal.BaseJoyentCloudApiExpectTest; -import org.jclouds.joyent.cloudapi.v6_5.parse.ParseDatasetListTest; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableSet; - -/** - * @author Gerald Pereira - */ -@Test(groups = "unit", testName = "DatasetApiExpectTest") -public class DatasetApiExpectTest extends BaseJoyentCloudApiExpectTest { - public HttpRequest list = HttpRequest.builder().method("GET") - .endpoint("https://us-sw-1.api.joyentcloud.com/my/datasets") - .addHeader("X-Api-Version", "~6.5") - .addHeader("Accept", "application/json") - .addHeader("Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==").build(); - - public HttpResponse listResponse = HttpResponse.builder().statusCode(200) - .payload(payloadFromResource("/dataset_list.json")).build(); - - public void testListDatasetsWhenResponseIs2xx() { - - JoyentCloudApi apiWhenDatasetsExists = requestsSendResponses(getDatacenters, getDatacentersResponse, list, listResponse); - - assertEquals(apiWhenDatasetsExists.getDatasetApiForDatacenter("us-sw-1").list().toString(), new ParseDatasetListTest() - .expected().toString()); - } - - public void testListDatasetsWhenResponseIs404() { - HttpResponse listResponse = HttpResponse.builder().statusCode(404).build(); - - JoyentCloudApi listWhenNone = requestsSendResponses(getDatacenters, getDatacentersResponse, list, listResponse); - - assertEquals(listWhenNone.getDatasetApiForDatacenter("us-sw-1").list(), ImmutableSet.of()); - } -} diff --git a/labs/joyent-cloudapi/src/test/java/org/jclouds/joyent/cloudapi/v6_5/features/DatasetApiLiveTest.java b/labs/joyent-cloudapi/src/test/java/org/jclouds/joyent/cloudapi/v6_5/features/DatasetApiLiveTest.java deleted file mode 100644 index f37f5bcafa..0000000000 --- a/labs/joyent-cloudapi/src/test/java/org/jclouds/joyent/cloudapi/v6_5/features/DatasetApiLiveTest.java +++ /dev/null @@ -1,54 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.joyent.cloudapi.v6_5.features; - -import static org.testng.Assert.assertEquals; - -import java.util.Set; - -import org.jclouds.joyent.cloudapi.v6_5.domain.Dataset; -import org.jclouds.joyent.cloudapi.v6_5.features.DatasetApi; -import org.jclouds.joyent.cloudapi.v6_5.internal.BaseJoyentCloudApiLiveTest; -import org.testng.annotations.Test; - -/** - * @author Gerald Pereira - */ -@Test(groups = "live", testName = "DatasetApiLiveTest") -public class DatasetApiLiveTest extends BaseJoyentCloudApiLiveTest { - - @Test - public void testListAndGetDatasets() throws Exception { - for (String datacenterId : cloudApiContext.getApi().getConfiguredDatacenters()) { - DatasetApi api = cloudApiContext.getApi().getDatasetApiForDatacenter(datacenterId); - Set response = api.list(); - assert null != response; - for (Dataset dataset : response) { - Dataset newDetails = api.get(dataset.getId()); - assertEquals(newDetails.getId(), dataset.getId()); - assertEquals(newDetails.getName(), dataset.getName()); - assertEquals(newDetails.getType(), dataset.getType()); - assertEquals(newDetails.getVersion(), dataset.getVersion()); - assertEquals(newDetails.getUrn(), dataset.getUrn()); - assertEquals(newDetails.getCreated(), dataset.getCreated()); - assertEquals(newDetails.isDefault(), dataset.isDefault()); - } - } - } -} diff --git a/labs/joyent-cloudapi/src/test/java/org/jclouds/joyent/cloudapi/v6_5/features/KeyApiExpectTest.java b/labs/joyent-cloudapi/src/test/java/org/jclouds/joyent/cloudapi/v6_5/features/KeyApiExpectTest.java deleted file mode 100644 index dc37fab7c1..0000000000 --- a/labs/joyent-cloudapi/src/test/java/org/jclouds/joyent/cloudapi/v6_5/features/KeyApiExpectTest.java +++ /dev/null @@ -1,83 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unles required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either expres or implied. See the License for the - * specific language governing permisions and limitations - * under the License. - */ -package org.jclouds.joyent.cloudapi.v6_5.features; - -import static org.testng.Assert.assertEquals; - -import org.jclouds.http.HttpRequest; -import org.jclouds.http.HttpResponse; -import org.jclouds.joyent.cloudapi.v6_5.JoyentCloudApi; -import org.jclouds.joyent.cloudapi.v6_5.internal.BaseJoyentCloudApiExpectTest; -import org.jclouds.joyent.cloudapi.v6_5.parse.ParseKeyListTest; -import org.jclouds.joyent.cloudapi.v6_5.parse.ParseKeyTest; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableSet; - -/** - * @author Adrian Cole - */ -@Test(groups = "unit", testName = "KeyApiExpectTest") -public class KeyApiExpectTest extends BaseJoyentCloudApiExpectTest { - public HttpRequest list = HttpRequest.builder().method("GET") - .endpoint("https://api.joyentcloud.com/my/keys") - .addHeader("X-Api-Version", "~6.5") - .addHeader("Accept", "application/json") - .addHeader("Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==").build(); - - public HttpResponse listResponse = HttpResponse.builder().statusCode(200).payload( - payloadFromResource("/key_list.json")).build(); - - public void testListKeysWhenResponseIs2xx() { - - JoyentCloudApi apiWhenKeysExists = requestsSendResponses(getDatacenters, getDatacentersResponse, list, listResponse); - - assertEquals(apiWhenKeysExists.getKeyApi().list(), new ParseKeyListTest().expected()); - } - - public void testListKeysWhenResponseIs404() { - HttpResponse listResponse = HttpResponse.builder().statusCode(404).build(); - - JoyentCloudApi listWhenNone = requestsSendResponses(getDatacenters, getDatacentersResponse, list, listResponse); - - assertEquals(listWhenNone.getKeyApi().list(), ImmutableSet.of()); - } - - public void testCreateKeyWhenResponseIs202() throws Exception { - HttpRequest create = HttpRequest.builder() - .method("POST") - .endpoint("https://api.joyentcloud.com/my/keys") - .addHeader("X-Api-Version", "~6.5") - .addHeader("Accept", "application/json") - .addHeader("Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==") - .payload( - payloadFromStringWithContentType( - "{\"name\":\"rsa\",\"key\":\"ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA0A5Pf5Cq...\"}", - "application/json")).build(); - - HttpResponse createResponse = HttpResponse.builder().statusCode(202).message("HTTP/1.1 202 Accepted") - .payload(payloadFromResourceWithContentType("/key.json", "application/json; charset=UTF-8")) - .build(); - - JoyentCloudApi apiWithNewKey = requestsSendResponses(getDatacenters, getDatacentersResponse, create, createResponse); - - assertEquals(apiWithNewKey.getKeyApi().create(new ParseKeyTest().expected()) - .toString(), new ParseKeyTest().expected().toString()); - } -} diff --git a/labs/joyent-cloudapi/src/test/java/org/jclouds/joyent/cloudapi/v6_5/features/KeyApiLiveTest.java b/labs/joyent-cloudapi/src/test/java/org/jclouds/joyent/cloudapi/v6_5/features/KeyApiLiveTest.java deleted file mode 100644 index 35b0400584..0000000000 --- a/labs/joyent-cloudapi/src/test/java/org/jclouds/joyent/cloudapi/v6_5/features/KeyApiLiveTest.java +++ /dev/null @@ -1,87 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.joyent.cloudapi.v6_5.features; - -import static org.testng.Assert.assertEquals; - -import java.util.Set; - -import org.jclouds.joyent.cloudapi.v6_5.domain.Key; -import org.jclouds.joyent.cloudapi.v6_5.features.KeyApi; -import org.jclouds.joyent.cloudapi.v6_5.internal.BaseJoyentCloudApiLiveTest; -import org.jclouds.ssh.SshKeys; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.Test; - -/** - * @author Adrian Cole - */ -@Test(groups = "live", singleThreaded = true, testName = "KeyApiLiveTest") -public class KeyApiLiveTest extends BaseJoyentCloudApiLiveTest { - - @Test - public void testListAndGetKeys() throws Exception { - KeyApi api = cloudApiContext.getApi().getKeyApi(); - Set response = api.list(); - assert null != response; - for (Key key : response) { - Key newDetails = api.get(key.getName()); - assertEquals(newDetails.getName(), key.getName()); - assertEquals(newDetails.get(), key.get()); - assertEquals(newDetails.getCreated(), key.getCreated()); - } - - } - - private String keyText; - private String fingerprint; - - @BeforeTest - public void initKeys() { - keyText = SshKeys.generate().get("public"); - fingerprint = SshKeys.fingerprintPublicKey(keyText); - } - - public void testCreateKey() { - KeyApi api = cloudApiContext.getApi().getKeyApi(); - - Key newKey = api.create(Key.builder().name(fingerprint).key(keyText).build()); - assertEquals(newKey.getName(), fingerprint); - assertEquals(newKey.get(), keyText); - - newKey = api.get(fingerprint); - assertEquals(newKey.getName(), fingerprint); - assertEquals(newKey.get(), keyText); - } - - @Test(dependsOnMethods = "testCreateKey", expectedExceptions = IllegalStateException.class) - public void testDuplicateKey() { - KeyApi api = cloudApiContext.getApi().getKeyApi(); - api.create(Key.builder().name(fingerprint).key(keyText).build()); - } - - @Test(dependsOnMethods = "testDuplicateKey") - public void testDestroyKey() { - final KeyApi api = cloudApiContext.getApi().getKeyApi(); - api.delete(fingerprint); - // not that eventhough the key is destroyed it is visible via GET for at - // least 45 seconds. This may be a cache issue on the server - } - -} diff --git a/labs/joyent-cloudapi/src/test/java/org/jclouds/joyent/cloudapi/v6_5/features/MachineApiExpectTest.java b/labs/joyent-cloudapi/src/test/java/org/jclouds/joyent/cloudapi/v6_5/features/MachineApiExpectTest.java deleted file mode 100644 index 7032dccf35..0000000000 --- a/labs/joyent-cloudapi/src/test/java/org/jclouds/joyent/cloudapi/v6_5/features/MachineApiExpectTest.java +++ /dev/null @@ -1,85 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unles required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either expres or implied. See the License for the - * specific language governing permisions and limitations - * under the License. - */ -package org.jclouds.joyent.cloudapi.v6_5.features; - -import static org.testng.Assert.assertEquals; - -import org.jclouds.http.HttpRequest; -import org.jclouds.http.HttpResponse; -import org.jclouds.joyent.cloudapi.v6_5.JoyentCloudApi; -import org.jclouds.joyent.cloudapi.v6_5.internal.BaseJoyentCloudApiExpectTest; -import org.jclouds.joyent.cloudapi.v6_5.options.CreateMachineOptions; -import org.jclouds.joyent.cloudapi.v6_5.parse.ParseCreatedMachineTest; -import org.jclouds.joyent.cloudapi.v6_5.parse.ParseMachineListTest; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableSet; - -/** - * @author Gerald Pereira - */ -@Test(groups = "unit", testName = "MachineApiExpectTest") -public class MachineApiExpectTest extends BaseJoyentCloudApiExpectTest { - public HttpRequest list = HttpRequest.builder().method("GET") - .endpoint("https://us-sw-1.api.joyentcloud.com/my/machines") - .addHeader("X-Api-Version", "~6.5") - .addHeader("Accept", "application/json") - .addHeader("Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==").build(); - - public HttpResponse listResponse = HttpResponse.builder().statusCode(200).payload( - payloadFromResource("/machine_list.json")).build(); - - public void testListMachinesWhenResponseIs2xx() { - - JoyentCloudApi apiWhenMachinesExists = requestsSendResponses(getDatacenters, getDatacentersResponse, list, listResponse); - - assertEquals(apiWhenMachinesExists.getMachineApiForDatacenter("us-sw-1").list(), new ParseMachineListTest().expected()); - } - - public void testListMachinesWhenResponseIs404() { - HttpResponse listResponse = HttpResponse.builder().statusCode(404).build(); - - JoyentCloudApi listWhenNone = requestsSendResponses(getDatacenters, getDatacentersResponse, list, listResponse); - - assertEquals(listWhenNone.getMachineApiForDatacenter("us-sw-1").list(), ImmutableSet.of()); - } - - public void testCreateMachineWhenResponseIs202() throws Exception { - HttpRequest createWithDataset = HttpRequest - .builder() - .method("POST") - .endpoint("https://us-sw-1.api.joyentcloud.com/my/machines?dataset=sdc%3Asdc%3Acentos-5.7%3A1.2.1&name=sample-e92&package=Small%201GB") - .addHeader("X-Api-Version", "~6.5") - .addHeader("Accept", "application/json") - .addHeader("Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==").build(); - - HttpResponse createWithDatasetResponse = HttpResponse.builder().statusCode(202).message("HTTP/1.1 202 Accepted") - .payload(payloadFromResourceWithContentType("/new_machine.json", "application/json; charset=UTF-8")) - .build(); - - JoyentCloudApi apiWithNewMachine = requestsSendResponses(getDatacenters, getDatacentersResponse, createWithDataset, createWithDatasetResponse); - - assertEquals( - apiWithNewMachine - .getMachineApiForDatacenter("us-sw-1") - .createWithDataset("sdc:sdc:centos-5.7:1.2.1", - CreateMachineOptions.Builder.name("sample-e92").packageName("Small 1GB")).toString(), - new ParseCreatedMachineTest().expected().toString()); - } -} diff --git a/labs/joyent-cloudapi/src/test/java/org/jclouds/joyent/cloudapi/v6_5/features/MachineApiLiveTest.java b/labs/joyent-cloudapi/src/test/java/org/jclouds/joyent/cloudapi/v6_5/features/MachineApiLiveTest.java deleted file mode 100644 index 0a51238031..0000000000 --- a/labs/joyent-cloudapi/src/test/java/org/jclouds/joyent/cloudapi/v6_5/features/MachineApiLiveTest.java +++ /dev/null @@ -1,166 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.joyent.cloudapi.v6_5.features; - -import static com.google.common.base.Predicates.not; -import static java.util.concurrent.TimeUnit.SECONDS; -import static org.jclouds.util.Predicates2.retry; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertTrue; - -import java.util.Map; -import java.util.Set; - -import org.jclouds.compute.domain.ExecResponse; -import org.jclouds.domain.LoginCredentials; -import org.jclouds.joyent.cloudapi.v6_5.domain.Key; -import org.jclouds.joyent.cloudapi.v6_5.domain.Machine; -import org.jclouds.joyent.cloudapi.v6_5.internal.BaseJoyentCloudApiLiveTest; -import org.jclouds.joyent.cloudapi.v6_5.options.CreateMachineOptions; -import org.jclouds.joyent.cloudapi.v6_5.reference.Metadata; -import org.jclouds.predicates.SocketOpen; -import org.jclouds.ssh.SshClient; -import org.jclouds.ssh.SshKeys; -import org.jclouds.sshj.config.SshjSshClientModule; -import org.jclouds.util.InetAddresses2; -import org.testng.annotations.AfterGroups; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -import com.google.common.base.Predicate; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.Iterables; -import com.google.common.net.HostAndPort; -import com.google.inject.Module; - -/** - * @author Adrian Cole - */ -@Test(groups = "live", testName = "MachineApiLiveTest") -public class MachineApiLiveTest extends BaseJoyentCloudApiLiveTest { - - @Test - public void testListAndGetMachines() throws Exception { - for (String datacenterId : cloudApiContext.getApi().getConfiguredDatacenters()) { - MachineApi api = cloudApiContext.getApi().getMachineApiForDatacenter(datacenterId); - Set response = api.list(); - assert null != response; - for (Machine machine : response) { - Machine newDetails = api.get(machine.getId()); - assertEquals(newDetails.getId(), machine.getId()); - assertEquals(newDetails.getName(), machine.getName()); - assertEquals(newDetails.getType(), machine.getType()); - assertEquals(newDetails.getState(), machine.getState()); - assertEquals(newDetails.getDatasetURN(), machine.getDatasetURN()); - assertEquals(newDetails.getMemorySizeMb(), machine.getMemorySizeMb()); - assertEquals(newDetails.getDiskSizeGb(), machine.getDiskSizeGb()); - assertEquals(newDetails.getIps(), machine.getIps()); - assertEquals(newDetails.getCreated(), machine.getCreated()); - assertEquals(newDetails.getUpdated(), machine.getUpdated()); - assertEquals(newDetails.getMetadata(), machine.getMetadata()); - } - } - } - - private Map key; - private String fingerprint; - private Predicate socketTester; - private Predicate machineRunning; - private MachineApi api; - private Machine machine; - protected String datasetURN = System.getProperty("test." + provider + ".image-id", "sdc:sdc:ubuntu-10.04:1.0.1"); - private String name; - - @BeforeClass(groups = { "integration", "live" }) - @Override - public void setupContext() { - super.setupContext(); - key = SshKeys.generate(); - fingerprint = SshKeys.fingerprintPublicKey(key.get("public")); - cloudApiContext.getApi().getKeyApi().create(Key.builder().name(fingerprint).key(key.get("public")).build()); - api = cloudApiContext.getApi().getMachineApiForDatacenter( - Iterables.get(cloudApiContext.getApi().getConfiguredDatacenters(), 0)); - SocketOpen socketOpen = context.utils().injector().getInstance(SocketOpen.class); - socketTester = retry(socketOpen, 180, 1, 1, SECONDS); - machineRunning = retry(new Predicate() { - public boolean apply(Machine input) { - return api.get(input.getId()).getState() == Machine.State.RUNNING; - } - }, 600, 5, 5, SECONDS); - } - - public void testCreateMachine() { - Machine newMachine = api.createWithDataset(datasetURN, - CreateMachineOptions.Builder.metadata(ImmutableMap.of("foo", "bar"))); - machine = newMachine; - name = newMachine.getName(); - - assertEquals(newMachine.getMetadata().get("foo").toString(), "bar"); - assertTrue( - newMachine.getMetadata().get(Metadata.ROOT_AUTHORIZED_KEYS.key()).indexOf(key.get("public")) != -1, - newMachine + "; key: " + key.get("public")); - - assertTrue(machineRunning.apply(newMachine), newMachine.toString()); - machine = api.get(newMachine.getId()); - - } - - @Test(dependsOnMethods = "testCreateMachine", expectedExceptions = IllegalStateException.class) - public void testDuplicateMachineThrowsIllegalStateException() { - api.createWithDataset(datasetURN, CreateMachineOptions.Builder.name(name)); - } - - @Test(dependsOnMethods = "testCreateMachine") - protected void testSsh() { - String publicAddress = Iterables.find(machine.getIps(), not(InetAddresses2.IsPrivateIPAddress.INSTANCE)); - HostAndPort socket = HostAndPort.fromParts(publicAddress, 22); - assertTrue(socketTester.apply(socket), socket.toString()); - SshClient api = context.utils().injector().getInstance(SshClient.Factory.class) - .create(socket, LoginCredentials.builder().user("root").privateKey(key.get("private")).build()); - try { - api.connect(); - ExecResponse exec = api.exec("echo hello"); - System.out.println(exec); - assertEquals(exec.getOutput().trim(), "hello"); - } finally { - if (api != null) - api.disconnect(); - } - } - - @Test(dependsOnMethods = "testSsh") - public void testDeleteMachine() { - api.delete(machine.getId()); - } - - - @AfterGroups(groups = "live") - @Override - protected void tearDownContext() { - if (machine != null) - api.delete(machine.getId()); - cloudApiContext.getApi().getKeyApi().delete(fingerprint); - super.tearDownContext(); - } - - @Override - protected Module getSshModule() { - return new SshjSshClientModule(); - } -} diff --git a/labs/joyent-cloudapi/src/test/java/org/jclouds/joyent/cloudapi/v6_5/features/PackageApiExpectTest.java b/labs/joyent-cloudapi/src/test/java/org/jclouds/joyent/cloudapi/v6_5/features/PackageApiExpectTest.java deleted file mode 100644 index 35dc828ab2..0000000000 --- a/labs/joyent-cloudapi/src/test/java/org/jclouds/joyent/cloudapi/v6_5/features/PackageApiExpectTest.java +++ /dev/null @@ -1,60 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unles required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either expres or implied. See the License for the - * specific language governing permisions and limitations - * under the License. - */ -package org.jclouds.joyent.cloudapi.v6_5.features; - -import static org.testng.Assert.assertEquals; - -import org.jclouds.http.HttpRequest; -import org.jclouds.http.HttpResponse; -import org.jclouds.joyent.cloudapi.v6_5.JoyentCloudApi; -import org.jclouds.joyent.cloudapi.v6_5.internal.BaseJoyentCloudApiExpectTest; -import org.jclouds.joyent.cloudapi.v6_5.parse.ParsePackageListTest; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableSet; - -/** - * @author Gerald Pereira - */ -@Test(groups = "unit", testName = "PackageApiExpectTest") -public class PackageApiExpectTest extends BaseJoyentCloudApiExpectTest { - public HttpRequest list = HttpRequest.builder().method("GET") - .endpoint("https://us-sw-1.api.joyentcloud.com/my/packages") - .addHeader("X-Api-Version", "~6.5") - .addHeader("Accept", "application/json") - .addHeader("Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==").build(); - - public HttpResponse listResponse = HttpResponse.builder().statusCode(200) - .payload(payloadFromResource("/package_list.json")).build(); - - public void testListPackagesWhenResponseIs2xx() { - - JoyentCloudApi apiWhenPackagesExists = requestsSendResponses(getDatacenters, getDatacentersResponse, list, listResponse); - - assertEquals(apiWhenPackagesExists.getPackageApiForDatacenter("us-sw-1").list(), new ParsePackageListTest().expected()); - } - - public void testListPackagesWhenResponseIs404() { - HttpResponse listResponse = HttpResponse.builder().statusCode(404).build(); - - JoyentCloudApi listWhenNone = requestsSendResponses(getDatacenters, getDatacentersResponse, list, listResponse); - - assertEquals(listWhenNone.getPackageApiForDatacenter("us-sw-1").list(), ImmutableSet.of()); - } -} diff --git a/labs/joyent-cloudapi/src/test/java/org/jclouds/joyent/cloudapi/v6_5/features/PackageApiLiveTest.java b/labs/joyent-cloudapi/src/test/java/org/jclouds/joyent/cloudapi/v6_5/features/PackageApiLiveTest.java deleted file mode 100644 index 797ebb4c78..0000000000 --- a/labs/joyent-cloudapi/src/test/java/org/jclouds/joyent/cloudapi/v6_5/features/PackageApiLiveTest.java +++ /dev/null @@ -1,52 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.joyent.cloudapi.v6_5.features; - -import static org.testng.Assert.assertEquals; - -import java.util.Set; - -import org.jclouds.joyent.cloudapi.v6_5.domain.Package; -import org.jclouds.joyent.cloudapi.v6_5.features.PackageApi; -import org.jclouds.joyent.cloudapi.v6_5.internal.BaseJoyentCloudApiLiveTest; -import org.testng.annotations.Test; - -/** - * @author Gerald Pereira - */ -@Test(groups = "live", testName = "PackageApiLiveTest") -public class PackageApiLiveTest extends BaseJoyentCloudApiLiveTest { - - @Test - public void testListAndGetPackages() throws Exception { - for (String datacenterId : cloudApiContext.getApi().getConfiguredDatacenters()) { - PackageApi api = cloudApiContext.getApi().getPackageApiForDatacenter(datacenterId); - Set response = api.list(); - assert null != response; - for (Package pkg : response) { - Package newDetails = api.get(pkg.getName()); - assertEquals(newDetails.getName(), pkg.getName()); - assertEquals(newDetails.getMemorySizeMb(), pkg.getMemorySizeMb()); - assertEquals(newDetails.getDiskSizeGb(), pkg.getDiskSizeGb()); - assertEquals(newDetails.getSwapSizeMb(), pkg.getSwapSizeMb()); - assertEquals(newDetails.isDefault(), pkg.isDefault()); - } - } - } -} diff --git a/labs/joyent-cloudapi/src/test/java/org/jclouds/joyent/cloudapi/v6_5/handlers/JoyentCloudErrorHandlerTest.java b/labs/joyent-cloudapi/src/test/java/org/jclouds/joyent/cloudapi/v6_5/handlers/JoyentCloudErrorHandlerTest.java deleted file mode 100644 index b67360f6e4..0000000000 --- a/labs/joyent-cloudapi/src/test/java/org/jclouds/joyent/cloudapi/v6_5/handlers/JoyentCloudErrorHandlerTest.java +++ /dev/null @@ -1,97 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.joyent.cloudapi.v6_5.handlers; - -import static org.easymock.EasyMock.createMock; -import static org.easymock.EasyMock.expect; -import static org.easymock.EasyMock.replay; -import static org.easymock.EasyMock.reportMatcher; -import static org.easymock.EasyMock.verify; - -import java.net.URI; - -import org.easymock.IArgumentMatcher; -import org.jclouds.http.HttpCommand; -import org.jclouds.http.HttpRequest; -import org.jclouds.http.HttpResponse; -import org.testng.annotations.Test; - -/** - * - * @author Adrian Cole - */ -@Test(groups = "unit", testName = "JoyentCloudErrorHandlerTest") -public class JoyentCloudErrorHandlerTest { - - @Test - public void test409MakesIllegalStateException() { - assertCodeMakes( - "POST", - URI.create("https://us-east-1.api.joyentcloud.com/my/machines/b7d07c64-ba40-496a-a19a-3f1d028494ff"), - 409, - "HTTP/1.1 409 Conflict", - "\"{\"code\":\"InvalidState\",\"message\":\"An incompatible transition has already been queued for this resource\"}\"", - IllegalStateException.class); - } - - private void assertCodeMakes(String method, URI uri, int statusCode, String message, String content, - Class expected) { - assertCodeMakes(method, uri, statusCode, message, "application/json", content, expected); - } - - private void assertCodeMakes(String method, URI uri, int statusCode, String message, String contentType, - String content, Class expected) { - - JoyentCloudErrorHandler function = new JoyentCloudErrorHandler(); - - HttpCommand command = createMock(HttpCommand.class); - HttpRequest request = HttpRequest.builder().method(method).endpoint(uri).build(); - HttpResponse response = HttpResponse.builder().statusCode(statusCode).message(message).payload(content).build(); - response.getPayload().getContentMetadata().setContentType(contentType); - - expect(command.getCurrentRequest()).andReturn(request).atLeastOnce(); - command.setException(classEq(expected)); - - replay(command); - - function.handleError(command, response); - - verify(command); - } - - public static Exception classEq(final Class in) { - reportMatcher(new IArgumentMatcher() { - - @Override - public void appendTo(StringBuffer buffer) { - buffer.append("classEq("); - buffer.append(in); - buffer.append(")"); - } - - @Override - public boolean matches(Object arg) { - return arg.getClass() == in; - } - - }); - return null; - } - -} diff --git a/labs/joyent-cloudapi/src/test/java/org/jclouds/joyent/cloudapi/v6_5/internal/BaseJoyentCloudApiExpectTest.java b/labs/joyent-cloudapi/src/test/java/org/jclouds/joyent/cloudapi/v6_5/internal/BaseJoyentCloudApiExpectTest.java deleted file mode 100644 index 180560b427..0000000000 --- a/labs/joyent-cloudapi/src/test/java/org/jclouds/joyent/cloudapi/v6_5/internal/BaseJoyentCloudApiExpectTest.java +++ /dev/null @@ -1,30 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.joyent.cloudapi.v6_5.internal; - -import org.jclouds.joyent.cloudapi.v6_5.JoyentCloudApi; - -/** - * Base class for writing Cloud Api Rest Api Expect tests - * - * @author Adrian Cole - */ -public class BaseJoyentCloudApiExpectTest extends BaseJoyentCloudExpectTest { - -} diff --git a/labs/joyent-cloudapi/src/test/java/org/jclouds/joyent/cloudapi/v6_5/internal/BaseJoyentCloudApiLiveTest.java b/labs/joyent-cloudapi/src/test/java/org/jclouds/joyent/cloudapi/v6_5/internal/BaseJoyentCloudApiLiveTest.java deleted file mode 100644 index f9aeb9c8dd..0000000000 --- a/labs/joyent-cloudapi/src/test/java/org/jclouds/joyent/cloudapi/v6_5/internal/BaseJoyentCloudApiLiveTest.java +++ /dev/null @@ -1,56 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.joyent.cloudapi.v6_5.internal; - -import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest; -import org.jclouds.joyent.cloudapi.v6_5.JoyentCloudApi; -import org.jclouds.joyent.cloudapi.v6_5.JoyentCloudAsyncApi; -import org.jclouds.rest.RestContext; -import org.jclouds.sshj.config.SshjSshClientModule; -import org.testng.annotations.BeforeGroups; -import org.testng.annotations.Test; - -import com.google.inject.Module; - -/** - * Tests behavior of {@code JoyentCloudApi} - * - * @author Adrian Cole - */ -@Test(groups = "live") -public class BaseJoyentCloudApiLiveTest extends BaseComputeServiceContextLiveTest { - - public BaseJoyentCloudApiLiveTest() { - provider = "joyent-cloudapi"; - } - - protected RestContext cloudApiContext; - - @BeforeGroups(groups = { "integration", "live" }) - @Override - public void setupContext() { - super.setupContext(); - cloudApiContext = view.unwrap(); - } - - @Override - protected Module getSshModule() { - return new SshjSshClientModule(); - } -} diff --git a/labs/joyent-cloudapi/src/test/java/org/jclouds/joyent/cloudapi/v6_5/internal/BaseJoyentCloudAsyncApiExpectTest.java b/labs/joyent-cloudapi/src/test/java/org/jclouds/joyent/cloudapi/v6_5/internal/BaseJoyentCloudAsyncApiExpectTest.java deleted file mode 100644 index 538dd558d1..0000000000 --- a/labs/joyent-cloudapi/src/test/java/org/jclouds/joyent/cloudapi/v6_5/internal/BaseJoyentCloudAsyncApiExpectTest.java +++ /dev/null @@ -1,39 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.joyent.cloudapi.v6_5.internal; - -import java.util.Properties; - -import org.jclouds.http.HttpRequest; -import org.jclouds.http.HttpResponse; -import org.jclouds.joyent.cloudapi.v6_5.JoyentCloudAsyncApi; - -import com.google.common.base.Function; -import com.google.inject.Module; - -/** - * Base class for writing Cloud Api Rest Api Expect tests - * - * @author Adrian Cole - */ -public class BaseJoyentCloudAsyncApiExpectTest extends BaseJoyentCloudExpectTest { - public JoyentCloudAsyncApi createClient(Function fn, Module module, Properties props) { - return createInjector(fn, module, props).getInstance(JoyentCloudAsyncApi.class); - } -} diff --git a/labs/joyent-cloudapi/src/test/java/org/jclouds/joyent/cloudapi/v6_5/internal/BaseJoyentCloudExpectTest.java b/labs/joyent-cloudapi/src/test/java/org/jclouds/joyent/cloudapi/v6_5/internal/BaseJoyentCloudExpectTest.java deleted file mode 100644 index 30aa44153a..0000000000 --- a/labs/joyent-cloudapi/src/test/java/org/jclouds/joyent/cloudapi/v6_5/internal/BaseJoyentCloudExpectTest.java +++ /dev/null @@ -1,44 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.joyent.cloudapi.v6_5.internal; - -import org.jclouds.http.HttpRequest; -import org.jclouds.http.HttpResponse; -import org.jclouds.rest.internal.BaseRestApiExpectTest; - -/** - * Base class for writing JoyentCloud Expect tests - * - * @author Adrian Cole - */ -public class BaseJoyentCloudExpectTest extends BaseRestApiExpectTest { - protected HttpRequest getDatacenters = HttpRequest.builder() - .method("GET") - .endpoint("https://api.joyentcloud.com/my/datacenters") - .addHeader("X-Api-Version", "~6.5") - .addHeader("Accept", "application/json") - .addHeader("Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==").build(); - - protected HttpResponse getDatacentersResponse = HttpResponse.builder().statusCode(200) - .payload(payloadFromResource("/datacenters.json")).build(); - - public BaseJoyentCloudExpectTest() { - provider = "joyent-cloudapi"; - } -} diff --git a/labs/joyent-cloudapi/src/test/java/org/jclouds/joyent/cloudapi/v6_5/parse/ParseCreatedMachineTest.java b/labs/joyent-cloudapi/src/test/java/org/jclouds/joyent/cloudapi/v6_5/parse/ParseCreatedMachineTest.java deleted file mode 100644 index b69966f91d..0000000000 --- a/labs/joyent-cloudapi/src/test/java/org/jclouds/joyent/cloudapi/v6_5/parse/ParseCreatedMachineTest.java +++ /dev/null @@ -1,80 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.joyent.cloudapi.v6_5.parse; - -import javax.ws.rs.Consumes; -import javax.ws.rs.core.MediaType; - -import org.jclouds.date.internal.SimpleDateFormatDateService; -import org.jclouds.domain.JsonBall; -import org.jclouds.joyent.cloudapi.v6_5.domain.Machine; -import org.jclouds.joyent.cloudapi.v6_5.domain.Machine.Type; -import org.jclouds.json.BaseItemParserTest; -import org.jclouds.json.config.GsonModule; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; -import com.google.inject.Guice; -import com.google.inject.Injector; - -/** - * @author Gerald Pereira - */ -@Test(groups = "unit", testName = "ParseMachineTest") -public class ParseCreatedMachineTest extends BaseItemParserTest { - - @Override - public String resource() { - return "/new_machine.json"; - } - - @Override - @Consumes(MediaType.APPLICATION_JSON) - public Machine expected() { - return Machine - .builder() - .id("94eba336-ecb7-49f5-8a27-52f5e4dd57a1") - .name("sample-e92") - .type(Type.VIRTUALMACHINE) - .state(Machine.State.STOPPED) - .dataset("sdc:sdc:centos-5.7:1.2.1") - .ips(ImmutableSet. builder().add("37.153.96.62").add("10.224.0.63").build()) - .memorySizeMb(1024) - .diskSizeGb(61440) - .metadata( - ImmutableMap. builder() - .put("root_authorized_keys", new JsonBall("ssh-rsa XXXXXX== test@xxxx.ovh.net\n")).build()) - .created(new SimpleDateFormatDateService().iso8601SecondsDateParse("2012-05-09T13:32:46+00:00")) - .updated(new SimpleDateFormatDateService().iso8601SecondsDateParse("2012-05-11T08:44:53+00:00")) - .build(); - } - - protected Injector injector() { - return Guice.createInjector(new GsonModule() { - - @Override - protected void configure() { - bind(DateAdapter.class).to(Iso8601DateAdapter.class); - super.configure(); - } - - }); - } -} diff --git a/labs/joyent-cloudapi/src/test/java/org/jclouds/joyent/cloudapi/v6_5/parse/ParseDatasetListTest.java b/labs/joyent-cloudapi/src/test/java/org/jclouds/joyent/cloudapi/v6_5/parse/ParseDatasetListTest.java deleted file mode 100644 index dc24b6ad6c..0000000000 --- a/labs/joyent-cloudapi/src/test/java/org/jclouds/joyent/cloudapi/v6_5/parse/ParseDatasetListTest.java +++ /dev/null @@ -1,98 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.joyent.cloudapi.v6_5.parse; - -import java.util.Set; - -import javax.ws.rs.Consumes; -import javax.ws.rs.core.MediaType; - -import org.jclouds.date.internal.SimpleDateFormatDateService; -import org.jclouds.joyent.cloudapi.v6_5.domain.Dataset; -import org.jclouds.joyent.cloudapi.v6_5.domain.Machine.Type; -import org.jclouds.json.BaseSetParserTest; -import org.jclouds.json.config.GsonModule; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableSet; -import com.google.inject.Guice; -import com.google.inject.Injector; - -/** - * @author Gerald Pereira - */ -@Test(groups = "unit", testName = "ParseDatasetListTest") -public class ParseDatasetListTest extends BaseSetParserTest { - - @Override - public String resource() { - return "/dataset_list.json"; - } - - @Override - @Consumes(MediaType.APPLICATION_JSON) - public Set expected() { - return ImmutableSet.of( - Dataset.builder() - .id("71101322-43a5-11e1-8f01-cf2a3031a7f4") - .urn("sdc:sdc:ubuntu-10.04:1.0.1") - .name("ubuntu-10.04") - .os("linux") - .type(Type.VIRTUALMACHINE) - .description("Ubuntu 10.04 VM 1.0.1") - .version("1.0.1") - .created(new SimpleDateFormatDateService().iso8601SecondsDateParse("2012-02-22T18:27:32+00:00")) - .build(), - - Dataset.builder() - .id("e4cd7b9e-4330-11e1-81cf-3bb50a972bda") - .urn("sdc:sdc:centos-6:1.0.1") - .name("centos-6") - .os("linux") - .type(Type.VIRTUALMACHINE) - .description("Centos 6 VM 1.0.1") - .version("1.0.1") - .created(new SimpleDateFormatDateService().iso8601SecondsDateParse("2012-02-15T20:04:18+00:00")) - .build(), - - Dataset.builder() - .id("9551fdbc-cc9a-11e1-a9e7-eb1e788a8690") - .urn("sdc:sdc:standard64:1.0.1") - .name("standard64") - .os("smartos") - .type(Type.SMARTMACHINE) - .description("64-bit machine image optimized for web development") - .version("1.0.1") - .created(new SimpleDateFormatDateService().iso8601SecondsDateParse("2012-07-13T03:30:22+00:00")) - .build() - ); - } - - protected Injector injector() { - return Guice.createInjector(new GsonModule() { - - @Override - protected void configure() { - bind(DateAdapter.class).to(Iso8601DateAdapter.class); - super.configure(); - } - - }); - } -} diff --git a/labs/joyent-cloudapi/src/test/java/org/jclouds/joyent/cloudapi/v6_5/parse/ParseDatasetTest.java b/labs/joyent-cloudapi/src/test/java/org/jclouds/joyent/cloudapi/v6_5/parse/ParseDatasetTest.java deleted file mode 100644 index 907dc1e4da..0000000000 --- a/labs/joyent-cloudapi/src/test/java/org/jclouds/joyent/cloudapi/v6_5/parse/ParseDatasetTest.java +++ /dev/null @@ -1,71 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.joyent.cloudapi.v6_5.parse; - -import javax.ws.rs.Consumes; -import javax.ws.rs.core.MediaType; - -import org.jclouds.date.internal.SimpleDateFormatDateService; -import org.jclouds.joyent.cloudapi.v6_5.domain.Dataset; -import org.jclouds.joyent.cloudapi.v6_5.domain.Machine.Type; -import org.jclouds.json.BaseItemParserTest; -import org.jclouds.json.config.GsonModule; -import org.testng.annotations.Test; - -import com.google.inject.Guice; -import com.google.inject.Injector; - -/** - * @author Gerald Pereira - */ -@Test(groups = "unit", testName = "ParseDatasetTest") -public class ParseDatasetTest extends BaseItemParserTest { - - @Override - public String resource() { - return "/dataset.json"; - } - - @Override - @Consumes(MediaType.APPLICATION_JSON) - public Dataset expected() { - return Dataset.builder() - .id("e4cd7b9e-4330-11e1-81cf-3bb50a972bda") - .urn("sdc:sdc:centos-6:1.0.1") - .name("centos-6") - .os("linux") - .type(Type.VIRTUALMACHINE) - .description("Centos 6 VM 1.0.1") - .isDefault(false) - .version("1.0.1") - .created(new SimpleDateFormatDateService().iso8601SecondsDateParse("2012-02-13T06:30:33+00:00")).build(); - } - - protected Injector injector() { - return Guice.createInjector(new GsonModule() { - - @Override - protected void configure() { - bind(DateAdapter.class).to(Iso8601DateAdapter.class); - super.configure(); - } - - }); - } -} diff --git a/labs/joyent-cloudapi/src/test/java/org/jclouds/joyent/cloudapi/v6_5/parse/ParseKeyListTest.java b/labs/joyent-cloudapi/src/test/java/org/jclouds/joyent/cloudapi/v6_5/parse/ParseKeyListTest.java deleted file mode 100644 index 3cb6c8f844..0000000000 --- a/labs/joyent-cloudapi/src/test/java/org/jclouds/joyent/cloudapi/v6_5/parse/ParseKeyListTest.java +++ /dev/null @@ -1,70 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.joyent.cloudapi.v6_5.parse; - -import java.util.Set; - -import javax.ws.rs.Consumes; -import javax.ws.rs.core.MediaType; - -import org.jclouds.date.internal.SimpleDateFormatDateService; -import org.jclouds.joyent.cloudapi.v6_5.domain.Key; -import org.jclouds.json.BaseSetParserTest; -import org.jclouds.json.config.GsonModule; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableSet; -import com.google.inject.Guice; -import com.google.inject.Injector; - -/** - * @author Adrian Cole - */ -@Test(groups = "unit", testName = "ParseKeyListTest") -public class ParseKeyListTest extends BaseSetParserTest { - - @Override - public String resource() { - return "/key_list.json"; - } - - @Override - @Consumes(MediaType.APPLICATION_JSON) - public Set expected() { - return ImmutableSet.of( - Key.builder() - .name("rsa") - .key("ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA0A5Pf5Cq...") - .created(new SimpleDateFormatDateService().iso8601SecondsDateParse("2011-04-13T22:14:46+00:00")) - .build() - ); - } - - protected Injector injector() { - return Guice.createInjector(new GsonModule() { - - @Override - protected void configure() { - bind(DateAdapter.class).to(Iso8601DateAdapter.class); - super.configure(); - } - - }); - } -} diff --git a/labs/joyent-cloudapi/src/test/java/org/jclouds/joyent/cloudapi/v6_5/parse/ParseKeyTest.java b/labs/joyent-cloudapi/src/test/java/org/jclouds/joyent/cloudapi/v6_5/parse/ParseKeyTest.java deleted file mode 100644 index c464de6066..0000000000 --- a/labs/joyent-cloudapi/src/test/java/org/jclouds/joyent/cloudapi/v6_5/parse/ParseKeyTest.java +++ /dev/null @@ -1,65 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.joyent.cloudapi.v6_5.parse; - -import javax.ws.rs.Consumes; -import javax.ws.rs.core.MediaType; - -import org.jclouds.date.internal.SimpleDateFormatDateService; -import org.jclouds.joyent.cloudapi.v6_5.domain.Key; -import org.jclouds.json.BaseItemParserTest; -import org.jclouds.json.config.GsonModule; -import org.testng.annotations.Test; - -import com.google.inject.Guice; -import com.google.inject.Injector; - -/** - * @author Adrian Cole - */ -@Test(groups = "unit", testName = "ParseKeyTest") -public class ParseKeyTest extends BaseItemParserTest { - - @Override - public String resource() { - return "/key.json"; - } - - @Override - @Consumes(MediaType.APPLICATION_JSON) - public Key expected() { - return Key.builder() - .name("rsa") - .key("ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA0A5Pf5Cq...") - .created(new SimpleDateFormatDateService().iso8601SecondsDateParse("2011-04-13T22:14:46+00:00")) - .build(); - } - - protected Injector injector() { - return Guice.createInjector(new GsonModule() { - - @Override - protected void configure() { - bind(DateAdapter.class).to(Iso8601DateAdapter.class); - super.configure(); - } - - }); - } -} diff --git a/labs/joyent-cloudapi/src/test/java/org/jclouds/joyent/cloudapi/v6_5/parse/ParseMachineListTest.java b/labs/joyent-cloudapi/src/test/java/org/jclouds/joyent/cloudapi/v6_5/parse/ParseMachineListTest.java deleted file mode 100644 index df92bc0d8f..0000000000 --- a/labs/joyent-cloudapi/src/test/java/org/jclouds/joyent/cloudapi/v6_5/parse/ParseMachineListTest.java +++ /dev/null @@ -1,92 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.joyent.cloudapi.v6_5.parse; - -import java.util.Set; - -import javax.ws.rs.Consumes; -import javax.ws.rs.core.MediaType; - -import org.jclouds.date.internal.SimpleDateFormatDateService; -import org.jclouds.domain.JsonBall; -import org.jclouds.joyent.cloudapi.v6_5.domain.Machine; -import org.jclouds.joyent.cloudapi.v6_5.domain.Machine.Type; -import org.jclouds.json.BaseSetParserTest; -import org.jclouds.json.config.GsonModule; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; -import com.google.inject.Guice; -import com.google.inject.Injector; - -/** - * @author Gerald Pereira - */ -@Test(groups = "unit", testName = "ParseMachineListTest") -public class ParseMachineListTest extends BaseSetParserTest { - - @Override - public String resource() { - return "/machine_list.json"; - } - - @Override - @Consumes(MediaType.APPLICATION_JSON) - public Set expected() { - return ImmutableSet.of( - - Machine.builder().id("d73cb0b0-7d1f-44ef-8c40-e040eef0f726").name("sample-e922").type(Type.SMARTMACHINE) - .state(Machine.State.RUNNING).dataset("sdc:sdc:smartosplus:3.1.0") - .ips(ImmutableSet. builder().add("37.153.96.56").add("10.224.0.57").build()) - .memorySizeMb(1024).diskSizeGb(61440).metadata(ImmutableMap. of()) - .created(new SimpleDateFormatDateService().iso8601SecondsDateParse("2012-05-09T13:39:43+00:00")) - .updated(new SimpleDateFormatDateService().iso8601SecondsDateParse("2012-05-09T13:43:45+00:00")) - .build(), - - Machine.builder() - .id("94eba336-ecb7-49f5-8a27-52f5e4dd57a1") - .name("sample-e92") - .type(Type.VIRTUALMACHINE) - .state(Machine.State.RUNNING) - .dataset("sdc:sdc:centos-5.7:1.2.1") - .ips(ImmutableSet. builder().add("37.153.96.62").add("10.224.0.63").build()) - .memorySizeMb(1024) - .diskSizeGb(61440) - .metadata( - ImmutableMap. builder() - .put("root_authorized_keys", new JsonBall("ssh-rsa XXXXXX== test@xxxx.ovh.net\n")).build()) - .created(new SimpleDateFormatDateService().iso8601SecondsDateParse("2012-05-09T13:32:46+00:00")) - .updated(new SimpleDateFormatDateService().iso8601SecondsDateParse("2012-05-11T09:00:33+00:00")) - .build() - ); - } - - protected Injector injector() { - return Guice.createInjector(new GsonModule() { - - @Override - protected void configure() { - bind(DateAdapter.class).to(Iso8601DateAdapter.class); - super.configure(); - } - - }); - } -} diff --git a/labs/joyent-cloudapi/src/test/java/org/jclouds/joyent/cloudapi/v6_5/parse/ParseMachineTest.java b/labs/joyent-cloudapi/src/test/java/org/jclouds/joyent/cloudapi/v6_5/parse/ParseMachineTest.java deleted file mode 100644 index 38fa37f141..0000000000 --- a/labs/joyent-cloudapi/src/test/java/org/jclouds/joyent/cloudapi/v6_5/parse/ParseMachineTest.java +++ /dev/null @@ -1,79 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.joyent.cloudapi.v6_5.parse; - -import javax.ws.rs.Consumes; -import javax.ws.rs.core.MediaType; - -import org.jclouds.date.internal.SimpleDateFormatDateService; -import org.jclouds.domain.JsonBall; -import org.jclouds.joyent.cloudapi.v6_5.domain.Machine; -import org.jclouds.joyent.cloudapi.v6_5.domain.Machine.Type; -import org.jclouds.json.BaseItemParserTest; -import org.jclouds.json.config.GsonModule; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; -import com.google.inject.Guice; -import com.google.inject.Injector; - -/** - * @author Gerald Pereira - */ -@Test(groups = "unit", testName = "ParseMachineTest") -public class ParseMachineTest extends BaseItemParserTest { - - @Override - public String resource() { - return "/machine.json"; - } - - @Override - @Consumes(MediaType.APPLICATION_JSON) - public Machine expected() { - return Machine - .builder() - .id("94eba336-ecb7-49f5-8a27-52f5e4dd57a1") - .name("sample-e92") - .type(Type.VIRTUALMACHINE) - .state(Machine.State.STOPPED) - .dataset("sdc:sdc:centos-5.7:1.2.1") - .ips(ImmutableSet. builder().add("37.153.96.62").add("10.224.0.63").build()) - .memorySizeMb(1024) - .diskSizeGb(61440) - .metadata( - ImmutableMap. builder() - .put("root_authorized_keys", new JsonBall("ssh-rsa XXXXXX== test@xxxx.ovh.net\n")).build()) - .created(new SimpleDateFormatDateService().iso8601SecondsDateParse("2012-05-09T13:32:46+00:00")) - .updated(new SimpleDateFormatDateService().iso8601SecondsDateParse("2012-05-11T08:44:53+00:00")).build(); - } - - protected Injector injector() { - return Guice.createInjector(new GsonModule() { - - @Override - protected void configure() { - bind(DateAdapter.class).to(Iso8601DateAdapter.class); - super.configure(); - } - - }); - } -} diff --git a/labs/joyent-cloudapi/src/test/java/org/jclouds/joyent/cloudapi/v6_5/parse/ParsePackageListTest.java b/labs/joyent-cloudapi/src/test/java/org/jclouds/joyent/cloudapi/v6_5/parse/ParsePackageListTest.java deleted file mode 100644 index 3ac142cbb1..0000000000 --- a/labs/joyent-cloudapi/src/test/java/org/jclouds/joyent/cloudapi/v6_5/parse/ParsePackageListTest.java +++ /dev/null @@ -1,69 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.joyent.cloudapi.v6_5.parse; - -import java.util.Set; - -import javax.ws.rs.Consumes; -import javax.ws.rs.core.MediaType; - -import org.jclouds.joyent.cloudapi.v6_5.domain.Package; -import org.jclouds.json.BaseSetParserTest; -import org.jclouds.json.config.GsonModule; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableSet; -import com.google.inject.Guice; -import com.google.inject.Injector; - -/** - * @author Gerald Pereira - */ -@Test(groups = "unit", testName = "ParsePackageListTest") -public class ParsePackageListTest extends BaseSetParserTest { - - @Override - public String resource() { - return "/package_list.json"; - } - - @Override - @Consumes(MediaType.APPLICATION_JSON) - public Set expected() { - return ImmutableSet.of(org.jclouds.joyent.cloudapi.v6_5.domain.Package.builder().name("Small 1GB").memorySizeMb(1024) - .diskSizeGb(30720).swapSizeMb(2048).isDefault(true).build(), - - org.jclouds.joyent.cloudapi.v6_5.domain.Package.builder().name("Medium 2GB").memorySizeMb(2048).diskSizeGb(61440) - .swapSizeMb(4096).isDefault(false).build() - - ); - } - - protected Injector injector() { - return Guice.createInjector(new GsonModule() { - - @Override - protected void configure() { - bind(DateAdapter.class).to(Iso8601DateAdapter.class); - super.configure(); - } - - }); - } -} diff --git a/labs/joyent-cloudapi/src/test/java/org/jclouds/joyent/cloudapi/v6_5/parse/ParsePackageTest.java b/labs/joyent-cloudapi/src/test/java/org/jclouds/joyent/cloudapi/v6_5/parse/ParsePackageTest.java deleted file mode 100644 index 8b9da901b0..0000000000 --- a/labs/joyent-cloudapi/src/test/java/org/jclouds/joyent/cloudapi/v6_5/parse/ParsePackageTest.java +++ /dev/null @@ -1,64 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.joyent.cloudapi.v6_5.parse; - -import javax.ws.rs.Consumes; -import javax.ws.rs.core.MediaType; - -import org.jclouds.json.BaseItemParserTest; -import org.jclouds.json.config.GsonModule; -import org.testng.annotations.Test; - -import com.google.inject.Guice; -import com.google.inject.Injector; - -/** - * @author Gerald Pereira - */ -@Test(groups = "unit", testName = "ParsePackageTest") -public class ParsePackageTest extends BaseItemParserTest { - - @Override - public String resource() { - return "/package.json"; - } - - @Override - @Consumes(MediaType.APPLICATION_JSON) - public org.jclouds.joyent.cloudapi.v6_5.domain.Package expected() { - return org.jclouds.joyent.cloudapi.v6_5.domain.Package.builder() - .name("Small 1GB") - .memorySizeMb(1024) - .diskSizeGb(30720) - .swapSizeMb(2048) - .isDefault(true).build(); - } - - protected Injector injector() { - return Guice.createInjector(new GsonModule() { - - @Override - protected void configure() { - bind(DateAdapter.class).to(Iso8601DateAdapter.class); - super.configure(); - } - - }); - } -} diff --git a/labs/joyent-cloudapi/src/test/resources/datacenters.json b/labs/joyent-cloudapi/src/test/resources/datacenters.json deleted file mode 100644 index 7f4cdc3783..0000000000 --- a/labs/joyent-cloudapi/src/test/resources/datacenters.json +++ /dev/null @@ -1 +0,0 @@ -{"us-east-1":"https://us-east-1.api.joyentcloud.com","us-west-1":"https://us-west-1.api.joyentcloud.com","us-sw-1":"https://us-sw-1.api.joyentcloud.com","eu-ams-1":"https://eu-ams-1.api.joyentcloud.com"} \ No newline at end of file diff --git a/labs/joyent-cloudapi/src/test/resources/dataset.json b/labs/joyent-cloudapi/src/test/resources/dataset.json deleted file mode 100644 index e363f8f44d..0000000000 --- a/labs/joyent-cloudapi/src/test/resources/dataset.json +++ /dev/null @@ -1 +0,0 @@ -{"id":"e4cd7b9e-4330-11e1-81cf-3bb50a972bda","urn":"sdc:sdc:centos-6:1.0.1","name":"centos-6","os":"linux","type":"virtualmachine","description":"Centos 6 VM 1.0.1","default":false,"requirements":{},"version":"1.0.1","created":"2012-02-13T06:30:33+00:00"} \ No newline at end of file diff --git a/labs/joyent-cloudapi/src/test/resources/dataset_list.json b/labs/joyent-cloudapi/src/test/resources/dataset_list.json deleted file mode 100644 index dab5df96c7..0000000000 --- a/labs/joyent-cloudapi/src/test/resources/dataset_list.json +++ /dev/null @@ -1,34 +0,0 @@ -[{ - "id": "71101322-43a5-11e1-8f01-cf2a3031a7f4", - "urn": "sdc:sdc:ubuntu-10.04:1.0.1", - "name": "ubuntu-10.04", - "os": "linux", - "type": "virtualmachine", - "description": "Ubuntu 10.04 VM 1.0.1", - "default": false, - "requirements": {}, - "version": "1.0.1", - "created": "2012-02-22T18:27:32+00:00" -}, { - "id": "e4cd7b9e-4330-11e1-81cf-3bb50a972bda", - "urn": "sdc:sdc:centos-6:1.0.1", - "name": "centos-6", - "os": "linux", - "type": "virtualmachine", - "description": "Centos 6 VM 1.0.1", - "default": false, - "requirements": {}, - "version": "1.0.1", - "created": "2012-02-15T20:04:18+00:00" -}, { - "id": "9551fdbc-cc9a-11e1-a9e7-eb1e788a8690", - "urn": "sdc:sdc:standard64:1.0.1", - "name": "standard64", - "os": "smartos", - "type": "smartmachine", - "description": "64-bit machine image optimized for web development", - "default": false, - "requirements": {}, - "version": "1.0.1", - "created": "2012-07-13T03:30:22+00:00" -}] \ No newline at end of file diff --git a/labs/joyent-cloudapi/src/test/resources/key.json b/labs/joyent-cloudapi/src/test/resources/key.json deleted file mode 100644 index 5957f79416..0000000000 --- a/labs/joyent-cloudapi/src/test/resources/key.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "name": "rsa", - "key": "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA0A5Pf5Cq...", - "created": "2011-04-13T22:14:46+00:00" -} \ No newline at end of file diff --git a/labs/joyent-cloudapi/src/test/resources/key_list.json b/labs/joyent-cloudapi/src/test/resources/key_list.json deleted file mode 100644 index 503dd9cbfa..0000000000 --- a/labs/joyent-cloudapi/src/test/resources/key_list.json +++ /dev/null @@ -1,7 +0,0 @@ -[ - { - "name": "rsa", - "key": "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA0A5Pf5Cq...", - "created": "2011-04-13T22:14:46+00:00" - } -] \ No newline at end of file diff --git a/labs/joyent-cloudapi/src/test/resources/machine.json b/labs/joyent-cloudapi/src/test/resources/machine.json deleted file mode 100644 index 48151249bb..0000000000 --- a/labs/joyent-cloudapi/src/test/resources/machine.json +++ /dev/null @@ -1 +0,0 @@ -{"id":"94eba336-ecb7-49f5-8a27-52f5e4dd57a1","name":"sample-e92","type":"virtualmachine","state":"stopped","dataset":"sdc:sdc:centos-5.7:1.2.1","ips":["37.153.96.62","10.224.0.63"],"memory":1024,"disk":61440,"metadata":{"root_authorized_keys":"ssh-rsa XXXXXX== test@xxxx.ovh.net"},"created":"2012-05-09T13:32:46+00:00","updated":"2012-05-11T08:44:53+00:00"} diff --git a/labs/joyent-cloudapi/src/test/resources/machine_list.json b/labs/joyent-cloudapi/src/test/resources/machine_list.json deleted file mode 100644 index 51b82b7923..0000000000 --- a/labs/joyent-cloudapi/src/test/resources/machine_list.json +++ /dev/null @@ -1 +0,0 @@ -[{"id":"d73cb0b0-7d1f-44ef-8c40-e040eef0f726","name":"sample-e922","type":"smartmachine","state":"running","dataset":"sdc:sdc:smartosplus:3.1.0","ips":["37.153.96.56","10.224.0.57"],"memory":1024,"disk":61440,"metadata":{},"created":"2012-05-09T13:39:43+00:00","updated":"2012-05-09T13:43:45+00:00"},{"id":"94eba336-ecb7-49f5-8a27-52f5e4dd57a1","name":"sample-e92","type":"virtualmachine","state":"running","dataset":"sdc:sdc:centos-5.7:1.2.1","ips":["37.153.96.62","10.224.0.63"],"memory":1024,"disk":61440,"metadata":{"root_authorized_keys":"ssh-rsa XXXXXX== test@xxxx.ovh.net\n"},"created":"2012-05-09T13:32:46+00:00","updated":"2012-05-11T09:00:33+00:00"}] \ No newline at end of file diff --git a/labs/joyent-cloudapi/src/test/resources/new_machine.json b/labs/joyent-cloudapi/src/test/resources/new_machine.json deleted file mode 100644 index 48151249bb..0000000000 --- a/labs/joyent-cloudapi/src/test/resources/new_machine.json +++ /dev/null @@ -1 +0,0 @@ -{"id":"94eba336-ecb7-49f5-8a27-52f5e4dd57a1","name":"sample-e92","type":"virtualmachine","state":"stopped","dataset":"sdc:sdc:centos-5.7:1.2.1","ips":["37.153.96.62","10.224.0.63"],"memory":1024,"disk":61440,"metadata":{"root_authorized_keys":"ssh-rsa XXXXXX== test@xxxx.ovh.net"},"created":"2012-05-09T13:32:46+00:00","updated":"2012-05-11T08:44:53+00:00"} diff --git a/labs/joyent-cloudapi/src/test/resources/package.json b/labs/joyent-cloudapi/src/test/resources/package.json deleted file mode 100644 index 757a6a663d..0000000000 --- a/labs/joyent-cloudapi/src/test/resources/package.json +++ /dev/null @@ -1 +0,0 @@ -{"name":"Small 1GB","memory":1024,"disk":30720,"vcpus":1,"swap":2048,"default":true} \ No newline at end of file diff --git a/labs/joyent-cloudapi/src/test/resources/package_list.json b/labs/joyent-cloudapi/src/test/resources/package_list.json deleted file mode 100644 index d83ebc9022..0000000000 --- a/labs/joyent-cloudapi/src/test/resources/package_list.json +++ /dev/null @@ -1 +0,0 @@ -[{"name":"Small 1GB","memory":1024,"disk":30720,"vcpus":1,"swap":2048,"default":true},{"name":"Medium 2GB","memory":2048,"disk":61440,"vcpus":1,"swap":4096,"default":false}] \ No newline at end of file diff --git a/labs/joyentcloud/pom.xml b/labs/joyentcloud/pom.xml deleted file mode 100644 index 1d00bcbe77..0000000000 --- a/labs/joyentcloud/pom.xml +++ /dev/null @@ -1,128 +0,0 @@ - - - - 4.0.0 - - org.jclouds.labs - jclouds-labs-project - 1.7.0-SNAPSHOT - ../project/pom.xml - - joyentcloud - jcloud joyentcloud api - jclouds components to access the Joyent Cloud - bundle - - - https://api.joyentcloud.com - ~6.5 - - FIXME_IDENTITY - FIXME_CREDENTIALS - org.jclouds.joyent.joyentcloud*;version="${project.version}" - - org.jclouds.rest.internal;version="${jclouds.version}", - org.jclouds.labs*;version="${project.version}", - org.jclouds*;version="${jclouds.version}", - * - - - - - - org.jclouds.labs - joyent-cloudapi - ${project.version} - - - org.jclouds.labs - joyent-cloudapi - ${project.version} - test-jar - test - - - org.jclouds - jclouds-compute - ${jclouds.version} - test-jar - test - - - org.jclouds - jclouds-core - ${jclouds.version} - test-jar - test - - - org.jclouds.driver - jclouds-slf4j - ${jclouds.version} - test - - - org.jclouds.driver - jclouds-sshj - ${jclouds.version} - test - - - ch.qos.logback - logback-classic - test - - - - - - live - - - - org.apache.maven.plugins - maven-surefire-plugin - - - integration - integration-test - - test - - - - ${test.joyentcloud.endpoint} - ${test.joyentcloud.api-version} - ${test.joyentcloud.build-version} - ${test.joyentcloud.identity} - ${test.joyentcloud.credential} - - - - - - - - - - - diff --git a/labs/joyentcloud/src/main/java/org/jclouds/joyent/joyentcloud/JoyentCloudProviderMetadata.java b/labs/joyentcloud/src/main/java/org/jclouds/joyent/joyentcloud/JoyentCloudProviderMetadata.java deleted file mode 100644 index 4be1332e0d..0000000000 --- a/labs/joyentcloud/src/main/java/org/jclouds/joyent/joyentcloud/JoyentCloudProviderMetadata.java +++ /dev/null @@ -1,90 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.joyent.joyentcloud; - -import static org.jclouds.location.reference.LocationConstants.ISO3166_CODES; -import static org.jclouds.location.reference.LocationConstants.PROPERTY_ZONE; -import static org.jclouds.location.reference.LocationConstants.PROPERTY_ZONES; - -import java.net.URI; -import java.util.Properties; - -import org.jclouds.joyent.cloudapi.v6_5.JoyentCloudApiMetadata; -import org.jclouds.providers.ProviderMetadata; -import org.jclouds.providers.internal.BaseProviderMetadata; - -/** - * Implementation of {@link org.jclouds.types.ProviderMetadata} for SDC. - * @author Adrian Cole - */ -public class JoyentCloudProviderMetadata extends BaseProviderMetadata { - - public static Builder builder() { - return new Builder(); - } - - @Override - public Builder toBuilder() { - return builder().fromProviderMetadata(this); - } - - public JoyentCloudProviderMetadata() { - super(builder()); - } - - public JoyentCloudProviderMetadata(Builder builder) { - super(builder); - } - - public static Properties defaultProperties() { - Properties properties = new Properties(); - properties.setProperty(PROPERTY_ZONES, "us-east-1,us-west-1,us-sw-1,eu-ams-1"); - properties.setProperty(PROPERTY_ZONE + ".us-east-1." + ISO3166_CODES, "US-VA"); - properties.setProperty(PROPERTY_ZONE + ".us-west-1." + ISO3166_CODES, "US-CA"); - properties.setProperty(PROPERTY_ZONE + ".us-sw-1." + ISO3166_CODES, "US-NV"); - properties.setProperty(PROPERTY_ZONE + ".eu-ams-1." + ISO3166_CODES, "NL-NH"); - return properties; - } - - public static class Builder extends BaseProviderMetadata.Builder { - - protected Builder() { - id("joyentcloud") - .name("JoyentCloud") - .apiMetadata(new JoyentCloudApiMetadata()) - .homepage(URI.create("http://www.joyent.com/products/smartdatacenter/")) - .console(URI.create("https://my.joyentcloud.com/login")) - .iso3166Codes("US-VA", "US-CA", "US-NV", "NL-NH") - .endpoint("https://api.joyentcloud.com") - .defaultProperties(JoyentCloudProviderMetadata.defaultProperties()); - } - - @Override - public JoyentCloudProviderMetadata build() { - return new JoyentCloudProviderMetadata(this); - } - - @Override - public Builder fromProviderMetadata(ProviderMetadata in) { - super.fromProviderMetadata(in); - return this; - } - - } -} diff --git a/labs/joyentcloud/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata b/labs/joyentcloud/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata deleted file mode 100644 index 73d417c6f8..0000000000 --- a/labs/joyentcloud/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata +++ /dev/null @@ -1 +0,0 @@ -org.jclouds.joyent.joyentcloud.JoyentCloudProviderMetadata diff --git a/labs/joyentcloud/src/test/java/org/jclouds/joyent/joyentcloud/JoyentCloudComputeServiceLiveTest.java b/labs/joyentcloud/src/test/java/org/jclouds/joyent/joyentcloud/JoyentCloudComputeServiceLiveTest.java deleted file mode 100644 index 12175c078a..0000000000 --- a/labs/joyentcloud/src/test/java/org/jclouds/joyent/joyentcloud/JoyentCloudComputeServiceLiveTest.java +++ /dev/null @@ -1,33 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.joyent.joyentcloud; - -import org.testng.annotations.Test; - -/** - * - * @author Adrian Cole - */ -@Test(groups = "live", singleThreaded = true, testName = "JoyentCloudComputeServiceLiveTest") -public class JoyentCloudComputeServiceLiveTest extends org.jclouds.joyent.cloudapi.v6_5.compute.JoyentCloudComputeServiceLiveTest { - - public JoyentCloudComputeServiceLiveTest() { - provider = "joyentcloud"; - } -} diff --git a/labs/joyentcloud/src/test/java/org/jclouds/joyent/joyentcloud/JoyentCloudLiveTest.java b/labs/joyentcloud/src/test/java/org/jclouds/joyent/joyentcloud/JoyentCloudLiveTest.java deleted file mode 100644 index cc31a09716..0000000000 --- a/labs/joyentcloud/src/test/java/org/jclouds/joyent/joyentcloud/JoyentCloudLiveTest.java +++ /dev/null @@ -1,32 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.joyent.joyentcloud; - -import org.jclouds.joyent.cloudapi.v6_5.JoyentCloudApiLiveTest; -import org.testng.annotations.Test; - -/** - * @author Adrian Cole - */ -@Test(groups = "live", testName = "JoyentCloudLiveTest") -public class JoyentCloudLiveTest extends JoyentCloudApiLiveTest { - public JoyentCloudLiveTest() { - provider = "joyentcloud"; - } -} diff --git a/labs/joyentcloud/src/test/java/org/jclouds/joyent/joyentcloud/JoyentCloudProviderMetadataTest.java b/labs/joyentcloud/src/test/java/org/jclouds/joyent/joyentcloud/JoyentCloudProviderMetadataTest.java deleted file mode 100644 index 40c6f0d28d..0000000000 --- a/labs/joyentcloud/src/test/java/org/jclouds/joyent/joyentcloud/JoyentCloudProviderMetadataTest.java +++ /dev/null @@ -1,35 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not computee this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.joyent.joyentcloud; - -import org.jclouds.joyent.cloudapi.v6_5.JoyentCloudApiMetadata; -import org.jclouds.providers.internal.BaseProviderMetadataTest; -import org.testng.annotations.Test; - -/** - * - * @author Adrian Cole - */ -@Test(groups = "unit", testName = "JoyentCloudProviderMetadataTest") -public class JoyentCloudProviderMetadataTest extends BaseProviderMetadataTest { - - public JoyentCloudProviderMetadataTest() { - super(new JoyentCloudProviderMetadata(), new JoyentCloudApiMetadata()); - } -} diff --git a/labs/joyentcloud/src/test/java/org/jclouds/joyent/joyentcloud/JoyentCloudTemplateBuilderLiveTest.java b/labs/joyentcloud/src/test/java/org/jclouds/joyent/joyentcloud/JoyentCloudTemplateBuilderLiveTest.java deleted file mode 100644 index 53694d74fc..0000000000 --- a/labs/joyentcloud/src/test/java/org/jclouds/joyent/joyentcloud/JoyentCloudTemplateBuilderLiveTest.java +++ /dev/null @@ -1,102 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.joyent.joyentcloud; - -import static com.google.common.base.Predicates.not; -import static org.jclouds.compute.domain.OsFamily.SMARTOS; -import static org.jclouds.compute.domain.OsFamily.UBUNTU; -import static org.testng.Assert.assertEquals; - -import java.io.IOException; -import java.util.Set; - -import org.jclouds.compute.domain.OsFamilyVersion64Bit; -import org.jclouds.compute.domain.Template; -import org.jclouds.compute.internal.BaseTemplateBuilderLiveTest; -import org.testng.annotations.Test; - -import com.google.common.base.Predicate; -import com.google.common.collect.ImmutableSet; - -/** - * - * @author Adrian Cole - */ -@Test(groups = "live", singleThreaded = true, testName = "JoyentCloudTemplateBuilderLiveTest") -public class JoyentCloudTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest { - - public JoyentCloudTemplateBuilderLiveTest() { - provider = "joyentcloud"; - } - - @Override - protected Predicate defineUnsupportedOperatingSystems() { - return not(new Predicate() { - - @Override - public boolean apply(OsFamilyVersion64Bit input) { - switch (input.family) { - case UBUNTU: - return (input.version.equals("") || input.version.equals("10.04") || input.version.equals("12.04")) - && input.is64Bit; - case DEBIAN: - return input.is64Bit && !input.version.equals("5.0"); - case CENTOS: - return (input.version.equals("") || input.version.equals("5.7") || input.version.equals("6.0")) - && input.is64Bit; - default: - return false; - } - } - - }); - } - - @Test - public void testTemplateBuilderSmartOS() throws IOException { - Template smartTemplate = view.getComputeService().templateBuilder().osFamily(SMARTOS).build(); - assertEquals(smartTemplate.getImage().getOperatingSystem().is64Bit(), true); - assertEquals(smartTemplate.getImage().getOperatingSystem().getVersion(), "1.6.3"); - assertEquals(smartTemplate.getImage().getOperatingSystem().getFamily(), SMARTOS); - assertEquals(smartTemplate.getImage().getName(), "smartos"); - assertEquals(smartTemplate.getImage().getDefaultCredentials().getUser(), "root"); - assertEquals(smartTemplate.getLocation().getId(), "us-east-1"); - assertEquals(smartTemplate.getImage().getLocation().getId(), "us-east-1"); - assertEquals(smartTemplate.getHardware().getLocation().getId(), "us-east-1"); - } - - @Test - @Override - public void testDefaultTemplateBuilder() { - Template defaultTemplate = this.view.getComputeService().templateBuilder().build(); - assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true); - assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), "12.04"); - assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), UBUNTU); - assertEquals(defaultTemplate.getImage().getName(), "ubuntu-12.04"); - assertEquals(defaultTemplate.getImage().getDefaultCredentials().getUser(), "root"); - assertEquals(defaultTemplate.getLocation().getId(), "us-east-1"); - assertEquals(defaultTemplate.getImage().getLocation().getId(), "us-east-1"); - assertEquals(defaultTemplate.getHardware().getLocation().getId(), "us-east-1"); - } - - @Override - protected Set getIso3166Codes() { - return ImmutableSet. of("US-VA", "US-CA", "US-NV", "NL-NH"); - } -} diff --git a/labs/joyentcloud/src/test/java/org/jclouds/joyent/joyentcloud/features/JoyentCloudDatacenterApiLiveTest.java b/labs/joyentcloud/src/test/java/org/jclouds/joyent/joyentcloud/features/JoyentCloudDatacenterApiLiveTest.java deleted file mode 100644 index 1a808a5284..0000000000 --- a/labs/joyentcloud/src/test/java/org/jclouds/joyent/joyentcloud/features/JoyentCloudDatacenterApiLiveTest.java +++ /dev/null @@ -1,32 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.joyent.joyentcloud.features; - -import org.jclouds.joyent.cloudapi.v6_5.features.DatacenterApiLiveTest; -import org.testng.annotations.Test; - -/** - * @author Adrian Cole - */ -@Test(groups = "live", testName = "JoyentCloudDatacenterApiLiveTest") -public class JoyentCloudDatacenterApiLiveTest extends DatacenterApiLiveTest { - public JoyentCloudDatacenterApiLiveTest() { - provider = "joyentcloud"; - } -} diff --git a/labs/joyentcloud/src/test/java/org/jclouds/joyent/joyentcloud/features/JoyentCloudDatasetApiLiveTest.java b/labs/joyentcloud/src/test/java/org/jclouds/joyent/joyentcloud/features/JoyentCloudDatasetApiLiveTest.java deleted file mode 100644 index 326afc7239..0000000000 --- a/labs/joyentcloud/src/test/java/org/jclouds/joyent/joyentcloud/features/JoyentCloudDatasetApiLiveTest.java +++ /dev/null @@ -1,32 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.joyent.joyentcloud.features; - -import org.jclouds.joyent.cloudapi.v6_5.features.DatasetApiLiveTest; -import org.testng.annotations.Test; - -/** - * @author Adrian Cole - */ -@Test(groups = "live", testName = "JoyentCloudDatasetApiLiveTest") -public class JoyentCloudDatasetApiLiveTest extends DatasetApiLiveTest { - public JoyentCloudDatasetApiLiveTest() { - provider = "joyentcloud"; - } -} diff --git a/labs/joyentcloud/src/test/java/org/jclouds/joyent/joyentcloud/features/JoyentCloudKeyApiLiveTest.java b/labs/joyentcloud/src/test/java/org/jclouds/joyent/joyentcloud/features/JoyentCloudKeyApiLiveTest.java deleted file mode 100644 index 135a58848d..0000000000 --- a/labs/joyentcloud/src/test/java/org/jclouds/joyent/joyentcloud/features/JoyentCloudKeyApiLiveTest.java +++ /dev/null @@ -1,32 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.joyent.joyentcloud.features; - -import org.jclouds.joyent.cloudapi.v6_5.features.KeyApiLiveTest; -import org.testng.annotations.Test; - -/** - * @author Adrian Cole - */ -@Test(groups = "live", testName = "JoyentCloudKeyApiLiveTest") -public class JoyentCloudKeyApiLiveTest extends KeyApiLiveTest { - public JoyentCloudKeyApiLiveTest() { - provider = "joyentcloud"; - } -} diff --git a/labs/joyentcloud/src/test/java/org/jclouds/joyent/joyentcloud/features/JoyentCloudMachineApiLiveTest.java b/labs/joyentcloud/src/test/java/org/jclouds/joyent/joyentcloud/features/JoyentCloudMachineApiLiveTest.java deleted file mode 100644 index 636565ff4e..0000000000 --- a/labs/joyentcloud/src/test/java/org/jclouds/joyent/joyentcloud/features/JoyentCloudMachineApiLiveTest.java +++ /dev/null @@ -1,32 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.joyent.joyentcloud.features; - -import org.jclouds.joyent.cloudapi.v6_5.features.MachineApiLiveTest; -import org.testng.annotations.Test; - -/** - * @author Adrian Cole - */ -@Test(groups = "live", testName = "JoyentCloudMachineApiLiveTest") -public class JoyentCloudMachineApiLiveTest extends MachineApiLiveTest { - public JoyentCloudMachineApiLiveTest() { - provider = "joyentcloud"; - } -} diff --git a/labs/joyentcloud/src/test/java/org/jclouds/joyent/joyentcloud/features/JoyentCloudPackageApiLiveTest.java b/labs/joyentcloud/src/test/java/org/jclouds/joyent/joyentcloud/features/JoyentCloudPackageApiLiveTest.java deleted file mode 100644 index 7092b460a5..0000000000 --- a/labs/joyentcloud/src/test/java/org/jclouds/joyent/joyentcloud/features/JoyentCloudPackageApiLiveTest.java +++ /dev/null @@ -1,33 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.joyent.joyentcloud.features; - -import org.jclouds.joyent.cloudapi.v6_5.features.PackageApiLiveTest; -import org.testng.annotations.Test; - -/** - * @author Adrian Cole - */ -@Test(groups = "live", testName = "JoyentCloudPackageApiLiveTest") -public class JoyentCloudPackageApiLiveTest extends PackageApiLiveTest { - - public JoyentCloudPackageApiLiveTest(){ - provider = "joyentcloud"; - } -} diff --git a/labs/nodepool/pom.xml b/labs/nodepool/pom.xml deleted file mode 100644 index c552ebcaad..0000000000 --- a/labs/nodepool/pom.xml +++ /dev/null @@ -1,147 +0,0 @@ - - - - 4.0.0 - - org.jclouds - jclouds-project - 1.7.0-SNAPSHOT - ../../project/pom.xml - - org.jclouds.labs - nodepool - jcloud nodepool api - bundle - - - byon - org.jclouds.logging.slf4j.config.SLF4JLoggingModule,org.jclouds.sshj.config.SshjSshClientModule - FIXME_ENDPOINT - - - FIXME_IDENTITY - FIXME_CREDENTIALS - org.jclouds.nodepool*;version="${project.version}" - - org.jclouds.rest.internal;version="${project.version}", - org.jclouds*;version="${project.version}", - * - - - - - - org.jclouds - jclouds-compute - ${project.version} - - - org.jclouds - jclouds-blobstore - ${project.version} - - - - org.jclouds - jclouds-allcompute - ${project.version} - test - - - org.jclouds.api - filesystem - ${project.version} - - - org.jclouds - jclouds-compute - ${project.version} - test-jar - test - - - org.jclouds.api - byon - ${project.version} - test - - - org.jclouds - jclouds-core - ${project.version} - test-jar - test - - - org.jclouds.driver - jclouds-slf4j - ${project.version} - test - - - org.jclouds.driver - jclouds-sshj - ${project.version} - test - - - ch.qos.logback - logback-classic - test - - - - - - live - - - - org.apache.maven.plugins - maven-surefire-plugin - - - integration - integration-test - - test - - - - ${test.nodepool.endpoint} - ${test.nodepool.api-version} - ${test.nodepool.build-version} - ${test.nodepool.identity} - ${test.nodepool.credential} - ${jclouds.nodepool.backend-provider} - ${jclouds.nodepool.backend-modules} - - - - - - - - - - - diff --git a/labs/nodepool/src/main/java/org/jclouds/nodepool/Backend.java b/labs/nodepool/src/main/java/org/jclouds/nodepool/Backend.java deleted file mode 100644 index 0347b3c27a..0000000000 --- a/labs/nodepool/src/main/java/org/jclouds/nodepool/Backend.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.nodepool; - -import static java.lang.annotation.ElementType.ANNOTATION_TYPE; -import static java.lang.annotation.ElementType.FIELD; -import static java.lang.annotation.ElementType.METHOD; -import static java.lang.annotation.ElementType.PARAMETER; -import static java.lang.annotation.RetentionPolicy.RUNTIME; - -import java.lang.annotation.Retention; -import java.lang.annotation.Target; - -import javax.inject.Qualifier; - -/** - * Designates that this Resource qualifies an object to the back-end of the pool - * - * @author Adrian Cole - */ -@Target( { ANNOTATION_TYPE, FIELD, METHOD, PARAMETER }) -@Retention(RUNTIME) -@Qualifier -public @interface Backend { - -} diff --git a/labs/nodepool/src/main/java/org/jclouds/nodepool/NodePoolApiMetadata.java b/labs/nodepool/src/main/java/org/jclouds/nodepool/NodePoolApiMetadata.java deleted file mode 100644 index d22c8d2c9d..0000000000 --- a/labs/nodepool/src/main/java/org/jclouds/nodepool/NodePoolApiMetadata.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.nodepool; - -import static org.jclouds.nodepool.config.NodePoolProperties.BACKEND_GROUP; -import static org.jclouds.nodepool.config.NodePoolProperties.BACKEND_MODULES; -import static org.jclouds.nodepool.config.NodePoolProperties.MAX_SIZE; -import static org.jclouds.nodepool.config.NodePoolProperties.METADATA_CONTAINER; -import static org.jclouds.nodepool.config.NodePoolProperties.MIN_SIZE; -import static org.jclouds.nodepool.config.NodePoolProperties.POOL_ADMIN_ACCESS; -import static org.jclouds.nodepool.config.NodePoolProperties.REMOVE_DESTROYED; - -import java.io.File; -import java.net.URI; -import java.util.Properties; - -import org.jclouds.apis.internal.BaseApiMetadata; -import org.jclouds.nodepool.config.BindBackendComputeService; -import org.jclouds.nodepool.config.BindInputStreamToFilesystemBlobStore; -import org.jclouds.nodepool.config.NodePoolComputeServiceContextModule; -import org.jclouds.rest.internal.BaseRestApiMetadata; - -import com.google.common.collect.ImmutableSet; -import com.google.inject.Module; - -public class NodePoolApiMetadata extends BaseApiMetadata { - - @Override - public Builder toBuilder() { - return new Builder().fromApiMetadata(this); - } - - public NodePoolApiMetadata() { - super(new Builder()); - } - - protected NodePoolApiMetadata(Builder builder) { - super(builder); - } - - public static Properties defaultProperties() { - Properties properties = BaseRestApiMetadata.defaultProperties(); - properties.setProperty(BACKEND_GROUP, "nodepool"); - properties.setProperty(METADATA_CONTAINER, "nodes"); - properties.setProperty(BACKEND_MODULES, - "org.jclouds.logging.slf4j.config.SLF4JLoggingModule,org.jclouds.sshj.config.SshjSshClientModule"); - properties.setProperty(MAX_SIZE, 10 + ""); - properties.setProperty(MIN_SIZE, 5 + ""); - properties.setProperty(REMOVE_DESTROYED, "true"); - // by default use the current user's user and private key if one exists, if not the properties - // will need to be set (no default passwords) - if (new File(System.getProperty("user.home") + "/.ssh/id_rsa").exists()) { - properties.setProperty(POOL_ADMIN_ACCESS, "adminUsername=" + System.getProperty("user.name") - + ",adminPrivateKeyFile=" + System.getProperty("user.home") + "/.ssh/id_rsa"); - } - return properties; - } - - public static class Builder extends BaseApiMetadata.Builder { - protected Builder() { - id("nodepool") - .name("node pool provider wrapper") - .identityName("backend identity") - .endpointName("backend endpoint") - .defaultEndpoint("fixme") - .documentation(URI.create("http://www.jclouds.org/documentation/userguide/compute")) - .view(NodePoolComputeServiceContext.class) - .defaultModules( - ImmutableSet.> builder() - .add(NodePoolComputeServiceContextModule.class) - .add(BindInputStreamToFilesystemBlobStore.class) - .add(BindBackendComputeService.class).build()) - .defaultProperties(NodePoolApiMetadata.defaultProperties()); - } - - @Override - public NodePoolApiMetadata build() { - return new NodePoolApiMetadata(this); - } - - @Override - protected Builder self() { - return this; - } - } -} diff --git a/labs/nodepool/src/main/java/org/jclouds/nodepool/NodePoolComputeServiceAdapter.java b/labs/nodepool/src/main/java/org/jclouds/nodepool/NodePoolComputeServiceAdapter.java deleted file mode 100644 index 8d0134cbb1..0000000000 --- a/labs/nodepool/src/main/java/org/jclouds/nodepool/NodePoolComputeServiceAdapter.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.nodepool; - -import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.compute.JCloudsNativeComputeServiceAdapter; -import org.jclouds.nodepool.internal.EagerNodePoolComputeServiceAdapter; - -import com.google.inject.ImplementedBy; - -@ImplementedBy(EagerNodePoolComputeServiceAdapter.class) -public interface NodePoolComputeServiceAdapter extends JCloudsNativeComputeServiceAdapter { - - int idleNodes(); - - int maxNodes(); - - int minNodes(); - - int usedNodes(); - - int currentSize(); - - void destroyPool(); - - ComputeServiceContext getBackendComputeServiceContext(); - - String getPoolGroupName(); - -} diff --git a/labs/nodepool/src/main/java/org/jclouds/nodepool/NodePoolComputeServiceContext.java b/labs/nodepool/src/main/java/org/jclouds/nodepool/NodePoolComputeServiceContext.java deleted file mode 100644 index 10bfb8a308..0000000000 --- a/labs/nodepool/src/main/java/org/jclouds/nodepool/NodePoolComputeServiceContext.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.nodepool; - -import javax.inject.Singleton; - -import org.jclouds.Context; -import org.jclouds.compute.ComputeService; -import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.compute.Utils; -import org.jclouds.compute.internal.ComputeServiceContextImpl; -import org.jclouds.location.Provider; - -import com.google.common.reflect.TypeToken; -import com.google.inject.Inject; - -@Singleton -public class NodePoolComputeServiceContext extends ComputeServiceContextImpl { - - private final NodePoolComputeServiceAdapter adapter; - - @Inject - public NodePoolComputeServiceContext(@Provider Context backend, @Provider TypeToken backendType, - ComputeService computeService, Utils utils, NodePoolComputeServiceAdapter adapter) { - super(backend, backendType, computeService, utils); - this.adapter = adapter; - } - - /** - * Returns the statistics on the pool. - * - * @return - */ - public NodePoolStats getPoolStats() { - return new NodePoolStats(adapter.currentSize(), adapter.idleNodes(), adapter.usedNodes(), adapter.maxNodes(), - adapter.minNodes()); - } - - /** - * Destroys all (backing nodes) in the pool and deletes all state. - */ - public void destroyPool() { - this.adapter.destroyPool(); - } - - /** - * Returns the backend context. - * - * @return - */ - public ComputeServiceContext getBackendContext() { - return this.adapter.getBackendComputeServiceContext(); - } - - public String getPoolGroupName() { - return this.adapter.getPoolGroupName(); - } - -} diff --git a/labs/nodepool/src/main/java/org/jclouds/nodepool/NodePoolStats.java b/labs/nodepool/src/main/java/org/jclouds/nodepool/NodePoolStats.java deleted file mode 100644 index c06ebd2fb2..0000000000 --- a/labs/nodepool/src/main/java/org/jclouds/nodepool/NodePoolStats.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.jclouds.nodepool; - -/** - * NodePool statistics and status. - * - * @author David Alves - * - */ -public class NodePoolStats { - - private final int currentSize; - private final int idleNodes; - private final int usedNodes; - private final int maxNodes; - private final int minNodes; - - NodePoolStats(int currentSize, int idleNodes, int usedNodes, int maxNodes, int minNodes) { - this.currentSize = currentSize; - this.idleNodes = idleNodes; - this.usedNodes = usedNodes; - this.maxNodes = maxNodes; - this.minNodes = minNodes; - } - - /** - * The number of nodes currently allocated in the backend provider and in the pool. - */ - public int currentSize() { - return currentSize; - } - - /** - * The number of nodes in the pool not being used. - */ - public int idleNodes() { - return idleNodes; - } - - /** - * The number of nodes in the pool that are currently being used. - */ - public int usedNodes() { - return usedNodes; - } - - /** - * The maximum size the pool will reach. - */ - public int maxNodes() { - return maxNodes; - } - - /** - * The minimum size of the pool. - */ - public int minNodes() { - return minNodes; - } - -} diff --git a/labs/nodepool/src/main/java/org/jclouds/nodepool/config/BindBackendComputeService.java b/labs/nodepool/src/main/java/org/jclouds/nodepool/config/BindBackendComputeService.java deleted file mode 100644 index d6ae99fd5d..0000000000 --- a/labs/nodepool/src/main/java/org/jclouds/nodepool/config/BindBackendComputeService.java +++ /dev/null @@ -1,340 +0,0 @@ -/* - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.nodepool.config; - -import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.base.Preconditions.checkState; -import static org.jclouds.nodepool.config.NodePoolProperties.BACKEND_GROUP; - -import java.net.URI; -import java.util.Properties; -import java.util.Set; - -import javax.inject.Named; -import javax.inject.Singleton; - -import org.jclouds.ContextBuilder; -import org.jclouds.compute.ComputeService; -import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.compute.domain.Hardware; -import org.jclouds.compute.domain.HardwareBuilder; -import org.jclouds.compute.domain.Image; -import org.jclouds.compute.domain.Image.Status; -import org.jclouds.compute.domain.ImageBuilder; -import org.jclouds.compute.domain.NodeMetadata; -import org.jclouds.compute.domain.OsFamily; -import org.jclouds.compute.domain.Template; -import org.jclouds.compute.domain.TemplateBuilder; -import org.jclouds.compute.domain.TemplateBuilderSpec; -import org.jclouds.compute.options.TemplateOptions; -import org.jclouds.compute.predicates.NodePredicates; -import org.jclouds.domain.Credentials; -import org.jclouds.domain.Location; -import org.jclouds.internal.FilterStringsBoundToInjectorByName; -import org.jclouds.lifecycle.Closer; -import org.jclouds.location.Provider; -import org.jclouds.nodepool.Backend; -import org.jclouds.rest.annotations.ApiVersion; -import org.jclouds.rest.annotations.BuildVersion; -import org.jclouds.util.Predicates2; - -import com.google.common.annotations.Beta; -import com.google.common.base.Function; -import com.google.common.base.Predicate; -import com.google.common.base.Predicates; -import com.google.common.base.Supplier; -import com.google.common.base.Suppliers; -import com.google.common.collect.Iterables; -import com.google.common.collect.Sets; -import com.google.inject.Exposed; -import com.google.inject.Module; -import com.google.inject.Provides; - -public class BindBackendComputeService extends BindJcloudsModules { - - @Provides - @Singleton - @Backend - protected String provideBackendProvider(@Named(NodePoolProperties.BACKEND_PROVIDER) String provider) { - return provider; - } - - // things wrapped in suppliers are intentional. They can cause network i/o - // and shouldn't be invoked until after the injector is created. - - @Provides - @Singleton - @Backend - @Exposed - protected Supplier makeBackendComputeService(@Backend final String provider, - @Backend final Set modules, @Provider final Supplier creds, - @Backend final Supplier overrides, final Closer closer) { - return Suppliers.memoize(new Supplier() { - - @Override - public ComputeService get() { - Credentials currentCreds = checkNotNull(creds.get(), "credential supplier returned null"); - ComputeServiceContext ctx = ContextBuilder.newBuilder(provider) - .credentials(currentCreds.identity, currentCreds.credential).overrides(overrides.get()) - .modules(modules).buildView(ComputeServiceContext.class); - closer.addToClose(ctx); - return ctx.getComputeService(); - } - - }); - } - - private static final Predicate keys = Predicates.and( - Predicates.not(Predicates2.startsWith("jclouds.nodepool")), - Predicates.not(Predicates2.startsWith("nodepool"))); - - @Provides - @Singleton - @Backend - protected Supplier propertiesFor(final FilterStringsBoundToInjectorByName filterStringsBoundByName, - @Backend final String provider, @Provider final Supplier endpoint, - @ApiVersion final String apiVersion, @BuildVersion final String buildVersion) { - return Suppliers.memoize(new Supplier() { - - @Override - public Properties get() { - Properties props = new Properties(); - props.putAll(filterStringsBoundByName.apply(keys)); - props.put(provider + ".endpoint", endpoint.get().toASCIIString()); - props.put(provider + ".api-version", apiVersion); - props.put(provider + ".build-version", buildVersion); - return props; - } - - }); - } - - @Provides - @Exposed - @Singleton - protected TemplateBuilder templateBuilder(@Backend final Supplier compute, - @Backend final Supplier