diff --git a/allcompute/pom.xml b/allcompute/pom.xml index 095ac3af14..015cd60c82 100644 --- a/allcompute/pom.xml +++ b/allcompute/pom.xml @@ -68,11 +68,6 @@ cloudservers ${project.version} - - org.apache.jclouds.api - vcloud - ${project.version} - org.apache.jclouds.provider gogrid diff --git a/apis/byon/README.txt b/apis/byon/README.txt index 3b7a9c467e..0c53c7a549 100644 --- a/apis/byon/README.txt +++ b/apis/byon/README.txt @@ -57,7 +57,7 @@ Here are the properties: * group - primary group of the machine. ex. hadoop * tags - optional; list of arbitrary tags. * note this list is not yet in jclouds NodeMetadata - * username - primary login user. ex. ubuntu, vcloud, toor, root + * username - primary login user. ex. ubuntu, toor, root * sudo_password - optional; when a script is run with the "runAsRoot" option true, yet the username is not root, a sudo command is invoked. If sudo_password is set, the contents will be passed to sudo -S. diff --git a/apis/pom.xml b/apis/pom.xml index 81792936fd..ddd1764143 100644 --- a/apis/pom.xml +++ b/apis/pom.xml @@ -36,7 +36,6 @@ s3 ec2 sqs - vcloud elasticstack atmos swift diff --git a/apis/vcloud/README.txt b/apis/vcloud/README.txt deleted file mode 100644 index b00a7affa2..0000000000 --- a/apis/vcloud/README.txt +++ /dev/null @@ -1,6 +0,0 @@ -# -# The jclouds API for VMware vCloud (http://www.vmware.com/products/vcloud/). -# -# TODO: Implementation status. -# TODO: Supported features. -# TODO: Usage example. diff --git a/apis/vcloud/pom.xml b/apis/vcloud/pom.xml deleted file mode 100644 index 3c9a1f12f5..0000000000 --- a/apis/vcloud/pom.xml +++ /dev/null @@ -1,128 +0,0 @@ - - - - 4.0.0 - - org.apache.jclouds - jclouds-project - 2.0.0-SNAPSHOT - ../../project/pom.xml - - org.apache.jclouds.api - vcloud - jclouds vcloud api - jclouds components to access an implementation of VMWare vCloud - bundle - - - FIXME_ENDPOINT - 1.0 - - FIXME_IDENTITY - FIXME_CREDENTIAL - - org.jclouds.vcloud*;version="${project.version}" - - org.jclouds.compute.internal;version="${project.version}", - org.jclouds.rest.internal;version="${project.version}", - org.jclouds*;version="${project.version}", - * - - - - - - com.jamesmurty.utils - java-xmlbuilder - 0.4 - - - org.apache.jclouds - jclouds-core - ${project.version} - - - org.apache.jclouds - jclouds-core - ${project.version} - test-jar - test - - - org.apache.jclouds - jclouds-compute - ${project.version} - - - org.apache.jclouds - jclouds-compute - ${project.version} - test-jar - test - - - org.apache.jclouds.driver - jclouds-sshj - ${project.version} - test - - - org.apache.jclouds.driver - jclouds-log4j - ${project.version} - test - - - - - - live - - - - org.apache.maven.plugins - maven-surefire-plugin - - - integration - integration-test - - test - - - - ${test.vcloud.endpoint} - ${test.vcloud.api-version} - ${test.vcloud.build-version} - ${test.vcloud.identity} - ${test.vcloud.credential} - ${test.vcloud.template} - - - - - - - - - - - - diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/TaskInErrorStateException.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/TaskInErrorStateException.java deleted file mode 100644 index fb54599068..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/TaskInErrorStateException.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud; - -import org.jclouds.vcloud.domain.Task; - -public class TaskInErrorStateException extends RuntimeException { - - private final Task task; - - public TaskInErrorStateException(Task task) { - super("error on task: " + task + " error: " + task.getError()); - this.task = task; - } - - public Task getTask() { - return task; - } - -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/TaskStillRunningException.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/TaskStillRunningException.java deleted file mode 100644 index 64eafbed76..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/TaskStillRunningException.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud; - -import org.jclouds.vcloud.domain.Task; - -public class TaskStillRunningException extends RuntimeException { - - private final Task task; - - public TaskStillRunningException(Task task) { - super("task still running: " + task); - this.task = task; - } - - public Task getTask() { - return task; - } - -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/VCloudApi.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/VCloudApi.java deleted file mode 100644 index 1c3b46c92c..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/VCloudApi.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud; - -import java.io.Closeable; - -import org.jclouds.rest.annotations.Delegate; -import org.jclouds.rest.annotations.RequestFilters; -import org.jclouds.vcloud.features.CatalogApi; -import org.jclouds.vcloud.features.NetworkApi; -import org.jclouds.vcloud.features.OrgApi; -import org.jclouds.vcloud.features.TaskApi; -import org.jclouds.vcloud.features.VAppApi; -import org.jclouds.vcloud.features.VAppTemplateApi; -import org.jclouds.vcloud.features.VDCApi; -import org.jclouds.vcloud.features.VmApi; -import org.jclouds.vcloud.filters.AddVCloudAuthorizationAndCookieToRequest; - -/** - * Provides access to VCloud resources via their REST API. - *

- * - * @see - */ -@RequestFilters(AddVCloudAuthorizationAndCookieToRequest.class) -public interface VCloudApi extends Closeable { - /** - * Provides asynchronous access to VApp Template features. - * - */ - @Delegate - VAppTemplateApi getVAppTemplateApi(); - - /** - * Provides synchronous access to VApp features. - */ - @Delegate - VAppApi getVAppApi(); - - /** - * Provides synchronous access to Vm features. - */ - @Delegate - VmApi getVmApi(); - - /** - * Provides synchronous access to Catalog features. - */ - @Delegate - CatalogApi getCatalogApi(); - - /** - * Provides synchronous access to Task features. - */ - @Delegate - TaskApi getTaskApi(); - - /** - * Provides synchronous access to VDC features. - */ - @Delegate - VDCApi getVDCApi(); - - /** - * Provides synchronous access to Network features. - */ - @Delegate - NetworkApi getNetworkApi(); - - /** - * Provides synchronous access to Org features. - */ - @Delegate - OrgApi getOrgApi(); - -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/VCloudApiMetadata.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/VCloudApiMetadata.java deleted file mode 100644 index 4c88d8aa0b..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/VCloudApiMetadata.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud; -import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL; -import static org.jclouds.compute.config.ComputeServiceProperties.TEMPLATE; -import static org.jclouds.reflect.Reflection2.typeToken; -import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_DEFAULT_FENCEMODE; -import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_TIMEOUT_TASK_COMPLETED; -import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_VERSION_SCHEMA; -import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_XML_NAMESPACE; -import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_XML_SCHEMA; - -import java.net.URI; -import java.util.Properties; - -import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.rest.internal.BaseHttpApiMetadata; -import org.jclouds.vcloud.compute.config.VCloudComputeServiceContextModule; -import org.jclouds.vcloud.config.VCloudHttpApiModule; -import org.jclouds.vcloud.domain.network.FenceMode; - -import com.google.common.collect.ImmutableSet; -import com.google.inject.Module; - -/** - * Implementation of {@link ApiMetadata} for VCloud 1.0 API - */ -public class VCloudApiMetadata extends BaseHttpApiMetadata { - - - @Override - public Builder toBuilder() { - return new Builder().fromApiMetadata(this); - } - - public VCloudApiMetadata() { - this(new Builder()); - } - - protected VCloudApiMetadata(Builder builder) { - super(builder); - } - - public static Properties defaultProperties() { - Properties properties = BaseHttpApiMetadata.defaultProperties(); - properties.setProperty(PROPERTY_VCLOUD_VERSION_SCHEMA, "1"); - properties.setProperty(PROPERTY_VCLOUD_XML_NAMESPACE, - String.format("http://www.vmware.com/vcloud/v${%s}", PROPERTY_VCLOUD_VERSION_SCHEMA)); - properties.setProperty(PROPERTY_SESSION_INTERVAL, 8 * 60 + ""); - properties.setProperty(PROPERTY_VCLOUD_XML_SCHEMA, "http://vcloud.safesecureweb.com/ns/vcloud.xsd"); - properties.setProperty("jclouds.dns_name_length_min", "1"); - properties.setProperty("jclouds.dns_name_length_max", "80"); - properties.setProperty(PROPERTY_VCLOUD_DEFAULT_FENCEMODE, FenceMode.BRIDGED.toString()); - // TODO integrate this with the {@link ComputeTimeouts} instead of having - // a single timeout for - // everything. - properties.setProperty(PROPERTY_VCLOUD_TIMEOUT_TASK_COMPLETED, 1200l * 1000l + ""); - properties.setProperty(PROPERTY_SESSION_INTERVAL, 300 + ""); - // CIM ostype does not include version info - properties.setProperty(TEMPLATE, "osFamily=UBUNTU,os64Bit=true"); - return properties; - } - - public static class Builder extends BaseHttpApiMetadata.Builder { - protected Builder() { - id("vcloud") - .name("VCloud 1.0 API") - .identityName("User at Organization (user@org)") - .credentialName("Password") - .documentation(URI.create("http://www.vmware.com/support/pubs/vcd_pubs.html")) - .version("1.0") - .defaultProperties(VCloudApiMetadata.defaultProperties()) - .view(typeToken(ComputeServiceContext.class)) - .defaultModules(ImmutableSet.>of(VCloudHttpApiModule.class, VCloudComputeServiceContextModule.class)); - } - - @Override - public VCloudApiMetadata build() { - return new VCloudApiMetadata(this); - } - - @Override - protected Builder self() { - return this; - } - } -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/VCloudMediaType.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/VCloudMediaType.java deleted file mode 100644 index f8f5ed4f42..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/VCloudMediaType.java +++ /dev/null @@ -1,215 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud; - -import javax.ws.rs.core.MediaType; - -/** - * Resource Types used in VCloud - * - * @see MediaType - */ -public final class VCloudMediaType { - /** - * "application/vnd.vmware.vcloud.error+xml" - */ - public static final String ERROR_XML = "application/vnd.vmware.vcloud.error+xml"; - - /** - * "application/vnd.vmware.vcloud.error+xml" - */ - public static final MediaType ERROR_XML_TYPE = new MediaType("application", "vnd.vmware.vcloud.error+xml"); - - /** - * "application/vnd.vmware.vcloud.vcloud+xml" - */ - public static final String VCLOUD_XML = "application/vnd.vmware.vcloud.vcloud+xml"; - - /** - * "application/vnd.vmware.vcloud.vcloud+xml" - */ - public static final MediaType VCLOUD_XML_TYPE = new MediaType("application", "vnd.vmware.vcloud.vcloud+xml"); - /** - * "application/vnd.vmware.vcloud.orgList+xml" - */ - public static final String ORGLIST_XML = "application/vnd.vmware.vcloud.orgList+xml"; - - /** - * "application/vnd.vmware.vcloud.orgList+xml" - */ - public static final MediaType ORGLIST_XML_TYPE = new MediaType("application", "vnd.vmware.vcloud.orgList+xml"); - /** - * "application/vnd.vmware.vcloud.org+xml" - */ - public static final String ORG_XML = "application/vnd.vmware.vcloud.org+xml"; - /** - * "application/vnd.vmware.vcloud.org+xml" - */ - public static final MediaType ORG_XML_TYPE = new MediaType("application", "vnd.vmware.vcloud.org+xml"); - - /** - * "application/vnd.vmware.vcloud.vdc+xml" - */ - public static final String VDC_XML = "application/vnd.vmware.vcloud.vdc+xml"; - /** - * "application/vnd.vmware.vcloud.vdc+xml" - */ - public static final MediaType VDC_XML_TYPE = new MediaType("application", "vnd.vmware.vcloud.vdc+xml"); - - /** - * "application/vnd.vmware.vcloud.catalog+xml" - */ - public static final String CATALOG_XML = "application/vnd.vmware.vcloud.catalog+xml"; - /** - * "application/vnd.vmware.vcloud.catalog+xml" - */ - public static final MediaType CATALOG_XML_TYPE = new MediaType("application", "vnd.vmware.vcloud.catalog+xml"); - - /** - * "application/vnd.vmware.vcloud.tasksList+xml" - */ - public static final String TASKSLIST_XML = "application/vnd.vmware.vcloud.tasksList+xml"; - /** - * "application/vnd.vmware.vcloud.tasksList+xml" - */ - public static final MediaType TASKSLIST_XML_TYPE = new MediaType("application", "vnd.vmware.vcloud.tasksList+xml"); - - /** - * "application/vnd.vmware.vcloud.catalogItem+xml" - */ - public static final String CATALOGITEM_XML = "application/vnd.vmware.vcloud.catalogItem+xml"; - /** - * "application/vnd.vmware.vcloud.catalogItem+xml" - */ - public static final MediaType CATALOGITEM_XML_TYPE = new MediaType("application", - "vnd.vmware.vcloud.catalogItem+xml"); - /** - * "application/vnd.vmware.vcloud.networkConnectionSection+xml" - */ - public static final String NETWORKCONNECTIONSECTION_XML = "application/vnd.vmware.vcloud.networkConnectionSection+xml"; - /** - * "application/vnd.vmware.vcloud.networkConnectionSection+xml" - */ - public static final MediaType NETWORKCONNECTIONSECTION_XML_TYPE = new MediaType("application", - "vnd.vmware.vcloud.networkConnectionSection+xml"); - /** - * "application/vnd.vmware.vcloud.virtualHardwareSection+xml" - */ - public static final String VIRTUALHARDWARESECTION_XML = "application/vnd.vmware.vcloud.virtualHardwareSection+xml"; - /** - * "application/vnd.vmware.vcloud.virtualHardwareSection+xml" - */ - public static final MediaType VIRTUALHARDWARESECTION_XML_TYPE = new MediaType("application", - "vnd.vmware.vcloud.virtualHardwareSection+xml"); - /** - * "application/vnd.vmware.vcloud.guestCustomizationSection+xml" - */ - public static final String GUESTCUSTOMIZATIONSECTION_XML = "application/vnd.vmware.vcloud.guestCustomizationSection+xml"; - /** - * "application/vnd.vmware.vcloud.guestCustomizationSection+xml" - */ - public static final MediaType GUESTCUSTOMIZATIONSECTION_XML_TYPE = new MediaType("application", - "vnd.vmware.vcloud.guestCustomizationSection+xml"); - - /** - * "application/vnd.vmware.vcloud.networkSection+xml" - */ - public static final String NETWORKSECTION_XML = "application/vnd.vmware.vcloud.networkSection+xml"; - /** - * "application/vnd.vmware.vcloud.networkSection+xml" - */ - public static final MediaType NETWORKSECTION_XML_TYPE = new MediaType("application", - "vnd.vmware.vcloud.networkSection+xml"); - - /** - * "application/vnd.vmware.vcloud.task+xml" - */ - public static final String TASK_XML = "application/vnd.vmware.vcloud.task+xml"; - /** - * "application/vnd.vmware.vcloud.task+xml" - */ - public static final MediaType TASK_XML_TYPE = new MediaType("application", "vnd.vmware.vcloud.task+xml"); - - /** - * "application/vnd.vmware.vcloud.undeployVAppParams+xml" - */ - public static final String UNDEPLOYVAPPPARAMS_XML = "application/vnd.vmware.vcloud.undeployVAppParams+xml"; - /** - * "application/vnd.vmware.vcloud.undeployVAppParams+xml" - */ - public static final MediaType UNDEPLOYVAPPPARAMS_XML_TYPE = new MediaType("application", - "vnd.vmware.vcloud.undeployVAppParams+xml"); - - /** - * "application/vnd.vmware.vcloud.deployVAppParams+xml" - */ - public static final String DEPLOYVAPPPARAMS_XML = "application/vnd.vmware.vcloud.deployVAppParams+xml"; - /** - * "application/vnd.vmware.vcloud.deployVAppParams+xml" - */ - public static final MediaType DEPLOYVAPPPARAMS_XML_TYPE = new MediaType("application", - "vnd.vmware.vcloud.deployVAppParams+xml"); - - /** - * "application/vnd.vmware.vcloud.vApp+xml" - */ - public static final String VAPP_XML = "application/vnd.vmware.vcloud.vApp+xml"; - /** - * "application/vnd.vmware.vcloud.vApp+xml" - */ - public static final MediaType VAPP_XML_TYPE = new MediaType("application", "vnd.vmware.vcloud.vApp+xml"); - - /** - * "application/vnd.vmware.vcloud.vm+xml" - */ - public static final String VM_XML = "application/vnd.vmware.vcloud.vm+xml"; - /** - * "application/vnd.vmware.vcloud.vm+xml" - */ - public static final MediaType VM_XML_TYPE = new MediaType("application", "vnd.vmware.vcloud.vm+xml"); - - /** - * "application/vnd.vmware.vcloud.vAppTemplate+xml" - */ - public static final String VAPPTEMPLATE_XML = "application/vnd.vmware.vcloud.vAppTemplate+xml"; - /** - * "application/vnd.vmware.vcloud.vAppTemplate+xml" - */ - public static final MediaType VAPPTEMPLATE_XML_TYPE = new MediaType("application", - "vnd.vmware.vcloud.vAppTemplate+xml"); - /** - * "application/vnd.vmware.vcloud.network+xml" - */ - public static final String NETWORK_XML = "application/vnd.vmware.vcloud.network+xml"; - /** - * "application/vnd.vmware.vcloud.network+xml" - */ - public static final MediaType NETWORK_XML_TYPE = new MediaType("application", "vnd.vmware.vcloud.network+xml"); - - /** - * "application/vnd.vmware.vcloud.rasdItem+xml" - */ - public static final String RASDITEM_XML = "application/vnd.vmware.vcloud.rasdItem+xml"; - /** - * "application/vnd.vmware.vcloud.rasdItem+xml" - */ - public static final MediaType RASDITEM_XML_TYPE = new MediaType("application", "vnd.vmware.vcloud.rasdItem+xml"); - - private VCloudMediaType() { - throw new AssertionError("intentionally unimplemented"); - } -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/VCloudResponseException.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/VCloudResponseException.java deleted file mode 100644 index ea8d7f83d9..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/VCloudResponseException.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud; - -import org.jclouds.http.HttpCommand; -import org.jclouds.http.HttpResponse; -import org.jclouds.http.HttpResponseException; -import org.jclouds.vcloud.domain.VCloudError; - -/** - * Encapsulates an VCloud Error. - */ -public class VCloudResponseException extends HttpResponseException { - - private org.jclouds.vcloud.domain.VCloudError error; - - public VCloudResponseException(HttpCommand command, HttpResponse response, VCloudError error) { - super(String.format("request %s failed with code %s, error: %s", command.getCurrentRequest().getRequestLine(), response - .getStatusCode(), error.toString()), command, response); - this.setError(error); - - } - - public VCloudResponseException(HttpCommand command, HttpResponse response, VCloudError error, Throwable cause) { - super(String.format("request %1$s failed with error: %2$s", command.getCurrentRequest().getRequestLine(), error - .toString()), command, response, cause); - this.setError(error); - - } - - public VCloudResponseException(String message, HttpCommand command, HttpResponse response, VCloudError error) { - super(message, command, response); - this.setError(error); - - } - - public VCloudResponseException(String message, HttpCommand command, HttpResponse response, VCloudError error, - Throwable cause) { - super(message, command, response, cause); - this.setError(error); - - } - - public void setError(VCloudError error) { - this.error = error; - } - - public VCloudError getError() { - return error; - } - -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/VCloudToken.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/VCloudToken.java deleted file mode 100644 index 2aca7bd8c2..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/VCloudToken.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -import javax.inject.Qualifier; - -/** - * A VCloud Session Token - */ -@Retention(value = RetentionPolicy.RUNTIME) -@Target(value = { ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD }) -@Qualifier -public @interface VCloudToken { - -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/VCloudVersionsApi.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/VCloudVersionsApi.java deleted file mode 100644 index 01ec0459cf..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/VCloudVersionsApi.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud; - -import java.io.Closeable; -import java.net.URI; -import java.util.SortedMap; - -import javax.ws.rs.GET; -import javax.ws.rs.Path; - -import org.jclouds.rest.annotations.XMLResponseParser; -import org.jclouds.vcloud.xml.SupportedVersionsHandler; - -public interface VCloudVersionsApi extends Closeable { - - @GET - @XMLResponseParser(SupportedVersionsHandler.class) - @Path("/versions") - SortedMap getSupportedVersions(); -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/binders/BindCPUCountToXmlPayload.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/binders/BindCPUCountToXmlPayload.java deleted file mode 100644 index fc757a1b84..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/binders/BindCPUCountToXmlPayload.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.binders; - -import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.base.Preconditions.checkNotNull; -import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_XML_NAMESPACE; -import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_XML_SCHEMA; - -import java.util.Properties; - -import javax.inject.Named; -import javax.inject.Singleton; - -import org.jclouds.cim.ResourceAllocationSettingData.ResourceType; -import org.jclouds.http.HttpRequest; -import org.jclouds.rest.binders.BindToStringPayload; - -import com.google.common.base.Throwables; -import com.google.inject.Inject; -import com.jamesmurty.utils.XMLBuilder; - -@Singleton -public class BindCPUCountToXmlPayload extends BindToStringPayload { - protected final String ns; - protected final String schema; - - @Inject - public BindCPUCountToXmlPayload(BindToStringPayload stringBinder, @Named(PROPERTY_VCLOUD_XML_NAMESPACE) String ns, - @Named(PROPERTY_VCLOUD_XML_SCHEMA) String schema) { - this.ns = ns; - this.schema = schema; - } - - private static final String RESOURCE_ALLOCATION_NS = "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData"; - - @Override - public R bindToRequest(R request, Object payload) { - checkArgument(checkNotNull(payload, "cpuCount") instanceof Integer, "this binder is only valid for Integers!"); - Integer cpuCount = Integer.class.cast(payload); - XMLBuilder cpuItem; - try { - cpuItem = XMLBuilder.create("Item").a("xmlns", ns).a("xmlns:rasd", RESOURCE_ALLOCATION_NS); - cpuItem.e("rasd:AllocationUnits").t("hertz * 10^6"); - cpuItem.e("rasd:Description").t("Number of Virtual CPUs"); - cpuItem.e("rasd:ElementName").t(cpuCount.toString() + " virtual CPU(s)"); - cpuItem.e("rasd:InstanceID").t("4"); - cpuItem.e("rasd:ResourceType").t(ResourceType.PROCESSOR.value()); - cpuItem.e("rasd:VirtualQuantity").t(cpuCount.toString()); - cpuItem.e("rasd:Weight").t("0"); - Properties outputProperties = new Properties(); - outputProperties.put(javax.xml.transform.OutputKeys.OMIT_XML_DECLARATION, "yes"); - request = super.bindToRequest(request, cpuItem.asString(outputProperties)); - } catch (Exception e) { - Throwables.propagate(e); - } - return request; - } - -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/binders/BindCaptureVAppParamsToXmlPayload.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/binders/BindCaptureVAppParamsToXmlPayload.java deleted file mode 100644 index 8a556be3fd..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/binders/BindCaptureVAppParamsToXmlPayload.java +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.binders; - -import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.base.Preconditions.checkNotNull; -import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_XML_NAMESPACE; -import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_XML_SCHEMA; - -import java.util.Map; -import java.util.Properties; - -import javax.inject.Named; -import javax.inject.Singleton; -import javax.xml.parsers.FactoryConfigurationError; -import javax.xml.parsers.ParserConfigurationException; -import javax.xml.transform.TransformerException; - -import org.jclouds.http.HttpRequest; -import org.jclouds.rest.MapBinder; -import org.jclouds.rest.binders.BindToStringPayload; -import org.jclouds.rest.internal.GeneratedHttpRequest; -import org.jclouds.vcloud.VCloudMediaType; -import org.jclouds.vcloud.options.CaptureVAppOptions; - -import com.google.inject.Inject; -import com.jamesmurty.utils.XMLBuilder; - -@Singleton -public class BindCaptureVAppParamsToXmlPayload implements MapBinder { - - protected final String ns; - protected final String schema; - private final BindToStringPayload stringBinder; - - @Inject - public BindCaptureVAppParamsToXmlPayload(BindToStringPayload stringBinder, - @Named(PROPERTY_VCLOUD_XML_NAMESPACE) String ns, @Named(PROPERTY_VCLOUD_XML_SCHEMA) String schema) { - this.ns = ns; - this.schema = schema; - this.stringBinder = stringBinder; - } - - @Override - public R bindToRequest(R request, Map postParams) { - checkArgument(checkNotNull(request, "request") instanceof GeneratedHttpRequest, - "this binder is only valid for GeneratedHttpRequests!"); - GeneratedHttpRequest gRequest = (GeneratedHttpRequest) request; - String templateName = checkNotNull(postParams.remove("templateName"), "templateName").toString(); - String vApp = checkNotNull(postParams.remove("vApp"), "vApp").toString(); - - CaptureVAppOptions options = findOptionsInArgsOrNull(gRequest); - if (options == null) { - options = new CaptureVAppOptions(); - } - try { - return stringBinder.bindToRequest(request, generateXml(templateName, vApp, options)); - } catch (ParserConfigurationException e) { - throw new RuntimeException(e); - } catch (FactoryConfigurationError e) { - throw new RuntimeException(e); - } catch (TransformerException e) { - throw new RuntimeException(e); - } - - } - - protected String generateXml(String templateName, String vApp, CaptureVAppOptions options) - throws ParserConfigurationException, FactoryConfigurationError, TransformerException { - XMLBuilder rootBuilder = buildRoot(templateName); - if (options.getDescription() != null) - rootBuilder.e("Description").text(options.getDescription()); - rootBuilder.e("Source").a("href", vApp).a("type", VCloudMediaType.VAPP_XML); - Properties outputProperties = new Properties(); - outputProperties.put(javax.xml.transform.OutputKeys.OMIT_XML_DECLARATION, "yes"); - return rootBuilder.asString(outputProperties); - } - - protected XMLBuilder buildRoot(String name) throws ParserConfigurationException, FactoryConfigurationError { - XMLBuilder rootBuilder = XMLBuilder.create("CaptureVAppParams").a("name", name).a("xmlns", ns) - .a("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance").a("xsi:schemaLocation", ns + " " + schema); - return rootBuilder; - } - - protected CaptureVAppOptions findOptionsInArgsOrNull(GeneratedHttpRequest gRequest) { - for (Object arg : gRequest.getInvocation().getArgs()) { - if (arg instanceof CaptureVAppOptions) { - return (CaptureVAppOptions) arg; - } else if (arg instanceof CaptureVAppOptions[]) { - CaptureVAppOptions[] options = (CaptureVAppOptions[]) arg; - return (options.length > 0) ? options[0] : null; - } - } - return null; - } - - @Override - public R bindToRequest(R request, Object input) { - throw new IllegalStateException("CaptureVAppParams is needs parameters"); - } - - protected String ifNullDefaultTo(String value, String defaultValue) { - return value != null ? value : checkNotNull(defaultValue, "defaultValue"); - } -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/binders/BindCatalogItemToXmlPayload.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/binders/BindCatalogItemToXmlPayload.java deleted file mode 100644 index 98c4e3a187..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/binders/BindCatalogItemToXmlPayload.java +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.binders; - -import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.base.Preconditions.checkNotNull; -import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_XML_NAMESPACE; -import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_XML_SCHEMA; - -import java.net.URI; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Properties; - -import javax.inject.Named; -import javax.inject.Singleton; -import javax.xml.parsers.FactoryConfigurationError; -import javax.xml.parsers.ParserConfigurationException; -import javax.xml.transform.TransformerException; - -import org.jclouds.http.HttpRequest; -import org.jclouds.rest.MapBinder; -import org.jclouds.rest.binders.BindToStringPayload; -import org.jclouds.rest.internal.GeneratedHttpRequest; -import org.jclouds.vcloud.options.CatalogItemOptions; - -import com.google.inject.Inject; -import com.jamesmurty.utils.XMLBuilder; - -@Singleton -public class BindCatalogItemToXmlPayload implements MapBinder { - - protected final String ns; - protected final String schema; - private final BindToStringPayload stringBinder; - - @Inject - public BindCatalogItemToXmlPayload(BindToStringPayload stringBinder, - @Named(PROPERTY_VCLOUD_XML_NAMESPACE) String ns, @Named(PROPERTY_VCLOUD_XML_SCHEMA) String schema) { - this.ns = ns; - this.schema = schema; - this.stringBinder = stringBinder; - } - - @Override - public R bindToRequest(R request, Map postParams) { - checkArgument(checkNotNull(request, "request") instanceof GeneratedHttpRequest, - "this binder is only valid for GeneratedHttpRequests!"); - GeneratedHttpRequest gRequest = (GeneratedHttpRequest) request; - String name = checkNotNull(postParams.get("name"), "name").toString(); - URI entity = URI.create(checkNotNull(postParams.get("Entity"), "Entity").toString()); - - CatalogItemOptions options = findOptionsInArgsOrNew(gRequest); - try { - return stringBinder.bindToRequest(request, generateXml(name, entity, options)); - } catch (ParserConfigurationException e) { - throw new RuntimeException(e); - } catch (FactoryConfigurationError e) { - throw new RuntimeException(e); - } catch (TransformerException e) { - throw new RuntimeException(e); - } - - } - - protected String generateXml(String templateName, URI entity, CatalogItemOptions options) - throws ParserConfigurationException, FactoryConfigurationError, TransformerException { - XMLBuilder rootBuilder = buildRoot(templateName); - if (options.getDescription() != null) - rootBuilder.e("Description").t(options.getDescription()); - rootBuilder.e("Entity").a("href", entity.toASCIIString()); - for (Entry entry : options.getProperties().entrySet()) { - rootBuilder.e("Property").a("key", entry.getKey()).t(entry.getValue()); - } - Properties outputProperties = new Properties(); - outputProperties.put(javax.xml.transform.OutputKeys.OMIT_XML_DECLARATION, "yes"); - return rootBuilder.asString(outputProperties); - } - - protected XMLBuilder buildRoot(String name) throws ParserConfigurationException, FactoryConfigurationError { - XMLBuilder rootBuilder = XMLBuilder.create("CatalogItem").a("name", name).a("xmlns", ns).a("xmlns:xsi", - "http://www.w3.org/2001/XMLSchema-instance").a("xsi:schemaLocation", ns + " " + schema); - return rootBuilder; - } - - protected CatalogItemOptions findOptionsInArgsOrNew(GeneratedHttpRequest gRequest) { - for (Object arg : gRequest.getInvocation().getArgs()) { - if (arg instanceof CatalogItemOptions) { - return CatalogItemOptions.class.cast(arg); - } else if (arg.getClass().isArray()) { - Object[] array = (Object[]) arg; - if (array.length > 0 && array[0] instanceof CatalogItemOptions) - return CatalogItemOptions.class.cast(array[0]); - } - } - return new CatalogItemOptions(); - } - - @Override - public R bindToRequest(R request, Object input) { - throw new IllegalStateException("CatalogItem is needs parameters"); - } - - protected String ifNullDefaultTo(String value, String defaultValue) { - return value != null ? value : checkNotNull(defaultValue, "defaultValue"); - } -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/binders/BindCloneParamsToXmlPayload.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/binders/BindCloneParamsToXmlPayload.java deleted file mode 100644 index 71617bc268..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/binders/BindCloneParamsToXmlPayload.java +++ /dev/null @@ -1,128 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.binders; - -import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.base.Preconditions.checkNotNull; -import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_XML_NAMESPACE; -import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_XML_SCHEMA; - -import java.util.Map; -import java.util.Properties; - -import javax.inject.Named; -import javax.inject.Singleton; - -import org.jclouds.http.HttpRequest; -import org.jclouds.rest.MapBinder; -import org.jclouds.rest.binders.BindToStringPayload; -import org.jclouds.rest.internal.GeneratedHttpRequest; -import org.jclouds.vcloud.options.CloneOptions; - -import com.google.common.base.Throwables; -import com.google.inject.Inject; -import com.jamesmurty.utils.XMLBuilder; - -@Singleton -public abstract class BindCloneParamsToXmlPayload implements MapBinder { - - protected final String ns; - protected final String schema; - private final BindToStringPayload stringBinder; - - protected abstract String getRootElement(); - protected abstract String getSourceMediaType(); - protected abstract Class getOptionClass(); - - @Inject - public BindCloneParamsToXmlPayload(BindToStringPayload stringBinder, - @Named(PROPERTY_VCLOUD_XML_NAMESPACE) String ns, @Named(PROPERTY_VCLOUD_XML_SCHEMA) String schema) { - this.ns = ns; - this.schema = schema; - this.stringBinder = stringBinder; - } - - @Override - public R bindToRequest(R request, Map postParams) { - checkArgument(checkNotNull(request, "request") instanceof GeneratedHttpRequest, - "this binder is only valid for GeneratedHttpRequests!"); - GeneratedHttpRequest gRequest = (GeneratedHttpRequest) request; - String name = checkNotNull(postParams.get("name"), "name").toString(); - String source = checkNotNull(postParams.get("Source"), "Source").toString(); - boolean isSourceDelete = Boolean.parseBoolean((String) postParams.get("IsSourceDelete")); - - O options = findOptionsInArgsOrNew(gRequest); - return stringBinder.bindToRequest(request, generateXml(name, source, isSourceDelete, options)); - } - - protected String generateXml(String name, String source, boolean isSourceDelete, O options) { - XMLBuilder rootBuilder = buildRoot(name, options); - addElementsUnderRoot(rootBuilder, source, options, isSourceDelete); - Properties outputProperties = new Properties(); - outputProperties.put(javax.xml.transform.OutputKeys.OMIT_XML_DECLARATION, "yes"); - try { - return rootBuilder.asString(outputProperties); - } catch (Exception e) { - throw Throwables.propagate(e); - } - } - - protected void addElementsUnderRoot(XMLBuilder rootBuilder, String source, O options, boolean isSourceDelete) { - if (options.getDescription() != null) - rootBuilder.e("Description").text(options.getDescription()); - rootBuilder.e("Source").a("href", source).a("type", getSourceMediaType()); - if (isSourceDelete) - rootBuilder.e("IsSourceDelete").t("true"); - } - - protected XMLBuilder buildRoot(String name, O options) { - try { - return XMLBuilder.create(getRootElement()).a("xmlns", ns).a("xmlns:xsi", - "http://www.w3.org/2001/XMLSchema-instance").a("xsi:schemaLocation", ns + " " + schema).a("name", - name); - } catch (Exception e) { - throw Throwables.propagate(e); - } - } - - @SuppressWarnings("unchecked") - protected O findOptionsInArgsOrNew(GeneratedHttpRequest gRequest) { - for (Object arg : gRequest.getInvocation().getArgs()) { - if (getOptionClass().isInstance(arg)) { - return (O) arg; - } else if (arg.getClass().isArray()) { - Object[] array = (Object[]) arg; - if (array.length > 0 && getOptionClass().isInstance(array[0])) - return (O) array[0]; - } - } - try { - return getOptionClass().newInstance(); - } catch (Exception e) { - throw Throwables.propagate(e); - } - } - - @Override - public R bindToRequest(R request, Object input) { - throw new IllegalStateException("CloneParams is needs parameters"); - } - - protected String ifNullDefaultTo(String value, String defaultValue) { - return value != null ? value : checkNotNull(defaultValue, "defaultValue"); - } -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/binders/BindCloneVAppParamsToXmlPayload.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/binders/BindCloneVAppParamsToXmlPayload.java deleted file mode 100644 index 50c3b83112..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/binders/BindCloneVAppParamsToXmlPayload.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.binders; - -import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_XML_NAMESPACE; -import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_XML_SCHEMA; - -import javax.inject.Named; -import javax.inject.Singleton; - -import org.jclouds.rest.binders.BindToStringPayload; -import org.jclouds.vcloud.VCloudMediaType; -import org.jclouds.vcloud.options.CloneVAppOptions; - -import com.google.inject.Inject; -import com.jamesmurty.utils.XMLBuilder; - -@Singleton -public class BindCloneVAppParamsToXmlPayload extends BindCloneParamsToXmlPayload { - - @Inject - public BindCloneVAppParamsToXmlPayload(BindToStringPayload stringBinder, - @Named(PROPERTY_VCLOUD_XML_NAMESPACE) String ns, @Named(PROPERTY_VCLOUD_XML_SCHEMA) String schema) { - super(stringBinder, ns, schema); - } - - @Override - protected Class getOptionClass() { - return CloneVAppOptions.class; - } - - @Override - protected String getRootElement() { - return "CloneVAppParams"; - } - - @Override - protected String getSourceMediaType() { - return VCloudMediaType.VAPP_XML; - } - - protected XMLBuilder buildRoot(String name, CloneVAppOptions options) { - return super.buildRoot(name, options).a("deploy", options.isDeploy() + "").a("powerOn", options.isPowerOn() + ""); - } - -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/binders/BindCloneVAppTemplateParamsToXmlPayload.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/binders/BindCloneVAppTemplateParamsToXmlPayload.java deleted file mode 100644 index 2323c94427..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/binders/BindCloneVAppTemplateParamsToXmlPayload.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.binders; - -import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_XML_NAMESPACE; -import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_XML_SCHEMA; - -import javax.inject.Named; -import javax.inject.Singleton; - -import org.jclouds.rest.binders.BindToStringPayload; -import org.jclouds.vcloud.VCloudMediaType; -import org.jclouds.vcloud.options.CloneVAppTemplateOptions; - -import com.google.inject.Inject; - -@Singleton -public class BindCloneVAppTemplateParamsToXmlPayload extends BindCloneParamsToXmlPayload { - - @Inject - public BindCloneVAppTemplateParamsToXmlPayload(BindToStringPayload stringBinder, - @Named(PROPERTY_VCLOUD_XML_NAMESPACE) String ns, @Named(PROPERTY_VCLOUD_XML_SCHEMA) String schema) { - super(stringBinder, schema, schema); - } - - @Override - protected Class getOptionClass() { - return CloneVAppTemplateOptions.class; - } - - @Override - protected String getRootElement() { - return "CloneVAppTemplateParams"; - } - - @Override - protected String getSourceMediaType() { - return VCloudMediaType.VAPPTEMPLATE_XML; - } - -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/binders/BindDeployVAppParamsToXmlPayload.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/binders/BindDeployVAppParamsToXmlPayload.java deleted file mode 100644 index d376222a1e..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/binders/BindDeployVAppParamsToXmlPayload.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.binders; - -import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_XML_NAMESPACE; - -import javax.inject.Named; -import javax.inject.Singleton; - -import org.jclouds.rest.binders.BindToStringPayload; - -import com.google.inject.Inject; - -@Singleton -public class BindDeployVAppParamsToXmlPayload extends BindParamsToXmlPayload { - - @Inject - public BindDeployVAppParamsToXmlPayload(BindToStringPayload stringBinder, - @Named(PROPERTY_VCLOUD_XML_NAMESPACE) String ns) { - super("DeployVAppParams", stringBinder, ns); - } - -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/binders/BindGuestCustomizationSectionToXmlPayload.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/binders/BindGuestCustomizationSectionToXmlPayload.java deleted file mode 100644 index 3ba51d1d3e..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/binders/BindGuestCustomizationSectionToXmlPayload.java +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.binders; - -import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.base.Preconditions.checkNotNull; -import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_XML_NAMESPACE; -import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_XML_SCHEMA; - -import java.util.Properties; - -import javax.annotation.Resource; -import javax.inject.Named; -import javax.inject.Singleton; - -import org.jclouds.http.HttpRequest; -import org.jclouds.logging.Logger; -import org.jclouds.rest.binders.BindToStringPayload; -import org.jclouds.vcloud.domain.GuestCustomizationSection; - -import com.google.common.base.Throwables; -import com.google.inject.Inject; -import com.jamesmurty.utils.XMLBuilder; - -@Singleton -public class BindGuestCustomizationSectionToXmlPayload extends BindToStringPayload { - @Resource - protected Logger logger = Logger.NULL; - - protected final String ns; - protected final String schema; - - @Inject - public BindGuestCustomizationSectionToXmlPayload(BindToStringPayload stringBinder, - @Named(PROPERTY_VCLOUD_XML_NAMESPACE) String ns, @Named(PROPERTY_VCLOUD_XML_SCHEMA) String schema) { - this.ns = ns; - this.schema = schema; - } - @Override - public R bindToRequest(R request, Object payload) { - checkArgument(checkNotNull(payload, "GuestCustomizationSection") instanceof GuestCustomizationSection, - "this binder is only valid for GuestCustomizationSection!"); - GuestCustomizationSection guest = GuestCustomizationSection.class.cast(payload); - XMLBuilder guestCustomizationSection; - try { - guestCustomizationSection = XMLBuilder.create("GuestCustomizationSection").a("xmlns", ns).a("xmlns:ovf", - "http://schemas.dmtf.org/ovf/envelope/1").a("type", guest.getType()).a("href", - guest.getHref().toASCIIString()).a("ovf:required", "false"); - guestCustomizationSection.e("ovf:Info").t(guest.getInfo()); - - if (guest.isEnabled() != null) - guestCustomizationSection.e("Enabled").t(guest.isEnabled().toString()); - if (guest.shouldChangeSid() != null) - guestCustomizationSection.e("ChangeSid").t(guest.shouldChangeSid().toString()); - if (guest.getVirtualMachineId() != null) - guestCustomizationSection.e("VirtualMachineId").t(guest.getVirtualMachineId().toString()); - if (guest.isJoinDomainEnabled() != null) - guestCustomizationSection.e("JoinDomainEnabled").t(guest.isJoinDomainEnabled().toString()); - if (guest.shouldUseOrgSettings() != null) - guestCustomizationSection.e("UseOrgSettings").t(guest.shouldUseOrgSettings().toString()); - if (guest.getDomainName() != null) - guestCustomizationSection.e("DomainName").t(guest.getDomainName().toString()); - if (guest.getDomainUserName() != null) - guestCustomizationSection.e("DomainUserName").t(guest.getDomainUserName().toString()); - if (guest.getDomainUserPassword() != null) - guestCustomizationSection.e("DomainUserPassword").t(guest.getDomainUserPassword().toString()); - if (guest.isAdminPasswordEnabled() != null) - guestCustomizationSection.e("AdminPasswordEnabled").t(guest.isAdminPasswordEnabled().toString()); - if (guest.isAdminPasswordAuto() != null) - guestCustomizationSection.e("AdminPasswordAuto").t(guest.isAdminPasswordAuto().toString()); - // if (guest.getAdminPassword() != null) - // guestCustomizationSection.e("AdminPassword").t(guest.getAdminPassword().toString()); - if (guest.isResetPasswordRequired() != null) - guestCustomizationSection.e("ResetPasswordRequired").t(guest.isResetPasswordRequired().toString()); - if (guest.getCustomizationScript() != null) - guestCustomizationSection.e("CustomizationScript").t(guest.getCustomizationScript()); - if (guest.getComputerName() != null) - guestCustomizationSection.e("ComputerName").t(guest.getComputerName().toString()); - if (guest.getEdit() != null) - guestCustomizationSection.e("Link").a("rel", "edit").a("type", guest.getType()).a("href", - guest.getHref().toASCIIString()); - - Properties outputProperties = new Properties(); - outputProperties.put(javax.xml.transform.OutputKeys.OMIT_XML_DECLARATION, "yes"); - request = super.bindToRequest(request, guestCustomizationSection.asString(outputProperties)); - request.getPayload().getContentMetadata().setContentType(guest.getType()); - } catch (Exception e) { - Throwables.propagate(e); - } - return request; - } - -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/binders/BindInstantiateVAppTemplateParamsToXmlPayload.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/binders/BindInstantiateVAppTemplateParamsToXmlPayload.java deleted file mode 100644 index 5576ca0432..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/binders/BindInstantiateVAppTemplateParamsToXmlPayload.java +++ /dev/null @@ -1,216 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.binders; - -import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.collect.Iterables.transform; -import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_XML_NAMESPACE; -import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_XML_SCHEMA; - -import java.net.URI; -import java.util.Map; -import java.util.Properties; -import java.util.Set; - -import javax.inject.Inject; -import javax.inject.Named; -import javax.inject.Singleton; -import javax.xml.parsers.FactoryConfigurationError; -import javax.xml.parsers.ParserConfigurationException; -import javax.xml.transform.TransformerException; - -import org.jclouds.http.HttpRequest; -import org.jclouds.javax.annotation.Nullable; -import org.jclouds.rest.MapBinder; -import org.jclouds.rest.binders.BindToStringPayload; -import org.jclouds.rest.internal.GeneratedHttpRequest; -import org.jclouds.vcloud.domain.ReferenceType; -import org.jclouds.vcloud.domain.VAppTemplate; -import org.jclouds.vcloud.domain.Vm; -import org.jclouds.vcloud.domain.network.FenceMode; -import org.jclouds.vcloud.domain.network.NetworkConfig; -import org.jclouds.vcloud.endpoints.Network; -import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions; - -import com.google.common.annotations.VisibleForTesting; -import com.google.common.base.Function; -import com.google.common.base.Supplier; -import com.google.common.cache.LoadingCache; -import com.google.common.collect.ImmutableSet; -import com.jamesmurty.utils.XMLBuilder; - -@Singleton -public class BindInstantiateVAppTemplateParamsToXmlPayload implements MapBinder { - - protected final String ns; - protected final String schema; - protected final BindToStringPayload stringBinder; - protected final Supplier defaultNetwork; - protected final FenceMode defaultFenceMode; - protected final LoadingCache templateCache; - protected final Function defaultNetworkNameInTemplate; - - @Inject - public BindInstantiateVAppTemplateParamsToXmlPayload(LoadingCache templateCache, - @Network Function defaultNetworkNameInTemplate, BindToStringPayload stringBinder, - @Named(PROPERTY_VCLOUD_XML_NAMESPACE) String ns, @Named(PROPERTY_VCLOUD_XML_SCHEMA) String schema, - @Network Supplier network, FenceMode fenceMode) { - this.templateCache = templateCache; - this.defaultNetworkNameInTemplate = defaultNetworkNameInTemplate; - this.ns = ns; - this.schema = schema; - this.stringBinder = stringBinder; - this.defaultNetwork = network; - this.defaultFenceMode = fenceMode; - } - - @Override - public R bindToRequest(R request, Map postParams) { - checkArgument(checkNotNull(request, "request") instanceof GeneratedHttpRequest, - "this binder is only valid for GeneratedHttpRequests!"); - GeneratedHttpRequest gRequest = (GeneratedHttpRequest) request; - String name = checkNotNull(postParams.remove("name"), "name").toString(); - URI template = URI.create(checkNotNull(postParams.remove("template"), "template").toString()); - - Set networkConfig = null; - - NetworkConfigDecorator networkConfigDecorator = new NetworkConfigDecorator(templateCache.getUnchecked(template), - defaultNetwork.get().getHref(), defaultFenceMode, defaultNetworkNameInTemplate); - - InstantiateVAppTemplateOptions options = findOptionsInArgsOrNull(gRequest); - - if (options != null) { - if (!options.getNetworkConfig().isEmpty()) - networkConfig = ImmutableSet - .copyOf(transform(options.getNetworkConfig(), networkConfigDecorator)); - } else { - options = new InstantiateVAppTemplateOptions(); - } - - if (networkConfig == null) - networkConfig = ImmutableSet.of(networkConfigDecorator.apply(null)); - - try { - return stringBinder.bindToRequest(request, generateXml(name, options.getDescription(), options.shouldDeploy(), - options.shouldPowerOn(), template, networkConfig)); - } catch (ParserConfigurationException e) { - throw new RuntimeException(e); - } catch (FactoryConfigurationError e) { - throw new RuntimeException(e); - } catch (TransformerException e) { - throw new RuntimeException(e); - } - - } - - @VisibleForTesting - Set ifCustomizationScriptIsSetGetVmsInTemplate(String customizationScript, final URI template) { - Set vms = ImmutableSet.of(); - if (customizationScript != null) { - VAppTemplate vAppTemplate = templateCache.getUnchecked(template); - checkArgument(vAppTemplate != null, "vAppTemplate %s not found!", template); - vms = vAppTemplate.getChildren(); - checkArgument(!vms.isEmpty(), "no vms found in vAppTemplate %s", vAppTemplate); - } - return vms; - } - - protected static final class NetworkConfigDecorator implements Function { - private final VAppTemplate template; - private final URI defaultNetwork; - private final FenceMode defaultFenceMode; - private final Function defaultNetworkNameInTemplate; - - protected NetworkConfigDecorator(VAppTemplate template, URI defaultNetwork, FenceMode defaultFenceMode, - Function defaultNetworkNameInTemplate) { - this.template = checkNotNull(template, "template"); - this.defaultNetwork = checkNotNull(defaultNetwork, "defaultNetwork"); - this.defaultFenceMode = checkNotNull(defaultFenceMode, "defaultFenceMode"); - this.defaultNetworkNameInTemplate = checkNotNull(defaultNetworkNameInTemplate, "defaultNetworkNameInTemplate"); - } - - @Override - public NetworkConfig apply(NetworkConfig from) { - if (from == null) - return new NetworkConfig(defaultNetworkNameInTemplate.apply(template), defaultNetwork, defaultFenceMode); - URI network = ifNullDefaultTo(from.getParentNetwork(), defaultNetwork); - FenceMode fenceMode = ifNullDefaultTo(from.getFenceMode(), defaultFenceMode); - // using conditional statement instead of ifNullDefaultTo so that we lazy invoke the - // function, as it is an expensive one. - String networkName = from.getNetworkName() != null ? from.getNetworkName() : defaultNetworkNameInTemplate - .apply(template); - return new NetworkConfig(networkName, network, fenceMode); - } - } - - protected String generateXml(String name, @Nullable String description, boolean deploy, boolean powerOn, - URI template, Iterable networkConfig) - throws ParserConfigurationException, FactoryConfigurationError, TransformerException { - XMLBuilder rootBuilder = buildRoot(name).a("deploy", deploy + "").a("powerOn", powerOn + ""); - if (description != null) - rootBuilder.e("Description").t(description); - XMLBuilder instantiationParamsBuilder = rootBuilder.e("InstantiationParams"); - addNetworkConfig(instantiationParamsBuilder, networkConfig); - rootBuilder.e("Source").a("href", template.toASCIIString()); - rootBuilder.e("AllEULAsAccepted").t("true"); - - Properties outputProperties = new Properties(); - outputProperties.put(javax.xml.transform.OutputKeys.OMIT_XML_DECLARATION, "yes"); - return rootBuilder.asString(outputProperties); - } - - protected void addNetworkConfig(XMLBuilder instantiationParamsBuilder, - Iterable networkConfig) { - XMLBuilder networkConfigBuilder = instantiationParamsBuilder.e("NetworkConfigSection"); - networkConfigBuilder.e("ovf:Info").t("Configuration parameters for logical networks"); - for (NetworkConfig n : networkConfig) { - XMLBuilder configurationBuilder = networkConfigBuilder.e("NetworkConfig").a("networkName", n.getNetworkName()) - .e("Configuration"); - configurationBuilder.e("ParentNetwork").a("href", n.getParentNetwork().toASCIIString()); - if (n.getFenceMode() != null) { - configurationBuilder.e("FenceMode").t(n.getFenceMode().toString()); - } - } - } - - protected XMLBuilder buildRoot(String name) throws ParserConfigurationException, FactoryConfigurationError { - return XMLBuilder.create("InstantiateVAppTemplateParams").a("name", name).a("xmlns", ns) - .a("xmlns:ovf", "http://schemas.dmtf.org/ovf/envelope/1"); - } - - protected InstantiateVAppTemplateOptions findOptionsInArgsOrNull(GeneratedHttpRequest gRequest) { - for (Object arg : gRequest.getInvocation().getArgs()) { - if (arg instanceof InstantiateVAppTemplateOptions) { - return (InstantiateVAppTemplateOptions) arg; - } else if (arg instanceof InstantiateVAppTemplateOptions[]) { - InstantiateVAppTemplateOptions[] options = (InstantiateVAppTemplateOptions[]) arg; - return (options.length > 0) ? options[0] : null; - } - } - return null; - } - - @Override - public R bindToRequest(R request, Object input) { - throw new IllegalStateException("InstantiateVAppTemplateParams is needs parameters"); - } - - public static T ifNullDefaultTo(T value, T defaultValue) { - return value != null ? value : checkNotNull(defaultValue, "defaultValue"); - } -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/binders/BindMemoryToXmlPayload.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/binders/BindMemoryToXmlPayload.java deleted file mode 100644 index e6a1cd450f..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/binders/BindMemoryToXmlPayload.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.binders; - -import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.base.Preconditions.checkNotNull; -import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_XML_NAMESPACE; -import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_XML_SCHEMA; - -import java.util.Properties; - -import javax.inject.Named; -import javax.inject.Singleton; - -import org.jclouds.cim.ResourceAllocationSettingData.ResourceType; -import org.jclouds.http.HttpRequest; -import org.jclouds.rest.binders.BindToStringPayload; - -import com.google.common.base.Throwables; -import com.google.inject.Inject; -import com.jamesmurty.utils.XMLBuilder; - -@Singleton -public class BindMemoryToXmlPayload extends BindToStringPayload { - protected final String ns; - protected final String schema; - - @Inject - public BindMemoryToXmlPayload(BindToStringPayload stringBinder, @Named(PROPERTY_VCLOUD_XML_NAMESPACE) String ns, - @Named(PROPERTY_VCLOUD_XML_SCHEMA) String schema) { - this.ns = ns; - this.schema = schema; - } - - private static final String RESOURCE_ALLOCATION_NS = "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData"; - - @Override - public R bindToRequest(R request, Object payload) { - checkArgument(checkNotNull(payload, "memoryInMB") instanceof Integer, "this binder is only valid for Integers!"); - Integer memoryInMB = Integer.class.cast(payload); - XMLBuilder cpuItem; - try { - cpuItem = XMLBuilder.create("Item").a("xmlns", ns).a("xmlns:rasd", RESOURCE_ALLOCATION_NS); - cpuItem.e("rasd:AllocationUnits").t("byte * 2^20"); - cpuItem.e("rasd:Description").t("Memory Size"); - cpuItem.e("rasd:ElementName").t(memoryInMB.toString() + " MB of memory"); - cpuItem.e("rasd:InstanceID").t("5"); - cpuItem.e("rasd:Reservation").t("0"); - cpuItem.e("rasd:ResourceType").t(ResourceType.MEMORY.value()); - cpuItem.e("rasd:VirtualQuantity").t(memoryInMB.toString()); - cpuItem.e("rasd:Weight").t("0"); - Properties outputProperties = new Properties(); - outputProperties.put(javax.xml.transform.OutputKeys.OMIT_XML_DECLARATION, "yes"); - request = super.bindToRequest(request, cpuItem.asString(outputProperties)); - } catch (Exception e) { - Throwables.propagate(e); - } - return request; - } - -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/binders/BindNetworkConnectionSectionToXmlPayload.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/binders/BindNetworkConnectionSectionToXmlPayload.java deleted file mode 100644 index 6a277255f9..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/binders/BindNetworkConnectionSectionToXmlPayload.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.binders; - -import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.base.Preconditions.checkNotNull; -import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_XML_NAMESPACE; -import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_XML_SCHEMA; - -import java.util.Properties; - -import javax.annotation.Resource; -import javax.inject.Named; -import javax.inject.Singleton; - -import org.jclouds.http.HttpRequest; -import org.jclouds.logging.Logger; -import org.jclouds.rest.binders.BindToStringPayload; -import org.jclouds.vcloud.domain.NetworkConnection; -import org.jclouds.vcloud.domain.NetworkConnectionSection; - -import com.google.common.base.Throwables; -import com.google.inject.Inject; -import com.jamesmurty.utils.XMLBuilder; - -@Singleton -public class BindNetworkConnectionSectionToXmlPayload extends BindToStringPayload { - @Resource - protected Logger logger = Logger.NULL; - - protected final String ns; - protected final String schema; - - @Inject - public BindNetworkConnectionSectionToXmlPayload(BindToStringPayload stringBinder, - @Named(PROPERTY_VCLOUD_XML_NAMESPACE) String ns, @Named(PROPERTY_VCLOUD_XML_SCHEMA) String schema) { - this.ns = ns; - this.schema = schema; - } - - @Override - public R bindToRequest(R request, Object payload) { - checkArgument(checkNotNull(payload, "NetworkConnectionSection") instanceof NetworkConnectionSection, - "this binder is only valid for NetworkConnectionSection!"); - NetworkConnectionSection net = NetworkConnectionSection.class.cast(payload); - XMLBuilder networkConnectionSection; - try { - networkConnectionSection = XMLBuilder.create("NetworkConnectionSection").a("xmlns", ns) - .a("xmlns:ovf", "http://schemas.dmtf.org/ovf/envelope/1").a("type", net.getType()) - .a("href", net.getHref().toASCIIString()).a("ovf:required", "false"); - networkConnectionSection.e("ovf:Info").t(net.getInfo()); - - if (net.getPrimaryNetworkConnectionIndex() != null) - networkConnectionSection.e("PrimaryNetworkConnectionIndex").t( - net.getPrimaryNetworkConnectionIndex().toString()); - for (NetworkConnection networkConnection : net.getConnections()) { - XMLBuilder networkConnectionSectionChild = networkConnectionSection.e("NetworkConnection").a("network", - networkConnection.getNetwork()); - networkConnectionSectionChild.e("NetworkConnectionIndex").t( - networkConnection.getNetworkConnectionIndex() + ""); - if (networkConnection.getExternalIpAddress() != null) - networkConnectionSectionChild.e("ExternalIpAddress").t(networkConnection.getExternalIpAddress()); - if (networkConnection.getIpAddress() != null) - networkConnectionSectionChild.e("IpAddress").t(networkConnection.getIpAddress()); - networkConnectionSectionChild.e("IsConnected").t(networkConnection.isConnected() + ""); - if (networkConnection.getMACAddress() != null) - networkConnectionSectionChild.e("MACAddress").t(networkConnection.getMACAddress()); - if (networkConnection.getIpAddressAllocationMode() != null) - networkConnectionSectionChild.e("IpAddressAllocationMode").t( - networkConnection.getIpAddressAllocationMode().toString()); - } - - if (net.getEdit() != null) - networkConnectionSection.e("Link").a("rel", "edit").a("type", net.getType()) - .a("href", net.getHref().toASCIIString()); - - Properties outputProperties = new Properties(); - outputProperties.put(javax.xml.transform.OutputKeys.OMIT_XML_DECLARATION, "yes"); - request = super.bindToRequest(request, networkConnectionSection.asString(outputProperties)); - request.getPayload().getContentMetadata().setContentType(net.getType()); - } catch (Exception e) { - Throwables.propagate(e); - } - return request; - } - -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/binders/BindParamsToXmlPayload.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/binders/BindParamsToXmlPayload.java deleted file mode 100644 index f613c1bf6a..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/binders/BindParamsToXmlPayload.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.binders; - -import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_XML_NAMESPACE; - -import java.util.Map; -import java.util.Map.Entry; -import java.util.Properties; - -import javax.inject.Named; -import javax.inject.Singleton; -import javax.xml.parsers.FactoryConfigurationError; -import javax.xml.parsers.ParserConfigurationException; -import javax.xml.transform.TransformerException; - -import org.jclouds.http.HttpRequest; -import org.jclouds.rest.MapBinder; -import org.jclouds.rest.binders.BindToStringPayload; - -import com.google.inject.Inject; -import com.jamesmurty.utils.XMLBuilder; - -@Singleton -public class BindParamsToXmlPayload implements MapBinder { - - protected final String ns; - protected final BindToStringPayload stringBinder; - protected final String element; - - @Inject - public BindParamsToXmlPayload(String element, BindToStringPayload stringBinder, - @Named(PROPERTY_VCLOUD_XML_NAMESPACE) String ns) { - this.element = element; - this.ns = ns; - this.stringBinder = stringBinder; - } - @Override - public R bindToRequest(R request, Map postParams) { - try { - return stringBinder.bindToRequest(request, generateXml(postParams)); - } catch (Exception e) { - throw new RuntimeException(e); - } - } - - private String generateXml(Map postParams) throws ParserConfigurationException, - FactoryConfigurationError, TransformerException { - XMLBuilder rootBuilder = XMLBuilder.create(element); - for (Entry entry : postParams.entrySet()) - rootBuilder.a(entry.getKey(), (String) entry.getValue()); - rootBuilder.a("xmlns", ns); - Properties outputProperties = new Properties(); - outputProperties.put(javax.xml.transform.OutputKeys.OMIT_XML_DECLARATION, "yes"); - return rootBuilder.asString(outputProperties); - } - - @Override - public R bindToRequest(R request, Object input) { - throw new IllegalArgumentException("incorrect usage"); - } -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/binders/BindUndeployVAppParamsToXmlPayload.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/binders/BindUndeployVAppParamsToXmlPayload.java deleted file mode 100644 index d95846e24e..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/binders/BindUndeployVAppParamsToXmlPayload.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.binders; - -import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_XML_NAMESPACE; - -import javax.inject.Named; -import javax.inject.Singleton; - -import org.jclouds.rest.binders.BindToStringPayload; - -import com.google.inject.Inject; - -@Singleton -public class BindUndeployVAppParamsToXmlPayload extends BindParamsToXmlPayload { - - @Inject - public BindUndeployVAppParamsToXmlPayload(BindToStringPayload stringBinder, - @Named(PROPERTY_VCLOUD_XML_NAMESPACE) String ns) { - super("UndeployVAppParams", stringBinder, ns); - } - -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/binders/OrgNameAndCatalogNameToEndpoint.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/binders/OrgNameAndCatalogNameToEndpoint.java deleted file mode 100644 index 09c81e5925..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/binders/OrgNameAndCatalogNameToEndpoint.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.binders; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.net.URI; -import java.util.Map; -import java.util.NoSuchElementException; - -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jclouds.http.HttpRequest; -import org.jclouds.rest.MapBinder; -import org.jclouds.vcloud.domain.Org; -import org.jclouds.vcloud.domain.ReferenceType; -import org.jclouds.vcloud.endpoints.Catalog; - -import com.google.common.base.Supplier; -import com.google.common.collect.Iterables; - -@Singleton -public class OrgNameAndCatalogNameToEndpoint implements MapBinder { - private final Supplier> orgMap; - private final Supplier defaultOrg; - private final Supplier defaultCatalog; - - @Inject - public OrgNameAndCatalogNameToEndpoint(Supplier> orgMap, - @org.jclouds.vcloud.endpoints.Org Supplier defaultOrg, - @Catalog Supplier defaultCatalog) { - this.orgMap = orgMap; - this.defaultOrg = defaultOrg; - this.defaultCatalog = defaultCatalog; - } - - @SuppressWarnings("unchecked") - @Override - public R bindToRequest(R request, Map postParams) { - Object org = postParams.get("orgName"); - Object catalog = postParams.get("catalogName"); - if (org == null && catalog == null) - return (R) request.toBuilder().endpoint(defaultCatalog.get().getHref()).build(); - else if (org == null) - org = defaultOrg.get().getName(); - - try { - Map catalogs = checkNotNull(orgMap.get().get(org)).getCatalogs(); - URI endpoint = catalog == null ? Iterables.getLast(catalogs.values()).getHref() : catalogs.get(catalog).getHref(); - return (R) request.toBuilder().endpoint(endpoint).build(); - } catch (NullPointerException e) { - throw new NoSuchElementException(org + "/" + catalog + " not found in " + orgMap.get()); - } - } - - @Override - public R bindToRequest(R request, Object input) { - throw new IllegalStateException(getClass() + " needs parameters"); - } -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/binders/OrgNameAndVDCNameToEndpoint.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/binders/OrgNameAndVDCNameToEndpoint.java deleted file mode 100644 index b4bc580939..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/binders/OrgNameAndVDCNameToEndpoint.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.binders; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.net.URI; -import java.util.Map; -import java.util.NoSuchElementException; - -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jclouds.http.HttpRequest; -import org.jclouds.rest.MapBinder; -import org.jclouds.vcloud.domain.Org; -import org.jclouds.vcloud.domain.ReferenceType; -import org.jclouds.vcloud.endpoints.VDC; - -import com.google.common.base.Supplier; -import com.google.common.collect.Iterables; - -@Singleton -public class OrgNameAndVDCNameToEndpoint implements MapBinder { - private final Supplier> orgNameToVDCEndpoint; - private final Supplier defaultOrg; - private final Supplier defaultVDC; - - @Inject - public OrgNameAndVDCNameToEndpoint(Supplier> orgNameToVDCEndpoint, - @org.jclouds.vcloud.endpoints.Org Supplier defaultOrg, @VDC Supplier defaultVDC) { - this.orgNameToVDCEndpoint = orgNameToVDCEndpoint; - this.defaultOrg = defaultOrg; - this.defaultVDC = defaultVDC; - } - - @SuppressWarnings("unchecked") - @Override - public R bindToRequest(R request, Map postParams) { - Object org = postParams.get("orgName"); - Object vdc = postParams.get("vdcName"); - if (org == null && vdc == null) - return (R) request.toBuilder().endpoint(defaultVDC.get().getHref()).build(); - else if (org == null) - org = defaultOrg.get().getName(); - - try { - Map vdcs = checkNotNull(orgNameToVDCEndpoint.get().get(org)).getVDCs(); - URI endpoint = vdc == null ? Iterables.getLast(vdcs.values()).getHref() : vdcs.get(vdc).getHref(); - return (R) request.toBuilder().endpoint(endpoint).build(); - } catch (NullPointerException e) { - throw new NoSuchElementException(org + "/" + vdc + " not found in " + orgNameToVDCEndpoint.get()); - } - } - - @Override - public R bindToRequest(R request, Object input) { - throw new IllegalStateException(getClass() + " needs parameters"); - } -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/binders/OrgNameCatalogNameItemNameToEndpoint.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/binders/OrgNameCatalogNameItemNameToEndpoint.java deleted file mode 100644 index 2d9f762254..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/binders/OrgNameCatalogNameItemNameToEndpoint.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.binders; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.Map; -import java.util.NoSuchElementException; - -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jclouds.http.HttpRequest; -import org.jclouds.rest.MapBinder; -import org.jclouds.vcloud.domain.ReferenceType; -import org.jclouds.vcloud.endpoints.Catalog; -import org.jclouds.vcloud.endpoints.Org; - -import com.google.common.base.Supplier; - -@Singleton -public class OrgNameCatalogNameItemNameToEndpoint implements MapBinder { - private final Supplier>> orgCatalogMap; - private final Supplier defaultOrg; - private final Supplier defaultCatalog; - - @Inject - public OrgNameCatalogNameItemNameToEndpoint( - Supplier>> orgCatalogMap, - @Org Supplier defaultOrg, @Catalog Supplier defaultCatalog) { - this.orgCatalogMap = orgCatalogMap; - this.defaultOrg = defaultOrg; - this.defaultCatalog = defaultCatalog; - } - - @SuppressWarnings("unchecked") - @Override - public R bindToRequest(R request, Map postParams) { - Object org = postParams.get("orgName"); - Object catalog = postParams.get("catalogName"); - Object catalogItem = postParams.get("itemName"); - if (org == null) - org = defaultOrg.get().getName(); - if (catalog == null) - catalog = defaultCatalog.get().getName(); - try { - Map catalogs = checkNotNull(orgCatalogMap.get().get(org)); - return (R) request.toBuilder().endpoint(catalogs.get(catalog).get(catalogItem).getHref()).build(); - } catch (NullPointerException e) { - throw new NoSuchElementException(org + "/" + catalog + "/" + catalogItem + " not found in " - + orgCatalogMap.get()); - } - } - - @Override - public R bindToRequest(R request, Object input) { - throw new IllegalStateException(getClass() + " needs parameters"); - } -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/binders/OrgNameCatalogNameVAppTemplateNameToEndpoint.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/binders/OrgNameCatalogNameVAppTemplateNameToEndpoint.java deleted file mode 100644 index a8b798dd31..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/binders/OrgNameCatalogNameVAppTemplateNameToEndpoint.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.binders; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.net.URI; -import java.util.Map; -import java.util.NoSuchElementException; - -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jclouds.http.HttpRequest; -import org.jclouds.rest.MapBinder; -import org.jclouds.vcloud.domain.CatalogItem; -import org.jclouds.vcloud.domain.ReferenceType; -import org.jclouds.vcloud.endpoints.Catalog; -import org.jclouds.vcloud.endpoints.Org; - -import com.google.common.base.Supplier; - -@Singleton -public class OrgNameCatalogNameVAppTemplateNameToEndpoint implements MapBinder { - private final Supplier>>> orgCatalogItemMap; - private final Supplier defaultOrg; - private final Supplier defaultCatalog; - - @Inject - public OrgNameCatalogNameVAppTemplateNameToEndpoint( - Supplier>>> orgCatalogItemMap, - @Org Supplier defaultOrg, @Catalog Supplier defaultCatalog) { - this.orgCatalogItemMap = orgCatalogItemMap; - this.defaultOrg = defaultOrg; - this.defaultCatalog = defaultCatalog; - } - - @SuppressWarnings("unchecked") - @Override - public R bindToRequest(R request, Map postParams) { - Object org = postParams.get("orgName"); - Object catalog = postParams.get("catalogName"); - Object catalogItem = postParams.get("itemName"); - if (org == null) - org = defaultOrg.get().getName(); - if (catalog == null) - catalog = defaultCatalog.get().getName(); - Map>> orgCatalogItemMap = this.orgCatalogItemMap.get(); - - if (!orgCatalogItemMap.containsKey(org)) - throw new NoSuchElementException("org: " + org + " not found in " + orgCatalogItemMap.keySet()); - Map> catalogs = orgCatalogItemMap.get(org); - - if (!catalogs.containsKey(catalog)) - throw new NoSuchElementException("catalog: " + org + "/" + catalog + " not found in " + catalogs.keySet()); - Map catalogMap = catalogs.get(catalog); - - if (!catalogMap.containsKey(catalogItem)) - throw new NoSuchElementException("item: " + org + "/" + catalog + "/" + catalogItem + " not found in " - + catalogMap.keySet()); - CatalogItem item = catalogMap.get(catalogItem); - - URI endpoint = checkNotNull(item.getEntity(), - "item: " + org + "/" + catalog + "/" + catalogItem + " has no entity").getHref(); - return (R) request.toBuilder().endpoint(endpoint).build(); - } - - @Override - public R bindToRequest(R request, Object input) { - throw new IllegalStateException(getClass() + " needs parameters"); - } -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/binders/OrgNameVDCNameNetworkNameToEndpoint.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/binders/OrgNameVDCNameNetworkNameToEndpoint.java deleted file mode 100644 index 11bfeac959..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/binders/OrgNameVDCNameNetworkNameToEndpoint.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.binders; - -import java.net.URI; -import java.util.Map; -import java.util.NoSuchElementException; - -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jclouds.vcloud.domain.ReferenceType; -import org.jclouds.vcloud.endpoints.Org; -import org.jclouds.vcloud.endpoints.VDC; - -import com.google.common.base.Supplier; - -@Singleton -public class OrgNameVDCNameNetworkNameToEndpoint extends OrgNameVDCNameResourceNameToEndpoint { - @Inject - public OrgNameVDCNameNetworkNameToEndpoint( - Supplier>> orgVDCMap, - @Org Supplier defaultOrg, @VDC Supplier defaultVDC) { - super(orgVDCMap, defaultOrg, defaultVDC); - } - - protected URI getEndpointOfResourceInVDC(Object org, Object vDC, Object resource, - org.jclouds.vcloud.domain.VDC vDCObject) { - ReferenceType resourceEntity = vDCObject.getAvailableNetworks().get(resource); - if (resourceEntity == null) - throw new NoSuchElementException("network " + resource + " in vdc " + vDC + ", org " + org + " not found in " - + vDCObject.getAvailableNetworks().keySet()); - return resourceEntity.getHref(); - } - -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/binders/OrgNameVDCNameResourceEntityNameToEndpoint.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/binders/OrgNameVDCNameResourceEntityNameToEndpoint.java deleted file mode 100644 index effcc49825..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/binders/OrgNameVDCNameResourceEntityNameToEndpoint.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.binders; - -import java.net.URI; -import java.util.Map; -import java.util.NoSuchElementException; - -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jclouds.vcloud.domain.ReferenceType; -import org.jclouds.vcloud.endpoints.Org; -import org.jclouds.vcloud.endpoints.VDC; - -import com.google.common.base.Supplier; - -@Singleton -public class OrgNameVDCNameResourceEntityNameToEndpoint extends OrgNameVDCNameResourceNameToEndpoint { - @Inject - public OrgNameVDCNameResourceEntityNameToEndpoint( - Supplier>> orgVDCMap, - @Org Supplier defaultOrg, @VDC Supplier defaultVDC) { - super(orgVDCMap, defaultOrg, defaultVDC); - } - - protected URI getEndpointOfResourceInVDC(Object org, Object vDC, Object resource, - org.jclouds.vcloud.domain.VDC vDCObject) { - ReferenceType resourceEntity = vDCObject.getResourceEntities().get(resource); - if (resourceEntity == null) - throw new NoSuchElementException("entity " + resource + " in vdc " + vDC + ", org " + org + " not found in " - + vDCObject.getResourceEntities().keySet()); - return resourceEntity.getHref(); - } - -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/binders/OrgNameVDCNameResourceNameToEndpoint.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/binders/OrgNameVDCNameResourceNameToEndpoint.java deleted file mode 100644 index 99ac848d23..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/binders/OrgNameVDCNameResourceNameToEndpoint.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.binders; - -import static com.google.common.base.Preconditions.checkState; - -import java.net.URI; -import java.util.Map; -import java.util.NoSuchElementException; - -import javax.inject.Inject; - -import org.jclouds.http.HttpRequest; -import org.jclouds.rest.MapBinder; -import org.jclouds.vcloud.domain.ReferenceType; -import org.jclouds.vcloud.domain.VDC; -import org.jclouds.vcloud.endpoints.Org; - -import com.google.common.base.Supplier; -public abstract class OrgNameVDCNameResourceNameToEndpoint implements MapBinder { - - protected final Supplier>> orgVDCMap; - protected final Supplier defaultOrg; - protected final Supplier defaultVDC; - - @Inject - public OrgNameVDCNameResourceNameToEndpoint( - Supplier>> orgVDCMap, - @Org Supplier defaultOrg, @org.jclouds.vcloud.endpoints.VDC Supplier defaultVDC) { - this.orgVDCMap = orgVDCMap; - this.defaultOrg = defaultOrg; - this.defaultVDC = defaultVDC; - } - - @SuppressWarnings("unchecked") - @Override - public R bindToRequest(R request, Map postParams) { - Object org = postParams.get("orgName"); - Object vDC = postParams.get("vdcName"); - Object resource = postParams.get("resourceName"); - if (org == null) - org = defaultOrg.get().getName(); - if (vDC == null) - vDC = defaultVDC.get().getName(); - Map> orgToVDCs = orgVDCMap.get(); - checkState(orgToVDCs != null, "could not get map of org name to vdcs!"); - Map vDCs = orgToVDCs.get(org); - if (vDCs == null) - throw new NoSuchElementException("org " + org + " not found in " + orgToVDCs.keySet()); - org.jclouds.vcloud.domain.VDC vDCObject = vDCs.get(vDC); - if (vDCObject == null) - throw new NoSuchElementException("vdc " + vDC + " in org " + org + " not found in " + vDCs.keySet()); - URI endpoint = getEndpointOfResourceInVDC(org, vDC, resource, vDCObject); - return (R) request.toBuilder().endpoint(endpoint).build(); - } - - protected abstract URI getEndpointOfResourceInVDC(Object org, Object vDC, Object resource, VDC vDCObject); - - @Override - public R bindToRequest(R request, Object input) { - throw new IllegalStateException(getClass() + " needs parameters"); - } -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/config/VCloudComputeServiceContextModule.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/config/VCloudComputeServiceContextModule.java deleted file mode 100644 index d3538c0c2d..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/config/VCloudComputeServiceContextModule.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.compute.config; - -import org.jclouds.compute.config.ComputeServiceAdapterContextModule; -import org.jclouds.domain.Location; -import org.jclouds.vcloud.domain.VApp; -import org.jclouds.vcloud.domain.VAppTemplate; - -/** - * Configures the {@link VCloudComputeServiceContext}; requires {@link VCloudComputeClientImpl} - * bound. - */ -public class VCloudComputeServiceContextModule extends - ComputeServiceAdapterContextModule { - - @Override - protected void configure() { - super.configure(); - install(new VCloudComputeServiceDependenciesModule()); - } - -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/config/VCloudComputeServiceDependenciesModule.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/config/VCloudComputeServiceDependenciesModule.java deleted file mode 100644 index 8b53c902fc..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/config/VCloudComputeServiceDependenciesModule.java +++ /dev/null @@ -1,150 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.compute.config; - - -import java.util.Map; - -import javax.inject.Singleton; - -import org.jclouds.compute.ComputeServiceAdapter; -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.options.TemplateOptions; -import org.jclouds.domain.Location; -import org.jclouds.functions.IdentityFunction; -import org.jclouds.vcloud.compute.functions.HardwareForVApp; -import org.jclouds.vcloud.compute.functions.HardwareForVAppTemplate; -import org.jclouds.vcloud.compute.functions.ImageForVAppTemplate; -import org.jclouds.vcloud.compute.functions.VAppToNodeMetadata; -import org.jclouds.vcloud.compute.internal.VCloudTemplateBuilderImpl; -import org.jclouds.vcloud.compute.options.VCloudTemplateOptions; -import org.jclouds.vcloud.compute.strategy.VCloudComputeServiceAdapter; -import org.jclouds.vcloud.domain.Org; -import org.jclouds.vcloud.domain.ReferenceType; -import org.jclouds.vcloud.domain.Status; -import org.jclouds.vcloud.domain.VApp; -import org.jclouds.vcloud.domain.VAppTemplate; -import org.jclouds.vcloud.domain.network.FenceMode; -import org.jclouds.vcloud.domain.network.NetworkConfig; -import org.jclouds.vcloud.endpoints.Network; -import org.jclouds.vcloud.functions.VAppTemplatesInOrg; - -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.collect.ImmutableMap; -import com.google.inject.AbstractModule; -import com.google.inject.Provides; -import com.google.inject.TypeLiteral; - -public class VCloudComputeServiceDependenciesModule extends AbstractModule { - - @VisibleForTesting - public static final Map toPortableNodeStatus = ImmutableMap - . builder() - .put(Status.OFF, NodeMetadata.Status.SUSPENDED) - .put(Status.ON, NodeMetadata.Status.RUNNING) - .put(Status.RESOLVED, NodeMetadata.Status.PENDING) - .put(Status.MIXED, NodeMetadata.Status.PENDING) - .put(Status.UNKNOWN, NodeMetadata.Status.UNRECOGNIZED) - .put(Status.UNRECOGNIZED, NodeMetadata.Status.UNRECOGNIZED) - .put(Status.DEPLOYED, NodeMetadata.Status.PENDING) - .put(Status.SUSPENDED, NodeMetadata.Status.SUSPENDED) - .put(Status.WAITING_FOR_INPUT, NodeMetadata.Status.PENDING) - .put(Status.INCONSISTENT, NodeMetadata.Status.PENDING) - .put(Status.ERROR, NodeMetadata.Status.ERROR) - .put(Status.UNRESOLVED, NodeMetadata.Status.PENDING).build(); - - @Singleton - @Provides - protected Map toPortableNodeStatus() { - return toPortableNodeStatus; - } - - @VisibleForTesting - public static final Map toPortableImageStatus = ImmutableMap - . builder() - .put(Status.RESOLVED, Image.Status.AVAILABLE) - .put(Status.OFF, Image.Status.AVAILABLE) - .put(Status.MIXED, Image.Status.PENDING) - .put(Status.UNKNOWN, Image.Status.UNRECOGNIZED) - .put(Status.UNRECOGNIZED, Image.Status.UNRECOGNIZED) - .put(Status.DEPLOYED, Image.Status.PENDING) - .put(Status.PENDING_DESCRIPTOR, Image.Status.PENDING) - .put(Status.COPYING, Image.Status.PENDING) - .put(Status.PENDING_CONTENTS, Image.Status.PENDING) - .put(Status.QUARANTINED, Image.Status.PENDING) - .put(Status.QUARANTINE_EXPIRED, Image.Status.ERROR) - .put(Status.REJECTED, Image.Status.ERROR) - .put(Status.TRANSFER_TIMEOUT, Image.Status.ERROR) - .put(Status.ERROR, Image.Status.ERROR) - .put(Status.UNRESOLVED, Image.Status.PENDING).build(); - - @Singleton - @Provides - protected Map toPortableImageStatus() { - return toPortableImageStatus; - } - - @SuppressWarnings("unchecked") - @Override - protected void configure() { - bind(new TypeLiteral>() { - }).to(VCloudComputeServiceAdapter.class); - - bind(new TypeLiteral>() { - }).to(VAppToNodeMetadata.class); - - bind(TemplateOptions.class).to(VCloudTemplateOptions.class); - bind(TemplateBuilder.class).to(VCloudTemplateBuilderImpl.class); - - bind(new TypeLiteral>() { - }).to(new TypeLiteral() { - }); - - bind(new TypeLiteral>>() { - }).to(VAppTemplatesInOrg.class); - bind(new TypeLiteral>() { - }).to(ImageForVAppTemplate.class); - bind(new TypeLiteral>() { - }).to(HardwareForVAppTemplate.class); - - // we aren't converting from a provider-specific type - bind(new TypeLiteral>() { - }).to(Class.class.cast(IdentityFunction.class)); - } - - - @Provides - @Singleton - public Supplier networkConfig(@Network Supplier network, - final FenceMode defaultFenceMode) { - return Suppliers.compose(new Function() { - - @Override - public NetworkConfig apply(ReferenceType input) { - return new NetworkConfig(input.getName(), input.getHref(), defaultFenceMode); - } - - }, network); - } - -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/functions/FindLocationForResource.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/functions/FindLocationForResource.java deleted file mode 100644 index f7e2cdf386..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/functions/FindLocationForResource.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.compute.functions; - -import java.net.URI; -import java.util.NoSuchElementException; -import java.util.Set; - -import javax.annotation.Resource; -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jclouds.collect.Memoized; -import org.jclouds.domain.Location; -import org.jclouds.logging.Logger; -import org.jclouds.vcloud.domain.ReferenceType; - -import com.google.common.base.Function; -import com.google.common.base.Supplier; - -@Singleton -public class FindLocationForResource implements Function { - - @Resource - protected Logger logger = Logger.NULL; - - final Supplier> locations; - - @Inject - public FindLocationForResource(@Memoized Supplier> locations) { - this.locations = locations; - } - - /** - * searches for a location associated with this resource. - * - * @throws NoSuchElementException - * if not found - */ - public Location apply(ReferenceType resource) { - for (Location input : locations.get()) { - do { - // The "name" isn't always present, ex inside a vApp we have a rel - // link that only includes href and type. - if (URI.create(input.getId()).equals(resource.getHref())) - return input; - } while ((input = input.getParent()) != null); - } - throw new NoSuchElementException(String.format("resource: %s not found in locations: %s", resource, - locations.get())); - } -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/functions/HardwareForVApp.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/functions/HardwareForVApp.java deleted file mode 100644 index 6ec2bf8a80..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/functions/HardwareForVApp.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.compute.functions; - -import static com.google.common.base.Preconditions.checkNotNull; - -import javax.annotation.Resource; -import javax.inject.Inject; - -import org.jclouds.compute.domain.Hardware; -import org.jclouds.compute.domain.HardwareBuilder; -import org.jclouds.compute.predicates.ImagePredicates; -import org.jclouds.domain.Location; -import org.jclouds.logging.Logger; -import org.jclouds.ovf.VirtualHardwareSection; -import org.jclouds.vcloud.domain.ReferenceType; -import org.jclouds.vcloud.domain.VApp; -import org.jclouds.vcloud.domain.Vm; - -import com.google.common.base.Function; -import com.google.common.collect.Iterables; - -public class HardwareForVApp implements Function { - - @Resource - protected Logger logger = Logger.NULL; - - private final Function findLocationForResource; - private final VCloudHardwareBuilderFromResourceAllocations rasdToHardwareBuilder; - - @Inject - protected HardwareForVApp(Function findLocationForResource, - VCloudHardwareBuilderFromResourceAllocations rasdToHardwareBuilder) { - this.findLocationForResource = checkNotNull(findLocationForResource, "findLocationForResource"); - this.rasdToHardwareBuilder = checkNotNull(rasdToHardwareBuilder, "rasdToHardwareBuilder"); - } - - @Override - public Hardware apply(VApp from) { - checkNotNull(from, "VApp"); - // TODO make this work with composite vApps - Vm vm = from.getChildren().isEmpty() ? null : Iterables.get(from.getChildren(), 0); - if (vm == null) - return null; - - VirtualHardwareSection hardware = vm.getVirtualHardwareSection(); - HardwareBuilder builder = rasdToHardwareBuilder.apply(hardware.getItems()); - builder.location(findLocationForResource.apply(checkNotNull(from, "from").getVDC())); - builder.ids(from.getHref().toASCIIString()).name(from.getName()).supportsImage( - ImagePredicates.idEquals(from.getHref().toASCIIString())); - builder.hypervisor("VMware"); - return builder.build(); - } -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/functions/HardwareForVAppTemplate.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/functions/HardwareForVAppTemplate.java deleted file mode 100644 index 46d16273b8..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/functions/HardwareForVAppTemplate.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.compute.functions; - -import static com.google.common.base.Preconditions.checkNotNull; - -import javax.annotation.Resource; -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jclouds.compute.domain.Hardware; -import org.jclouds.compute.domain.HardwareBuilder; -import org.jclouds.compute.predicates.ImagePredicates; -import org.jclouds.logging.Logger; -import org.jclouds.ovf.Envelope; -import org.jclouds.ovf.VirtualHardwareSection; -import org.jclouds.vcloud.domain.VAppTemplate; - -import com.google.common.base.Function; -import com.google.common.collect.Iterables; - -@Singleton -public class HardwareForVAppTemplate implements Function { - - @Resource - protected Logger logger = Logger.NULL; - - private final Function templateToEnvelope; - private final FindLocationForResource findLocationForResource; - private final VCloudHardwareBuilderFromResourceAllocations rasdToHardwareBuilder; - - @Inject - protected HardwareForVAppTemplate(Function templateToEnvelope, - FindLocationForResource findLocationForResource, - VCloudHardwareBuilderFromResourceAllocations rasdToHardwareBuilder) { - this.templateToEnvelope = checkNotNull(templateToEnvelope, "templateToEnvelope"); - this.findLocationForResource = checkNotNull(findLocationForResource, "findLocationForResource"); - this.rasdToHardwareBuilder = checkNotNull(rasdToHardwareBuilder, "rasdToHardwareBuilder"); - } - - @Override - public Hardware apply(VAppTemplate from) { - checkNotNull(from, "VAppTemplate"); - - Envelope ovf = templateToEnvelope.apply(from); - - if (ovf.getVirtualSystem().getVirtualHardwareSections().size() > 1) { - logger.warn("multiple hardware choices found. using first", ovf); - } - VirtualHardwareSection hardware = Iterables.get(ovf.getVirtualSystem().getVirtualHardwareSections(), 0); - HardwareBuilder builder = rasdToHardwareBuilder.apply(hardware.getItems()); - if (from.getVDC() != null) { - builder.location(findLocationForResource.apply(from.getVDC())); - } else { - // otherwise, it could be in a public catalog, which is not assigned to a VDC - } - builder.ids(from.getHref().toASCIIString()).name(from.getName()).supportsImage( - ImagePredicates.idEquals(from.getHref().toASCIIString())); - builder.hypervisor("VMware"); - return builder.build(); - - } - - protected String getName(String name) { - return name; - } -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/functions/ImageForVAppTemplate.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/functions/ImageForVAppTemplate.java deleted file mode 100644 index eb70f286f7..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/functions/ImageForVAppTemplate.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.compute.functions; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.Map; - -import javax.annotation.Resource; -import javax.inject.Inject; -import javax.inject.Named; -import javax.inject.Singleton; - -import org.jclouds.compute.domain.CIMOperatingSystem; -import org.jclouds.compute.domain.Image; -import org.jclouds.compute.domain.ImageBuilder; -import org.jclouds.compute.reference.ComputeServiceConstants; -import org.jclouds.logging.Logger; -import org.jclouds.ovf.Envelope; -import org.jclouds.vcloud.domain.Status; -import org.jclouds.vcloud.domain.VAppTemplate; - -import com.google.common.base.Function; - -@Singleton -public class ImageForVAppTemplate implements Function { - - @Resource - @Named(ComputeServiceConstants.COMPUTE_LOGGER) - public Logger logger = Logger.NULL; - - private final Map toPortableImageStatus; - private final Function templateToEnvelope; - private final FindLocationForResource findLocationForResource; - - - @Inject - protected ImageForVAppTemplate(Map toPortableImageStatus, Function templateToEnvelope, - FindLocationForResource findLocationForResource) { - this.toPortableImageStatus = checkNotNull(toPortableImageStatus, "toPortableImageStatus"); - this.templateToEnvelope = checkNotNull(templateToEnvelope, "templateToEnvelope"); - this.findLocationForResource = checkNotNull(findLocationForResource, "findLocationForResource"); - } - - @Override - public Image apply(VAppTemplate from) { - checkNotNull(from, "VAppTemplate"); - Envelope ovf = templateToEnvelope.apply(from); - - ImageBuilder builder = new ImageBuilder(); - builder.ids(from.getHref().toASCIIString()); - builder.uri(from.getHref()); - builder.name(from.getName()); - if (from.getVDC() != null) { - builder.location(findLocationForResource.apply(from.getVDC())); - } else { - // otherwise, it could be in a public catalog, which is not assigned to a VDC - } - builder.description(from.getDescription() != null ? from.getDescription() : from.getName()); - builder.operatingSystem(CIMOperatingSystem.toComputeOs(ovf)); - builder.status(toPortableImageStatus.get(from.getStatus())); - return builder.build(); - } - -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/functions/VAppToNodeMetadata.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/functions/VAppToNodeMetadata.java deleted file mode 100644 index 0947c78c7a..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/functions/VAppToNodeMetadata.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.compute.functions; - -import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.base.Predicates.not; -import static com.google.common.base.Strings.isNullOrEmpty; -import static com.google.common.collect.Iterables.filter; -import static org.jclouds.compute.util.ComputeServiceUtils.addMetadataAndParseTagsFromCommaDelimitedValue; -import static org.jclouds.compute.util.ComputeServiceUtils.groupFromMapOrName; -import static org.jclouds.vcloud.compute.util.VCloudComputeUtils.getCredentialsFrom; -import static org.jclouds.vcloud.compute.util.VCloudComputeUtils.getIpsFromVApp; -import static org.jclouds.vcloud.compute.util.VCloudComputeUtils.toComputeOs; - -import java.util.Map; -import java.util.Set; - -import javax.annotation.Resource; -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jclouds.compute.domain.Hardware; -import org.jclouds.compute.domain.NodeMetadata; -import org.jclouds.compute.domain.NodeMetadataBuilder; -import org.jclouds.compute.functions.GroupNamingConvention; -import org.jclouds.domain.Credentials; -import org.jclouds.logging.Logger; -import org.jclouds.util.InetAddresses2.IsPrivateIPAddress; -import org.jclouds.vcloud.domain.Status; -import org.jclouds.vcloud.domain.VApp; - -import com.google.common.base.Function; -import com.google.common.base.Splitter; -import com.google.common.collect.ImmutableMap; - -@Singleton -public class VAppToNodeMetadata implements Function { - @Resource - protected static Logger logger = Logger.NULL; - - protected final FindLocationForResource findLocationForResourceInVDC; - protected final Function hardwareForVApp; - protected final Map vAppStatusToNodeStatus; - protected final Map credentialStore; - protected final GroupNamingConvention nodeNamingConvention; - - @Inject - protected VAppToNodeMetadata(Map vAppStatusToNodeStatus, Map credentialStore, - FindLocationForResource findLocationForResourceInVDC, Function hardwareForVApp, - GroupNamingConvention.Factory namingConvention) { - this.nodeNamingConvention = checkNotNull(namingConvention, "namingConvention").createWithoutPrefix(); - this.hardwareForVApp = checkNotNull(hardwareForVApp, "hardwareForVApp"); - this.findLocationForResourceInVDC = checkNotNull(findLocationForResourceInVDC, "findLocationForResourceInVDC"); - this.credentialStore = checkNotNull(credentialStore, "credentialStore"); - this.vAppStatusToNodeStatus = checkNotNull(vAppStatusToNodeStatus, "vAppStatusToNodeStatus"); - } - - public NodeMetadata apply(VApp from) { - NodeMetadataBuilder builder = new NodeMetadataBuilder(); - builder.ids(from.getHref().toASCIIString()); - builder.uri(from.getHref()); - builder.name(from.getName()); - String groupName = ""; - Map metadataMap; - - if (!isNullOrEmpty(from.getDescription()) - && from.getDescription().indexOf('=') != -1 - && from.getDescription().indexOf('\n') != -1) { - try { - metadataMap = Splitter.on('\n').withKeyValueSeparator("=").split(from.getDescription()); - - addMetadataAndParseTagsFromCommaDelimitedValue(builder, metadataMap); - } catch (IllegalArgumentException iae) { - // no op - metadataMap = ImmutableMap.of(); - } - } else { - metadataMap = ImmutableMap.of(); - } - builder.hostname(from.getName()); - builder.location(findLocationForResourceInVDC.apply(from.getVDC())); - builder.group(groupFromMapOrName(metadataMap, from.getName(), nodeNamingConvention)); - builder.operatingSystem(toComputeOs(from, null)); - builder.hardware(hardwareForVApp.apply(from)); - builder.status(vAppStatusToNodeStatus.get(from.getStatus())); - Set addresses = getIpsFromVApp(from); - builder.publicAddresses(filter(addresses, not(IsPrivateIPAddress.INSTANCE))); - builder.privateAddresses(filter(addresses, IsPrivateIPAddress.INSTANCE)); - - // normally, we don't affect the credential store when reading vApps. - // However, login user, etc, is actually in the metadata, so lets see - Credentials fromApi = getCredentialsFrom(from); - if (fromApi != null && !credentialStore.containsKey("node#" + from.getHref().toASCIIString())) - credentialStore.put("node#" + from.getHref().toASCIIString(), fromApi); - return builder.build(); - } -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/functions/VCloudHardwareBuilderFromResourceAllocations.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/functions/VCloudHardwareBuilderFromResourceAllocations.java deleted file mode 100644 index 2f3bd429de..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/functions/VCloudHardwareBuilderFromResourceAllocations.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.compute.functions; - -import javax.inject.Singleton; - -import org.jclouds.cim.ResourceAllocationSettingData; -import org.jclouds.cim.functions.HardwareBuilderFromResourceAllocations; -import org.jclouds.compute.domain.Volume; -import org.jclouds.compute.domain.internal.VolumeImpl; -import org.jclouds.vcloud.domain.ovf.VCloudHardDisk; - -@Singleton -public class VCloudHardwareBuilderFromResourceAllocations extends HardwareBuilderFromResourceAllocations { - @Override - public Volume apply(ResourceAllocationSettingData from) { - if (from instanceof VCloudHardDisk) { - VCloudHardDisk vDisk = VCloudHardDisk.class.cast(from); - return new VolumeImpl(from.getAddressOnParent() + "", Volume.Type.LOCAL, vDisk.getCapacity() / 1024f, null, - "0".equals(from.getAddressOnParent()), true); - } else { - return super.apply(from); - } - - } -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/functions/ValidateVAppTemplateAndReturnEnvelopeOrThrowIllegalArgumentException.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/functions/ValidateVAppTemplateAndReturnEnvelopeOrThrowIllegalArgumentException.java deleted file mode 100644 index 61142815b1..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/functions/ValidateVAppTemplateAndReturnEnvelopeOrThrowIllegalArgumentException.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.compute.functions; - -import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.base.Preconditions.checkNotNull; - -import java.net.URI; -import java.util.concurrent.ExecutionException; - -import javax.annotation.Resource; -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jclouds.logging.Logger; -import org.jclouds.ovf.Envelope; -import org.jclouds.vcloud.domain.VAppTemplate; - -import com.google.common.base.Function; -import com.google.common.cache.LoadingCache; - -@Singleton -public class ValidateVAppTemplateAndReturnEnvelopeOrThrowIllegalArgumentException implements - Function { - - @Resource - protected Logger logger = Logger.NULL; - - private final LoadingCache envelopes; - - @Inject - protected ValidateVAppTemplateAndReturnEnvelopeOrThrowIllegalArgumentException(LoadingCache envelopes) { - this.envelopes = checkNotNull(envelopes, "envelopes"); - } - - @Override - public Envelope apply(VAppTemplate from) { - checkArgument(from.getChildren().size() == 1, "multiple vms are not supported: %s", from); - - checkArgument(from.getNetworkSection().getNetworks().size() == 1, - "multiple network connections are not supported: %s", from); - - checkArgument(from.isOvfDescriptorUploaded(), "ovf descriptor is not uploaded: %s", from); - Envelope ovf = getOVFForVAppTemplateAndValidate(from); - return ovf; - } - - private Envelope getOVFForVAppTemplateAndValidate(VAppTemplate from) throws IllegalArgumentException { - Envelope ovf; - try { - ovf = envelopes.get(from.getHref()); - checkArgument(!ovf.getVirtualSystem().getVirtualHardwareSections().isEmpty(), - "no hardware sections exist in ovf %s", ovf); - } catch (ExecutionException e) { - throw new IllegalArgumentException("no ovf envelope found for: " + from, e); - } - return ovf; - } -} - diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/internal/VCloudTemplateBuilderImpl.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/internal/VCloudTemplateBuilderImpl.java deleted file mode 100644 index 8304466318..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/internal/VCloudTemplateBuilderImpl.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.compute.internal; - -import java.util.Set; - -import javax.inject.Inject; -import javax.inject.Named; -import javax.inject.Provider; - -import org.jclouds.collect.Memoized; -import org.jclouds.compute.domain.Hardware; -import org.jclouds.compute.domain.TemplateBuilder; -import org.jclouds.compute.domain.internal.TemplateBuilderImpl; -import org.jclouds.compute.options.TemplateOptions; -import org.jclouds.compute.strategy.GetImageStrategy; -import org.jclouds.compute.suppliers.ImageCacheSupplier; -import org.jclouds.domain.Location; - -import com.google.common.base.Supplier; - -public class VCloudTemplateBuilderImpl extends TemplateBuilderImpl { - - @Inject - protected VCloudTemplateBuilderImpl(@Memoized Supplier> locations, - ImageCacheSupplier images, @Memoized Supplier> sizes, - Supplier defaultLocation, @Named("DEFAULT") Provider optionsProvider, - @Named("DEFAULT") Provider defaultTemplateProvider, GetImageStrategy getImageStrategy) { - super(locations, images, sizes, defaultLocation, optionsProvider, defaultTemplateProvider, getImageStrategy); - } -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/options/VCloudTemplateOptions.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/options/VCloudTemplateOptions.java deleted file mode 100644 index 03b12fe53a..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/options/VCloudTemplateOptions.java +++ /dev/null @@ -1,348 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.compute.options; - -import static com.google.common.base.Objects.equal; -import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.base.Strings.emptyToNull; - -import java.net.URI; -import java.util.Map; - -import org.jclouds.compute.options.TemplateOptions; -import org.jclouds.vcloud.domain.network.FenceMode; -import org.jclouds.vcloud.domain.network.IpAddressAllocationMode; - -import com.google.common.base.Objects; -import com.google.common.base.Objects.ToStringHelper; - -/** - * Contains options supported in the {@code ComputeService#runNode} operation on - * the "vcloud" provider.

- * Usage

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

- * - * import static org.jclouds.compute.options.VCloudTemplateOptions.Builder.*; - *

- * ComputeService client = // get connection - * templateBuilder.options(inboundPorts(22, 80, 8080, 443)); - * Set set = client.createNodesInGroup(tag, 2, templateBuilder.build()); - * - */ -public class VCloudTemplateOptions extends TemplateOptions implements Cloneable { - @Override - public VCloudTemplateOptions clone() { - VCloudTemplateOptions options = new VCloudTemplateOptions(); - copyTo(options); - return options; - } - - @Override - public void copyTo(TemplateOptions to) { - super.copyTo(to); - if (to instanceof VCloudTemplateOptions) { - VCloudTemplateOptions eTo = VCloudTemplateOptions.class.cast(to); - if (getCustomizationScript() != null) - eTo.customizationScript(getCustomizationScript()); - if (getDescription() != null) - eTo.description(getDescription()); - if (getIpAddressAllocationMode() != null) - eTo.ipAddressAllocationMode(getIpAddressAllocationMode()); - if (getIpAddressAllocationMode() != null) - eTo.ipAddressAllocationMode(getIpAddressAllocationMode()); - if (getParentNetwork() != null) - eTo.parentNetwork(getParentNetwork()); - if (getFenceMode() != null) - eTo.fenceMode(getFenceMode()); - } - } - - private String description = null; - private String customizationScript = null; - private IpAddressAllocationMode ipAddressAllocationMode = null; - private URI parentNetwork = null; - private FenceMode fenceMode = null; - - @Override - public boolean equals(Object o) { - if (this == o) - return true; - if (o == null || getClass() != o.getClass()) - return false; - VCloudTemplateOptions that = VCloudTemplateOptions.class.cast(o); - return super.equals(that) && equal(this.description, that.description) - && equal(this.customizationScript, that.customizationScript) - && equal(this.ipAddressAllocationMode, that.ipAddressAllocationMode) - && equal(this.parentNetwork, that.parentNetwork); - } - - @Override - public int hashCode() { - return Objects.hashCode(super.hashCode(), description, customizationScript, ipAddressAllocationMode, - parentNetwork); - } - - @Override - public ToStringHelper string() { - return super.string().add("description", description).add("customizationScript", customizationScript) - .add("ipAddressAllocationMode", ipAddressAllocationMode).add("parentNetwork", parentNetwork); - } - - /** - * Optional description. Used for the Description of the vApp created by this - * instantiation. - */ - public VCloudTemplateOptions description(String description) { - this.description = description; - return this; - } - - /** - * Specifies the customizationScript used to run instances with - */ - public VCloudTemplateOptions customizationScript(String customizationScript) { - this.customizationScript = checkNotNull(emptyToNull(customizationScript), "customizationScript must be defined"); - return this; - } - - /** - * Specifies the ipAddressAllocationMode used to for network interfaces on - * the VMs - */ - public VCloudTemplateOptions ipAddressAllocationMode(IpAddressAllocationMode ipAddressAllocationMode) { - this.ipAddressAllocationMode = ipAddressAllocationMode; - return this; - } - - /** - * Specifies the parentNetwork to connect the the network interfaces on the - * VMs to. - * - * @see InstantiateVAppTemplateOptions#addNetworkConfig - */ - public VCloudTemplateOptions parentNetwork(URI parentNetwork) { - this.parentNetwork = parentNetwork; - return this; - } - - /** - * How to connect to the parent network - * - * @see InstantiateVAppTemplateOptions#addNetworkConfig - */ - public VCloudTemplateOptions fenceMode(FenceMode fenceMode) { - this.fenceMode = fenceMode; - return this; - } - - public static class Builder { - /** - * @see VCloudTemplateOptions#description - */ - public static VCloudTemplateOptions description(String description) { - return new VCloudTemplateOptions().description(description); - } - - /** - * @see VCloudTemplateOptions#customizationScript - */ - public static VCloudTemplateOptions customizationScript(String customizationScript) { - return new VCloudTemplateOptions().customizationScript(customizationScript); - } - - /** - * @see VCloudTemplateOptions#ipAddressAllocationMode - */ - public static VCloudTemplateOptions ipAddressAllocationMode(IpAddressAllocationMode ipAddressAllocationMode) { - return new VCloudTemplateOptions().ipAddressAllocationMode(ipAddressAllocationMode); - } - - /** - * @see VCloudTemplateOptions#parentNetwork(URI parentNetwork) - */ - public static VCloudTemplateOptions parentNetwork(URI parentNetwork) { - return new VCloudTemplateOptions().parentNetwork(parentNetwork); - } - - /** - * @see VCloudTemplateOptions#fenceMode(FenceMode) - */ - public static VCloudTemplateOptions fenceMode(FenceMode fenceMode) { - return new VCloudTemplateOptions().fenceMode(fenceMode); - } - - // methods that only facilitate returning the correct object type - /** - * @see TemplateOptions#inboundPorts - */ - public static VCloudTemplateOptions inboundPorts(int... ports) { - VCloudTemplateOptions options = new VCloudTemplateOptions(); - return VCloudTemplateOptions.class.cast(options.inboundPorts(ports)); - } - - /** - * @see TemplateOptions#port - */ - public static VCloudTemplateOptions blockOnPort(int port, int seconds) { - VCloudTemplateOptions options = new VCloudTemplateOptions(); - return VCloudTemplateOptions.class.cast(options.blockOnPort(port, seconds)); - } - - /** - * @see TemplateOptions#userMetadata(Map) - */ - public static VCloudTemplateOptions userMetadata(Map userMetadata) { - VCloudTemplateOptions options = new VCloudTemplateOptions(); - return VCloudTemplateOptions.class.cast(options.userMetadata(userMetadata)); - } - - /** - * @see TemplateOptions#userMetadata(String, String) - */ - public static VCloudTemplateOptions userMetadata(String key, String value) { - VCloudTemplateOptions options = new VCloudTemplateOptions(); - return VCloudTemplateOptions.class.cast(options.userMetadata(key, value)); - } - - /** - * @see TemplateOptions#nodeNames(Iterable) - */ - public static VCloudTemplateOptions nodeNames(Iterable nodeNames) { - VCloudTemplateOptions options = new VCloudTemplateOptions(); - return VCloudTemplateOptions.class.cast(options.nodeNames(nodeNames)); - } - - /** - * @see TemplateOptions#networks(Iterable) - */ - public static VCloudTemplateOptions networks(Iterable networks) { - VCloudTemplateOptions options = new VCloudTemplateOptions(); - return VCloudTemplateOptions.class.cast(options.networks(networks)); - } - - } - - /** - * @return description of the vApp - */ - public String getDescription() { - return description; - } - - /** - * @return customizationScript on the vms - */ - public String getCustomizationScript() { - return customizationScript; - } - - /** - * @return ipAddressAllocationMode on the vms - */ - public IpAddressAllocationMode getIpAddressAllocationMode() { - return ipAddressAllocationMode; - } - - /** - * @return parentNetwork to connect to the vms - */ - public URI getParentNetwork() { - return parentNetwork; - } - - /** - * @return FenceMode to connect the parent network with - */ - public FenceMode getFenceMode() { - return fenceMode; - } - - // methods that only facilitate returning the correct object type - - /** - * @see TemplateOptions#blockOnPort - */ - @Override - public VCloudTemplateOptions blockOnPort(int port, int seconds) { - return VCloudTemplateOptions.class.cast(super.blockOnPort(port, seconds)); - } - - /** - * - * special thing is that we do assume if you are passing groups that you have - * everything you need already defined. for example, our option inboundPorts - * normally creates ingress rules accordingly but if we notice you've - * specified securityGroups, we do not mess with rules at all - * - * @see TemplateOptions#inboundPorts - */ - @Override - public VCloudTemplateOptions inboundPorts(int... ports) { - return VCloudTemplateOptions.class.cast(super.inboundPorts(ports)); - } - - /** - * @see TemplateOptions#authorizePublicKey(String) - */ - @Override - public VCloudTemplateOptions authorizePublicKey(String publicKey) { - return VCloudTemplateOptions.class.cast(super.authorizePublicKey(publicKey)); - } - - /** - * @see TemplateOptions#installPrivateKey(String) - */ - @Override - public VCloudTemplateOptions installPrivateKey(String privateKey) { - return VCloudTemplateOptions.class.cast(super.installPrivateKey(privateKey)); - } - - /** - * {@inheritDoc} - */ - @Override - public VCloudTemplateOptions userMetadata(Map userMetadata) { - return VCloudTemplateOptions.class.cast(super.userMetadata(userMetadata)); - } - - /** - * {@inheritDoc} - */ - @Override - public VCloudTemplateOptions userMetadata(String key, String value) { - return VCloudTemplateOptions.class.cast(super.userMetadata(key, value)); - } - - /** - * {@inheritDoc} - */ - @Override - public VCloudTemplateOptions nodeNames(Iterable nodeNames) { - return VCloudTemplateOptions.class.cast(super.nodeNames(nodeNames)); - } - - /** - * {@inheritDoc} - */ - @Override - public VCloudTemplateOptions networks(Iterable networks) { - return VCloudTemplateOptions.class.cast(super.networks(networks)); - } - -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/strategy/InstantiateVAppTemplateWithGroupEncodedIntoNameThenCustomizeDeployAndPowerOn.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/strategy/InstantiateVAppTemplateWithGroupEncodedIntoNameThenCustomizeDeployAndPowerOn.java deleted file mode 100644 index 574f3e7060..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/strategy/InstantiateVAppTemplateWithGroupEncodedIntoNameThenCustomizeDeployAndPowerOn.java +++ /dev/null @@ -1,299 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.compute.strategy; - -import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.base.Predicates.not; -import static com.google.common.collect.Iterables.find; -import static com.google.common.collect.Iterables.get; -import static org.jclouds.compute.util.ComputeServiceUtils.getCores; -import static org.jclouds.compute.util.ComputeServiceUtils.metadataAndTagsAsCommaDelimitedValue; -import static org.jclouds.vcloud.compute.util.VCloudComputeUtils.getCredentialsFrom; -import static org.jclouds.vcloud.options.InstantiateVAppTemplateOptions.Builder.addNetworkConfig; - -import java.net.URI; -import java.util.Map; - -import javax.annotation.Resource; -import javax.inject.Inject; -import javax.inject.Named; -import javax.inject.Singleton; - -import org.jclouds.compute.ComputeServiceAdapter.NodeAndInitialCredentials; -import org.jclouds.compute.domain.Template; -import org.jclouds.compute.reference.ComputeServiceConstants; -import org.jclouds.javax.annotation.Nullable; -import org.jclouds.logging.Logger; -import org.jclouds.ovf.Network; -import org.jclouds.predicates.validators.DnsNameValidator; -import org.jclouds.rest.annotations.BuildVersion; -import org.jclouds.vcloud.TaskStillRunningException; -import org.jclouds.vcloud.VCloudApi; -import org.jclouds.vcloud.compute.options.VCloudTemplateOptions; -import org.jclouds.vcloud.domain.GuestCustomizationSection; -import org.jclouds.vcloud.domain.NetworkConnection; -import org.jclouds.vcloud.domain.NetworkConnectionSection; -import org.jclouds.vcloud.domain.NetworkConnectionSection.Builder; -import org.jclouds.vcloud.domain.Task; -import org.jclouds.vcloud.domain.VApp; -import org.jclouds.vcloud.domain.VAppTemplate; -import org.jclouds.vcloud.domain.Vm; -import org.jclouds.vcloud.domain.network.IpAddressAllocationMode; -import org.jclouds.vcloud.domain.network.NetworkConfig; -import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions; - -import com.google.common.annotations.VisibleForTesting; -import com.google.common.base.Joiner; -import com.google.common.base.Predicate; -import com.google.common.cache.LoadingCache; -import com.google.common.collect.ImmutableSet; - -@Singleton -public class InstantiateVAppTemplateWithGroupEncodedIntoNameThenCustomizeDeployAndPowerOn { - @Resource - @Named(ComputeServiceConstants.COMPUTE_LOGGER) - protected Logger logger = Logger.NULL; - - protected final VCloudApi client; - protected final Predicate successTester; - protected final LoadingCache vAppTemplates; - protected final NetworkConfigurationForNetworkAndOptions networkConfigurationForNetworkAndOptions; - protected final String buildVersion; - - - @Inject - protected InstantiateVAppTemplateWithGroupEncodedIntoNameThenCustomizeDeployAndPowerOn(VCloudApi client, - Predicate successTester, LoadingCache vAppTemplates, NetworkConfigurationForNetworkAndOptions networkConfigurationForNetworkAndOptions, - @BuildVersion String buildVersion) { - this.client = client; - this.successTester = successTester; - this.vAppTemplates = vAppTemplates; - this.networkConfigurationForNetworkAndOptions = networkConfigurationForNetworkAndOptions; - this.buildVersion = buildVersion; - } - - /** - * per john ellis at bluelock, vCloud Director 1.5 is more strict than earlier versions. - *

- * It appears to be 15 characters to match Windows' hostname limitation. Must be alphanumeric, at - * least one non-number character and hyphens and underscores are the only non-alpha character - * allowed. - */ - public static enum ComputerNameValidator { - INSTANCE; - - private DnsNameValidator validator; - - ComputerNameValidator() { - this.validator = new DnsNameValidator(3, 15); - } - - public void validate(@Nullable String t) throws IllegalArgumentException { - this.validator.validate(t); - } - - } - - public NodeAndInitialCredentials createNodeWithGroupEncodedIntoName(String group, String name, Template template) { - // no sense waiting until failures occur later - ComputerNameValidator.INSTANCE.validate(name); - VApp vAppResponse = instantiateVAppFromTemplate(name, template); - waitForTask(vAppResponse.getTasks().get(0)); - logger.debug("<< instantiated VApp(%s)", vAppResponse.getName()); - - // vm data is available after instantiate completes - vAppResponse = client.getVAppApi().getVApp(vAppResponse.getHref()); - - // per above check, we know there is only a single VM - Vm vm = get(vAppResponse.getChildren(), 0); - - template.getOptions().userMetadata(ComputeServiceConstants.NODE_GROUP_KEY, group); - VCloudTemplateOptions vOptions = VCloudTemplateOptions.class.cast(template.getOptions()); - - // note we cannot do tasks in parallel or VCD will throw "is busy" errors - - // note we must do this before any other customizations as there is a dependency on - // valid naming conventions before you can perform commands such as updateCPUCount - logger.trace(">> updating customization vm(%s) name->(%s)", vm.getName(), name); - waitForTask(updateVmWithNameAndCustomizationScript(vm, name, vOptions.getCustomizationScript())); - logger.trace("<< updated customization vm(%s)", name); - - ensureVmHasAllocationModeOrPooled(vAppResponse, vOptions.getIpAddressAllocationMode()); - - int cpuCount = (int) getCores(template.getHardware()); - logger.trace(">> updating cpuCount(%d) vm(%s)", cpuCount, vm.getName()); - waitForTask(updateCPUCountOfVm(vm, cpuCount)); - logger.trace("<< updated cpuCount vm(%s)", vm.getName()); - int memoryMB = template.getHardware().getRam(); - logger.trace(">> updating memoryMB(%d) vm(%s)", memoryMB, vm.getName()); - waitForTask(updateMemoryMBOfVm(vm, memoryMB)); - logger.trace("<< updated memoryMB vm(%s)", vm.getName()); - logger.trace(">> deploying vApp(%s)", vAppResponse.getName()); - waitForTask(client.getVAppApi().deployVApp(vAppResponse.getHref())); - logger.trace("<< deployed vApp(%s)", vAppResponse.getName()); - - // only after deploy is the password valid - vAppResponse = client.getVAppApi().getVApp(vAppResponse.getHref()); - - logger.trace(">> powering on vApp(%s)", vAppResponse.getName()); - client.getVAppApi().powerOnVApp(vAppResponse.getHref()); - - return new NodeAndInitialCredentials(vAppResponse, vAppResponse.getHref().toASCIIString(), - getCredentialsFrom(vAppResponse)); - - } - - @VisibleForTesting - protected VApp instantiateVAppFromTemplate(String name, Template template) { - VCloudTemplateOptions vOptions = VCloudTemplateOptions.class.cast(template.getOptions()); - - URI templateId = URI.create(template.getImage().getId()); - - VAppTemplate vAppTemplate = vAppTemplates.getUnchecked(templateId); - - if (vAppTemplate.getChildren().size() > 1) - throw new UnsupportedOperationException("we currently do not support multiple vms in a vAppTemplate " - + vAppTemplate); - - if (vAppTemplate.getNetworkSection().getNetworks().size() > 1) - throw new UnsupportedOperationException( - "we currently do not support multiple network connections in a vAppTemplate " + vAppTemplate); - - Network networkToConnect = get(vAppTemplate.getNetworkSection().getNetworks(), 0); - - - NetworkConfig config = networkConfigurationForNetworkAndOptions.apply(networkToConnect, vOptions); - - // note that in VCD 1.5, the network name after instantiation will be the same as the parent - InstantiateVAppTemplateOptions options = addNetworkConfig(config); - - // TODO make disk size specifiable - // disk((long) ((template.getHardware().getVolumes().get(0).getSize()) * - // 1024 * 1024l)); - - - - String description = VCloudTemplateOptions.class.cast(template.getOptions()).getDescription(); - if (description == null) { - Map md = metadataAndTagsAsCommaDelimitedValue(template.getOptions()); - description = Joiner.on('\n').withKeyValueSeparator("=").join(md); - } - - options.description(description); - options.deploy(false); - options.powerOn(false); - - URI VDC = URI.create(template.getLocation().getId()); - - logger.debug(">> instantiating vApp vDC(%s) template(%s) name(%s) options(%s) ", VDC, templateId, name, options); - - VApp vAppResponse = client.getVAppTemplateApi().createVAppInVDCByInstantiatingTemplate(name, VDC, templateId, - options); - return vAppResponse; - } - - // TODO: filtering on "none" is a hack until we can filter on - // vAppTemplate.getNetworkConfigSection().getNetworkConfigs() where - // name = getChildren().NetworkConnectionSection.connection where ipallocationmode == none - static Predicate networkWithNoIpAllocation = new Predicate() { - - @Override - public boolean apply(Network input) { - return "none".equals(input.getName()); - } - - }; - - public void waitForTask(Task task) { - if (!successTester.apply(task.getHref())) { - throw new TaskStillRunningException(task); - } - } - /** - * Naming constraints modifying a VM on a VApp in vCloud Director (at least v1.5) can be more - * strict than those in a vAppTemplate. For example, while it is possible to instantiate a - * vAppTemplate with a VM named (incorrectly) {@code Ubuntu_10.04}, you must change the name to a - * valid (alphanumeric underscore) name before you can update it. - */ - public Task updateVmWithNameAndCustomizationScript(Vm vm, String name, @Nullable String customizationScript) { - GuestCustomizationSection guestConfiguration = vm.getGuestCustomizationSection(); - guestConfiguration.setComputerName(name); - if (customizationScript != null) { - // In version 1.0.0, the api returns a script that loses newlines, so we cannot append to a - // customization script. - // TODO: parameterize whether to overwrite or append existing customization - if (!buildVersion.startsWith("1.0.0") && !"".endsWith(buildVersion) - && guestConfiguration.getCustomizationScript() != null) - customizationScript = guestConfiguration.getCustomizationScript() + "\n" + customizationScript; - - guestConfiguration.setCustomizationScript(customizationScript); - } - return client.getVmApi().updateGuestCustomizationOfVm(guestConfiguration, vm.getHref()); - } - - public void ensureVmHasAllocationModeOrPooled(VApp vApp, @Nullable IpAddressAllocationMode ipAllocationMode) { - Network networkToConnect = find(vApp.getNetworkSection().getNetworks(), not(networkWithNoIpAllocation)); - - Vm vm = get(vApp.getChildren(), 0); - - NetworkConnectionSection net = vm.getNetworkConnectionSection(); - checkArgument(!net.getConnections().isEmpty(), "no connections on vm %s", vm); - - NetworkConnection toConnect = findWithPoolAllocationOrFirst(net); - - if (ipAllocationMode == null) - ipAllocationMode = toConnect.getIpAddressAllocationMode(); - - // make sure that we are in fact allocating ips - if (ipAllocationMode == IpAddressAllocationMode.NONE) - ipAllocationMode = IpAddressAllocationMode.POOL; - - if (toConnect.isConnected() && toConnect.getIpAddressAllocationMode() == ipAllocationMode - && toConnect.getNetwork().equals(networkToConnect.getName())) { - // then we don't need to change the network settings, and can save a call - } else { - Builder builder = net.toBuilder(); - builder.connections(ImmutableSet.of(toConnect.toBuilder().network(networkToConnect.getName()).connected(true) - .ipAddressAllocationMode(ipAllocationMode).build())); - logger.trace(">> updating networkConnection vm(%s)", vm.getName()); - - waitForTask(client.getVmApi().updateNetworkConnectionOfVm(builder.build(), vm.getHref())); - logger.trace("<< updated networkConnection vm(%s)", vm.getName()); - - } - - } - - private NetworkConnection findWithPoolAllocationOrFirst(NetworkConnectionSection net) { - return find(net.getConnections(), new Predicate() { - - @Override - public boolean apply(NetworkConnection input) { - return input.getIpAddressAllocationMode() == IpAddressAllocationMode.POOL; - } - - }, get(net.getConnections(), 0)); - } - - public Task updateCPUCountOfVm(Vm vm, int cpuCount) { - return client.getVmApi().updateCPUCountOfVm(cpuCount, vm.getHref()); - } - - public Task updateMemoryMBOfVm(Vm vm, int memoryInMB) { - return client.getVmApi().updateMemoryMBOfVm(memoryInMB, vm.getHref()); - } -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/strategy/NetworkConfigurationForNetworkAndOptions.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/strategy/NetworkConfigurationForNetworkAndOptions.java deleted file mode 100644 index 28c8a9b2a6..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/strategy/NetworkConfigurationForNetworkAndOptions.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.compute.strategy; - -import java.net.URI; - -import javax.inject.Inject; - -import org.jclouds.ovf.Network; -import org.jclouds.vcloud.compute.options.VCloudTemplateOptions; -import org.jclouds.vcloud.domain.network.FenceMode; -import org.jclouds.vcloud.domain.network.NetworkConfig; - -import com.google.common.annotations.Beta; -import com.google.common.base.Supplier; - -@Beta -public class NetworkConfigurationForNetworkAndOptions { - protected final Supplier defaultNetworkConfig; - protected final FenceMode defaultFenceMode; - - @Inject - protected NetworkConfigurationForNetworkAndOptions(Supplier defaultNetworkConfig, - FenceMode defaultFenceMode) { - this.defaultNetworkConfig = defaultNetworkConfig; - this.defaultFenceMode = defaultFenceMode; - } - - /** - * - * returns a {@link NetworkConfig} used to instantiate a vAppTemplate to - * either the default parent (org) network, or one specified by options. - * - * @param networkToConnect - * network defined in the VAppTemplate you wish to connect to - * @param vOptions - * options to override defaults with - * @return - */ - public NetworkConfig apply(Network networkToConnect, VCloudTemplateOptions vOptions) { - NetworkConfig config; - URI userDefinedParentNetwork = vOptions.getParentNetwork(); - FenceMode fenceMode = vOptions.getFenceMode() != null ? vOptions.getFenceMode() : defaultFenceMode; - if (userDefinedParentNetwork != null) { - config = NetworkConfig.builder().networkName("jclouds").fenceMode(fenceMode) - .parentNetwork(userDefinedParentNetwork).build(); - } else { - config = defaultNetworkConfig.get().toBuilder().fenceMode(fenceMode).build(); - } - - // if we only have a disconnected network, we are adding a new section - // for the upstream - if (InstantiateVAppTemplateWithGroupEncodedIntoNameThenCustomizeDeployAndPowerOn.networkWithNoIpAllocation - .apply(networkToConnect)) { - // TODO: remove the disconnected entry - } else { - config = config.toBuilder().networkName(networkToConnect.getName()).build(); - } - return config; - } - -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/strategy/VCloudComputeServiceAdapter.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/strategy/VCloudComputeServiceAdapter.java deleted file mode 100644 index 4d300c88aa..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/strategy/VCloudComputeServiceAdapter.java +++ /dev/null @@ -1,262 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.compute.strategy; - -import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.collect.Iterables.contains; -import static com.google.common.collect.Iterables.filter; - -import java.net.URI; -import java.util.Map; -import java.util.Set; - -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.Template; -import org.jclouds.compute.reference.ComputeServiceConstants; -import org.jclouds.domain.Location; -import org.jclouds.logging.Logger; -import org.jclouds.ovf.Envelope; -import org.jclouds.util.Throwables2; -import org.jclouds.vcloud.TaskInErrorStateException; -import org.jclouds.vcloud.TaskStillRunningException; -import org.jclouds.vcloud.VCloudApi; -import org.jclouds.vcloud.VCloudMediaType; -import org.jclouds.vcloud.domain.Org; -import org.jclouds.vcloud.domain.ReferenceType; -import org.jclouds.vcloud.domain.Status; -import org.jclouds.vcloud.domain.Task; -import org.jclouds.vcloud.domain.VApp; -import org.jclouds.vcloud.domain.VAppTemplate; -import org.jclouds.vcloud.suppliers.VAppTemplatesSupplier; - -import com.google.common.annotations.VisibleForTesting; -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; - -/** - * defines the connection between the {@link org.jclouds.vcloud.VCloudApi} implementation and the jclouds - * {@link ComputeService} - */ -@Singleton -public class VCloudComputeServiceAdapter implements ComputeServiceAdapter { - - @Resource - @Named(ComputeServiceConstants.COMPUTE_LOGGER) - protected Logger logger = Logger.NULL; - - protected final VCloudApi client; - protected final Predicate successTester; - protected final InstantiateVAppTemplateWithGroupEncodedIntoNameThenCustomizeDeployAndPowerOn booter; - protected final Supplier> nameToOrg; - protected final Supplier> templates; - protected final Function templateToEnvelope; - - @Inject - protected VCloudComputeServiceAdapter(VCloudApi client, Predicate successTester, - InstantiateVAppTemplateWithGroupEncodedIntoNameThenCustomizeDeployAndPowerOn booter, - Supplier> nameToOrg, VAppTemplatesSupplier templates, - Function templateToEnvelope) { - this.client = checkNotNull(client, "client"); - this.successTester = checkNotNull(successTester, "successTester"); - this.booter = checkNotNull(booter, "booter"); - this.nameToOrg = checkNotNull(nameToOrg, "nameToOrg"); - this.templates = checkNotNull(templates, "templates"); - this.templateToEnvelope = checkNotNull(templateToEnvelope, "templateToEnvelope"); - } - - @Override - public NodeAndInitialCredentials createNodeWithGroupEncodedIntoName(String group, String name, - Template template) { - return booter.createNodeWithGroupEncodedIntoName(group, name, template); - } - - @Override - public Iterable listHardwareProfiles() { - return supportedTemplates(); - } - - private Iterable supportedTemplates() { - return filter(templates.get(), new Predicate() { - - @Override - public boolean apply(VAppTemplate from) { - try { - templateToEnvelope.apply(from); - } catch (IllegalArgumentException e) { - logger.warn("Unsupported: " + e.getMessage()); - return false; - } catch (RuntimeException e) { - IllegalArgumentException e2 = Throwables2.getFirstThrowableOfType(e, IllegalArgumentException.class); - if (e2 != null) { - logger.warn("Unsupported: " + e2.getMessage()); - return false; - } else { - throw e; - } - } - return true; - } - - }); - } - - @Override - public Iterable listImages() { - return supportedTemplates(); - } - - @Override - public Iterable listNodes() { - // TODO: parallel or cache - Builder nodes = ImmutableSet.builder(); - for (Org org : nameToOrg.get().values()) { - for (ReferenceType vdc : org.getVDCs().values()) { - for (ReferenceType resource : client.getVDCApi().getVDC(vdc.getHref()).getResourceEntities().values()) { - if (resource.getType().equals(VCloudMediaType.VAPP_XML)) { - addVAppToSetRetryingIfNotYetPresent(nodes, vdc, resource); - } - } - } - } - return nodes.build(); - } - - @Override - public Iterable listNodesByIds(final Iterable ids) { - return filter(listNodes(), new Predicate() { - - @Override - public boolean apply(VApp vm) { - return contains(ids, vm.getHref().toASCIIString()); - } - }); - } - - @VisibleForTesting - void addVAppToSetRetryingIfNotYetPresent(Builder nodes, ReferenceType vdc, ReferenceType resource) { - VApp node = null; - int i = 0; - while (node == null && i++ < 3) { - try { - node = client.getVAppApi().getVApp(resource.getHref()); - nodes.add(node); - } catch (NullPointerException e) { - logger.warn("vApp %s not yet present in vdc %s", resource.getName(), vdc.getName()); - } - } - } - - @Override - public Iterable listLocations() { - // Not using the adapter to determine locations - return ImmutableSet.of(); - } - - @Override - public VApp getNode(String in) { - URI id = URI.create(in); - return client.getVAppApi().getVApp(id); - } - - @Override - public VAppTemplate getImage(String in) { - URI id = URI.create(in); - return client.getVAppTemplateApi().getVAppTemplate(id); - } - - @Override - public void destroyNode(String id) { - URI vappId = URI.create(checkNotNull(id, "node.id")); - VApp vApp = cancelAnyRunningTasks(vappId); - if (vApp.getStatus() != Status.OFF) { - logger.debug(">> powering off VApp vApp(%s), current status: %s", vApp.getName(), vApp.getStatus()); - try { - waitForTask(client.getVAppApi().powerOffVApp(vApp.getHref())); - vApp = client.getVAppApi().getVApp(vApp.getHref()); - logger.debug("<< %s vApp(%s)", vApp.getStatus(), vApp.getName()); - } catch (IllegalStateException e) { - logger.warn(e, "<< %s vApp(%s)", vApp.getStatus(), vApp.getName()); - } - logger.debug(">> undeploying vApp(%s), current status: %s", vApp.getName(), vApp.getStatus()); - try { - waitForTask(client.getVAppApi().undeployVApp(vApp.getHref())); - vApp = client.getVAppApi().getVApp(vApp.getHref()); - logger.debug("<< %s vApp(%s)", vApp.getStatus(), vApp.getName()); - } catch (IllegalStateException e) { - logger.warn(e, "<< %s vApp(%s)", vApp.getStatus(), vApp.getName()); - } - } - logger.debug(">> deleting vApp(%s)", vApp.getHref()); - waitForTask(client.getVAppApi().deleteVApp(vApp.getHref())); - logger.debug("<< deleted vApp(%s)", vApp.getHref()); - } - - VApp waitForPendingTasksToComplete(URI vappId) { - VApp vApp = client.getVAppApi().getVApp(vappId); - if (vApp.getTasks().isEmpty()) - return vApp; - for (Task task : vApp.getTasks()) - waitForTask(task); - return client.getVAppApi().getVApp(vappId); - } - - VApp cancelAnyRunningTasks(URI vappId) { - VApp vApp = client.getVAppApi().getVApp(vappId); - if (vApp.getTasks().isEmpty()) - return vApp; - for (Task task : vApp.getTasks()) { - try { - client.getTaskApi().cancelTask(task.getHref()); - waitForTask(task); - } catch (TaskInErrorStateException e) { - } - } - return client.getVAppApi().getVApp(vappId); - - } - - public void waitForTask(Task task) { - if (!successTester.apply(task.getHref())) - throw new TaskStillRunningException(task); - } - - @Override - public void rebootNode(String in) { - URI id = URI.create(checkNotNull(in, "node.id")); - waitForTask(client.getVAppApi().resetVApp(id)); - } - - @Override - public void resumeNode(String in) { - URI id = URI.create(checkNotNull(in, "node.id")); - waitForTask(client.getVAppApi().powerOnVApp(id)); - } - - @Override - public void suspendNode(String in) { - URI id = URI.create(checkNotNull(in, "node.id")); - waitForTask(client.getVAppApi().powerOffVApp(id)); - } -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/util/VCloudComputeUtils.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/util/VCloudComputeUtils.java deleted file mode 100644 index 7d2d80ff33..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/util/VCloudComputeUtils.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.compute.util; - -import static com.google.common.collect.Iterables.filter; - -import java.util.Set; - -import org.jclouds.cim.CIMPredicates; -import org.jclouds.cim.ResourceAllocationSettingData; -import org.jclouds.cim.ResourceAllocationSettingData.ResourceType; -import org.jclouds.compute.domain.CIMOperatingSystem; -import org.jclouds.compute.domain.OperatingSystem; -import org.jclouds.domain.LoginCredentials; -import org.jclouds.vcloud.domain.NetworkConnection; -import org.jclouds.vcloud.domain.VApp; -import org.jclouds.vcloud.domain.VAppTemplate; -import org.jclouds.vcloud.domain.Vm; -import org.jclouds.vcloud.domain.ovf.VCloudNetworkAdapter; - -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.ImmutableSet.Builder; -import com.google.common.collect.Iterables; - -public class VCloudComputeUtils { - public static OperatingSystem toComputeOs(VApp vApp, OperatingSystem defaultOs) { - CIMOperatingSystem cimOs = toComputeOs(vApp); - return cimOs != null ? cimOs : defaultOs; - } - - public static CIMOperatingSystem toComputeOs(VApp vApp) { - // TODO we need to change the design so that it doesn't assume single-vms - return !vApp.getChildren().isEmpty() ? toComputeOs(Iterables.get(vApp.getChildren(), 0)) : null; - } - - public static CIMOperatingSystem toComputeOs(Vm vm) { - return CIMOperatingSystem.toComputeOs(vm.getOperatingSystemSection()); - } - - public static String getVirtualSystemIdentifierOfFirstVMIn(VApp vApp) { - return !vApp.getChildren().isEmpty() ? getVirtualSystemIdentifierOf(Iterables.get(vApp.getChildren(), 0)) : null; - } - - public static String getVirtualSystemIdentifierOf(Vm vm) { - if (vm.getVirtualHardwareSection() != null && vm.getVirtualHardwareSection().getSystem() != null) - return vm.getVirtualHardwareSection().getSystem().getVirtualSystemIdentifier(); - return null; - } - - public static LoginCredentials getCredentialsFrom(VApp vApp) { - return !vApp.getChildren().isEmpty() ? getCredentialsFrom(Iterables.get(vApp.getChildren(), 0)) : null; - } - - public static LoginCredentials getCredentialsFrom(VAppTemplate vApp) { - return !vApp.getChildren().isEmpty() ? getCredentialsFrom(Iterables.get(vApp.getChildren(), 0)) : null; - } - - public static LoginCredentials getCredentialsFrom(Vm vm) { - LoginCredentials.Builder builder = LoginCredentials.builder(); - if (vm.getGuestCustomizationSection() != null) - builder.password(vm.getGuestCustomizationSection().getAdminPassword()); - return builder.build(); - } - - public static Set getIpsFromVApp(VApp vApp) { - // TODO make this work with composite vApps - if (vApp.getChildren().isEmpty()) - return ImmutableSet.of(); - Builder ips = ImmutableSet.builder(); - Vm vm = Iterables.get(vApp.getChildren(), 0); - // TODO: figure out how to differentiate public from private ip addresses - // assumption is that we'll do this from the network object, which may - // have - // enough data to tell whether or not it is a public network without - // string - // parsing. At worst, we could have properties set per cloud provider to - // declare the networks which are public, then check against these in - // networkconnection.getNetwork - if (vm.getNetworkConnectionSection() != null) { - for (NetworkConnection connection : vm.getNetworkConnectionSection().getConnections()) { - if (connection.getIpAddress() != null) - ips.add(connection.getIpAddress()); - if (connection.getExternalIpAddress() != null) - ips.add(connection.getExternalIpAddress()); - } - } else { - for (ResourceAllocationSettingData net : filter(vm.getVirtualHardwareSection().getItems(), - CIMPredicates.resourceTypeIn(ResourceType.ETHERNET_ADAPTER))) { - if (net instanceof VCloudNetworkAdapter) { - VCloudNetworkAdapter vNet = VCloudNetworkAdapter.class.cast(net); - if (vNet.getIpAddress() != null) - ips.add(vNet.getIpAddress()); - } - } - } - return ips.build(); - } -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/config/DefaultCatalogForOrg.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/config/DefaultCatalogForOrg.java deleted file mode 100644 index eb700f35b8..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/config/DefaultCatalogForOrg.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.config; - -import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.base.Preconditions.checkState; -import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_DEFAULT_CATALOG; - -import java.util.Map; - -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jclouds.config.ValueOfConfigurationKeyOrNull; -import org.jclouds.vcloud.domain.Org; -import org.jclouds.vcloud.domain.ReferenceType; -import org.jclouds.vcloud.endpoints.Catalog; -import org.jclouds.vcloud.suppliers.OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefault; - -import com.google.common.base.Function; -import com.google.common.base.Predicate; -import com.google.common.base.Supplier; - -@Singleton -public class DefaultCatalogForOrg implements Function { - private final OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefault selector; - private final Supplier> nameToOrg; - - @Inject - public DefaultCatalogForOrg(ValueOfConfigurationKeyOrNull valueOfConfigurationKeyOrNull, - @Catalog Predicate defaultSelector, Supplier> nameToOrg) { - this.selector = new OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefault(checkNotNull( - valueOfConfigurationKeyOrNull, "valueOfConfigurationKeyOrNull"), PROPERTY_VCLOUD_DEFAULT_CATALOG, - checkNotNull(defaultSelector, "defaultSelector")); - this.nameToOrg = checkNotNull(nameToOrg, "nameToOrg"); - } - - @Override - public ReferenceType apply(ReferenceType defaultOrg) { - Org org = nameToOrg.get().get(defaultOrg.getName()); - checkState(org != null, "could not retrieve Org at %s", defaultOrg); - return selector.apply(org.getCatalogs().values()); - } - -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/config/DefaultNetworkForVDC.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/config/DefaultNetworkForVDC.java deleted file mode 100644 index e336b95e21..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/config/DefaultNetworkForVDC.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.config; - -import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.base.Preconditions.checkState; -import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_DEFAULT_NETWORK; - -import java.net.URI; -import java.util.Map; - -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jclouds.config.ValueOfConfigurationKeyOrNull; -import org.jclouds.vcloud.domain.ReferenceType; -import org.jclouds.vcloud.domain.VDC; -import org.jclouds.vcloud.endpoints.Network; -import org.jclouds.vcloud.suppliers.OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefault; - -import com.google.common.base.Function; -import com.google.common.base.Predicate; -import com.google.common.base.Supplier; - -@Singleton -public class DefaultNetworkForVDC implements Function { - - private final OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefault selector; - private final Supplier> uriToVDC; - - @Inject - public DefaultNetworkForVDC(ValueOfConfigurationKeyOrNull valueOfConfigurationKeyOrNull, - @Network Predicate defaultSelector, Supplier> uriToVDC) { - this.selector = new OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefault(checkNotNull( - valueOfConfigurationKeyOrNull, "valueOfConfigurationKeyOrNull"), PROPERTY_VCLOUD_DEFAULT_NETWORK, - checkNotNull(defaultSelector, "defaultSelector")); - this.uriToVDC = checkNotNull(uriToVDC, "uriToVDC"); - } - - @Override - public ReferenceType apply(ReferenceType defaultVDC) { - org.jclouds.vcloud.domain.VDC vDC = uriToVDC.get().get(defaultVDC.getHref()); - checkState(vDC != null, "could not retrieve VDC at %s", defaultVDC); - return selector.apply(vDC.getAvailableNetworks().values()); - } - -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/config/DefaultOrgForUser.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/config/DefaultOrgForUser.java deleted file mode 100644 index 8ed2ebad93..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/config/DefaultOrgForUser.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.config; - -import static com.google.common.base.Preconditions.checkNotNull; -import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_DEFAULT_ORG; - -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jclouds.config.ValueOfConfigurationKeyOrNull; -import org.jclouds.vcloud.domain.ReferenceType; -import org.jclouds.vcloud.domain.VCloudSession; -import org.jclouds.vcloud.endpoints.Org; -import org.jclouds.vcloud.suppliers.OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefault; - -import com.google.common.base.Predicate; -import com.google.common.base.Supplier; - -@Singleton -public class DefaultOrgForUser implements Supplier { - - private final OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefault selector; - private final Supplier session; - - @Inject - public DefaultOrgForUser(ValueOfConfigurationKeyOrNull valueOfConfigurationKeyOrNull, - @Org Predicate defaultSelector, Supplier session) { - this.selector = new OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefault(checkNotNull( - valueOfConfigurationKeyOrNull, "valueOfConfigurationKeyOrNull"), PROPERTY_VCLOUD_DEFAULT_ORG, checkNotNull( - defaultSelector, "defaultSelector")); - this.session = checkNotNull(session, "session"); - } - - @Override - public ReferenceType get() { - return selector.apply(session.get().getOrgs().values()); - } - -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/config/DefaultTasksListForOrg.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/config/DefaultTasksListForOrg.java deleted file mode 100644 index c670161c3f..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/config/DefaultTasksListForOrg.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.config; - -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 javax.inject.Singleton; - -import org.jclouds.vcloud.domain.Org; -import org.jclouds.vcloud.domain.ReferenceType; - -import com.google.common.base.Function; -import com.google.common.base.Supplier; - -@Singleton -public class DefaultTasksListForOrg implements Function { - private final Supplier> nameToOrg; - - @Inject - public DefaultTasksListForOrg(Supplier> nameToOrg) { - this.nameToOrg = checkNotNull(nameToOrg, "nameToOrg"); - } - - @Override - public ReferenceType apply(ReferenceType defaultOrg) { - org.jclouds.vcloud.domain.Org org = nameToOrg.get().get(defaultOrg.getName()); - checkState(org != null, "could not retrieve Org at %s", defaultOrg); - return org.getTasksList(); - } - -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/config/DefaultVCloudReferencesModule.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/config/DefaultVCloudReferencesModule.java deleted file mode 100644 index 5a0ba9dc95..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/config/DefaultVCloudReferencesModule.java +++ /dev/null @@ -1,161 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.config; - -import java.net.URI; -import java.util.Map; - -import javax.annotation.Resource; -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jclouds.logging.Logger; -import org.jclouds.vcloud.domain.Catalog; -import org.jclouds.vcloud.domain.ReferenceType; -import org.jclouds.vcloud.endpoints.Org; - -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.ImmutableMap; -import com.google.common.collect.ImmutableMap.Builder; -import com.google.inject.AbstractModule; -import com.google.inject.Injector; -import com.google.inject.Provides; -import com.google.inject.TypeLiteral; - -public class DefaultVCloudReferencesModule extends AbstractModule { - - @Override - protected void configure() { - bind(new TypeLiteral>() { - }).annotatedWith(Org.class).to(DefaultOrgForUser.class); - } - - @Provides - @Singleton - @org.jclouds.vcloud.endpoints.Org - protected Predicate provideDefaultOrgSelector(Injector i) { - return Predicates.alwaysTrue(); - } - - @Provides - @org.jclouds.vcloud.endpoints.TasksList - @Singleton - protected Supplier provideDefaultTasksList(DefaultTasksListForOrg defaultTasksListURIForOrg, - @org.jclouds.vcloud.endpoints.Org Supplier defaultOrg) { - return Suppliers.compose(defaultTasksListURIForOrg, defaultOrg); - } - - @Provides - @org.jclouds.vcloud.endpoints.Catalog - @Singleton - protected Supplier provideDefaultCatalog(DefaultCatalogForOrg defaultCatalogURIForOrg, - @org.jclouds.vcloud.endpoints.Org Supplier defaultOrg) { - return Suppliers.compose(defaultCatalogURIForOrg, defaultOrg); - } - - @Provides - @Singleton - @org.jclouds.vcloud.endpoints.Catalog - protected Predicate provideDefaultCatalogSelector(Injector i) { - return i.getInstance(WriteableCatalog.class); - } - - @Provides - @Singleton - protected Supplier> provideCatalogsById( - Supplier>> supplier) { - return Suppliers - .compose( - new Function>, Map>() { - - @Override - public Map apply(Map> arg0) { - Builder builder = ImmutableMap.builder(); - for (Map v1 : arg0.values()) { - for (Catalog v2 : v1.values()) { - builder.put(v2.getHref(), v2); - } - } - return builder.build(); - } - - }, supplier); - } - - @Singleton - public static class WriteableCatalog implements Predicate { - - @Resource - protected Logger logger = Logger.NULL; - - private final Supplier> catalogsByIdSupplier; - - @Inject - public WriteableCatalog(Supplier> catalogsByIdSupplier) { - this.catalogsByIdSupplier = catalogsByIdSupplier; - } - - @Override - public boolean apply(ReferenceType arg0) { - // TODO: this is inefficient, calculating the index each time, but - // shouldn't be added to constructor as the supplier is an expensive - // call - Map index = catalogsByIdSupplier.get(); - Catalog catalog = index.get(arg0.getHref()); - if (catalog == null) { - if (logger.isTraceEnabled()) - logger.trace("didn't find catalog %s", arg0); - return false; - } else - return !catalog.isReadOnly(); - } - } - - @Provides - @org.jclouds.vcloud.endpoints.VDC - @Singleton - protected Supplier provideDefaultVDC(DefaultVDCForOrg defaultVDCURIForOrg, - @org.jclouds.vcloud.endpoints.Org Supplier defaultOrg) { - return Suppliers.compose(defaultVDCURIForOrg, defaultOrg); - } - - @Provides - @Singleton - @org.jclouds.vcloud.endpoints.VDC - protected Predicate provideDefaultVDCSelector(Injector i) { - return Predicates.alwaysTrue(); - } - - @Provides - @org.jclouds.vcloud.endpoints.Network - @Singleton - protected Supplier provideDefaultNetwork(DefaultNetworkForVDC defaultNetworkURIForVDC, - @org.jclouds.vcloud.endpoints.VDC Supplier defaultVDC) { - return Suppliers.compose(defaultNetworkURIForVDC, defaultVDC); - } - - @Provides - @Singleton - @org.jclouds.vcloud.endpoints.Network - protected Predicate provideDefaultNetworkSelector(Injector i) { - return Predicates.alwaysTrue(); - } -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/config/DefaultVDCForOrg.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/config/DefaultVDCForOrg.java deleted file mode 100644 index 4eefd30dd0..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/config/DefaultVDCForOrg.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.config; - -import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.base.Preconditions.checkState; -import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_DEFAULT_VDC; - -import java.util.Map; - -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jclouds.config.ValueOfConfigurationKeyOrNull; -import org.jclouds.vcloud.domain.Org; -import org.jclouds.vcloud.domain.ReferenceType; -import org.jclouds.vcloud.endpoints.VDC; -import org.jclouds.vcloud.suppliers.OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefault; - -import com.google.common.base.Function; -import com.google.common.base.Predicate; -import com.google.common.base.Supplier; - -@Singleton -public class DefaultVDCForOrg implements Function { - private final OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefault selector; - private final Supplier> nameToOrg; - - @Inject - public DefaultVDCForOrg(ValueOfConfigurationKeyOrNull valueOfConfigurationKeyOrNull, - @VDC Predicate defaultSelector, Supplier> nameToOrg) { - this.selector = new OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefault(checkNotNull( - valueOfConfigurationKeyOrNull, "valueOfConfigurationKeyOrNull"), PROPERTY_VCLOUD_DEFAULT_VDC, - checkNotNull(defaultSelector, "defaultSelector")); - this.nameToOrg = checkNotNull(nameToOrg, "nameToOrg"); - } - - @Override - public ReferenceType apply(ReferenceType defaultOrg) { - Org org = nameToOrg.get().get(defaultOrg.getName()); - checkState(org != null, "could not retrieve Org at %s", defaultOrg); - return selector.apply(org.getVDCs().values()); - } - -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/config/VCloudHttpApiModule.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/config/VCloudHttpApiModule.java deleted file mode 100644 index 50d21cac1f..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/config/VCloudHttpApiModule.java +++ /dev/null @@ -1,536 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.config; - -import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.base.Preconditions.checkState; -import static com.google.common.base.Predicates.notNull; -import static com.google.common.collect.Iterables.concat; -import static com.google.common.collect.Iterables.filter; -import static com.google.common.collect.Iterables.getLast; -import static com.google.common.collect.Iterables.transform; -import static com.google.common.collect.Maps.transformValues; -import static com.google.common.collect.Maps.uniqueIndex; -import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL; -import static org.jclouds.rest.config.BinderUtils.bindHttpApi; -import static org.jclouds.util.Predicates2.retry; -import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_DEFAULT_FENCEMODE; -import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_TIMEOUT_TASK_COMPLETED; - -import java.net.URI; -import java.util.Map; -import java.util.Map.Entry; -import java.util.SortedMap; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicReference; - -import javax.inject.Inject; -import javax.inject.Named; -import javax.inject.Singleton; - -import org.jclouds.cim.xml.ResourceAllocationSettingDataHandler; -import org.jclouds.domain.Location; -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.location.suppliers.ImplicitLocationSupplier; -import org.jclouds.location.suppliers.LocationsSupplier; -import org.jclouds.ovf.Envelope; -import org.jclouds.rest.AuthorizationException; -import org.jclouds.rest.ConfiguresHttpApi; -import org.jclouds.rest.annotations.ApiVersion; -import org.jclouds.rest.config.HttpApiModule; -import org.jclouds.rest.suppliers.MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier; -import org.jclouds.vcloud.VCloudApi; -import org.jclouds.vcloud.VCloudToken; -import org.jclouds.vcloud.VCloudVersionsApi; -import org.jclouds.vcloud.compute.functions.FindLocationForResource; -import org.jclouds.vcloud.compute.functions.ValidateVAppTemplateAndReturnEnvelopeOrThrowIllegalArgumentException; -import org.jclouds.vcloud.domain.Catalog; -import org.jclouds.vcloud.domain.CatalogItem; -import org.jclouds.vcloud.domain.Org; -import org.jclouds.vcloud.domain.ReferenceType; -import org.jclouds.vcloud.domain.VAppTemplate; -import org.jclouds.vcloud.domain.VCloudSession; -import org.jclouds.vcloud.domain.VDC; -import org.jclouds.vcloud.domain.network.FenceMode; -import org.jclouds.vcloud.endpoints.Network; -import org.jclouds.vcloud.endpoints.OrgList; -import org.jclouds.vcloud.functions.CatalogItemsInCatalog; -import org.jclouds.vcloud.functions.CatalogItemsInOrg; -import org.jclouds.vcloud.functions.CatalogsInOrg; -import org.jclouds.vcloud.functions.DefaultNetworkNameInTemplate; -import org.jclouds.vcloud.functions.OrgsForLocations; -import org.jclouds.vcloud.functions.OrgsForNames; -import org.jclouds.vcloud.functions.VAppTemplatesForCatalogItems; -import org.jclouds.vcloud.functions.VDCsInOrg; -import org.jclouds.vcloud.handlers.ParseVCloudErrorFromHttpResponse; -import org.jclouds.vcloud.internal.VCloudLoginApi; -import org.jclouds.vcloud.loaders.OVFLoader; -import org.jclouds.vcloud.loaders.VAppTemplateLoader; -import org.jclouds.vcloud.location.DefaultVDC; -import org.jclouds.vcloud.location.OrgAndVDCToLocationSupplier; -import org.jclouds.vcloud.predicates.TaskSuccess; -import org.jclouds.vcloud.xml.ovf.VCloudResourceAllocationSettingDataHandler; - -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.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.ImmutableMap.Builder; -import com.google.common.collect.Lists; -import com.google.inject.Injector; -import com.google.inject.Provides; -import com.google.inject.Scopes; -import com.google.inject.TypeLiteral; - -/** - * Configures the VCloud authentication service connection, including logging and http transport. - */ -@ConfiguresHttpApi -public class VCloudHttpApiModule extends HttpApiModule { - - - @Provides - @Singleton - protected Supplier provideVCloudTokenCache(@Named(PROPERTY_SESSION_INTERVAL) long seconds, - AtomicReference authException, final VCloudLoginApi login) { - return MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier.create(authException, - new Supplier() { - - @Override - public VCloudSession get() { - return login.login(); - } - - @Override - public String toString() { - return Objects.toStringHelper(login).add("method", "login").toString(); - } - }, seconds, TimeUnit.SECONDS); - } - - @Override - protected void configure() { - super.configure(); - bind(new TypeLiteral, Iterable>>() { - }).to(new TypeLiteral() { - }); - bind(ResourceAllocationSettingDataHandler.class).to(VCloudResourceAllocationSettingDataHandler.class); - installDefaultVCloudEndpointsModule(); - bind(new TypeLiteral>() { - }).to(new TypeLiteral() { - }); - bind(new TypeLiteral>>() { - }).to(new TypeLiteral() { - }); - bind(new TypeLiteral>>() { - }).to(new TypeLiteral() { - }); - bind(new TypeLiteral, Iterable>>() { - }).to(new TypeLiteral() { - }); - bind(new TypeLiteral, Iterable>>() { - }).to(new TypeLiteral() { - }); - bind(new TypeLiteral>>() { - }).to(new TypeLiteral() { - }); - bind(new TypeLiteral>>() { - }).to(new TypeLiteral() { - }); - - bindCacheLoaders(); - - bind(new TypeLiteral>() { - }).annotatedWith(Network.class).to(new TypeLiteral() { - }); - - bind(new TypeLiteral>() { - }).to(new TypeLiteral() { - }); - bindHttpApi(binder(), VCloudApi.class); - bindHttpApi(binder(), VCloudVersionsApi.class); - bindHttpApi(binder(), VCloudLoginApi.class); - } - - protected void bindCacheLoaders() { - bind(new TypeLiteral>() { - }).to(new TypeLiteral() { - }); - - bind(new TypeLiteral>() { - }).to(new TypeLiteral() { - }); - } - - @Provides - @Singleton - @org.jclouds.vcloud.endpoints.VDC - protected Supplier> provideVDCtoORG(Supplier> orgNameToOrgSupplier) { - return Suppliers.compose(new Function, Map>() { - - @Override - public Map apply(Map arg0) { - Builder returnVal = ImmutableMap.builder(); - for (Entry orgr : arg0.entrySet()) { - for (String vdc : orgr.getValue().getVDCs().keySet()) { - returnVal.put(vdc, orgr.getKey()); - } - } - return returnVal.build(); - } - }, orgNameToOrgSupplier); - - } - - @Provides - @Singleton - protected Supplier> provideOrgMapCache(@Named(PROPERTY_SESSION_INTERVAL) long seconds, - AtomicReference authException, OrgMapSupplier supplier) { - return MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier.create(authException, supplier, seconds, - TimeUnit.SECONDS); - } - - @Provides - @Singleton - @OrgList - protected Supplier provideOrgListURI(Supplier sessionSupplier) { - return Suppliers.compose(new Function() { - - @Override - public URI apply(VCloudSession arg0) { - return URI.create(getLast(arg0.getOrgs().values()).getHref().toASCIIString().replaceAll("org/.*", "org")); - } - - @Override - public String toString() { - return "orgListURI()"; - } - - }, sessionSupplier); - } - - @Singleton - public static class OrgMapSupplier implements Supplier> { - protected final Supplier sessionSupplier; - protected final Function, Iterable> organizationsForNames; - - @Inject - protected OrgMapSupplier(Supplier sessionSupplier, - Function, Iterable> organizationsForNames) { - this.sessionSupplier = sessionSupplier; - this.organizationsForNames = organizationsForNames; - } - - @Override - public Map get() { - return uniqueIndex(organizationsForNames.apply(sessionSupplier.get().getOrgs().keySet()), name); - } - } - - protected void installDefaultVCloudEndpointsModule() { - install(new DefaultVCloudReferencesModule()); - } - - @Singleton - public static class OrgCatalogSupplier implements - Supplier>> { - protected final Supplier> orgSupplier; - protected final Function> allCatalogsInOrg; - - @Inject - protected OrgCatalogSupplier(Supplier> orgSupplier, - Function> allCatalogsInOrg) { - this.orgSupplier = orgSupplier; - this.allCatalogsInOrg = allCatalogsInOrg; - } - - @Override - public Map> get() { - return transformValues(transformValues(orgSupplier.get(), allCatalogsInOrg), - new Function, Map>() { - - @Override - public Map apply(Iterable from) { - return ImmutableMap.copyOf(uniqueIndex(from, name)); - } - - }); - } - } - - @VCloudToken - @Provides - @Singleton - Supplier provideVCloudToken(Supplier cache) { - return Suppliers.compose(new Function() { - - @Override - public String apply(VCloudSession input) { - return checkNotNull(input.getVCloudToken(), "No token present in session"); - } - }, cache); - } - - @Provides - @org.jclouds.vcloud.endpoints.Org - @Singleton - protected Supplier> provideVDCtoORG(@Named(PROPERTY_SESSION_INTERVAL) long seconds, - AtomicReference authException, OrgNameToOrgSupplier supplier) { - return MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier.create(authException, supplier, seconds, - TimeUnit.SECONDS); - } - - @Provides - @Singleton - protected Supplier> provideURIToVDC( - @Named(PROPERTY_SESSION_INTERVAL) long seconds, AtomicReference authException, - URItoVDC supplier) { - return MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier.create(authException, supplier, seconds, - TimeUnit.SECONDS); - } - - @Singleton - public static class URItoVDC implements Supplier> { - private final Supplier>> orgVDCMap; - - @Inject - URItoVDC(Supplier>> orgVDCMap) { - this.orgVDCMap = orgVDCMap; - } - - @Override - public Map get() { - return uniqueIndex(concat(transform(orgVDCMap.get().values(), - new Function, Iterable>() { - - @Override - public Iterable apply( - Map from) { - return from.values(); - } - - })), new Function() { - - @Override - public URI apply(VDC from) { - return from.getHref(); - } - - }); - } - - } - - static final Function name = new Function() { - - @Override - public String apply(ReferenceType from) { - return from.getName(); - } - - }; - - @Provides - @Singleton - @org.jclouds.vcloud.endpoints.VCloudLogin - protected Supplier provideAuthenticationURI(final VCloudVersionsApi versionService, - @ApiVersion final String version) { - return new Supplier() { - - @Override - public URI get() { - SortedMap versions = versionService.getSupportedVersions(); - checkState(!versions.isEmpty(), "No versions present"); - checkState(versions.containsKey(version), "version " + version + " not present in: " + versions); - return versions.get(version); - } - - public String toString() { - return "login()"; - } - }; - } - - @Singleton - private static class OrgNameToOrgSupplier implements Supplier> { - private final Supplier sessionSupplier; - - @Inject - OrgNameToOrgSupplier(Supplier sessionSupplier) { - this.sessionSupplier = sessionSupplier; - } - - @Override - public Map get() { - return sessionSupplier.get().getOrgs(); - } - - } - - @Provides - @Singleton - protected Supplier provideOrg(final Supplier> orgSupplier, - @org.jclouds.vcloud.endpoints.Org Supplier defaultOrg) { - return Suppliers.compose(new Function() { - - @Override - public Org apply(ReferenceType input) { - return orgSupplier.get().get(input.getName()); - - } - }, defaultOrg); - } - - @Provides - @Singleton - protected Predicate successTester(Injector injector, - @Named(PROPERTY_VCLOUD_TIMEOUT_TASK_COMPLETED) long completed) { - return retry(injector.getInstance(TaskSuccess.class), completed); - } - - @Provides - @Singleton - protected Supplier>> provideOrgCatalogItemMapSupplierCache( - @Named(PROPERTY_SESSION_INTERVAL) long seconds, AtomicReference authException, - OrgCatalogSupplier supplier) { - return MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier.create(authException, supplier, seconds, - TimeUnit.SECONDS); - } - - @Provides - @Singleton - protected Supplier>> provideOrgVDCSupplierCache( - @Named(PROPERTY_SESSION_INTERVAL) long seconds, AtomicReference authException, - OrgVDCSupplier supplier) { - return MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier.create(authException, supplier, seconds, - TimeUnit.SECONDS); - } - - @Singleton - public static class OrgVDCSupplier implements Supplier>> { - protected final Supplier> orgSupplier; - private final Function> allVDCsInOrg; - - @Inject - protected OrgVDCSupplier(Supplier> orgSupplier, - Function> allVDCsInOrg) { - this.orgSupplier = orgSupplier; - this.allVDCsInOrg = allVDCsInOrg; - } - - @Override - public Map> get() { - return transformValues(transformValues(orgSupplier.get(), allVDCsInOrg), - new Function, Map>() { - - @Override - public Map apply( - Iterable from) { - return uniqueIndex(Lists.newArrayList(from), name); - } - - }); - } - } - - @Singleton - public static class OrgCatalogItemSupplier implements - Supplier>>> { - protected final Supplier>> catalogSupplier; - protected final Function> allCatalogItemsInCatalog; - - @Inject - protected OrgCatalogItemSupplier( - Supplier>> catalogSupplier, - Function> allCatalogItemsInCatalog) { - this.catalogSupplier = catalogSupplier; - this.allCatalogItemsInCatalog = allCatalogItemsInCatalog; - } - - @Override - public Map>> get() { - return transformValues( - catalogSupplier.get(), - new Function, Map>>() { - - @Override - public Map> apply( - Map from) { - return transformValues( - from, - new Function>() { - - @Override - public Map apply(Catalog from) { - return uniqueIndex(filter(allCatalogItemsInCatalog.apply(from), notNull()), name); - } - }); - - } - }); - } - } - - @Provides - @Singleton - protected Supplier>>> provideOrgCatalogItemSupplierCache( - @Named(PROPERTY_SESSION_INTERVAL) long seconds, AtomicReference authException, - OrgCatalogItemSupplier supplier) { - return MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier.create(authException, supplier, seconds, - TimeUnit.SECONDS); - } - - @Provides - @Singleton - protected FenceMode defaultFenceMode(@Named(PROPERTY_VCLOUD_DEFAULT_FENCEMODE) String fenceMode) { - return FenceMode.fromValue(fenceMode); - } - - @Provides - @Singleton - protected LoadingCache vAppTemplates(CacheLoader vAppTemplates) { - return CacheBuilder.newBuilder().build(vAppTemplates); - } - - @Provides - @Singleton - protected LoadingCache envelopes(CacheLoader envelopes) { - return CacheBuilder.newBuilder().build(envelopes); - } - - @Override - protected void bindErrorHandlers() { - bind(HttpErrorHandler.class).annotatedWith(Redirection.class).to(ParseVCloudErrorFromHttpResponse.class); - bind(HttpErrorHandler.class).annotatedWith(ClientError.class).to(ParseVCloudErrorFromHttpResponse.class); - bind(HttpErrorHandler.class).annotatedWith(ServerError.class).to(ParseVCloudErrorFromHttpResponse.class); - } - - @Override - protected void installLocations() { - super.installLocations(); - bind(ImplicitLocationSupplier.class).to(DefaultVDC.class).in(Scopes.SINGLETON); - bind(LocationsSupplier.class).to(OrgAndVDCToLocationSupplier.class).in(Scopes.SINGLETON); - } -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/AllocationModel.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/AllocationModel.java deleted file mode 100644 index aadb475745..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/AllocationModel.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.domain; - -import static com.google.common.base.Preconditions.checkNotNull; - -import com.google.common.base.CaseFormat; - -/** - * The AllocationModel element defines how resources are allocated in a vDC. - */ -public enum AllocationModel { - /** - * Resources are committed to a vDC only when vApps are created in it - */ - ALLOCATION_VAPP, - /** - * Only a percentage of the resources you allocate are committed to the organization vDC. - */ - ALLOCATION_POOL, - /** - * All the resources you allocate are committed as a pool to the organization vDC. vApps in vDCs - * that support this allocation model can specify values for resource and limit. - */ - RESERVATION_POOL, - /** - * The VCloud API returned a model unsupported in the version 1.0 spec. - */ - UNRECOGNIZED; - - public String value() { - switch (this) { - case ALLOCATION_VAPP: - return "AllocationVApp"; - case ALLOCATION_POOL: - return "AllocationPool"; - case RESERVATION_POOL: - return "ReservationPool"; - default: - return "UnrecognizedModel"; - } - } - - @Override - public String toString() { - return value(); - } - - public static AllocationModel fromValue(String model) { - try { - return valueOf(CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, checkNotNull(model, "model"))); - } catch (IllegalArgumentException e) { - return UNRECOGNIZED; - } - } -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/Capacity.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/Capacity.java deleted file mode 100644 index 73dd7610ae..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/Capacity.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.domain; - -/** - * reports storage resource consumption in a vDC. - */ -public class Capacity { - - private final String units; - private final long allocated; - private final long limit; - private final int used; - private final long overhead; - - public Capacity(String units, long allocated, long limit, int used, long overhead) { - this.units = units; - this.limit = limit; - this.allocated = allocated; - this.used = used; - this.overhead = overhead; - } - - public String getUnits() { - return units; - } - - public long getAllocated() { - return allocated; - } - - public long getLimit() { - return limit; - } - - /** - * percentage of the allocation in use. - */ - public int getUsed() { - return used; - } - - /** - * number of Units allocated to vShield Manager virtual machines provisioned from this vDC. - */ - public long getOverhead() { - return overhead; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + (int) (allocated ^ (allocated >>> 32)); - result = prime * result + (int) (limit ^ (limit >>> 32)); - result = prime * result + (int) (overhead ^ (overhead >>> 32)); - result = prime * result + ((units == null) ? 0 : units.hashCode()); - result = prime * result + used; - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - Capacity other = (Capacity) obj; - if (allocated != other.allocated) - return false; - if (limit != other.limit) - return false; - if (overhead != other.overhead) - return false; - if (units == null) { - if (other.units != null) - return false; - } else if (!units.equals(other.units)) - return false; - if (used != other.used) - return false; - return true; - } - - @Override - public String toString() { - return "[allocated=" + allocated + ", limit=" + limit + ", overhead=" + overhead + ", units=" + units + ", used=" - + used + "]"; - } -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/Catalog.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/Catalog.java deleted file mode 100644 index 5e2985104b..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/Catalog.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.domain; - -import java.util.List; -import java.util.Map; - -import org.jclouds.javax.annotation.Nullable; -import org.jclouds.vcloud.domain.internal.CatalogImpl; - -import com.google.inject.ImplementedBy; - -@org.jclouds.vcloud.endpoints.Catalog -@ImplementedBy(CatalogImpl.class) -public interface Catalog extends ReferenceType, Map { - /** - * Reference to the org containing this vDC. - * - * @since vcloud api 1.0 - * @return org, or null if this is a version before 1.0 where the org isn't present - */ - ReferenceType getOrg(); - - /** - * optional description - * - * @since vcloud api 0.8 - */ - @Nullable - String getDescription(); - - /** - * read‐only element, true if the catalog is published - * - * @since vcloud api 1.0 - */ - boolean isPublished(); - - /** - * @return true, if the current user cannot modify the catalog - * @since vcloud api 1.0 - */ - boolean isReadOnly(); - - /** - * read‐only container for Task elements. Each element in the container represents a queued, - * running, or failed task owned by this object. - * - * @since vcloud api 1.0 - */ - List getTasks(); -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/CatalogItem.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/CatalogItem.java deleted file mode 100644 index dc94dbd040..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/CatalogItem.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.domain; - -import java.util.Map; - -import org.jclouds.vcloud.domain.internal.CatalogItemImpl; - -import com.google.inject.ImplementedBy; - -@ImplementedBy(CatalogItemImpl.class) -public interface CatalogItem extends ReferenceType { - - String getDescription(); - - ReferenceType getEntity(); - - Map getProperties(); - -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/GuestCustomizationSection.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/GuestCustomizationSection.java deleted file mode 100644 index b72c8ca182..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/GuestCustomizationSection.java +++ /dev/null @@ -1,440 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.domain; - -import java.net.URI; - -import org.jclouds.vcloud.VCloudMediaType; - -/** - * The GuestCustomization of a Vm contains customization parameters for the guest operating system - * of the virtual machine. - */ -public class GuestCustomizationSection { - protected final String type; - protected final URI href; - protected String info; - protected Boolean enabled; - protected Boolean changeSid; - protected String virtualMachineId; - protected Boolean joinDomainEnabled; - protected Boolean useOrgSettings; - protected String domainName; - protected String domainUserName; - protected String domainUserPassword; - protected Boolean adminPasswordEnabled; - protected Boolean adminPasswordAuto; - protected String adminPassword; - protected Boolean resetPasswordRequired; - protected String customizationScript; - protected String computerName; - protected final ReferenceType edit; - - public GuestCustomizationSection(URI href) { - this.href = href; - this.type = VCloudMediaType.GUESTCUSTOMIZATIONSECTION_XML; - this.info = "Specifies Guest OS Customization Settings"; - this.edit = null; - } - - public GuestCustomizationSection(String type, URI href, String info, Boolean enabled, Boolean changeSid, - String virtualMachineId, Boolean joinDomainEnabled, Boolean useOrgSettings, String domainName, - String domainUserName, String domainUserPassword, Boolean adminPasswordEnabled, Boolean adminPasswordAuto, - String adminPassword, Boolean resetPasswordRequired, String customizationScript, String computerName, - ReferenceType edit) { - this.type = type; - this.href = href; - this.info = info; - this.enabled = enabled; - this.changeSid = changeSid; - this.virtualMachineId = virtualMachineId; - this.joinDomainEnabled = joinDomainEnabled; - this.useOrgSettings = useOrgSettings; - this.domainName = domainName; - this.domainUserName = domainUserName; - this.domainUserPassword = domainUserPassword; - this.adminPasswordEnabled = adminPasswordEnabled; - this.adminPasswordAuto = adminPasswordAuto; - this.adminPassword = adminPassword; - this.resetPasswordRequired = resetPasswordRequired; - this.customizationScript = customizationScript; - this.computerName = computerName; - this.edit = edit; - } - - /** - * - * @return media type of this section - */ - public String getType() { - return type; - } - - /** - * - * @return URL to access this section - */ - public URI getHref() { - return href; - } - - /** - * - * @return - */ - public String getInfo() { - return info; - } - - /** - * - * @return if true, to enable guest customization at power on - */ - public Boolean isEnabled() { - return enabled; - } - - /** - * - * @return if true, customization will run sysprep to change the Windows SID for this virtual - * machine - */ - public Boolean shouldChangeSid() { - return changeSid; - } - - /** - * - * @return unique identifier for this virtual machine - */ - public String getVirtualMachineId() { - return virtualMachineId; - } - - /** - * - * @return if true, this virtual machine can join a Windows domain - */ - public Boolean isJoinDomainEnabled() { - return joinDomainEnabled; - } - - /** - * - * @return if true, this virtual machine uses the containing organization’s default values for - * Windows domain name, domain user name, and domain user password - */ - public Boolean useOrgSettings() { - return useOrgSettings; - } - - /** - * - * @return if UseOrgSettings is false, specifies the Windows domain to join - */ - public String getDomainName() { - return domainName; - } - - /** - * - * @return if UseOrgSettings is false, specifies the Windows domain user name - */ - public String getDomainUserName() { - return domainUserName; - } - - /** - * - * @return if UseOrgSettings is false, specifies the Windows domain user’s password - */ - public String getDomainUserPassword() { - return domainUserPassword; - } - - /** - * - * @return true if the guest OS allows use of a local administrator password - */ - public Boolean isAdminPasswordEnabled() { - return adminPasswordEnabled; - } - - /** - * - * @return true if the local administrator password should be automatically generated - */ - public Boolean isAdminPasswordAuto() { - return adminPasswordAuto; - } - - /** - * - * @return local administrator password for this virtual machine - */ - public String getAdminPassword() { - return adminPassword; - } - - /** - * - * @return if true, the local administrator must reset his password on first use - */ - public Boolean isResetPasswordRequired() { - return resetPasswordRequired; - } - - /** - * - * @return the customization script to run - */ - public String getCustomizationScript() { - return customizationScript; - } - - /** - * - * @return name of this virtual machine in DNS or Windows domain - */ - public String getComputerName() { - return computerName; - } - - /** - * - * @return edit link - */ - public ReferenceType getEdit() { - return edit; - } - - @Override - public String toString() { - return "[href=" + getHref() + ", type=" + getType() + ", info=" + getInfo() + ", enabled=" + isEnabled() + "]"; - } - - @Override - public int hashCode() { - int prime = 31; - int result = 1; - result = prime * result + ((adminPassword == null) ? 0 : adminPassword.hashCode()); - result = prime * result + ((adminPasswordAuto == null) ? 0 : adminPasswordAuto.hashCode()); - result = prime * result + ((adminPasswordEnabled == null) ? 0 : adminPasswordEnabled.hashCode()); - result = prime * result + ((changeSid == null) ? 0 : changeSid.hashCode()); - result = prime * result + ((computerName == null) ? 0 : computerName.hashCode()); - result = prime * result + ((customizationScript == null) ? 0 : customizationScript.hashCode()); - result = prime * result + ((domainName == null) ? 0 : domainName.hashCode()); - result = prime * result + ((domainUserName == null) ? 0 : domainUserName.hashCode()); - result = prime * result + ((domainUserPassword == null) ? 0 : domainUserPassword.hashCode()); - result = prime * result + ((edit == null) ? 0 : edit.hashCode()); - result = prime * result + ((enabled == null) ? 0 : enabled.hashCode()); - result = prime * result + ((href == null) ? 0 : href.hashCode()); - result = prime * result + ((info == null) ? 0 : info.hashCode()); - result = prime * result + ((joinDomainEnabled == null) ? 0 : joinDomainEnabled.hashCode()); - result = prime * result + ((resetPasswordRequired == null) ? 0 : resetPasswordRequired.hashCode()); - result = prime * result + ((type == null) ? 0 : type.hashCode()); - result = prime * result + ((useOrgSettings == null) ? 0 : useOrgSettings.hashCode()); - result = prime * result + ((virtualMachineId == null) ? 0 : virtualMachineId.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; - GuestCustomizationSection other = (GuestCustomizationSection) obj; - if (adminPassword == null) { - if (other.adminPassword != null) - return false; - } else if (!adminPassword.equals(other.adminPassword)) - return false; - if (adminPasswordAuto == null) { - if (other.adminPasswordAuto != null) - return false; - } else if (!adminPasswordAuto.equals(other.adminPasswordAuto)) - return false; - if (adminPasswordEnabled == null) { - if (other.adminPasswordEnabled != null) - return false; - } else if (!adminPasswordEnabled.equals(other.adminPasswordEnabled)) - return false; - if (changeSid == null) { - if (other.changeSid != null) - return false; - } else if (!changeSid.equals(other.changeSid)) - return false; - if (computerName == null) { - if (other.computerName != null) - return false; - } else if (!computerName.equals(other.computerName)) - return false; - if (customizationScript == null) { - if (other.customizationScript != null) - return false; - } else if (!customizationScript.equals(other.customizationScript)) - return false; - if (domainName == null) { - if (other.domainName != null) - return false; - } else if (!domainName.equals(other.domainName)) - return false; - if (domainUserName == null) { - if (other.domainUserName != null) - return false; - } else if (!domainUserName.equals(other.domainUserName)) - return false; - if (domainUserPassword == null) { - if (other.domainUserPassword != null) - return false; - } else if (!domainUserPassword.equals(other.domainUserPassword)) - return false; - if (edit == null) { - if (other.edit != null) - return false; - } else if (!edit.equals(other.edit)) - return false; - if (enabled == null) { - if (other.enabled != null) - return false; - } else if (!enabled.equals(other.enabled)) - return false; - if (href == null) { - if (other.href != null) - return false; - } else if (!href.equals(other.href)) - return false; - if (info == null) { - if (other.info != null) - return false; - } else if (!info.equals(other.info)) - return false; - if (joinDomainEnabled == null) { - if (other.joinDomainEnabled != null) - return false; - } else if (!joinDomainEnabled.equals(other.joinDomainEnabled)) - return false; - if (resetPasswordRequired == null) { - if (other.resetPasswordRequired != null) - return false; - } else if (!resetPasswordRequired.equals(other.resetPasswordRequired)) - return false; - if (type == null) { - if (other.type != null) - return false; - } else if (!type.equals(other.type)) - return false; - if (useOrgSettings == null) { - if (other.useOrgSettings != null) - return false; - } else if (!useOrgSettings.equals(other.useOrgSettings)) - return false; - if (virtualMachineId == null) { - if (other.virtualMachineId != null) - return false; - } else if (!virtualMachineId.equals(other.virtualMachineId)) - return false; - return true; - } - - public void setEnabled(Boolean enabled) { - this.enabled = enabled; - } - - public Boolean getChangeSid() { - return changeSid; - } - - public void setChangeSid(Boolean changeSid) { - this.changeSid = changeSid; - } - - public Boolean getJoinDomainEnabled() { - return joinDomainEnabled; - } - - public void setJoinDomainEnabled(Boolean joinDomainEnabled) { - this.joinDomainEnabled = joinDomainEnabled; - } - - public Boolean shouldUseOrgSettings() { - return useOrgSettings; - } - - public void setUseOrgSettings(Boolean useOrgSettings) { - this.useOrgSettings = useOrgSettings; - } - - public Boolean getAdminPasswordEnabled() { - return adminPasswordEnabled; - } - - public void setAdminPasswordEnabled(Boolean adminPasswordEnabled) { - this.adminPasswordEnabled = adminPasswordEnabled; - } - - public Boolean getAdminPasswordAuto() { - return adminPasswordAuto; - } - - public void setAdminPasswordAuto(Boolean adminPasswordAuto) { - this.adminPasswordAuto = adminPasswordAuto; - } - - public Boolean getResetPasswordRequired() { - return resetPasswordRequired; - } - - public void setResetPasswordRequired(Boolean resetPasswordRequired) { - this.resetPasswordRequired = resetPasswordRequired; - } - - public void setInfo(String info) { - this.info = info; - } - - public void setVirtualMachineId(String virtualMachineId) { - this.virtualMachineId = virtualMachineId; - } - - public void setDomainName(String domainName) { - this.domainName = domainName; - } - - public void setDomainUserName(String domainUserName) { - this.domainUserName = domainUserName; - } - - public void setDomainUserPassword(String domainUserPassword) { - this.domainUserPassword = domainUserPassword; - } - - public void setAdminPassword(String adminPassword) { - this.adminPassword = adminPassword; - } - - public void setCustomizationScript(String customizationScript) { - this.customizationScript = customizationScript; - } - - public void setComputerName(String computerName) { - this.computerName = computerName; - } -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/InstantiateVAppTemplateParams.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/InstantiateVAppTemplateParams.java deleted file mode 100644 index 4b024df362..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/InstantiateVAppTemplateParams.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.domain; - -import java.util.Set; - -import org.jclouds.cim.ResourceAllocationSettingData; -import org.jclouds.cim.VirtualSystemSettingData; - -import com.google.common.collect.Iterables; -import com.google.common.collect.Sets; - -/** - * The InstantiateVAppTemplateParams element forms the body of an instantiateVappTemplate request. - */ -public class InstantiateVAppTemplateParams { - - protected final String info; - protected final VirtualSystemSettingData virtualSystem; - protected final Set resourceAllocations = Sets.newLinkedHashSet(); - - public InstantiateVAppTemplateParams(String info, VirtualSystemSettingData virtualSystem, Iterable resourceAllocations) { - this.info = info; - this.virtualSystem = virtualSystem; - Iterables.addAll(this.resourceAllocations, resourceAllocations); - } - - public String getInfo() { - return info; - } - - public VirtualSystemSettingData getSystem() { - return virtualSystem; - } - - public Set getResourceAllocationSettingDatas() { - return resourceAllocations; - } - - @Override - public String toString() { - return "[info=" + getInfo() + ", virtualSystem=" + getSystem() + "]"; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((info == null) ? 0 : info.hashCode()); - result = prime * result + ((resourceAllocations == null) ? 0 : resourceAllocations.hashCode()); - result = prime * result + ((virtualSystem == null) ? 0 : virtualSystem.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; - InstantiateVAppTemplateParams other = (InstantiateVAppTemplateParams) obj; - if (info == null) { - if (other.info != null) - return false; - } else if (!info.equals(other.info)) - return false; - if (resourceAllocations == null) { - if (other.resourceAllocations != null) - return false; - } else if (!resourceAllocations.equals(other.resourceAllocations)) - return false; - if (virtualSystem == null) { - if (other.virtualSystem != null) - return false; - } else if (!virtualSystem.equals(other.virtualSystem)) - return false; - return true; - } - -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/NetworkConnection.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/NetworkConnection.java deleted file mode 100644 index 34aa34226f..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/NetworkConnection.java +++ /dev/null @@ -1,231 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.domain; - -import org.jclouds.javax.annotation.Nullable; -import org.jclouds.vcloud.domain.network.IpAddressAllocationMode; - -/** - * describes a single network connection. - */ -public class NetworkConnection { - public static Builder builder() { - return new Builder(); - } - - public static class Builder { - - private String network; - private int networkConnectionIndex; - private String ipAddress; - private String externalIpAddress; - private boolean connected; - private String MACAddress; - private IpAddressAllocationMode ipAddressAllocationMode; - - public Builder network(String network) { - this.network = network; - return this; - } - - public Builder networkConnectionIndex(int networkConnectionIndex) { - this.networkConnectionIndex = networkConnectionIndex; - return this; - } - - public Builder ipAddress(String ipAddress) { - this.ipAddress = ipAddress; - return this; - } - - public Builder externalIpAddress(String externalIpAddress) { - this.externalIpAddress = externalIpAddress; - return this; - } - - public Builder connected(boolean connected) { - this.connected = connected; - return this; - } - - public Builder MACAddress(String MACAddress) { - this.MACAddress = MACAddress; - return this; - } - - public Builder ipAddressAllocationMode(IpAddressAllocationMode ipAddressAllocationMode) { - this.ipAddressAllocationMode = ipAddressAllocationMode; - return this; - } - - public NetworkConnection build() { - return new NetworkConnection(network, networkConnectionIndex, ipAddress, externalIpAddress, connected, - MACAddress, ipAddressAllocationMode); - } - - public static Builder fromNetworkConnection(NetworkConnection in) { - return new Builder().network(in.getNetwork()).networkConnectionIndex(in.getNetworkConnectionIndex()) - .ipAddress(in.getIpAddress()).externalIpAddress(in.getExternalIpAddress()).connected(in.isConnected()) - .MACAddress(in.getMACAddress()).ipAddressAllocationMode(in.getIpAddressAllocationMode()); - } - } - - private final String network; - private final int networkConnectionIndex; - @Nullable - private final String ipAddress; - @Nullable - private final String externalIpAddress; - private final boolean connected; - @Nullable - private final String MACAddress; - private final IpAddressAllocationMode ipAddressAllocationMode; - - public NetworkConnection(String network, int networkConnectionIndex, @Nullable String ipAddress, - @Nullable String externalIpAddress, boolean connected, @Nullable String MACAddress, - IpAddressAllocationMode ipAddressAllocationMode) { - this.network = network; - this.networkConnectionIndex = networkConnectionIndex; - this.ipAddress = ipAddress; - this.externalIpAddress = externalIpAddress; - this.connected = connected; - this.MACAddress = MACAddress; - this.ipAddressAllocationMode = ipAddressAllocationMode; - } - - /** - * @return The name of the network to which this connection connects. - */ - public String getNetwork() { - return network; - } - - /** - * @return The value in the rasd:AddressOnParent element of the device supporting this - * connection. - */ - public int getNetworkConnectionIndex() { - return networkConnectionIndex; - } - - /** - * @return IP address of this connection - */ - @Nullable - public String getIpAddress() { - return ipAddress; - } - - /** - * @return If the network that the NIC is connected to has NAT or port mapping, the external - * address is populated in this element. - */ - @Nullable - public String getExternalIpAddress() { - return externalIpAddress; - } - - /** - * @return If the vApp is deployed, specifies the current state of its connection. If the vApp is - * undeployed, specifies whether this connection should be connected at deployment time. - */ - public boolean isConnected() { - return connected; - } - - /** - * @return MAC address of this connection - */ - @Nullable - public String getMACAddress() { - return MACAddress; - } - - /** - * @return specifies how an IP address is allocated to this connection - */ - public IpAddressAllocationMode getIpAddressAllocationMode() { - return ipAddressAllocationMode; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((MACAddress == null) ? 0 : MACAddress.hashCode()); - result = prime * result + (connected ? 1231 : 1237); - result = prime * result + ((externalIpAddress == null) ? 0 : externalIpAddress.hashCode()); - result = prime * result + ((ipAddress == null) ? 0 : ipAddress.hashCode()); - result = prime * result + ((ipAddressAllocationMode == null) ? 0 : ipAddressAllocationMode.hashCode()); - result = prime * result + ((network == null) ? 0 : network.hashCode()); - result = prime * result + networkConnectionIndex; - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - NetworkConnection other = (NetworkConnection) obj; - if (MACAddress == null) { - if (other.MACAddress != null) - return false; - } else if (!MACAddress.equals(other.MACAddress)) - return false; - if (connected != other.connected) - return false; - if (externalIpAddress == null) { - if (other.externalIpAddress != null) - return false; - } else if (!externalIpAddress.equals(other.externalIpAddress)) - return false; - if (ipAddress == null) { - if (other.ipAddress != null) - return false; - } else if (!ipAddress.equals(other.ipAddress)) - return false; - if (ipAddressAllocationMode == null) { - if (other.ipAddressAllocationMode != null) - return false; - } else if (!ipAddressAllocationMode.equals(other.ipAddressAllocationMode)) - return false; - if (network == null) { - if (other.network != null) - return false; - } else if (!network.equals(other.network)) - return false; - if (networkConnectionIndex != other.networkConnectionIndex) - return false; - return true; - } - - public Builder toBuilder() { - return Builder.fromNetworkConnection(this); - } - - @Override - public String toString() { - return "[network=" + network + ", connected=" + connected + ", ipAddress=" + ipAddress + ", externalIpAddress=" - + externalIpAddress + ", networkConnectionIndex=" + networkConnectionIndex + ", ipAddressAllocationMode=" - + ipAddressAllocationMode + ", MACAddress=" + MACAddress + "]"; - } - -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/NetworkConnectionSection.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/NetworkConnectionSection.java deleted file mode 100644 index c6f5f37d70..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/NetworkConnectionSection.java +++ /dev/null @@ -1,218 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.domain; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.net.URI; -import java.util.Set; - -import com.google.common.collect.ImmutableSet; - -/** - * The NetworkConnectionSection element specifies how a Vm is connected to a vApp network. It - * extends the ovf:NetworkConnection element. - *

- * NOTE The OVF NetworkSection element and the vCloud API NetworkConnectionSection element specify - * many of the same parameters for a network connection. If both are present in a Vm body, the - * values specified in the NetworkConnectionSection override those specified in the NetworkSection. - */ -public class NetworkConnectionSection { - public static Builder builder() { - return new Builder(); - } - - public static class Builder { - protected String type; - protected URI href; - protected String info; - protected Integer primaryNetworkConnectionIndex; - protected Set connections = ImmutableSet.of(); - protected ReferenceType edit; - - public Builder type(String type) { - this.type = type; - return this; - } - - public Builder href(URI href) { - this.href = href; - return this; - } - - public Builder info(String info) { - this.info = info; - return this; - } - - public Builder primaryNetworkConnectionIndex(Integer primaryNetworkConnectionIndex) { - this.primaryNetworkConnectionIndex = primaryNetworkConnectionIndex; - return this; - } - - public Builder connections(Iterable connections) { - this.connections = ImmutableSet.copyOf(checkNotNull(connections, "connections")); - return this; - } - - public Builder edit(ReferenceType edit) { - this.edit = edit; - return this; - } - - public NetworkConnectionSection build() { - return new NetworkConnectionSection(type, href, info, primaryNetworkConnectionIndex, connections, edit); - } - - public static Builder fromNetworkConnectionSection(NetworkConnectionSection in) { - return new Builder().type(in.getType()).href(in.getHref()).info(in.getInfo()) - .primaryNetworkConnectionIndex(in.getPrimaryNetworkConnectionIndex()).connections(in.getConnections()) - .edit(in.getEdit()); - } - } - - protected final String type; - protected final URI href; - protected final String info; - protected final Integer primaryNetworkConnectionIndex; - protected final Set connections; - protected final ReferenceType edit; - - public NetworkConnectionSection(String type, URI href, String info, Integer primaryNetworkConnectionIndex, - Iterable connections, ReferenceType edit) { - this.type = type; - this.href = href; - this.info = info; - this.primaryNetworkConnectionIndex = primaryNetworkConnectionIndex; - this.connections = ImmutableSet.copyOf(checkNotNull(connections, "connections")); - this.edit = edit; - } - - /** - * - * @return media type of this section - */ - public String getType() { - return type; - } - - /** - * - * @return URL to access this section - */ - public URI getHref() { - return href; - } - - /** - * - * @return - */ - public String getInfo() { - return info; - } - - /** - * - * @return The value of the rasd:AddressOnParent element of the device (NIC) supporting the - * primary network connection to the containing virtual machine. - */ - public Integer getPrimaryNetworkConnectionIndex() { - return primaryNetworkConnectionIndex; - } - - /** - * - */ - public Set getConnections() { - return connections; - } - - /** - * - */ - public ReferenceType getEdit() { - return edit; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((connections == null) ? 0 : connections.hashCode()); - result = prime * result + ((edit == null) ? 0 : edit.hashCode()); - result = prime * result + ((href == null) ? 0 : href.hashCode()); - result = prime * result + ((info == null) ? 0 : info.hashCode()); - result = prime * result - + ((primaryNetworkConnectionIndex == null) ? 0 : primaryNetworkConnectionIndex.hashCode()); - result = prime * result + ((type == null) ? 0 : type.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; - NetworkConnectionSection other = (NetworkConnectionSection) obj; - if (connections == null) { - if (other.connections != null) - return false; - } else if (!connections.equals(other.connections)) - return false; - if (edit == null) { - if (other.edit != null) - return false; - } else if (!edit.equals(other.edit)) - return false; - if (href == null) { - if (other.href != null) - return false; - } else if (!href.equals(other.href)) - return false; - if (info == null) { - if (other.info != null) - return false; - } else if (!info.equals(other.info)) - return false; - if (primaryNetworkConnectionIndex == null) { - if (other.primaryNetworkConnectionIndex != null) - return false; - } else if (!primaryNetworkConnectionIndex.equals(other.primaryNetworkConnectionIndex)) - return false; - if (type == null) { - if (other.type != null) - return false; - } else if (!type.equals(other.type)) - return false; - return true; - } - - public Builder toBuilder() { - return Builder.fromNetworkConnectionSection(this); - } - - @Override - public String toString() { - return "[href=" + href + ", connections=" + connections + ", primaryNetworkConnectionIndex=" - + primaryNetworkConnectionIndex + "]"; - } - -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/Org.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/Org.java deleted file mode 100644 index 7f4ede9dcf..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/Org.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.domain; - -import java.util.List; -import java.util.Map; - -import org.jclouds.javax.annotation.Nullable; -import org.jclouds.vcloud.domain.internal.OrgImpl; - -import com.google.inject.ImplementedBy; - -/** - * A vCloud organization is a high-level abstraction that provides a unit of administration for - * objects and resources. As viewed by a user, an organization (represented by an Org element) can - * contain Catalog, Network, and vDC elements. If there are any queued, running, or recently - * completed tasks owned by a member of the organization, it also contains a TasksList element. As - * viewed by an administrator, an organization also contains users, groups, and other information - */ -@ImplementedBy(OrgImpl.class) -public interface Org extends ReferenceType { - /** - * optional description - * - * @since vcloud api 0.8 - */ - @Nullable - String getDescription(); - - /** - * full name of the organization - * - * @since vcloud api 1.0 - */ - @Nullable - String getFullName(); - - /** - * @since vcloud api 0.8 - */ - Map getCatalogs(); - - /** - * @since vcloud api 0.8 - */ - Map getVDCs(); - - /** - * If there are any queued, running, or recently completed tasks owned by a member of the - * organization, it also contains a TasksList. - * - * @since vcloud api 0.8 - */ - @Nullable - ReferenceType getTasksList(); - - /** - * @since vcloud api 1.0 - */ - Map getNetworks(); - - /** - * read‐only container for Task elements. Each element in the container represents a queued, - * running, or failed task owned by this object. - * - * @since vcloud api 1.0 - */ - List getTasks(); - -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/ReferenceType.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/ReferenceType.java deleted file mode 100644 index 108c1395f5..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/ReferenceType.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.domain; - -import java.net.URI; - -import org.jclouds.vcloud.domain.internal.ReferenceTypeImpl; - -import com.google.inject.ImplementedBy; - -/** - * Many container elements are populated with references to contained objects. Each reference - * consists of a hyperlink, an optional media type, and a name. - */ -@ImplementedBy(ReferenceTypeImpl.class) -public interface ReferenceType extends Comparable { - /** - * @return hyperlink to the referenced object - */ - URI getHref(); - - /** - * @return name of the referenced object. - * - */ - String getName(); - - /** - * @return object type, expressed as the media type of the XML representing of the object - * @see VCloudMediaType - */ - String getType(); - -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/Status.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/Status.java deleted file mode 100644 index 748099b423..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/Status.java +++ /dev/null @@ -1,244 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.domain; - -import static com.google.common.base.Preconditions.checkNotNull; - -/** - * Objects such as vAppTemplate, vApp, and Vm have a status attribute whose value indicates the - * state of the object. Status for an object, such as a vAppTemplate or vApp, whose Children (Vm - * objects) each have a status of their own, is computed from the status of the Children. - * - *

NOTE

- *

- * The deployment status of an object is indicated by the value of its deployed attribute. - * - * @since vcloud api 0.8 - */ -public enum Status { - /** - * The {@link VAppTemplate}, {@link VApp}, or {@link Vm} could not be created. - * - * @since vcloud api 1.0 - */ - ERROR, - /** - * The {@link VAppTemplate}, {@link VApp}, or {@link Vm} is unresolved. - * - * @since vcloud api 0.8 - */ - UNRESOLVED, - /** - * The {@link VAppTemplate}, {@link VApp}, or {@link Vm} is resolved. - * - * @since vcloud api 0.8 - */ - RESOLVED, - /** - * The object is deployed. - *

- * note that the documentation does not reference use of this. - * - * @since vcloud api 1.0 - */ - DEPLOYED, - /** - * The {@link VApp} or {@link Vm} is suspended. - * - * @since vcloud api 0.8 - */ - SUSPENDED, - /** - * The {@link VApp} or {@link Vm} is powered on - * - * @since vcloud api 0.8 - */ - ON, - /** - * The {@link VApp} or {@link Vm} waiting for user input. - * - * @since vcloud api 1.0 - */ - WAITING_FOR_INPUT, - /** - * The {@link VAppTemplate}, {@link VApp}, or {@link Vm} is in an unknown state. - * - * @since vcloud api 1.0 - */ - UNKNOWN, - /** - * The {@link VAppTemplate}, {@link VApp}, or {@link Vm} is in an unrecognized state. - * - * @since vcloud api 1.0 - */ - UNRECOGNIZED, - /** - * The {@link VAppTemplate}, {@link VApp}, or {@link Vm} is off. - * - * @since vcloud api 0.8 - */ - OFF, - /** - * The {@link VApp} or {@link Vm} is in an inconsistent state. - * - * @since vcloud api 1.0 - */ - INCONSISTENT, - /** - * The {@link VAppTemplate} or {@link VApp} have children do not all have the same status. - * - * @since vcloud api 1.0 - */ - MIXED, - /** - * The {@link VAppTemplate} Upload initiated, OVF descriptor pending - * - * @since vcloud api 1.0 - */ - PENDING_DESCRIPTOR, - /** - * The {@link VAppTemplate} Upload initiated, copying contents - * - * @since vcloud api 1.0 - */ - COPYING, - /** - * The {@link VAppTemplate} Upload initiated, disk contents pending - * - * @since vcloud api 1.0 - */ - PENDING_CONTENTS, - /** - * The {@link VAppTemplate} Upload has been quarantined - * - * @since vcloud api 1.0 - */ - QUARANTINED, - /** - * The {@link VAppTemplate} Upload quarantine period has expired - * - * @since vcloud api 1.0 - */ - QUARANTINE_EXPIRED, - /** - * The {@link VAppTemplate} rejected - * - * @since vcloud api 1.0 - */ - REJECTED, - /** - * The {@link VAppTemplate} transfer timeout - * - * @since vcloud api 1.0 - */ - TRANSFER_TIMEOUT; - - public String value() { - switch (this) { - case UNRESOLVED: - return "0"; - case RESOLVED: - return "1"; - case DEPLOYED: - return "2"; - case SUSPENDED: - return "3"; - case ON: - return "4"; - case WAITING_FOR_INPUT: - return "5"; - case UNKNOWN: - return "6"; - case UNRECOGNIZED: - return "7"; - case OFF: - return "8"; - case INCONSISTENT: - return "9"; - case MIXED: - return "10"; - case PENDING_DESCRIPTOR: - return "11"; - case COPYING: - return "12"; - case PENDING_CONTENTS: - return "13"; - case QUARANTINED: - return "14"; - case QUARANTINE_EXPIRED: - return "15"; - case REJECTED: - return "16"; - case TRANSFER_TIMEOUT: - return "17"; - default: - return "7"; - } - } - - public static Status fromValue(String status) { - try { - return fromValue(Integer.parseInt(checkNotNull(status, "status"))); - } catch (IllegalArgumentException e) { - return UNRECOGNIZED; - } - } - - public static Status fromValue(int v) { - switch (v) { - case 0: - return UNRESOLVED; - case 1: - return RESOLVED; - case 2: - return DEPLOYED; - case 3: - return SUSPENDED; - case 4: - return ON; - case 5: - return WAITING_FOR_INPUT; - case 6: - return UNKNOWN; - case 7: - return UNRECOGNIZED; - case 8: - return OFF; - case 9: - return INCONSISTENT; - case 10: - return MIXED; - case 11: - return PENDING_DESCRIPTOR; - case 12: - return COPYING; - case 13: - return PENDING_CONTENTS; - case 14: - return QUARANTINED; - case 15: - return QUARANTINE_EXPIRED; - case 16: - return REJECTED; - case 17: - return TRANSFER_TIMEOUT; - default: - return UNRECOGNIZED; - } - } - -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/Task.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/Task.java deleted file mode 100644 index 82585d6050..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/Task.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.domain; - -import java.util.Date; - -import org.jclouds.javax.annotation.Nullable; -import org.jclouds.vcloud.domain.internal.TaskImpl; - -import com.google.inject.ImplementedBy; - -/** - * Whenever the result of a request cannot be returned immediately, the server creates a Task - * object. Tasks owned by an object such as a vApp or vDC are contained in the Tasks element of the - * object’s XML representation. This element is read‐only. - */ -@ImplementedBy(TaskImpl.class) -public interface Task extends ReferenceType { - /** - * The current status of the task. - */ - String getOperation(); - - /** - * The current status of the task. - */ - TaskStatus getStatus(); - - /** - * date and time when the task was started. - */ - Date getStartTime(); - - /** - * date and time when the task completed. Does not appear for running tasks. - */ - Date getEndTime(); - - /** - * date and time at which the task expires. By default, tasks expire 24 hours after their start - * time. Expired tasks cannot be queried. - */ - Date getExpiryTime(); - - /** - * A link to the object that owns the task. For copy operations, the owner is the copy that is - * being created. For delete operations, the owner is the deleted object, so this element is not - * included. For all other operations, the owner is the object to which the request was made. - */ - ReferenceType getOwner(); - - /** - * error message or related information returned by the task - */ - @Nullable - VCloudError getError(); - -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/TaskStatus.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/TaskStatus.java deleted file mode 100644 index 68ee690bad..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/TaskStatus.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.domain; - -import static com.google.common.base.Preconditions.checkNotNull; - -public enum TaskStatus { - /** - * The task has completed and returned a value indicating success. - */ - SUCCESS, - /** - * The task is running. - */ - RUNNING, - - /** - * The task has been queued for execution. - */ - QUEUED, - /** - * The task has completed and returned a value indicating an error. - */ - ERROR, - /** - * not an official status, temporarily in. - */ - CANCELLED, UNRECOGNIZED; - public String value() { - return name().toLowerCase(); - } - - @Override - public String toString() { - return value(); - } - - public static TaskStatus fromValue(String status) { - if ("CANCELED".equals(status.toUpperCase())) { - // TODO: ecloud hack - status = "CANCELLED"; - } else if ("FAILED".equals(status.toUpperCase())) { - status = "ERROR"; - } else if ("COMPLETED".equals(status.toUpperCase())) { - status = "SUCCESS"; - } - try { - return valueOf(checkNotNull(status, "status").toUpperCase()); - } catch (IllegalArgumentException e) { - return UNRECOGNIZED; - } - } - -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/TasksList.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/TasksList.java deleted file mode 100644 index 6405054ed3..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/TasksList.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.domain; - -import java.net.URI; -import java.util.SortedSet; - -import org.jclouds.vcloud.domain.internal.TasksListImpl; - -import com.google.inject.ImplementedBy; - -@org.jclouds.vcloud.endpoints.TasksList -@ImplementedBy(TasksListImpl.class) -public interface TasksList { - - URI getLocation(); - - SortedSet getTasks(); - -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/VApp.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/VApp.java deleted file mode 100644 index 98efea27f3..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/VApp.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.domain; - -import java.util.List; -import java.util.Set; - -import org.jclouds.javax.annotation.Nullable; -import org.jclouds.vcloud.domain.ovf.VCloudNetworkSection; - -/** - * A VApp is the result of instantiation of a {@link VAppTemplate}.

note

- *

- * When the {@link #getStatus} is {@link Status#UNRESOLVED}, there will be a task present for the - * instantiation of the VApp. - */ -public interface VApp extends ReferenceType { - /** - * Reference to the vdc containing this vApp. - * - * @since vcloud api 1.0 - * @return vdc, or null if this is a version before 1.0 where the org isn't present - */ - ReferenceType getVDC(); - - /** - * The creation status of the vDC - * - * @since vcloud api 1.0 - */ - Status getStatus(); - - /** - * optional description - * - * @since vcloud api 0.8 - */ - @Nullable - String getDescription(); - - /** - * - * @return true if the OVF descriptor for the template has been uploaded to the containing vDC. - * @since vcloud api 1.0 - */ - boolean isOvfDescriptorUploaded(); - - /** - * read‐only container for Task elements. Each element in the container represents a queued, - * running, or failed task owned by this object. - * - * @since vcloud api 1.0 - */ - List getTasks(); - - /** - * container for Vm elements representing virtual machines - * - * @since vcloud api 1.0 - */ - Set getChildren(); - - /** - * description of the predefined vApp internal networks in this template - * - * @return null if the vApp is not yet instantiated - * @since vcloud api 1.0 - */ - @Nullable - VCloudNetworkSection getNetworkSection(); -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/VAppTemplate.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/VAppTemplate.java deleted file mode 100644 index 8fdd6fb831..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/VAppTemplate.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.domain; - -import java.util.List; -import java.util.Set; - -import org.jclouds.javax.annotation.Nullable; -import org.jclouds.vcloud.domain.internal.VAppTemplateImpl; -import org.jclouds.vcloud.domain.ovf.VCloudNetworkSection; - -import com.google.inject.ImplementedBy; - -/** - * A VAppTemplate is an abstract description of a vApp. It is created when you upload an OVF package - * to a vDC. - */ -@ImplementedBy(VAppTemplateImpl.class) -public interface VAppTemplate extends ReferenceType { - /** - * Reference to the VDC containing this template. - * - * @since vcloud api 1.0 - * @return org, or null if this is a version before 1.0 where the vdc isn't present - */ - ReferenceType getVDC(); - - /** - * @return creation status of the VAppTemplate. - * - * @since vcloud api 1.0 - */ - Status getStatus(); - - /** - * optional description - * - * @since vcloud api 1.0 - */ - @Nullable - String getDescription(); - - /** - * read-only container for Task elements. Each element in the container represents a queued, - * running, or failed task owned by this object. - * - * @since vcloud api 1.0 - */ - List getTasks(); - - /** - * - * @return true if the OVF descriptor for the template has been uploaded to the containing vDC. - * @since vcloud api 1.0 - */ - boolean isOvfDescriptorUploaded(); - - /** - * read-only identifier created on import - * - * @since vcloud api 1.0 - */ - @Nullable - String getVAppScopedLocalId(); - - /** - * container for Vm elements representing virtual machines - * - * @since vcloud api 1.0 - */ - Set getChildren(); - - /** - * description of the predefined vApp internal networks in this template - * - * @return null if the vAppTemplate is still copying - * @since vcloud api 1.0 - */ - @Nullable - VCloudNetworkSection getNetworkSection(); -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/VCloudError.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/VCloudError.java deleted file mode 100644 index 3fa88b628f..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/VCloudError.java +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.domain; - -import static com.google.common.base.Preconditions.checkNotNull; - -import org.jclouds.javax.annotation.Nullable; -import org.jclouds.vcloud.domain.internal.ErrorImpl; - -import com.google.inject.ImplementedBy; - -@ImplementedBy(ErrorImpl.class) -public interface VCloudError { - public static enum MinorCode { - /** - * The request was made by a user who had insufficient rights to the object or operation. - */ - ACCESS_TO_RESOURCE_IS_FORBIDDEN, - /** - * The request could not be validated or contained invalid XML. - */ - BAD_REQUEST, - /** - * A conflict was detected between sections of an OVF descriptor. - */ - CONFLICT, - /** - * The entity is busy - */ - BUSY_ENTITY, - /** - * An attempt to instantiate a vAppTemplate or use a vAppTemplate or a Vm in a composition did - * not include an AllEULAsAccepted element with a value of true. - */ - EULA_NOT_ACCEPTED, - /** - * Returned for any failure that cannot be matched to another minor error code. - */ - INTERNAL_SERVER_ERROR, - /** - * One or more references (href attribute values) supplied in the request could not be - * resolved to an object. - */ - INVALID_REFERENCE, - /** - * The HTTP method (GET, PUT, POST, DELETE) is not allowed for the request. - */ - METHOD_NOT_ALLOWED, - /** - * One or more references (href attribute values) supplied in the request could not be - * resolved to an object, or the Content‐type of the request was incorrect. - */ - RESOURCE_NOT_FOUND, - /** - * The request raised an exception that did not match any HTTP status code. - */ - UNKNOWN, - /** - * The wrong content type was specified for the request. - */ - UNSUPPORTED_MEDIA_TYPE, UNRECOGNIZED; - - public static MinorCode fromValue(String minorCode) { - try { - return valueOf(checkNotNull(minorCode, "minorCode")); - } catch (IllegalArgumentException e) { - return UNRECOGNIZED; - } - } - } - - /** - * - * @return message describing the error - */ - String getMessage(); - - /** - * - * @return matches the HTTP status code - */ - int getMajorErrorCode(); - - /** - * - * @return error code specific to the failed operation or null if vcloud <0.9 - */ - @Nullable - MinorCode getMinorErrorCode(); - - /** - * - * @return optional additional information about the source of the error - */ - @Nullable - String getVendorSpecificErrorCode(); - - /** - * - * @return stack trace of the error, if available. This attribute is returned only when a request - * is made by the system administrator. - */ - String getStackTrace(); -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/VCloudSession.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/VCloudSession.java deleted file mode 100644 index 01acd91a00..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/VCloudSession.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.domain; - -import java.util.Map; - -public interface VCloudSession { - String getVCloudToken(); - - Map getOrgs(); -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/VDC.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/VDC.java deleted file mode 100644 index c741d26d52..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/VDC.java +++ /dev/null @@ -1,144 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.domain; - -import java.util.List; -import java.util.Map; - -import org.jclouds.javax.annotation.Nullable; -import org.jclouds.vcloud.domain.internal.VDCImpl; - -import com.google.inject.ImplementedBy; - -/** - * A vDC is a deployment environment for vApps. A Vdc element provides a user view of a vDC. - */ -@org.jclouds.vcloud.endpoints.VDC -@ImplementedBy(VDCImpl.class) -public interface VDC extends ReferenceType { - /** - * Reference to the org containing this vDC. - * - * @since vcloud api 1.0 - * @return org, or null if this is a version before 1.0 where the org isn't present - */ - ReferenceType getOrg(); - - /** - * The creation status of the vDC - * - * @since vcloud api 1.0 - */ - VDCStatus getStatus(); - - /** - * optional description - * - * @since vcloud api 0.8 - */ - @Nullable - String getDescription(); - - /** - * read‐only container for Task elements. Each element in the container represents a queued, - * running, or failed task owned by this object. - * - * @since vcloud api 1.0 - */ - List getTasks(); - - /** - * defines how resources are allocated by the vDC. The value of this element is set by the - * administrator who created the vDC. It is read‐only to users. - * - * @since vcloud api 1.0 - */ - AllocationModel getAllocationModel(); - - /** - * defines the storage capacity available in the vDC - * - * @since vcloud api 0.8 - * @return null if the provider doesn't support storage capacity - */ - @Nullable - Capacity getStorageCapacity(); - - /** - * reports CPU resource consumption in a vDC - * - * @since vcloud api 0.8 - * @return null if the provider doesn't support cpu capacity - */ - @Nullable - Capacity getCpuCapacity(); - - /** - * reports memory resource consumption in a vDC - * - * @since vcloud api 0.8 - * @return null if the provider doesn't support memory capacity - */ - @Nullable - Capacity getMemoryCapacity(); - - /** - * container for ResourceEntity elements - * - * @since vcloud api 0.8 - */ - Map getResourceEntities(); - - /** - * container for OrgNetwork elements that represent organization networks contained by the vDC - * - * @since vcloud api 0.8 - */ - Map getAvailableNetworks(); - - /** - * maximum number of virtual NICs allowed in this vDC. Defaults to 0, which specifies an - * unlimited number. - * - * @since vcloud api 1.0 - */ - int getNicQuota(); - - /** - * maximum number of OrgNetwork objects that can be deployed in this vDC. Defaults to 0, which - * specifies an unlimited number. - * - * @since vcloud api 1.0 - */ - int getNetworkQuota(); - - /** - * maximum number of virtual machines that can be deployed in this vDC. Defaults to 0, which - * specifies an unlimited number. - * - * @since vcloud api 0.8 - */ - int getVmQuota(); - - /** - * true if this vDC is enabled - * - * @since vcloud api 1.0 - */ - boolean isEnabled(); - -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/VDCStatus.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/VDCStatus.java deleted file mode 100644 index 81b25d9f02..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/VDCStatus.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.domain; - -/** - * The creation status of the vDC - * - * @see VDC#getStatus - */ -public enum VDCStatus { - - CREATION_FAILED, NOT_READY, READY, UNKNOWN, UNRECOGNIZED; - - public int value() { - switch (this) { - case CREATION_FAILED: - return -1; - case NOT_READY: - return 0; - case READY: - return 1; - case UNKNOWN: - return 2; - default: - return 3; - } - } - - public static VDCStatus fromValue(int status) { - switch (status) { - case -1: - return CREATION_FAILED; - case 0: - return NOT_READY; - case 1: - return READY; - case 2: - return UNKNOWN; - default: - return UNRECOGNIZED; - } - } -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/Vm.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/Vm.java deleted file mode 100644 index 79657b184d..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/Vm.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.domain; - -import java.util.List; - -import org.jclouds.javax.annotation.Nullable; -import org.jclouds.vcloud.domain.internal.VmImpl; -import org.jclouds.vcloud.domain.ovf.VCloudOperatingSystemSection; -import org.jclouds.vcloud.domain.ovf.VCloudVirtualHardwareSection; - -import com.google.inject.ImplementedBy; - -/** - * A Vm represents a virtual machine, a member of a vApp’s Children container.

note

- *

- * When the {@link #getStatus} is {@link Status#UNRESOLVED}, there will be a task present for the - * instantiation of the VApp. - */ -@ImplementedBy(VmImpl.class) -public interface Vm extends ReferenceType { - /** - * Reference to the {@link VApp} or {@link VAppTemplate} containing this vm. - * - * @since vcloud api 1.0 - */ - ReferenceType getParent(); - - /** - * @return creation status of the Vm or null, if a part of a VAppTemplate - * - * @since vcloud api 1.0 - */ - @Nullable - Status getStatus(); - - /** - * optional description - * - * @since vcloud api 0.8 - */ - @Nullable - String getDescription(); - - /** - * read‐only container for Task elements. Each element in the container represents a queued, - * running, or failed task owned by this object. - * - * @since vcloud api 1.0 - */ - List getTasks(); - - /** - * @return virtual hardware that comprises this VM, or null, if part of a vApp template - * - * @since vcloud api 1.0 - */ - @Nullable - VCloudVirtualHardwareSection getVirtualHardwareSection(); - - /** - * @return operating system on this VM, or null, if part of a vApp template - * - * @since vcloud api 1.0 - */ - @Nullable - VCloudOperatingSystemSection getOperatingSystemSection(); - - /** - * @return network connections for this VM, or null if it doesn't exist - * - * @since vcloud api 1.0 - */ - @Nullable - NetworkConnectionSection getNetworkConnectionSection(); - - /** - * @return guest customization section for this VM, or null if it doesn't exist - * - * @since vcloud api 1.0 - */ - @Nullable - GuestCustomizationSection getGuestCustomizationSection(); - - /** - * read-only identifier created on import - * - * @since vcloud api 1.0 - */ - @Nullable - String getVAppScopedLocalId(); -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/internal/CatalogImpl.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/internal/CatalogImpl.java deleted file mode 100644 index 4ad9caf5a7..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/internal/CatalogImpl.java +++ /dev/null @@ -1,186 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.domain.internal; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.net.URI; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; - -import org.jclouds.javax.annotation.Nullable; -import org.jclouds.vcloud.domain.Catalog; -import org.jclouds.vcloud.domain.ReferenceType; -import org.jclouds.vcloud.domain.Task; - -import com.google.common.collect.Iterables; -import com.google.common.collect.Lists; - -/** - * Locations of resources in vCloud - */ -public class CatalogImpl extends LinkedHashMap implements Catalog { - - private final String name; - private final String type; - private final URI href; - private final ReferenceType org; - @Nullable - private final String description; - private final List tasks = Lists.newArrayList(); - private final boolean published; - private final boolean readOnly; - - public CatalogImpl(String name, String type, URI href, ReferenceType org, @Nullable String description, - Map contents, Iterable tasks, boolean published, boolean readOnly) { - this.name = checkNotNull(name, "name"); - this.type = checkNotNull(type, "type"); - this.org = org; // TODO: once <1.0 is killed check not null - this.description = description; - this.href = checkNotNull(href, "href"); - putAll(checkNotNull(contents, "contents")); - Iterables.addAll(this.tasks, checkNotNull(tasks, "tasks")); - this.published = published; - this.readOnly = readOnly; - } - - /** - * {@inheritDoc} - */ - @Override - public URI getHref() { - return href; - } - - /** - * {@inheritDoc} - */ - @Override - public String getName() { - return name; - } - - /** - * {@inheritDoc} - */ - @Override - public ReferenceType getOrg() { - return org; - } - - /** - * {@inheritDoc} - */ - @Override - public String getDescription() { - return description; - } - - /** - * {@inheritDoc} - */ - @Override - public String getType() { - return type; - } - - /** - * {@inheritDoc} - */ - @Override - public List getTasks() { - return tasks; - } - - /** - * {@inheritDoc} - */ - @Override - public boolean isPublished() { - return published; - } - - /** - * {@inheritDoc} - */ - @Override - public boolean isReadOnly() { - return readOnly; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = super.hashCode(); - result = prime * result + ((description == null) ? 0 : description.hashCode()); - result = prime * result + ((href == null) ? 0 : href.hashCode()); - result = prime * result + ((name == null) ? 0 : name.hashCode()); - result = prime * result + ((org == null) ? 0 : org.hashCode()); - result = prime * result + ((tasks == null) ? 0 : tasks.hashCode()); - result = prime * result + ((type == null) ? 0 : type.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (!super.equals(obj)) - return false; - if (getClass() != obj.getClass()) - return false; - CatalogImpl other = (CatalogImpl) obj; - if (description == null) { - if (other.description != null) - return false; - } else if (!description.equals(other.description)) - return false; - if (href == null) { - if (other.href != null) - return false; - } else if (!href.equals(other.href)) - return false; - if (name == null) { - if (other.name != null) - return false; - } else if (!name.equals(other.name)) - return false; - if (org == null) { - if (other.org != null) - return false; - } else if (!org.equals(other.org)) - return false; - if (tasks == null) { - if (other.tasks != null) - return false; - } else if (!tasks.equals(other.tasks)) - return false; - if (type == null) { - if (other.type != null) - return false; - } else if (!type.equals(other.type)) - return false; - return true; - } - - @Override - public int compareTo(ReferenceType o) { - return (this == o) ? 0 : getHref().compareTo(o.getHref()); - } - -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/internal/CatalogItemImpl.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/internal/CatalogItemImpl.java deleted file mode 100644 index 5cac6ab2a2..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/internal/CatalogItemImpl.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.domain.internal; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.net.URI; -import java.util.Map; - -import org.jclouds.javax.annotation.Nullable; -import org.jclouds.vcloud.VCloudMediaType; -import org.jclouds.vcloud.domain.CatalogItem; -import org.jclouds.vcloud.domain.ReferenceType; - -import com.google.common.collect.Maps; - -public class CatalogItemImpl extends ReferenceTypeImpl implements CatalogItem { - - private final String description; - private final ReferenceType entity; - private final Map properties = Maps.newLinkedHashMap(); - - public CatalogItemImpl(String name, URI id, @Nullable String description, ReferenceType entity, - Map properties) { - super(name, VCloudMediaType.CATALOGITEM_XML, id); - this.description = description; - this.entity = checkNotNull(entity, "entity"); - this.properties.putAll(checkNotNull(properties, "properties")); - } - - @Override - public String getType() { - return VCloudMediaType.CATALOGITEM_XML; - } - - public ReferenceType getEntity() { - return entity; - } - - @Override - public String getDescription() { - return description; - } - - public Map getProperties() { - return properties; - } - - @Override - public String toString() { - return "CatalogItemImpl [id=" + getHref() + ", name=" + getName() + ", type=" + getType() + ", description=" - + getDescription() + ", entity=" + entity + ", properties=" + properties + "]"; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = super.hashCode(); - result = prime * result + ((description == null) ? 0 : description.hashCode()); - result = prime * result + ((entity == null) ? 0 : entity.hashCode()); - result = prime * result + ((properties == null) ? 0 : properties.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (!super.equals(obj)) - return false; - if (getClass() != obj.getClass()) - return false; - CatalogItemImpl other = (CatalogItemImpl) obj; - if (description == null) { - if (other.description != null) - return false; - } else if (!description.equals(other.description)) - return false; - if (entity == null) { - if (other.entity != null) - return false; - } else if (!entity.equals(other.entity)) - return false; - if (properties == null) { - if (other.properties != null) - return false; - } else if (!properties.equals(other.properties)) - return false; - return true; - } - -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/internal/ErrorImpl.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/internal/ErrorImpl.java deleted file mode 100644 index 2550f1bb6f..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/internal/ErrorImpl.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.domain.internal; - -import static com.google.common.base.Preconditions.checkNotNull; - -import org.jclouds.javax.annotation.Nullable; -import org.jclouds.vcloud.domain.VCloudError; - -public class ErrorImpl implements VCloudError { - private final String message; - private final int majorErrorCode; - private final MinorCode minorErrorCode; - @Nullable - private final String vendorSpecificErrorCode; - @Nullable - private final String stackTrace; - - public ErrorImpl(String message, int majorErrorCode, @Nullable MinorCode minorErrorCode, - @Nullable String vendorSpecificErrorCode, @Nullable String stackTrace) { - this.message = checkNotNull(message, "message"); - this.majorErrorCode = majorErrorCode; - this.minorErrorCode = minorErrorCode; // check null after 0.8 is gone - this.vendorSpecificErrorCode = vendorSpecificErrorCode; - this.stackTrace = stackTrace; - } - - public String getMessage() { - return message; - } - - public int getMajorErrorCode() { - return majorErrorCode; - } - - public MinorCode getMinorErrorCode() { - return minorErrorCode; - } - - public String getVendorSpecificErrorCode() { - return vendorSpecificErrorCode; - } - - public String getStackTrace() { - return stackTrace; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + majorErrorCode; - result = prime * result + ((message == null) ? 0 : message.hashCode()); - result = prime * result + ((minorErrorCode == null) ? 0 : minorErrorCode.hashCode()); - result = prime * result + ((stackTrace == null) ? 0 : stackTrace.hashCode()); - result = prime * result + ((vendorSpecificErrorCode == null) ? 0 : vendorSpecificErrorCode.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; - ErrorImpl other = (ErrorImpl) obj; - if (majorErrorCode != other.majorErrorCode) - return false; - if (message == null) { - if (other.message != null) - return false; - } else if (!message.equals(other.message)) - return false; - if (minorErrorCode == null) { - if (other.minorErrorCode != null) - return false; - } else if (!minorErrorCode.equals(other.minorErrorCode)) - return false; - if (stackTrace == null) { - if (other.stackTrace != null) - return false; - } else if (!stackTrace.equals(other.stackTrace)) - return false; - if (vendorSpecificErrorCode == null) { - if (other.vendorSpecificErrorCode != null) - return false; - } else if (!vendorSpecificErrorCode.equals(other.vendorSpecificErrorCode)) - return false; - return true; - } - - @Override - public String toString() { - return "[majorErrorCode=" + majorErrorCode + ", message=" + message + ", minorErrorCode=" + minorErrorCode - + ", stackTrace=" + stackTrace + ", vendorSpecificErrorCode=" + vendorSpecificErrorCode + "]"; - } - -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/internal/OrgImpl.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/internal/OrgImpl.java deleted file mode 100644 index 87327d1e7c..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/internal/OrgImpl.java +++ /dev/null @@ -1,168 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.domain.internal; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.net.URI; -import java.util.List; -import java.util.Map; - -import org.jclouds.javax.annotation.Nullable; -import org.jclouds.vcloud.domain.Org; -import org.jclouds.vcloud.domain.ReferenceType; -import org.jclouds.vcloud.domain.Task; - -import com.google.common.collect.Iterables; -import com.google.common.collect.Lists; -import com.google.common.collect.Maps; - -/** - * Locations of resources in vCloud - */ -public class OrgImpl extends ReferenceTypeImpl implements Org { - private final String fullName; - @Nullable - private final String description; - private final Map catalogs = Maps.newLinkedHashMap(); - private final Map vdcs = Maps.newLinkedHashMap(); - private final Map networks = Maps.newLinkedHashMap(); - private final ReferenceType tasksList; - private final List tasks = Lists.newArrayList(); - - public OrgImpl(String name, String type, URI id, String fullName, String description, - Map catalogs, Map vdcs, Map networks, - @Nullable ReferenceType tasksList, Iterable tasks) { - super(name, type, id); - this.fullName = checkNotNull(fullName, "fullName"); - this.description = description; - this.catalogs.putAll(checkNotNull(catalogs, "catalogs")); - this.vdcs.putAll(checkNotNull(vdcs, "vdcs")); - this.networks.putAll(checkNotNull(networks, "networks")); - this.tasksList = tasksList; - Iterables.addAll(this.tasks, checkNotNull(tasks, "tasks")); - } - - @Override - public String getFullName() { - return fullName; - } - - @Override - public String getDescription() { - return description; - } - - @Override - public Map getCatalogs() { - return catalogs; - } - - @Override - public Map getVDCs() { - return vdcs; - } - - @Override - public Map getNetworks() { - return networks; - } - - @Override - public ReferenceType getTasksList() { - return tasksList; - } - - @Override - public List getTasks() { - return tasks; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = super.hashCode(); - result = prime * result + ((catalogs == null) ? 0 : catalogs.hashCode()); - result = prime * result + ((description == null) ? 0 : description.hashCode()); - result = prime * result + ((fullName == null) ? 0 : fullName.hashCode()); - result = prime * result + ((networks == null) ? 0 : networks.hashCode()); - result = prime * result + ((tasks == null) ? 0 : tasks.hashCode()); - result = prime * result + ((tasksList == null) ? 0 : tasksList.hashCode()); - result = prime * result + ((vdcs == null) ? 0 : vdcs.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (!super.equals(obj)) - return false; - if (getClass() != obj.getClass()) - return false; - OrgImpl other = (OrgImpl) obj; - if (catalogs == null) { - if (other.catalogs != null) - return false; - } else if (!catalogs.equals(other.catalogs)) - return false; - if (description == null) { - if (other.description != null) - return false; - } else if (!description.equals(other.description)) - return false; - if (fullName == null) { - if (other.fullName != null) - return false; - } else if (!fullName.equals(other.fullName)) - return false; - if (networks == null) { - if (other.networks != null) - return false; - } else if (!networks.equals(other.networks)) - return false; - if (tasks == null) { - if (other.tasks != null) - return false; - } else if (!tasks.equals(other.tasks)) - return false; - if (tasksList == null) { - if (other.tasksList != null) - return false; - } else if (!tasksList.equals(other.tasksList)) - return false; - if (vdcs == null) { - if (other.vdcs != null) - return false; - } else if (!vdcs.equals(other.vdcs)) - return false; - return true; - } - - @Override - public int compareTo(ReferenceType o) { - return (this == o) ? 0 : getHref().compareTo(o.getHref()); - } - - @Override - public String toString() { - return "[href=" + getHref() + ", name=" + getName() + ", type=" + getType() + ", fullName=" + fullName - + ", description=" + description + ", catalogs=" + catalogs + ", networks=" + networks + ", tasksList=" - + tasksList + ", vdcs=" + vdcs + ", tasks=" + tasks + "]"; - } - -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/internal/ReferenceTypeImpl.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/internal/ReferenceTypeImpl.java deleted file mode 100644 index 4519eba824..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/internal/ReferenceTypeImpl.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.domain.internal; - -import static com.google.common.base.Objects.equal; - -import java.net.URI; - -import org.jclouds.vcloud.domain.ReferenceType; - -import com.google.common.base.Objects; -import com.google.common.base.Objects.ToStringHelper; - -/** - * Location of a Rest resource - */ -public class ReferenceTypeImpl implements ReferenceType { - private final String name; - private final String type; - private final URI href; - - public ReferenceTypeImpl(String name, String type, URI href) { - this.name = name; - this.type = type; - this.href = href; - } - - @Override - public String getName() { - return name; - } - - @Override - public String getType() { - return type; - } - - @Override - public URI getHref() { - return href; - } - - @Override - public int compareTo(ReferenceType that) { - return (this == that) ? 0 : getHref().compareTo(that.getHref()); - } - - @Override - public boolean equals(Object o) { - if (this == o) - return true; - if (o == null || getClass() != o.getClass()) - return false; - ReferenceTypeImpl that = ReferenceTypeImpl.class.cast(o); - return equal(this.href, that.href); - } - - @Override - public int hashCode() { - return Objects.hashCode(href); - } - - @Override - public String toString() { - return string().toString(); - } - - protected ToStringHelper string() { - return Objects.toStringHelper("").omitNullValues().add("href", href).add("name", name).add("type", type); - } -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/internal/TaskImpl.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/internal/TaskImpl.java deleted file mode 100644 index 70815a1c5b..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/internal/TaskImpl.java +++ /dev/null @@ -1,160 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.domain.internal; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.net.URI; -import java.util.Date; - -import org.jclouds.javax.annotation.Nullable; -import org.jclouds.vcloud.VCloudMediaType; -import org.jclouds.vcloud.domain.ReferenceType; -import org.jclouds.vcloud.domain.Task; -import org.jclouds.vcloud.domain.TaskStatus; -import org.jclouds.vcloud.domain.VCloudError; - -import com.google.common.base.Objects; - -public class TaskImpl extends ReferenceTypeImpl implements Task { - - private final String operation; - private final TaskStatus status; - private final Date startTime; - @Nullable - private final Date endTime; - @Nullable - private final Date expiryTime; - private final ReferenceType owner; - @Nullable - private final VCloudError error; - - public TaskImpl(URI id, String operation, TaskStatus status, Date startTime, @Nullable Date endTime, - @Nullable Date expiryTime, ReferenceType owner, VCloudError error) { - super(null, VCloudMediaType.TASK_XML, id); - this.operation = operation; - this.status = checkNotNull(status, "status"); - this.startTime = startTime; - this.endTime = endTime; - this.expiryTime = expiryTime; - this.owner = owner; - this.error = error; - } - - @Override - public TaskStatus getStatus() { - return status; - } - - @Override - public Date getStartTime() { - return startTime; - } - - @Override - public ReferenceType getOwner() { - return owner; - } - - @Override - public Date getEndTime() { - return endTime; - } - - @Override - public VCloudError getError() { - return error; - } - - @Override - public String toString() { - return Objects.toStringHelper("").omitNullValues().add("href", getHref()).add("name", getName()) - .add("owner", owner).add("operation", operation).add("startTime", startTime).add("endTime", endTime) - .add("expiryTime", expiryTime).add("error", error).toString(); - } - - public Date getExpiryTime() { - return expiryTime; - } - - @Override - public String getOperation() { - return operation; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = super.hashCode(); - result = prime * result + ((endTime == null) ? 0 : endTime.hashCode()); - result = prime * result + ((error == null) ? 0 : error.hashCode()); - result = prime * result + ((expiryTime == null) ? 0 : expiryTime.hashCode()); - result = prime * result + ((operation == null) ? 0 : operation.hashCode()); - result = prime * result + ((owner == null) ? 0 : owner.hashCode()); - result = prime * result + ((startTime == null) ? 0 : startTime.hashCode()); - result = prime * result + ((status == null) ? 0 : status.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (!super.equals(obj)) - return false; - if (getClass() != obj.getClass()) - return false; - TaskImpl other = (TaskImpl) obj; - if (endTime == null) { - if (other.endTime != null) - return false; - } else if (!endTime.equals(other.endTime)) - return false; - if (error == null) { - if (other.error != null) - return false; - } else if (!error.equals(other.error)) - return false; - if (expiryTime == null) { - if (other.expiryTime != null) - return false; - } else if (!expiryTime.equals(other.expiryTime)) - return false; - if (operation == null) { - if (other.operation != null) - return false; - } else if (!operation.equals(other.operation)) - return false; - if (owner == null) { - if (other.owner != null) - return false; - } else if (!owner.equals(other.owner)) - return false; - if (startTime == null) { - if (other.startTime != null) - return false; - } else if (!startTime.equals(other.startTime)) - return false; - if (status == null) { - if (other.status != null) - return false; - } else if (!status.equals(other.status)) - return false; - return true; - } - -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/internal/TasksListImpl.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/internal/TasksListImpl.java deleted file mode 100644 index 4c8b2c8226..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/internal/TasksListImpl.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.domain.internal; - -import java.net.URI; -import java.util.SortedSet; - -import org.jclouds.vcloud.domain.Task; -import org.jclouds.vcloud.domain.TasksList; - -/** - * Locations of resources in vCloud - */ -public class TasksListImpl implements TasksList { - private final SortedSet tasks; - private final URI id; - - public TasksListImpl(URI id, SortedSet tasks) { - this.id = id; - this.tasks = tasks; - } - - @Override - public SortedSet getTasks() { - return tasks; - } - - @Override - public URI getLocation() { - return id; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((id == null) ? 0 : id.hashCode()); - result = prime * result + ((tasks == null) ? 0 : tasks.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; - TasksListImpl other = (TasksListImpl) obj; - if (id == null) { - if (other.id != null) - return false; - } else if (!id.equals(other.id)) - return false; - if (tasks == null) { - if (other.tasks != null) - return false; - } else if (!tasks.equals(other.tasks)) - return false; - return true; - } - -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/internal/VAppImpl.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/internal/VAppImpl.java deleted file mode 100644 index 95dc6f599a..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/internal/VAppImpl.java +++ /dev/null @@ -1,163 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.domain.internal; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.net.URI; -import java.util.List; -import java.util.Set; - -import org.jclouds.javax.annotation.Nullable; -import org.jclouds.vcloud.domain.ReferenceType; -import org.jclouds.vcloud.domain.Status; -import org.jclouds.vcloud.domain.Task; -import org.jclouds.vcloud.domain.VApp; -import org.jclouds.vcloud.domain.Vm; -import org.jclouds.vcloud.domain.ovf.VCloudNetworkSection; - -import com.google.common.collect.Iterables; -import com.google.common.collect.Lists; -import com.google.common.collect.Sets; - -/** - * Locations of resources in vCloud - */ -public class VAppImpl extends ReferenceTypeImpl implements VApp { - - private final Status status; - private final ReferenceType vdc; - @Nullable - private final String description; - private final List tasks = Lists.newArrayList(); - private final boolean ovfDescriptorUploaded; - private final Set children = Sets.newLinkedHashSet(); - @Nullable - private final VCloudNetworkSection networkSection; - - public VAppImpl(String name, String type, URI id, Status status, ReferenceType vdc, @Nullable String description, - Iterable tasks, boolean ovfDescriptorUploaded, Iterable children, - @Nullable VCloudNetworkSection networkSection) { - super(name, type, id); - this.status = checkNotNull(status, "status"); - this.vdc = vdc; // TODO: once <1.0 is killed check not null - this.description = description; - Iterables.addAll(this.tasks, checkNotNull(tasks, "tasks")); - this.ovfDescriptorUploaded = ovfDescriptorUploaded; - Iterables.addAll(this.children, checkNotNull(children, "children")); - this.networkSection = networkSection; // can be null when copying - } - - /** - * {@inheritDoc} - */ - @Override - public Status getStatus() { - return status; - } - - /** - * {@inheritDoc} - */ - @Override - public ReferenceType getVDC() { - return vdc; - } - - /** - * {@inheritDoc} - */ - @Override - public String getDescription() { - return description; - } - - /** - * {@inheritDoc} - */ - @Override - public List getTasks() { - return tasks; - } - - /** - * {@inheritDoc} - */ - @Override - public boolean isOvfDescriptorUploaded() { - return ovfDescriptorUploaded; - } - - /** - * {@inheritDoc} - */ - @Override - public Set getChildren() { - return children; - } - - /** - * {@inheritDoc} - */ - @Override - public VCloudNetworkSection getNetworkSection() { - return networkSection; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = super.hashCode(); - result = prime * result + ((description == null) ? 0 : description.hashCode()); - result = prime * result + (ovfDescriptorUploaded ? 1231 : 1237); - result = prime * result + ((status == null) ? 0 : status.hashCode()); - result = prime * result + ((tasks == null) ? 0 : tasks.hashCode()); - result = prime * result + ((vdc == null) ? 0 : vdc.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (!super.equals(obj)) - return false; - if (getClass() != obj.getClass()) - return false; - VAppImpl other = (VAppImpl) obj; - if (description == null) { - if (other.description != null) - return false; - } else if (!description.equals(other.description)) - return false; - if (ovfDescriptorUploaded != other.ovfDescriptorUploaded) - return false; - if (vdc == null) { - if (other.vdc != null) - return false; - } else if (!vdc.equals(other.vdc)) - return false; - return true; - } - - @Override - public String toString() { - return "[id=" + getHref() + ", name=" + getName() + ", vdc=" + vdc + ", description=" + description + ", status=" - + status + "]"; - } - -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/internal/VAppTemplateImpl.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/internal/VAppTemplateImpl.java deleted file mode 100644 index c7b35e1089..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/internal/VAppTemplateImpl.java +++ /dev/null @@ -1,202 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.domain.internal; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.net.URI; -import java.util.List; -import java.util.Set; - -import org.jclouds.javax.annotation.Nullable; -import org.jclouds.vcloud.domain.ReferenceType; -import org.jclouds.vcloud.domain.Status; -import org.jclouds.vcloud.domain.Task; -import org.jclouds.vcloud.domain.VAppTemplate; -import org.jclouds.vcloud.domain.Vm; -import org.jclouds.vcloud.domain.ovf.VCloudNetworkSection; - -import com.google.common.collect.Iterables; -import com.google.common.collect.Lists; -import com.google.common.collect.Sets; - -/** - * Locations of resources in vCloud - */ -public class VAppTemplateImpl extends ReferenceTypeImpl implements VAppTemplate { - - private final Status status; - private final ReferenceType vdc; - @Nullable - private final String description; - private final List tasks = Lists.newArrayList(); - private final boolean ovfDescriptorUploaded; - private final String vAppScopedLocalId; - private final Set children = Sets.newLinkedHashSet(); - @Nullable - private final VCloudNetworkSection networkSection; - - public VAppTemplateImpl(String name, String type, URI id, Status status, ReferenceType vdc, - @Nullable String description, Iterable tasks, boolean ovfDescriptorUploaded, - @Nullable String vAppScopedLocalId, Iterable children, - @Nullable VCloudNetworkSection networkSection) { - super(name, type, id); - this.status = checkNotNull(status, "status"); - this.vdc = vdc; // TODO: once <1.0 is killed check not null - this.description = description; - Iterables.addAll(this.tasks, checkNotNull(tasks, "tasks")); - this.vAppScopedLocalId = vAppScopedLocalId; - this.ovfDescriptorUploaded = ovfDescriptorUploaded; - Iterables.addAll(this.children, checkNotNull(children, "children")); - this.networkSection = networkSection; // can be null when copying - } - - /** - * {@inheritDoc} - */ - @Override - public Status getStatus() { - return status; - } - - /** - * {@inheritDoc} - */ - @Override - public ReferenceType getVDC() { - return vdc; - } - - /** - * {@inheritDoc} - */ - @Override - public String getDescription() { - return description; - } - - /** - * {@inheritDoc} - */ - @Override - public List getTasks() { - return tasks; - } - - /** - * {@inheritDoc} - */ - @Override - public String getVAppScopedLocalId() { - return vAppScopedLocalId; - } - - /** - * {@inheritDoc} - */ - @Override - public boolean isOvfDescriptorUploaded() { - return ovfDescriptorUploaded; - } - - /** - * {@inheritDoc} - */ - @Override - public Set getChildren() { - return children; - } - - /** - * {@inheritDoc} - */ - @Override - public VCloudNetworkSection getNetworkSection() { - return networkSection; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = super.hashCode(); - result = prime * result + ((children == null) ? 0 : children.hashCode()); - result = prime * result + ((description == null) ? 0 : description.hashCode()); - result = prime * result + ((networkSection == null) ? 0 : networkSection.hashCode()); - result = prime * result + (ovfDescriptorUploaded ? 1231 : 1237); - result = prime * result + ((status == null) ? 0 : status.hashCode()); - result = prime * result + ((tasks == null) ? 0 : tasks.hashCode()); - result = prime * result + ((vAppScopedLocalId == null) ? 0 : vAppScopedLocalId.hashCode()); - result = prime * result + ((vdc == null) ? 0 : vdc.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (!super.equals(obj)) - return false; - if (getClass() != obj.getClass()) - return false; - VAppTemplateImpl other = (VAppTemplateImpl) obj; - if (children == null) { - if (other.children != null) - return false; - } else if (!children.equals(other.children)) - return false; - if (description == null) { - if (other.description != null) - return false; - } else if (!description.equals(other.description)) - return false; - if (networkSection == null) { - if (other.networkSection != null) - return false; - } else if (!networkSection.equals(other.networkSection)) - return false; - if (ovfDescriptorUploaded != other.ovfDescriptorUploaded) - return false; - if (status == null) { - if (other.status != null) - return false; - } else if (!status.equals(other.status)) - return false; - if (tasks == null) { - if (other.tasks != null) - return false; - } else if (!tasks.equals(other.tasks)) - return false; - if (vAppScopedLocalId == null) { - if (other.vAppScopedLocalId != null) - return false; - } else if (!vAppScopedLocalId.equals(other.vAppScopedLocalId)) - return false; - if (vdc == null) { - if (other.vdc != null) - return false; - } else if (!vdc.equals(other.vdc)) - return false; - return true; - } - - @Override - public String toString() { - return "[id=" + getHref() + ", name=" + getName() + ", vdc=" + vdc + ", description=" + description + ", status=" - + status + "]"; - } - -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/internal/VDCImpl.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/internal/VDCImpl.java deleted file mode 100644 index f68c486861..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/internal/VDCImpl.java +++ /dev/null @@ -1,289 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.domain.internal; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.net.URI; -import java.util.List; -import java.util.Map; - -import org.jclouds.javax.annotation.Nullable; -import org.jclouds.vcloud.domain.AllocationModel; -import org.jclouds.vcloud.domain.Capacity; -import org.jclouds.vcloud.domain.ReferenceType; -import org.jclouds.vcloud.domain.Task; -import org.jclouds.vcloud.domain.VDC; -import org.jclouds.vcloud.domain.VDCStatus; - -import com.google.common.collect.Iterables; -import com.google.common.collect.Lists; -import com.google.common.collect.Maps; - -/** - * Locations of resources in vCloud - */ -public class VDCImpl extends ReferenceTypeImpl implements VDC { - - private final VDCStatus status; - private final ReferenceType org; - @Nullable - private final String description; - private final List tasks = Lists.newArrayList(); - private final AllocationModel allocationModel; - private final Capacity storageCapacity; - private final Capacity cpuCapacity; - private final Capacity memoryCapacity; - private final Map resourceEntities = Maps.newLinkedHashMap(); - private final Map availableNetworks = Maps.newLinkedHashMap(); - private final int nicQuota; - private final int networkQuota; - private final int vmQuota; - private final boolean isEnabled; - - public VDCImpl(String name, String type, URI id, VDCStatus status, ReferenceType org, @Nullable String description, - Iterable tasks, AllocationModel allocationModel, @Nullable Capacity storageCapacity, - @Nullable Capacity cpuCapacity, @Nullable Capacity memoryCapacity, - Map resourceEntities, Map availableNetworks, int nicQuota, - int networkQuota, int vmQuota, boolean isEnabled) { - super(name, type, id); - this.status = checkNotNull(status, "status"); - this.org = org; // TODO: once <1.0 is killed check not null - this.description = description; - Iterables.addAll(this.tasks, checkNotNull(tasks, "tasks")); - this.allocationModel = checkNotNull(allocationModel, "allocationModel"); - this.storageCapacity = storageCapacity; // TODO: once <1.0 is killed check not null - this.cpuCapacity = cpuCapacity; // TODO: once <1.0 is killed check not null - this.memoryCapacity = memoryCapacity; // TODO: once <1.0 is killed check not null - this.resourceEntities.putAll(checkNotNull(resourceEntities, "resourceEntities")); - this.availableNetworks.putAll(checkNotNull(availableNetworks, "availableNetworks")); - this.nicQuota = nicQuota; - this.networkQuota = networkQuota; - this.vmQuota = vmQuota; - this.isEnabled = isEnabled; - } - - /** - * {@inheritDoc} - */ - @Override - public VDCStatus getStatus() { - return status; - } - - /** - * {@inheritDoc} - */ - @Override - public ReferenceType getOrg() { - return org; - } - - /** - * {@inheritDoc} - */ - @Override - public String getDescription() { - return description; - } - - /** - * {@inheritDoc} - */ - @Override - public List getTasks() { - return tasks; - } - - /** - * {@inheritDoc} - */ - @Override - public AllocationModel getAllocationModel() { - return allocationModel; - } - - /** - * {@inheritDoc} - */ - @Override - public Capacity getStorageCapacity() { - return storageCapacity; - } - - /** - * {@inheritDoc} - */ - @Override - public Capacity getCpuCapacity() { - return cpuCapacity; - } - - /** - * {@inheritDoc} - */ - @Override - public Capacity getMemoryCapacity() { - return memoryCapacity; - } - - /** - * {@inheritDoc} - */ - @Override - public Map getResourceEntities() { - return resourceEntities; - } - - /** - * {@inheritDoc} - */ - @Override - public Map getAvailableNetworks() { - return availableNetworks; - } - - /** - * {@inheritDoc} - */ - @Override - public int getNicQuota() { - return nicQuota; - } - - /** - * {@inheritDoc} - */ - @Override - public int getNetworkQuota() { - return networkQuota; - } - - /** - * {@inheritDoc} - */ - @Override - public int getVmQuota() { - return vmQuota; - } - - /** - * {@inheritDoc} - */ - @Override - public boolean isEnabled() { - return isEnabled; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = super.hashCode(); - result = prime * result + ((allocationModel == null) ? 0 : allocationModel.hashCode()); - result = prime * result + ((availableNetworks == null) ? 0 : availableNetworks.hashCode()); - result = prime * result + ((cpuCapacity == null) ? 0 : cpuCapacity.hashCode()); - result = prime * result + ((description == null) ? 0 : description.hashCode()); - result = prime * result + (isEnabled ? 1231 : 1237); - result = prime * result + ((memoryCapacity == null) ? 0 : memoryCapacity.hashCode()); - result = prime * result + networkQuota; - result = prime * result + nicQuota; - result = prime * result + ((org == null) ? 0 : org.hashCode()); - result = prime * result + ((resourceEntities == null) ? 0 : resourceEntities.hashCode()); - result = prime * result + ((status == null) ? 0 : status.hashCode()); - result = prime * result + ((storageCapacity == null) ? 0 : storageCapacity.hashCode()); - result = prime * result + ((tasks == null) ? 0 : tasks.hashCode()); - result = prime * result + vmQuota; - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (!super.equals(obj)) - return false; - if (getClass() != obj.getClass()) - return false; - VDCImpl other = (VDCImpl) obj; - if (allocationModel == null) { - if (other.allocationModel != null) - return false; - } else if (!allocationModel.equals(other.allocationModel)) - return false; - if (availableNetworks == null) { - if (other.availableNetworks != null) - return false; - } else if (!availableNetworks.equals(other.availableNetworks)) - return false; - if (cpuCapacity == null) { - if (other.cpuCapacity != null) - return false; - } else if (!cpuCapacity.equals(other.cpuCapacity)) - return false; - if (description == null) { - if (other.description != null) - return false; - } else if (!description.equals(other.description)) - return false; - if (isEnabled != other.isEnabled) - return false; - if (memoryCapacity == null) { - if (other.memoryCapacity != null) - return false; - } else if (!memoryCapacity.equals(other.memoryCapacity)) - return false; - if (networkQuota != other.networkQuota) - return false; - if (nicQuota != other.nicQuota) - return false; - if (org == null) { - if (other.org != null) - return false; - } else if (!org.equals(other.org)) - return false; - if (resourceEntities == null) { - if (other.resourceEntities != null) - return false; - } else if (!resourceEntities.equals(other.resourceEntities)) - return false; - if (status == null) { - if (other.status != null) - return false; - } else if (!status.equals(other.status)) - return false; - if (storageCapacity == null) { - if (other.storageCapacity != null) - return false; - } else if (!storageCapacity.equals(other.storageCapacity)) - return false; - if (tasks == null) { - if (other.tasks != null) - return false; - } else if (!tasks.equals(other.tasks)) - return false; - if (vmQuota != other.vmQuota) - return false; - return true; - } - - @Override - public String toString() { - return "[id=" + getHref() + ", name=" + getName() + ", org=" + org + ", description=" + description + ", status=" - + status + ", isEnabled=" + isEnabled + "]"; - } - -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/internal/VmImpl.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/internal/VmImpl.java deleted file mode 100644 index 00ea089b20..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/internal/VmImpl.java +++ /dev/null @@ -1,214 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.domain.internal; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.net.URI; -import java.util.List; - -import org.jclouds.javax.annotation.Nullable; -import org.jclouds.vcloud.domain.GuestCustomizationSection; -import org.jclouds.vcloud.domain.NetworkConnectionSection; -import org.jclouds.vcloud.domain.ReferenceType; -import org.jclouds.vcloud.domain.Status; -import org.jclouds.vcloud.domain.Task; -import org.jclouds.vcloud.domain.Vm; -import org.jclouds.vcloud.domain.ovf.VCloudOperatingSystemSection; -import org.jclouds.vcloud.domain.ovf.VCloudVirtualHardwareSection; - -import com.google.common.collect.Iterables; -import com.google.common.collect.Lists; - -/** - * Locations of resources in vCloud - */ -public class VmImpl extends ReferenceTypeImpl implements Vm { - - @Nullable - private final Status status; - private final ReferenceType vApp; - @Nullable - private final String description; - private final List tasks = Lists.newArrayList(); - @Nullable - private final VCloudVirtualHardwareSection hardware; - private final String vAppScopedLocalId; - private final VCloudOperatingSystemSection os; - @Nullable - private final GuestCustomizationSection guestCustomization; - @Nullable - private final NetworkConnectionSection networkConnectionSection; - - public VmImpl(String name, String type, URI id, @Nullable Status status, ReferenceType vApp, - @Nullable String description, Iterable tasks, @Nullable VCloudVirtualHardwareSection hardware, - @Nullable VCloudOperatingSystemSection os, @Nullable NetworkConnectionSection networkConnectionSection, - @Nullable GuestCustomizationSection guestCustomization, @Nullable String vAppScopedLocalId) { - super(name, type, id); - this.status = status; - this.vApp = vApp; // TODO: once <1.0 is killed check not null - this.description = description; - Iterables.addAll(this.tasks, checkNotNull(tasks, "tasks")); - this.hardware = hardware; - this.os = os; - this.networkConnectionSection = networkConnectionSection; - this.guestCustomization = guestCustomization; - this.vAppScopedLocalId = vAppScopedLocalId; - } - - /** - * {@inheritDoc} - */ - @Override - @Nullable - public Status getStatus() { - return status; - } - - /** - * {@inheritDoc} - */ - @Override - public ReferenceType getParent() { - return vApp; - } - - /** - * {@inheritDoc} - */ - @Override - public String getDescription() { - return description; - } - - /** - * {@inheritDoc} - */ - @Override - public List getTasks() { - return tasks; - } - - /** - * {@inheritDoc} - */ - @Override - public VCloudVirtualHardwareSection getVirtualHardwareSection() { - return hardware; - } - - /** - * {@inheritDoc} - */ - @Override - public VCloudOperatingSystemSection getOperatingSystemSection() { - return os; - } - - /** - * {@inheritDoc} - */ - @Override - public NetworkConnectionSection getNetworkConnectionSection() { - return networkConnectionSection; - } - - /** - * {@inheritDoc} - */ - @Override - public GuestCustomizationSection getGuestCustomizationSection() { - return guestCustomization; - } - - /** - * {@inheritDoc} - */ - @Override - public String getVAppScopedLocalId() { - return vAppScopedLocalId; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = super.hashCode(); - result = prime * result + ((description == null) ? 0 : description.hashCode()); - result = prime * result + ((guestCustomization == null) ? 0 : guestCustomization.hashCode()); - result = prime * result + ((hardware == null) ? 0 : hardware.hashCode()); - result = prime * result + ((networkConnectionSection == null) ? 0 : networkConnectionSection.hashCode()); - result = prime * result + ((os == null) ? 0 : os.hashCode()); - result = prime * result + ((vApp == null) ? 0 : vApp.hashCode()); - result = prime * result + ((vAppScopedLocalId == null) ? 0 : vAppScopedLocalId.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (!super.equals(obj)) - return false; - if (getClass() != obj.getClass()) - return false; - VmImpl other = (VmImpl) obj; - if (description == null) { - if (other.description != null) - return false; - } else if (!description.equals(other.description)) - return false; - if (guestCustomization == null) { - if (other.guestCustomization != null) - return false; - } else if (!guestCustomization.equals(other.guestCustomization)) - return false; - if (hardware == null) { - if (other.hardware != null) - return false; - } else if (!hardware.equals(other.hardware)) - return false; - if (networkConnectionSection == null) { - if (other.networkConnectionSection != null) - return false; - } else if (!networkConnectionSection.equals(other.networkConnectionSection)) - return false; - if (os == null) { - if (other.os != null) - return false; - } else if (!os.equals(other.os)) - return false; - if (vApp == null) { - if (other.vApp != null) - return false; - } else if (!vApp.equals(other.vApp)) - return false; - if (vAppScopedLocalId == null) { - if (other.vAppScopedLocalId != null) - return false; - } else if (!vAppScopedLocalId.equals(other.vAppScopedLocalId)) - return false; - return true; - } - - @Override - public String toString() { - return "[href=" + getHref() + ", name=" + getName() + ", type=" + getType() + ", description=" + description - + ", status=" + status + ", tasks=" + tasks + ", vApp=" + vApp + ", hardware=" + hardware + ", os=" + os - + ", network=" + networkConnectionSection + ", vAppScopedLocalId=" + vAppScopedLocalId + "]"; - } - -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/network/DhcpService.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/network/DhcpService.java deleted file mode 100644 index 628a7d1b3b..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/network/DhcpService.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.domain.network; - -import static com.google.common.base.Objects.equal; - -import org.jclouds.javax.annotation.Nullable; - -import com.google.common.base.Objects; - -/** - * specifies the properties of the network’s DHCP service - */ -public class DhcpService { - private final boolean enabled; - @Nullable - private final Integer defaultLeaseTime; - @Nullable - private final Integer maxLeaseTime; - @Nullable - private final IpRange ipRange; - - public DhcpService(boolean enabled, @Nullable Integer defaultLeaseTime, @Nullable Integer maxLeaseTime, - @Nullable IpRange ipRange) { - this.enabled = enabled; - this.defaultLeaseTime = defaultLeaseTime; - this.maxLeaseTime = maxLeaseTime; - this.ipRange = ipRange; - } - - /** - * @return true if the service is enabled - * - * @since vcloud api 0.8 - */ - public boolean isEnabled() { - return enabled; - } - - /** - * default duration of a DHCP address lease - * - * @since vcloud api 0.9 - */ - @Nullable - public Integer getDefaultLeaseTime() { - return defaultLeaseTime; - } - - /** - * maximum duration of a DHCP address lease. - * - * @since vcloud api 0.9 - */ - @Nullable - public Integer getMaxLeaseTime() { - return maxLeaseTime; - } - - /** - * @return range of IP addresses available to DHCP clients - * - * @since vcloud api 0.9 - */ - @Nullable - public IpRange getIpRange() { - return ipRange; - } - - @Override - public boolean equals(Object o) { - if (this == o) - return true; - if (o == null || getClass() != o.getClass()) - return false; - DhcpService that = DhcpService.class.cast(o); - return equal(this.enabled, that.enabled) && equal(this.defaultLeaseTime, that.defaultLeaseTime) - && equal(this.maxLeaseTime, that.maxLeaseTime) && equal(this.ipRange, that.ipRange); - } - - @Override - public int hashCode() { - return Objects.hashCode(enabled, defaultLeaseTime, maxLeaseTime, ipRange); - } - - @Override - public String toString() { - return Objects.toStringHelper("").omitNullValues().add("enabled", enabled) - .add("defaultLeaseTime", defaultLeaseTime).add("maxLeaseTime", maxLeaseTime).add("ipRange", ipRange) - .toString(); - } -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/network/Features.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/network/Features.java deleted file mode 100644 index 24eb38e3fd..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/network/Features.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.domain.network; - -import static com.google.common.base.Objects.equal; - -import org.jclouds.javax.annotation.Nullable; - -import com.google.common.base.Objects; - -/** - * The Features element defines the DHCP and firewall features of a network. - */ -public class Features { - @Nullable - private final DhcpService dhcpService; - @Nullable - private final FirewallService firewallService; - @Nullable - private final NatService natService; - - public Features(@Nullable DhcpService dhcpService, @Nullable FirewallService firewallService, - @Nullable NatService natService) { - this.dhcpService = dhcpService; - this.firewallService = firewallService; - this.natService = natService; - } - - /** - * specifies the properties of the network’s DHCP service - * - * @since vcloud api 0.9, but emulated for 0.8 - */ - @Nullable - public DhcpService getDhcpService() { - return dhcpService; - } - - /** - * defines the firewall service capabilities of the network - * - * @since vcloud api 0.8 - */ - @Nullable - public FirewallService getFirewallService() { - return firewallService; - } - - /** - * defines the NAT service capabilities of the network - * - * @since vcloud api 0.8 - */ - @Nullable - public NatService getNatService() { - return natService; - } - - @Override - public boolean equals(Object o) { - if (this == o) - return true; - if (o == null || getClass() != o.getClass()) - return false; - Features that = Features.class.cast(o); - return equal(this.dhcpService, that.dhcpService) && equal(this.firewallService, that.firewallService) - && equal(this.natService, that.natService); - } - - @Override - public int hashCode() { - return Objects.hashCode(dhcpService, firewallService, natService); - } - - @Override - public String toString() { - return Objects.toStringHelper("").omitNullValues().add("dhcpService", dhcpService) - .add("firewallService", firewallService).add("natService", natService).toString(); - } - -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/network/FenceMode.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/network/FenceMode.java deleted file mode 100644 index a531b0d415..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/network/FenceMode.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.domain.network; - -import static com.google.common.base.Preconditions.checkNotNull; - -import com.google.common.base.CaseFormat; - -/** - * - * The FenceMode element contains one of the following strings that specify how a network is - * connected to its parent network. - */ -public enum FenceMode { - /** - * The two networks are bridged. - *

- * Note that in vcloud 0.8 this was called ALLOW_IN_OUT, and so our implementation automatically - * converts this for you. Use bridged instead of allowInOut. - * - * @since vcloud api 0.9 - */ - BRIDGED, - /** - * The two networks are not connected. - * - * @since vcloud api 0.8 - */ - ISOLATED, - /** - * The two networks are connected as specified in their NatService elements. - * - * @since vcloud api 0.8 - */ - NAT_ROUTED, UNRECOGNIZED; - - public String value() { - return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, name()); - } - - @Override - public String toString() { - return value(); - } - - public static FenceMode fromValue(String fenceMode) { - try { - return valueOf(CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, checkNotNull(fenceMode, "fenceMode"))); - } catch (IllegalArgumentException e) { - return UNRECOGNIZED; - } - } - -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/network/FirewallService.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/network/FirewallService.java deleted file mode 100644 index bde3a216e6..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/network/FirewallService.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.domain.network; - -import static com.google.common.base.Objects.equal; -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.List; - -import org.jclouds.javax.annotation.Nullable; -import org.jclouds.vcloud.domain.network.firewall.FirewallRule; - -import com.google.common.base.Objects; -import com.google.common.base.Objects.ToStringHelper; -import com.google.common.collect.Iterables; -import com.google.common.collect.Lists; - -/** - * The FirewallService element defines the firewall service capabilities of a network. - */ -public class FirewallService { - private final boolean enabled; - - List firewallRules = Lists.newArrayList(); - - public FirewallService(boolean enabled, Iterable firewallRules) { - this.enabled = enabled; - Iterables.addAll(this.firewallRules, checkNotNull(firewallRules, "firewallRules")); - } - - /** - * @return Firewall rules for the network - * - * @since vcloud api 0.8 - */ - public List getFirewallRules() { - return firewallRules; - } - - /** - * @return true if the service is enabled - * - * @since vcloud api 0.9 - */ - @Nullable - public boolean isEnabled() { - return enabled; - } - - @Override - public boolean equals(Object o) { - if (this == o) - return true; - if (o == null || getClass() != o.getClass()) - return false; - FirewallService that = FirewallService.class.cast(o); - return equal(this.enabled, that.enabled) && equal(this.firewallRules, that.firewallRules); - } - - @Override - public int hashCode() { - return Objects.hashCode(enabled, firewallRules); - } - - @Override - public String toString() { - ToStringHelper helper = Objects.toStringHelper("").omitNullValues().add("enabled", enabled); - if (!firewallRules.isEmpty()) - helper.add("firewallRules", firewallRules); - return helper.toString(); - } -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/network/IpAddressAllocationMode.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/network/IpAddressAllocationMode.java deleted file mode 100644 index 2b32691cfd..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/network/IpAddressAllocationMode.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.domain.network; - - -/** - * - * The IpAddressAllocationMode element specifies how an IP address is allocated to this connection. - */ -public enum IpAddressAllocationMode { - /** - * no IP addressing mode specified - * - * @since vcloud api 1.0 - */ - NONE, - /** - * static IP address assigned manually - * - * @since vcloud api 1.0 - */ - MANUAL, - /** - * static IP address allocated from a pool - * - * @since vcloud api 1.0 - */ - POOL, - /** - * IP address assigned by DHCP - * - * @since vcloud api 1.0 - */ - DHCP; - -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/network/IpRange.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/network/IpRange.java deleted file mode 100644 index 180d13dbc7..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/network/IpRange.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.domain.network; - -import static com.google.common.base.Objects.equal; -import static com.google.common.base.Preconditions.checkNotNull; - -import com.google.common.base.Objects; - -/** - * The IpRange element defines a range of IP addresses available on a network. - */ -public class IpRange { - private final String startAddress; - private final String endAddress; - - public IpRange(String startAddress, String endAddress) { - this.startAddress = checkNotNull(startAddress, "startAddress"); - this.endAddress = checkNotNull(endAddress, "endAddress"); - } - - /** - * @return lowest IP address in the range - * - * @since vcloud api 0.9 - */ - public String getStartAddress() { - return startAddress; - } - - /** - * @return highest IP address in the range - * - * @since vcloud api 0.9 - */ - public String getEndAddress() { - return endAddress; - } - - @Override - public boolean equals(Object o) { - if (this == o) - return true; - if (o == null || getClass() != o.getClass()) - return false; - IpRange that = IpRange.class.cast(o); - return equal(this.startAddress, that.startAddress) && equal(this.endAddress, that.endAddress); - } - - @Override - public int hashCode() { - return Objects.hashCode(startAddress, endAddress); - } - - @Override - public String toString() { - return Objects.toStringHelper("").omitNullValues().add("startAddress", startAddress) - .add("endAddress", endAddress).toString(); - } - -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/network/IpScope.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/network/IpScope.java deleted file mode 100644 index 13cd9bb0bc..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/network/IpScope.java +++ /dev/null @@ -1,169 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.domain.network; - -import static com.google.common.base.Objects.equal; -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.Set; - -import org.jclouds.javax.annotation.Nullable; - -import com.google.common.base.Objects; -import com.google.common.base.Objects.ToStringHelper; -import com.google.common.collect.Iterables; -import com.google.common.collect.Sets; - -/** - * The IpScope element defines the address range, gateway, netmask, and other properties of the - * network. - */ -public class IpScope { - private final boolean inherited; - @Nullable - private final String gateway; - @Nullable - private final String netmask; - @Nullable - private final String dns1; - @Nullable - private final String dns2; - @Nullable - private final String dnsSuffix; - private final Set ipRanges = Sets.newLinkedHashSet(); - private final Set allocatedIpAddresses = Sets.newLinkedHashSet(); - - public IpScope(boolean inherited, @Nullable String gateway, @Nullable String netmask, @Nullable String dns1, - @Nullable String dns2, @Nullable String dnsSuffix, Iterable ipRanges, - Iterable allocatedIpAddresses) { - this.inherited = inherited; - this.gateway = gateway; - this.netmask = netmask; - this.dns1 = dns1; - this.dns2 = dns2; - this.dnsSuffix = dnsSuffix; - Iterables.addAll(this.ipRanges, checkNotNull(ipRanges, "ipRanges")); - Iterables.addAll(this.allocatedIpAddresses, checkNotNull(allocatedIpAddresses, "allocatedIpAddresses")); - } - - /** - * @return true of the values in this IpScope element are inherited from the ParentNetwork of the - * containing Configuration - * @since vcloud api 0.9 - */ - public boolean isInherited() { - return inherited; - } - - /** - * @return IP address of the network gateway - * - * @since vcloud api 0.8 - */ - @Nullable - public String getGateway() { - return gateway; - } - - /** - * @return netmask to apply to addresses on the network - * - * @since vcloud api 0.8 - */ - @Nullable - public String getNetmask() { - return netmask; - } - - /** - * @return IP address of the primary DNS server for this network - * - * @since vcloud api 0.9 - */ - @Nullable - public String getDns1() { - return dns1; - } - - /** - * @return IP address of the secondary DNS server for this network - * - * @since vcloud api 0.9 - */ - @Nullable - public String getDns2() { - return dns2; - } - - /** - * @return suffix to be applied when resolving hostnames that are not fully‐qualified. - * - * @since vcloud api 0.9 - */ - @Nullable - public String getDnsSuffix() { - return dnsSuffix; - } - - /** - * @return A container for IpRange elements. - * - * @since vcloud api 0.9 - */ - public Set getIpRanges() { - return ipRanges; - } - - /** - * @return A list of addresses allocated from any of the specified IpRanges - * - * @since vcloud api 0.9 - */ - public Set getAllocatedIpAddresses() { - return allocatedIpAddresses; - } - - @Override - public boolean equals(Object o) { - if (this == o) - return true; - if (o == null || getClass() != o.getClass()) - return false; - IpScope that = IpScope.class.cast(o); - return equal(this.inherited, that.inherited) && equal(this.gateway, that.gateway) - && equal(this.netmask, that.netmask) && equal(this.dns1, that.dns1) && equal(this.dns2, that.dns2) - && equal(this.dnsSuffix, that.dnsSuffix) - && equal(this.ipRanges, that.ipRanges) - && equal(this.allocatedIpAddresses, that.allocatedIpAddresses); - } - - @Override - public int hashCode() { - return Objects.hashCode(inherited, gateway, netmask, dns1, dns2, dnsSuffix, ipRanges, allocatedIpAddresses); - } - - @Override - public String toString() { - ToStringHelper helper = Objects.toStringHelper("").omitNullValues().add("inherited", inherited).add("gateway", gateway) - .add("netmask", netmask).add("dns1", dns1).add("dns2", dns2).add("dnsSuffix", dnsSuffix); - if (!ipRanges.isEmpty()) - helper.add("ipRanges", ipRanges); - if (!allocatedIpAddresses.isEmpty()) - helper.add("allocatedIpAddresses", allocatedIpAddresses); - return helper.toString(); - } -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/network/NatService.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/network/NatService.java deleted file mode 100644 index 14e0251eee..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/network/NatService.java +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.domain.network; - -import static com.google.common.base.Objects.equal; -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.List; - -import org.jclouds.javax.annotation.Nullable; -import org.jclouds.vcloud.domain.network.nat.NatPolicy; -import org.jclouds.vcloud.domain.network.nat.NatRule; -import org.jclouds.vcloud.domain.network.nat.NatType; - -import com.google.common.base.Objects; -import com.google.common.base.Objects.ToStringHelper; -import com.google.common.collect.Iterables; -import com.google.common.collect.Lists; - -/** - * The NatService element defines the network address translation capabilities of a network. - */ -public class NatService { - private final boolean enabled; - @Nullable - private final NatType type; - @Nullable - private final NatPolicy policy; - private final List natRules = Lists.newArrayList(); - - public NatService(boolean enabled, @Nullable NatType type, @Nullable NatPolicy policy, - Iterable natRules) { - this.enabled = enabled; - this.type = type; - this.policy = policy; - Iterables.addAll(this.natRules, checkNotNull(natRules, "natRules")); - } - - /** - * @return Nat rules for the network - * - * @since vcloud api 0.8 - */ - public List getNatRules() { - return natRules; - } - - /** - * @return true if the service is enabled - * - * @since vcloud api 0.9 - */ - public boolean isEnabled() { - return enabled; - } - - /** - * @return specifies how Network Address Translation is implemented by the NAT service - * - * @since vcloud api 0.9 - */ - @Nullable - public NatType getType() { - return type; - } - - /** - * @return specifies how packets are handled by the NAT service. - * - * @since vcloud api 0.9 - */ - @Nullable - public NatPolicy getPolicy() { - return policy; - } - - @Override - public boolean equals(Object o) { - if (this == o) - return true; - if (o == null || getClass() != o.getClass()) - return false; - NatService that = NatService.class.cast(o); - return equal(this.enabled, that.enabled) && equal(this.type, that.type) - && equal(this.policy, that.policy) && equal(this.natRules, that.natRules); - } - - @Override - public int hashCode() { - return Objects.hashCode(enabled, type, policy, natRules); - } - - @Override - public String toString() { - ToStringHelper helper = Objects.toStringHelper("").omitNullValues().add("enabled", enabled) - .add("type", type).add("policy", policy); - if (!natRules.isEmpty()) - helper.add("natRules", natRules); - return helper.toString(); - } -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/network/NetworkConfig.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/network/NetworkConfig.java deleted file mode 100644 index 79e6461b17..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/network/NetworkConfig.java +++ /dev/null @@ -1,163 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.domain.network; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.net.URI; - -import org.jclouds.javax.annotation.Nullable; - -public class NetworkConfig { - - public Builder toBuilder() { - return builder().fromNetworkConfig(this); - } - - public static Builder builder() { - return new Builder(); - } - - public static class Builder { - private String networkName; - private URI parentNetwork; - private FenceMode fenceMode; - - public Builder networkName(String networkName) { - this.networkName = networkName; - return this; - } - - public Builder parentNetwork(URI parentNetwork) { - this.parentNetwork = parentNetwork; - return this; - } - - public Builder fenceMode(FenceMode fenceMode) { - this.fenceMode = fenceMode; - return this; - } - - public Builder fromNetworkConfig(NetworkConfig in) { - return networkName(in.getNetworkName()).parentNetwork(in.getParentNetwork()).fenceMode(in.getFenceMode()); - } - - public NetworkConfig build() { - return new NetworkConfig(networkName, parentNetwork, fenceMode); - } - } - - @Nullable - private final String networkName; - private final URI parentNetwork; - @Nullable - private final FenceMode fenceMode; - - /** - * - * Create a new NetworkConfig. - * - * @param networkName - * a valid {@networkConfig - * org.jclouds.vcloud.domain.VAppTemplate#getNetworkSection network in the vapp - * template}, or null to have us choose default - * @param parentNetwork - * a valid {@networkConfig org.jclouds.vcloud.domain.Org#getNetworks in - * the Org} - * @param fenceMode - * how to manage the relationship between the two networks - */ - public NetworkConfig(String networkName, URI parentNetwork, FenceMode fenceMode) { - this.networkName = networkName; - this.parentNetwork = checkNotNull(parentNetwork, "parentNetwork"); - this.fenceMode = fenceMode; - } - - public NetworkConfig(URI parentNetwork) { - this(null, parentNetwork, null); - } - - /** - * A name for the network. If the - * {@link org.jclouds.vcloud.domain.VAppTemplate#getNetworkSection} includes a - * {@link NetworkSection.Network} network element, the name you specify for the vApp network must - * match the name specified in that element’s name attribute. - * - * @return - */ - public String getNetworkName() { - return networkName; - } - - /** - * - * @return A reference to the organization network to which this network connects. - */ - public URI getParentNetwork() { - return parentNetwork; - } - - /** - * A value of bridged indicates that this vApp network is connected directly to the organization - * network. - */ - public FenceMode getFenceMode() { - return fenceMode; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((fenceMode == null) ? 0 : fenceMode.hashCode()); - result = prime * result + ((parentNetwork == null) ? 0 : parentNetwork.hashCode()); - result = prime * result + ((networkName == null) ? 0 : networkName.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; - NetworkConfig other = (NetworkConfig) obj; - if (fenceMode == null) { - if (other.fenceMode != null) - return false; - } else if (!fenceMode.equals(other.fenceMode)) - return false; - if (parentNetwork == null) { - if (other.parentNetwork != null) - return false; - } else if (!parentNetwork.equals(other.parentNetwork)) - return false; - if (networkName == null) { - if (other.networkName != null) - return false; - } else if (!networkName.equals(other.networkName)) - return false; - return true; - } - - @Override - public String toString() { - return "[networkName=" + networkName + ", parentNetwork=" + parentNetwork + ", fenceMode=" + fenceMode + "]"; - } -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/network/OrgNetwork.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/network/OrgNetwork.java deleted file mode 100644 index f50d18cd06..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/network/OrgNetwork.java +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.domain.network; - -import java.util.List; -import java.util.Set; - -import org.jclouds.javax.annotation.Nullable; -import org.jclouds.vcloud.domain.ReferenceType; -import org.jclouds.vcloud.domain.Task; -import org.jclouds.vcloud.domain.network.internal.OrgNetworkImpl; - -import com.google.inject.ImplementedBy; - -/** - * A vDC is a deployment environment for vApps. A Vdc element provides a user view of a vDC. - */ -@org.jclouds.vcloud.endpoints.Network -@ImplementedBy(OrgNetworkImpl.class) -public interface OrgNetwork extends ReferenceType { - /** - * The org this network belongs to. - * - * @since vcloud api 0.9 - */ - @Nullable - ReferenceType getOrg(); - - /** - * optional description - * - * @since vcloud api 0.8 - */ - @Nullable - String getDescription(); - - /** - * read‐only container for Task elements. Each element in the container represents a queued, - * running, or failed task owned by this object. - * - * @since vcloud api 0.9 - */ - List getTasks(); - - /** - * - * @return properties of the network - * - * @since vcloud api 0.9, but emulated for 0.8 - */ - Configuration getConfiguration(); - - /** - * A reference the network pool from which this network is provisioned. This element, which is - * required when creating a NatRouted or Isolated network, is returned in response to a creation - * request but not shown in subsequent GET requests. - * - * @since vcloud api 0.9 - */ - @Nullable - ReferenceType getNetworkPool(); - - /** - * list of external IP addresses that this network can use for NAT. - * - * @since vcloud api 0.9 - */ - Set getAllowedExternalIpAddresses(); - - /** - * The Configuration element specifies properties of a network. - */ - interface Configuration { - /** - * defines the address range, gateway, netmask, and other properties of the network. - * - * @since vcloud api 0.9, but emulated for 0.8 - */ - @Nullable - IpScope getIpScope(); - - /** - * reference to a network to which this network connects - * - * @since vcloud api 0.9 - */ - @Nullable - ReferenceType getParentNetwork(); - - /** - * defines how this network is connected to its ParentNetwork - * - * @since vcloud api 0.8 - */ - FenceMode getFenceMode(); - - /** - * defines a set of network features. - * - * @since vcloud api 0.9, but emulated for 0.8 - */ - @Nullable Features getFeatures(); - } - -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/network/firewall/FirewallPolicy.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/network/firewall/FirewallPolicy.java deleted file mode 100644 index 44a5e81aeb..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/network/firewall/FirewallPolicy.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.domain.network.firewall; - -import static com.google.common.base.Preconditions.checkNotNull; - -import com.google.common.base.CaseFormat; - -/** - * specifies how packets are handled by the firewall - */ -public enum FirewallPolicy { - /** - * drop packets of this type - */ - DROP, - /** - * allow packets of this type to pass through the firewall - */ - ALLOW, UNRECOGNIZED; - - public String value() { - return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, name()); - } - - @Override - public String toString() { - return value(); - } - - public static FirewallPolicy fromValue(String policy) { - try { - return valueOf(CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, checkNotNull(policy, "policy"))); - } catch (IllegalArgumentException e) { - return UNRECOGNIZED; - } - } - -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/network/firewall/FirewallProtocols.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/network/firewall/FirewallProtocols.java deleted file mode 100644 index 8b09dc2564..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/network/firewall/FirewallProtocols.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.domain.network.firewall; - -import static com.google.common.base.Objects.equal; - -import com.google.common.base.Objects; - -/** - * The Protocols element specifies the protocols to which firewall rules apply. - * - * @since vcloud api 0.9 emulated for 0.8 - */ -public class FirewallProtocols { - private final boolean tcp; - private final boolean udp; - - public FirewallProtocols(boolean tcp, boolean udp) { - this.tcp = tcp; - this.udp = udp; - } - - /** - * @return true if the firewall rules apply to the TCP protocol - */ - public boolean isTcp() { - return tcp; - } - - /** - * @return true if the firewall rules apply to the UDP protocol - */ - public boolean isUdp() { - return udp; - } - - @Override - public boolean equals(Object o) { - if (this == o) - return true; - if (o == null || getClass() != o.getClass()) - return false; - FirewallProtocols that = FirewallProtocols.class.cast(o); - return equal(this.tcp, that.tcp) && equal(this.udp, that.udp); - } - - @Override - public int hashCode() { - return Objects.hashCode(tcp, udp); - } - - @Override - public String toString() { - return Objects.toStringHelper("").omitNullValues().add("tcp", tcp).add("udp", udp).toString(); - } - -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/network/firewall/FirewallRule.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/network/firewall/FirewallRule.java deleted file mode 100644 index dfb578b01e..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/network/firewall/FirewallRule.java +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.domain.network.firewall; - -import static com.google.common.base.Objects.equal; -import static com.google.common.base.Preconditions.checkNotNull; - -import org.jclouds.javax.annotation.Nullable; - -import com.google.common.base.Objects; - -/** - * The FirewallRule element defines a single firewall rule. - * - * @since vcloud api 0.8 - */ -public class FirewallRule { - - private final boolean enabled; - @Nullable - private final String description; - @Nullable - private final FirewallPolicy policy; - @Nullable - private final FirewallProtocols protocols; - private final int port; - private final String destinationIp; - - public FirewallRule(boolean enabled, @Nullable String description, @Nullable FirewallPolicy policy, - @Nullable FirewallProtocols protocols, int port, String destinationIp) { - this.enabled = enabled; - this.description = description; - this.policy = policy; - this.protocols = protocols; - this.port = port; - this.destinationIp = checkNotNull(destinationIp, "destinationIp"); - } - - /** - * @return true if the rule is enabled - */ - public boolean isEnabled() { - return enabled; - } - - /** - * @return description of the rule - */ - @Nullable - public String getDescription() { - return description; - } - - /** - * @return specifies how packets are handled by the firewall - */ - @Nullable - public FirewallPolicy getPolicy() { - return policy; - } - - /** - * @return specifies the protocols to which this firewall rule applies - */ - @Nullable - public FirewallProtocols getProtocols() { - return protocols; - } - - /** - * @return specifies the network port to which this firewall rule applies. A value of ‐1 matches - * any port. - */ - public int getPort() { - return port; - } - - /** - * @return specifies the destination IP address, inside the firewall, to which this firewall rule - * applies - */ - public String getDestinationIp() { - return destinationIp; - } - - @Override - public boolean equals(Object o) { - if (this == o) - return true; - if (o == null || getClass() != o.getClass()) - return false; - FirewallRule that = FirewallRule.class.cast(o); - return equal(this.enabled, that.enabled) && equal(this.description, that.description) - && equal(this.policy, that.policy) && equal(this.protocols, that.protocols) && equal(this.port, that.port) - && equal(this.destinationIp, that.destinationIp); - } - - @Override - public int hashCode() { - return Objects.hashCode(enabled, description, policy, protocols, port, destinationIp); - } - - @Override - public String toString() { - return Objects.toStringHelper("").omitNullValues().add("enabled", enabled).add("description", description) - .add("policy", policy).add("protocols", protocols).add("port", port).add("destinationIp", destinationIp) - .toString(); - } - -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/network/internal/OrgNetworkImpl.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/network/internal/OrgNetworkImpl.java deleted file mode 100644 index 0dc059aa3f..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/network/internal/OrgNetworkImpl.java +++ /dev/null @@ -1,198 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.domain.network.internal; - -import static com.google.common.base.Objects.equal; -import static com.google.common.base.Preconditions.checkNotNull; - -import java.net.URI; -import java.util.List; -import java.util.Set; - -import org.jclouds.javax.annotation.Nullable; -import org.jclouds.vcloud.domain.ReferenceType; -import org.jclouds.vcloud.domain.Task; -import org.jclouds.vcloud.domain.internal.ReferenceTypeImpl; -import org.jclouds.vcloud.domain.network.Features; -import org.jclouds.vcloud.domain.network.FenceMode; -import org.jclouds.vcloud.domain.network.IpScope; -import org.jclouds.vcloud.domain.network.OrgNetwork; - -import com.google.common.base.Objects; -import com.google.common.base.Objects.ToStringHelper; -import com.google.common.collect.Iterables; -import com.google.common.collect.Lists; -import com.google.common.collect.Sets; - -public class OrgNetworkImpl extends ReferenceTypeImpl implements OrgNetwork { - @Nullable - private final ReferenceType org; - @Nullable - private final String description; - private final List tasks = Lists.newArrayList(); - private final Configuration configuration; - @Nullable - private final ReferenceType networkPool; - private final Set allowedExternalIpAddresses = Sets.newLinkedHashSet(); - - public OrgNetworkImpl(String name, String type, URI id, @Nullable ReferenceType org, @Nullable String description, - Iterable tasks, Configuration configuration, @Nullable ReferenceType networkPool, - Iterable allowedExternalIpAddresses) { - super(name, type, id); - this.org = org; - this.description = description; - Iterables.addAll(this.tasks, checkNotNull(tasks, "tasks")); - this.configuration = checkNotNull(configuration, "configuration"); - this.networkPool = networkPool; - Iterables.addAll(this.allowedExternalIpAddresses, checkNotNull(allowedExternalIpAddresses, - "allowedExternalIpAddresses")); - } - - public static class ConfigurationImpl implements Configuration { - - @Nullable - private final IpScope ipScope; - @Nullable - private final ReferenceType parentNetwork; - private final FenceMode fenceMode; - private final Features features; - - public ConfigurationImpl(@Nullable IpScope ipScope, @Nullable ReferenceType parentNetwork, FenceMode fenceMode, - @Nullable Features features) { - this.ipScope = ipScope; - this.parentNetwork = parentNetwork; - this.fenceMode = checkNotNull(fenceMode, "fenceMode"); - this.features = features; - } - - /** - * {@inheritDoc} - */ - @Override - public IpScope getIpScope() { - return ipScope; - } - - /** - * {@inheritDoc} - */ - @Override - public ReferenceType getParentNetwork() { - return parentNetwork; - } - - /** - * {@inheritDoc} - */ - @Override - public FenceMode getFenceMode() { - return fenceMode; - } - - /** - * {@inheritDoc} - */ - @Override - @Nullable - public Features getFeatures() { - return features; - } - - @Override - public boolean equals(Object o) { - if (this == o) - return true; - if (o == null || getClass() != o.getClass()) - return false; - ConfigurationImpl that = ConfigurationImpl.class.cast(o); - return equal(this.ipScope, that.ipScope) && equal(this.parentNetwork, that.parentNetwork) - && equal(this.fenceMode, that.fenceMode) && equal(this.features, that.features); - } - - @Override - public int hashCode() { - return Objects.hashCode(ipScope, parentNetwork, fenceMode, features); - } - - @Override - public String toString() { - return Objects.toStringHelper("").omitNullValues().add("ipScope", ipScope).add("parentNetwork", parentNetwork) - .add("fenceMode", fenceMode).add("features", features).toString(); - } - - } - - /** - * {@inheritDoc} - */ - @Override - public ReferenceType getOrg() { - return org; - } - - /** - * {@inheritDoc} - */ - @Override - public String getDescription() { - return description; - } - - /** - * {@inheritDoc} - */ - @Override - public List getTasks() { - return tasks; - } - - /** - * {@inheritDoc} - */ - @Override - public Configuration getConfiguration() { - return configuration; - } - - /** - * {@inheritDoc} - */ - @Override - public ReferenceType getNetworkPool() { - return networkPool; - } - - /** - * {@inheritDoc} - */ - @Override - public Set getAllowedExternalIpAddresses() { - return allowedExternalIpAddresses; - } - - @Override - public ToStringHelper string() { - ToStringHelper helper = super.string().add("org", org).add("description", description) - .add("configuration", configuration).add("networkPool", networkPool); - if (!allowedExternalIpAddresses.isEmpty()) - helper.add("allowedExternalIpAddresses", allowedExternalIpAddresses); - if (!tasks.isEmpty()) - helper.add("tasks", tasks); - return helper; - } - -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/network/nat/NatPolicy.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/network/nat/NatPolicy.java deleted file mode 100644 index 8a49b33e18..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/network/nat/NatPolicy.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.domain.network.nat; - -import static com.google.common.base.Preconditions.checkNotNull; - -import com.google.common.base.CaseFormat; - -/** - * The Policy element of a NatService element specifies how packets are handled by the NAT service. - */ -public enum NatPolicy { - /** - * packets of this type pass through the firewall in both directions - */ - ALLOW_TRAFFIC, - /** - * only inbound packets of this type pass through the firewall - */ - ALLOW_TRAFFIC_IN, UNRECOGNIZED; - - public String value() { - return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, name()); - } - - @Override - public String toString() { - return value(); - } - - public static NatPolicy fromValue(String policy) { - try { - return valueOf(CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, checkNotNull(policy, "policy"))); - } catch (IllegalArgumentException e) { - return UNRECOGNIZED; - } - } - -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/network/nat/NatProtocol.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/network/nat/NatProtocol.java deleted file mode 100644 index 7204bae072..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/network/nat/NatProtocol.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.domain.network.nat; - - -/** - * - * The Protocol specifies the network protocol to which this rule applies - * - * @since vcloud api 0.9 - */ -public enum NatProtocol { - /** - * the rule applies to the TCP protocol - * - * @since vcloud api 0.9 - */ - TCP, - /** - * the rule applies to the UDP protocol - * - * @since vcloud api 0.9 - */ - UDP, - /** - * the rule applies to the TCP and UDP protocols. - * - * @since vcloud api 0.9 - */ - TCP_UDP; - -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/network/nat/NatRule.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/network/nat/NatRule.java deleted file mode 100644 index b9ca5108f2..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/network/nat/NatRule.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.domain.network.nat; - -import org.jclouds.javax.annotation.Nullable; - -/** - * - * Defines a rule associated with Nat - * - * @since vcloud api 0.9 - */ -public interface NatRule { - /** - * IP address to which this NAT rule maps the IP address specified in the InternalIp element. - */ - @Nullable - String getExternalIP(); -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/network/nat/NatType.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/network/nat/NatType.java deleted file mode 100644 index 98b95e2780..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/network/nat/NatType.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.domain.network.nat; - -import static com.google.common.base.Preconditions.checkNotNull; - -import com.google.common.base.CaseFormat; - -/** - * - * The NatType element specifies how network address translation is implemented by the NAT service. - * - * @since vcloud api 0.9 - */ -public enum NatType { - /** - * NAT service implemented by IP address translation - * - * @since vcloud api 0.9 - */ - IP_TRANSLATION, - /** - * NAT service implemented by network port forwarding - * - * @since vcloud api 0.9 - */ - PORT_FORWARDING, UNRECOGNIZED; - - public String value() { - return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, name()); - } - - @Override - public String toString() { - return value(); - } - - public static NatType fromValue(String natType) { - try { - return valueOf(CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, checkNotNull(natType, "natType"))); - } catch (IllegalArgumentException e) { - return UNRECOGNIZED; - } - } -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/network/nat/rules/MappingMode.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/network/nat/rules/MappingMode.java deleted file mode 100644 index 6d71116312..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/network/nat/rules/MappingMode.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.domain.network.nat.rules; - -import static com.google.common.base.Preconditions.checkNotNull; - -import com.google.common.base.CaseFormat; - -/** - * The MappingMode element specifies how IP address mapping is implemented by the NAT service. - */ -public enum MappingMode { - /** - * the external IP address is specified in the ExternalIP element - */ - MANUAL, - /** - * the external IP address is assigned automatically - */ - AUTOMATIC, UNRECOGNIZED; - - public String value() { - return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, name()); - } - - @Override - public String toString() { - return value(); - } - - public static MappingMode fromValue(String mode) { - try { - return valueOf(CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, checkNotNull(mode, "mode"))); - } catch (IllegalArgumentException e) { - return UNRECOGNIZED; - } - } - -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/network/nat/rules/OneToOneVmRule.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/network/nat/rules/OneToOneVmRule.java deleted file mode 100644 index c2b1b4bff8..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/network/nat/rules/OneToOneVmRule.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.domain.network.nat.rules; - -import static com.google.common.base.Objects.equal; -import static com.google.common.base.Preconditions.checkNotNull; - -import org.jclouds.javax.annotation.Nullable; -import org.jclouds.vcloud.domain.network.nat.NatRule; - -import com.google.common.base.Objects; - -/** - * The OneToOneVmRule element describes a NAT rule that specifies network address translation - * details for a single virtual machine. The external IP address can be specified manually or - * assigned automatically at deployment time. The internal IP address is discovered by looking up - * the specified VmReference and NIC ID. - * - * @since vcloud 0.9 - */ -public class OneToOneVmRule implements NatRule { - private final MappingMode mappingMode; - @Nullable - private final String externalIP; - @Nullable - private final String vAppScopedVmId; - private final int vmNicId; - - public OneToOneVmRule(MappingMode mappingMode, @Nullable String externalIp, @Nullable String vAppScopedVmId, - int vmNicId) { - this.mappingMode = checkNotNull(mappingMode, "mappingMode"); - this.externalIP = externalIp; - this.vAppScopedVmId = vAppScopedVmId; - this.vmNicId = vmNicId; - } - - @Override - public boolean equals(Object o) { - if (this == o) - return true; - if (o == null || getClass() != o.getClass()) - return false; - OneToOneVmRule that = OneToOneVmRule.class.cast(o); - return equal(this.mappingMode, that.mappingMode) && equal(this.externalIP, that.externalIP) - && equal(this.vAppScopedVmId, that.vAppScopedVmId) && equal(this.vmNicId, that.vmNicId); - } - - @Override - public int hashCode() { - return Objects.hashCode(mappingMode, externalIP, vAppScopedVmId, vmNicId); - } - - @Override - public String toString() { - return Objects.toStringHelper("").omitNullValues().add("mappingMode", mappingMode).add("externalIP", externalIP) - .add("vAppScopedVmId", vAppScopedVmId).add("vmNicId", vmNicId).toString(); - } - - /** - * @return how IP address mapping is implemented by the NAT service - * @since vcloud 0.9 - */ - public MappingMode getMappingMode() { - return mappingMode; - } - - /** - * @return if MappingMode is manual, specifies the external IP address of this Vm, otherwise - * null. - * @since vcloud 0.9 - */ - @Nullable - @Override - public String getExternalIP() { - return externalIP; - } - - /** - * @return read‐only identifier created on import - * @since vcloud 0.9 - */ - @Nullable - public String getVAppScopedVmId() { - return vAppScopedVmId; - } - - /** - * @return device number of the NIC on the referenced virtual machine - * @since vcloud 0.9 - */ - public int getVmNicId() { - return vmNicId; - } - -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/network/nat/rules/PortForwardingRule.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/network/nat/rules/PortForwardingRule.java deleted file mode 100644 index 3170a7316c..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/network/nat/rules/PortForwardingRule.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.domain.network.nat.rules; - -import static com.google.common.base.Objects.equal; -import static com.google.common.base.Preconditions.checkNotNull; - -import org.jclouds.vcloud.domain.network.nat.NatProtocol; -import org.jclouds.vcloud.domain.network.nat.NatRule; - -import com.google.common.base.Objects; - -/** - * The PortForwardingRule element describes a NAT rule that maps an IP address and port in an - * organization network to an external IP address and port. - * - * @since vcloud 0.8 - */ -public class PortForwardingRule implements NatRule { - private final String externalIP; - private final int externalPort; - private final String internalIP; - private final int internalPort; - private final NatProtocol protocol; - - public PortForwardingRule(String externalIP, int externalPort, String internalIP, int internalPort, - NatProtocol protocol) { - this.externalIP = checkNotNull(externalIP, "externalIP"); - this.externalPort = externalPort; - this.internalIP = checkNotNull(internalIP, "internalIP"); - this.internalPort = internalPort; - this.protocol = checkNotNull(protocol, "protocol"); - } - - /** - * IP address to which this NAT rule maps the IP address specified in the InternalIp element. - */ - @Override - public String getExternalIP() { - return externalIP; - } - - /** - * network port to which this NAT rule maps the port number specified in the InternalPort element - */ - public int getExternalPort() { - return externalPort; - } - - /** - * IP address to which this NAT rule maps the IP address specified in the ExternalIp element. - */ - public String getInternalIP() { - return internalIP; - } - - /** - * network port to which this NAT rule maps the port number specified in the ExternalPort - * element. - */ - public int getInternalPort() { - return internalPort; - } - - /** - * specifies the network protocol to which this rule applies - */ - public NatProtocol getProtocol() { - return protocol; - } - - @Override - public boolean equals(Object o) { - if (this == o) - return true; - if (o == null || getClass() != o.getClass()) - return false; - PortForwardingRule that = PortForwardingRule.class.cast(o); - return equal(this.externalIP, that.externalIP) && equal(this.externalPort, that.externalPort) - && equal(this.internalIP, that.internalIP) && equal(this.internalPort, that.internalPort) - && equal(this.protocol, that.protocol); - } - - @Override - public int hashCode() { - return Objects.hashCode(externalIP, externalPort, internalIP, internalPort, protocol); - } - - @Override - public String toString() { - return Objects.toStringHelper("").omitNullValues().add("externalIP", externalIP) - .add("externalPort", externalPort).add("internalIP", internalIP).add("internalPort", internalPort) - .add("protocol", protocol).toString(); - } - -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/network/nat/rules/VmRule.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/network/nat/rules/VmRule.java deleted file mode 100644 index 8793a58524..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/network/nat/rules/VmRule.java +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.domain.network.nat.rules; - -import static com.google.common.base.Objects.equal; -import static com.google.common.base.Preconditions.checkNotNull; - -import org.jclouds.javax.annotation.Nullable; -import org.jclouds.vcloud.domain.network.nat.NatProtocol; -import org.jclouds.vcloud.domain.network.nat.NatRule; - -import com.google.common.base.Objects; - -/** - * The VmRule element describes a NAT rule that maps an IP address and port in a vApp network to an - * external IP address and port. The external IP address, external port, and internal port are - * specified in the element. The internal IP address is discovered by looking up the specified - * VmReference and VmNicId. - * - * @since vcloud 0.9 - */ -public class VmRule implements NatRule { - @Nullable - private final String externalIP; - private final int externalPort; - @Nullable - private final String vAppScopedLocalId; - private final int vmNicId; - private final int internalPort; - private final NatProtocol protocol; - - public VmRule(@Nullable String externalIP, int externalPort, @Nullable String vAppScopedLocalId, int vmNicId, - int internalPort, NatProtocol protocol) { - this.externalIP = externalIP; - this.externalPort = externalPort; - this.vAppScopedLocalId = vAppScopedLocalId; - this.vmNicId = vmNicId; - this.internalPort = internalPort; - this.protocol = checkNotNull(protocol, "protocol"); - } - - /** - * IP address to which this NAT rule maps the IP address specified in the vAppScopedLocalId element. - */ - @Nullable - public String getExternalIP() { - return externalIP; - } - - /** - * network port to which this NAT rule maps the port number specified in the InternalPort element - */ - public Integer getExternalPort() { - return externalPort; - } - - /** - * @return read‐only identifier created on import - * @since vcloud 0.9 - */ - @Nullable - public String getVAppScopedLocalId() { - return vAppScopedLocalId; - } - - /** - * @return device number of the NIC on the referenced virtual machine - * @since vcloud 0.9 - */ - public int getVmNicId() { - return vmNicId; - } - - /** - * network port to which this NAT rule maps the port number specified in the ExternalPort - * element. - */ - public Integer getInternalPort() { - return internalPort; - } - - /** - * specifies the network protocol to which this rule applies - */ - public NatProtocol getProtocol() { - return protocol; - } - - @Override - public boolean equals(Object o) { - if (this == o) - return true; - if (o == null || getClass() != o.getClass()) - return false; - VmRule that = VmRule.class.cast(o); - return equal(this.externalIP, that.externalIP) && equal(this.externalPort, that.externalPort) - && equal(this.vAppScopedLocalId, that.vAppScopedLocalId) && equal(this.vmNicId, that.vmNicId) - && equal(this.internalPort, that.internalPort) && equal(this.protocol, that.protocol); - } - - @Override - public int hashCode() { - return Objects.hashCode(externalIP, externalPort, vAppScopedLocalId, vmNicId, internalPort, protocol); - } - - @Override - public String toString() { - return Objects.toStringHelper("").omitNullValues().add("externalIP", externalIP) - .add("externalPort", externalPort).add("vAppScopedLocalId", vAppScopedLocalId).add("vmNicId", vmNicId) - .add("internalPort", internalPort).add("protocol", protocol).toString(); - } - -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/ovf/EditableResourceAllocationSettingData.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/ovf/EditableResourceAllocationSettingData.java deleted file mode 100644 index b12be8651b..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/ovf/EditableResourceAllocationSettingData.java +++ /dev/null @@ -1,298 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.domain.ovf; - -import java.util.List; - -import org.jclouds.cim.ResourceAllocationSettingData; -import org.jclouds.vcloud.domain.ReferenceType; - -public class EditableResourceAllocationSettingData extends ResourceAllocationSettingData { - - public static Builder builder() { - return new Builder(); - } - - /** - * {@inheritDoc} - */ - @Override - public Builder toBuilder() { - return builder().fromEditableResourceAllocationSettingData(this); - } - - public static class Builder extends ResourceAllocationSettingData.Builder { - private ReferenceType edit; - - /** - * @see EditableResourceAllocationSettingData#getEdit - */ - public Builder edit(ReferenceType edit) { - this.edit = edit; - return this; - } - - public EditableResourceAllocationSettingData build() { - return new EditableResourceAllocationSettingData(elementName, instanceID, caption, description, address, - addressOnParent, allocationUnits, automaticAllocation, automaticDeallocation, consumerVisibility, limit, - mappingBehavior, otherResourceType, parent, poolID, reservation, resourceSubType, resourceType, - virtualQuantity, virtualQuantityUnits, weight, connections, hostResources, edit); - } - - public Builder fromEditableResourceAllocationSettingData(EditableResourceAllocationSettingData in) { - return edit(in.getEdit()).fromResourceAllocationSettingData(in); - } - - /** - * {@inheritDoc} - */ - @Override - public Builder caption(String caption) { - return Builder.class.cast(super.caption(caption)); - } - - /** - * {@inheritDoc} - */ - @Override - public Builder description(String description) { - return Builder.class.cast(super.description(description)); - } - - /** - * {@inheritDoc} - */ - @Override - public Builder elementName(String elementName) { - return Builder.class.cast(super.elementName(elementName)); - } - - /** - * {@inheritDoc} - */ - @Override - public Builder instanceID(String instanceID) { - return Builder.class.cast(super.instanceID(instanceID)); - } - - /** - * {@inheritDoc} - */ - @Override - public Builder address(String address) { - return Builder.class.cast(super.address(address)); - } - - /** - * {@inheritDoc} - */ - @Override - public Builder addressOnParent(String addressOnParent) { - return Builder.class.cast(super.addressOnParent(addressOnParent)); - } - - /** - * {@inheritDoc} - */ - @Override - public Builder allocationUnits(String allocationUnits) { - return Builder.class.cast(super.allocationUnits(allocationUnits)); - } - - /** - * {@inheritDoc} - */ - @Override - public Builder automaticAllocation(Boolean automaticAllocation) { - return Builder.class.cast(super.automaticAllocation(automaticAllocation)); - } - - /** - * {@inheritDoc} - */ - @Override - public Builder automaticDeallocation(Boolean automaticDeallocation) { - return Builder.class.cast(super.automaticDeallocation(automaticDeallocation)); - } - - /** - * {@inheritDoc} - */ - @Override - public Builder connection(String connection) { - return Builder.class.cast(super.connection(connection)); - } - - /** - * {@inheritDoc} - */ - @Override - public Builder connections(List connections) { - return Builder.class.cast(super.connections(connections)); - } - - /** - * {@inheritDoc} - */ - @Override - public Builder consumerVisibility(ConsumerVisibility consumerVisibility) { - return Builder.class.cast(super.consumerVisibility(consumerVisibility)); - } - - /** - * {@inheritDoc} - */ - @Override - public Builder hostResource(String hostResource) { - return Builder.class.cast(super.hostResource(hostResource)); - } - - /** - * {@inheritDoc} - */ - @Override - public Builder hostResources(List hostResources) { - return Builder.class.cast(super.hostResources(hostResources)); - } - - /** - * {@inheritDoc} - */ - @Override - public Builder limit(Long limit) { - return Builder.class.cast(super.limit(limit)); - } - - /** - * {@inheritDoc} - */ - @Override - public Builder mappingBehavior(MappingBehavior mappingBehavior) { - return Builder.class.cast(super.mappingBehavior(mappingBehavior)); - } - - /** - * {@inheritDoc} - */ - @Override - public Builder otherResourceType(String otherResourceType) { - return Builder.class.cast(super.otherResourceType(otherResourceType)); - } - - /** - * {@inheritDoc} - */ - @Override - public Builder parent(String parent) { - return Builder.class.cast(super.parent(parent)); - } - - /** - * {@inheritDoc} - */ - @Override - public Builder poolID(String poolID) { - return Builder.class.cast(super.poolID(poolID)); - } - - /** - * {@inheritDoc} - */ - @Override - public Builder reservation(Long reservation) { - return Builder.class.cast(super.reservation(reservation)); - } - - /** - * {@inheritDoc} - */ - @Override - public Builder resourceSubType(String resourceSubType) { - return Builder.class.cast(super.resourceSubType(resourceSubType)); - } - - /** - * {@inheritDoc} - */ - @Override - public Builder resourceType(org.jclouds.cim.ResourceAllocationSettingData.ResourceType resourceType) { - return Builder.class.cast(super.resourceType(resourceType)); - } - - /** - * {@inheritDoc} - */ - @Override - public Builder virtualQuantity(Long virtualQuantity) { - return Builder.class.cast(super.virtualQuantity(virtualQuantity)); - } - - /** - * {@inheritDoc} - */ - @Override - public Builder virtualQuantityUnits(String virtualQuantityUnits) { - return Builder.class.cast(super.virtualQuantityUnits(virtualQuantityUnits)); - } - - /** - * {@inheritDoc} - */ - @Override - public Builder weight(Integer weight) { - return Builder.class.cast(super.weight(weight)); - } - - @Override - public Builder fromResourceAllocationSettingData(ResourceAllocationSettingData in) { - return Builder.class.cast(super.fromResourceAllocationSettingData(in)); - } - - } - - private final ReferenceType edit; - - public EditableResourceAllocationSettingData(String elementName, String instanceID, String caption, - String description, String address, String addressOnParent, String allocationUnits, - Boolean automaticAllocation, Boolean automaticDeallocation, ConsumerVisibility consumerVisibility, Long limit, - MappingBehavior mappingBehavior, String otherResourceType, String parent, String poolID, Long reservation, - String resourceSubType, org.jclouds.cim.ResourceAllocationSettingData.ResourceType resourceType, - Long virtualQuantity, String virtualQuantityUnits, Integer weight, List connections, - List hostResources, ReferenceType edit) { - super(elementName, instanceID, caption, description, address, addressOnParent, allocationUnits, - automaticAllocation, automaticDeallocation, consumerVisibility, limit, mappingBehavior, otherResourceType, - parent, poolID, reservation, resourceSubType, resourceType, virtualQuantity, virtualQuantityUnits, weight, - connections, hostResources); - this.edit = edit; - } - - public ReferenceType getEdit() { - return edit; - } - - @Override - public String toString() { - return String - .format( - "[elementName=%s, instanceID=%s, caption=%s, description=%s, address=%s, addressOnParent=%s, allocationUnits=%s, automaticAllocation=%s, automaticDeallocation=%s, connections=%s, consumerVisibility=%s, hostResources=%s, limit=%s, mappingBehavior=%s, otherResourceType=%s, parent=%s, poolID=%s, reservation=%s, resourceSubType=%s, resourceType=%s, virtualQuantity=%s, virtualQuantityUnits=%s, weight=%s, edit=%s]", - elementName, instanceID, caption, description, address, addressOnParent, allocationUnits, - automaticAllocation, automaticDeallocation, connections, consumerVisibility, hostResources, limit, - mappingBehavior, otherResourceType, parent, poolID, reservation, resourceSubType, resourceType, - virtualQuantity, virtualQuantityUnits, weight, edit); - } - -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/ovf/VCloudHardDisk.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/ovf/VCloudHardDisk.java deleted file mode 100644 index b281785fd2..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/ovf/VCloudHardDisk.java +++ /dev/null @@ -1,326 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.domain.ovf; - -import java.util.List; - -import org.jclouds.cim.ResourceAllocationSettingData; - -public class VCloudHardDisk extends ResourceAllocationSettingData { - - public static Builder builder() { - return new Builder(); - } - - /** - * {@inheritDoc} - */ - @Override - public Builder toBuilder() { - return builder().fromVCloudHardDisk(this); - } - - public static class Builder extends ResourceAllocationSettingData.Builder { - private long capacity; - private int busType; - private String busSubType; - - /** - * @see VCloudHardDisk#getCapacity - */ - public Builder capacity(long capacity) { - this.capacity = capacity; - return this; - } - - /** - * @see VCloudHardDisk#getBusType - */ - public Builder busType(int busType) { - this.busType = busType; - return this; - } - - /** - * @see VCloudHardDisk#getBusSubType - */ - public Builder busSubType(String busSubType) { - this.busSubType = busSubType; - return this; - } - - public VCloudHardDisk build() { - return new VCloudHardDisk(elementName, instanceID, caption, description, address, addressOnParent, - allocationUnits, automaticAllocation, automaticDeallocation, consumerVisibility, limit, mappingBehavior, - otherResourceType, parent, poolID, reservation, resourceSubType, resourceType, virtualQuantity, - virtualQuantityUnits, weight, connections, hostResources, capacity, busType, busSubType); - } - - public Builder fromVCloudHardDisk(VCloudHardDisk in) { - return capacity(in.getCapacity()).busType(in.getBusType()).busSubType(in.getBusSubType()) - .fromResourceAllocationSettingData(in); - } - - /** - * {@inheritDoc} - */ - @Override - public Builder caption(String caption) { - return Builder.class.cast(super.caption(caption)); - } - - /** - * {@inheritDoc} - */ - @Override - public Builder description(String description) { - return Builder.class.cast(super.description(description)); - } - - /** - * {@inheritDoc} - */ - @Override - public Builder elementName(String elementName) { - return Builder.class.cast(super.elementName(elementName)); - } - - /** - * {@inheritDoc} - */ - @Override - public Builder instanceID(String instanceID) { - return Builder.class.cast(super.instanceID(instanceID)); - } - - /** - * {@inheritDoc} - */ - @Override - public Builder address(String address) { - return Builder.class.cast(super.address(address)); - } - - /** - * {@inheritDoc} - */ - @Override - public Builder addressOnParent(String addressOnParent) { - return Builder.class.cast(super.addressOnParent(addressOnParent)); - } - - /** - * {@inheritDoc} - */ - @Override - public Builder allocationUnits(String allocationUnits) { - return Builder.class.cast(super.allocationUnits(allocationUnits)); - } - - /** - * {@inheritDoc} - */ - @Override - public Builder automaticAllocation(Boolean automaticAllocation) { - return Builder.class.cast(super.automaticAllocation(automaticAllocation)); - } - - /** - * {@inheritDoc} - */ - @Override - public Builder automaticDeallocation(Boolean automaticDeallocation) { - return Builder.class.cast(super.automaticDeallocation(automaticDeallocation)); - } - - /** - * {@inheritDoc} - */ - @Override - public Builder connection(String connection) { - return Builder.class.cast(super.connection(connection)); - } - - /** - * {@inheritDoc} - */ - @Override - public Builder connections(List connections) { - return Builder.class.cast(super.connections(connections)); - } - - /** - * {@inheritDoc} - */ - @Override - public Builder consumerVisibility(ConsumerVisibility consumerVisibility) { - return Builder.class.cast(super.consumerVisibility(consumerVisibility)); - } - - /** - * {@inheritDoc} - */ - @Override - public Builder hostResource(String hostResource) { - return Builder.class.cast(super.hostResource(hostResource)); - } - - /** - * {@inheritDoc} - */ - @Override - public Builder hostResources(List hostResources) { - return Builder.class.cast(super.hostResources(hostResources)); - } - - /** - * {@inheritDoc} - */ - @Override - public Builder limit(Long limit) { - return Builder.class.cast(super.limit(limit)); - } - - /** - * {@inheritDoc} - */ - @Override - public Builder mappingBehavior(MappingBehavior mappingBehavior) { - return Builder.class.cast(super.mappingBehavior(mappingBehavior)); - } - - /** - * {@inheritDoc} - */ - @Override - public Builder otherResourceType(String otherResourceType) { - return Builder.class.cast(super.otherResourceType(otherResourceType)); - } - - /** - * {@inheritDoc} - */ - @Override - public Builder parent(String parent) { - return Builder.class.cast(super.parent(parent)); - } - - /** - * {@inheritDoc} - */ - @Override - public Builder poolID(String poolID) { - return Builder.class.cast(super.poolID(poolID)); - } - - /** - * {@inheritDoc} - */ - @Override - public Builder reservation(Long reservation) { - return Builder.class.cast(super.reservation(reservation)); - } - - /** - * {@inheritDoc} - */ - @Override - public Builder resourceSubType(String resourceSubType) { - return Builder.class.cast(super.resourceSubType(resourceSubType)); - } - - /** - * {@inheritDoc} - */ - @Override - public Builder resourceType(org.jclouds.cim.ResourceAllocationSettingData.ResourceType resourceType) { - return Builder.class.cast(super.resourceType(resourceType)); - } - - /** - * {@inheritDoc} - */ - @Override - public Builder virtualQuantity(Long virtualQuantity) { - return Builder.class.cast(super.virtualQuantity(virtualQuantity)); - } - - /** - * {@inheritDoc} - */ - @Override - public Builder virtualQuantityUnits(String virtualQuantityUnits) { - return Builder.class.cast(super.virtualQuantityUnits(virtualQuantityUnits)); - } - - /** - * {@inheritDoc} - */ - @Override - public Builder weight(Integer weight) { - return Builder.class.cast(super.weight(weight)); - } - - @Override - public Builder fromResourceAllocationSettingData(ResourceAllocationSettingData in) { - return Builder.class.cast(super.fromResourceAllocationSettingData(in)); - } - } - - private final long capacity; - private final int busType; - private final String busSubType; - - public VCloudHardDisk(String elementName, String instanceID, String caption, String description, String address, - String addressOnParent, String allocationUnits, Boolean automaticAllocation, Boolean automaticDeallocation, - ConsumerVisibility consumerVisibility, Long limit, MappingBehavior mappingBehavior, String otherResourceType, - String parent, String poolID, Long reservation, String resourceSubType, - org.jclouds.cim.ResourceAllocationSettingData.ResourceType resourceType, Long virtualQuantity, - String virtualQuantityUnits, Integer weight, List connections, List hostResources, - long capacity, int busType, String busSubType) { - super(elementName, instanceID, caption, description, address, addressOnParent, allocationUnits, - automaticAllocation, automaticDeallocation, consumerVisibility, limit, mappingBehavior, otherResourceType, - parent, poolID, reservation, resourceSubType, resourceType, virtualQuantity, virtualQuantityUnits, weight, - connections, hostResources); - this.capacity = capacity; - this.busType = busType; - this.busSubType = busSubType; - } - - public long getCapacity() { - return capacity; - } - - public int getBusType() { - return busType; - } - - public String getBusSubType() { - return busSubType; - } - - @Override - public String toString() { - return String - .format( - "[elementName=%s, instanceID=%s, caption=%s, description=%s, address=%s, addressOnParent=%s, allocationUnits=%s, automaticAllocation=%s, automaticDeallocation=%s, connections=%s, consumerVisibility=%s, hostResources=%s, limit=%s, mappingBehavior=%s, otherResourceType=%s, parent=%s, poolID=%s, reservation=%s, resourceSubType=%s, resourceType=%s, virtualQuantity=%s, virtualQuantityUnits=%s, weight=%s, busSubType=%s, busType=%s, capacity=%s]", - elementName, instanceID, caption, description, address, addressOnParent, allocationUnits, - automaticAllocation, automaticDeallocation, connections, consumerVisibility, hostResources, limit, - mappingBehavior, otherResourceType, parent, poolID, reservation, resourceSubType, resourceType, - virtualQuantity, virtualQuantityUnits, weight, busSubType, busType, capacity); - } -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/ovf/VCloudNetworkAdapter.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/ovf/VCloudNetworkAdapter.java deleted file mode 100644 index 7a48916ddb..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/ovf/VCloudNetworkAdapter.java +++ /dev/null @@ -1,328 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.domain.ovf; - -import java.util.List; - -import org.jclouds.cim.ResourceAllocationSettingData; - -public class VCloudNetworkAdapter extends ResourceAllocationSettingData { - - public static Builder builder() { - return new Builder(); - } - - /** - * {@inheritDoc} - */ - @Override - public Builder toBuilder() { - return builder().fromVCloudNetworkAdapter(this); - } - - public static class Builder extends ResourceAllocationSettingData.Builder { - private String ipAddress; - private boolean primaryNetworkConnection; - private String ipAddressingMode; - - /** - * @see VCloudNetworkAdapter#getCapacity - */ - public Builder ipAddress(String ipAddress) { - this.ipAddress = ipAddress; - return this; - } - - /** - * @see VCloudNetworkAdapter#getBusType - */ - public Builder primaryNetworkConnection(boolean primaryNetworkConnection) { - this.primaryNetworkConnection = primaryNetworkConnection; - return this; - } - - /** - * @see VCloudNetworkAdapter#getBusSubType - */ - public Builder ipAddressingMode(String ipAddressingMode) { - this.ipAddressingMode = ipAddressingMode; - return this; - } - - public VCloudNetworkAdapter build() { - return new VCloudNetworkAdapter(elementName, instanceID, caption, description, address, addressOnParent, - allocationUnits, automaticAllocation, automaticDeallocation, consumerVisibility, limit, - mappingBehavior, otherResourceType, parent, poolID, reservation, resourceSubType, resourceType, - virtualQuantity, virtualQuantityUnits, weight, connections, hostResources, ipAddress, - primaryNetworkConnection, ipAddressingMode); - } - - public Builder fromVCloudNetworkAdapter(VCloudNetworkAdapter in) { - return ipAddress(in.getIpAddress()).primaryNetworkConnection(in.isPrimaryNetworkConnection()) - .ipAddressingMode(in.getIpAddressingMode()).fromResourceAllocationSettingData(in); - } - - /** - * {@inheritDoc} - */ - @Override - public Builder caption(String caption) { - return Builder.class.cast(super.caption(caption)); - } - - /** - * {@inheritDoc} - */ - @Override - public Builder description(String description) { - return Builder.class.cast(super.description(description)); - } - - /** - * {@inheritDoc} - */ - @Override - public Builder elementName(String elementName) { - return Builder.class.cast(super.elementName(elementName)); - } - - /** - * {@inheritDoc} - */ - @Override - public Builder instanceID(String instanceID) { - return Builder.class.cast(super.instanceID(instanceID)); - } - - /** - * {@inheritDoc} - */ - @Override - public Builder address(String address) { - return Builder.class.cast(super.address(address)); - } - - /** - * {@inheritDoc} - */ - @Override - public Builder addressOnParent(String addressOnParent) { - return Builder.class.cast(super.addressOnParent(addressOnParent)); - } - - /** - * {@inheritDoc} - */ - @Override - public Builder allocationUnits(String allocationUnits) { - return Builder.class.cast(super.allocationUnits(allocationUnits)); - } - - /** - * {@inheritDoc} - */ - @Override - public Builder automaticAllocation(Boolean automaticAllocation) { - return Builder.class.cast(super.automaticAllocation(automaticAllocation)); - } - - /** - * {@inheritDoc} - */ - @Override - public Builder automaticDeallocation(Boolean automaticDeallocation) { - return Builder.class.cast(super.automaticDeallocation(automaticDeallocation)); - } - - /** - * {@inheritDoc} - */ - @Override - public Builder connection(String connection) { - return Builder.class.cast(super.connection(connection)); - } - - /** - * {@inheritDoc} - */ - @Override - public Builder connections(List connections) { - return Builder.class.cast(super.connections(connections)); - } - - /** - * {@inheritDoc} - */ - @Override - public Builder consumerVisibility(ConsumerVisibility consumerVisibility) { - return Builder.class.cast(super.consumerVisibility(consumerVisibility)); - } - - /** - * {@inheritDoc} - */ - @Override - public Builder hostResource(String hostResource) { - return Builder.class.cast(super.hostResource(hostResource)); - } - - /** - * {@inheritDoc} - */ - @Override - public Builder hostResources(List hostResources) { - return Builder.class.cast(super.hostResources(hostResources)); - } - - /** - * {@inheritDoc} - */ - @Override - public Builder limit(Long limit) { - return Builder.class.cast(super.limit(limit)); - } - - /** - * {@inheritDoc} - */ - @Override - public Builder mappingBehavior(MappingBehavior mappingBehavior) { - return Builder.class.cast(super.mappingBehavior(mappingBehavior)); - } - - /** - * {@inheritDoc} - */ - @Override - public Builder otherResourceType(String otherResourceType) { - return Builder.class.cast(super.otherResourceType(otherResourceType)); - } - - /** - * {@inheritDoc} - */ - @Override - public Builder parent(String parent) { - return Builder.class.cast(super.parent(parent)); - } - - /** - * {@inheritDoc} - */ - @Override - public Builder poolID(String poolID) { - return Builder.class.cast(super.poolID(poolID)); - } - - /** - * {@inheritDoc} - */ - @Override - public Builder reservation(Long reservation) { - return Builder.class.cast(super.reservation(reservation)); - } - - /** - * {@inheritDoc} - */ - @Override - public Builder resourceSubType(String resourceSubType) { - return Builder.class.cast(super.resourceSubType(resourceSubType)); - } - - /** - * {@inheritDoc} - */ - @Override - public Builder resourceType(org.jclouds.cim.ResourceAllocationSettingData.ResourceType resourceType) { - return Builder.class.cast(super.resourceType(resourceType)); - } - - /** - * {@inheritDoc} - */ - @Override - public Builder virtualQuantity(Long virtualQuantity) { - return Builder.class.cast(super.virtualQuantity(virtualQuantity)); - } - - /** - * {@inheritDoc} - */ - @Override - public Builder virtualQuantityUnits(String virtualQuantityUnits) { - return Builder.class.cast(super.virtualQuantityUnits(virtualQuantityUnits)); - } - - /** - * {@inheritDoc} - */ - @Override - public Builder weight(Integer weight) { - return Builder.class.cast(super.weight(weight)); - } - - @Override - public Builder fromResourceAllocationSettingData(ResourceAllocationSettingData in) { - return Builder.class.cast(super.fromResourceAllocationSettingData(in)); - } - } - - private final String ipAddress; - private final boolean primaryNetworkConnection; - private final String ipAddressingMode; - - public VCloudNetworkAdapter(String elementName, String instanceID, String caption, String description, - String address, String addressOnParent, String allocationUnits, Boolean automaticAllocation, - Boolean automaticDeallocation, ConsumerVisibility consumerVisibility, Long limit, - MappingBehavior mappingBehavior, String otherResourceType, String parent, String poolID, Long reservation, - String resourceSubType, org.jclouds.cim.ResourceAllocationSettingData.ResourceType resourceType, - Long virtualQuantity, String virtualQuantityUnits, Integer weight, List connections, - List hostResources, String ipAddress, boolean primaryNetworkConnection, String ipAddressingMode) { - super(elementName, instanceID, caption, description, address, addressOnParent, allocationUnits, - automaticAllocation, automaticDeallocation, consumerVisibility, limit, mappingBehavior, - otherResourceType, parent, poolID, reservation, resourceSubType, resourceType, virtualQuantity, - virtualQuantityUnits, weight, connections, hostResources); - this.ipAddress = ipAddress; - this.primaryNetworkConnection = primaryNetworkConnection; - this.ipAddressingMode = ipAddressingMode; - } - - public String getIpAddress() { - return ipAddress; - } - - public boolean isPrimaryNetworkConnection() { - return primaryNetworkConnection; - } - - public String getIpAddressingMode() { - return ipAddressingMode; - } - - @Override - public String toString() { - return String - .format( - "[elementName=%s, instanceID=%s, caption=%s, description=%s, address=%s, addressOnParent=%s, allocationUnits=%s, automaticAllocation=%s, automaticDeallocation=%s, connections=%s, consumerVisibility=%s, hostResources=%s, limit=%s, mappingBehavior=%s, otherResourceType=%s, parent=%s, poolID=%s, reservation=%s, resourceSubType=%s, resourceType=%s, virtualQuantity=%s, virtualQuantityUnits=%s, weight=%s, ipAddressingMode=%s, primaryNetworkConnection=%s, ipAddress=%s]", - elementName, instanceID, caption, description, address, addressOnParent, allocationUnits, - automaticAllocation, automaticDeallocation, connections, consumerVisibility, hostResources, - limit, mappingBehavior, otherResourceType, parent, poolID, reservation, resourceSubType, - resourceType, virtualQuantity, virtualQuantityUnits, weight, ipAddressingMode, - primaryNetworkConnection, ipAddress); - } -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/ovf/VCloudNetworkSection.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/ovf/VCloudNetworkSection.java deleted file mode 100644 index 64dddc5252..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/ovf/VCloudNetworkSection.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.domain.ovf; - -import java.net.URI; - -import org.jclouds.ovf.Network; -import org.jclouds.ovf.NetworkSection; - -/** - * VCloud extension - */ -public class VCloudNetworkSection extends NetworkSection { - protected final String type; - protected final URI href; - - public VCloudNetworkSection(String type, URI href, String info, Iterable networks) { - super(info, networks); - this.type = type; - this.href = href; - } - - public String getType() { - return type; - } - - public URI getHref() { - return href; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = super.hashCode(); - result = prime * result + ((href == null) ? 0 : href.hashCode()); - result = prime * result + ((type == null) ? 0 : type.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (!super.equals(obj)) - return false; - if (getClass() != obj.getClass()) - return false; - VCloudNetworkSection other = (VCloudNetworkSection) obj; - if (href == null) { - if (other.href != null) - return false; - } else if (!href.equals(other.href)) - return false; - if (type == null) { - if (other.type != null) - return false; - } else if (!type.equals(other.type)) - return false; - return true; - } - - @Override - public String toString() { - return "[href=" + getHref() + ", type=" + getType() + ", info=" + getInfo() + ", networks=" + getNetworks() + "]"; - } -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/ovf/VCloudOperatingSystemSection.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/ovf/VCloudOperatingSystemSection.java deleted file mode 100644 index 052eadda82..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/ovf/VCloudOperatingSystemSection.java +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.domain.ovf; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.net.URI; - -import org.jclouds.javax.annotation.Nullable; -import org.jclouds.ovf.OperatingSystemSection; -import org.jclouds.vcloud.domain.ReferenceType; - -/** - * A description of the operating system supported by a virtual machine. - */ -public class VCloudOperatingSystemSection extends OperatingSystemSection { - protected final String type; - protected final URI href; - @Nullable - protected final String vmwOsType; - protected final ReferenceType edit; - - public VCloudOperatingSystemSection(@Nullable Integer id, @Nullable String info, @Nullable String description, String type, - URI href, @Nullable String vmwOsType, ReferenceType edit) { - super(id, info, description); - this.type = type; - this.href = href; - this.vmwOsType = vmwOsType; - this.edit = checkNotNull(edit, "edit"); - } - - public String getType() { - return type; - } - - public URI getHref() { - return href; - } - - /** - * - * @return VMware osType, if running on VMware - */ - public String getVmwOsType() { - return vmwOsType; - } - - /** - * - * @return edit link - */ - public ReferenceType getEdit() { - return edit; - } - - @Override - public String toString() { - return "[href=" + getHref() + ", type=" + getType() + ", id=" + getId() + ", vmwOsType=" + getVmwOsType() - + ", description=" + getDescription() + "]"; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = super.hashCode(); - result = prime * result + ((edit == null) ? 0 : edit.hashCode()); - result = prime * result + ((href == null) ? 0 : href.hashCode()); - result = prime * result + ((type == null) ? 0 : type.hashCode()); - result = prime * result + ((vmwOsType == null) ? 0 : vmwOsType.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (!super.equals(obj)) - return false; - if (getClass() != obj.getClass()) - return false; - VCloudOperatingSystemSection other = (VCloudOperatingSystemSection) obj; - if (edit == null) { - if (other.edit != null) - return false; - } else if (!edit.equals(other.edit)) - return false; - if (href == null) { - if (other.href != null) - return false; - } else if (!href.equals(other.href)) - return false; - if (type == null) { - if (other.type != null) - return false; - } else if (!type.equals(other.type)) - return false; - if (vmwOsType == null) { - if (other.vmwOsType != null) - return false; - } else if (!vmwOsType.equals(other.vmwOsType)) - return false; - return true; - } -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/ovf/VCloudVirtualHardwareSection.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/ovf/VCloudVirtualHardwareSection.java deleted file mode 100644 index 6d89b954fc..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/ovf/VCloudVirtualHardwareSection.java +++ /dev/null @@ -1,179 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.domain.ovf; - -import java.net.URI; - -import org.jclouds.cim.ResourceAllocationSettingData; -import org.jclouds.cim.VirtualSystemSettingData; -import org.jclouds.ovf.Section; -import org.jclouds.ovf.VirtualHardwareSection; - -/** - * A description of the virtual hardware supported by a virtual machine. - */ -public class VCloudVirtualHardwareSection extends VirtualHardwareSection { - public static Builder builder() { - return new Builder(); - } - - /** - * {@inheritDoc} - */ - @Override - public Builder toBuilder() { - return builder().fromVCloudVirtualHardwareSection(this); - } - - public static class Builder extends VirtualHardwareSection.Builder { - protected String type; - protected URI href; - - /** - * @see VCloudVirtualHardware#getType - */ - public Builder type(String type) { - this.type = type; - return this; - } - - /** - * @see VCloudVirtualHardware#getHref - */ - public Builder href(URI href) { - this.href = href; - return this; - } - - /** - * {@inheritDoc} - */ - @Override - public Builder system(VirtualSystemSettingData virtualSystem) { - return Builder.class.cast(super.system(virtualSystem)); - } - - /** - * {@inheritDoc} - */ - @Override - public Builder transport(String transport) { - return Builder.class.cast(super.transport(transport)); - } - - /** - * {@inheritDoc} - */ - @Override - public Builder transports(Iterable transports) { - return Builder.class.cast(super.transports(transports)); - } - - /** - * {@inheritDoc} - */ - @Override - public Builder item(ResourceAllocationSettingData item) { - return Builder.class.cast(super.item(item)); - } - - /** - * {@inheritDoc} - */ - @Override - public Builder items(Iterable items) { - return Builder.class.cast(super.items(items)); - } - - /** - * {@inheritDoc} - */ - @Override - public VCloudVirtualHardwareSection build() { - return new VCloudVirtualHardwareSection(type, href, info, transports, virtualSystem, items); - } - - public Builder fromVCloudVirtualHardwareSection(VCloudVirtualHardwareSection in) { - return fromVirtualHardwareSection(in).type(in.getType()).href(in.getHref()); - } - - /** - * {@inheritDoc} - */ - @Override - public Builder fromVirtualHardwareSection(VirtualHardwareSection in) { - return Builder.class.cast(super.fromVirtualHardwareSection(in)); - } - - /** - * {@inheritDoc} - */ - @Override - public Builder fromSection(Section in) { - return Builder.class.cast(super.fromSection(in)); - } - - /** - * {@inheritDoc} - */ - @Override - public Builder info(String info) { - return Builder.class.cast(super.info(info)); - } - } - - protected final String type; - protected final URI href; - - public VCloudVirtualHardwareSection(String type, URI href, String info, Iterable transports, - VirtualSystemSettingData virtualSystem, Iterable resourceAllocations) { - super(info, transports, virtualSystem, resourceAllocations); - this.type = type; - this.href = href; - } - - public String getType() { - return type; - } - - public URI getHref() { - return href; - } - - @Override - public int hashCode() { - return href.hashCode(); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (!super.equals(obj)) - return false; - if (getClass() != obj.getClass()) - return false; - VCloudVirtualHardwareSection other = (VCloudVirtualHardwareSection) obj; - return href.equals(other.href); - } - - @Override - public String toString() { - return "[href=" + getHref() + ", type=" + getType() + ", info=" + getInfo() + ", virtualSystem=" + getSystem() - + "]"; - } -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/endpoints/Catalog.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/endpoints/Catalog.java deleted file mode 100644 index 7b59d1ee77..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/endpoints/Catalog.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.endpoints; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -import javax.inject.Qualifier; - -/** - * Related to a VCloud Catalog. - */ -@Retention(value = RetentionPolicy.RUNTIME) -@Target(value = { ElementType.TYPE, ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD }) -@Qualifier -public @interface Catalog { - -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/endpoints/Network.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/endpoints/Network.java deleted file mode 100644 index f30162e14c..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/endpoints/Network.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.endpoints; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -import javax.inject.Qualifier; - -/** - * Related to a VCloud Network. - */ -@Retention(value = RetentionPolicy.RUNTIME) -@Target(value = { ElementType.TYPE, ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD }) -@Qualifier -public @interface Network { - -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/endpoints/Org.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/endpoints/Org.java deleted file mode 100644 index 167b1ee3ad..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/endpoints/Org.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.endpoints; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -import javax.inject.Qualifier; - -/** - * Related to a VCloud express Org. - */ -@Retention(value = RetentionPolicy.RUNTIME) -@Target(value = { ElementType.TYPE, ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD }) -@Qualifier -public @interface Org { - -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/endpoints/OrgList.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/endpoints/OrgList.java deleted file mode 100644 index 5e0caabbce..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/endpoints/OrgList.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.endpoints; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -import javax.inject.Qualifier; - -/** - * Related to a VCloud express Org List. - */ -@Retention(value = RetentionPolicy.RUNTIME) -@Target(value = { ElementType.TYPE, ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD }) -@Qualifier -public @interface OrgList { - -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/endpoints/TasksList.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/endpoints/TasksList.java deleted file mode 100644 index 333a39f659..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/endpoints/TasksList.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.endpoints; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -import javax.inject.Qualifier; - -/** - * Related to a VCloud express Task List. - */ -@Retention(value = RetentionPolicy.RUNTIME) -@Target(value = { ElementType.TYPE, ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD }) -@Qualifier -public @interface TasksList { - -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/endpoints/VCloudLogin.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/endpoints/VCloudLogin.java deleted file mode 100644 index 7d3124be8f..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/endpoints/VCloudLogin.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.endpoints; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -import javax.inject.Qualifier; - -/** - * Represents a component related to vCloud. - * - * @see - */ -@Retention(value = RetentionPolicy.RUNTIME) -@Target(value = { ElementType.TYPE, ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD }) -@Qualifier -public @interface VCloudLogin { - -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/endpoints/VDC.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/endpoints/VDC.java deleted file mode 100644 index 193eb746b4..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/endpoints/VDC.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.endpoints; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -import javax.inject.Qualifier; - -/** - * Related to a VCloud express Catalog. - */ -@Retention(value = RetentionPolicy.RUNTIME) -@Target(value = {ElementType.TYPE, ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD }) -@Qualifier -public @interface VDC { - -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/features/CatalogApi.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/features/CatalogApi.java deleted file mode 100644 index 1aa660e17c..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/features/CatalogApi.java +++ /dev/null @@ -1,143 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.features; - -import static org.jclouds.vcloud.VCloudMediaType.CATALOGITEM_XML; -import static org.jclouds.vcloud.VCloudMediaType.CATALOG_XML; - -import java.net.URI; - -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.Produces; - -import org.jclouds.Fallbacks; -import org.jclouds.javax.annotation.Nullable; -import org.jclouds.rest.annotations.EndpointParam; -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.XMLResponseParser; -import org.jclouds.vcloud.binders.BindCatalogItemToXmlPayload; -import org.jclouds.vcloud.binders.OrgNameAndCatalogNameToEndpoint; -import org.jclouds.vcloud.binders.OrgNameCatalogNameItemNameToEndpoint; -import org.jclouds.vcloud.domain.Catalog; -import org.jclouds.vcloud.domain.CatalogItem; -import org.jclouds.vcloud.filters.AddVCloudAuthorizationAndCookieToRequest; -import org.jclouds.vcloud.options.CatalogItemOptions; -import org.jclouds.vcloud.xml.CatalogHandler; -import org.jclouds.vcloud.xml.CatalogItemHandler; - - -/** - * Provides access to Catalog functionality in vCloud - *

- * - * @see - */ -@RequestFilters(AddVCloudAuthorizationAndCookieToRequest.class) -public interface CatalogApi { - - @GET - @XMLResponseParser(CatalogHandler.class) - @Fallback(Fallbacks.NullOnNotFoundOr404.class) - @Consumes(CATALOG_XML) - Catalog getCatalog(@EndpointParam URI catalogId); - - /** - * returns the catalog in the organization associated with the specified name. Note that both - * parameters can be null to choose default. - * - * @param orgName - * organization name, or null for the default - * @param catalogName - * catalog name, or null for the default - * @throws NoSuchElementException - * if you specified an org or catalog name that isn't present - */ - @GET - @XMLResponseParser(CatalogHandler.class) - @Fallback(Fallbacks.NullOnNotFoundOr404.class) - @Consumes(CATALOG_XML) - @MapBinder(OrgNameAndCatalogNameToEndpoint.class) - Catalog findCatalogInOrgNamed(@Nullable @PayloadParam("orgName") String orgName, - @Nullable @PayloadParam("catalogName") String catalogName); - - @GET - @Consumes(CATALOGITEM_XML) - @XMLResponseParser(CatalogItemHandler.class) - @Fallback(Fallbacks.NullOnNotFoundOr404.class) - CatalogItem getCatalogItem(@EndpointParam URI catalogItem); - - /** - * returns the catalog item in the catalog associated with the specified name. Note that the org - * and catalog parameters can be null to choose default. - * - * @param orgName - * organization name, or null for the default - * @param catalogName - * catalog name, or null for the default - * @param itemName - * item you wish to lookup - * - * @throws NoSuchElementException - * if you specified an org, catalog, or catalog item name that isn't present - */ - @GET - @Consumes(CATALOGITEM_XML) - @XMLResponseParser(CatalogItemHandler.class) - @Fallback(Fallbacks.NullOnNotFoundOr404.class) - @MapBinder(OrgNameCatalogNameItemNameToEndpoint.class) - CatalogItem findCatalogItemInOrgCatalogNamed(@Nullable @PayloadParam("orgName") String orgName, - @Nullable @PayloadParam("catalogName") String catalogName, - @PayloadParam("itemName") String itemName); - - /** - * A catalog can contain references to vApp templates and media images that have been uploaded to - * any vDC in an organization. A vApp template or media image can be listed in at most one - * catalog. - * - * @param entity - * the reference to the vApp templates and media image - * @param catalog - * URI of the catalog to add the resourceEntity from - * @param name - * name of the entry in the catalog - * - * @param options - * options such as description or properties - * @return the new catalog item - */ - @POST - @Path("/catalogItems") - @Consumes(CATALOGITEM_XML) - @Produces(CATALOGITEM_XML) - @MapBinder(BindCatalogItemToXmlPayload.class) - @XMLResponseParser(CatalogItemHandler.class) - CatalogItem addVAppTemplateOrMediaImageToCatalogAndNameItem(@PayloadParam("Entity") URI entity, - @EndpointParam URI catalog, - @PayloadParam("name") String name, - CatalogItemOptions... options); - - @DELETE - @Fallback(Fallbacks.VoidOnNotFoundOr404.class) - void deleteCatalogItem(@EndpointParam URI href); -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/features/NetworkApi.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/features/NetworkApi.java deleted file mode 100644 index d36e4713f2..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/features/NetworkApi.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.features; - -import static org.jclouds.vcloud.VCloudMediaType.NETWORK_XML; - -import java.net.URI; - -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; - -import org.jclouds.Fallbacks; -import org.jclouds.javax.annotation.Nullable; -import org.jclouds.rest.annotations.EndpointParam; -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.XMLResponseParser; -import org.jclouds.vcloud.binders.OrgNameVDCNameNetworkNameToEndpoint; -import org.jclouds.vcloud.domain.network.OrgNetwork; -import org.jclouds.vcloud.filters.AddVCloudAuthorizationAndCookieToRequest; -import org.jclouds.vcloud.xml.OrgNetworkHandler; - -/** - * Provides access to Network functionality in vCloud - *

- */ -@RequestFilters(AddVCloudAuthorizationAndCookieToRequest.class) -public interface NetworkApi { - - @GET - @Consumes(NETWORK_XML) - @XMLResponseParser(OrgNetworkHandler.class) - @Fallback(Fallbacks.NullOnNotFoundOr404.class) - @MapBinder(OrgNameVDCNameNetworkNameToEndpoint.class) - OrgNetwork findNetworkInOrgVDCNamed(@Nullable @PayloadParam("orgName") String orgName, - @Nullable @PayloadParam("vdcName") String vdcName, - @PayloadParam("resourceName") String networkName); - - @GET - @Consumes(NETWORK_XML) - @XMLResponseParser(OrgNetworkHandler.class) - @Fallback(Fallbacks.NullOnNotFoundOr404.class) - OrgNetwork getNetwork(@EndpointParam URI network); -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/features/OrgApi.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/features/OrgApi.java deleted file mode 100644 index 3b7cf3a90b..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/features/OrgApi.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.features; - -import static org.jclouds.vcloud.VCloudMediaType.ORG_XML; - -import java.net.URI; -import java.util.Map; - -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; - -import org.jclouds.Fallbacks; -import org.jclouds.javax.annotation.Nullable; -import org.jclouds.rest.annotations.Endpoint; -import org.jclouds.rest.annotations.EndpointParam; -import org.jclouds.rest.annotations.Fallback; -import org.jclouds.rest.annotations.RequestFilters; -import org.jclouds.rest.annotations.XMLResponseParser; -import org.jclouds.vcloud.VCloudMediaType; -import org.jclouds.vcloud.domain.Org; -import org.jclouds.vcloud.domain.ReferenceType; -import org.jclouds.vcloud.endpoints.OrgList; -import org.jclouds.vcloud.filters.AddVCloudAuthorizationAndCookieToRequest; -import org.jclouds.vcloud.functions.OrgNameToEndpoint; -import org.jclouds.vcloud.xml.OrgHandler; -import org.jclouds.vcloud.xml.OrgListHandler; - - -/** - * Provides access to Org functionality in vCloud - *

- */ -@RequestFilters(AddVCloudAuthorizationAndCookieToRequest.class) -public interface OrgApi { - - /** - * The response to a login request includes a list of the organizations to which the - * authenticated user has access. - * - * @return organizations indexed by name - */ - @GET - @Endpoint(OrgList.class) - @XMLResponseParser(OrgListHandler.class) - @Consumes(VCloudMediaType.ORGLIST_XML) - Map listOrgs(); - - @GET - @XMLResponseParser(OrgHandler.class) - @Fallback(Fallbacks.NullOnNotFoundOr404.class) - @Consumes(ORG_XML) - Org getOrg(@EndpointParam URI orgId); - - /** - * This call returns a list of all vCloud Data Centers (vdcs), catalogs, and task lists within - * the organization. - * - * @param name - * organization name, or null for the default - * @throws NoSuchElementException - * if you specified an org name that isn't present - */ - @GET - @XMLResponseParser(OrgHandler.class) - @Fallback(Fallbacks.NullOnNotFoundOr404.class) - @Consumes(ORG_XML) - Org findOrgNamed(@Nullable @EndpointParam(parser = OrgNameToEndpoint.class) String orgName); - -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/features/TaskApi.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/features/TaskApi.java deleted file mode 100644 index b9a60a69ea..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/features/TaskApi.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.features; - -import static org.jclouds.vcloud.VCloudMediaType.TASKSLIST_XML; -import static org.jclouds.vcloud.VCloudMediaType.TASK_XML; - -import java.net.URI; - -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.Path; - -import org.jclouds.Fallbacks; -import org.jclouds.javax.annotation.Nullable; -import org.jclouds.rest.annotations.EndpointParam; -import org.jclouds.rest.annotations.Fallback; -import org.jclouds.rest.annotations.RequestFilters; -import org.jclouds.rest.annotations.XMLResponseParser; -import org.jclouds.vcloud.domain.Task; -import org.jclouds.vcloud.domain.TasksList; -import org.jclouds.vcloud.filters.AddVCloudAuthorizationAndCookieToRequest; -import org.jclouds.vcloud.functions.OrgNameToTasksListEndpoint; -import org.jclouds.vcloud.xml.TaskHandler; -import org.jclouds.vcloud.xml.TasksListHandler; - -/** - * Provides access to Task functionality in vCloud - *

- */ -@RequestFilters(AddVCloudAuthorizationAndCookieToRequest.class) -public interface TaskApi { - - @GET - @Consumes(TASKSLIST_XML) - @XMLResponseParser(TasksListHandler.class) - @Fallback(Fallbacks.NullOnNotFoundOr404.class) - TasksList getTasksList(@EndpointParam URI tasksListId); - - @GET - @Consumes(TASKSLIST_XML) - @XMLResponseParser(TasksListHandler.class) - @Fallback(Fallbacks.NullOnNotFoundOr404.class) - TasksList findTasksListInOrgNamed(@Nullable @EndpointParam(parser = OrgNameToTasksListEndpoint.class) String orgName); - - /** - * Whenever the result of a request cannot be returned immediately, the server creates a Task - * object and includes it in the response, as a member of the Tasks container in the response - * body. Each Task has an href value, which is a URL that the client can use to retrieve the Task - * element alone, without the rest of the response in which it was contained. All information - * about the task is included in the Task element when it is returned in the response’s Tasks - * container, so a client does not need to make an additional request to the Task URL unless it - * wants to follow the progress of a task that was incomplete. - */ - @GET - @Consumes(TASK_XML) - @XMLResponseParser(TaskHandler.class) - @Fallback(Fallbacks.NullOnNotFoundOr404.class) - Task getTask(@EndpointParam URI taskId); - - @POST - @Path("/action/cancel") - void cancelTask(@EndpointParam URI taskId); - -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/features/VAppApi.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/features/VAppApi.java deleted file mode 100644 index af44c3e7b1..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/features/VAppApi.java +++ /dev/null @@ -1,260 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.features; - -import static org.jclouds.vcloud.VCloudMediaType.DEPLOYVAPPPARAMS_XML; -import static org.jclouds.vcloud.VCloudMediaType.TASK_XML; -import static org.jclouds.vcloud.VCloudMediaType.UNDEPLOYVAPPPARAMS_XML; -import static org.jclouds.vcloud.VCloudMediaType.VAPP_XML; - -import java.net.URI; - -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.Produces; - -import org.jclouds.Fallbacks; -import org.jclouds.javax.annotation.Nullable; -import org.jclouds.predicates.validators.DnsNameValidator; -import org.jclouds.rest.annotations.EndpointParam; -import org.jclouds.rest.annotations.Fallback; -import org.jclouds.rest.annotations.MapBinder; -import org.jclouds.rest.annotations.ParamValidators; -import org.jclouds.rest.annotations.PayloadParam; -import org.jclouds.rest.annotations.PayloadParams; -import org.jclouds.rest.annotations.RequestFilters; -import org.jclouds.rest.annotations.XMLResponseParser; -import org.jclouds.vcloud.binders.BindCloneVAppParamsToXmlPayload; -import org.jclouds.vcloud.binders.BindDeployVAppParamsToXmlPayload; -import org.jclouds.vcloud.binders.BindUndeployVAppParamsToXmlPayload; -import org.jclouds.vcloud.binders.OrgNameVDCNameResourceEntityNameToEndpoint; -import org.jclouds.vcloud.domain.Task; -import org.jclouds.vcloud.domain.VApp; -import org.jclouds.vcloud.filters.AddVCloudAuthorizationAndCookieToRequest; -import org.jclouds.vcloud.options.CloneVAppOptions; -import org.jclouds.vcloud.xml.TaskHandler; -import org.jclouds.vcloud.xml.VAppHandler; - - -/** - * Provides access to VApp functionality in vCloud - *

- * - * @see - */ -@RequestFilters(AddVCloudAuthorizationAndCookieToRequest.class) -public interface VAppApi { - @GET - @Consumes(VAPP_XML) - @XMLResponseParser(VAppHandler.class) - @Fallback(Fallbacks.NullOnNotFoundOr404.class) - @MapBinder(OrgNameVDCNameResourceEntityNameToEndpoint.class) - VApp findVAppInOrgVDCNamed(@Nullable @PayloadParam("orgName") String orgName, - @Nullable @PayloadParam("vdcName") String vdcName, @PayloadParam("resourceName") String vAppName); - - @POST - @Path("/action/cloneVApp") - @Produces("application/vnd.vmware.vcloud.cloneVAppParams+xml") - @Consumes(TASK_XML) - @XMLResponseParser(TaskHandler.class) - @MapBinder(BindCloneVAppParamsToXmlPayload.class) - Task copyVAppToVDCAndName(@PayloadParam("Source") URI sourceVApp, - @EndpointParam URI vdc, @PayloadParam("name") @ParamValidators(DnsNameValidator.class) String newName, - CloneVAppOptions... options); - - @POST - @Path("/action/cloneVApp") - @Produces("application/vnd.vmware.vcloud.cloneVAppParams+xml") - @Consumes(TASK_XML) - @XMLResponseParser(TaskHandler.class) - @PayloadParams(keys = "IsSourceDelete", values = "true") - @MapBinder(BindCloneVAppParamsToXmlPayload.class) - Task moveVAppToVDCAndRename(@PayloadParam("Source") URI sourceVApp, - @EndpointParam URI vdc, @PayloadParam("name") @ParamValidators(DnsNameValidator.class) String newName, - CloneVAppOptions... options); - - @GET - @Consumes(VAPP_XML) - @XMLResponseParser(VAppHandler.class) - @Fallback(Fallbacks.NullOnNotFoundOr404.class) - VApp getVApp(@EndpointParam URI href); - - /** - * To deploy a vApp, the client makes a request to its action/deploy URL. Deploying a vApp - * automatically deploys all of the virtual machines it contains. To deploy a virtual machine, - * the client makes a request to its action/deploy URL. - *

- * Deploying a Vm implicitly deploys the parent vApp if that vApp is not already deployed. - */ - @POST - @Consumes(TASK_XML) - @Produces(DEPLOYVAPPPARAMS_XML) - @Path("/action/deploy") - @MapBinder(BindDeployVAppParamsToXmlPayload.class) - @XMLResponseParser(TaskHandler.class) - Task deployVApp(@EndpointParam URI href); - - /** - * like {@link #deployVApp(URI)}, except deploy transitions to power on state - * - */ - @POST - @Consumes(TASK_XML) - @Produces(DEPLOYVAPPPARAMS_XML) - @Path("/action/deploy") - @MapBinder(BindDeployVAppParamsToXmlPayload.class) - @PayloadParams(keys = "powerOn", values = "true") - @XMLResponseParser(TaskHandler.class) - Task deployAndPowerOnVApp(@EndpointParam URI href); - - /** - * Undeploying a vApp powers off or suspends any running virtual machines it contains, then frees - * the resources reserved for the vApp and sets the vApp’s deploy attribute to a value of false - * to indicate that it is not deployed. - *

- * Undeploying a virtual machine powers off or suspends the virtual machine, then frees the - * resources reserved for it and sets the its deploy attribute to a value of false to indicate - * that it is not deployed. This operation has no effect on the containing vApp. - *

NOTE

- * Using this method will simply power off the vms. In order to save their state, use - * {@link #undeployAndSaveStateOf} - * - */ - @POST - @Consumes(TASK_XML) - @Produces(UNDEPLOYVAPPPARAMS_XML) - @Path("/action/undeploy") - @MapBinder(BindUndeployVAppParamsToXmlPayload.class) - @XMLResponseParser(TaskHandler.class) - Task undeployVApp(@EndpointParam URI href); - - /** - * like {@link #undeployVApp(URI)}, where the undeployed virtual machines are suspended and their - * suspend state saved - * - */ - @POST - @Consumes(TASK_XML) - @Produces(UNDEPLOYVAPPPARAMS_XML) - @Path("/action/undeploy") - @MapBinder(BindUndeployVAppParamsToXmlPayload.class) - @PayloadParams(keys = "saveState", values = "true") - @XMLResponseParser(TaskHandler.class) - Task undeployAndSaveStateOfVApp(@EndpointParam URI href); - - /** - * A powerOn request to a vApp URL powers on all of the virtual machines in the vApp, as - * specified in the vApp’s StartupSection field. - *

- * A powerOn request to a virtual machine URL powers on the specified virtual machine and forces - * deployment of the parent vApp. - *

- *

NOTE

A powerOn request to a vApp or virtual machine that is undeployed forces - * deployment. - */ - @POST - @Consumes(TASK_XML) - @Path("/power/action/powerOn") - @XMLResponseParser(TaskHandler.class) - Task powerOnVApp(@EndpointParam URI href); - - /** - * A powerOff request to a vApp URL powers off all of the virtual machines in the vApp, as - * specified in its StartupSection field. - *

- * A powerOff request to a virtual machine URL powers off the specified virtual machine. - */ - @POST - @Consumes(TASK_XML) - @Path("/power/action/powerOff") - @XMLResponseParser(TaskHandler.class) - Task powerOffVApp(@EndpointParam URI href); - - /** - * A shutdown request to a vApp URL shuts down all of the virtual machines in the vApp, as - * specified in its StartupSection field. - *

- * A shutdown request to a virtual machine URL shuts down the specified virtual machine. - *

- *

NOTE - * A reset request to a virtual machine URL resets the specified virtual machine. - */ - @POST - @Consumes(TASK_XML) - @Path("/power/action/reset") - @XMLResponseParser(TaskHandler.class) - Task resetVApp(@EndpointParam URI href); - - /** - * A reboot request to a vApp URL reboots all of the virtual machines in the vApp, as specified - * in its StartupSection field. - *

- * A reboot request to a virtual machine URL reboots the specified virtual machine. - *

- *

NOTE

Because this request sends a signal to the guest OS, the vCloud API cannot track - * the progress or verify the result of the requested operation. Hence, void is returned - */ - @POST - @Path("/power/action/reboot") - void rebootVApp(@EndpointParam URI href); - - /** - * A suspend request to a vApp URL suspends all of the virtual machines in the vApp, as specified - * in its StartupSection field. - *

- * A suspend request to a virtual machine URL suspends the specified virtual machine. - */ - @POST - @Consumes(TASK_XML) - @Path("/power/action/suspend") - @XMLResponseParser(TaskHandler.class) - Task suspendVApp(@EndpointParam URI href); - - /** - * delete a vAppTemplate, vApp, or media image. You cannot delete an object if it is in use. Any - * object that is being copied or moved is in use. Other criteria that determine whether an - * object is in use depend on the object type. - *

    - *
  • A vApptemplate is in use if it is being instantiated. After instantiation is complete, the - * template is no longer in use.
  • - *
  • A vApp is in use if it is deployed.
  • - *
  • A media image is in use if it is inserted in a Vm.
  • - *
- * - * @param href - * href of the vApp - * @return task of the operation in progress - */ - @DELETE - @Consumes(TASK_XML) - @Fallback(Fallbacks.VoidOnNotFoundOr404.class) - @XMLResponseParser(TaskHandler.class) - Task deleteVApp(@EndpointParam URI href); -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/features/VAppTemplateApi.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/features/VAppTemplateApi.java deleted file mode 100644 index 8f4aa29867..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/features/VAppTemplateApi.java +++ /dev/null @@ -1,179 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.features; - -import static org.jclouds.vcloud.VCloudMediaType.TASK_XML; -import static org.jclouds.vcloud.VCloudMediaType.VAPPTEMPLATE_XML; -import static org.jclouds.vcloud.VCloudMediaType.VAPP_XML; - -import java.net.URI; - -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.Produces; -import javax.ws.rs.core.MediaType; - -import org.jclouds.Fallbacks; -import org.jclouds.javax.annotation.Nullable; -import org.jclouds.ovf.Envelope; -import org.jclouds.ovf.xml.EnvelopeHandler; -import org.jclouds.predicates.validators.DnsNameValidator; -import org.jclouds.rest.annotations.EndpointParam; -import org.jclouds.rest.annotations.Fallback; -import org.jclouds.rest.annotations.MapBinder; -import org.jclouds.rest.annotations.ParamValidators; -import org.jclouds.rest.annotations.PayloadParam; -import org.jclouds.rest.annotations.PayloadParams; -import org.jclouds.rest.annotations.RequestFilters; -import org.jclouds.rest.annotations.XMLResponseParser; -import org.jclouds.vcloud.binders.BindCaptureVAppParamsToXmlPayload; -import org.jclouds.vcloud.binders.BindCloneVAppTemplateParamsToXmlPayload; -import org.jclouds.vcloud.binders.BindInstantiateVAppTemplateParamsToXmlPayload; -import org.jclouds.vcloud.binders.OrgNameCatalogNameVAppTemplateNameToEndpoint; -import org.jclouds.vcloud.domain.Task; -import org.jclouds.vcloud.domain.VApp; -import org.jclouds.vcloud.domain.VAppTemplate; -import org.jclouds.vcloud.filters.AddVCloudAuthorizationAndCookieToRequest; -import org.jclouds.vcloud.options.CaptureVAppOptions; -import org.jclouds.vcloud.options.CloneVAppTemplateOptions; -import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions; -import org.jclouds.vcloud.xml.TaskHandler; -import org.jclouds.vcloud.xml.VAppHandler; -import org.jclouds.vcloud.xml.VAppTemplateHandler; - - -/** - * Provides access to VApp Template functionality in vCloud - *

- * - * @see - */ -@RequestFilters(AddVCloudAuthorizationAndCookieToRequest.class) -public interface VAppTemplateApi { - /** - * returns the vapp template corresponding to a catalog item in the catalog associated with the - * specified name. Note that the org and catalog parameters can be null to choose default. - * - * @param orgName - * organization name, or null for the default - * @param catalogName - * catalog name, or null for the default - * @param itemName - * item you wish to lookup - * - * @throws NoSuchElementException - * if you specified an org, catalog, or catalog item name that isn't present - */ - @GET - @Consumes(VAPPTEMPLATE_XML) - @XMLResponseParser(VAppTemplateHandler.class) - @Fallback(Fallbacks.NullOnNotFoundOr404.class) - @MapBinder(OrgNameCatalogNameVAppTemplateNameToEndpoint.class) - VAppTemplate findVAppTemplateInOrgCatalogNamed(@Nullable @PayloadParam("orgName") String orgName, - @Nullable @PayloadParam("catalogName") String catalogName, - @PayloadParam("itemName") String itemName); - - /** - */ - @POST - @Path("/action/instantiateVAppTemplate") - @Produces("application/vnd.vmware.vcloud.instantiateVAppTemplateParams+xml") - @Consumes(VAPP_XML) - @XMLResponseParser(VAppHandler.class) - @MapBinder(BindInstantiateVAppTemplateParamsToXmlPayload.class) - VApp createVAppInVDCByInstantiatingTemplate( - @PayloadParam("name") @ParamValidators(DnsNameValidator.class) String appName, @EndpointParam URI vdc, - @PayloadParam("template") URI template, InstantiateVAppTemplateOptions... options); - - @POST - @Path("/action/cloneVAppTemplate") - @Produces("application/vnd.vmware.vcloud.cloneVAppTemplateParams+xml") - @Consumes(TASK_XML) - @XMLResponseParser(TaskHandler.class) - @MapBinder(BindCloneVAppTemplateParamsToXmlPayload.class) - Task copyVAppTemplateToVDCAndName(@PayloadParam("Source") URI sourceVAppTemplate, - @EndpointParam URI vdc, @PayloadParam("name") @ParamValidators(DnsNameValidator.class) String newName, - CloneVAppTemplateOptions... options); - - @POST - @Path("/action/cloneVAppTemplate") - @Produces("application/vnd.vmware.vcloud.cloneVAppTemplateParams+xml") - @Consumes(TASK_XML) - @XMLResponseParser(TaskHandler.class) - @PayloadParams(keys = "IsSourceDelete", values = "true") - @MapBinder(BindCloneVAppTemplateParamsToXmlPayload.class) - Task moveVAppTemplateToVDCAndRename(@PayloadParam("Source") URI toClone, - @EndpointParam URI vdc, @PayloadParam("name") @ParamValidators(DnsNameValidator.class) String newName, - CloneVAppTemplateOptions... options); - - /** - * The captureVApp request creates a vApp template from an instantiated vApp.

Note

- * Before it can be captured, a vApp must be undeployed - * - * @param targetVdcHref - * @param sourceVAppHref - * @param newTemplateName - * @param options - * @return template in progress - */ - @POST - @Path("/action/captureVApp") - @Produces("application/vnd.vmware.vcloud.captureVAppParams+xml") - @Consumes(VAPPTEMPLATE_XML) - @XMLResponseParser(VAppTemplateHandler.class) - @MapBinder(BindCaptureVAppParamsToXmlPayload.class) - VAppTemplate captureVAppAsTemplateInVDC(@PayloadParam("vApp") URI toCapture, - @PayloadParam("templateName") @ParamValidators(DnsNameValidator.class) String templateName, - @EndpointParam URI vdc, CaptureVAppOptions... options); - - @GET - @Consumes(VAPPTEMPLATE_XML) - @XMLResponseParser(VAppTemplateHandler.class) - @Fallback(Fallbacks.NullOnNotFoundOr404.class) - VAppTemplate getVAppTemplate(@EndpointParam URI vAppTemplate); - - @GET - @Consumes(MediaType.TEXT_XML) - @Path("/ovf") - @XMLResponseParser(EnvelopeHandler.class) - @Fallback(Fallbacks.NullOnNotFoundOr404.class) - Envelope getOvfEnvelopeForVAppTemplate(@EndpointParam URI href); - - /** - * delete a vAppTemplate, vApp, or media image. You cannot delete an object if it is in use. Any - * object that is being copied or moved is in use. Other criteria that determine whether an - * object is in use depend on the object type. - *
    - *
  • A vApptemplate is in use if it is being instantiated. After instantiation is complete, the - * template is no longer in use.
  • - *
  • A vApp is in use if it is deployed.
  • - *
  • A media image is in use if it is inserted in a Vm.
  • - *
- * - * @param id - * href of the vApp - * @return task of the operation in progress - */ - @DELETE - @Consumes(TASK_XML) - @Fallback(Fallbacks.VoidOnNotFoundOr404.class) - @XMLResponseParser(TaskHandler.class) - Task deleteVAppTemplate(@EndpointParam URI href); -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/features/VDCApi.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/features/VDCApi.java deleted file mode 100644 index 7b02798f91..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/features/VDCApi.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.features; - -import static org.jclouds.vcloud.VCloudMediaType.VDC_XML; - -import java.net.URI; - -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; - -import org.jclouds.Fallbacks; -import org.jclouds.javax.annotation.Nullable; -import org.jclouds.rest.annotations.EndpointParam; -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.XMLResponseParser; -import org.jclouds.vcloud.binders.OrgNameAndVDCNameToEndpoint; -import org.jclouds.vcloud.domain.VDC; -import org.jclouds.vcloud.filters.AddVCloudAuthorizationAndCookieToRequest; -import org.jclouds.vcloud.xml.VDCHandler; - - -/** - * Provides access to VDC functionality in vCloud - *

- */ -@RequestFilters(AddVCloudAuthorizationAndCookieToRequest.class) -public interface VDCApi { - @GET - @XMLResponseParser(VDCHandler.class) - @Consumes(VDC_XML) - @Fallback(Fallbacks.NullOnNotFoundOr404.class) - VDC getVDC(@EndpointParam URI vdc); - - /** - * returns the VDC in the organization associated with the specified name. Note that both - * parameters can be null to choose default. - * - * @param orgName - * organization name, or null for the default - * @param vdcName - * catalog name, or null for the default - * @throws NoSuchElementException - * if you specified an org or vdc name that isn't present - */ - @GET - @XMLResponseParser(VDCHandler.class) - @Consumes(VDC_XML) - @Fallback(Fallbacks.NullOnNotFoundOr404.class) - @MapBinder(OrgNameAndVDCNameToEndpoint.class) - VDC findVDCInOrgNamed(@Nullable @PayloadParam("orgName") String orgName, - @Nullable @PayloadParam("vdcName") String vdcName); - -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/features/VmApi.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/features/VmApi.java deleted file mode 100644 index 8aa186e759..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/features/VmApi.java +++ /dev/null @@ -1,293 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.features; - -import static org.jclouds.vcloud.VCloudMediaType.DEPLOYVAPPPARAMS_XML; -import static org.jclouds.vcloud.VCloudMediaType.GUESTCUSTOMIZATIONSECTION_XML; -import static org.jclouds.vcloud.VCloudMediaType.NETWORKCONNECTIONSECTION_XML; -import static org.jclouds.vcloud.VCloudMediaType.RASDITEM_XML; -import static org.jclouds.vcloud.VCloudMediaType.TASK_XML; -import static org.jclouds.vcloud.VCloudMediaType.UNDEPLOYVAPPPARAMS_XML; -import static org.jclouds.vcloud.VCloudMediaType.VM_XML; - -import java.io.InputStream; -import java.net.URI; - -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; - -import org.jclouds.Fallbacks; -import org.jclouds.rest.annotations.BinderParam; -import org.jclouds.rest.annotations.EndpointParam; -import org.jclouds.rest.annotations.Fallback; -import org.jclouds.rest.annotations.MapBinder; -import org.jclouds.rest.annotations.PayloadParams; -import org.jclouds.rest.annotations.RequestFilters; -import org.jclouds.rest.annotations.XMLResponseParser; -import org.jclouds.vcloud.binders.BindCPUCountToXmlPayload; -import org.jclouds.vcloud.binders.BindDeployVAppParamsToXmlPayload; -import org.jclouds.vcloud.binders.BindGuestCustomizationSectionToXmlPayload; -import org.jclouds.vcloud.binders.BindMemoryToXmlPayload; -import org.jclouds.vcloud.binders.BindNetworkConnectionSectionToXmlPayload; -import org.jclouds.vcloud.binders.BindUndeployVAppParamsToXmlPayload; -import org.jclouds.vcloud.domain.GuestCustomizationSection; -import org.jclouds.vcloud.domain.NetworkConnectionSection; -import org.jclouds.vcloud.domain.Task; -import org.jclouds.vcloud.domain.Vm; -import org.jclouds.vcloud.filters.AddVCloudAuthorizationAndCookieToRequest; -import org.jclouds.vcloud.xml.TaskHandler; -import org.jclouds.vcloud.xml.VmHandler; - - -/** - * Provides access to VM functionality in vCloud - *

- */ -@RequestFilters(AddVCloudAuthorizationAndCookieToRequest.class) -public interface VmApi { - - @GET - @Consumes(VM_XML) - @XMLResponseParser(VmHandler.class) - @Fallback(Fallbacks.NullOnNotFoundOr404.class) - Vm getVm(@EndpointParam URI href); - - /** - * To deploy a vApp, the client makes a request to its action/deploy URL. Deploying a vApp - * automatically deploys all of the virtual machines it contains. To deploy a virtual machine, - * the client makes a request to its action/deploy URL. - *

- * Deploying a Vm implicitly deploys the parent vApp if that vApp is not already deployed. - */ - @POST - @Consumes(TASK_XML) - @Produces(DEPLOYVAPPPARAMS_XML) - @Path("/action/deploy") - @MapBinder(BindDeployVAppParamsToXmlPayload.class) - @XMLResponseParser(TaskHandler.class) - Task deployVm(@EndpointParam URI href); - - /** - * like {@link #deploy(URI)}, except deploy transitions to power on state - * - */ - @POST - @Consumes(TASK_XML) - @Produces(DEPLOYVAPPPARAMS_XML) - @Path("/action/deploy") - @MapBinder(BindDeployVAppParamsToXmlPayload.class) - @PayloadParams(keys = "powerOn", values = "true") - @XMLResponseParser(TaskHandler.class) - Task deployAndPowerOnVm(@EndpointParam URI href); - - /** - * Undeploying a vApp powers off or suspends any running virtual machines it contains, then frees - * the resources reserved for the vApp and sets the vApp’s deploy attribute to a value of false - * to indicate that it is not deployed. - *

- * Undeploying a virtual machine powers off or suspends the virtual machine, then frees the - * resources reserved for it and sets the its deploy attribute to a value of false to indicate - * that it is not deployed. This operation has no effect on the containing vApp. - *

NOTE

- * Using this method will simply power off the vms. In order to save their state, use - * {@link #undeployAndSaveStateOf} - * - */ - @POST - @Consumes(TASK_XML) - @Produces(UNDEPLOYVAPPPARAMS_XML) - @Path("/action/undeploy") - @MapBinder(BindUndeployVAppParamsToXmlPayload.class) - @XMLResponseParser(TaskHandler.class) - Task undeployVm(@EndpointParam URI href); - - /** - * like {@link #undeploy(URI)}, where the undeployed virtual machines are suspended and their - * suspend state saved - * - */ - @POST - @Consumes(TASK_XML) - @Produces(UNDEPLOYVAPPPARAMS_XML) - @Path("/action/undeploy") - @MapBinder(BindUndeployVAppParamsToXmlPayload.class) - @PayloadParams(keys = "saveState", values = "true") - @XMLResponseParser(TaskHandler.class) - Task undeployAndSaveStateOfVm(@EndpointParam URI href); - - /** - * A powerOn request to a vApp URL powers on all of the virtual machines in the vApp, as - * specified in the vApp’s StartupSection field. - *

- * A powerOn request to a virtual machine URL powers on the specified virtual machine and forces - * deployment of the parent vApp. - *

- *

NOTE

A powerOn request to a vApp or virtual machine that is undeployed forces - * deployment. - */ - @POST - @Consumes(TASK_XML) - @Path("/power/action/powerOn") - @XMLResponseParser(TaskHandler.class) - Task powerOnVm(@EndpointParam URI href); - - /** - * A powerOff request to a vApp URL powers off all of the virtual machines in the vApp, as - * specified in its StartupSection field. - *

- * A powerOff request to a virtual machine URL powers off the specified virtual machine. - */ - @POST - @Consumes(TASK_XML) - @Path("/power/action/powerOff") - @XMLResponseParser(TaskHandler.class) - Task powerOffVm(@EndpointParam URI href); - - /** - * A shutdown request to a vApp URL shuts down all of the virtual machines in the vApp, as - * specified in its StartupSection field. - *

- * A shutdown request to a virtual machine URL shuts down the specified virtual machine. - *

- *

NOTE - * A reset request to a virtual machine URL resets the specified virtual machine. - */ - @POST - @Consumes(TASK_XML) - @Path("/power/action/reset") - @XMLResponseParser(TaskHandler.class) - Task resetVm(@EndpointParam URI href); - - /** - * A reboot request to a vApp URL reboots all of the virtual machines in the vApp, as specified - * in its StartupSection field. - *

- * A reboot request to a virtual machine URL reboots the specified virtual machine. - *

- *

NOTE

Because this request sends a signal to the guest OS, the vCloud API cannot track - * the progress or verify the result of the requested operation. Hence, void is returned - */ - @POST - @Path("/power/action/reboot") - void rebootVm(@EndpointParam URI href); - - /** - * A suspend request to a vApp URL suspends all of the virtual machines in the vApp, as specified - * in its StartupSection field. - *

- * A suspend request to a virtual machine URL suspends the specified virtual machine. - */ - @POST - @Consumes(TASK_XML) - @Path("/power/action/suspend") - @XMLResponseParser(TaskHandler.class) - Task suspendVm(@EndpointParam URI href); - - /** - * Get a Screen Thumbnail for a Virtual Machine - * - * @param href - * to snapshot - */ - @GET - @Path("/screen") - @Consumes("image/png") - @Fallback(Fallbacks.NullOnNotFoundOr404.class) - InputStream getScreenThumbnailForVm(@EndpointParam URI vm); - - /** - * Modify the Guest Customization Section of a Virtual Machine - * - * @param href - * uri to modify - * @param updated - * guestCustomizationSection - * @return task in progress - */ - @PUT - @Consumes(TASK_XML) - @Produces(GUESTCUSTOMIZATIONSECTION_XML) - @Path("/guestCustomizationSection") - @XMLResponseParser(TaskHandler.class) - Task updateGuestCustomizationOfVm( - @BinderParam(BindGuestCustomizationSectionToXmlPayload.class) GuestCustomizationSection guestCustomizationSection, - @EndpointParam URI href); - - /** - * Modify the Network Connection Section of a Virtual Machine - * - * @param href - * uri to modify - * @param updated - * networkConnectionSection - * @return task in progress - */ - @PUT - @Consumes(TASK_XML) - @Produces(NETWORKCONNECTIONSECTION_XML) - @Path("/networkConnectionSection") - @XMLResponseParser(TaskHandler.class) - Task updateNetworkConnectionOfVm( - @BinderParam(BindNetworkConnectionSectionToXmlPayload.class) NetworkConnectionSection networkConnectionSection, - @EndpointParam URI href); - - /** - * update the cpuCount of an existing VM - * - * @param href - * to update - * @param cpuCount - * count to change the primary cpu to - */ - @PUT - @Consumes(TASK_XML) - @Produces(RASDITEM_XML) - @Path("/virtualHardwareSection/cpu") - @XMLResponseParser(TaskHandler.class) - Task updateCPUCountOfVm(@BinderParam(BindCPUCountToXmlPayload.class) int cpuCount, - @EndpointParam URI href); - - /** - * update the memoryInMB of an existing VM - * - * @param href - * to update - * @param memoryInMB - * memory in MB to assign to the VM - */ - @PUT - @Consumes(TASK_XML) - @Produces(RASDITEM_XML) - @Path("/virtualHardwareSection/memory") - @XMLResponseParser(TaskHandler.class) - Task updateMemoryMBOfVm(@BinderParam(BindMemoryToXmlPayload.class) int memoryInMB, - @EndpointParam URI href); -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/filters/AddVCloudAuthorizationAndCookieToRequest.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/filters/AddVCloudAuthorizationAndCookieToRequest.java deleted file mode 100644 index 9d2953faff..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/filters/AddVCloudAuthorizationAndCookieToRequest.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.filters; - -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jclouds.http.HttpException; -import org.jclouds.http.HttpRequest; -import org.jclouds.http.HttpRequestFilter; -import org.jclouds.vcloud.VCloudToken; - -import com.google.common.base.Supplier; -import com.google.common.collect.ImmutableMultimap; -import com.google.common.net.HttpHeaders; - -/** - * Adds the VCloud Token to the request as a cookie - */ -@Singleton -public class AddVCloudAuthorizationAndCookieToRequest implements HttpRequestFilter { - private Supplier vcloudTokenProvider; - - @Inject - public AddVCloudAuthorizationAndCookieToRequest(@VCloudToken Supplier authTokenProvider) { - this.vcloudTokenProvider = authTokenProvider; - } - - @Override - public HttpRequest filter(HttpRequest request) throws HttpException { - String token = vcloudTokenProvider.get(); - return request - .toBuilder() - .replaceHeaders( - ImmutableMultimap.of("x-vcloud-authorization", token, HttpHeaders.COOKIE, "vcloud-token=" - + token)).build(); - } -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/functions/CatalogItemsInCatalog.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/functions/CatalogItemsInCatalog.java deleted file mode 100644 index db18f9e5f1..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/functions/CatalogItemsInCatalog.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.functions; - -import static com.google.common.collect.Iterables.filter; -import static com.google.common.collect.Iterables.transform; - -import javax.annotation.Resource; -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jclouds.logging.Logger; -import org.jclouds.vcloud.VCloudApi; -import org.jclouds.vcloud.VCloudMediaType; -import org.jclouds.vcloud.domain.Catalog; -import org.jclouds.vcloud.domain.CatalogItem; -import org.jclouds.vcloud.domain.ReferenceType; - -import com.google.common.base.Function; -import com.google.common.base.Predicate; - -@Singleton -public class CatalogItemsInCatalog implements Function> { - @Resource - public Logger logger = Logger.NULL; - - private final VCloudApi aclient; - - @Inject - CatalogItemsInCatalog(VCloudApi aclient) { - this.aclient = aclient; - } - - @Override - public Iterable apply(Catalog from) { - return transform(filter(from.values(), new Predicate() { - public boolean apply(ReferenceType input) { - return input.getType().equals(VCloudMediaType.CATALOGITEM_XML); - } - }), new Function() { - public CatalogItem apply(ReferenceType from) { - return aclient.getCatalogApi().getCatalogItem(from.getHref()); - } - }); - } - -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/functions/CatalogItemsInOrg.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/functions/CatalogItemsInOrg.java deleted file mode 100644 index f6ccf7d270..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/functions/CatalogItemsInOrg.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.functions; - -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jclouds.vcloud.domain.Catalog; -import org.jclouds.vcloud.domain.CatalogItem; -import org.jclouds.vcloud.domain.Org; - -import com.google.common.base.Function; -import com.google.common.collect.Iterables; - -@Singleton -public class CatalogItemsInOrg implements Function> { - - private final Function> allCatalogsInOrg; - - private final Function> allCatalogItemsInCatalog; - - @Inject - CatalogItemsInOrg(Function> allCatalogsInOrg, - Function> allCatalogItemsInCatalog) { - this.allCatalogsInOrg = allCatalogsInOrg; - this.allCatalogItemsInCatalog = allCatalogItemsInCatalog; - } - - @Override - public Iterable apply(Org from) { - return Iterables.concat(Iterables.transform(allCatalogsInOrg.apply(from), - new Function>() { - @Override - public Iterable apply(Catalog from) { - return allCatalogItemsInCatalog.apply(from); - } - - })); - } -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/functions/CatalogsInOrg.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/functions/CatalogsInOrg.java deleted file mode 100644 index 15be6c74c1..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/functions/CatalogsInOrg.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.functions; - -import static com.google.common.collect.Iterables.transform; - -import javax.annotation.Resource; -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jclouds.logging.Logger; -import org.jclouds.vcloud.VCloudApi; -import org.jclouds.vcloud.domain.Catalog; -import org.jclouds.vcloud.domain.Org; -import org.jclouds.vcloud.domain.ReferenceType; - -import com.google.common.base.Function; - -@Singleton -public class CatalogsInOrg implements Function> { - @Resource - public Logger logger = Logger.NULL; - - private final VCloudApi aclient; - - @Inject - CatalogsInOrg(VCloudApi aclient) { - this.aclient = aclient; - } - - @Override - public Iterable apply(final Org org) { - return transform(org.getCatalogs().values(), new Function() { - public Catalog apply(ReferenceType from) { - return aclient.getCatalogApi().getCatalog(from.getHref()); - } - }); - } -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/functions/DefaultNetworkNameInTemplate.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/functions/DefaultNetworkNameInTemplate.java deleted file mode 100644 index 11712cc91f..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/functions/DefaultNetworkNameInTemplate.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.functions; - -import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.collect.Iterables.get; - -import java.util.Set; - -import javax.annotation.Resource; -import javax.inject.Singleton; - -import org.jclouds.logging.Logger; -import org.jclouds.ovf.Network; -import org.jclouds.vcloud.domain.VAppTemplate; - -import com.google.common.base.Function; - -@Singleton -public class DefaultNetworkNameInTemplate implements Function { - @Resource - protected Logger logger = Logger.NULL; - - @Override - public String apply(VAppTemplate vAppTemplate) { - checkArgument(vAppTemplate != null, "vAppTemplate was null!"); - Set networks = vAppTemplate.getNetworkSection().getNetworks(); - checkArgument(!networks.isEmpty(), "no networks found in vAppTemplate %s", vAppTemplate); - if (networks.size() > 1) - logger.warn("multiple networks found for %s, choosing first from: %s", vAppTemplate.getName(), networks); - return get(networks, 0).getName(); - } -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/functions/NetworksInOrg.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/functions/NetworksInOrg.java deleted file mode 100644 index 25c18a10a0..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/functions/NetworksInOrg.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.functions; - -import static com.google.common.collect.Iterables.transform; - -import javax.annotation.Resource; -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jclouds.logging.Logger; -import org.jclouds.vcloud.VCloudApi; -import org.jclouds.vcloud.domain.Org; -import org.jclouds.vcloud.domain.ReferenceType; -import org.jclouds.vcloud.domain.network.OrgNetwork; - -import com.google.common.base.Function; - -@Singleton -public class NetworksInOrg implements Function> { - @Resource - public Logger logger = Logger.NULL; - - private final VCloudApi aclient; - - @Inject - NetworksInOrg(VCloudApi aclient) { - this.aclient = aclient; - } - - @Override - public Iterable apply(final Org org) { - return transform(org.getNetworks().values(), new Function() { - public OrgNetwork apply(ReferenceType from) { - return aclient.getNetworkApi().getNetwork(from.getHref()); - } - }); - } - -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/functions/OrgNameToEndpoint.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/functions/OrgNameToEndpoint.java deleted file mode 100644 index bc762a59c1..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/functions/OrgNameToEndpoint.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.functions; - -import java.net.URI; -import java.util.Map; -import java.util.NoSuchElementException; - -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jclouds.vcloud.domain.ReferenceType; -import org.jclouds.vcloud.endpoints.Org; - -import com.google.common.base.Function; -import com.google.common.base.Supplier; - -@Singleton -public class OrgNameToEndpoint implements Function { - private final Supplier> orgNameToEndpointSupplier; - private final Supplier defaultOrg; - - @Inject - public OrgNameToEndpoint(@Org Supplier> orgNameToEndpointSupplier, - @Org Supplier defaultOrg) { - this.orgNameToEndpointSupplier = orgNameToEndpointSupplier; - this.defaultOrg = defaultOrg; - } - - public URI apply(Object from) { - try { - Map orgNameToEndpoint = orgNameToEndpointSupplier.get(); - return from == null ? defaultOrg.get().getHref() : orgNameToEndpoint.get(from).getHref(); - } catch (NullPointerException e) { - throw new NoSuchElementException("org " + from + " not found in " + orgNameToEndpointSupplier.get().keySet()); - } - } - -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/functions/OrgNameToTasksListEndpoint.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/functions/OrgNameToTasksListEndpoint.java deleted file mode 100644 index 1d3fc4aa6f..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/functions/OrgNameToTasksListEndpoint.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.functions; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.net.URI; -import java.util.Map; -import java.util.NoSuchElementException; - -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jclouds.vcloud.domain.Org; -import org.jclouds.vcloud.domain.ReferenceType; -import org.jclouds.vcloud.endpoints.TasksList; - -import com.google.common.base.Function; -import com.google.common.base.Supplier; - -@Singleton -public class OrgNameToTasksListEndpoint implements Function { - private final Supplier> orgMap; - private final Supplier defaultTasksList; - - @Inject - public OrgNameToTasksListEndpoint(Supplier> orgMap, - @TasksList Supplier defaultTasksList) { - this.orgMap = orgMap; - this.defaultTasksList = defaultTasksList; - } - - public URI apply(Object from) { - Object org = from; - if (org == null) - return defaultTasksList.get().getHref(); - try { - return checkNotNull(orgMap.get().get(org)).getTasksList().getHref(); - } catch (NullPointerException e) { - throw new NoSuchElementException(org + " not found in " + orgMap.get()); - } - } - -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/functions/OrgsForLocations.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/functions/OrgsForLocations.java deleted file mode 100644 index 72be2f6129..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/functions/OrgsForLocations.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.functions; - -import static com.google.common.collect.Iterables.transform; - -import java.net.URI; - -import javax.annotation.Resource; -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jclouds.domain.Location; -import org.jclouds.domain.LocationScope; -import org.jclouds.logging.Logger; -import org.jclouds.vcloud.VCloudApi; -import org.jclouds.vcloud.domain.Org; - -import com.google.common.base.Function; -import com.google.common.base.Predicate; -import com.google.common.collect.FluentIterable; - -@Singleton -public class OrgsForLocations implements Function, Iterable> { - @Resource - public Logger logger = Logger.NULL; - private final VCloudApi aclient; - - @Inject - OrgsForLocations(VCloudApi aclient) { - this.aclient = aclient; - } - - /** - * Zones are assignable, but we want regions. so we look for zones, whose - * parent is region. then, we use a set to extract the unique set. - */ - @Override - public Iterable apply(Iterable from) { - FluentIterable uris = FluentIterable.from(from).filter(new Predicate() { - public boolean apply(Location input) { - return input.getScope() == LocationScope.ZONE; - } - }).transform(new Function() { - public URI apply(Location from) { - return URI.create(from.getParent().getId()); - } - }); - return transform(uris, new Function() { - public Org apply(URI from) { - return aclient.getOrgApi().getOrg(from); - } - }); - } - -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/functions/OrgsForNames.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/functions/OrgsForNames.java deleted file mode 100644 index ce3cd9ebb6..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/functions/OrgsForNames.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.functions; - -import static com.google.common.collect.Iterables.transform; - -import javax.annotation.Resource; -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jclouds.logging.Logger; -import org.jclouds.vcloud.VCloudApi; -import org.jclouds.vcloud.domain.Org; - -import com.google.common.base.Function; -import com.google.common.base.Predicates; -import com.google.common.collect.Iterables; - -@Singleton -public class OrgsForNames implements Function, Iterable> { - @Resource - public Logger logger = Logger.NULL; - private final VCloudApi aclient; - - @Inject - OrgsForNames(VCloudApi aclient) { - this.aclient = aclient; - } - - @Override - public Iterable apply(Iterable from) { - return Iterables.filter(transform(from, new Function() { - public Org apply(String from) { - return aclient.getOrgApi().findOrgNamed(from); - } - }), Predicates.notNull()); - } - -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/functions/ParseLoginResponseFromHeaders.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/functions/ParseLoginResponseFromHeaders.java deleted file mode 100644 index d9900fd247..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/functions/ParseLoginResponseFromHeaders.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.functions; -import static com.google.common.base.Preconditions.checkNotNull; -import static org.jclouds.http.HttpUtils.releasePayload; - -import java.util.Map; -import java.util.NoSuchElementException; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import javax.inject.Inject; -import javax.inject.Provider; -import javax.inject.Singleton; - -import org.jclouds.http.HttpResponse; -import org.jclouds.http.HttpResponseException; -import org.jclouds.http.functions.ParseSax; -import org.jclouds.http.functions.ParseSax.Factory; -import org.jclouds.vcloud.VCloudToken; -import org.jclouds.vcloud.domain.ReferenceType; -import org.jclouds.vcloud.domain.VCloudSession; -import org.jclouds.vcloud.endpoints.Org; -import org.jclouds.vcloud.xml.OrgListHandler; - -import com.google.common.base.Function; -import com.google.common.base.Predicates; -import com.google.common.collect.Iterables; -import com.google.common.net.HttpHeaders; - -/** - * This parses {@link VCloudSession} from HTTP headers. - */ -@Singleton -public class ParseLoginResponseFromHeaders implements Function { - static final Pattern pattern = Pattern.compile("(vcloud-token)=?([^;]+)(;.*)?"); - - private final ParseSax.Factory factory; - private final Provider orgHandlerProvider; - - @Inject - private ParseLoginResponseFromHeaders(Factory factory, Provider orgHandlerProvider) { - this.factory = factory; - this.orgHandlerProvider = orgHandlerProvider; - } - - /** - * parses the http response headers to create a new {@link VCloudSession} object. - */ - public VCloudSession apply(HttpResponse from) { - try { - final String token = parseTokenFromHeaders(from); - final Map org = factory.create(orgHandlerProvider.get()).parse( - checkNotNull(from.getPayload().getInput(), "no payload in http response to login request %s", from)); - - return new VCloudSession() { - @VCloudToken - public String getVCloudToken() { - return token; - } - - @Org - public Map getOrgs() { - return org; - } - }; - } finally { - releasePayload(from); - } - } - - public String parseTokenFromHeaders(HttpResponse from) { - String cookieHeader = from.getFirstHeaderOrNull("x-vcloud-authorization"); - if (cookieHeader != null) { - Matcher matcher = pattern.matcher(cookieHeader); - return matcher.find() ? matcher.group(2) : cookieHeader; - } else { - try { - cookieHeader = Iterables.find(from.getHeaders().get(HttpHeaders.SET_COOKIE), Predicates.contains(pattern)); - Matcher matcher = pattern.matcher(cookieHeader); - matcher.find(); - return matcher.group(2); - } catch (NoSuchElementException e) { - throw new HttpResponseException(String.format("Header %s or %s must be present", "x-vcloud-authorization", - HttpHeaders.SET_COOKIE), null, from); - } - } - } -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/functions/VAppTemplatesForCatalogItems.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/functions/VAppTemplatesForCatalogItems.java deleted file mode 100644 index d3a6a9b0ff..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/functions/VAppTemplatesForCatalogItems.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.functions; - -import static com.google.common.collect.Iterables.filter; -import static com.google.common.collect.Iterables.transform; - -import javax.annotation.Resource; -import javax.inject.Inject; -import javax.inject.Named; -import javax.inject.Singleton; - -import org.jclouds.compute.reference.ComputeServiceConstants; -import org.jclouds.logging.Logger; -import org.jclouds.vcloud.VCloudApi; -import org.jclouds.vcloud.VCloudMediaType; -import org.jclouds.vcloud.domain.CatalogItem; -import org.jclouds.vcloud.domain.VAppTemplate; - -import com.google.common.base.Function; -import com.google.common.base.Predicate; -import com.google.common.base.Predicates; - -@Singleton -public class VAppTemplatesForCatalogItems implements Function, Iterable> { - @Resource - @Named(ComputeServiceConstants.COMPUTE_LOGGER) - private Logger logger = Logger.NULL; - private final VCloudApi aclient; - - @Inject - VAppTemplatesForCatalogItems(VCloudApi aclient) { - this.aclient = aclient; - } - - @Override - public Iterable apply(Iterable from) { - return filter(transform(filter(from, new Predicate() { - public boolean apply(CatalogItem input) { - return input.getEntity().getType().equals(VCloudMediaType.VAPPTEMPLATE_XML); - } - }), new Function() { - public VAppTemplate apply(CatalogItem from) { - return aclient.getVAppTemplateApi().getVAppTemplate(from.getEntity().getHref()); - } - }), Predicates.notNull()); - } - -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/functions/VAppTemplatesInOrg.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/functions/VAppTemplatesInOrg.java deleted file mode 100644 index 992c2af7d6..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/functions/VAppTemplatesInOrg.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.functions; - -import static com.google.common.base.Predicates.and; -import static com.google.common.base.Predicates.notNull; -import static com.google.common.collect.Iterables.filter; - -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jclouds.vcloud.domain.CatalogItem; -import org.jclouds.vcloud.domain.Org; -import org.jclouds.vcloud.domain.Status; -import org.jclouds.vcloud.domain.VAppTemplate; - -import com.google.common.base.Function; -import com.google.common.base.Predicate; -import com.google.common.collect.ImmutableSet; - -@Singleton -public class VAppTemplatesInOrg implements Function> { - - private final Function> allCatalogItemsInOrg; - private final Function, Iterable> vAppTemplatesForCatalogItems; - - @Inject - VAppTemplatesInOrg(Function> allCatalogItemsInOrg, - Function, Iterable> vAppTemplatesForCatalogItems) { - this.allCatalogItemsInOrg = allCatalogItemsInOrg; - this.vAppTemplatesForCatalogItems = vAppTemplatesForCatalogItems; - } - - @Override - public Iterable apply(Org from) { - Iterable catalogs = allCatalogItemsInOrg.apply(from); - Iterable vAppTemplates = vAppTemplatesForCatalogItems.apply(catalogs); - return filter(vAppTemplates, and(notNull(), new Predicate() { - @Override - public boolean apply(VAppTemplate input) { - if (input == null) - return false; - return ImmutableSet.of(Status.RESOLVED, Status.OFF).contains(input.getStatus()); - } - })); - } - -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/functions/VDCsInOrg.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/functions/VDCsInOrg.java deleted file mode 100644 index 4457233569..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/functions/VDCsInOrg.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.functions; - -import static com.google.common.collect.Iterables.transform; - -import javax.annotation.Resource; -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jclouds.logging.Logger; -import org.jclouds.vcloud.VCloudApi; -import org.jclouds.vcloud.domain.Org; -import org.jclouds.vcloud.domain.ReferenceType; -import org.jclouds.vcloud.domain.VDC; - -import com.google.common.base.Function; - -@Singleton -public class VDCsInOrg implements Function> { - @Resource - public Logger logger = Logger.NULL; - - private final VCloudApi aclient; - - @Inject - VDCsInOrg(VCloudApi aclient) { - this.aclient = aclient; - } - - @Override - public Iterable apply(final Org org) { - return transform(org.getVDCs().values(), new Function() { - public VDC apply(ReferenceType from) { - return aclient.getVDCApi().getVDC(from.getHref()); - } - }); - } - -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/handlers/ParseVCloudErrorFromHttpResponse.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/handlers/ParseVCloudErrorFromHttpResponse.java deleted file mode 100644 index 2c9f96f454..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/handlers/ParseVCloudErrorFromHttpResponse.java +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.handlers; - -import static org.jclouds.http.HttpUtils.releasePayload; - -import java.io.IOException; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import javax.annotation.Resource; -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jclouds.http.HttpCommand; -import org.jclouds.http.HttpErrorHandler; -import org.jclouds.http.HttpRequest; -import org.jclouds.http.HttpResponse; -import org.jclouds.http.HttpResponseException; -import org.jclouds.logging.Logger; -import org.jclouds.rest.AuthorizationException; -import org.jclouds.rest.ResourceNotFoundException; -import org.jclouds.util.Strings2; -import org.jclouds.vcloud.VCloudResponseException; -import org.jclouds.vcloud.domain.VCloudError; -import org.jclouds.vcloud.domain.VCloudError.MinorCode; -import org.jclouds.vcloud.util.VCloudUtils; - -/** - * This will parse and set an appropriate exception on the command object. - */ -@Singleton -public class ParseVCloudErrorFromHttpResponse implements HttpErrorHandler { - @Resource - protected Logger logger = Logger.NULL; - public static final Pattern RESOURCE_PATTERN = Pattern.compile(".*/v[^/]+/([^/]+)/([0-9]+)"); - private final VCloudUtils utils; - - @Inject - public ParseVCloudErrorFromHttpResponse(VCloudUtils utils) { - this.utils = utils; - } - - public void handleError(HttpCommand command, HttpResponse response) { - HttpRequest request = command.getCurrentRequest(); - Exception exception = new HttpResponseException(command, response); - try { - VCloudError error = null; - String message = null; - if (response.getPayload() != null) { - try { - error = utils.parseErrorFromContent(request, response); - if (error != null) { - message = error.getMessage(); - exception = new VCloudResponseException(command, response, error); - } else { - message = Strings2.toStringAndClose(response.getPayload().openStream()); - exception = message != null ? new HttpResponseException(command, response, message) : exception; - } - } catch (IOException e) { - } finally { - response.getPayload().release(); - } - } - message = message != null ? message : String.format("%s -> %s", request.getRequestLine(), response - .getStatusLine()); - - switch (response.getStatusCode()) { - case 400: - if (error != null - && ((error.getMinorErrorCode() != null && error.getMinorErrorCode() == MinorCode.BUSY_ENTITY) - || (error.getMessage() != null && error.getMessage().indexOf("is not running") != -1))) - exception = new IllegalStateException(message, exception); - else - exception = new IllegalArgumentException(message, exception); - break; - case 401: - case 403: - if (error != null - && ((error.getMinorErrorCode() != null && error.getMinorErrorCode() == MinorCode.ACCESS_TO_RESOURCE_IS_FORBIDDEN) - || (error.getMessage() != null && error.getMessage().indexOf("No access to entity") != -1))) - exception = new ResourceNotFoundException(message, exception); - else - exception = new AuthorizationException(exception.getMessage(), exception); - break; - case 404: - if (!command.getCurrentRequest().getMethod().equals("DELETE")) { - String path = command.getCurrentRequest().getEndpoint().getPath(); - Matcher matcher = RESOURCE_PATTERN.matcher(path); - if (matcher.find()) { - message = String.format("%s %s not found", matcher.group(1), matcher.group(2)); - } else { - message = path; - } - exception = new ResourceNotFoundException(message); - } - break; - } - } finally { - releasePayload(response); - command.setException(exception); - } - } -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/internal/VCloudLoginApi.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/internal/VCloudLoginApi.java deleted file mode 100644 index acf77c5ac4..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/internal/VCloudLoginApi.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.internal; - -import java.io.Closeable; - -import javax.ws.rs.Consumes; -import javax.ws.rs.POST; - -import org.jclouds.http.filters.BasicAuthentication; -import org.jclouds.rest.annotations.Endpoint; -import org.jclouds.rest.annotations.RequestFilters; -import org.jclouds.rest.annotations.ResponseParser; -import org.jclouds.vcloud.VCloudMediaType; -import org.jclouds.vcloud.domain.VCloudSession; -import org.jclouds.vcloud.functions.ParseLoginResponseFromHeaders; - -@Endpoint(org.jclouds.vcloud.endpoints.VCloudLogin.class) -@RequestFilters(BasicAuthentication.class) -public interface VCloudLoginApi extends Closeable { - - /** - * This request returns a token to use in subsequent requests. After 30 minutes of inactivity, - * the token expires and you have to request a new token with this call. - */ - @POST - @ResponseParser(ParseLoginResponseFromHeaders.class) - @Consumes(VCloudMediaType.ORGLIST_XML) - VCloudSession login(); -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/loaders/OVFLoader.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/loaders/OVFLoader.java deleted file mode 100644 index f004f973e3..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/loaders/OVFLoader.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.loaders; - -import java.net.URI; - -import javax.annotation.Resource; -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jclouds.logging.Logger; -import org.jclouds.ovf.Envelope; -import org.jclouds.vcloud.VCloudApi; - -import com.google.common.cache.CacheLoader; - -@Singleton -public class OVFLoader extends CacheLoader { - @Resource - protected Logger logger = Logger.NULL; - - private final VCloudApi client; - - @Inject - OVFLoader(VCloudApi client) { - this.client = client; - } - - @Override - public Envelope load(URI template) { - return client.getVAppTemplateApi().getOvfEnvelopeForVAppTemplate(template); - } -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/loaders/VAppTemplateLoader.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/loaders/VAppTemplateLoader.java deleted file mode 100644 index ee707db091..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/loaders/VAppTemplateLoader.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.loaders; - -import java.net.URI; - -import javax.annotation.Resource; -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jclouds.logging.Logger; -import org.jclouds.vcloud.VCloudApi; -import org.jclouds.vcloud.domain.VAppTemplate; - -import com.google.common.cache.CacheLoader; - -@Singleton -public class VAppTemplateLoader extends CacheLoader { - @Resource - protected Logger logger = Logger.NULL; - - private final VCloudApi client; - - @Inject - VAppTemplateLoader(VCloudApi client) { - this.client = client; - } - - @Override - public VAppTemplate load(URI template) { - return client.getVAppTemplateApi().getVAppTemplate(template); - } -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/location/DefaultVDC.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/location/DefaultVDC.java deleted file mode 100644 index 38fb340fc6..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/location/DefaultVDC.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.location; - -import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.collect.Iterables.find; - -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.domain.LocationScope; -import org.jclouds.location.suppliers.ImplicitLocationSupplier; -import org.jclouds.vcloud.domain.ReferenceType; -import org.jclouds.vcloud.endpoints.VDC; - -import com.google.common.base.Predicate; -import com.google.common.base.Supplier; - -@Singleton -public class DefaultVDC implements ImplicitLocationSupplier { - private final Supplier> locationsSupplier; - private final IsDefaultVDC isDefaultVDC; - - @Inject - DefaultVDC(@Memoized Supplier> locationsSupplier, IsDefaultVDC isDefaultVDC) { - this.locationsSupplier = checkNotNull(locationsSupplier, "locationsSupplierSupplier"); - this.isDefaultVDC = checkNotNull(isDefaultVDC, "isDefaultVDC"); - } - - @Override - public Location get() { - return find(locationsSupplier.get(), isDefaultVDC); - } - - - @Singleton - public static class IsDefaultVDC implements Predicate { - private final Supplier defaultVDCSupplier; - - @Inject - IsDefaultVDC(@VDC Supplier defaultVDCSupplier) { - this.defaultVDCSupplier = checkNotNull(defaultVDCSupplier, "defaultVDCSupplier"); - } - - @Override - public boolean apply(Location input) { - ReferenceType defaultVDC = defaultVDCSupplier.get(); - return input.getScope() == LocationScope.ZONE && input.getId().equals(defaultVDC.getHref().toASCIIString()); - } - - @Override - public String toString() { - return "isDefaultVDC()"; - } - } -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/location/OrgAndVDCToLocationSupplier.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/location/OrgAndVDCToLocationSupplier.java deleted file mode 100644 index a0c15056d5..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/location/OrgAndVDCToLocationSupplier.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.location; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.net.URI; -import java.util.Map; -import java.util.Set; - -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.location.Iso3166; -import org.jclouds.location.Provider; -import org.jclouds.location.suppliers.LocationsSupplier; -import org.jclouds.location.suppliers.all.JustProvider; -import org.jclouds.vcloud.domain.Org; -import org.jclouds.vcloud.domain.ReferenceType; - -import com.google.common.base.Supplier; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.ImmutableSet.Builder; -import com.google.common.collect.Iterables; - -@Singleton -public class OrgAndVDCToLocationSupplier extends JustProvider implements LocationsSupplier { - - private final Supplier> orgNameToResource; - private final Supplier> orgNameToVDCResource; - private final Supplier>>> isoCodesByIdSupplier; - - @Inject - OrgAndVDCToLocationSupplier(@Iso3166 Set isoCodes, @Provider String providerName, - @Provider Supplier endpoint, - @org.jclouds.vcloud.endpoints.Org Supplier> orgNameToResource, - Supplier> orgNameToVDCResource, - @Iso3166 Supplier>>> isoCodesByIdSupplier) { - super(providerName, endpoint, isoCodes); - this.orgNameToResource = checkNotNull(orgNameToResource, "orgNameToResource"); - this.orgNameToVDCResource = checkNotNull(orgNameToVDCResource, "orgNameToVDCResource"); - this.isoCodesByIdSupplier = checkNotNull(isoCodesByIdSupplier, "isoCodesByIdSupplier"); - } - - @Override - public Set get() { - return buildJustProviderOrVDCs().build(); - } - - protected Builder buildJustProviderOrVDCs() { - Builder locations = ImmutableSet.builder(); - Location provider = Iterables.getOnlyElement(super.get()); - if (orgNameToResource.get().isEmpty()) - return locations.add(provider); - Map>> isoCodesById = isoCodesByIdSupplier.get(); - for (ReferenceType org : orgNameToResource.get().values()) { - LocationBuilder builder = new LocationBuilder().scope(LocationScope.REGION).id(org.getHref().toASCIIString()) - .description(org.getName()).parent(provider); - if (isoCodesById.containsKey(org.getHref().toASCIIString())) - builder.iso3166Codes(isoCodesById.get(org.getHref().toASCIIString()).get()); - Location orgL = builder.build(); - for (ReferenceType vdc : orgNameToVDCResource.get().get(org.getName()).getVDCs().values()) { - builder = new LocationBuilder().scope(LocationScope.ZONE).id(vdc.getHref().toASCIIString()).description( - vdc.getName()).parent(orgL); - if (isoCodesById.containsKey(vdc.getHref().toASCIIString())) - builder.iso3166Codes(isoCodesById.get(vdc.getHref().toASCIIString()).get()); - locations.add(builder.build()); - } - } - return locations; - } - -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/options/CaptureVAppOptions.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/options/CaptureVAppOptions.java deleted file mode 100644 index 89580fdb86..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/options/CaptureVAppOptions.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.options; - -import static com.google.common.base.Preconditions.checkNotNull; - -public class CaptureVAppOptions { - - private String description; - - public CaptureVAppOptions withDescription(String description) { - checkNotNull(description, "description"); - this.description = description; - return this; - } - - public String getDescription() { - return description; - } - - public static class Builder { - - /** - * @see CaptureVAppOptions#withDescription(String) - */ - public static CaptureVAppOptions withDescription(String description) { - CaptureVAppOptions options = new CaptureVAppOptions(); - return options.withDescription(description); - } - } - -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/options/CatalogItemOptions.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/options/CatalogItemOptions.java deleted file mode 100644 index 6512031db1..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/options/CatalogItemOptions.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.options; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.Map; - -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.Maps; - -public class CatalogItemOptions { - - private String description; - private Map properties = Maps.newLinkedHashMap(); - - /** - * optional description for the CatalogItem - */ - public CatalogItemOptions description(String description) { - this.description = checkNotNull(description, "description"); - return this; - } - - /** - * optional properties for the CatalogItem - */ - public CatalogItemOptions properties(Map properties) { - this.properties = ImmutableMap.copyOf(checkNotNull(properties, "properties")); - return this; - } - - public String getDescription() { - return description; - } - - public Map getProperties() { - return properties; - } - - public static class Builder { - - /** - * @see CatalogItemOptions#description - */ - public static CatalogItemOptions description(String description) { - return new CatalogItemOptions().description(description); - } - - /** - * @see CatalogItemOptions#properties - */ - public static CatalogItemOptions properties(Map properties) { - return new CatalogItemOptions().properties(properties); - } - } - -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/options/CloneOptions.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/options/CloneOptions.java deleted file mode 100644 index e3f5eeafd5..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/options/CloneOptions.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.options; - -import static com.google.common.base.Preconditions.checkNotNull; - -public class CloneOptions { - - private String description; - - /** - * the clone should be powered on after it is deployed - */ - public CloneOptions description(String description) { - checkNotNull(description, "description"); - this.description = description; - return this; - } - - public String getDescription() { - return description; - } - - public static class Builder { - - /** - * @see CloneOptions#description(String) - */ - public static CloneOptions description(String description) { - return new CloneOptions().description(description); - } - } - -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/options/CloneVAppOptions.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/options/CloneVAppOptions.java deleted file mode 100644 index 23793efabc..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/options/CloneVAppOptions.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.options; - -import static com.google.common.base.Preconditions.checkState; - -public class CloneVAppOptions extends CloneOptions { - - private boolean deploy; - private boolean powerOn; - - /** - * the clone should be deployed after it is created - */ - public CloneVAppOptions deploy() { - this.deploy = true; - return this; - } - - /** - * the clone should be powered on after it is deployed - */ - public CloneVAppOptions powerOn() { - checkState(deploy, "must set deploy before setting powerOn"); - powerOn = true; - return this; - } - - /** - * {@inheritDoc} - */ - @Override - public CloneVAppOptions description(String description) { - return CloneVAppOptions.class.cast(super.description(description)); - } - - public boolean isDeploy() { - return deploy; - } - - public boolean isPowerOn() { - return powerOn; - } - - public static class Builder { - - /** - * @see CloneVAppOptions#deploy() - */ - public static CloneVAppOptions deploy() { - return new CloneVAppOptions().deploy(); - } - - /** - * @see CloneVAppOptions#powerOn() - */ - public static CloneVAppOptions powerOn() { - return new CloneVAppOptions().powerOn(); - } - - public static CloneVAppOptions description(String description) { - return new CloneVAppOptions().description(description); - } - } - -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/options/CloneVAppTemplateOptions.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/options/CloneVAppTemplateOptions.java deleted file mode 100644 index d0332eac53..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/options/CloneVAppTemplateOptions.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.options; - -public class CloneVAppTemplateOptions extends CloneOptions { - /** - * {@inheritDoc} - */ - @Override - public CloneVAppTemplateOptions description(String description) { - return CloneVAppTemplateOptions.class.cast(super.description(description)); - } - - public static class Builder { - public static CloneVAppTemplateOptions description(String description) { - return new CloneVAppTemplateOptions().description(description); - } - } - -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/options/InstantiateVAppTemplateOptions.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/options/InstantiateVAppTemplateOptions.java deleted file mode 100644 index 7f6c2c1758..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/options/InstantiateVAppTemplateOptions.java +++ /dev/null @@ -1,173 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.options; - -import static com.google.common.base.Objects.equal; -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.Set; - -import org.jclouds.vcloud.domain.network.NetworkConfig; - -import com.google.common.base.Objects; -import com.google.common.base.Objects.ToStringHelper; -import com.google.common.collect.Sets; - -public class InstantiateVAppTemplateOptions { - private Set networkConfig = Sets.newLinkedHashSet(); - - private Boolean customizeOnInstantiate; - private String description = null; - private boolean deploy = true; - private boolean powerOn = true; - - public String getDescription() { - return description; - } - - public boolean shouldDeploy() { - return deploy; - } - - public boolean shouldPowerOn() { - return powerOn; - } - - /** - * Optional description. Used for the Description of the vApp created by this - * instantiation. - */ - public InstantiateVAppTemplateOptions description(String description) { - this.description = description; - return this; - } - - /** - * deploy the vapp after it is instantiated? - */ - public InstantiateVAppTemplateOptions deploy(boolean deploy) { - this.deploy = deploy; - return this; - } - - /** - * powerOn the vapp after it is instantiated? - */ - public InstantiateVAppTemplateOptions powerOn(boolean powerOn) { - this.powerOn = powerOn; - return this; - } - - /** - * {@networkConfig VAppTemplate}s have internal networks that can be - * connected in order to access the internet or other external networks. - * - *

default behaviour if you don't use this option

By default, we - * connect the first internal {@networkConfig - * org.jclouds.vcloud.domain.VAppTemplate#getNetworkSection network in the - * vapp template}to a default chosen from the org or specified via - * {@networkConfig - * org.jclouds.vcloud.reference.VCloudConstants# - * PROPERTY_VCLOUD_DEFAULT_NETWORK} using the {@networkConfig - * org.jclouds.vcloud.domain.FenceMode#BRIDGED} or an - * override set by the property {@networkConfig - * org.jclouds.vcloud.reference.VCloudConstants# - * PROPERTY_VCLOUD_DEFAULT_FENCEMODE}. - */ - public InstantiateVAppTemplateOptions addNetworkConfig(NetworkConfig networkConfig) { - this.networkConfig.add(checkNotNull(networkConfig, "networkConfig")); - return this; - } - - public Set getNetworkConfig() { - return networkConfig; - } - - public static class Builder { - - /** - * @see InstantiateVAppTemplateOptions#description - */ - public static InstantiateVAppTemplateOptions description(String description) { - InstantiateVAppTemplateOptions options = new InstantiateVAppTemplateOptions(); - return options.description(description); - } - - /** - * @see InstantiateVAppTemplateOptions#deploy - */ - public static InstantiateVAppTemplateOptions deploy(boolean deploy) { - InstantiateVAppTemplateOptions options = new InstantiateVAppTemplateOptions(); - return options.deploy(deploy); - } - - /** - * @see InstantiateVAppTemplateOptions#powerOn - */ - public static InstantiateVAppTemplateOptions powerOn(boolean powerOn) { - InstantiateVAppTemplateOptions options = new InstantiateVAppTemplateOptions(); - return options.powerOn(powerOn); - } - - /** - * @see InstantiateVAppTemplateOptions#addNetworkConfig - */ - public static InstantiateVAppTemplateOptions addNetworkConfig(NetworkConfig networkConfig) { - InstantiateVAppTemplateOptions options = new InstantiateVAppTemplateOptions(); - return options.addNetworkConfig(networkConfig); - } - - } - - @Override - public boolean equals(Object object) { - if (this == object) { - return true; - } - if (object instanceof InstantiateVAppTemplateOptions) { - final InstantiateVAppTemplateOptions other = InstantiateVAppTemplateOptions.class.cast(object); - return equal(networkConfig, other.networkConfig) - && equal(customizeOnInstantiate, other.customizeOnInstantiate) && equal(description, other.description) - && equal(deploy, other.deploy) && equal(powerOn, other.powerOn); - } else { - return false; - } - } - - @Override - public int hashCode() { - return Objects.hashCode(networkConfig, customizeOnInstantiate, description, deploy, powerOn); - } - - @Override - public String toString() { - return string().toString(); - } - - protected ToStringHelper string() { - ToStringHelper toString = Objects.toStringHelper("").omitNullValues(); - toString.add("customizeOnInstantiate", customizeOnInstantiate).add("description", description); - if (!networkConfig.isEmpty()) - toString.add("networkConfig", networkConfig); - if (!deploy) - toString.add("deploy", deploy); - if (!powerOn) - toString.add("powerOn", powerOn); - return toString; - } - -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/predicates/TaskSuccess.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/predicates/TaskSuccess.java deleted file mode 100644 index 2b249ceb13..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/predicates/TaskSuccess.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.predicates; - -import java.net.URI; - -import javax.annotation.Resource; -import javax.inject.Singleton; - -import org.jclouds.logging.Logger; -import org.jclouds.vcloud.TaskInErrorStateException; -import org.jclouds.vcloud.VCloudApi; -import org.jclouds.vcloud.domain.Task; -import org.jclouds.vcloud.domain.TaskStatus; - -import com.google.common.base.Predicate; -import com.google.inject.Inject; - -/** - * - * Tests to see if a task succeeds. - */ -@Singleton -public class TaskSuccess implements Predicate { - - private final VCloudApi client; - - @Resource - protected Logger logger = Logger.NULL; - - @Inject - public TaskSuccess(VCloudApi client) { - this.client = client; - } - - public boolean apply(URI taskId) { - logger.trace("looking for status on task %s", taskId); - - Task task = client.getTaskApi().getTask(taskId); - // perhaps task isn't available, yet - if (task == null) - return false; - logger.trace("%s: looking for status %s: currently: %s", task, TaskStatus.SUCCESS, task.getStatus()); - if (task.getStatus() == TaskStatus.ERROR) - throw new TaskInErrorStateException(task); - return task.getStatus() == TaskStatus.SUCCESS; - } - -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/reference/VCloudConstants.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/reference/VCloudConstants.java deleted file mode 100644 index 2429c6a8c5..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/reference/VCloudConstants.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.reference; - -/** - * Configuration properties and constants used in VCloud connections. - */ -public final class VCloudConstants { - public static final String PROPERTY_VCLOUD_VERSION_SCHEMA = "jclouds.vcloud.version.schema"; - /** - * name of the default org that your vApp will join, if an org isn't - * explicitly specified. - */ - public static final String PROPERTY_VCLOUD_DEFAULT_ORG = "jclouds.vcloud.defaults.org"; - /** - * name of the default catalog to query, if it isn't explicitly specified. - */ - public static final String PROPERTY_VCLOUD_DEFAULT_CATALOG = "jclouds.vcloud.defaults.catalog"; - /** - * name of the VDC that your vApp will join, if a vDC isn't explicitly - * specified. - */ - public static final String PROPERTY_VCLOUD_DEFAULT_VDC = "jclouds.vcloud.defaults.vdc"; - /** - * name of the default network, in the default VDC that your vApp will join. - */ - public static final String PROPERTY_VCLOUD_DEFAULT_NETWORK = "jclouds.vcloud.defaults.network"; - public static final String PROPERTY_VCLOUD_DEFAULT_FENCEMODE = "jclouds.vcloud.defaults.fencemode"; - - public static final String PROPERTY_VCLOUD_XML_NAMESPACE = "jclouds.vcloud.xml.ns"; - public static final String PROPERTY_VCLOUD_XML_SCHEMA = "jclouds.vcloud.xml.schema"; - - public static final String PROPERTY_VCLOUD_TIMEOUT_TASK_COMPLETED = "jclouds.vcloud.timeout.task-complete"; - - private VCloudConstants() { - throw new AssertionError("intentionally unimplemented"); - } -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/reference/package-info.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/reference/package-info.java deleted file mode 100644 index 158debeaf7..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/reference/package-info.java +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * This package contains properties and reference data used in vCloud. - */ -package org.jclouds.vcloud.reference; diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/suppliers/OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefault.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/suppliers/OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefault.java deleted file mode 100644 index fbe84065f8..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/suppliers/OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefault.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.suppliers; - -import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.NoSuchElementException; - -import org.jclouds.config.ValueOfConfigurationKeyOrNull; -import org.jclouds.vcloud.domain.ReferenceType; - -import com.google.common.base.Function; -import com.google.common.base.Predicate; -import com.google.common.collect.Iterables; - -public class OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefault implements - Function, ReferenceType> { - - protected final ValueOfConfigurationKeyOrNull valueOfConfigurationKeyOrNull; - protected final String configurationKey; - protected final Predicate defaultSelector; - - public OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefault( - ValueOfConfigurationKeyOrNull valueOfConfigurationKeyOrNull, String configurationKey, - Predicate defaultSelector) { - this.configurationKey = checkNotNull(configurationKey, "configurationKey"); - this.valueOfConfigurationKeyOrNull = checkNotNull(valueOfConfigurationKeyOrNull, "valueOfConfigurationKeyOrNull"); - this.defaultSelector = checkNotNull(defaultSelector, "defaultSelector"); - } - - @Override - public ReferenceType apply(Iterable referenceTypes) { - checkNotNull(referenceTypes, "referenceTypes"); - checkArgument(!Iterables.isEmpty(referenceTypes), - "No referenceTypes corresponding to configuration key %s present", configurationKey); - if (Iterables.size(referenceTypes) == 1) - return Iterables.getLast(referenceTypes); - String namingPattern = valueOfConfigurationKeyOrNull.apply(configurationKey); - if (namingPattern != null) { - return findReferenceTypeWithNameMatchingPattern(referenceTypes, namingPattern); - } else { - return defaultReferenceType(referenceTypes); - } - } - - public ReferenceType defaultReferenceType(Iterable referenceTypes) { - return Iterables.find(referenceTypes, defaultSelector); - } - - public ReferenceType findReferenceTypeWithNameMatchingPattern(Iterable referenceTypes, - String namingPattern) { - try { - return Iterables.find(referenceTypes, new ReferenceTypeNameMatchesPattern(namingPattern)); - } catch (NoSuchElementException e) { - throw new NoSuchElementException(String.format( - "referenceType matching pattern [%s], corresponding to configuration key %s, not in %s", namingPattern, - configurationKey, referenceTypes)); - } - } - - static class ReferenceTypeNameMatchesPattern implements Predicate { - - private final String namingPattern; - - public ReferenceTypeNameMatchesPattern(String namingPattern) { - this.namingPattern = checkNotNull(namingPattern, "namingPattern"); - } - - @Override - public boolean apply(ReferenceType arg0) { - return arg0.getName().matches(namingPattern); - } - - @Override - public String toString() { - return "nameMatchesPattern(" + namingPattern + ")"; - - } - } -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/suppliers/VAppTemplatesSupplier.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/suppliers/VAppTemplatesSupplier.java deleted file mode 100644 index 08e101749c..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/suppliers/VAppTemplatesSupplier.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.suppliers; - -import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.collect.Iterables.concat; -import static com.google.common.collect.Sets.newLinkedHashSet; -import static org.jclouds.concurrent.FutureIterables.transformParallel; - -import java.util.Map; -import java.util.Set; -import java.util.concurrent.Callable; - -import javax.annotation.Resource; -import javax.inject.Inject; -import javax.inject.Named; -import javax.inject.Singleton; - -import org.jclouds.Constants; -import org.jclouds.compute.reference.ComputeServiceConstants; -import org.jclouds.logging.Logger; -import org.jclouds.vcloud.domain.Org; -import org.jclouds.vcloud.domain.VAppTemplate; - -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; - -@Singleton -public class VAppTemplatesSupplier implements Supplier> { - - @Resource - @Named(ComputeServiceConstants.COMPUTE_LOGGER) - public Logger logger = Logger.NULL; - - private final Supplier> orgMap; - private final Function> imagesInOrg; - private final ListeningExecutorService userExecutor; - - @Inject - VAppTemplatesSupplier(Supplier> orgMap, - Function> imagesInOrg, - @Named(Constants.PROPERTY_USER_THREADS) ListeningExecutorService userExecutor) { - this.orgMap = checkNotNull(orgMap, "orgMap"); - this.imagesInOrg = checkNotNull(imagesInOrg, "imagesInOrg"); - this.userExecutor = checkNotNull(userExecutor, "userExecutor"); - } - - @Override - public Set get() { - Iterable orgs = checkNotNull(orgMap.get().values(), "orgs"); - Iterable> images = transformParallel(orgs, - new Function>>() { - public ListenableFuture> apply(final Org from) { - checkNotNull(from, "org"); - return userExecutor.submit(new Callable>() { - public Iterable call() throws Exception { - return imagesInOrg.apply(from); - } - public String toString() { - return "imagesInOrg(" + from.getHref() + ")"; - } - }); - } - }, userExecutor, null, logger, "images in " + orgs); - return newLinkedHashSet(concat(images)); - } -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/util/Utils.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/util/Utils.java deleted file mode 100644 index 8bd10f12fc..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/util/Utils.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.util; - -import java.net.URI; -import java.util.Map; - -import org.jclouds.vcloud.domain.ReferenceType; -import org.jclouds.vcloud.domain.VCloudError; -import org.jclouds.vcloud.domain.VCloudError.MinorCode; -import org.jclouds.vcloud.domain.internal.ErrorImpl; -import org.jclouds.vcloud.domain.internal.ReferenceTypeImpl; - -public class Utils { - - public static ReferenceType newReferenceType(Map attributes, String defaultType) { - String uri = attributes.get("href"); - String type = attributes.get("type"); - // savvis org has null href - URI href = (uri != null) ? URI.create(uri) : null; - return new ReferenceTypeImpl(attributes.get("name"), type != null ? type : defaultType, href); - } - - public static ReferenceType newReferenceType(Map attributes) { - return newReferenceType(attributes, null); - } - - public static VCloudError newError(Map attributes) { - - String vendorSpecificErrorCode = attributes.get("vendorSpecificErrorCode"); - int errorCode; - // remove this logic when vcloud 0.8 is gone - try { - errorCode = Integer.parseInt(attributes.get("majorErrorCode")); - } catch (NumberFormatException e) { - errorCode = 500; - vendorSpecificErrorCode = attributes.get("majorErrorCode"); - } - MinorCode minorErrorCode = attributes.containsKey("minorErrorCode") ? MinorCode.fromValue(attributes - .get("minorErrorCode")) : null; - if (minorErrorCode == null || minorErrorCode == MinorCode.UNRECOGNIZED) { - vendorSpecificErrorCode = attributes.get("minorErrorCode"); - } - - return new ErrorImpl(attributes.get("message"), errorCode, minorErrorCode, vendorSpecificErrorCode, attributes - .get("stackTrace")); - } - - public static void putReferenceType(Map map, Map attributes) { - map.put(attributes.get("name"), newReferenceType(attributes)); - } -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/util/VCloudUtils.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/util/VCloudUtils.java deleted file mode 100644 index 67e24453c5..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/util/VCloudUtils.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.util; - -import javax.annotation.Resource; -import javax.inject.Inject; -import javax.inject.Provider; -import javax.inject.Singleton; - -import org.jclouds.http.HttpRequest; -import org.jclouds.http.HttpResponse; -import org.jclouds.http.functions.ParseSax; -import org.jclouds.http.functions.ParseSax.Factory; -import org.jclouds.logging.Logger; -import org.jclouds.vcloud.VCloudMediaType; -import org.jclouds.vcloud.domain.VCloudError; -import org.jclouds.vcloud.xml.ErrorHandler; - -/** - * Needed to sign and verify requests and responses. - */ -@Singleton -public class VCloudUtils { - private final ParseSax.Factory factory; - private final Provider errorHandlerProvider; - @Resource - protected Logger logger = Logger.NULL; - - @Inject - VCloudUtils(Factory factory, Provider errorHandlerProvider) { - this.factory = factory; - this.errorHandlerProvider = errorHandlerProvider; - } - - public VCloudError parseErrorFromContent(HttpRequest request, HttpResponse response) { - // HEAD has no content - if (response.getPayload() == null) - return null; - // NOTE in vCloud Datacenter 1.5, if you make vCloud 1.0 requests, the content type - // header is suffixed with ;1.0 - String contentType = response.getPayload().getContentMetadata().getContentType(); - if (contentType != null && contentType.startsWith(VCloudMediaType.ERROR_XML)) { - try { - return factory.create(errorHandlerProvider.get()).setContext(request).apply(response); - } catch (RuntimeException e) { - logger.warn(e, "error parsing error"); - } - } - return null; - } -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/CatalogHandler.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/CatalogHandler.java deleted file mode 100644 index 41546dfd9f..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/CatalogHandler.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.xml; - -import static org.jclouds.vcloud.util.Utils.newReferenceType; -import static org.jclouds.vcloud.util.Utils.putReferenceType; - -import java.util.List; -import java.util.Map; - -import javax.inject.Inject; - -import org.jclouds.http.functions.ParseSax; -import org.jclouds.util.SaxUtils; -import org.jclouds.vcloud.VCloudMediaType; -import org.jclouds.vcloud.domain.Catalog; -import org.jclouds.vcloud.domain.ReferenceType; -import org.jclouds.vcloud.domain.Task; -import org.jclouds.vcloud.domain.internal.CatalogImpl; -import org.xml.sax.Attributes; -import org.xml.sax.SAXException; - -import com.google.common.collect.Lists; -import com.google.common.collect.Maps; - -public class CatalogHandler extends ParseSax.HandlerWithResult { - - protected final TaskHandler taskHandler; - - @Inject - public CatalogHandler(TaskHandler taskHandler) { - this.taskHandler = taskHandler; - } - - private StringBuilder currentText = new StringBuilder(); - - private ReferenceType catalog; - private Map contents = Maps.newLinkedHashMap(); - protected List tasks = Lists.newArrayList(); - private String description; - private ReferenceType org; - - private boolean published = true; - private boolean readOnly = true; - - public Catalog getResult() { - return new CatalogImpl(catalog.getName(), catalog.getType(), catalog.getHref(), org, description, contents, - tasks, published, readOnly); - } - - @Override - public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException { - Map attributes = SaxUtils.cleanseAttributes(attrs); - if (SaxUtils.equalsOrSuffix(qName, "Catalog")) { - catalog = newReferenceType(attributes, VCloudMediaType.CATALOG_XML); - } else if (SaxUtils.equalsOrSuffix(qName, "CatalogItem")) { - putReferenceType(contents, attributes); - } else if (SaxUtils.equalsOrSuffix(qName, "Link") && "up".equals(attributes.get("rel"))) { - org = newReferenceType(attributes); - } else if (SaxUtils.equalsOrSuffix(qName, "Link") && "add".equals(attributes.get("rel"))) { - readOnly = false; - } else { - taskHandler.startElement(uri, localName, qName, attrs); - } - } - - public void endElement(String uri, String name, String qName) { - taskHandler.endElement(uri, name, qName); - if (SaxUtils.equalsOrSuffix(qName, "Task")) { - this.tasks.add(taskHandler.getResult()); - } else if (SaxUtils.equalsOrSuffix(qName, "Description")) { - description = currentOrNull(); - } else if (SaxUtils.equalsOrSuffix(qName, "IsPublished")) { - published = Boolean.parseBoolean(currentOrNull()); - } - currentText.setLength(0); - } - - public void characters(char ch[], int start, int length) { - currentText.append(ch, start, length); - } - - protected String currentOrNull() { - String returnVal = currentText.toString().trim(); - return returnVal.equals("") ? null : returnVal; - } -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/CatalogItemHandler.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/CatalogItemHandler.java deleted file mode 100644 index 0a5e1a265e..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/CatalogItemHandler.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.xml; - -import static org.jclouds.vcloud.util.Utils.newReferenceType; - -import java.util.Map; -import java.util.SortedMap; - -import org.jclouds.http.functions.ParseSax; -import org.jclouds.util.SaxUtils; -import org.jclouds.vcloud.domain.CatalogItem; -import org.jclouds.vcloud.domain.ReferenceType; -import org.jclouds.vcloud.domain.internal.CatalogItemImpl; -import org.xml.sax.Attributes; -import org.xml.sax.SAXException; - -import com.google.common.collect.Maps; - -public class CatalogItemHandler extends ParseSax.HandlerWithResult { - private StringBuilder currentText = new StringBuilder(); - - protected ReferenceType catalogItem; - protected ReferenceType entity; - - protected String description; - protected String key; - protected SortedMap properties = Maps.newTreeMap(); - - public CatalogItem getResult() { - return new CatalogItemImpl(catalogItem.getName(), catalogItem.getHref(), description, entity, properties); - } - - @Override - public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException { - Map attributes = SaxUtils.cleanseAttributes(attrs); - if (SaxUtils.equalsOrSuffix(qName, "CatalogItem")) { - catalogItem = newReferenceType(attributes); - } else if (SaxUtils.equalsOrSuffix(qName, "Entity")) { - entity = newReferenceType(attributes); - } else if (SaxUtils.equalsOrSuffix(qName, "Property")) { - key = attributes.get("key"); - } - } - - public void endElement(String uri, String name, String qName) { - if (SaxUtils.equalsOrSuffix(qName, "Description")) { - description = currentOrNull(); - } else if (SaxUtils.equalsOrSuffix(qName, "Property")) { - properties.put(key, currentOrNull()); - key = null; - } - currentText.setLength(0); - } - - public void characters(char ch[], int start, int length) { - currentText.append(ch, start, length); - } - - protected String currentOrNull() { - String returnVal = currentText.toString().trim(); - return returnVal.equals("") ? null : returnVal; - } -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/ErrorHandler.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/ErrorHandler.java deleted file mode 100644 index 3c4704ab21..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/ErrorHandler.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.xml; - -import java.util.Map; - -import org.jclouds.http.functions.ParseSax; -import org.jclouds.util.SaxUtils; -import org.jclouds.vcloud.domain.VCloudError; -import org.jclouds.vcloud.util.Utils; -import org.xml.sax.Attributes; -import org.xml.sax.SAXException; - -public class ErrorHandler extends ParseSax.HandlerWithResult { - private VCloudError error; - - public VCloudError getResult() { - return error; - } - - @Override - public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException { - Map attributes = SaxUtils.cleanseAttributes(attrs); - if (SaxUtils.equalsOrSuffix(qName, "Error")) { - error = Utils.newError(attributes); - } - } -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/GuestCustomizationSectionHandler.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/GuestCustomizationSectionHandler.java deleted file mode 100644 index 548ea421cf..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/GuestCustomizationSectionHandler.java +++ /dev/null @@ -1,134 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.xml; - -import static org.jclouds.vcloud.util.Utils.newReferenceType; - -import java.util.Map; - -import org.jclouds.http.functions.ParseSax; -import org.jclouds.util.SaxUtils; -import org.jclouds.vcloud.domain.GuestCustomizationSection; -import org.jclouds.vcloud.domain.ReferenceType; -import org.xml.sax.Attributes; - -public class GuestCustomizationSectionHandler extends ParseSax.HandlerWithResult { - protected StringBuilder currentText = new StringBuilder(); - private ReferenceType guest; - private ReferenceType edit; - - protected String info; - protected String name; - protected Boolean enabled; - protected Boolean changeSid; - protected String virtualMachineId; - protected Boolean joinDomainEnabled; - protected Boolean useOrgSettings; - protected String domainName; - protected String domainUserName; - protected String domainUserPassword; - protected Boolean adminPasswordEnabled; - protected Boolean adminPasswordAuto; - protected String adminPassword; - protected Boolean resetPasswordRequired; - protected String customizationScript; - protected String computerName; - - public GuestCustomizationSection getResult() { - GuestCustomizationSection system = new GuestCustomizationSection(guest.getType(), guest.getHref(), info, enabled, - changeSid, virtualMachineId, joinDomainEnabled, useOrgSettings, domainName, domainUserName, - domainUserPassword, adminPasswordEnabled, adminPasswordAuto, adminPassword, resetPasswordRequired, - customizationScript, computerName, edit); - this.guest = null; - this.info = null; - this.edit = null; - this.enabled = null; - this.changeSid = null; - this.virtualMachineId = null; - this.joinDomainEnabled = null; - this.useOrgSettings = null; - this.domainName = null; - this.domainUserName = null; - this.domainUserPassword = null; - this.adminPasswordEnabled = null; - this.adminPasswordAuto = null; - this.adminPassword = null; - this.resetPasswordRequired = null; - this.customizationScript = null; - this.computerName = null; - return system; - } - - public void startElement(String uri, String localName, String qName, Attributes attrs) { - Map attributes = SaxUtils.cleanseAttributes(attrs); - this.currentText.setLength(0); - if (qName.endsWith("GuestCustomizationSection")) { - guest = newReferenceType(attributes); - } else if (qName.endsWith("Link") && "edit".equals(attributes.get("rel"))) { - edit = newReferenceType(attributes); - } - } - - @Override - public void endElement(String uri, String localName, String qName) { - if (qName.endsWith("Info")) { - this.info = currentOrNull(); - } else if (qName.endsWith("AdminPasswordEnabled")) { - this.adminPasswordEnabled = Boolean.parseBoolean(currentOrNull()); - } else if (qName.endsWith("JoinDomainEnabled")) { - this.joinDomainEnabled = Boolean.parseBoolean(currentOrNull()); - } else if (qName.endsWith("Enabled")) { - this.enabled = Boolean.parseBoolean(currentOrNull()); - } else if (qName.endsWith("ChangeSid")) { - this.changeSid = Boolean.parseBoolean(currentOrNull()); - } else if (qName.endsWith("VirtualMachineId")) { - this.virtualMachineId = currentOrNull(); - } else if (qName.endsWith("UseOrgSettings")) { - this.useOrgSettings = Boolean.parseBoolean(currentOrNull()); - } else if (qName.endsWith("DomainName")) { - this.domainName = currentOrNull(); - } else if (qName.endsWith("DomainUserName")) { - this.domainUserName = currentOrNull(); - } else if (qName.endsWith("DomainUserPassword")) { - this.domainUserPassword = currentOrNull(); - } else if (qName.endsWith("AdminPasswordAuto")) { - this.adminPasswordAuto = Boolean.parseBoolean(currentOrNull()); - } else if (qName.endsWith("AdminPassword")) { - this.adminPassword = currentOrNull(); - } else if (qName.endsWith("ResetPasswordRequired")) { - this.resetPasswordRequired = Boolean.parseBoolean(currentOrNull()); - } else if (qName.endsWith("CustomizationScript")) { - this.customizationScript = currentOrNull(); - if (this.customizationScript != null) - customizationScript = customizationScript.replace(">", ">"); - } else if (qName.endsWith("ComputerName")) { - this.computerName = currentOrNull(); - } else if (qName.endsWith("Name")) { - this.name = currentOrNull(); - } - currentText.setLength(0); - } - - public void characters(char ch[], int start, int length) { - currentText.append(ch, start, length); - } - - protected String currentOrNull() { - String returnVal = currentText.toString(); - return returnVal.equals("") ? null : returnVal; - } -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/NetworkConnectionHandler.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/NetworkConnectionHandler.java deleted file mode 100644 index 0224a30fe5..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/NetworkConnectionHandler.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.xml; - -import java.util.Map; - -import org.jclouds.http.functions.ParseSax; -import org.jclouds.util.SaxUtils; -import org.jclouds.vcloud.domain.NetworkConnection; -import org.jclouds.vcloud.domain.network.IpAddressAllocationMode; -import org.xml.sax.Attributes; - -public class NetworkConnectionHandler extends ParseSax.HandlerWithResult { - protected StringBuilder currentText = new StringBuilder(); - - protected String network; - protected int networkConnectionIndex; - protected String ipAddress; - protected String externalIpAddress; - protected boolean connected; - protected String MACAddress; - protected IpAddressAllocationMode ipAddressAllocationMode; - - public NetworkConnection getResult() { - NetworkConnection connection = new NetworkConnection(network, networkConnectionIndex, ipAddress, - externalIpAddress, connected, MACAddress, ipAddressAllocationMode); - this.network = null; - this.networkConnectionIndex = -1; - this.ipAddress = null; - this.externalIpAddress = null; - this.connected = false; - this.MACAddress = null; - this.ipAddressAllocationMode = null; - return connection; - } - - public void startElement(String uri, String localName, String qName, Attributes attrs) { - Map attributes = SaxUtils.cleanseAttributes(attrs); - if (qName.endsWith("NetworkConnection")) { - network = attributes.get("network"); - } - } - - @Override - public void endElement(String uri, String localName, String qName) { - if (qName.endsWith("NetworkConnectionIndex")) { - this.networkConnectionIndex = Integer.parseInt(currentOrNull()); - } else if (qName.endsWith("IpAddress")) { - this.ipAddress = currentOrNull(); - } else if (qName.endsWith("ExternalIpAddress")) { - this.externalIpAddress = currentOrNull(); - } else if (qName.endsWith("IsConnected")) { - this.connected = Boolean.parseBoolean(currentOrNull()); - } else if (qName.endsWith("MACAddress")) { - this.MACAddress = currentOrNull(); - } else if (qName.endsWith("IpAddressAllocationMode")) { - this.ipAddressAllocationMode = IpAddressAllocationMode.valueOf(currentOrNull()); - } - currentText.setLength(0); - } - - public void characters(char ch[], int start, int length) { - currentText.append(ch, start, length); - } - - protected String currentOrNull() { - String returnVal = currentText.toString().trim(); - return returnVal.equals("") ? null : returnVal; - } -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/NetworkConnectionSectionHandler.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/NetworkConnectionSectionHandler.java deleted file mode 100644 index e453ca64ee..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/NetworkConnectionSectionHandler.java +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.xml; - -import static org.jclouds.vcloud.util.Utils.newReferenceType; - -import java.util.Map; -import java.util.Set; - -import javax.inject.Inject; - -import org.jclouds.http.functions.ParseSax; -import org.jclouds.util.SaxUtils; -import org.jclouds.vcloud.domain.NetworkConnection; -import org.jclouds.vcloud.domain.NetworkConnectionSection; -import org.jclouds.vcloud.domain.ReferenceType; -import org.xml.sax.Attributes; - -import com.google.common.collect.Sets; - -public class NetworkConnectionSectionHandler extends ParseSax.HandlerWithResult { - protected StringBuilder currentText = new StringBuilder(); - - private final NetworkConnectionHandler networkConnectionHandler; - - @Inject - public NetworkConnectionSectionHandler(NetworkConnectionHandler networkConnectionHandler) { - this.networkConnectionHandler = networkConnectionHandler; - } - - protected String info; - protected Set connections = Sets.newLinkedHashSet(); - protected ReferenceType section; - protected ReferenceType edit; - protected Integer primaryNetworkConnectionIndex; - protected boolean inConnections; - - public NetworkConnectionSection getResult() { - return new NetworkConnectionSection(section.getType(), section.getHref(), info, primaryNetworkConnectionIndex, - connections, edit); - } - - @Override - public void startElement(String uri, String localName, String qName, Attributes attrs) { - Map attributes = SaxUtils.cleanseAttributes(attrs); - if (qName.endsWith("NetworkConnection")) { - inConnections = true; - } - if (inConnections) { - networkConnectionHandler.startElement(uri, localName, qName, attrs); - } else if (qName.endsWith("NetworkConnectionSection")) { - section = newReferenceType(attributes); - } else if (qName.endsWith("Link") && "edit".equals(attributes.get("rel"))) { - edit = newReferenceType(attributes); - } - } - - @Override - public void endElement(String uri, String localName, String qName) { - if (qName.endsWith("NetworkConnection")) { - inConnections = false; - connections.add(networkConnectionHandler.getResult()); - } - if (inConnections) { - networkConnectionHandler.endElement(uri, localName, qName); - } else if (qName.endsWith("Info")) { - this.info = currentOrNull(); - } else if (qName.endsWith("PrimaryNetworkConnectionIndex")) { - this.primaryNetworkConnectionIndex = Integer.valueOf(currentOrNull()); - } - currentText.setLength(0); - } - - @Override - public void characters(char ch[], int start, int length) { - if (inConnections) - networkConnectionHandler.characters(ch, start, length); - else - currentText.append(ch, start, length); - } - - protected String currentOrNull() { - String returnVal = currentText.toString().trim(); - return returnVal.equals("") ? null : returnVal; - } -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/OrgHandler.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/OrgHandler.java deleted file mode 100644 index ec79641b85..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/OrgHandler.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.xml; - -import static org.jclouds.vcloud.util.Utils.newReferenceType; -import static org.jclouds.vcloud.util.Utils.putReferenceType; - -import java.util.List; -import java.util.Map; - -import javax.inject.Inject; - -import org.jclouds.http.functions.ParseSax; -import org.jclouds.util.SaxUtils; -import org.jclouds.vcloud.domain.Org; -import org.jclouds.vcloud.domain.ReferenceType; -import org.jclouds.vcloud.domain.Task; -import org.jclouds.vcloud.domain.internal.OrgImpl; -import org.xml.sax.Attributes; -import org.xml.sax.SAXException; - -import com.google.common.collect.Lists; -import com.google.common.collect.Maps; - -public class OrgHandler extends ParseSax.HandlerWithResult { - - protected final TaskHandler taskHandler; - - @Inject - public OrgHandler(TaskHandler taskHandler) { - this.taskHandler = taskHandler; - } - - private StringBuilder currentText = new StringBuilder(); - - protected ReferenceType org; - protected Map vdcs = Maps.newLinkedHashMap(); - protected ReferenceType tasksList; - protected Map catalogs = Maps.newLinkedHashMap(); - protected Map networks = Maps.newLinkedHashMap(); - protected List tasks = Lists.newArrayList(); - - protected String description; - protected String fullName; - - public Org getResult() { - return new OrgImpl(org.getName(), org.getType(), org.getHref(), fullName != null ? fullName : org.getName(), - description, catalogs, vdcs, networks, tasksList, tasks); - } - - @Override - public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException { - Map attributes = SaxUtils.cleanseAttributes(attrs); - if (qName.endsWith("Org")) { - org = newReferenceType(attributes); - } else if (qName.endsWith("Link")) { - String type = attributes.get("type"); - if (type != null) { - if (type.indexOf("vdc+xml") != -1) { - putReferenceType(vdcs, attributes); - } else if (type.indexOf("catalog+xml") != -1) { - putReferenceType(catalogs, attributes); - } else if (type.indexOf("tasksList+xml") != -1) { - tasksList = newReferenceType(attributes); - } else if (type.indexOf("network+xml") != -1) { - putReferenceType(networks, attributes); - } - } - } else { - taskHandler.startElement(uri, localName, qName, attrs); - } - - } - - public void endElement(String uri, String name, String qName) { - taskHandler.endElement(uri, name, qName); - if (qName.endsWith("Task")) { - this.tasks.add(taskHandler.getResult()); - } else if (qName.endsWith("Description")) { - description = currentOrNull(); - } else if (qName.endsWith("FullName")) { - fullName = currentOrNull(); - } - currentText.setLength(0); - } - - public void characters(char ch[], int start, int length) { - currentText.append(ch, start, length); - } - - protected String currentOrNull() { - String returnVal = currentText.toString().trim(); - return returnVal.equals("") ? null : returnVal; - } -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/OrgListHandler.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/OrgListHandler.java deleted file mode 100644 index 9088842258..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/OrgListHandler.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.xml; - -import static org.jclouds.vcloud.util.Utils.putReferenceType; - -import java.util.Map; - -import org.jclouds.http.functions.ParseSax; -import org.jclouds.util.SaxUtils; -import org.jclouds.vcloud.domain.ReferenceType; -import org.xml.sax.Attributes; -import org.xml.sax.SAXException; - -import com.google.common.collect.Maps; - -public class OrgListHandler extends ParseSax.HandlerWithResult> { - - private Map org = Maps.newHashMap(); - - public Map getResult() { - return org; - } - - @Override - public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException { - Map attributes = SaxUtils.cleanseAttributes(attrs); - if (qName.endsWith("Org")) { - String type = attributes.get("type"); - if (type != null) { - if (type.indexOf("org+xml") != -1) { - putReferenceType(org, attributes); - } - } - } - } -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/OrgNetworkHandler.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/OrgNetworkHandler.java deleted file mode 100644 index a4e3044be5..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/OrgNetworkHandler.java +++ /dev/null @@ -1,322 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.xml; - -import static org.jclouds.util.SaxUtils.equalsOrSuffix; -import static org.jclouds.vcloud.util.Utils.newReferenceType; - -import java.util.List; -import java.util.Map; -import java.util.Set; - -import javax.inject.Inject; - -import org.jclouds.http.functions.ParseSax; -import org.jclouds.util.SaxUtils; -import org.jclouds.vcloud.domain.ReferenceType; -import org.jclouds.vcloud.domain.Task; -import org.jclouds.vcloud.domain.network.DhcpService; -import org.jclouds.vcloud.domain.network.Features; -import org.jclouds.vcloud.domain.network.FenceMode; -import org.jclouds.vcloud.domain.network.FirewallService; -import org.jclouds.vcloud.domain.network.IpRange; -import org.jclouds.vcloud.domain.network.IpScope; -import org.jclouds.vcloud.domain.network.NatService; -import org.jclouds.vcloud.domain.network.OrgNetwork; -import org.jclouds.vcloud.domain.network.firewall.FirewallPolicy; -import org.jclouds.vcloud.domain.network.firewall.FirewallProtocols; -import org.jclouds.vcloud.domain.network.firewall.FirewallRule; -import org.jclouds.vcloud.domain.network.internal.OrgNetworkImpl; -import org.jclouds.vcloud.domain.network.nat.NatPolicy; -import org.jclouds.vcloud.domain.network.nat.NatProtocol; -import org.jclouds.vcloud.domain.network.nat.NatRule; -import org.jclouds.vcloud.domain.network.nat.NatType; -import org.jclouds.vcloud.domain.network.nat.rules.MappingMode; -import org.jclouds.vcloud.domain.network.nat.rules.OneToOneVmRule; -import org.jclouds.vcloud.domain.network.nat.rules.PortForwardingRule; -import org.jclouds.vcloud.domain.network.nat.rules.VmRule; -import org.xml.sax.Attributes; -import org.xml.sax.SAXException; - -import com.google.common.collect.Iterables; -import com.google.common.collect.Lists; -import com.google.common.collect.Sets; - -public class OrgNetworkHandler extends ParseSax.HandlerWithResult { - - protected final TaskHandler taskHandler; - - @Inject - public OrgNetworkHandler(TaskHandler taskHandler) { - this.taskHandler = taskHandler; - } - - protected StringBuilder currentText = new StringBuilder(); - - protected ReferenceType network; - protected ReferenceType org; - protected String orgDescription; - protected List tasks = Lists.newArrayList(); - - protected String startAddress; - protected String endAddress; - - protected boolean inherited; - protected String gateway; - protected String netmask; - protected String dns1; - protected String dns2; - protected String dnsSuffix; - protected Set ipRanges = Sets.newLinkedHashSet(); - protected Set allocatedIpAddresses = Sets.newLinkedHashSet(); - - protected IpScope ipScope; - protected ReferenceType parentNetwork; - protected FenceMode fenceMode; - - protected boolean serviceEnabled; - protected Integer defaultLeaseTime; - protected Integer maxLeaseTime; - - protected DhcpService dhcpService; - - protected boolean inFirewallRule; - protected boolean firewallRuleEnabled; - protected String firewallRuleDescription; - protected FirewallPolicy firewallPolicy; - - protected boolean tcp; - protected boolean udp; - protected FirewallProtocols protocols; - protected int port; - protected String destinationIp; - - protected List firewallRules = Lists.newArrayList(); - protected FirewallService firewallService; - - protected NatType natType; - protected NatPolicy natPolicy; - - protected MappingMode mappingMode; - protected String externalIP; - protected String vAppScopedVmId; - protected int vmNicId; - - protected int externalPort; - protected String internalIP; - protected int internalPort; - protected NatProtocol natProtocol; - - protected String vAppScopedLocalId; - - protected List natRules = Lists.newArrayList(); - protected NatService natService; - - protected Features features; - protected OrgNetwork.Configuration configuration; - - protected ReferenceType networkPool; - protected Set allowedExternalIpAddresses = Sets.newLinkedHashSet(); - - public OrgNetwork getResult() { - return new OrgNetworkImpl(network.getName(), network.getType(), network.getHref(), org, orgDescription, tasks, - configuration, networkPool, allowedExternalIpAddresses); - } - - @Override - public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException { - Map attributes = SaxUtils.cleanseAttributes(attrs); - if (SaxUtils.equalsOrSuffix(qName, "OrgNetwork")) { - network = newReferenceType(attributes); - } else if (SaxUtils.equalsOrSuffix(qName, "FirewallRule")) { - this.inFirewallRule = true; - } else if (SaxUtils.equalsOrSuffix(qName, "ParentNetwork")) { - parentNetwork = newReferenceType(attributes); - } else if (SaxUtils.equalsOrSuffix(qName, "Link") && "up".equals(attributes.get("rel"))) { - org = newReferenceType(attributes); - } else { - taskHandler.startElement(uri, localName, qName, attrs); - } - String type = attributes.get("type"); - if (type != null) { - if (type.indexOf("networkPool+xml") != -1) { - networkPool = newReferenceType(attributes); - } - } - } - - public void endElement(String uri, String name, String qName) { - taskHandler.endElement(uri, name, qName); - if (SaxUtils.equalsOrSuffix(qName, "Task")) { - this.tasks.add(taskHandler.getResult()); - } else if (SaxUtils.equalsOrSuffix(qName, "Description")) { - if (inFirewallRule) - firewallRuleDescription = currentOrNull(); - else - orgDescription = currentOrNull(); - } else if (SaxUtils.equalsOrSuffix(qName, "FenceMode")) { - fenceMode = FenceMode.fromValue(currentOrNull()); - } else if (SaxUtils.equalsOrSuffix(qName, "StartAddress")) { - startAddress = currentOrNull(); - } else if (SaxUtils.equalsOrSuffix(qName, "EndAddress")) { - endAddress = currentOrNull(); - } else if (SaxUtils.equalsOrSuffix(qName, "AllocatedIpAddress")) { - allocatedIpAddresses.add(currentOrNull()); - } else if (SaxUtils.equalsOrSuffix(qName, "IpRange")) { - ipRanges.add(new IpRange(startAddress, endAddress)); - this.startAddress = null; - this.endAddress = null; - } else if (SaxUtils.equalsOrSuffix(qName, "IsInherited")) { - inherited = Boolean.parseBoolean(currentOrNull()); - } else if (SaxUtils.equalsOrSuffix(qName, "Gateway")) { - gateway = currentOrNull(); - } else if (SaxUtils.equalsOrSuffix(qName, "Netmask")) { - netmask = currentOrNull(); - } else if (SaxUtils.equalsOrSuffix(qName, "Dns1")) { - dns1 = currentOrNull(); - } else if (SaxUtils.equalsOrSuffix(qName, "Dns2")) { - dns2 = currentOrNull(); - } else if (SaxUtils.equalsOrSuffix(qName, "DnsSuffix")) { - dnsSuffix = currentOrNull(); - } else if (SaxUtils.equalsOrSuffix(qName, "IpScope")) { - ipScope = new IpScope(inherited, gateway, netmask, dns1, dns2, dnsSuffix, ipRanges, allocatedIpAddresses); - this.inherited = false; - this.gateway = null; - this.netmask = null; - this.dns1 = null; - this.dns2 = null; - this.dnsSuffix = null; - this.ipRanges = Sets.newLinkedHashSet(); - this.allocatedIpAddresses = Sets.newLinkedHashSet(); - } else if (SaxUtils.equalsOrSuffix(qName, "IsEnabled")) { - if (inFirewallRule) - firewallRuleEnabled = Boolean.parseBoolean(currentOrNull()); - else - serviceEnabled = Boolean.parseBoolean(currentOrNull()); - } else if (SaxUtils.equalsOrSuffix(qName, "DefaultLeaseTime")) { - defaultLeaseTime = Integer.parseInt(currentOrNull()); - } else if (SaxUtils.equalsOrSuffix(qName, "MaxLeaseTime")) { - maxLeaseTime = Integer.parseInt(currentOrNull()); - } else if (SaxUtils.equalsOrSuffix(qName, "DhcpService")) { - this.dhcpService = new DhcpService(serviceEnabled, defaultLeaseTime, maxLeaseTime, Iterables - .getOnlyElement(ipRanges)); - this.serviceEnabled = false; - this.defaultLeaseTime = null; - this.maxLeaseTime = null; - this.ipRanges = Sets.newLinkedHashSet(); - } else if (SaxUtils.equalsOrSuffix(qName, "Policy")) { - if (inFirewallRule) - firewallPolicy = FirewallPolicy.fromValue(currentOrNull()); - else - natPolicy = NatPolicy.fromValue(currentOrNull()); - } else if (SaxUtils.equalsOrSuffix(qName, "Tcp")) { - tcp = Boolean.parseBoolean(currentOrNull()); - } else if (SaxUtils.equalsOrSuffix(qName, "Udp")) { - udp = Boolean.parseBoolean(currentOrNull()); - } else if (SaxUtils.equalsOrSuffix(qName, "Protocols")) { - this.protocols = new FirewallProtocols(tcp, udp); - this.tcp = false; - this.udp = false; - } else if (SaxUtils.equalsOrSuffix(qName, "DestinationIp")) { - this.destinationIp = currentOrNull(); - } else if (SaxUtils.equalsOrSuffix(qName, "FirewallRule")) { - this.inFirewallRule = false; - this.firewallRules.add(new FirewallRule(firewallRuleEnabled, firewallRuleDescription, firewallPolicy, - protocols, port, destinationIp)); - this.firewallRuleEnabled = false; - this.firewallRuleDescription = null; - this.firewallPolicy = null; - this.protocols = null; - this.port = -1; - this.destinationIp = null; - } else if (SaxUtils.equalsOrSuffix(qName, "FirewallService")) { - firewallService = new FirewallService(serviceEnabled, firewallRules); - this.serviceEnabled = false; - this.firewallRules = Lists.newArrayList(); - } else if (SaxUtils.equalsOrSuffix(qName, "NatType")) { - natType = NatType.fromValue(currentOrNull()); - } else if (SaxUtils.equalsOrSuffix(qName, "MappingMode")) { - mappingMode = MappingMode.fromValue(currentOrNull()); - } else if (qName.equalsIgnoreCase("ExternalIP")) { - externalIP = currentOrNull(); - } else if (qName.equalsIgnoreCase("VAppScopedVmId")) { - vAppScopedVmId = currentOrNull(); - } else if (qName.equalsIgnoreCase("VAppScopedLocalId")) { - vAppScopedLocalId = currentOrNull(); - } else if (qName.equalsIgnoreCase("vmNicId")) { - vmNicId = Integer.parseInt(currentOrNull()); - } else if (SaxUtils.equalsOrSuffix(qName, "OneToOneVmRule")) { - natRules.add(new OneToOneVmRule(mappingMode, externalIP, vAppScopedVmId, vmNicId)); - this.mappingMode = null; - this.externalIP = null; - this.vAppScopedVmId = null; - this.vmNicId = -1; - } else if (qName.equalsIgnoreCase("ExternalPort")) { - externalPort = Integer.parseInt(currentOrNull()); - } else if (qName.equalsIgnoreCase("InternalIP")) { - internalIP = currentOrNull(); - } else if (qName.equalsIgnoreCase("InternalPort")) { - internalPort = Integer.parseInt(currentOrNull()); - } else if (equalsOrSuffix(qName, "Protocol")) { - natProtocol = NatProtocol.valueOf(currentOrNull()); - } else if (SaxUtils.equalsOrSuffix(qName, "PortForwardingRule")) { - natRules.add(new PortForwardingRule(externalIP, externalPort, internalIP, internalPort, natProtocol)); - this.externalIP = null; - this.externalPort = -1; - this.internalIP = null; - this.internalPort = -1; - this.natProtocol = null; - } else if (SaxUtils.equalsOrSuffix(qName, "VmRule")) { - natRules.add(new VmRule(externalIP, externalPort, vAppScopedLocalId, vmNicId, internalPort, natProtocol)); - this.externalIP = null; - this.externalPort = -1; - this.vAppScopedLocalId = null; - this.vmNicId = -1; - this.internalPort = -1; - this.natProtocol = null; - } else if (SaxUtils.equalsOrSuffix(qName, "NatService")) { - this.natService = new NatService(serviceEnabled, natType, natPolicy, natRules); - this.serviceEnabled = false; - this.natType = null; - this.natPolicy = null; - this.natRules = Lists.newArrayList(); - } else if (SaxUtils.equalsOrSuffix(qName, "Features")) { - this.features = new Features(dhcpService, firewallService, natService); - this.dhcpService = null; - this.firewallService = null; - this.natService = null; - } else if (SaxUtils.equalsOrSuffix(qName, "Configuration")) { - configuration = new OrgNetworkImpl.ConfigurationImpl(ipScope, parentNetwork, fenceMode, features); - this.ipScope = null; - this.parentNetwork = null; - this.fenceMode = null; - this.features = null; - } else if (SaxUtils.equalsOrSuffix(qName, "AllowedExternalIpAddress")) { - allowedExternalIpAddresses.add(currentOrNull()); - } - currentText.setLength(0); - } - - public void characters(char ch[], int start, int length) { - currentText.append(ch, start, length); - } - - protected String currentOrNull() { - String returnVal = currentText.toString().trim(); - return returnVal.equals("") ? null : returnVal; - } -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/SupportedVersionsHandler.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/SupportedVersionsHandler.java deleted file mode 100644 index d778da51f6..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/SupportedVersionsHandler.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.xml; - -import java.net.URI; -import java.util.SortedMap; - -import org.jclouds.http.functions.ParseSax; -import org.jclouds.util.SaxUtils; - -import com.google.common.collect.Maps; - -public class SupportedVersionsHandler extends ParseSax.HandlerWithResult> { - private StringBuilder currentText = new StringBuilder(); - - private SortedMap contents = Maps.newTreeMap(); - private String version; - private URI location; - - public SortedMap getResult() { - return contents; - } - - public void endElement(String uri, String name, String qName) { - if (SaxUtils.equalsOrSuffix(qName, "Version")) { - version = currentOrNull(); - } else if (SaxUtils.equalsOrSuffix(qName, "LoginUrl")) { - location = URI.create(currentOrNull()); - } else if (SaxUtils.equalsOrSuffix(qName, "VersionInfo")) { - contents.put(version, location); - } - currentText.setLength(0); - } - - public void characters(char ch[], int start, int length) { - currentText.append(ch, start, length); - } - - protected String currentOrNull() { - String returnVal = currentText.toString().trim(); - return returnVal.equals("") ? null : returnVal; - } -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/TaskHandler.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/TaskHandler.java deleted file mode 100644 index fd421ab832..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/TaskHandler.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.xml; - -import static org.jclouds.util.SaxUtils.equalsOrSuffix; - -import java.text.ParseException; -import java.util.Date; -import java.util.Map; - -import javax.annotation.Resource; -import javax.inject.Inject; - -import org.jclouds.date.DateService; -import org.jclouds.http.functions.ParseSax; -import org.jclouds.logging.Logger; -import org.jclouds.util.SaxUtils; -import org.jclouds.vcloud.domain.ReferenceType; -import org.jclouds.vcloud.domain.Task; -import org.jclouds.vcloud.domain.TaskStatus; -import org.jclouds.vcloud.domain.VCloudError; -import org.jclouds.vcloud.domain.internal.TaskImpl; -import org.jclouds.vcloud.util.Utils; -import org.xml.sax.Attributes; -import org.xml.sax.SAXException; - -public class TaskHandler extends ParseSax.HandlerWithResult { - protected final DateService dateService; - private String operation; - private ReferenceType taskLink; - private ReferenceType owner; - private TaskStatus status; - private Date startTime; - private Date endTime; - private Date expiryTime; - private Task task; - private VCloudError error; - private boolean inOwner; - - @Resource - protected Logger logger = Logger.NULL; - - @Inject - public TaskHandler(DateService dateService) { - this.dateService = dateService; - } - - public Task getResult() { - return task; - } - - @Override - public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException { - Map attributes = SaxUtils.cleanseAttributes(attrs); - if (equalsOrSuffix(qName, "Task")) { - if (attributes.get("href") != null && !inOwner)// queued tasks may not have an - // href yet - taskLink = Utils.newReferenceType(attributes); - status = TaskStatus.fromValue(attributes.get("status")); - operation = attributes.get("operation"); - if (attributes.containsKey("startTime")) - startTime = parseDate(attributes.get("startTime")); - if (attributes.containsKey("endTime")) - endTime = parseDate(attributes.get("endTime")); - if (attributes.containsKey("expiryTime")) - expiryTime = parseDate(attributes.get("expiryTime")); - // TODO technically the old Result object should only be owner for copy and delete tasks - } else if (equalsOrSuffix(qName, "Owner") || equalsOrSuffix(qName, "Result")) { - owner = Utils.newReferenceType(attributes); - } else if (equalsOrSuffix(qName, "Link") && "self".equals(attributes.get("rel"))) { - taskLink = Utils.newReferenceType(attributes); - } else if (equalsOrSuffix(qName, "Error")) { - error = Utils.newError(attributes); - } - } - - private Date parseDate(String toParse) { - try { - return dateService.iso8601DateParse(toParse); - } catch (RuntimeException e) { - if (e.getCause() instanceof ParseException) { - if (!toParse.endsWith("Z")) - toParse += "Z"; - return dateService.iso8601SecondsDateParse(toParse); - } else { - logger.error(e, "error parsing date"); - } - } - return null; - } - - @Override - public void endElement(String uri, String localName, String qName) { - if (equalsOrSuffix(qName, "Task")) { - this.task = new TaskImpl(taskLink.getHref(), operation, status, startTime, endTime, expiryTime, owner, error); - operation = null; - taskLink = null; - status = null; - startTime = null; - endTime = null; - owner = null; - error = null; - } else if (equalsOrSuffix(qName, "Owner")) { - inOwner = false; - } - } - - public void characters(char ch[], int start, int length) { - } - -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/TasksListHandler.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/TasksListHandler.java deleted file mode 100644 index 47ef4618ca..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/TasksListHandler.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.xml; - -import java.util.Map; -import java.util.SortedSet; - -import javax.inject.Inject; - -import org.jclouds.http.functions.ParseSax; -import org.jclouds.util.SaxUtils; -import org.jclouds.vcloud.domain.ReferenceType; -import org.jclouds.vcloud.domain.Task; -import org.jclouds.vcloud.domain.TasksList; -import org.jclouds.vcloud.domain.internal.TasksListImpl; -import org.jclouds.vcloud.util.Utils; -import org.xml.sax.Attributes; -import org.xml.sax.SAXException; - -import com.google.common.collect.Sets; - -public class TasksListHandler extends ParseSax.HandlerWithResult { - - private SortedSet tasks = Sets.newTreeSet(); - private final TaskHandler taskHandler; - private ReferenceType resource; - - @Inject - public TasksListHandler(TaskHandler taskHandler) { - this.taskHandler = taskHandler; - } - - public TasksList getResult() { - return new TasksListImpl(resource.getHref(), tasks); - } - - @Override - public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException { - Map attributes = SaxUtils.cleanseAttributes(attrs); - if (SaxUtils.equalsOrSuffix(qName, "TasksList")) { - resource = Utils.newReferenceType(attributes); - } else if (SaxUtils.equalsOrSuffix(qName, "Link") && "self".equals(attributes.get("rel"))) { - resource = Utils.newReferenceType(attributes); - } else { - taskHandler.startElement(uri, localName, qName, attrs); - } - } - - @Override - public void endElement(String uri, String localName, String qName) throws SAXException { - taskHandler.endElement(uri, localName, qName); - if (SaxUtils.equalsOrSuffix(qName, "Task")) { - this.tasks.add(taskHandler.getResult()); - } - } - -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/VAppHandler.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/VAppHandler.java deleted file mode 100644 index 7214d9a610..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/VAppHandler.java +++ /dev/null @@ -1,148 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.xml; - -import static org.jclouds.util.SaxUtils.equalsOrSuffix; -import static org.jclouds.vcloud.util.Utils.newReferenceType; - -import java.util.List; -import java.util.Map; -import java.util.Set; - -import javax.inject.Inject; - -import org.jclouds.http.functions.ParseSax; -import org.jclouds.util.SaxUtils; -import org.jclouds.vcloud.domain.ReferenceType; -import org.jclouds.vcloud.domain.Status; -import org.jclouds.vcloud.domain.Task; -import org.jclouds.vcloud.domain.VApp; -import org.jclouds.vcloud.domain.Vm; -import org.jclouds.vcloud.domain.internal.VAppImpl; -import org.jclouds.vcloud.domain.ovf.VCloudNetworkSection; -import org.jclouds.vcloud.xml.ovf.VCloudNetworkSectionHandler; -import org.xml.sax.Attributes; -import org.xml.sax.SAXException; - -import com.google.common.collect.Lists; -import com.google.common.collect.Sets; - -public class VAppHandler extends ParseSax.HandlerWithResult { - - protected final TaskHandler taskHandler; - protected final VmHandler vmHandler; - protected final VCloudNetworkSectionHandler networkSectionHandler; - - @Inject - public VAppHandler(TaskHandler taskHandler, VmHandler vmHandler, - VCloudNetworkSectionHandler networkSectionHandler) { - this.taskHandler = taskHandler; - this.vmHandler = vmHandler; - this.networkSectionHandler = networkSectionHandler; - } - - protected StringBuilder currentText = new StringBuilder(); - - protected ReferenceType template; - protected Status status; - protected ReferenceType vdc; - protected String description; - protected List tasks = Lists.newArrayList(); - protected boolean ovfDescriptorUploaded = true; - - private boolean inChildren; - private boolean inTasks; - private boolean inNetworkSection; - protected Set children = Sets.newLinkedHashSet(); - private VCloudNetworkSection networkSection; - - public VApp getResult() { - return new VAppImpl(template.getName(), template.getType(), template.getHref(), status, vdc, description, tasks, - ovfDescriptorUploaded, children, networkSection); - } - - protected int depth = 0; - - @Override - public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException { - Map attributes = SaxUtils.cleanseAttributes(attrs); - depth++; - if (depth == 2) { - if (equalsOrSuffix(qName, "Children")) { - inChildren = true; - } else if (equalsOrSuffix(qName, "Tasks")) { - inTasks = true; - } else if (equalsOrSuffix(qName, "NetworkSection")) { - inNetworkSection = true; - } - } - if (inChildren) { - vmHandler.startElement(uri, localName, qName, attrs); - } else if (inTasks) { - taskHandler.startElement(uri, localName, qName, attrs); - } else if (inNetworkSection) { - networkSectionHandler.startElement(uri, localName, qName, attrs); - } else if (equalsOrSuffix(qName, "VApp")) { - template = newReferenceType(attributes); - if (attributes.containsKey("status")) - this.status = Status.fromValue(Integer.parseInt(attributes.get("status"))); - } else if (equalsOrSuffix(qName, "Link") && "up".equals(attributes.get("rel"))) { - vdc = newReferenceType(attributes); - } - - } - - public void endElement(String uri, String name, String qName) { - depth--; - if (depth == 1) { - if (equalsOrSuffix(qName, "Children")) { - inChildren = false; - this.children.add(vmHandler.getResult()); - } else if (equalsOrSuffix(qName, "Tasks")) { - inTasks = false; - this.tasks.add(taskHandler.getResult()); - } else if (equalsOrSuffix(qName, "Description")) { - description = SaxUtils.currentOrNull(currentText); - } else if (equalsOrSuffix(qName, "NetworkSection")) { - inNetworkSection = false; - this.networkSection = networkSectionHandler.getResult(); - } - } - if (inChildren) { - vmHandler.endElement(uri, name, qName); - } else if (inTasks) { - taskHandler.endElement(uri, name, qName); - } else if (inNetworkSection) { - networkSectionHandler.endElement(uri, name, qName); - } else if (equalsOrSuffix(qName, "ovfDescriptorUploaded")) { - ovfDescriptorUploaded = Boolean.parseBoolean(SaxUtils.currentOrNull(currentText)); - } - currentText.setLength(0); - } - - public void characters(char ch[], int start, int length) { - if (inTasks) - taskHandler.characters(ch, start, length); - else if (inChildren) - vmHandler.characters(ch, start, length); - else if (inNetworkSection) - networkSectionHandler.characters(ch, start, length); - else - currentText.append(ch, start, length); - } - -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/VAppTemplateHandler.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/VAppTemplateHandler.java deleted file mode 100644 index d0cd121115..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/VAppTemplateHandler.java +++ /dev/null @@ -1,149 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.xml; - -import static org.jclouds.util.SaxUtils.equalsOrSuffix; -import static org.jclouds.vcloud.util.Utils.newReferenceType; - -import java.util.List; -import java.util.Map; -import java.util.Set; - -import javax.inject.Inject; - -import org.jclouds.http.functions.ParseSax; -import org.jclouds.util.SaxUtils; -import org.jclouds.vcloud.domain.ReferenceType; -import org.jclouds.vcloud.domain.Status; -import org.jclouds.vcloud.domain.Task; -import org.jclouds.vcloud.domain.VAppTemplate; -import org.jclouds.vcloud.domain.Vm; -import org.jclouds.vcloud.domain.internal.VAppTemplateImpl; -import org.jclouds.vcloud.domain.ovf.VCloudNetworkSection; -import org.jclouds.vcloud.xml.ovf.VCloudNetworkSectionHandler; -import org.xml.sax.Attributes; -import org.xml.sax.SAXException; - -import com.google.common.collect.Lists; -import com.google.common.collect.Sets; - -public class VAppTemplateHandler extends ParseSax.HandlerWithResult { - - protected final TaskHandler taskHandler; - protected final VmHandler vmHandler; - protected final VCloudNetworkSectionHandler networkSectionHandler; - - @Inject - public VAppTemplateHandler(TaskHandler taskHandler, VmHandler vmHandler, - VCloudNetworkSectionHandler networkSectionHandler) { - this.taskHandler = taskHandler; - this.vmHandler = vmHandler; - this.networkSectionHandler = networkSectionHandler; - } - - protected StringBuilder currentText = new StringBuilder(); - - protected ReferenceType template; - protected Status status; - protected ReferenceType vdc; - protected String description; - protected List tasks = Lists.newArrayList(); - protected boolean ovfDescriptorUploaded = true; - protected String vAppScopedLocalId; - - private boolean inChildren; - private boolean inTasks; - private boolean inNetworkSection; - protected Set children = Sets.newLinkedHashSet(); - private VCloudNetworkSection networkSection; - - public VAppTemplate getResult() { - return new VAppTemplateImpl(template.getName(), template.getType(), template.getHref(), status, vdc, description, - tasks, ovfDescriptorUploaded, vAppScopedLocalId, children, networkSection); - } - - @Override - public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException { - Map attributes = SaxUtils.cleanseAttributes(attrs); - if (equalsOrSuffix(qName, "Children")) { - inChildren = true; - } else if (equalsOrSuffix(qName, "Tasks")) { - inTasks = true; - } else if (equalsOrSuffix(qName, "NetworkSection")) { - inNetworkSection = true; - } - if (inChildren) { - vmHandler.startElement(uri, localName, qName, attrs); - } else if (inTasks) { - taskHandler.startElement(uri, localName, qName, attrs); - } else if (inNetworkSection) { - networkSectionHandler.startElement(uri, localName, qName, attrs); - } else if (equalsOrSuffix(qName, "VAppTemplate")) { - template = newReferenceType(attributes); - if (attributes.containsKey("status")) - this.status = Status.fromValue(Integer.parseInt(attributes.get("status"))); - } else if (equalsOrSuffix(qName, "Link") && "up".equals(attributes.get("rel"))) { - vdc = newReferenceType(attributes); - } - - } - - public void endElement(String uri, String name, String qName) { - if (equalsOrSuffix(qName, "Children")) { - inChildren = false; - Vm vm = vmHandler.getResult(); - if (vm != null) - this.children.add(vmHandler.getResult()); - } else if (equalsOrSuffix(qName, "Tasks")) { - inTasks = false; - this.tasks.add(taskHandler.getResult()); - } else if (equalsOrSuffix(qName, "NetworkSection")) { - inNetworkSection = false; - this.networkSection = networkSectionHandler.getResult(); - } - if (inChildren) { - vmHandler.endElement(uri, name, qName); - } else if (inTasks) { - taskHandler.endElement(uri, name, qName); - } else if (inNetworkSection) { - networkSectionHandler.endElement(uri, name, qName); - } else if (equalsOrSuffix(qName, "Description")) { - description = currentOrNull(); - } else if (equalsOrSuffix(qName, "VAppScopedLocalId")) { - vAppScopedLocalId = currentOrNull(); - } else if (equalsOrSuffix(qName, "ovfDescriptorUploaded")) { - ovfDescriptorUploaded = Boolean.parseBoolean(currentOrNull()); - } - currentText.setLength(0); - } - - public void characters(char ch[], int start, int length) { - if (inTasks) - taskHandler.characters(ch, start, length); - else if (inChildren) - vmHandler.characters(ch, start, length); - else if (inNetworkSection) - networkSectionHandler.characters(ch, start, length); - else - currentText.append(ch, start, length); - } - - protected String currentOrNull() { - String returnVal = currentText.toString().trim(); - return returnVal.equals("") ? null : returnVal; - } -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/VCloudVirtualHardwareHandler.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/VCloudVirtualHardwareHandler.java deleted file mode 100644 index cf6f6e530d..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/VCloudVirtualHardwareHandler.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.xml; - -import static org.jclouds.vcloud.util.Utils.newReferenceType; - -import java.util.Map; - -import javax.inject.Inject; - -import org.jclouds.http.functions.ParseSax; -import org.jclouds.ovf.VirtualHardwareSection; -import org.jclouds.ovf.xml.VirtualHardwareSectionHandler; -import org.jclouds.util.SaxUtils; -import org.jclouds.vcloud.domain.ReferenceType; -import org.jclouds.vcloud.domain.ovf.VCloudVirtualHardwareSection; -import org.xml.sax.Attributes; - -public class VCloudVirtualHardwareHandler extends ParseSax.HandlerWithResult { - - private final VirtualHardwareSectionHandler hardwareHandler; - - private ReferenceType hardware; - - @Inject - public VCloudVirtualHardwareHandler(VirtualHardwareSectionHandler hardwareHandler) { - this.hardwareHandler = hardwareHandler; - } - - public VCloudVirtualHardwareSection getResult() { - VirtualHardwareSection hardware = hardwareHandler.getResult(); - return new VCloudVirtualHardwareSection(this.hardware.getType(), this.hardware.getHref(), hardware.getInfo(), hardware - .getTransports(), hardware.getSystem(), hardware.getItems()); - } - - public void startElement(String uri, String localName, String qName, Attributes attrs) { - Map attributes = SaxUtils.cleanseAttributes(attrs); - if (qName.endsWith("VirtualHardwareSection")) { - hardware = newReferenceType(attributes); - } - hardwareHandler.startElement(uri, localName, qName, attrs); - } - - @Override - public void endElement(String uri, String localName, String qName) { - hardwareHandler.endElement(uri, localName, qName); - - } - - @Override - public void characters(char ch[], int start, int length) { - hardwareHandler.characters(ch, start, length); - } - -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/VDCHandler.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/VDCHandler.java deleted file mode 100644 index b529f0cd25..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/VDCHandler.java +++ /dev/null @@ -1,164 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.xml; - -import static org.jclouds.vcloud.util.Utils.newReferenceType; -import static org.jclouds.vcloud.util.Utils.putReferenceType; - -import java.util.List; -import java.util.Map; - -import javax.inject.Inject; - -import org.jclouds.http.functions.ParseSax; -import org.jclouds.util.SaxUtils; -import org.jclouds.vcloud.domain.AllocationModel; -import org.jclouds.vcloud.domain.Capacity; -import org.jclouds.vcloud.domain.ReferenceType; -import org.jclouds.vcloud.domain.Task; -import org.jclouds.vcloud.domain.VDC; -import org.jclouds.vcloud.domain.VDCStatus; -import org.jclouds.vcloud.domain.internal.VDCImpl; -import org.xml.sax.Attributes; -import org.xml.sax.SAXException; - -import com.google.common.collect.Lists; -import com.google.common.collect.Maps; - -public class VDCHandler extends ParseSax.HandlerWithResult { - - protected final TaskHandler taskHandler; - - @Inject - public VDCHandler(TaskHandler taskHandler) { - this.taskHandler = taskHandler; - } - - protected StringBuilder currentText = new StringBuilder(); - - protected ReferenceType vDC; - protected VDCStatus status = VDCStatus.READY; - protected ReferenceType org; - protected String description; - protected List tasks = Lists.newArrayList(); - protected AllocationModel allocationModel = AllocationModel.UNRECOGNIZED; - - protected Capacity storageCapacity; - protected Capacity cpuCapacity; - protected Capacity memoryCapacity; - - protected String units; - protected long allocated = 0; - protected long limit = 0; - protected int used = 0; - protected long overhead = 0; - - protected Map resourceEntities = Maps.newLinkedHashMap(); - protected Map availableNetworks = Maps.newLinkedHashMap(); - - protected int nicQuota; - protected int networkQuota; - protected int vmQuota; - protected boolean isEnabled = true; - - public VDC getResult() { - return new VDCImpl(vDC.getName(), vDC.getType(), vDC.getHref(), status, org, description, tasks, allocationModel, - storageCapacity, cpuCapacity, memoryCapacity, resourceEntities, availableNetworks, nicQuota, - networkQuota, vmQuota, isEnabled); - } - - void resetCapacity() { - units = null; - allocated = 0; - limit = 0; - used = 0; - overhead = 0; - } - - @Override - public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException { - Map attributes = SaxUtils.cleanseAttributes(attrs); - if (qName.endsWith("Vdc")) { - vDC = newReferenceType(attributes); - String status = attributes.get("status"); - if (status != null) - this.status = VDCStatus.fromValue(Integer.parseInt(status)); - } else if (qName.endsWith("Network")) { - putReferenceType(availableNetworks, attributes); - } else if (qName.endsWith("ResourceEntity")) { - putReferenceType(resourceEntities, attributes); - } else if (qName.endsWith("Link") && "up".equals(attributes.get("rel"))) { - org = newReferenceType(attributes); - } else { - taskHandler.startElement(uri, localName, qName, attrs); - } - - } - - public void endElement(String uri, String name, String qName) { - taskHandler.endElement(uri, name, qName); - if (qName.endsWith("Task")) { - this.tasks.add(taskHandler.getResult()); - } else if (qName.endsWith("Description")) { - description = currentOrNull(); - } else if (qName.endsWith("AllocationModel")) { - allocationModel = AllocationModel.fromValue(currentOrNull()); - } else if (qName.endsWith("Units")) { - units = currentOrNull(); - } else if (qName.endsWith("Allocated")) { - allocated = Integer.parseInt(currentOrNull()); - } else if (qName.endsWith("Used")) { - used = Integer.parseInt(currentOrNull()); - } else if (qName.endsWith("Limit")) { - limit = Integer.parseInt(currentOrNull()); - } else if (qName.endsWith("Overhead")) { - overhead = Integer.parseInt(currentOrNull()); - } else if (qName.endsWith("StorageCapacity")) { - storageCapacity = new Capacity(units, allocated, limit, used, overhead); - resetCapacity(); - } else if (qName.endsWith("Cpu")) { - cpuCapacity = new Capacity(units, allocated, limit, used, overhead); - resetCapacity(); - } else if (qName.endsWith("Memory")) { - memoryCapacity = new Capacity(units, allocated, limit, used, overhead); - resetCapacity(); - } else if (qName.endsWith("DeployedVmsQuota")) { - vmQuota = (int) limit; - // vcloud express doesn't have the zero is unlimited rule - if (vmQuota == -1) - vmQuota = 0; - } else if (qName.endsWith("VmQuota")) { - vmQuota = Integer.parseInt(currentOrNull()); - } else if (qName.endsWith("NicQuota")) { - nicQuota = Integer.parseInt(currentOrNull()); - } else if (qName.endsWith("NetworkQuota")) { - networkQuota = Integer.parseInt(currentOrNull()); - } else if (qName.endsWith("IsEnabled")) { - isEnabled = Boolean.parseBoolean(currentOrNull()); - } - currentText.setLength(0); - } - - public void characters(char ch[], int start, int length) { - currentText.append(ch, start, length); - } - - protected String currentOrNull() { - String returnVal = currentText.toString().trim(); - return returnVal.equals("") ? null : returnVal; - } -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/VmHandler.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/VmHandler.java deleted file mode 100644 index f68ee07201..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/VmHandler.java +++ /dev/null @@ -1,175 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.xml; - -import static org.jclouds.vcloud.util.Utils.newReferenceType; - -import java.util.List; -import java.util.Map; - -import javax.inject.Inject; - -import org.jclouds.http.functions.ParseSax; -import org.jclouds.util.SaxUtils; -import org.jclouds.vcloud.domain.GuestCustomizationSection; -import org.jclouds.vcloud.domain.NetworkConnectionSection; -import org.jclouds.vcloud.domain.ReferenceType; -import org.jclouds.vcloud.domain.Status; -import org.jclouds.vcloud.domain.Task; -import org.jclouds.vcloud.domain.Vm; -import org.jclouds.vcloud.domain.internal.VmImpl; -import org.jclouds.vcloud.domain.ovf.VCloudOperatingSystemSection; -import org.jclouds.vcloud.domain.ovf.VCloudVirtualHardwareSection; -import org.jclouds.vcloud.xml.ovf.VCloudOperatingSystemHandler; -import org.xml.sax.Attributes; -import org.xml.sax.SAXException; - -import com.google.common.collect.Lists; - -public class VmHandler extends ParseSax.HandlerWithResult { - - protected final TaskHandler taskHandler; - protected final VCloudVirtualHardwareHandler virtualHardwareHandler; - protected final VCloudOperatingSystemHandler operatingSystemHandler; - protected final GuestCustomizationSectionHandler guestCustomizationHandler; - protected final NetworkConnectionSectionHandler networkConnectionSectionHandler; - - @Inject - public VmHandler(TaskHandler taskHandler, VCloudVirtualHardwareHandler virtualHardwareHandler, - VCloudOperatingSystemHandler operatingSystemHandler, - NetworkConnectionSectionHandler networkConnectionSectionHandler, - GuestCustomizationSectionHandler guestCustomizationHandler) { - this.taskHandler = taskHandler; - this.virtualHardwareHandler = virtualHardwareHandler; - this.operatingSystemHandler = operatingSystemHandler; - this.networkConnectionSectionHandler = networkConnectionSectionHandler; - this.guestCustomizationHandler = guestCustomizationHandler; - } - - protected StringBuilder currentText = new StringBuilder(); - - protected ReferenceType vm; - protected Status status; - protected ReferenceType vdc; - protected String description; - protected List tasks = Lists.newArrayList(); - protected VCloudVirtualHardwareSection hardware; - protected VCloudOperatingSystemSection os; - protected NetworkConnectionSection networkConnectionSection; - protected GuestCustomizationSection guestCustomization; - protected String vAppScopedLocalId; - - private boolean inTasks; - private boolean inHardware; - private boolean inOs; - private boolean inNetworkConnectionSection; - private boolean inGuestCustomization; - - public Vm getResult() { - return vm == null ? null : new VmImpl(vm.getName(), vm.getType(), vm.getHref(), status, vdc, description, tasks, - hardware, os, networkConnectionSection, guestCustomization, vAppScopedLocalId); - } - - @Override - public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException { - Map attributes = SaxUtils.cleanseAttributes(attrs); - if (qName.endsWith("VirtualHardwareSection")) { - inHardware = true; - } else if (qName.endsWith("OperatingSystemSection")) { - inOs = true; - } else if (qName.endsWith("GuestCustomizationSection")) { - inGuestCustomization = true; - } else if (qName.endsWith("NetworkConnectionSection")) { - inNetworkConnectionSection = true; - } else if (qName.endsWith("Tasks")) { - inTasks = true; - } - if (inHardware) { - virtualHardwareHandler.startElement(uri, localName, qName, attrs); - } else if (inOs) { - operatingSystemHandler.startElement(uri, localName, qName, attrs); - } else if (inNetworkConnectionSection) { - networkConnectionSectionHandler.startElement(uri, localName, qName, attrs); - } else if (inGuestCustomization) { - guestCustomizationHandler.startElement(uri, localName, qName, attrs); - } else if (inTasks) { - taskHandler.startElement(uri, localName, qName, attrs); - } else if (SaxUtils.equalsOrSuffix(qName, "Vm")) { - vm = newReferenceType(attributes); - String status = attributes.get("status"); - if (status != null) - this.status = Status.fromValue(Integer.parseInt(status)); - } else if (SaxUtils.equalsOrSuffix(qName, "Link") && "up".equals(attributes.get("rel"))) { - vdc = newReferenceType(attributes); - } - } - - public void endElement(String uri, String name, String qName) { - if (qName.endsWith("VirtualHardwareSection")) { - inHardware = false; - this.hardware = virtualHardwareHandler.getResult(); - } else if (qName.endsWith("OperatingSystemSection")) { - inOs = false; - os = operatingSystemHandler.getResult(); - } else if (qName.endsWith("NetworkConnectionSection")) { - inNetworkConnectionSection = false; - networkConnectionSection = networkConnectionSectionHandler.getResult(); - } else if (qName.endsWith("GuestCustomizationSection")) { - inGuestCustomization = false; - guestCustomization = guestCustomizationHandler.getResult(); - } else if (qName.endsWith("Tasks")) { - inTasks = false; - this.tasks.add(taskHandler.getResult()); - } - if (inHardware) { - virtualHardwareHandler.endElement(uri, name, qName); - } else if (inOs) { - operatingSystemHandler.endElement(uri, name, qName); - } else if (inGuestCustomization) { - guestCustomizationHandler.endElement(uri, name, qName); - } else if (inNetworkConnectionSection) { - networkConnectionSectionHandler.endElement(uri, name, qName); - } else if (inTasks) { - taskHandler.endElement(uri, name, qName); - } else if (SaxUtils.equalsOrSuffix(qName, "Description")) { - description = currentOrNull(); - } else if (SaxUtils.equalsOrSuffix(qName, "VAppScopedLocalId")) { - vAppScopedLocalId = currentOrNull(); - } - currentText.setLength(0); - } - - public void characters(char ch[], int start, int length) { - if (inHardware) - virtualHardwareHandler.characters(ch, start, length); - else if (inOs) - operatingSystemHandler.characters(ch, start, length); - else if (inGuestCustomization) - guestCustomizationHandler.characters(ch, start, length); - else if (inNetworkConnectionSection) - networkConnectionSectionHandler.characters(ch, start, length); - else if (inTasks) - taskHandler.characters(ch, start, length); - else - currentText.append(ch, start, length); - } - - protected String currentOrNull() { - String returnVal = currentText.toString().trim(); - return returnVal.equals("") ? null : returnVal; - } -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/ovf/VCloudNetworkSectionHandler.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/ovf/VCloudNetworkSectionHandler.java deleted file mode 100644 index 39013bf619..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/ovf/VCloudNetworkSectionHandler.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.xml.ovf; - -import static org.jclouds.util.SaxUtils.equalsOrSuffix; - -import java.util.Map; - -import javax.inject.Inject; - -import org.jclouds.http.functions.ParseSax; -import org.jclouds.ovf.NetworkSection; -import org.jclouds.ovf.xml.NetworkSectionHandler; -import org.jclouds.util.SaxUtils; -import org.jclouds.vcloud.domain.ReferenceType; -import org.jclouds.vcloud.domain.ovf.VCloudNetworkSection; -import org.jclouds.vcloud.util.Utils; -import org.xml.sax.Attributes; - -public class VCloudNetworkSectionHandler extends ParseSax.HandlerWithResult { - private final NetworkSectionHandler networkSectionHandler; - - @Inject - VCloudNetworkSectionHandler(NetworkSectionHandler networkSectionHandler) { - this.networkSectionHandler = networkSectionHandler; - } - - private ReferenceType net; - - public VCloudNetworkSection getResult() { - NetworkSection system = networkSectionHandler.getResult(); - return new VCloudNetworkSection(net.getType(), net.getHref(), system.getInfo(), system.getNetworks()); - } - - public void startElement(String uri, String localName, String qName, Attributes attrs) { - Map attributes = SaxUtils.cleanseAttributes(attrs); - if (equalsOrSuffix(qName, "NetworkSection")) { - this.net = Utils.newReferenceType(attributes); - } - networkSectionHandler.startElement(uri, localName, qName, attrs); - } - - @Override - public void endElement(String uri, String localName, String qName) { - networkSectionHandler.endElement(uri, localName, qName); - } - - public void characters(char ch[], int start, int length) { - networkSectionHandler.characters(ch, start, length); - } - -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/ovf/VCloudOperatingSystemHandler.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/ovf/VCloudOperatingSystemHandler.java deleted file mode 100644 index 37866de35c..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/ovf/VCloudOperatingSystemHandler.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.xml.ovf; - -import static org.jclouds.vcloud.util.Utils.newReferenceType; - -import java.util.Map; - -import org.jclouds.http.functions.ParseSax; -import org.jclouds.util.SaxUtils; -import org.jclouds.vcloud.domain.ReferenceType; -import org.jclouds.vcloud.domain.ovf.VCloudOperatingSystemSection; -import org.jclouds.vcloud.util.Utils; -import org.xml.sax.Attributes; - -public class VCloudOperatingSystemHandler extends ParseSax.HandlerWithResult { - private StringBuilder currentText = new StringBuilder(); - - protected ReferenceType os; - protected Integer id; - protected String info; - protected String vmwOsType; - protected String description; - protected ReferenceType edit; - - public VCloudOperatingSystemSection getResult() { - VCloudOperatingSystemSection system = new VCloudOperatingSystemSection(id, info, description, os.getType(), os.getHref(), - vmwOsType, edit); - os = null; - id = null; - info = null; - vmwOsType = null; - description = null; - edit = null; - return system; - } - - @Override - public void startElement(String uri, String localName, String qName, Attributes attrs) { - Map attributes = SaxUtils.cleanseAttributes(attrs); - if (qName.endsWith("Link")) { - this.edit = Utils.newReferenceType(attributes); - } else if (qName.endsWith("OperatingSystemSection")) { - os = newReferenceType(attributes); - vmwOsType = attributes.get("osType"); - if (attributes.containsKey("id")) - this.id = Integer.parseInt(attributes.get("id")); - } - } - - @Override - public void endElement(String uri, String localName, String qName) { - if (qName.endsWith("Info")) { - this.info = currentText.toString().trim(); - } else if (qName.endsWith("Description")) { - this.description = currentText.toString().trim(); - } - currentText.setLength(0); - } - - public void characters(char ch[], int start, int length) { - currentText.append(ch, start, length); - } -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/ovf/VCloudResourceAllocationSettingDataHandler.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/ovf/VCloudResourceAllocationSettingDataHandler.java deleted file mode 100644 index 5331a34f0d..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/ovf/VCloudResourceAllocationSettingDataHandler.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.xml.ovf; - -import java.util.Map; - -import org.jclouds.cim.ResourceAllocationSettingData; -import org.jclouds.cim.xml.ResourceAllocationSettingDataHandler; -import org.jclouds.util.SaxUtils; -import org.jclouds.vcloud.domain.ReferenceType; -import org.jclouds.vcloud.domain.ovf.EditableResourceAllocationSettingData; -import org.jclouds.vcloud.domain.ovf.VCloudHardDisk; -import org.jclouds.vcloud.domain.ovf.VCloudNetworkAdapter; -import org.jclouds.vcloud.util.Utils; -import org.xml.sax.Attributes; - -public class VCloudResourceAllocationSettingDataHandler extends ResourceAllocationSettingDataHandler { - - private ReferenceType edit; - - private long capacity; - private int busType; - private String busSubType; - - private String ipAddress; - private boolean primaryNetworkConnection; - private String ipAddressingMode; - - public ResourceAllocationSettingData getResult() { - try { - ResourceAllocationSettingData from = super.getResult(); - if (edit != null) { - return EditableResourceAllocationSettingData.builder().fromResourceAllocationSettingData(from).edit(edit) - .build(); - } else if (busSubType != null) { - return VCloudHardDisk.builder().fromResourceAllocationSettingData(from).capacity(capacity).busType(busType) - .busSubType(busSubType).build(); - } else if (ipAddress != null) { - return VCloudNetworkAdapter.builder().fromResourceAllocationSettingData(from).ipAddress(ipAddress) - .primaryNetworkConnection(primaryNetworkConnection).ipAddressingMode(ipAddressingMode).build(); - } else { - return from; - } - } finally { - ipAddress = null; - primaryNetworkConnection = false; - ipAddressingMode = null; - capacity = -1; - busType = -1; - busSubType = null; - edit = null; - } - } - - @Override - public void startElement(String uri, String localName, String qName, Attributes attrs) { - Map attributes = SaxUtils.cleanseAttributes(attrs); - if (qName.endsWith("Link")) { - this.edit = Utils.newReferenceType(attributes); - } else if (qName.endsWith("HostResource") && !attributes.isEmpty()) { - capacity = Long.parseLong(attributes.get("capacity")); - busType = Integer.parseInt(attributes.get("busType")); - busSubType = attributes.get("busSubType"); - } else if (qName.endsWith("Connection") && !attributes.isEmpty()) { - ipAddress = attributes.get("ipAddress"); - primaryNetworkConnection = Boolean.parseBoolean(attributes.get("primaryNetworkConnection")); - ipAddressingMode = attributes.get("ipAddressingMode"); - } - super.startElement(uri, localName, qName, attrs); - } - -} diff --git a/apis/vcloud/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata b/apis/vcloud/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata deleted file mode 100644 index d800a949a2..0000000000 --- a/apis/vcloud/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata +++ /dev/null @@ -1 +0,0 @@ -org.jclouds.vcloud.VCloudApiMetadata \ No newline at end of file diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/VCloudApiMetadataTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/VCloudApiMetadataTest.java deleted file mode 100644 index 8e3f826233..0000000000 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/VCloudApiMetadataTest.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud; - -import org.jclouds.compute.internal.BaseComputeServiceApiMetadataTest; -import org.testng.annotations.Test; - -@Test(groups = "unit", testName = "VCloudApiMetadataTest") -public class VCloudApiMetadataTest extends BaseComputeServiceApiMetadataTest { - - public VCloudApiMetadataTest() { - super(new VCloudApiMetadata()); - } -} diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/VCloudApiTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/VCloudApiTest.java deleted file mode 100644 index 049b3d9366..0000000000 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/VCloudApiTest.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud; - -import java.io.IOException; -import java.util.concurrent.ExecutionException; - -import org.jclouds.vcloud.internal.BaseVCloudApiTest; -import org.jclouds.vcloud.utils.TestUtils; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; - -/** - * Tests behavior of {@code VCloudApi} - */ -// NOTE:without testName, this will not call @Before* and fail w/NPE during -// surefire -@Test(groups = "unit", testName = "VCloudApiTest") -public class VCloudApiTest extends BaseVCloudApiTest { - - private VCloudApi syncClient; - - public void testSync() throws SecurityException, NoSuchMethodException, InterruptedException, ExecutionException { - assert syncClient.getVAppApi() != null; - assert syncClient.getCatalogApi() != null; - assert syncClient.getVmApi() != null; - assert syncClient.getVAppTemplateApi() != null; - assert syncClient.getTaskApi() != null; - assert syncClient.getVDCApi() != null; - assert syncClient.getNetworkApi() != null; - assert syncClient.getOrgApi() != null; - } - - @BeforeClass - @Override - protected void setupFactory() throws IOException { - super.setupFactory(); - syncClient = injector.getInstance(VCloudApi.class); - } - - @DataProvider - public Object[][] ignoreOnWindows() { - return TestUtils.isWindowsOs() ? TestUtils.NO_INVOCATIONS - : TestUtils.SINGLE_NO_ARG_INVOCATION; - } - -} diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/VCloudSessionRefreshLiveTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/VCloudSessionRefreshLiveTest.java deleted file mode 100644 index dcd3e8ecc9..0000000000 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/VCloudSessionRefreshLiveTest.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud; - -import org.jclouds.vcloud.internal.BaseVCloudApiLiveTest; -import org.testng.annotations.Test; - -/** - * Tests session refresh works - */ -@Test(groups = "live", singleThreaded = true) -public class VCloudSessionRefreshLiveTest extends BaseVCloudApiLiveTest { - - private static final int timeOut = 40; - - @Test - public void testSessionRefresh() throws Exception { - VCloudApi connection = view.unwrapApi(VCloudApi.class); - - connection.getOrgApi().findOrgNamed(null); - Thread.sleep(timeOut * 1000); - connection.getOrgApi().findOrgNamed(null); - } - -} diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/VCloudVersionsApiTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/VCloudVersionsApiTest.java deleted file mode 100644 index 6095e1de9a..0000000000 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/VCloudVersionsApiTest.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud; - -import static org.jclouds.reflect.Reflection2.method; -import static org.testng.Assert.assertEquals; - -import java.io.IOException; - -import org.jclouds.http.HttpRequest; -import org.jclouds.http.functions.ParseSax; -import org.jclouds.providers.AnonymousProviderMetadata; -import org.jclouds.providers.ProviderMetadata; -import org.jclouds.rest.internal.BaseRestAnnotationProcessingTest; -import org.jclouds.rest.internal.GeneratedHttpRequest; -import org.jclouds.vcloud.xml.SupportedVersionsHandler; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableList; -import com.google.common.reflect.Invokable; - -/** - * Tests behavior of {@code VCloudVersionsApi} - */ -// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire -@Test(groups = "unit", testName = "VCloudVersionsApiTest") -public class VCloudVersionsApiTest extends BaseRestAnnotationProcessingTest { - - public void testVersions() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(VCloudVersionsApi.class, "getSupportedVersions"); - GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.of()); - - assertEquals(request.getRequestLine(), "GET http://localhost:8080/versions HTTP/1.1"); - assertNonPayloadHeadersEqual(request, ""); - assertPayloadEquals(request, null, null, false); - - assertResponseParserClassEquals(method, request, ParseSax.class); - assertSaxResponseParserClassEquals(method, SupportedVersionsHandler.class); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - @Override - protected void checkFilters(HttpRequest request) { - assertEquals(request.getFilters().size(), 0); - } - - @Override - protected ProviderMetadata createProviderMetadata() { - return AnonymousProviderMetadata.forApiOnEndpoint(VCloudVersionsApi.class, - "http://localhost:8080"); - } -} diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/binders/BindCatalogItemToXmlPayloadTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/binders/BindCatalogItemToXmlPayloadTest.java deleted file mode 100644 index 599f4a19e9..0000000000 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/binders/BindCatalogItemToXmlPayloadTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.binders; - -import static org.testng.Assert.assertEquals; - -import java.io.IOException; -import java.util.Map; - -import org.jclouds.rest.internal.GeneratedHttpRequest; -import org.jclouds.vcloud.internal.BasePayloadTest; -import org.jclouds.vcloud.options.CatalogItemOptions; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; - -/** - * Tests behavior of {@code BindCatalogItemToXmlPayload} - */ -@Test(groups = "unit") -public class BindCatalogItemToXmlPayloadTest extends BasePayloadTest { - - public void testDefault() throws IOException { - String expected = "mydescriptionbar"; - - CatalogItemOptions options = CatalogItemOptions.Builder.description("mydescription").properties( - ImmutableMap.of("foo", "bar")); - GeneratedHttpRequest request = requestForArgs(ImmutableList. of(options)); - - BindCatalogItemToXmlPayload binder = injector.getInstance(BindCatalogItemToXmlPayload.class); - - Map map = ImmutableMap. of("name", "myname", "Entity", "http://fooentity"); - - assertEquals(binder.bindToRequest(request, map).getPayload().getRawContent(), expected); - } -} diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/binders/BindCloneVAppParamsToXmlPayloadTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/binders/BindCloneVAppParamsToXmlPayloadTest.java deleted file mode 100644 index 8d6042d591..0000000000 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/binders/BindCloneVAppParamsToXmlPayloadTest.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.binders; - -import static org.testng.Assert.assertEquals; - -import org.jclouds.rest.internal.GeneratedHttpRequest; -import org.jclouds.util.Strings2; -import org.jclouds.vcloud.internal.BasePayloadTest; -import org.jclouds.vcloud.options.CloneVAppOptions; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableMap.Builder; - -/** - * Tests behavior of {@code BindCloneVAppParamsToXmlPayload} - */ -@Test(groups = "unit") -public class BindCloneVAppParamsToXmlPayloadTest extends BasePayloadTest { - - public void testWithDescriptionDeployOn() throws Exception { - String expected = Strings2.toStringAndClose(getClass().getResourceAsStream("/copyVApp.xml")); - - CloneVAppOptions options = new CloneVAppOptions().deploy().powerOn().description( - "The description of the new vApp"); - GeneratedHttpRequest request = requestForArgs(ImmutableList. of(options)); - - BindCloneVAppParamsToXmlPayload binder = injector.getInstance(BindCloneVAppParamsToXmlPayload.class); - - Builder map = ImmutableMap.builder(); - map.put("name", "new-linux-server"); - map.put("Source", "https://vcenterprise.bluelock.com/api/v1.0/vapp/201"); - assertEquals(binder.bindToRequest(request, map.build()).getPayload().getRawContent(), expected); - } - - public void testWithDescriptionDeployOnSourceDelete() throws Exception { - String expected = Strings2.toStringAndClose(getClass().getResourceAsStream("/moveVApp.xml")); - - CloneVAppOptions options = new CloneVAppOptions().deploy().powerOn().description( - "The description of the new vApp"); - GeneratedHttpRequest request = requestForArgs(ImmutableList. of(options)); - - BindCloneVAppParamsToXmlPayload binder = injector.getInstance(BindCloneVAppParamsToXmlPayload.class); - - Builder map = ImmutableMap.builder(); - map.put("name", "new-linux-server"); - map.put("Source", "https://vcenterprise.bluelock.com/api/v1.0/vapp/201"); - map.put("IsSourceDelete", "true"); - assertEquals(binder.bindToRequest(request, map.build()).getPayload().getRawContent(), expected); - } - - public void testDefault() throws Exception { - String expected = Strings2.toStringAndClose(getClass().getResourceAsStream("/copyVApp-default.xml")); - GeneratedHttpRequest request = requestForArgs(ImmutableList. of()); - - BindCloneVAppParamsToXmlPayload binder = injector.getInstance(BindCloneVAppParamsToXmlPayload.class); - - Builder map = ImmutableMap.builder(); - map.put("name", "my-vapp"); - map.put("Source", "https://vcenterprise.bluelock.com/api/v1.0/vapp/4181"); - assertEquals(binder.bindToRequest(request, map.build()).getPayload().getRawContent(), expected); - } -} diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/binders/BindCloneVAppTemplateParamsToXmlPayloadTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/binders/BindCloneVAppTemplateParamsToXmlPayloadTest.java deleted file mode 100644 index 73d6342316..0000000000 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/binders/BindCloneVAppTemplateParamsToXmlPayloadTest.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.binders; - -import static org.jclouds.util.Strings2.toStringAndClose; -import static org.testng.Assert.assertEquals; - -import java.io.IOException; - -import org.jclouds.rest.internal.GeneratedHttpRequest; -import org.jclouds.vcloud.internal.BasePayloadTest; -import org.jclouds.vcloud.options.CloneVAppTemplateOptions; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableMap.Builder; - -/** - * Tests behavior of {@code BindCloneVAppTemplateParamsToXmlPayload} - */ -@Test(groups = "unit") -public class BindCloneVAppTemplateParamsToXmlPayloadTest extends BasePayloadTest { - public void testWithDescription() throws IOException { - String expected = toStringAndClose(getClass().getResourceAsStream("/copyVAppTemplate.xml")); - - CloneVAppTemplateOptions options = new CloneVAppTemplateOptions() - .description("The description of the new vAppTemplate"); - GeneratedHttpRequest request = requestForArgs(ImmutableList. of(options)); - - BindCloneVAppTemplateParamsToXmlPayload binder = injector - .getInstance(BindCloneVAppTemplateParamsToXmlPayload.class); - - Builder map = ImmutableMap.builder(); - map.put("name", "new-linux-server"); - map.put("Source", "https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/201"); - - assertEquals(binder.bindToRequest(request, map.build()).getPayload().getRawContent(), expected); - } - - public void testWithDescriptionSourceDelete() throws IOException { - String expected = toStringAndClose(getClass().getResourceAsStream("/moveVAppTemplate.xml")); - - CloneVAppTemplateOptions options = new CloneVAppTemplateOptions() - .description("The description of the new vAppTemplate"); - GeneratedHttpRequest request = requestForArgs(ImmutableList. of(options)); - - BindCloneVAppTemplateParamsToXmlPayload binder = injector - .getInstance(BindCloneVAppTemplateParamsToXmlPayload.class); - - Builder map = ImmutableMap.builder(); - map.put("name", "new-linux-server"); - map.put("Source", "https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/201"); - map.put("IsSourceDelete", "true"); - - assertEquals(binder.bindToRequest(request, map.build()).getPayload().getRawContent(), expected); - } - - public void testDefault() throws IOException { - String expected = toStringAndClose(getClass().getResourceAsStream("/copyVAppTemplate-default.xml")); - - GeneratedHttpRequest request = requestForArgs(ImmutableList. of()); - - BindCloneVAppTemplateParamsToXmlPayload binder = injector - .getInstance(BindCloneVAppTemplateParamsToXmlPayload.class); - - Builder map = ImmutableMap.builder(); - map.put("name", "my-vapptemplate"); - map.put("Source", "https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/4181"); - - assertEquals(binder.bindToRequest(request, map.build()).getPayload().getRawContent(), expected); - } -} diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/binders/BindDeployVAppParamsToXmlPayloadTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/binders/BindDeployVAppParamsToXmlPayloadTest.java deleted file mode 100644 index f145e97014..0000000000 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/binders/BindDeployVAppParamsToXmlPayloadTest.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.binders; - -import static org.testng.Assert.assertEquals; - -import java.io.IOException; -import java.util.Map; - -import org.jclouds.rest.internal.GeneratedHttpRequest; -import org.jclouds.vcloud.internal.BasePayloadTest; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableList; -import com.google.common.collect.Maps; - -/** - * Tests behavior of {@code BindDeployVAppParamsToXmlPayload} - */ -@Test(groups = "unit") -public class BindDeployVAppParamsToXmlPayloadTest extends BasePayloadTest { - - public void testPowerOnTrue() throws IOException { - String expected = ""; - - GeneratedHttpRequest request = requestForArgs(ImmutableList. of()); - - BindDeployVAppParamsToXmlPayload binder = injector.getInstance(BindDeployVAppParamsToXmlPayload.class); - - Map map = Maps.newHashMap(); - map.put("powerOn", "true"); - assertEquals(binder.bindToRequest(request, map).getPayload().getRawContent(), expected); - } - - public void testDefault() throws IOException { - String expected = ""; - - GeneratedHttpRequest request = requestForArgs(ImmutableList. of()); - - BindDeployVAppParamsToXmlPayload binder = injector.getInstance(BindDeployVAppParamsToXmlPayload.class); - - Map map = Maps.newHashMap(); - assertEquals(binder.bindToRequest(request, map).getPayload().getRawContent(), expected); - } -} diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/binders/BindInstantiateVAppTemplateParamsToXmlPayloadTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/binders/BindInstantiateVAppTemplateParamsToXmlPayloadTest.java deleted file mode 100644 index ead0badf9f..0000000000 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/binders/BindInstantiateVAppTemplateParamsToXmlPayloadTest.java +++ /dev/null @@ -1,177 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.binders; - -import static org.easymock.EasyMock.createMock; -import static org.easymock.EasyMock.replay; -import static org.jclouds.vcloud.options.InstantiateVAppTemplateOptions.Builder.addNetworkConfig; -import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_DEFAULT_FENCEMODE; -import static org.testng.Assert.assertEquals; - -import java.io.IOException; -import java.net.URI; -import java.util.Map; - -import javax.inject.Named; -import javax.inject.Singleton; - -import org.jclouds.rest.internal.GeneratedHttpRequest; -import org.jclouds.util.Strings2; -import org.jclouds.vcloud.VCloudApiMetadata; -import org.jclouds.vcloud.domain.ReferenceType; -import org.jclouds.vcloud.domain.VAppTemplate; -import org.jclouds.vcloud.domain.internal.ReferenceTypeImpl; -import org.jclouds.vcloud.domain.network.FenceMode; -import org.jclouds.vcloud.domain.network.NetworkConfig; -import org.jclouds.vcloud.endpoints.Network; -import org.jclouds.vcloud.internal.BasePayloadTest; -import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions; -import org.nnsoft.guice.rocoto.Rocoto; -import org.nnsoft.guice.rocoto.configuration.ConfigurationModule; -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.cache.CacheBuilder; -import com.google.common.cache.CacheLoader; -import com.google.common.cache.LoadingCache; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.Maps; -import com.google.inject.Guice; -import com.google.inject.Injector; -import com.google.inject.Provides; - -/** - * Tests behavior of {@code BindInstantiateVAppTemplateParamsToXmlPayload} - */ -@Test(groups = "unit") -public class BindInstantiateVAppTemplateParamsToXmlPayloadTest extends BasePayloadTest { - Injector createInjector(final URI vAppTemplate, final VAppTemplate value) { - - return Guice.createInjector(Rocoto.expandVariables(new ConfigurationModule() { - - @Provides - @Singleton - @Network - protected Function templateToDefaultNetworkName() { - return Functions.forMap(ImmutableMap.of(value, "vAppNet-vApp Internal")); - } - - @Provides - @Singleton - protected LoadingCache templateIdToVAppTemplate() { - return CacheBuilder.newBuilder().build( - CacheLoader.from(Functions.forMap(ImmutableMap.of(vAppTemplate, value)))); - } - - @Override - protected void bindConfigurations() { - bindProperties(new VCloudApiMetadata().getDefaultProperties()); - } - - @Provides - @Singleton - public FenceMode defaultFenceMode(@Named(PROPERTY_VCLOUD_DEFAULT_FENCEMODE) String fenceMode) { - return FenceMode.fromValue(fenceMode); - } - - @Network - @Provides - @Singleton - Supplier provideNetwork() { - return Suppliers.ofInstance(new ReferenceTypeImpl(null, null, URI - .create("https://vcenterprise.bluelock.com/api/v1.0/network/1990"))); - } - })); - } - - public void testDefault() throws IOException { - URI templateUri = URI.create("https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/3"); - VAppTemplate template = createMock(VAppTemplate.class); - replay(template); - - String expected = Strings2.toStringAndClose(getClass().getResourceAsStream("/instantiationparams.xml")); - GeneratedHttpRequest request = requestForArgs(ImmutableList. of(new InstantiateVAppTemplateOptions())); - - BindInstantiateVAppTemplateParamsToXmlPayload binder = createInjector(templateUri, template).getInstance( - BindInstantiateVAppTemplateParamsToXmlPayload.class); - - Map map = Maps.newHashMap(); - map.put("name", "my-vapp"); - map.put("template", templateUri.toASCIIString()); - assertEquals(binder.bindToRequest(request, map).getPayload().getRawContent(), expected); - } - - public void testDescription() throws IOException { - URI templateUri = URI.create("https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/3"); - VAppTemplate template = createMock(VAppTemplate.class); - replay(template); - - String expected = Strings2.toStringAndClose(getClass() - .getResourceAsStream("/instantiationparams-description.xml")); - GeneratedHttpRequest request = requestForArgs(ImmutableList. of(new InstantiateVAppTemplateOptions().description("my foo"))); - - BindInstantiateVAppTemplateParamsToXmlPayload binder = createInjector(templateUri, template).getInstance( - BindInstantiateVAppTemplateParamsToXmlPayload.class); - - Map map = Maps.newHashMap(); - map.put("name", "my-vapp"); - map.put("template", templateUri.toASCIIString()); - assertEquals(binder.bindToRequest(request, map).getPayload().getRawContent(), expected); - } - - public void testWhenTemplateDoesntExist() throws IOException { - URI templateUri = URI.create("https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/3"); - VAppTemplate template = createMock(VAppTemplate.class); - replay(template); - - String expected = Strings2.toStringAndClose(getClass().getResourceAsStream("/instantiationparams.xml")); - GeneratedHttpRequest request = requestForArgs(ImmutableList. of()); - - BindInstantiateVAppTemplateParamsToXmlPayload binder = createInjector(templateUri, template).getInstance( - BindInstantiateVAppTemplateParamsToXmlPayload.class); - - Map map = Maps.newHashMap(); - map.put("name", "my-vapp"); - map.put("template", templateUri.toASCIIString()); - assertEquals(binder.bindToRequest(request, map).getPayload().getRawContent(), expected); - } - - public void testWithNetworkNameFenceMode() throws IOException { - URI templateUri = URI.create("https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/3"); - VAppTemplate template = createMock(VAppTemplate.class); - replay(template); - - InstantiateVAppTemplateOptions options = addNetworkConfig(new NetworkConfig("aloha", URI - .create("https://vcenterprise.bluelock.com/api/v1.0/network/1991"), FenceMode.NAT_ROUTED)); - - String expected = Strings2.toStringAndClose(getClass().getResourceAsStream("/instantiationparams-network.xml")); - GeneratedHttpRequest request = requestForArgs(ImmutableList. of(options)); - - BindInstantiateVAppTemplateParamsToXmlPayload binder = createInjector(templateUri, template).getInstance( - BindInstantiateVAppTemplateParamsToXmlPayload.class); - - Map map = Maps.newHashMap(); - map.put("name", "my-vapp"); - map.put("template", "https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/3"); - - assertEquals(binder.bindToRequest(request, map).getPayload().getRawContent(), expected); - } -} diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/binders/BindNetworkConnectionSectionToXmlPayloadTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/binders/BindNetworkConnectionSectionToXmlPayloadTest.java deleted file mode 100644 index 77059b04f8..0000000000 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/binders/BindNetworkConnectionSectionToXmlPayloadTest.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.binders; - -import static org.testng.Assert.assertEquals; - -import java.io.IOException; -import java.net.URI; - -import org.jclouds.http.HttpRequest; -import org.jclouds.vcloud.domain.NetworkConnection; -import org.jclouds.vcloud.domain.NetworkConnectionSection; -import org.jclouds.vcloud.domain.network.IpAddressAllocationMode; -import org.jclouds.vcloud.internal.BasePayloadTest; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableSet; - -/** - * Tests behavior of {@code BindNetworkConnectionSectionToXmlPayload} - */ -@Test(groups = "unit", testName = "BindNetworkConnectionSectionToXmlPayloadTest") -public class BindNetworkConnectionSectionToXmlPayloadTest extends BasePayloadTest { - - public void testWithIpAllocationModeNONE() throws IOException { - - HttpRequest request = HttpRequest.builder().endpoint("http://localhost/key").method("GET") - .build(); - - BindNetworkConnectionSectionToXmlPayload binder = injector - .getInstance(BindNetworkConnectionSectionToXmlPayload.class); - - binder.bindToRequest( - request, - NetworkConnectionSection - .builder() - .type("application/vnd.vmware.vcloud.networkConnectionSection+xml") - .info("Specifies the available VM network connections") - .href(URI.create("https://1.1.1.1/api/v1.0/vApp/vm-1/networkConnectionSection/")) - .connections( - ImmutableSet. of(NetworkConnection.builder().network("none") - .ipAddressAllocationMode(IpAddressAllocationMode.NONE).build())).build()); - assertEquals(request.getPayload().getContentMetadata().getContentType(), - "application/vnd.vmware.vcloud.networkConnectionSection+xml"); - - assertEquals( - request.getPayload().getRawContent(), - "Specifies the available VM network connections0falseNONE"); - - } - -} diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/binders/BindUndeployVAppParamsToXmlPayloadTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/binders/BindUndeployVAppParamsToXmlPayloadTest.java deleted file mode 100644 index 59a41419c6..0000000000 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/binders/BindUndeployVAppParamsToXmlPayloadTest.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.binders; - -import static org.testng.Assert.assertEquals; - -import java.io.IOException; -import java.util.Map; - -import org.jclouds.rest.internal.GeneratedHttpRequest; -import org.jclouds.vcloud.internal.BasePayloadTest; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableList; -import com.google.common.collect.Maps; - -/** - * Tests behavior of {@code BindUndeployVAppParamsToXmlPayload} - */ -@Test(groups = "unit") -public class BindUndeployVAppParamsToXmlPayloadTest extends BasePayloadTest { - - public void testSaveStateTrue() throws IOException { - String expected = ""; - - GeneratedHttpRequest request = requestForArgs(ImmutableList. of()); - - BindUndeployVAppParamsToXmlPayload binder = injector.getInstance(BindUndeployVAppParamsToXmlPayload.class); - - Map map = Maps.newHashMap(); - map.put("saveState", "true"); - assertEquals(binder.bindToRequest(request, map).getPayload().getRawContent(), expected); - } - - public void testDefault() throws IOException { - String expected = ""; - - GeneratedHttpRequest request = requestForArgs(ImmutableList. of()); - - BindUndeployVAppParamsToXmlPayload binder = injector.getInstance(BindUndeployVAppParamsToXmlPayload.class); - - Map map = Maps.newHashMap(); - assertEquals(binder.bindToRequest(request, map).getPayload().getRawContent(), expected); - } -} diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/compute/BaseVCloudComputeServiceExpectTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/compute/BaseVCloudComputeServiceExpectTest.java deleted file mode 100644 index f343d6e5df..0000000000 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/compute/BaseVCloudComputeServiceExpectTest.java +++ /dev/null @@ -1,158 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.compute; - -import java.net.URI; -import java.util.Properties; - -import javax.ws.rs.core.MediaType; - -import org.jclouds.apis.ApiMetadata; -import org.jclouds.compute.ComputeService; -import org.jclouds.http.HttpRequest; -import org.jclouds.http.HttpResponse; -import org.jclouds.rest.internal.BaseRestApiExpectTest; -import org.jclouds.vcloud.VCloudApiMetadata; -import org.jclouds.vcloud.VCloudMediaType; - -import com.google.common.base.Function; -import com.google.common.net.HttpHeaders; -import com.google.inject.Module; - -/** - * Base class for writing VCloud Expect tests for ComputeService operations - */ -public abstract class BaseVCloudComputeServiceExpectTest extends BaseRestApiExpectTest { - protected static final String ENDPOINT = "https://zone.myvcloud.com/api"; - - protected HttpRequest versionsRequest = HttpRequest.builder().method("GET").endpoint( - URI.create(ENDPOINT + "/versions")).build(); - - protected HttpResponse versionsResponseFromVCD1_5 = HttpResponse.builder().statusCode(200) - .message("HTTP/1.1 200 OK").payload(payloadFromResourceWithContentType("/versions-vcd15.xml", "text/xml")) - .build(); - - // initial auth is using basic - protected HttpRequest version1_0LoginRequest = HttpRequest.builder().method("POST").endpoint(ENDPOINT + "/v1.0/login") - .addHeader(HttpHeaders.ACCEPT, VCloudMediaType.ORGLIST_XML) - .addHeader(HttpHeaders.AUTHORIZATION, "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==").build(); - - protected String sessionToken = "AtatAgvJMrwOc9pDQq4RRCRLazThpnTKJDxSVH9oB2I="; - - // login response includes a cookie and also a vcloud extended header with the session token in it - // NOTE: vCloud Director 1.5 returns ;version=1.0 on responses to requests made in 1.0 format. - protected HttpResponse successfulVersion1_0LoginResponseFromVCD1_5WithSingleOrg = HttpResponse.builder().statusCode(200) - .message("HTTP/1.1 200 OK").payload(payloadFromResourceWithContentType("/orgList1.0-vcd15.xml", VCloudMediaType.ORGLIST_XML + ";version=1.0")) - .addHeader("x-vcloud-authorization", sessionToken) - .addHeader(HttpHeaders.SET_COOKIE, String.format("vcloud-token=%s; Secure; Path=/", sessionToken)).build(); - - // objects are looked up by id and the format of the id is hex-hyphen - protected String orgId = "c076f90a-397a-49fa-89b8-b294c1599cd0"; - - protected HttpRequest version1_0GetOrgRequest = HttpRequest.builder().method("GET").endpoint(ENDPOINT + "/v1.0/org/" + orgId) - .addHeader(HttpHeaders.ACCEPT, VCloudMediaType.ORG_XML) - .addHeader("x-vcloud-authorization", sessionToken) - .addHeader(HttpHeaders.COOKIE, "vcloud-token=" + sessionToken).build(); - - protected HttpResponse successfulVersion1_0GetOrgResponseFromVCD1_5WithSingleTasksListVDCAndNetwork = HttpResponse.builder().statusCode(200) - .message("HTTP/1.1 200 OK").payload(payloadFromResourceWithContentType("/org1.0-vcd15.xml", VCloudMediaType.ORG_XML + ";version=1.0")) - .build(); - - protected String catalogId = "3155f393-1e1d-4572-8c9c-d76f72ddb658"; - protected String vdcId = "e9cd3387-ac57-4d27-a481-9bee75e0690f"; - - protected HttpRequest version1_0GetCatalogRequest = HttpRequest.builder().method("GET").endpoint(ENDPOINT + "/v1.0/catalog/" + catalogId) - .addHeader(HttpHeaders.ACCEPT, VCloudMediaType.CATALOG_XML) - .addHeader("x-vcloud-authorization", sessionToken) - .addHeader(HttpHeaders.COOKIE, "vcloud-token=" + sessionToken).build(); - - protected HttpResponse successfulVersion1_0GetCatalogResponseFromVCD1_5WithSingleTemplate = HttpResponse.builder().statusCode(200) - .message("HTTP/1.1 200 OK").payload(payloadFromResourceWithContentType("/catalog1.0-vcd15.xml", VCloudMediaType.CATALOG_XML + ";version=1.0")) - .build(); - - protected String catalogItemId = "ceb369f7-1d07-4e32-9dbd-ebb5aa6ca55c"; - - protected HttpRequest version1_0GetCatalogItemRequest = HttpRequest.builder().method("GET").endpoint(ENDPOINT + "/v1.0/catalogItem/" + catalogItemId) - .addHeader(HttpHeaders.ACCEPT, VCloudMediaType.CATALOGITEM_XML) - .addHeader("x-vcloud-authorization", sessionToken) - .addHeader(HttpHeaders.COOKIE, "vcloud-token=" + sessionToken).build(); - - protected HttpResponse successfulVersion1_0GetCatalogItemResponseFromVCD1_5ForTemplate = HttpResponse.builder().statusCode(200) - .message("HTTP/1.1 200 OK").payload(payloadFromResourceWithContentType("/catalogItem1.0-vcd15.xml", VCloudMediaType.CATALOGITEM_XML + ";version=1.0")) - .build(); - - // note vAppTemplate has a prefix in its id - protected String templateId = "vappTemplate-51891b97-c5dd-47dc-a687-aabae354f728"; - - protected HttpRequest version1_0GetVDCRequest = HttpRequest.builder().method("GET").endpoint(ENDPOINT + "/v1.0/vdc/" + vdcId) - .addHeader(HttpHeaders.ACCEPT, VCloudMediaType.VDC_XML) - .addHeader("x-vcloud-authorization", sessionToken) - .addHeader(HttpHeaders.COOKIE, "vcloud-token=" + sessionToken).build(); - - protected HttpResponse successfulVersion1_0GetVDCResponseFromVCD1_5WithSingleTemplateAndNetwork = HttpResponse.builder().statusCode(200) - .message("HTTP/1.1 200 OK").payload(payloadFromResourceWithContentType("/vdc1.0-vcd15.xml", VCloudMediaType.VDC_XML + ";version=1.0")) - .build(); - - protected String networkId = "b466c0c5-8a5c-4335-b703-a2e2e6b5f3e1"; - - protected HttpRequest version1_0GetVAppTemplateRequest = HttpRequest.builder().method("GET").endpoint(ENDPOINT + "/v1.0/vAppTemplate/" + templateId) - .addHeader(HttpHeaders.ACCEPT, VCloudMediaType.VAPPTEMPLATE_XML) - .addHeader("x-vcloud-authorization", sessionToken) - .addHeader(HttpHeaders.COOKIE, "vcloud-token=" + sessionToken).build(); - - protected HttpResponse successfulVersion1_0GetVAppTemplateResponseFromVCD1_5WithSingleVMAndVDCParent = HttpResponse.builder().statusCode(200) - .message("HTTP/1.1 200 OK").payload(payloadFromResourceWithContentType("/template1.0-vcd15.xml", VCloudMediaType.VAPPTEMPLATE_XML + ";version=1.0")) - .build(); - - protected HttpResponse successfulVersion1_0GetVAppTemplateResponseFromVCD1_5WithMultipleVMsAndVDCParent = HttpResponse.builder().statusCode(200) - .message("HTTP/1.1 200 OK").payload(payloadFromResourceWithContentType("/template1.0-vcd15-multi-vm.xml", VCloudMediaType.VAPPTEMPLATE_XML + ";version=1.0")) - .build(); - - protected HttpRequest version1_0GetOVFForVAppTemplateRequest = HttpRequest.builder().method("GET").endpoint(ENDPOINT + "/v1.0/vAppTemplate/" + templateId + "/ovf") - .addHeader(HttpHeaders.ACCEPT, MediaType.TEXT_XML) - .addHeader("x-vcloud-authorization", sessionToken) - .addHeader(HttpHeaders.COOKIE, "vcloud-token=" + sessionToken).build(); - - protected HttpResponse successfulVersion1_0GetOVFForVAppTemplateResponseFromVCD1_5WithSingleVM = HttpResponse.builder().statusCode(200) - .message("HTTP/1.1 200 OK").payload(payloadFromResourceWithContentType("/ovf-ubuntu64.xml", MediaType.TEXT_XML + ";version=1.0")) - .build(); - - protected HttpResponse successfulVersion1_0GetOVFForVAppTemplateResponseFromVCD1_5WithMultipleVMs = HttpResponse.builder().statusCode(200) - .message("HTTP/1.1 200 OK").payload(payloadFromResourceWithContentType("/ovf-multi-vm.xml", MediaType.TEXT_XML + ";version=1.0")) - .build(); - - public BaseVCloudComputeServiceExpectTest() { - provider = "vcloud"; - } - - @Override - public ComputeService createClient(Function fn, Module module, Properties props) { - return createInjector(fn, module, props).getInstance(ComputeService.class); - } - - @Override - protected ApiMetadata createApiMetadata() { - return new VCloudApiMetadata(); - } - - @Override - protected Properties setupProperties() { - Properties props = super.setupProperties(); - props.setProperty(provider + ".endpoint", ENDPOINT); - return props; - } -} diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/compute/VCloudComputeServiceLiveTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/compute/VCloudComputeServiceLiveTest.java deleted file mode 100644 index f5d3ec68e5..0000000000 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/compute/VCloudComputeServiceLiveTest.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.compute; - -import org.jclouds.compute.internal.BaseComputeServiceLiveTest; -import org.jclouds.sshj.config.SshjSshClientModule; -import org.testng.annotations.Test; - -import com.google.inject.Module; - -@Test(groups = "live", enabled = true, singleThreaded = true) -public class VCloudComputeServiceLiveTest extends BaseComputeServiceLiveTest { - - public VCloudComputeServiceLiveTest() { - provider = "vcloud"; - } - - @Override - public void setServiceDefaults() { - // extremely short names needed so that we don't get errors relating to - // guestCustomization.computerName being too long - group = "vcd"; - } - - @Override - public void testOptionToNotBlock() { - // start call has to block until deploy - } - - @Override - protected Module getSshModule() { - return new SshjSshClientModule(); - } - -} diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/compute/functions/FindLocationForResourceTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/compute/functions/FindLocationForResourceTest.java deleted file mode 100644 index 65534aa087..0000000000 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/compute/functions/FindLocationForResourceTest.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.compute.functions; - -import static org.testng.Assert.assertEquals; - -import java.net.URI; -import java.util.NoSuchElementException; -import java.util.Set; - -import org.jclouds.domain.Location; -import org.jclouds.domain.LocationBuilder; -import org.jclouds.domain.LocationScope; -import org.jclouds.vcloud.domain.internal.ReferenceTypeImpl; -import org.testng.annotations.Test; - -import com.google.common.base.Suppliers; -import com.google.common.collect.ImmutableSet; - -/** - * Tests behavior of {@code FindLocationForResource} - */ -@Test(groups = "unit") -public class FindLocationForResourceTest { - public void testMatchWhenIdIsHref() { - Location location = new LocationBuilder().id("http://foo").description("description") - .scope(LocationScope.PROVIDER).build(); - FindLocationForResource converter = new FindLocationForResource( - Suppliers.> ofInstance(ImmutableSet. of(location))); - assertEquals(converter.apply(new ReferenceTypeImpl("name", "type", URI.create("http://foo"))), location); - } - - @Test(expectedExceptions = NoSuchElementException.class) - public void testGracefulWhenHrefIsntLocationId() { - FindLocationForResource converter = new FindLocationForResource( - Suppliers.> ofInstance(ImmutableSet. of(new LocationBuilder() - .id("http://bar").description("description").scope(LocationScope.PROVIDER).build()))); - converter.apply(new ReferenceTypeImpl("name", "type", URI.create("http://foo"))); - } - - @Test(expectedExceptions = NoSuchElementException.class) - public void testGracefulWhenLocationIdIsntURI() { - FindLocationForResource converter = new FindLocationForResource( - Suppliers.> ofInstance(ImmutableSet. of(new LocationBuilder().id("1") - .description("description").scope(LocationScope.PROVIDER).build()))); - converter.apply(new ReferenceTypeImpl("name", "type", URI.create("http://foo"))); - } -} diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/compute/functions/ListImagesInVCloudExpectTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/compute/functions/ListImagesInVCloudExpectTest.java deleted file mode 100644 index 426de426c8..0000000000 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/compute/functions/ListImagesInVCloudExpectTest.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.compute.functions; - -import static org.testng.Assert.assertEquals; - -import java.net.URI; -import java.util.Set; - -import org.jclouds.cim.OSType; -import org.jclouds.compute.ComputeService; -import org.jclouds.compute.domain.CIMOperatingSystem; -import org.jclouds.compute.domain.Image; -import org.jclouds.compute.domain.ImageBuilder; -import org.jclouds.domain.Location; -import org.jclouds.domain.LocationBuilder; -import org.jclouds.domain.LocationScope; -import org.jclouds.domain.LoginCredentials; -import org.jclouds.http.HttpRequest; -import org.jclouds.http.HttpResponse; -import org.jclouds.location.suppliers.all.JustProvider; -import org.jclouds.vcloud.compute.BaseVCloudComputeServiceExpectTest; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.Iterables; - -@Test(singleThreaded = true, testName = "ListImagesInVCloudExpectTest") -public class ListImagesInVCloudExpectTest extends BaseVCloudComputeServiceExpectTest { - - public void testListImagesUsingVCloud1_0ApiOnServerRunningVCloudDirector1_5ReturnsImageWithLocationForVAppTemplateInVDC() throws Exception { - ComputeService compute = requestsSendResponses(ImmutableMap.builder() - .put(versionsRequest, versionsResponseFromVCD1_5) - .put(version1_0LoginRequest, successfulVersion1_0LoginResponseFromVCD1_5WithSingleOrg) - .put(version1_0GetOrgRequest, successfulVersion1_0GetOrgResponseFromVCD1_5WithSingleTasksListVDCAndNetwork) - .put(version1_0GetCatalogRequest, successfulVersion1_0GetCatalogResponseFromVCD1_5WithSingleTemplate) - .put(version1_0GetCatalogItemRequest, successfulVersion1_0GetCatalogItemResponseFromVCD1_5ForTemplate) - .put(version1_0GetVDCRequest, successfulVersion1_0GetVDCResponseFromVCD1_5WithSingleTemplateAndNetwork) - .put(version1_0GetVAppTemplateRequest, successfulVersion1_0GetVAppTemplateResponseFromVCD1_5WithSingleVMAndVDCParent) - .put(version1_0GetOVFForVAppTemplateRequest, successfulVersion1_0GetOVFForVAppTemplateResponseFromVCD1_5WithSingleVM) - .build()); - - Location provider = Iterables.getOnlyElement(compute.getContext().utils().injector().getInstance(JustProvider.class).get()); - - Location orgLocation = new LocationBuilder().id(ENDPOINT + "/v1.0/org/" + orgId).scope(LocationScope.REGION) - .description("jclouds").parent(provider).build(); - - Location vdcLocation = new LocationBuilder().id(ENDPOINT + "/v1.0/vdc/" + vdcId).scope(LocationScope.ZONE) - .description("orgVDC-jclouds-Tier1-PAYG").parent(orgLocation).build(); - - Set currentImages = compute.listImages(); - assertEquals(compute.listImages().size(), 1); - Image onlyImage = Iterables.get(currentImages, 0); - - - Image expectedImage = new ImageBuilder() - .ids(ENDPOINT + "/v1.0/vAppTemplate/" + templateId) - .uri(URI.create(ENDPOINT + "/v1.0/vAppTemplate/" + templateId)) - .name("UbuntuServer-x64-2GB") - .operatingSystem(new CIMOperatingSystem(OSType.UBUNTU_64, "", null, "Ubuntu Linux (64-bit)")) - // TODO: this looks like a bug, as it says network interfaces - .description("This is a special place-holder used for disconnected network interfaces.") - .defaultCredentials(LoginCredentials.builder().identity("root").build()) - .status(Image.Status.AVAILABLE) - .location(vdcLocation).build(); - - assertEquals(onlyImage, expectedImage); - assertEquals(onlyImage.getStatus(), Image.Status.AVAILABLE); - - } -} diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/compute/functions/VAppToNodeMetadataTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/compute/functions/VAppToNodeMetadataTest.java deleted file mode 100644 index 3e36be28da..0000000000 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/compute/functions/VAppToNodeMetadataTest.java +++ /dev/null @@ -1,226 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.compute.functions; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; - -import java.io.InputStream; -import java.util.Map; -import java.util.NoSuchElementException; -import java.util.Set; - -import javax.inject.Singleton; - -import org.jclouds.cim.xml.ResourceAllocationSettingDataHandler; -import org.jclouds.collect.Memoized; -import org.jclouds.compute.domain.Hardware; -import org.jclouds.compute.domain.NodeMetadata; -import org.jclouds.domain.Credentials; -import org.jclouds.domain.Location; -import org.jclouds.domain.LocationBuilder; -import org.jclouds.domain.LocationScope; -import org.jclouds.http.functions.ParseSax; -import org.jclouds.http.functions.ParseSax.Factory; -import org.jclouds.http.functions.config.SaxParserModule; -import org.jclouds.vcloud.VCloudApiMetadata; -import org.jclouds.vcloud.compute.config.VCloudComputeServiceDependenciesModule; -import org.jclouds.vcloud.domain.ReferenceType; -import org.jclouds.vcloud.domain.Status; -import org.jclouds.vcloud.domain.VApp; -import org.jclouds.vcloud.domain.internal.VAppImpl; -import org.jclouds.vcloud.xml.VAppHandler; -import org.jclouds.vcloud.xml.ovf.VCloudResourceAllocationSettingDataHandler; -import org.testng.annotations.Test; - -import com.google.common.base.Function; -import com.google.common.base.Joiner; -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.common.collect.Maps; -import com.google.inject.AbstractModule; -import com.google.inject.Guice; -import com.google.inject.Injector; -import com.google.inject.Provides; -import com.google.inject.TypeLiteral; -import com.google.inject.name.Names; - -/** - * Tests behavior of {@code VAppToNodeMetadata} - */ -@Test(groups = "unit") -public class VAppToNodeMetadataTest { - - public Injector createInjectorWithLocation(final Location location) { - return Guice.createInjector(new SaxParserModule(), new AbstractModule() { - - @Override - protected void configure() { - Names.bindProperties(binder(), new VCloudApiMetadata().getDefaultProperties()); - bind(new TypeLiteral>() { - }).to(new TypeLiteral() { - }); - bind(new TypeLiteral>() { - }).to(new TypeLiteral() { - }); - bind(ResourceAllocationSettingDataHandler.class).to(VCloudResourceAllocationSettingDataHandler.class); - } - - @Memoized - @Singleton - @Provides - Supplier> supplyLocations() { - return Suppliers.> ofInstance(ImmutableSet. of(location)); - } - - @Singleton - @Provides - Map supplyCreds() { - return Maps.newConcurrentMap(); - } - - @Singleton - @Provides - protected Map provideVAppStatusToNodeStatus() { - return VCloudComputeServiceDependenciesModule.toPortableNodeStatus; - } - - }); - } - - public void testWhenVDCIsLocation() { - Location location = new LocationBuilder().id("https://1.1.1.1/api/v1.0/vdc/1").description("description") - .scope(LocationScope.PROVIDER).build(); - Injector injector = createInjectorWithLocation(location); - InputStream is = getClass().getResourceAsStream("/vapp-pool.xml"); - Factory factory = injector.getInstance(ParseSax.Factory.class); - VApp result = factory.create(injector.getInstance(VAppHandler.class)).parse(is); - VAppToNodeMetadata converter = injector.getInstance(VAppToNodeMetadata.class); - NodeMetadata node = converter.apply(result); - assertNotNull(node); - assertEquals(node.getUserMetadata(), ImmutableMap.of()); - assertEquals(node.getTags(), ImmutableSet.of()); - assertEquals(node.getLocation(), location); - assertEquals(node.getPrivateAddresses(), ImmutableSet.of("172.16.7.230")); - assertEquals(node.getPublicAddresses(), ImmutableSet.of()); - } - - public void testWithMetadataParseException() { - Location location = new LocationBuilder().id("https://1.1.1.1/api/v1.0/vdc/1").description("description") - .scope(LocationScope.PROVIDER).build(); - Injector injector = createInjectorWithLocation(location); - InputStream is = getClass().getResourceAsStream("/vapp-pool.xml"); - Factory factory = injector.getInstance(ParseSax.Factory.class); - VApp result = factory.create(injector.getInstance(VAppHandler.class)).parse(is); - VAppToNodeMetadata converter = injector.getInstance(VAppToNodeMetadata.class); - ImmutableMap metadata = ImmutableMap.of(); - ImmutableSet tags = ImmutableSet.of(); - - String description = " user=user_ssoid_1\nuid=3b7bb605-bb30-4e62-a3de-9076b052dee7 label='foo-DEVELOPMENT' date=2013-01-22 17:39:28.252"; - - result = new VAppImpl(result.getName(), result.getType(), result.getHref(), result.getStatus(), result.getVDC(), - description, result.getTasks(), result.isOvfDescriptorUploaded(), result.getChildren(), - result.getNetworkSection()); - - NodeMetadata node = converter.apply(result); - assertNotNull(node); - assertEquals(node.getUserMetadata(), metadata); - assertEquals(node.getTags(), tags); - } - - public void testWithMetadataNoNewLines() { - Location location = new LocationBuilder().id("https://1.1.1.1/api/v1.0/vdc/1").description("description") - .scope(LocationScope.PROVIDER).build(); - Injector injector = createInjectorWithLocation(location); - InputStream is = getClass().getResourceAsStream("/vapp-pool.xml"); - Factory factory = injector.getInstance(ParseSax.Factory.class); - VApp result = factory.create(injector.getInstance(VAppHandler.class)).parse(is); - VAppToNodeMetadata converter = injector.getInstance(VAppToNodeMetadata.class); - ImmutableMap metadata = ImmutableMap.of(); - ImmutableSet tags = ImmutableSet.of(); - - String description = " user=user_ssoid_1 uid=3b7bb605-bb30-4e62-a3de-9076b052dee7 label='foo-DEVELOPMENT' date=2013-01-22 17:39:28.252"; - - result = new VAppImpl(result.getName(), result.getType(), result.getHref(), result.getStatus(), result.getVDC(), - description, result.getTasks(), result.isOvfDescriptorUploaded(), result.getChildren(), - result.getNetworkSection()); - - NodeMetadata node = converter.apply(result); - assertNotNull(node); - assertEquals(node.getUserMetadata(), metadata); - assertEquals(node.getTags(), tags); - } - - public void testWithEncodedMetadata() { - Location location = new LocationBuilder().id("https://1.1.1.1/api/v1.0/vdc/1").description("description") - .scope(LocationScope.PROVIDER).build(); - Injector injector = createInjectorWithLocation(location); - InputStream is = getClass().getResourceAsStream("/vapp-pool.xml"); - Factory factory = injector.getInstance(ParseSax.Factory.class); - VApp result = factory.create(injector.getInstance(VAppHandler.class)).parse(is); - VAppToNodeMetadata converter = injector.getInstance(VAppToNodeMetadata.class); - ImmutableMap metadata = ImmutableMap.of("foo", "bar"); - ImmutableSet tags = ImmutableSet.of("tag1", "tag2"); - - String description = Joiner - .on('\n') - .withKeyValueSeparator("=") - .join(ImmutableMap. builder().putAll(metadata) - .put("jclouds_tags", Joiner.on(',').join(tags)).build()); - - result = new VAppImpl(result.getName(), result.getType(), result.getHref(), result.getStatus(), result.getVDC(), - description, result.getTasks(), result.isOvfDescriptorUploaded(), result.getChildren(), - result.getNetworkSection()); - - NodeMetadata node = converter.apply(result); - assertNotNull(node); - assertEquals(node.getUserMetadata(), metadata); - assertEquals(node.getTags(), tags); - - } - - public void testGracefulWhenNoIPs() { - Location location = new LocationBuilder().id("https://1.1.1.1/api/v1.0/vdc/1").description("description") - .scope(LocationScope.PROVIDER).build(); - Injector injector = createInjectorWithLocation(location); - InputStream is = getClass().getResourceAsStream("/vapp-none.xml"); - Factory factory = injector.getInstance(ParseSax.Factory.class); - VApp result = factory.create(injector.getInstance(VAppHandler.class)).parse(is); - VAppToNodeMetadata converter = injector.getInstance(VAppToNodeMetadata.class); - NodeMetadata node = converter.apply(result); - assertNotNull(node); - assertEquals(node.getLocation(), location); - assertEquals(node.getPrivateAddresses(), ImmutableSet.of()); - assertEquals(node.getPublicAddresses(), ImmutableSet.of()); - } - - @Test(expectedExceptions = NoSuchElementException.class) - public void testGracefulWhenVDCIsNotLocation() { - Location location = new LocationBuilder().id("https://1.1.1.1/api/v1.0/vdc/11111").description("description") - .scope(LocationScope.PROVIDER).build(); - Injector injector = createInjectorWithLocation(location); - InputStream is = getClass().getResourceAsStream("/vapp-pool.xml"); - Factory factory = injector.getInstance(ParseSax.Factory.class); - VApp result = factory.create(injector.getInstance(VAppHandler.class)).parse(is); - VAppToNodeMetadata converter = injector.getInstance(VAppToNodeMetadata.class); - NodeMetadata node = converter.apply(result); - assertNotNull(node); - assertEquals(node.getLocation(), location); - } -} diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/compute/options/VCloudTemplateOptionsTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/compute/options/VCloudTemplateOptionsTest.java deleted file mode 100644 index 4677835b07..0000000000 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/compute/options/VCloudTemplateOptionsTest.java +++ /dev/null @@ -1,195 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.compute.options; - -import static org.jclouds.vcloud.compute.options.VCloudTemplateOptions.Builder.blockOnPort; -import static org.jclouds.vcloud.compute.options.VCloudTemplateOptions.Builder.customizationScript; -import static org.jclouds.vcloud.compute.options.VCloudTemplateOptions.Builder.description; -import static org.jclouds.vcloud.compute.options.VCloudTemplateOptions.Builder.inboundPorts; -import static org.jclouds.vcloud.compute.options.VCloudTemplateOptions.Builder.ipAddressAllocationMode; -import static org.jclouds.vcloud.compute.options.VCloudTemplateOptions.Builder.parentNetwork; -import static org.testng.Assert.assertEquals; - -import java.io.IOException; -import java.net.URI; - -import org.jclouds.compute.options.TemplateOptions; -import org.jclouds.vcloud.domain.network.IpAddressAllocationMode; -import org.testng.annotations.Test; - -/** - * Tests possible uses of VCloudTemplateOptions and - * VCloudTemplateOptions.Builder.* - */ -public class VCloudTemplateOptionsTest { - @Test - public void testipAddressAllocationMode() { - VCloudTemplateOptions options = new VCloudTemplateOptions(); - options.ipAddressAllocationMode(IpAddressAllocationMode.NONE); - assertEquals(options.getIpAddressAllocationMode(), IpAddressAllocationMode.NONE); - } - - @Test - public void testipAddressAllocationModeStatic() { - VCloudTemplateOptions options = ipAddressAllocationMode(IpAddressAllocationMode.NONE); - assertEquals(options.getIpAddressAllocationMode(), IpAddressAllocationMode.NONE); - } - - public void testAs() { - TemplateOptions options = new VCloudTemplateOptions(); - assertEquals(options.as(VCloudTemplateOptions.class), options); - } - - @Test(expectedExceptions = NullPointerException.class, expectedExceptionsMessageRegExp = "customizationScript must be defined") - public void testcustomizationScriptBadFormat() { - VCloudTemplateOptions options = new VCloudTemplateOptions(); - options.customizationScript(""); - } - - @Test - public void testcustomizationScript() { - VCloudTemplateOptions options = new VCloudTemplateOptions(); - options.customizationScript("mykeypair"); - assertEquals(options.getCustomizationScript(), "mykeypair"); - } - - @Test - public void testcustomizationScriptStatic() { - VCloudTemplateOptions options = customizationScript("mykeypair"); - assertEquals(options.getCustomizationScript(), "mykeypair"); - } - - @Test - public void testNullparentNetwork() { - VCloudTemplateOptions options = new VCloudTemplateOptions(); - assertEquals(options.getParentNetwork(), null); - } - - @Test - public void testparentNetwork() { - VCloudTemplateOptions options = new VCloudTemplateOptions(); - options.parentNetwork(URI.create("https://network")); - assertEquals(options.getParentNetwork(), URI.create("https://network")); - } - - @Test - public void testparentNetworkStatic() { - VCloudTemplateOptions options = parentNetwork(URI.create("https://network")); - assertEquals(options.getParentNetwork(), URI.create("https://network")); - } - - @Test - public void testdescription() { - VCloudTemplateOptions options = new VCloudTemplateOptions(); - options.description("mykeypair"); - assertEquals(options.getDescription(), "mykeypair"); - } - - @Test - public void testdescriptionStatic() { - VCloudTemplateOptions options = description("mykeypair"); - assertEquals(options.getDescription(), "mykeypair"); - } - - @Test(expectedExceptions = NullPointerException.class, expectedExceptionsMessageRegExp = "customizationScript must be defined") - public void testcustomizationScriptNPE() { - customizationScript(null); - } - - @Test - public void testinstallPrivateKey() throws IOException { - VCloudTemplateOptions options = new VCloudTemplateOptions(); - options.installPrivateKey("-----BEGIN RSA PRIVATE KEY-----"); - assertEquals(options.getPrivateKey(), "-----BEGIN RSA PRIVATE KEY-----"); - } - - @Test - public void testNullinstallPrivateKey() { - VCloudTemplateOptions options = new VCloudTemplateOptions(); - assertEquals(options.getPrivateKey(), null); - } - - @Test - public void testauthorizePublicKey() throws IOException { - VCloudTemplateOptions options = new VCloudTemplateOptions(); - options.authorizePublicKey("ssh-rsa"); - assertEquals(options.getPublicKey(), "ssh-rsa"); - } - - @Test - public void testNullauthorizePublicKey() { - VCloudTemplateOptions options = new VCloudTemplateOptions(); - assertEquals(options.getPublicKey(), null); - } - - @Test(expectedExceptions = IllegalArgumentException.class) - public void testblockOnPortBadFormat() { - VCloudTemplateOptions options = new VCloudTemplateOptions(); - options.blockOnPort(-1, -1); - } - - @Test - public void testblockOnPort() { - VCloudTemplateOptions options = new VCloudTemplateOptions(); - options.blockOnPort(22, 30); - assertEquals(options.getPort(), 22); - assertEquals(options.getSeconds(), 30); - - } - - @Test - public void testNullblockOnPort() { - VCloudTemplateOptions options = new VCloudTemplateOptions(); - assertEquals(options.getPort(), -1); - assertEquals(options.getSeconds(), -1); - } - - @Test - public void testblockOnPortStatic() { - VCloudTemplateOptions options = blockOnPort(22, 30); - assertEquals(options.getPort(), 22); - assertEquals(options.getSeconds(), 30); - } - - @Test(expectedExceptions = IllegalArgumentException.class) - public void testinboundPortsBadFormat() { - VCloudTemplateOptions options = new VCloudTemplateOptions(); - options.inboundPorts(-1, -1); - } - - @Test - public void testinboundPorts() { - VCloudTemplateOptions options = new VCloudTemplateOptions(); - options.inboundPorts(22, 30); - assertEquals(options.getInboundPorts()[0], 22); - assertEquals(options.getInboundPorts()[1], 30); - - } - - @Test - public void testDefaultOpen22() { - VCloudTemplateOptions options = new VCloudTemplateOptions(); - assertEquals(options.getInboundPorts()[0], 22); - } - - @Test - public void testinboundPortsStatic() { - VCloudTemplateOptions options = inboundPorts(22, 30); - assertEquals(options.getInboundPorts()[0], 22); - assertEquals(options.getInboundPorts()[1], 30); - } -} diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/compute/strategy/InstantiateVAppTemplateWithGroupEncodedIntoNameThenCustomizeDeployAndPowerOnExpectTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/compute/strategy/InstantiateVAppTemplateWithGroupEncodedIntoNameThenCustomizeDeployAndPowerOnExpectTest.java deleted file mode 100644 index 9f05f7401d..0000000000 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/compute/strategy/InstantiateVAppTemplateWithGroupEncodedIntoNameThenCustomizeDeployAndPowerOnExpectTest.java +++ /dev/null @@ -1,167 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.compute.strategy; - -import static org.testng.Assert.assertEquals; - -import java.net.URI; -import java.util.Properties; - -import org.jclouds.compute.ComputeService; -import org.jclouds.compute.ComputeServiceAdapter.NodeAndInitialCredentials; -import org.jclouds.compute.domain.Template; -import org.jclouds.domain.LoginCredentials; -import org.jclouds.http.HttpRequest; -import org.jclouds.http.HttpResponse; -import org.jclouds.vcloud.compute.BaseVCloudComputeServiceExpectTest; -import org.jclouds.vcloud.compute.options.VCloudTemplateOptions; -import org.jclouds.vcloud.domain.VApp; -import org.jclouds.vcloud.domain.network.FenceMode; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableMap; -import com.google.common.net.HttpHeaders; -import com.jamesmurty.utils.XMLBuilder; - -@Test(singleThreaded = true, testName = "InstantiateVAppTemplateWithGroupEncodedIntoNameThenCustomizeDeployAndPowerOnExpectTest") -public class InstantiateVAppTemplateWithGroupEncodedIntoNameThenCustomizeDeployAndPowerOnExpectTest extends - BaseVCloudComputeServiceExpectTest { - - String ns = "http://www.vmware.com/vcloud/v1"; - Properties outputProperties; - public InstantiateVAppTemplateWithGroupEncodedIntoNameThenCustomizeDeployAndPowerOnExpectTest() { - outputProperties = new Properties(); - outputProperties.put(javax.xml.transform.OutputKeys.OMIT_XML_DECLARATION, "yes"); - } - - HttpResponse successfulVersion1_0InstantiatedVApp = HttpResponse.builder() - .statusCode(200) - .message("HTTP/1.1 200 OK") - .payload(payloadFromResourceWithContentType("/instantiatedvapp.xml", "application/vnd.vmware.vcloud.vApp+xml")).build(); - - // TODO: finish me! - @Test(enabled = false) - public void testCreateNodeUsingVCloud1_0ApiAgainstVCloudDirector1_5WhenVAppTemplateHasNetworkNamedNone() - throws Exception { - - String group = "group"; - String name = "group-abcd"; - - String instantiateXML = XMLBuilder.create("InstantiateVAppTemplateParams") - .a("xmlns", ns).a("xmlns:ovf", "http://schemas.dmtf.org/ovf/envelope/1") - .a("deploy", "false").a("name", name).a("powerOn", "false") - .e("Description").up() - .e("InstantiationParams") - .e("NetworkConfigSection") - .e("ovf:Info").t("Configuration parameters for logical networks").up() - .e("NetworkConfig").a("networkName", "orgNet-jclouds-External") // NOTE not "None" - .e("Configuration") - .e("ParentNetwork").a("href", ENDPOINT + "/v1.0/network/" + networkId).up() - .e("FenceMode").t("bridged").up() - .up() - .up() - .up() - .up() - .e("Source").a("href", ENDPOINT + "/v1.0/vAppTemplate/" + templateId).up() - .e("AllEULAsAccepted").t("true").up() - .asString(outputProperties); - - HttpRequest version1_0InstantiateWithNetworkNamedSameAsOrgNetwork = HttpRequest.builder().method("POST") - .endpoint(ENDPOINT + "/v1.0/vdc/" + vdcId + "/action/instantiateVAppTemplate") - .addHeader(HttpHeaders.ACCEPT, "application/vnd.vmware.vcloud.vApp+xml") - .addHeader("x-vcloud-authorization", sessionToken) - .addHeader(HttpHeaders.COOKIE, "vcloud-token=" + sessionToken) - .payload(payloadFromStringWithContentType(instantiateXML, "application/vnd.vmware.vcloud.instantiateVAppTemplateParams+xml")).build(); - - ComputeService compute = requestsSendResponses(ImmutableMap. builder() - .put(versionsRequest, versionsResponseFromVCD1_5) - .put(version1_0LoginRequest, successfulVersion1_0LoginResponseFromVCD1_5WithSingleOrg) - .put(version1_0GetOrgRequest, successfulVersion1_0GetOrgResponseFromVCD1_5WithSingleTasksListVDCAndNetwork) - .put(version1_0GetCatalogRequest, successfulVersion1_0GetCatalogResponseFromVCD1_5WithSingleTemplate) - .put(version1_0GetCatalogItemRequest, successfulVersion1_0GetCatalogItemResponseFromVCD1_5ForTemplate) - .put(version1_0GetVDCRequest, successfulVersion1_0GetVDCResponseFromVCD1_5WithSingleTemplateAndNetwork) - .put(version1_0GetVAppTemplateRequest, successfulVersion1_0GetVAppTemplateResponseFromVCD1_5WithSingleVMAndVDCParent) - .put(version1_0GetOVFForVAppTemplateRequest, successfulVersion1_0GetOVFForVAppTemplateResponseFromVCD1_5WithSingleVM) - .put(version1_0InstantiateWithNetworkNamedSameAsOrgNetwork, successfulVersion1_0InstantiatedVApp).build()); - - InstantiateVAppTemplateWithGroupEncodedIntoNameThenCustomizeDeployAndPowerOn starter = compute.getContext() - .utils().injector().getInstance( - InstantiateVAppTemplateWithGroupEncodedIntoNameThenCustomizeDeployAndPowerOn.class); - - - NodeAndInitialCredentials appAndCreds = starter.createNodeWithGroupEncodedIntoName(group, name, compute - .templateBuilder().build()); - - assertEquals(appAndCreds.getNode().getName(), name); - assertEquals(appAndCreds.getCredentials(), LoginCredentials.builder().user("root").password("fromVApp").build()); - - } - - public void testInstantiateVAppFromTemplateWhenUsingOverriddenNetworkAndFenceMode() - throws Exception { - - String name = "group-abcd"; - FenceMode fenceMode = FenceMode.NAT_ROUTED; - URI parentNetwork = URI.create(ENDPOINT + "/v1.0/network/" + "foooooooo"); - - String instantiateXML = XMLBuilder.create("InstantiateVAppTemplateParams") - .a("xmlns", ns).a("xmlns:ovf", "http://schemas.dmtf.org/ovf/envelope/1") - .a("deploy", "false").a("name", name).a("powerOn", "false") - .e("Description").up() - .e("InstantiationParams") - .e("NetworkConfigSection") - .e("ovf:Info").t("Configuration parameters for logical networks").up() - .e("NetworkConfig").a("networkName", "jclouds") // NOTE not "None" - .e("Configuration") - .e("ParentNetwork").a("href", parentNetwork.toASCIIString()).up() - .e("FenceMode").t(fenceMode.toString()).up() - .up() - .up() - .up() - .up() - .e("Source").a("href", ENDPOINT + "/v1.0/vAppTemplate/" + templateId).up() - .e("AllEULAsAccepted").t("true").up() - .asString(outputProperties); - - HttpRequest version1_0InstantiateWithCustomizedNetwork = HttpRequest.builder().method("POST") - .endpoint(ENDPOINT + "/v1.0/vdc/" + vdcId + "/action/instantiateVAppTemplate") - .addHeader(HttpHeaders.ACCEPT, "application/vnd.vmware.vcloud.vApp+xml") - .addHeader("x-vcloud-authorization", sessionToken) - .addHeader(HttpHeaders.COOKIE, "vcloud-token=" + sessionToken) - .payload(payloadFromStringWithContentType(instantiateXML, "application/vnd.vmware.vcloud.instantiateVAppTemplateParams+xml")).build(); - - ComputeService compute = requestsSendResponses(ImmutableMap. builder() - .put(versionsRequest, versionsResponseFromVCD1_5) - .put(version1_0LoginRequest, successfulVersion1_0LoginResponseFromVCD1_5WithSingleOrg) - .put(version1_0GetOrgRequest, successfulVersion1_0GetOrgResponseFromVCD1_5WithSingleTasksListVDCAndNetwork) - .put(version1_0GetCatalogRequest, successfulVersion1_0GetCatalogResponseFromVCD1_5WithSingleTemplate) - .put(version1_0GetCatalogItemRequest, successfulVersion1_0GetCatalogItemResponseFromVCD1_5ForTemplate) - .put(version1_0GetVDCRequest, successfulVersion1_0GetVDCResponseFromVCD1_5WithSingleTemplateAndNetwork) - .put(version1_0GetVAppTemplateRequest, successfulVersion1_0GetVAppTemplateResponseFromVCD1_5WithSingleVMAndVDCParent) - .put(version1_0GetOVFForVAppTemplateRequest, successfulVersion1_0GetOVFForVAppTemplateResponseFromVCD1_5WithSingleVM) - .put(version1_0InstantiateWithCustomizedNetwork, successfulVersion1_0InstantiatedVApp).build()); - - InstantiateVAppTemplateWithGroupEncodedIntoNameThenCustomizeDeployAndPowerOn starter = compute.getContext() - .utils().injector().getInstance( - InstantiateVAppTemplateWithGroupEncodedIntoNameThenCustomizeDeployAndPowerOn.class); - - Template template = compute.templateBuilder().build(); - template.getOptions().as(VCloudTemplateOptions.class).parentNetwork(parentNetwork).fenceMode(fenceMode); - starter.instantiateVAppFromTemplate(name, template); - - } -} diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/compute/strategy/VCloudComputeServiceAdapterTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/compute/strategy/VCloudComputeServiceAdapterTest.java deleted file mode 100644 index 232b1513e6..0000000000 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/compute/strategy/VCloudComputeServiceAdapterTest.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.compute.strategy; - -import static org.testng.Assert.assertEquals; - -import java.net.URI; - -import org.jclouds.compute.ComputeService; -import org.jclouds.http.HttpRequest; -import org.jclouds.http.HttpResponse; -import org.jclouds.vcloud.compute.BaseVCloudComputeServiceExpectTest; -import org.jclouds.vcloud.domain.VAppTemplate; -import org.testng.annotations.Test; - -import com.google.common.base.Function; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Iterables; - -public class VCloudComputeServiceAdapterTest extends BaseVCloudComputeServiceExpectTest { - - @Test - public void testListHardwareProfiles() throws Exception { - ComputeService compute = requestsSendResponses(ImmutableMap. builder() - .put(versionsRequest, versionsResponseFromVCD1_5) - .put(version1_0LoginRequest, successfulVersion1_0LoginResponseFromVCD1_5WithSingleOrg) - .put(version1_0GetOrgRequest, successfulVersion1_0GetOrgResponseFromVCD1_5WithSingleTasksListVDCAndNetwork) - .put(version1_0GetCatalogRequest, successfulVersion1_0GetCatalogResponseFromVCD1_5WithSingleTemplate) - .put(version1_0GetCatalogItemRequest, successfulVersion1_0GetCatalogItemResponseFromVCD1_5ForTemplate) - .put(version1_0GetVDCRequest, successfulVersion1_0GetVDCResponseFromVCD1_5WithSingleTemplateAndNetwork) - .put(version1_0GetVAppTemplateRequest, successfulVersion1_0GetVAppTemplateResponseFromVCD1_5WithSingleVMAndVDCParent) - .put(version1_0GetOVFForVAppTemplateRequest, successfulVersion1_0GetOVFForVAppTemplateResponseFromVCD1_5WithSingleVM) - .build()); - - VCloudComputeServiceAdapter adapter = compute.getContext() - .utils().injector().getInstance(VCloudComputeServiceAdapter.class); - - Iterable hardwareProfiles = adapter.listHardwareProfiles(); - - Iterable hardwareProfileRefs = Iterables.transform(ImmutableList.copyOf(hardwareProfiles), new Function() { - @Override public URI apply(VAppTemplate input) { - return input.getHref(); - } - }); - assertEquals(ImmutableSet.copyOf(hardwareProfileRefs), ImmutableSet.of(URI.create("https://zone.myvcloud.com/api/v1.0/vAppTemplate/vappTemplate-51891b97-c5dd-47dc-a687-aabae354f728"))); - } - - /** - * For issue 994. In BaseEnvelopeHandler when it encounters VirtualSystemCollection, it throws IllegalArgumentException - * (cannot currently create envelopes with multiple virtual systems). - * Thus we do not include the VM in the supported set, but we do return without propagating the exception. - */ - @Test - public void testListHardwareProfilesWithUnsupportedTemplate() throws Exception { - ComputeService compute = requestsSendResponses(ImmutableMap. builder() - .put(versionsRequest, versionsResponseFromVCD1_5) - .put(version1_0LoginRequest, successfulVersion1_0LoginResponseFromVCD1_5WithSingleOrg) - .put(version1_0GetOrgRequest, successfulVersion1_0GetOrgResponseFromVCD1_5WithSingleTasksListVDCAndNetwork) - .put(version1_0GetCatalogRequest, successfulVersion1_0GetCatalogResponseFromVCD1_5WithSingleTemplate) - .put(version1_0GetCatalogItemRequest, successfulVersion1_0GetCatalogItemResponseFromVCD1_5ForTemplate) - .put(version1_0GetVDCRequest, successfulVersion1_0GetVDCResponseFromVCD1_5WithSingleTemplateAndNetwork) - .put(version1_0GetVAppTemplateRequest, successfulVersion1_0GetVAppTemplateResponseFromVCD1_5WithMultipleVMsAndVDCParent) - .put(version1_0GetOVFForVAppTemplateRequest, successfulVersion1_0GetOVFForVAppTemplateResponseFromVCD1_5WithMultipleVMs) - .build()); - - VCloudComputeServiceAdapter adapter = compute.getContext() - .utils().injector().getInstance(VCloudComputeServiceAdapter.class); - - Iterable hardwareProfiles = adapter.listHardwareProfiles(); - - assertEquals(ImmutableSet.copyOf(hardwareProfiles), ImmutableSet.of()); - } -} diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/features/CatalogApiLiveTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/features/CatalogApiLiveTest.java deleted file mode 100644 index a787afb318..0000000000 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/features/CatalogApiLiveTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.features; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertTrue; - -import org.jclouds.rest.annotations.ApiVersion; -import org.jclouds.vcloud.VCloudMediaType; -import org.jclouds.vcloud.domain.Org; -import org.jclouds.vcloud.domain.ReferenceType; -import org.jclouds.vcloud.internal.BaseVCloudApiLiveTest; -import org.testng.annotations.Test; - -import com.google.inject.Key; - -@Test(groups = "live", enabled = true, singleThreaded = true, testName = "CatalogApiLiveTest") -public class CatalogApiLiveTest extends BaseVCloudApiLiveTest { - @Test - public void testGetCatalog() throws Exception { - Org org = getVCloudApi().getOrgApi().findOrgNamed(null); - for (ReferenceType catalog : org.getCatalogs().values()) { - assertEquals(catalog.getType(), VCloudMediaType.CATALOG_XML); - assertNotNull(getVCloudApi().getCatalogApi().getCatalog(catalog.getHref())); - } - } - - @Test - public void testFindCatalogIsWriteableIfNotVersion1_5() throws Exception { - // when we are in vCloud 1.0.0 public catalogs don't work, so our default - // catalog is private - if (!view.utils().injector().getInstance(Key.get(String.class, ApiVersion.class)).startsWith("1.5")) - assertTrue(getVCloudApi().getCatalogApi().findCatalogInOrgNamed(null, null).isReadOnly()); - } -} diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/features/CatalogApiTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/features/CatalogApiTest.java deleted file mode 100644 index c5094d54d7..0000000000 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/features/CatalogApiTest.java +++ /dev/null @@ -1,129 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.features; - -import static org.jclouds.reflect.Reflection2.method; - -import java.io.IOException; -import java.net.URI; - -import org.jclouds.Fallbacks.NullOnNotFoundOr404; -import org.jclouds.http.functions.ParseSax; -import org.jclouds.rest.internal.GeneratedHttpRequest; -import org.jclouds.vcloud.internal.BaseVCloudApiTest; -import org.jclouds.vcloud.options.CatalogItemOptions; -import org.jclouds.vcloud.xml.CatalogHandler; -import org.jclouds.vcloud.xml.CatalogItemHandler; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableList; -import com.google.common.reflect.Invokable; -/** - * Tests behavior of {@code CatalogApi} - */ -// NOTE:without testName, this will not call @Before* and fail w/NPE during -// surefire -@Test(groups = "unit", testName = "CatalogApiTest") -public class CatalogApiTest extends BaseVCloudApiTest { - - public void testCatalog() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(CatalogApi.class, "getCatalog", URI.class); - GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI - .create("https://vcenterprise.bluelock.com/api/v1.0/catalog/1"))); - - assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/catalog/1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.catalog+xml\n"); - assertPayloadEquals(request, null, null, false); - - assertResponseParserClassEquals(method, request, ParseSax.class); - assertSaxResponseParserClassEquals(method, CatalogHandler.class); - assertFallbackClassEquals(method, NullOnNotFoundOr404.class); - - checkFilters(request); - } - - public void testCatalogInOrg() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(CatalogApi.class, "findCatalogInOrgNamed", String.class, String.class); - GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("org", "catalog")); - - assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/catalog/1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.catalog+xml\n"); - assertPayloadEquals(request, null, null, false); - - assertResponseParserClassEquals(method, request, ParseSax.class); - assertSaxResponseParserClassEquals(method, CatalogHandler.class); - assertFallbackClassEquals(method, NullOnNotFoundOr404.class); - - checkFilters(request); - } - - public void testCatalogItemURI() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(CatalogApi.class, "getCatalogItem", URI.class); - GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI - .create("https://vcenterprise.bluelock.com/api/v1.0/catalogItem/2"))); - - assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/catalogItem/2 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.catalogItem+xml\n"); - assertPayloadEquals(request, null, null, false); - - assertResponseParserClassEquals(method, request, ParseSax.class); - assertSaxResponseParserClassEquals(method, CatalogItemHandler.class); - assertFallbackClassEquals(method, NullOnNotFoundOr404.class); - - checkFilters(request); - } - - public void testFindCatalogItemInOrgCatalogNamed() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(CatalogApi.class, "findCatalogItemInOrgCatalogNamed", String.class, - String.class, String.class); - GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("org", "catalog", "item")); - - assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/catalogItem/1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.catalogItem+xml\n"); - assertPayloadEquals(request, null, null, false); - - assertResponseParserClassEquals(method, request, ParseSax.class); - assertSaxResponseParserClassEquals(method, CatalogItemHandler.class); - assertFallbackClassEquals(method, NullOnNotFoundOr404.class); - - checkFilters(request); - } - - public void testAddVAppTemplateOrMediaImageToCatalogAndNameItem() throws SecurityException, NoSuchMethodException, - IOException { - Invokable method = method(CatalogApi.class, "addVAppTemplateOrMediaImageToCatalogAndNameItem", URI.class, - URI.class, String.class, CatalogItemOptions[].class); - GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI.create("http://fooentity"), URI - .create("https://vcenterprise.bluelock.com/api/v1.0/catalog/1"), "myname", CatalogItemOptions.Builder - .description("mydescription"))); - - assertRequestLineEquals(request, - "POST https://vcenterprise.bluelock.com/api/v1.0/catalog/1/catalogItems HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.catalogItem+xml\n"); - assertPayloadEquals( - request, - "mydescription", - "application/vnd.vmware.vcloud.catalogItem+xml", false); - - assertResponseParserClassEquals(method, request, ParseSax.class); - assertSaxResponseParserClassEquals(method, CatalogItemHandler.class); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - -} diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/features/NetworkApiLiveTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/features/NetworkApiLiveTest.java deleted file mode 100644 index b7d7102b16..0000000000 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/features/NetworkApiLiveTest.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.features; - -import org.jclouds.vcloud.internal.BaseVCloudApiLiveTest; -import org.testng.annotations.Test; - -@Test(groups = "live", enabled = true, singleThreaded = true, testName = "NetworkApiLiveTest") -public class NetworkApiLiveTest extends BaseVCloudApiLiveTest { - - -} diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/features/NetworkApiTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/features/NetworkApiTest.java deleted file mode 100644 index d6ce45261f..0000000000 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/features/NetworkApiTest.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.features; - -import static org.jclouds.reflect.Reflection2.method; - -import java.io.IOException; -import java.net.URI; - -import org.jclouds.Fallbacks.NullOnNotFoundOr404; -import org.jclouds.http.functions.ParseSax; -import org.jclouds.rest.internal.GeneratedHttpRequest; -import org.jclouds.vcloud.internal.BaseVCloudApiTest; -import org.jclouds.vcloud.xml.OrgNetworkHandler; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableList; -import com.google.common.reflect.Invokable; -/** - * Tests behavior of {@code NetworkApi} - */ -// NOTE:without testName, this will not call @Before* and fail w/NPE during -// surefire -@Test(groups = "unit", testName = "NetworkApiTest") -public class NetworkApiTest extends BaseVCloudApiTest { - - public void testNetwork() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(NetworkApi.class, "getNetwork", URI.class); - GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI - .create("https://vcenterprise.bluelock.com/api/v1.0/network/2"))); - - assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/network/2 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.network+xml\n"); - assertPayloadEquals(request, null, null, false); - - assertResponseParserClassEquals(method, request, ParseSax.class); - assertSaxResponseParserClassEquals(method, OrgNetworkHandler.class); - assertFallbackClassEquals(method, NullOnNotFoundOr404.class); - - checkFilters(request); - } - - public void testFindNetworkInOrgVDCNamed() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(NetworkApi.class, "findNetworkInOrgVDCNamed", String.class, String.class, - String.class); - GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("org", "vdc", "network")); - - assertRequestLineEquals(request, "GET https://vcloud.safesecureweb.com/network/1990 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.network+xml\n"); - assertPayloadEquals(request, null, null, false); - - assertResponseParserClassEquals(method, request, ParseSax.class); - assertSaxResponseParserClassEquals(method, OrgNetworkHandler.class); - assertFallbackClassEquals(method, NullOnNotFoundOr404.class); - - checkFilters(request); - } - -} diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/features/OrgApiLiveTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/features/OrgApiLiveTest.java deleted file mode 100644 index d1c8528653..0000000000 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/features/OrgApiLiveTest.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.features; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; - -import org.jclouds.vcloud.domain.ReferenceType; -import org.jclouds.vcloud.internal.BaseVCloudApiLiveTest; -import org.testng.annotations.Test; - -@Test(groups = "live", enabled = true, singleThreaded = true, testName = "OrgApiLiveTest") -public class OrgApiLiveTest extends BaseVCloudApiLiveTest { - - @Test - public void testListOrgs() throws Exception { - for (ReferenceType response : getVCloudApi().getOrgApi().listOrgs().values()) { - assertNotNull(response); - assertNotNull(response.getName()); - assertNotNull(response.getHref()); - assertEquals(getVCloudApi().getOrgApi().getOrg(response.getHref()).getName(), response.getName()); - assertEquals(getVCloudApi().getOrgApi().findOrgNamed(response.getName()).getName(), response.getName()); - } - } -} diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/features/OrgApiTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/features/OrgApiTest.java deleted file mode 100644 index 1080dde52d..0000000000 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/features/OrgApiTest.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.features; - -import static org.jclouds.reflect.Reflection2.method; - -import java.io.IOException; -import java.net.URI; - -import org.jclouds.Fallbacks.NullOnNotFoundOr404; -import org.jclouds.fallbacks.MapHttp4xxCodesToExceptions; -import org.jclouds.http.functions.ParseSax; -import org.jclouds.rest.internal.GeneratedHttpRequest; -import org.jclouds.vcloud.internal.BaseVCloudApiTest; -import org.jclouds.vcloud.xml.OrgHandler; -import org.jclouds.vcloud.xml.OrgListHandler; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableList; -import com.google.common.reflect.Invokable; -/** - * Tests behavior of {@code OrgApi} - */ -// NOTE:without testName, this will not call @Before* and fail w/NPE during -// surefire -@Test(groups = "unit", testName = "OrgApiTest") -public class OrgApiTest extends BaseVCloudApiTest { - - public void testlistOrgs() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(OrgApi.class, "listOrgs"); - GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.of()); - - assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/org HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.orgList+xml\n"); - assertPayloadEquals(request, null, null, false); - - assertResponseParserClassEquals(method, request, ParseSax.class); - assertSaxResponseParserClassEquals(method, OrgListHandler.class); - assertFallbackClassEquals(method, MapHttp4xxCodesToExceptions.class); - - checkFilters(request); - } - - public void testOrg() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(OrgApi.class, "getOrg", URI.class); - GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI - .create("https://vcenterprise.bluelock.com/api/v1.0/org/1"))); - - assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/org/1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.org+xml\n"); - assertPayloadEquals(request, null, null, false); - - assertResponseParserClassEquals(method, request, ParseSax.class); - assertSaxResponseParserClassEquals(method, OrgHandler.class); - assertFallbackClassEquals(method, NullOnNotFoundOr404.class); - - checkFilters(request); - } - - public void testFindOrgNamed() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(OrgApi.class, "findOrgNamed", String.class); - GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("org")); - - assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/org/1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.org+xml\n"); - assertPayloadEquals(request, null, null, false); - - assertResponseParserClassEquals(method, request, ParseSax.class); - assertSaxResponseParserClassEquals(method, OrgHandler.class); - assertFallbackClassEquals(method, NullOnNotFoundOr404.class); - - checkFilters(request); - } - -} diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/features/TaskApiLiveTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/features/TaskApiLiveTest.java deleted file mode 100644 index 5be4bf43de..0000000000 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/features/TaskApiLiveTest.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.features; - -import org.jclouds.vcloud.internal.BaseVCloudApiLiveTest; -import org.testng.annotations.Test; - -@Test(groups = "live", enabled = true, singleThreaded = true, testName = "TaskApiLiveTest") -public class TaskApiLiveTest extends BaseVCloudApiLiveTest { - - -} diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/features/TaskApiTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/features/TaskApiTest.java deleted file mode 100644 index 75518f0631..0000000000 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/features/TaskApiTest.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.features; - -import static org.jclouds.reflect.Reflection2.method; - -import java.io.IOException; -import java.net.URI; - -import org.jclouds.Fallbacks.NullOnNotFoundOr404; -import org.jclouds.http.functions.ParseSax; -import org.jclouds.http.functions.ReleasePayloadAndReturn; -import org.jclouds.rest.internal.GeneratedHttpRequest; -import org.jclouds.vcloud.internal.BaseVCloudApiTest; -import org.jclouds.vcloud.xml.TaskHandler; -import org.jclouds.vcloud.xml.TasksListHandler; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableList; -import com.google.common.reflect.Invokable; -/** - * Tests behavior of {@code TaskApi} - */ -// NOTE:without testName, this will not call @Before* and fail w/NPE during -// surefire -@Test(groups = "unit", testName = "TaskApiTest") -public class TaskApiTest extends BaseVCloudApiTest { - - public void testGetTasksList() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(TaskApi.class, "getTasksList", URI.class); - GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI - .create("https://vcenterprise.bluelock.com/api/v1.0/tasksList/1"))); - - assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/tasksList/1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.tasksList+xml\n"); - assertPayloadEquals(request, null, null, false); - - assertResponseParserClassEquals(method, request, ParseSax.class); - assertSaxResponseParserClassEquals(method, TasksListHandler.class); - assertFallbackClassEquals(method, NullOnNotFoundOr404.class); - - checkFilters(request); - } - - public void testFindTasksListInOrgNamed() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(TaskApi.class, "findTasksListInOrgNamed", String.class); - GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("org")); - - assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/tasksList/1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.tasksList+xml\n"); - assertPayloadEquals(request, null, null, false); - - assertResponseParserClassEquals(method, request, ParseSax.class); - assertSaxResponseParserClassEquals(method, TasksListHandler.class); - assertFallbackClassEquals(method, NullOnNotFoundOr404.class); - - checkFilters(request); - } - - public void testGetTask() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(TaskApi.class, "getTask", URI.class); - GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI - .create("https://vcenterprise.bluelock.com/api/v1.0/task/1"))); - - assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/task/1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n"); - assertPayloadEquals(request, null, null, false); - - assertResponseParserClassEquals(method, request, ParseSax.class); - assertSaxResponseParserClassEquals(method, TaskHandler.class); - assertFallbackClassEquals(method, NullOnNotFoundOr404.class); - - checkFilters(request); - } - - public void testCancelTask() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(TaskApi.class, "cancelTask", URI.class); - GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI - .create("https://vcenterprise.bluelock.com/api/v1.0/task/1"))); - - assertRequestLineEquals(request, "POST https://vcenterprise.bluelock.com/api/v1.0/task/1/action/cancel 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/apis/vcloud/src/test/java/org/jclouds/vcloud/features/VAppApiLiveTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/features/VAppApiLiveTest.java deleted file mode 100644 index cf4aca3836..0000000000 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/features/VAppApiLiveTest.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.features; - -import static org.testng.Assert.assertNotNull; - -import org.jclouds.vcloud.VCloudMediaType; -import org.jclouds.vcloud.domain.Org; -import org.jclouds.vcloud.domain.ReferenceType; -import org.jclouds.vcloud.domain.VApp; -import org.jclouds.vcloud.domain.VDC; -import org.jclouds.vcloud.internal.BaseVCloudApiLiveTest; -import org.testng.annotations.Test; - -@Test(groups = "live", enabled = true, singleThreaded = true, testName = "VAppApiLiveTest") -public class VAppApiLiveTest extends BaseVCloudApiLiveTest { - - @Test - public void testGetVApp() throws Exception { - Org org = getVCloudApi().getOrgApi().findOrgNamed(null); - for (ReferenceType vdc : org.getVDCs().values()) { - VDC response = getVCloudApi().getVDCApi().getVDC(vdc.getHref()); - for (ReferenceType item : response.getResourceEntities().values()) { - if (item.getType().equals(VCloudMediaType.VAPP_XML)) { - try { - VApp app = getVCloudApi().getVAppApi().getVApp(item.getHref()); - assertNotNull(app); - } catch (RuntimeException e) { - - } - } - } - } - } -} diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/features/VAppApiTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/features/VAppApiTest.java deleted file mode 100644 index 73ca9a1cc2..0000000000 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/features/VAppApiTest.java +++ /dev/null @@ -1,313 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.features; - -import static org.jclouds.reflect.Reflection2.method; - -import java.io.IOException; -import java.net.URI; - -import org.jclouds.Fallbacks.NullOnNotFoundOr404; -import org.jclouds.Fallbacks.VoidOnNotFoundOr404; -import org.jclouds.http.functions.ParseSax; -import org.jclouds.http.functions.ReleasePayloadAndReturn; -import org.jclouds.rest.internal.GeneratedHttpRequest; -import org.jclouds.util.Strings2; -import org.jclouds.vcloud.internal.BaseVCloudApiTest; -import org.jclouds.vcloud.options.CloneVAppOptions; -import org.jclouds.vcloud.xml.TaskHandler; -import org.jclouds.vcloud.xml.VAppHandler; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableList; -import com.google.common.reflect.Invokable; -/** - * Tests behavior of {@code VAppApi} - */ -// NOTE:without testName, this will not call @Before* and fail w/NPE during -// surefire -@Test(groups = "unit", testName = "VAppApiTest") -public class VAppApiTest extends BaseVCloudApiTest { - - public void testopyVAppToVDCAndName() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(VAppApi.class, "copyVAppToVDCAndName", URI.class, URI.class, String.class, - CloneVAppOptions[].class); - GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI - .create("https://vcenterprise.bluelock.com/api/v1.0/vapp/4181"), URI - .create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"), "my-vapp")); - - assertRequestLineEquals(request, - "POST https://vcenterprise.bluelock.com/api/v1.0/vdc/1/action/cloneVApp HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n"); - assertPayloadEquals(request, Strings2.toStringAndClose(getClass().getResourceAsStream("/copyVApp-default.xml")), - "application/vnd.vmware.vcloud.cloneVAppParams+xml", false); - - assertResponseParserClassEquals(method, request, ParseSax.class); - assertSaxResponseParserClassEquals(method, TaskHandler.class); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testCopyVAppToVDCAndNameOptions() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(VAppApi.class, "copyVAppToVDCAndName", URI.class, URI.class, String.class, - CloneVAppOptions[].class); - GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI - .create("https://vcenterprise.bluelock.com/api/v1.0/vapp/201"), URI - .create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"), "new-linux-server", new CloneVAppOptions() - .deploy().powerOn().description("The description of the new vApp"))); - - assertRequestLineEquals(request, - "POST https://vcenterprise.bluelock.com/api/v1.0/vdc/1/action/cloneVApp HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n"); - assertPayloadEquals(request, Strings2.toStringAndClose(getClass().getResourceAsStream("/copyVApp.xml")), - "application/vnd.vmware.vcloud.cloneVAppParams+xml", false); - - assertResponseParserClassEquals(method, request, ParseSax.class); - assertSaxResponseParserClassEquals(method, TaskHandler.class); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testMoveVAppToVDCAndRenameOptions() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(VAppApi.class, "moveVAppToVDCAndRename", URI.class, URI.class, String.class, - CloneVAppOptions[].class); - GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI - .create("https://vcenterprise.bluelock.com/api/v1.0/vapp/201"), URI - .create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"), "new-linux-server", new CloneVAppOptions() - .deploy().powerOn().description("The description of the new vApp"))); - - assertRequestLineEquals(request, - "POST https://vcenterprise.bluelock.com/api/v1.0/vdc/1/action/cloneVApp HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n"); - assertPayloadEquals(request, Strings2.toStringAndClose(getClass().getResourceAsStream("/moveVApp.xml")), - "application/vnd.vmware.vcloud.cloneVAppParams+xml", false); - - assertResponseParserClassEquals(method, request, ParseSax.class); - assertSaxResponseParserClassEquals(method, TaskHandler.class); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testDeployVApp() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(VAppApi.class, "deployVApp", URI.class); - GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI - .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"))); - - assertRequestLineEquals(request, "POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/action/deploy HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n"); - assertPayloadEquals(request, "", - "application/vnd.vmware.vcloud.deployVAppParams+xml", false); - - assertResponseParserClassEquals(method, request, ParseSax.class); - assertSaxResponseParserClassEquals(method, TaskHandler.class); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testDeployAndPowerOnVApp() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(VAppApi.class, "deployAndPowerOnVApp", URI.class); - GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI - .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"))); - - assertRequestLineEquals(request, "POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/action/deploy HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n"); - assertPayloadEquals(request, "", - "application/vnd.vmware.vcloud.deployVAppParams+xml", false); - - assertResponseParserClassEquals(method, request, ParseSax.class); - assertSaxResponseParserClassEquals(method, TaskHandler.class); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testGetVApp() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(VAppApi.class, "getVApp", URI.class); - GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI - .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"))); - - assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/vApp/1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.vApp+xml\n"); - assertPayloadEquals(request, null, null, false); - - assertResponseParserClassEquals(method, request, ParseSax.class); - assertSaxResponseParserClassEquals(method, VAppHandler.class); - assertFallbackClassEquals(method, NullOnNotFoundOr404.class); - - checkFilters(request); - } - - public void testRebootVApp() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(VAppApi.class, "rebootVApp", URI.class); - GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI - .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"))); - - assertRequestLineEquals(request, - "POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/power/action/reboot 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 testUndeployVApp() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(VAppApi.class, "undeployVApp", URI.class); - GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI - .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"))); - - assertRequestLineEquals(request, - "POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/action/undeploy HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n"); - assertPayloadEquals(request, "", - "application/vnd.vmware.vcloud.undeployVAppParams+xml", false); - - assertResponseParserClassEquals(method, request, ParseSax.class); - assertSaxResponseParserClassEquals(method, TaskHandler.class); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testUndeployAndSaveStateOfVAppSaveState() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(VAppApi.class, "undeployAndSaveStateOfVApp", URI.class); - GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI - .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"))); - - assertRequestLineEquals(request, - "POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/action/undeploy HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n"); - assertPayloadEquals(request, - "", - "application/vnd.vmware.vcloud.undeployVAppParams+xml", false); - - assertResponseParserClassEquals(method, request, ParseSax.class); - assertSaxResponseParserClassEquals(method, TaskHandler.class); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testDeleteVApp() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(VAppApi.class, "deleteVApp", URI.class); - GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI - .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"))); - - assertRequestLineEquals(request, "DELETE https://vcenterprise.bluelock.com/api/v1.0/vApp/1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n"); - assertPayloadEquals(request, null, null, false); - - assertResponseParserClassEquals(method, request, ParseSax.class); - assertSaxResponseParserClassEquals(method, TaskHandler.class); - assertFallbackClassEquals(method, VoidOnNotFoundOr404.class); - - checkFilters(request); - } - - public void testPowerOnVApp() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(VAppApi.class, "powerOnVApp", URI.class); - GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI - .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"))); - - assertRequestLineEquals(request, - "POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/power/action/powerOn HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n"); - assertPayloadEquals(request, null, null, false); - - assertResponseParserClassEquals(method, request, ParseSax.class); - assertSaxResponseParserClassEquals(method, TaskHandler.class); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testPowerOffVApp() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(VAppApi.class, "powerOffVApp", URI.class); - GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI - .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"))); - - assertRequestLineEquals(request, - "POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/power/action/powerOff HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n"); - assertPayloadEquals(request, null, null, false); - - assertResponseParserClassEquals(method, request, ParseSax.class); - assertSaxResponseParserClassEquals(method, TaskHandler.class); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testResetVApp() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(VAppApi.class, "resetVApp", URI.class); - GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI - .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"))); - - assertRequestLineEquals(request, - "POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/power/action/reset HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n"); - assertPayloadEquals(request, null, null, false); - - assertResponseParserClassEquals(method, request, ParseSax.class); - assertSaxResponseParserClassEquals(method, TaskHandler.class); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testSuspendVApp() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(VAppApi.class, "suspendVApp", URI.class); - GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI - .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"))); - - assertRequestLineEquals(request, - "POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/power/action/suspend HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n"); - assertPayloadEquals(request, null, null, false); - - assertResponseParserClassEquals(method, request, ParseSax.class); - assertSaxResponseParserClassEquals(method, TaskHandler.class); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testShutdownVApp() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(VAppApi.class, "shutdownVApp", URI.class); - GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI - .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"))); - - assertRequestLineEquals(request, - "POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/power/action/shutdown 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/apis/vcloud/src/test/java/org/jclouds/vcloud/features/VAppTemplateApiLiveTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/features/VAppTemplateApiLiveTest.java deleted file mode 100644 index e883235cc5..0000000000 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/features/VAppTemplateApiLiveTest.java +++ /dev/null @@ -1,164 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.features; - -import static com.google.common.collect.Iterables.getOnlyElement; -import static java.util.concurrent.TimeUnit.SECONDS; -import static org.jclouds.util.Predicates2.retry; -import static org.testng.Assert.assertEquals; - -import java.net.URI; - -import org.jclouds.compute.domain.NodeMetadata; -import org.jclouds.vcloud.VCloudMediaType; -import org.jclouds.vcloud.domain.Catalog; -import org.jclouds.vcloud.domain.CatalogItem; -import org.jclouds.vcloud.domain.Org; -import org.jclouds.vcloud.domain.ReferenceType; -import org.jclouds.vcloud.domain.Status; -import org.jclouds.vcloud.domain.Task; -import org.jclouds.vcloud.domain.VApp; -import org.jclouds.vcloud.domain.VAppTemplate; -import org.jclouds.vcloud.internal.BaseVCloudApiLiveTest; -import org.jclouds.vcloud.options.CatalogItemOptions; -import org.jclouds.vcloud.predicates.TaskSuccess; -import org.testng.annotations.Test; - -import com.google.common.base.Predicate; -import com.google.common.collect.ImmutableMap; - -@Test(groups = "live", enabled = true, singleThreaded = true, testName = "VAppTemplateApiLiveTest") -public class VAppTemplateApiLiveTest extends BaseVCloudApiLiveTest { - @Test - public void testGetVAppTemplate() throws Exception { - Org org = getVCloudApi().getOrgApi().findOrgNamed(null); - for (ReferenceType cat : org.getCatalogs().values()) { - Catalog response = getVCloudApi().getCatalogApi().getCatalog(cat.getHref()); - for (ReferenceType resource : response.values()) { - if (resource.getType().equals(VCloudMediaType.CATALOGITEM_XML)) { - CatalogItem item = getVCloudApi().getCatalogApi().getCatalogItem(resource.getHref()); - if (item.getEntity().getType().equals(VCloudMediaType.VAPPTEMPLATE_XML)) { - VAppTemplate template = getVCloudApi().getVAppTemplateApi().getVAppTemplate(item.getEntity().getHref()); - if (template != null) { - // the UUID in the href is the only way to actually link templates - assertEquals(template.getHref(), item.getEntity().getHref()); - } else { - // null can be no longer available or auth exception - } - } - } - } - } - } - - @Test - public void testGetOvfEnvelopeForVAppTemplate() throws Exception { - Org org = getVCloudApi().getOrgApi().findOrgNamed(null); - for (ReferenceType cat : org.getCatalogs().values()) { - Catalog response = getVCloudApi().getCatalogApi().getCatalog(cat.getHref()); - for (ReferenceType resource : response.values()) { - if (resource.getType().equals(VCloudMediaType.CATALOGITEM_XML)) { - CatalogItem item = getVCloudApi().getCatalogApi().getCatalogItem(resource.getHref()); - if (item.getEntity().getType().equals(VCloudMediaType.VAPPTEMPLATE_XML)) { - getVCloudApi().getVAppTemplateApi().getOvfEnvelopeForVAppTemplate(item.getEntity().getHref()); - // null can be no longer available or auth exception - } - } - } - } - } - - @Test - public void testFindVAppTemplate() throws Exception { - Org org = getVCloudApi().getOrgApi().findOrgNamed(null); - for (ReferenceType cat : org.getCatalogs().values()) { - Catalog response = getVCloudApi().getCatalogApi().getCatalog(cat.getHref()); - for (ReferenceType resource : response.values()) { - if (resource.getType().equals(VCloudMediaType.CATALOGITEM_XML)) { - CatalogItem item = getVCloudApi().getCatalogApi().getCatalogItem(resource.getHref()); - if (item.getEntity().getType().equals(VCloudMediaType.VAPPTEMPLATE_XML)) { - VAppTemplate template = getVCloudApi().getVAppTemplateApi().findVAppTemplateInOrgCatalogNamed( - org.getName(), response.getName(), item.getEntity().getName()); - if (template != null) { - // the UUID in the href is the only way to actually link templates - assertEquals(template.getHref(), item.getEntity().getHref()); - } else { - // null can be no longer available or auth exception - } - } - } - } - } - } - - @Test - public void testCaptureVApp() throws Exception { - String group = prefix + "cap"; - NodeMetadata node = null; - VAppTemplate vappTemplate = null; - CatalogItem item = null; - try { - - node = getOnlyElement(client.createNodesInGroup(group, 1)); - - Predicate taskTester = retry(new TaskSuccess(getVCloudApi()), 600, 5, SECONDS); - - // I have to undeploy first - Task task = getVCloudApi().getVAppApi().undeployVApp(URI.create(node.getId())); - - // wait up to ten minutes per above - assert taskTester.apply(task.getHref()) : node; - - VApp vApp = getVCloudApi().getVAppApi().getVApp(URI.create(node.getId())); - - // wait up to ten minutes per above - assertEquals(vApp.getStatus(), Status.OFF); - - // vdc is equiv to the node's location - // vapp uri is the same as the node's id - vappTemplate = getVCloudApi().getVAppTemplateApi().captureVAppAsTemplateInVDC(URI.create(node.getId()), - group, URI.create(node.getLocation().getId())); - - assertEquals(vappTemplate.getName(), group); - - task = vappTemplate.getTasks().get(0); - - // wait up to ten minutes per above - assert taskTester.apply(task.getHref()) : vappTemplate; - - item = getVCloudApi().getCatalogApi().addVAppTemplateOrMediaImageToCatalogAndNameItem( - vappTemplate.getHref(), - getVCloudApi().getCatalogApi().findCatalogInOrgNamed(null, null).getHref(), "fooname", - CatalogItemOptions.Builder.description("description").properties(ImmutableMap.of("foo", "bar"))); - - assertEquals(item.getName(), "fooname"); - assertEquals(item.getDescription(), "description"); - assertEquals(item.getProperties(), ImmutableMap.of("foo", "bar")); - assertEquals(item.getEntity().getName(), "fooname"); - assertEquals(item.getEntity().getHref(), vappTemplate.getHref()); - assertEquals(item.getEntity().getType(), vappTemplate.getType()); - - } finally { - if (item != null) - getVCloudApi().getCatalogApi().deleteCatalogItem(item.getHref()); - if (vappTemplate != null) - getVCloudApi().getVAppTemplateApi().deleteVAppTemplate(vappTemplate.getHref()); - if (node != null) - client.destroyNode(node.getId()); - } - } -} diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/features/VAppTemplateApiTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/features/VAppTemplateApiTest.java deleted file mode 100644 index 12bef2efbf..0000000000 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/features/VAppTemplateApiTest.java +++ /dev/null @@ -1,236 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.features; - -import static org.jclouds.reflect.Reflection2.method; -import static org.jclouds.vcloud.options.InstantiateVAppTemplateOptions.Builder.addNetworkConfig; - -import java.io.IOException; -import java.net.URI; - -import org.jclouds.Fallbacks.NullOnNotFoundOr404; -import org.jclouds.http.functions.ParseSax; -import org.jclouds.ovf.xml.EnvelopeHandler; -import org.jclouds.rest.internal.GeneratedHttpRequest; -import org.jclouds.util.Strings2; -import org.jclouds.vcloud.domain.network.FenceMode; -import org.jclouds.vcloud.domain.network.NetworkConfig; -import org.jclouds.vcloud.internal.BaseVCloudApiTest; -import org.jclouds.vcloud.options.CaptureVAppOptions; -import org.jclouds.vcloud.options.CloneVAppTemplateOptions; -import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions; -import org.jclouds.vcloud.xml.TaskHandler; -import org.jclouds.vcloud.xml.VAppHandler; -import org.jclouds.vcloud.xml.VAppTemplateHandler; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableList; -import com.google.common.reflect.Invokable; -/** - * Tests behavior of {@code VAppTemplateApi} - */ -// NOTE:without testName, this will not call @Before* and fail w/NPE during -// surefire -@Test(groups = "unit", testName = "VAppTemplateApiTest") -public class VAppTemplateApiTest extends BaseVCloudApiTest { - - public void testCreateVAppInVDCByInstantiatingTemplate() throws SecurityException, NoSuchMethodException, - IOException { - Invokable method = method(VAppTemplateApi.class, "createVAppInVDCByInstantiatingTemplate", String.class, - URI.class, URI.class, InstantiateVAppTemplateOptions[].class); - GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("my-vapp", URI - .create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"), URI - .create("https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/3"), - addNetworkConfig(new NetworkConfig("aloha", URI - .create("https://vcenterprise.bluelock.com/api/v1.0/network/1991"), FenceMode.NAT_ROUTED)))); - - assertRequestLineEquals(request, - "POST https://vcenterprise.bluelock.com/api/v1.0/vdc/1/action/instantiateVAppTemplate HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.vApp+xml\n"); - assertPayloadEquals(request, Strings2.toStringAndClose(getClass().getResourceAsStream( - "/instantiationparams-network.xml")), "application/vnd.vmware.vcloud.instantiateVAppTemplateParams+xml", - false); - - assertResponseParserClassEquals(method, request, ParseSax.class); - assertSaxResponseParserClassEquals(method, VAppHandler.class); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - @Test(expectedExceptions = IllegalArgumentException.class) - public void testCreateVAppInVDCByInstantiatingTemplateOptionsIllegalName() throws SecurityException, - NoSuchMethodException, IOException { - Invokable method = method(VAppTemplateApi.class, "createVAppInVDCByInstantiatingTemplate", String.class, - URI.class, URI.class, InstantiateVAppTemplateOptions[].class); - processor.createRequest(method, ImmutableList. of("CentOS 01", URI.create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"), URI - .create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"), addNetworkConfig(new NetworkConfig(null, - URI.create("https://vcenterprise.bluelock.com/api/v1.0/network/1991"), null)))); - } - - public void testcopyVAppTemplateToVDCAndName() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(VAppTemplateApi.class, "copyVAppTemplateToVDCAndName", URI.class, URI.class, - String.class, CloneVAppTemplateOptions[].class); - GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI - .create("https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/4181"), URI - .create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"), "my-vapptemplate")); - - assertRequestLineEquals(request, - "POST https://vcenterprise.bluelock.com/api/v1.0/vdc/1/action/cloneVAppTemplate HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n"); - assertPayloadEquals(request, Strings2.toStringAndClose(getClass().getResourceAsStream( - "/copyVAppTemplate-default.xml")), "application/vnd.vmware.vcloud.cloneVAppTemplateParams+xml", false); - - assertResponseParserClassEquals(method, request, ParseSax.class); - assertSaxResponseParserClassEquals(method, TaskHandler.class); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testcopyVAppTemplateToVDCAndNameOptions() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(VAppTemplateApi.class, "copyVAppTemplateToVDCAndName", URI.class, URI.class, - String.class, CloneVAppTemplateOptions[].class); - GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI - .create("https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/201"), URI - .create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"), "new-linux-server", - new CloneVAppTemplateOptions().description("The description of the new vAppTemplate"))); - - assertRequestLineEquals(request, - "POST https://vcenterprise.bluelock.com/api/v1.0/vdc/1/action/cloneVAppTemplate HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n"); - assertPayloadEquals(request, Strings2.toStringAndClose(getClass().getResourceAsStream("/copyVAppTemplate.xml")), - "application/vnd.vmware.vcloud.cloneVAppTemplateParams+xml", false); - - assertResponseParserClassEquals(method, request, ParseSax.class); - assertSaxResponseParserClassEquals(method, TaskHandler.class); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testmoveVAppTemplateToVDCAndRenameOptions() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(VAppTemplateApi.class, "moveVAppTemplateToVDCAndRename", URI.class, URI.class, - String.class, CloneVAppTemplateOptions[].class); - GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI - .create("https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/201"), URI - .create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"), "new-linux-server", - new CloneVAppTemplateOptions().description("The description of the new vAppTemplate"))); - - assertRequestLineEquals(request, - "POST https://vcenterprise.bluelock.com/api/v1.0/vdc/1/action/cloneVAppTemplate HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n"); - assertPayloadEquals(request, Strings2.toStringAndClose(getClass().getResourceAsStream("/moveVAppTemplate.xml")), - "application/vnd.vmware.vcloud.cloneVAppTemplateParams+xml", false); - - assertResponseParserClassEquals(method, request, ParseSax.class); - assertSaxResponseParserClassEquals(method, TaskHandler.class); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testcaptureVAppAsTemplateInVDC() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(VAppTemplateApi.class, "captureVAppAsTemplateInVDC", URI.class, String.class, - URI.class, CaptureVAppOptions[].class); - GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI - .create("https://vcenterprise.bluelock.com/api/v1.0/vapp/4181"), "my-template", URI - .create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"))); - - assertRequestLineEquals(request, - "POST https://vcenterprise.bluelock.com/api/v1.0/vdc/1/action/captureVApp HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.vAppTemplate+xml\n"); - assertPayloadEquals(request, Strings2 - .toStringAndClose(getClass().getResourceAsStream("/captureVApp-default.xml")), - "application/vnd.vmware.vcloud.captureVAppParams+xml", false); - - assertResponseParserClassEquals(method, request, ParseSax.class); - assertSaxResponseParserClassEquals(method, VAppTemplateHandler.class); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testcaptureVAppAsTemplateInVDCOptions() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(VAppTemplateApi.class, "captureVAppAsTemplateInVDC", URI.class, String.class, - URI.class, CaptureVAppOptions[].class); - GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI - .create("https://vcenterprise.bluelock.com/api/v1.0/vapp/201"), "my-template", URI - .create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"), new CaptureVAppOptions() - .withDescription("The description of the new vApp Template"))); - - assertRequestLineEquals(request, - "POST https://vcenterprise.bluelock.com/api/v1.0/vdc/1/action/captureVApp HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.vAppTemplate+xml\n"); - assertPayloadEquals(request, Strings2.toStringAndClose(getClass().getResourceAsStream("/captureVApp.xml")), - "application/vnd.vmware.vcloud.captureVAppParams+xml", false); - - assertResponseParserClassEquals(method, request, ParseSax.class); - assertSaxResponseParserClassEquals(method, VAppTemplateHandler.class); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testFindVAppTemplate() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(VAppTemplateApi.class, "findVAppTemplateInOrgCatalogNamed", String.class, - String.class, String.class); - GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("org", "catalog", "template")); - - assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/2 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.vAppTemplate+xml\n"); - assertPayloadEquals(request, null, null, false); - - assertResponseParserClassEquals(method, request, ParseSax.class); - assertSaxResponseParserClassEquals(method, VAppTemplateHandler.class); - assertFallbackClassEquals(method, NullOnNotFoundOr404.class); - - checkFilters(request); - } - - public void testVAppTemplateURI() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(VAppTemplateApi.class, "getVAppTemplate", URI.class); - GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI - .create("https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/2"))); - - assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/2 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.vAppTemplate+xml\n"); - assertPayloadEquals(request, null, null, false); - - assertResponseParserClassEquals(method, request, ParseSax.class); - assertSaxResponseParserClassEquals(method, VAppTemplateHandler.class); - assertFallbackClassEquals(method, NullOnNotFoundOr404.class); - - checkFilters(request); - } - - public void testGetOvfEnvelopeForVAppTemplate() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(VAppTemplateApi.class, "getOvfEnvelopeForVAppTemplate", URI.class); - GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI - .create("https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/2"))); - - assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/2/ovf HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: text/xml\n"); - assertPayloadEquals(request, null, null, false); - - assertResponseParserClassEquals(method, request, ParseSax.class); - assertSaxResponseParserClassEquals(method, EnvelopeHandler.class); - assertFallbackClassEquals(method, NullOnNotFoundOr404.class); - - checkFilters(request); - } -} diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/features/VDCApiLiveTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/features/VDCApiLiveTest.java deleted file mode 100644 index be1efdc874..0000000000 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/features/VDCApiLiveTest.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.features; - -import org.jclouds.vcloud.internal.BaseVCloudApiLiveTest; -import org.testng.annotations.Test; - -@Test(groups = "live", enabled = true, singleThreaded = true, testName = "VDCApiLiveTest") -public class VDCApiLiveTest extends BaseVCloudApiLiveTest { - - -} diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/features/VDCApiTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/features/VDCApiTest.java deleted file mode 100644 index 02964534ef..0000000000 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/features/VDCApiTest.java +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.features; - -import static org.jclouds.reflect.Reflection2.method; - -import java.io.IOException; -import java.net.URI; -import java.util.NoSuchElementException; - -import org.jclouds.Fallbacks.NullOnNotFoundOr404; -import org.jclouds.http.functions.ParseSax; -import org.jclouds.rest.internal.GeneratedHttpRequest; -import org.jclouds.vcloud.internal.BaseVCloudApiTest; -import org.jclouds.vcloud.xml.VDCHandler; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableList; -import com.google.common.collect.Lists; -import com.google.common.reflect.Invokable; -/** - * Tests behavior of {@code VDCApi} - */ -// NOTE:without testName, this will not call @Before* and fail w/NPE during -// surefire -@Test(groups = "unit", testName = "VDCApiTest") -public class VDCApiTest extends BaseVCloudApiTest { - - @Test(expectedExceptions = NoSuchElementException.class) - public void testFindVDCInOrgNamedBadVDC() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(VDCApi.class, "findVDCInOrgNamed", String.class, String.class); - processor.createRequest(method, ImmutableList. of("org", "vdc1")); - } - - @Test(expectedExceptions = NoSuchElementException.class) - public void testFindVDCInOrgNamedBadOrg() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(VDCApi.class, "findVDCInOrgNamed", String.class, String.class); - processor.createRequest(method, ImmutableList. of("org1", "vdc")); - } - - public void testFindVDCInOrgNamedNullOrg() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(VDCApi.class, "findVDCInOrgNamed", String.class, String.class); - GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "vdc")); - - assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/vdc/1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.vdc+xml\n"); - assertPayloadEquals(request, null, null, false); - - assertResponseParserClassEquals(method, request, ParseSax.class); - assertSaxResponseParserClassEquals(method, VDCHandler.class); - assertFallbackClassEquals(method, NullOnNotFoundOr404.class); - - checkFilters(request); - } - - public void testFindVDCInOrgNamedNullOrgAndVDC() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(VDCApi.class, "findVDCInOrgNamed", String.class, String.class); - GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, null)); - - assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/vdc/1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.vdc+xml\n"); - assertPayloadEquals(request, null, null, false); - - assertResponseParserClassEquals(method, request, ParseSax.class); - assertSaxResponseParserClassEquals(method, VDCHandler.class); - assertFallbackClassEquals(method, NullOnNotFoundOr404.class); - - checkFilters(request); - } - - public void testGetVDC() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(VDCApi.class, "getVDC", URI.class); - GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI - .create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"))); - - assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/vdc/1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.vdc+xml\n"); - assertPayloadEquals(request, null, null, false); - - assertResponseParserClassEquals(method, request, ParseSax.class); - assertSaxResponseParserClassEquals(method, VDCHandler.class); - assertFallbackClassEquals(method, NullOnNotFoundOr404.class); - - checkFilters(request); - } -} diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/features/VmApiLiveTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/features/VmApiLiveTest.java deleted file mode 100644 index f6b3d92df4..0000000000 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/features/VmApiLiveTest.java +++ /dev/null @@ -1,161 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.features; - -import static com.google.common.base.Charsets.UTF_8; -import static com.google.common.collect.Iterables.get; -import static com.google.common.collect.Iterables.getOnlyElement; -import static com.google.common.io.BaseEncoding.base64; -import static org.jclouds.compute.options.RunScriptOptions.Builder.wrapInInitScript; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; - -import org.jclouds.compute.domain.ExecResponse; -import org.jclouds.compute.domain.NodeMetadata; -import org.jclouds.compute.options.TemplateOptions; -import org.jclouds.vcloud.VCloudApi; -import org.jclouds.vcloud.VCloudMediaType; -import org.jclouds.vcloud.compute.options.VCloudTemplateOptions; -import org.jclouds.vcloud.domain.Org; -import org.jclouds.vcloud.domain.ReferenceType; -import org.jclouds.vcloud.domain.VApp; -import org.jclouds.vcloud.domain.VDC; -import org.jclouds.vcloud.domain.Vm; -import org.jclouds.vcloud.internal.BaseVCloudApiLiveTest; -import org.testng.annotations.Test; - -import com.google.common.collect.Iterables; -import com.google.common.net.HostAndPort; - -/** - * This tests that we can use guest customization as an alternative to bootstrapping with ssh. There - * are a few advantages to this, including the fact that it can work inside google appengine where - * network sockets (ssh:22) are prohibited. - */ -@Test(groups = "live", enabled = true, singleThreaded = true, testName = "VmApiLiveTest") -public class VmApiLiveTest extends BaseVCloudApiLiveTest { - - @Test - public void testGetThumbnailOfVm() throws Exception { - Org org = getVCloudApi().getOrgApi().findOrgNamed(null); - for (ReferenceType vdc : org.getVDCs().values()) { - VDC response = getVCloudApi().getVDCApi().getVDC(vdc.getHref()); - for (ReferenceType item : response.getResourceEntities().values()) { - if (item.getType().equals(VCloudMediaType.VAPP_XML)) { - try { - VApp app = getVCloudApi().getVAppApi().getVApp(item.getHref()); - assertNotNull(app); - for (Vm vm : app.getChildren()) { - assert getVCloudApi().getVmApi().getScreenThumbnailForVm(vm.getHref()) != null; - } - } catch (RuntimeException e) { - - } - } - } - } - } - - @Test - public void testGetVm() throws Exception { - Org org = getVCloudApi().getOrgApi().findOrgNamed(null); - for (ReferenceType vdc : org.getVDCs().values()) { - VDC response = getVCloudApi().getVDCApi().getVDC(vdc.getHref()); - for (ReferenceType item : response.getResourceEntities().values()) { - if (item.getType().equals(VCloudMediaType.VAPP_XML)) { - try { - VApp app = getVCloudApi().getVAppApi().getVApp(item.getHref()); - assertNotNull(app); - for (Vm vm : app.getChildren()) { - assertEquals(getVCloudApi().getVmApi().getVm(vm.getHref()).getHref(), vm.getHref()); - } - } catch (RuntimeException e) { - - } - } - } - } - } - - @Test - public void testExtendedOptionsWithCustomizationScript() throws Exception { - String PARSE_VMTOOLSD = "vmtoolsd --cmd=\"info-get guestinfo.ovfenv\" |grep vCloud_CustomizationInfo|sed 's/.*value=\"\\(.*\\)\".*/\\1/g'"; - - String group = prefix + "cus"; - - NodeMetadata node = null; - try { - - TemplateOptions options = client.templateOptions(); - options.blockOnPort(22, 180); - options.as(VCloudTemplateOptions.class).customizationScript(script); - options.as(VCloudTemplateOptions.class).description(group); - node = getOnlyElement(client.createNodesInGroup(group, 1, options)); - - VApp vapp = client.getContext().unwrapApi(VCloudApi.class).getVAppApi().getVApp( - node.getUri()); - assertEquals(vapp.getDescription(), group); - - Vm vm = Iterables.get(vapp.getChildren(), 0); - String apiOutput = vm.getGuestCustomizationSection().getCustomizationScript(); - checkApiOutput(apiOutput); - - ExecResponse vmTools = client.runScriptOnNode(node.getId(), PARSE_VMTOOLSD, - wrapInInitScript(false).runAsRoot(false)); - checkApiOutput(new String(base64().decode(vmTools.getOutput().trim()), UTF_8)); - - ExecResponse foo = client.runScriptOnNode(node.getId(), "cat /root/foo.txt", wrapInInitScript(false) - .runAsRoot(false)); - checkCustomizationOccurred(foo); - - } finally { - if (node != null) - client.destroyNode(node.getId()); - } - } - - protected void checkCustomizationOccurred(ExecResponse exec) { - // note that vmwaretools throws in \r characters when executing scripts - assert exec.getOutput().equals(iLoveAscii + "\r\n") : exec; - } - - protected void checkApiOutput(String apiOutput) { - checkApiOutput1_0_1(apiOutput); - } - - // make sure the script has a lot of screwy characters, knowing our parser - // throws-out \r - protected String iLoveAscii = "I '\"love\"' {asc|!}*&"; - - String script = "cat > /root/foo.txt< { - - public void testGetThumbnailOfVm() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(VmApi.class, "getScreenThumbnailForVm", URI.class); - GeneratedHttpRequest request = processor - .createRequest(method, ImmutableList. of(URI.create("http://vcloud.example.com/api/v1.0/vApp/vm-12"))); - - assertRequestLineEquals(request, "GET http://vcloud.example.com/api/v1.0/vApp/vm-12/screen HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: image/png\n"); - assertPayloadEquals(request, null, null, false); - - assertResponseParserClassEquals(method, request, ReturnInputStream.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, NullOnNotFoundOr404.class); - - checkFilters(request); - } - - @Test(dataProvider = "ignoreOnWindows", description = "see http://code.google.com/p/jclouds/issues/detail?id=402") - public void testUpdateGuestConfiguration() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(VmApi.class, "updateGuestCustomizationOfVm", GuestCustomizationSection.class, - URI.class); - GuestCustomizationSection guest = new GuestCustomizationSection(URI - .create("http://vcloud.example.com/api/v1.0/vApp/vm-12/guestCustomizationSection")); - guest.setCustomizationScript("cat > /tmp/foo.txt< of(guest, URI - .create("http://vcloud.example.com/api/v1.0/vApp/vm-12"))); - - assertRequestLineEquals(request, - "PUT http://vcloud.example.com/api/v1.0/vApp/vm-12/guestCustomizationSection HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n"); - assertPayloadEquals(request, Strings2.toStringAndClose(getClass().getResourceAsStream( - "/guestCustomizationSection.xml")), "application/vnd.vmware.vcloud.guestCustomizationSection+xml", false); - - assertResponseParserClassEquals(method, request, ParseSax.class); - assertSaxResponseParserClassEquals(method, TaskHandler.class); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testUpdateCPUCountOfVm() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(VmApi.class, "updateCPUCountOfVm", int.class, URI.class); - GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(2, URI - .create("http://vcloud.example.com/api/v1.0/vApp/vm-12"))); - - assertRequestLineEquals(request, - "PUT http://vcloud.example.com/api/v1.0/vApp/vm-12/virtualHardwareSection/cpu HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n"); - assertPayloadEquals(request, Strings2.toStringAndClose(getClass().getResourceAsStream("/cpuItem.xml")), - "application/vnd.vmware.vcloud.rasdItem+xml", false); - - assertResponseParserClassEquals(method, request, ParseSax.class); - assertSaxResponseParserClassEquals(method, TaskHandler.class); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testUpdateMemoryMBOfVm() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(VmApi.class, "updateMemoryMBOfVm", int.class, URI.class); - GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(512, URI - .create("http://vcloud.example.com/api/v1.0/vApp/vm-12"))); - - assertRequestLineEquals(request, - "PUT http://vcloud.example.com/api/v1.0/vApp/vm-12/virtualHardwareSection/memory HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n"); - assertPayloadEquals(request, Strings2.toStringAndClose(getClass().getResourceAsStream("/memoryItem.xml")), - "application/vnd.vmware.vcloud.rasdItem+xml", false); - - assertResponseParserClassEquals(method, request, ParseSax.class); - assertSaxResponseParserClassEquals(method, TaskHandler.class); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testDeployVm() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(VmApi.class, "deployVm", URI.class); - GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI - .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"))); - - assertRequestLineEquals(request, "POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/action/deploy HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n"); - assertPayloadEquals(request, "", - "application/vnd.vmware.vcloud.deployVAppParams+xml", false); - - assertResponseParserClassEquals(method, request, ParseSax.class); - assertSaxResponseParserClassEquals(method, TaskHandler.class); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testDeployAndPowerOnVm() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(VmApi.class, "deployAndPowerOnVm", URI.class); - GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI - .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"))); - - assertRequestLineEquals(request, "POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/action/deploy HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n"); - assertPayloadEquals(request, "", - "application/vnd.vmware.vcloud.deployVAppParams+xml", false); - - assertResponseParserClassEquals(method, request, ParseSax.class); - assertSaxResponseParserClassEquals(method, TaskHandler.class); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testGetVm() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(VmApi.class, "getVm", URI.class); - GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI - .create("https://vcenterprise.bluelock.com/api/v1.0/vm/1"))); - - assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/vm/1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.vm+xml\n"); - assertPayloadEquals(request, null, null, false); - - assertResponseParserClassEquals(method, request, ParseSax.class); - assertSaxResponseParserClassEquals(method, VmHandler.class); - assertFallbackClassEquals(method, NullOnNotFoundOr404.class); - - checkFilters(request); - } - - public void testRebootVm() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(VmApi.class, "rebootVm", URI.class); - GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI - .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"))); - - assertRequestLineEquals(request, - "POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/power/action/reboot 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 testUndeployVm() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(VmApi.class, "undeployVm", URI.class); - GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI - .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"))); - - assertRequestLineEquals(request, - "POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/action/undeploy HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n"); - assertPayloadEquals(request, "", - "application/vnd.vmware.vcloud.undeployVAppParams+xml", false); - - assertResponseParserClassEquals(method, request, ParseSax.class); - assertSaxResponseParserClassEquals(method, TaskHandler.class); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testUndeployAndSaveStateOfVmSaveState() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(VmApi.class, "undeployAndSaveStateOfVm", URI.class); - GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI - .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"))); - - assertRequestLineEquals(request, - "POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/action/undeploy HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n"); - assertPayloadEquals(request, - "", - "application/vnd.vmware.vcloud.undeployVAppParams+xml", false); - - assertResponseParserClassEquals(method, request, ParseSax.class); - assertSaxResponseParserClassEquals(method, TaskHandler.class); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testPowerOnVm() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(VmApi.class, "powerOnVm", URI.class); - GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI - .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"))); - - assertRequestLineEquals(request, - "POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/power/action/powerOn HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n"); - assertPayloadEquals(request, null, null, false); - - assertResponseParserClassEquals(method, request, ParseSax.class); - assertSaxResponseParserClassEquals(method, TaskHandler.class); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testPowerOffVm() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(VmApi.class, "powerOffVm", URI.class); - GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI - .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"))); - - assertRequestLineEquals(request, - "POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/power/action/powerOff HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n"); - assertPayloadEquals(request, null, null, false); - - assertResponseParserClassEquals(method, request, ParseSax.class); - assertSaxResponseParserClassEquals(method, TaskHandler.class); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testResetVm() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(VmApi.class, "resetVm", URI.class); - GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI - .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"))); - - assertRequestLineEquals(request, - "POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/power/action/reset HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n"); - assertPayloadEquals(request, null, null, false); - - assertResponseParserClassEquals(method, request, ParseSax.class); - assertSaxResponseParserClassEquals(method, TaskHandler.class); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testSuspendVm() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(VmApi.class, "suspendVm", URI.class); - GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI - .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"))); - - assertRequestLineEquals(request, - "POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/power/action/suspend HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n"); - assertPayloadEquals(request, null, null, false); - - assertResponseParserClassEquals(method, request, ParseSax.class); - assertSaxResponseParserClassEquals(method, TaskHandler.class); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testShutdownVm() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(VmApi.class, "shutdownVm", URI.class); - GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI - .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"))); - - assertRequestLineEquals(request, - "POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/power/action/shutdown HTTP/1.1"); - assertNonPayloadHeadersEqual(request, ""); - assertPayloadEquals(request, null, null, false); - - assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - @DataProvider - public Object[][] ignoreOnWindows() { - return TestUtils.isWindowsOs() ? TestUtils.NO_INVOCATIONS - : TestUtils.SINGLE_NO_ARG_INVOCATION; - } - -} diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/filters/AddVCloudAuthorizationAndCookieToRequestTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/filters/AddVCloudAuthorizationAndCookieToRequestTest.java deleted file mode 100644 index b2e46874e8..0000000000 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/filters/AddVCloudAuthorizationAndCookieToRequestTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.filters; - -import static org.testng.Assert.assertEquals; - -import org.jclouds.http.HttpRequest; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.Test; - -import com.google.common.base.Supplier; -import com.google.common.net.HttpHeaders; - -@Test(testName = "AddVCloudAuthorizationAndCookieToRequestTest") -public class AddVCloudAuthorizationAndCookieToRequestTest { - - private AddVCloudAuthorizationAndCookieToRequest filter; - - @BeforeTest - void setUp() { - filter = new AddVCloudAuthorizationAndCookieToRequest(new Supplier() { - public String get() { - return "token"; - } - }); - } - - @Test - public void testApply() { - HttpRequest request = HttpRequest.builder().method("GET").endpoint("http://localhost").build(); - request = filter.filter(request); - assertEquals(request.getHeaders().size(), 2); - assertEquals(request.getFirstHeaderOrNull(HttpHeaders.COOKIE), "vcloud-token=token"); - assertEquals(request.getFirstHeaderOrNull("x-vcloud-authorization"), "token"); - } - -} diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/functions/ParseLoginResponseFromHeadersTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/functions/ParseLoginResponseFromHeadersTest.java deleted file mode 100644 index 66a4f4ab6b..0000000000 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/functions/ParseLoginResponseFromHeadersTest.java +++ /dev/null @@ -1,145 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.functions; - -import static org.testng.Assert.assertEquals; - -import java.net.URI; - -import org.jclouds.http.HttpResponse; -import org.jclouds.http.HttpResponseException; -import org.jclouds.http.functions.BaseHandlerTest; -import org.jclouds.vcloud.VCloudMediaType; -import org.jclouds.vcloud.domain.VCloudSession; -import org.jclouds.vcloud.domain.internal.ReferenceTypeImpl; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableMap; - -/** - * Tests behavior of {@code ParseLoginResponseFromHeaders} - */ -// NOTE:without testName, this will not call @Before* and fail w/NPE during -// surefire -@Test(groups = "unit", testName = "ParseLoginResponseFromHeadersTest") -public class ParseLoginResponseFromHeadersTest extends BaseHandlerTest { - - private ParseLoginResponseFromHeaders parser; - - @BeforeTest - void setUp() { - parser = injector.getInstance(ParseLoginResponseFromHeaders.class); - } - - @Test - public void testApply() { - HttpResponse response = HttpResponse.builder().statusCode(200).message("OK") - .payload(getClass().getResourceAsStream("/orglist.xml")) - .addHeader("x-vcloud-authorization", "vcloud-token=9er4d061-4bff-48fa-84b1-5da7166764d2; path=/").build(); - response.getPayload().getContentMetadata().setContentType("Content-Type: application/xml; charset=utf-8"); - response.getPayload().getContentMetadata().setContentLength(307l); - - VCloudSession reply = parser.apply(response); - assertEquals(reply.getVCloudToken(), "9er4d061-4bff-48fa-84b1-5da7166764d2"); - assertEquals(reply.getOrgs(), ImmutableMap.of("adrian@jclouds.org", new ReferenceTypeImpl("adrian@jclouds.org", - VCloudMediaType.ORG_XML, URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/org/48")))); - - } - - @Test - public void testApplyBlueLock() { - HttpResponse response = HttpResponse.builder().statusCode(200).message("OK") - .payload(getClass().getResourceAsStream("/orglist.xml")) - .addHeader("x-vcloud-authorization", "MUKOJ2HoAfoMmLnHRp4esNb2MtWscCLLhVysnsIsCG0=").build(); - response.getPayload().getContentMetadata().setContentType("Content-Type: application/xml; charset=utf-8"); - response.getPayload().getContentMetadata().setContentLength(307l); - - VCloudSession reply = parser.apply(response); - assertEquals(reply.getVCloudToken(), "MUKOJ2HoAfoMmLnHRp4esNb2MtWscCLLhVysnsIsCG0="); - assertEquals(reply.getOrgs(), ImmutableMap.of("adrian@jclouds.org", new ReferenceTypeImpl("adrian@jclouds.org", - VCloudMediaType.ORG_XML, URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/org/48")))); - - } - - @Test - public void testApplyTerremark() { - HttpResponse response = HttpResponse.builder().statusCode(200).message("OK") - .payload(getClass().getResourceAsStream("/orglist.xml")) - .addHeader("Set-Cookie", "vcloud-token=37ce2715-9aba-4f48-8e45-2db8a8da702d; path=/").build(); - response.getPayload().getContentMetadata().setContentType("Content-Type: application/xml; charset=utf-8"); - response.getPayload().getContentMetadata().setContentLength(307l); - - VCloudSession reply = parser.apply(response); - assertEquals(reply.getVCloudToken(), "37ce2715-9aba-4f48-8e45-2db8a8da702d"); - assertEquals(reply.getOrgs(), ImmutableMap.of("adrian@jclouds.org", new ReferenceTypeImpl("adrian@jclouds.org", - VCloudMediaType.ORG_XML, URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/org/48")))); - - } - - @Test - public void testApplyTerremarkMultipleCookies() { - HttpResponse response = HttpResponse.builder().statusCode(200).message("OK") - .payload(getClass().getResourceAsStream("/orglist.xml")) - .addHeader("Set-Cookie", "NSC_ESUO_21654_72.46.239.132_443=fooo;expires=Thu, 02-Jun-2011 17:19:26 GMT;path=/;secure;httponly") - .addHeader("Set-Cookie", "vcloud-token=37ce2715-9aba-4f48-8e45-2db8a8da702d; path=/").build(); - response.getPayload().getContentMetadata().setContentType("Content-Type: application/xml; charset=utf-8"); - response.getPayload().getContentMetadata().setContentLength(307l); - - VCloudSession reply = parser.apply(response); - assertEquals(reply.getVCloudToken(), "37ce2715-9aba-4f48-8e45-2db8a8da702d"); - assertEquals(reply.getOrgs(), ImmutableMap.of("adrian@jclouds.org", new ReferenceTypeImpl("adrian@jclouds.org", - VCloudMediaType.ORG_XML, URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/org/48")))); - - } - - @Test(expectedExceptions = HttpResponseException.class) - public void testUnmatchedCookieThrowsHttpResponseException() { - HttpResponse response = HttpResponse.builder().statusCode(200).message("OK") - .payload(getClass().getResourceAsStream("/orglist.xml")) - .addHeader("Set-Cookie", "NSC_ESUO_21654_72.46.239.132_443=fooo;expires=Thu, 02-Jun-2011 17:19:26 GMT;path=/;secure;httponly").build(); - response.getPayload().getContentMetadata().setContentType("Content-Type: application/xml; charset=utf-8"); - response.getPayload().getContentMetadata().setContentLength(307l); - - parser.apply(response); - } - - @Test(expectedExceptions = HttpResponseException.class) - public void testNoThrowsHttpResponseException() { - HttpResponse response = HttpResponse.builder().statusCode(200).message("OK") - .payload(getClass().getResourceAsStream("/orglist.xml")).build(); - response.getPayload().getContentMetadata().setContentType("Content-Type: application/xml; charset=utf-8"); - response.getPayload().getContentMetadata().setContentLength(307l); - - parser.apply(response); - } - - @Test - public void testApplyVirtacore() { - HttpResponse response = HttpResponse.builder().statusCode(200).message("OK") - .payload(getClass().getResourceAsStream("/orglist.xml")) - .addHeader("x-vcloud-authorization", "vcloud-token=IPy0w7UGD4lwtdWAK/ZVzfuLK+dztxGRqsOhWqV0i48=").build(); - response.getPayload().getContentMetadata().setContentType("Content-Type: application/xml; charset=utf-8"); - response.getPayload().getContentMetadata().setContentLength(307l); - - VCloudSession reply = parser.apply(response); - assertEquals(reply.getVCloudToken(), "IPy0w7UGD4lwtdWAK/ZVzfuLK+dztxGRqsOhWqV0i48="); - assertEquals(reply.getOrgs(), ImmutableMap.of("adrian@jclouds.org", new ReferenceTypeImpl("adrian@jclouds.org", - VCloudMediaType.ORG_XML, URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/org/48")))); - - } -} diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/handlers/ParseVCloudErrorFromHttpResponseTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/handlers/ParseVCloudErrorFromHttpResponseTest.java deleted file mode 100644 index 9466191bfe..0000000000 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/handlers/ParseVCloudErrorFromHttpResponseTest.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.handlers; - -import java.net.URI; - -import org.jclouds.http.BaseHttpErrorHandlerTest; -import org.jclouds.http.HttpErrorHandler; -import org.jclouds.http.HttpResponseException; -import org.jclouds.rest.AuthorizationException; -import org.jclouds.rest.ResourceNotFoundException; -import org.jclouds.vcloud.VCloudMediaType; -import org.testng.annotations.Test; - -@Test(groups = { "unit" }) -public class ParseVCloudErrorFromHttpResponseTest extends BaseHttpErrorHandlerTest { - - @Test - public void testGet404SetsResourceNotFoundException() { - assertCodeMakes("GET", URI.create("https://services.vcloudexpress.terremark.com/api/v0.8a-ext1.6/vdc/32"), 404, - "", "", ResourceNotFoundException.class); - } - - @Test - public void testGet403NoAcessToEntitySetsResourceNotFoundException() { - assertCodeMakes( - "GET", - URI.create("https://zone01.bluelock.com/api/v1.0/vApp/vapp-1535788985"), - 403, - "HTTP/1.1 403", - VCloudMediaType.ERROR_XML, - "\n", - ResourceNotFoundException.class); - } - - @Test - public void testGet403NoAcessToEntitySetsResourceNotFoundExceptionOnAPI1_0AgainstVCD1_5() { - assertCodeMakes( - "GET", - URI.create("https://mycloud.greenhousedata.com/api/v1.0/vApp/vapp-d3a1f2cd-d07b-4ddc-bf7b-fb7468b4d95a"), - 403, - "HTTP/1.1 403", - // NOTE VCD 1.5 appends the api version to the media type - VCloudMediaType.ERROR_XML + ";1.0", - "", - ResourceNotFoundException.class); - } - - @Test - public void testDelete404SetsHttpResponseException() { - assertCodeMakes("DELETE", URI.create("https://services.vcloudexpress.terremark.com/api/v0.8a-ext1.6/vdc/32"), - 404, "", "", HttpResponseException.class); - } - - @Test - public void testPOSTNotRunningSetsIllegalStateException() { - assertCodeMakes( - "POST", - URI.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/vapp-138351019/action/undeploy"), - 400, - "HTTP/1.1 400 Bad Request", - VCloudMediaType.ERROR_XML, - "\n", - IllegalStateException.class); - } - - @Test - public void test401SetsAuthorizationException() { - assertCodeMakes("GET", URI.create("https://services.vcloudexpress.terremark.com/api/v0.8a-ext1.6/vdc/32"), 401, - "", "", AuthorizationException.class); - } - - @Override - protected Class getHandlerClass() { - return ParseVCloudErrorFromHttpResponse.class; - } - -} diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/internal/BasePayloadTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/internal/BasePayloadTest.java deleted file mode 100644 index 4ffe512c9e..0000000000 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/internal/BasePayloadTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.internal; - -import static org.jclouds.reflect.Reflection2.method; - -import java.net.URI; -import java.util.List; - -import org.jclouds.reflect.Invocation; -import org.jclouds.rest.internal.GeneratedHttpRequest; -import org.jclouds.vcloud.VCloudApiMetadata; -import org.nnsoft.guice.rocoto.Rocoto; -import org.nnsoft.guice.rocoto.configuration.ConfigurationModule; - -import com.google.common.base.Throwables; -import com.google.inject.Guice; -import com.google.inject.Injector; - -public class BasePayloadTest { - - protected Injector injector = Guice.createInjector(Rocoto.expandVariables(new ConfigurationModule() { - protected void bindConfigurations() { - bindProperties(new VCloudApiMetadata().getDefaultProperties()); - } - })); - - protected GeneratedHttpRequest requestForArgs(List args) { - try { - Invocation invocation = Invocation.create(method(String.class, "toString"), args); - return GeneratedHttpRequest.builder().method("POST").endpoint(URI.create("http://localhost/key")) - .invocation(invocation).build(); - } catch (SecurityException e) { - throw Throwables.propagate(e); - } - } -} diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/internal/BaseVCloudApiLiveTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/internal/BaseVCloudApiLiveTest.java deleted file mode 100644 index a4db473f55..0000000000 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/internal/BaseVCloudApiLiveTest.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.internal; - -import org.jclouds.compute.ComputeService; -import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest; -import org.jclouds.sshj.config.SshjSshClientModule; -import org.jclouds.vcloud.VCloudApi; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -import com.google.inject.Module; - -@Test(groups = "live", enabled = true, singleThreaded = true) -public abstract class BaseVCloudApiLiveTest extends BaseComputeServiceContextLiveTest { - - // username is too long for name constraints - protected String prefix = "vcd"; - - protected ComputeService client; - - public BaseVCloudApiLiveTest() { - provider = "vcloud"; - } - - protected VCloudApi getVCloudApi() { - return view.unwrapApi(VCloudApi.class); - } - - @Override - @BeforeClass(groups = { "integration", "live" }) - public void setupContext() { - super.setupContext(); - client = view.getComputeService(); - } - - @Override - protected Module getSshModule() { - return new SshjSshClientModule(); - } -} diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/internal/BaseVCloudApiTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/internal/BaseVCloudApiTest.java deleted file mode 100644 index feeec7c828..0000000000 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/internal/BaseVCloudApiTest.java +++ /dev/null @@ -1,270 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.internal; - -import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL; -import static org.testng.Assert.assertEquals; - -import java.net.URI; -import java.util.Map; -import java.util.concurrent.atomic.AtomicReference; - -import javax.inject.Inject; -import javax.inject.Named; -import javax.inject.Singleton; - -import org.jclouds.http.HttpRequest; -import org.jclouds.ovf.Envelope; -import org.jclouds.ovf.xml.EnvelopeHandlerTest; -import org.jclouds.providers.AnonymousProviderMetadata; -import org.jclouds.providers.ProviderMetadata; -import org.jclouds.rest.AuthorizationException; -import org.jclouds.rest.ConfiguresHttpApi; -import org.jclouds.rest.internal.BaseRestAnnotationProcessingTest; -import org.jclouds.vcloud.VCloudApiMetadata; -import org.jclouds.vcloud.VCloudMediaType; -import org.jclouds.vcloud.VCloudVersionsApi; -import org.jclouds.vcloud.config.VCloudHttpApiModule; -import org.jclouds.vcloud.domain.AllocationModel; -import org.jclouds.vcloud.domain.CatalogItem; -import org.jclouds.vcloud.domain.Org; -import org.jclouds.vcloud.domain.ReferenceType; -import org.jclouds.vcloud.domain.Task; -import org.jclouds.vcloud.domain.VAppTemplate; -import org.jclouds.vcloud.domain.VCloudSession; -import org.jclouds.vcloud.domain.VDC; -import org.jclouds.vcloud.domain.VDCStatus; -import org.jclouds.vcloud.domain.internal.CatalogImpl; -import org.jclouds.vcloud.domain.internal.CatalogItemImpl; -import org.jclouds.vcloud.domain.internal.OrgImpl; -import org.jclouds.vcloud.domain.internal.ReferenceTypeImpl; -import org.jclouds.vcloud.domain.internal.VDCImpl; -import org.jclouds.vcloud.filters.AddVCloudAuthorizationAndCookieToRequest; -import org.jclouds.vcloud.xml.VAppTemplateHandlerTest; -import org.testng.annotations.Test; - -import com.google.common.base.Functions; -import com.google.common.base.Supplier; -import com.google.common.base.Suppliers; -import com.google.common.cache.CacheLoader; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; -import com.google.inject.AbstractModule; -import com.google.inject.Module; -import com.google.inject.TypeLiteral; - -/** - * Tests behavior of {@code VCloudApi} - */ -// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire -@Test(groups = "unit", testName = "BaseVCloudApiTest") -public abstract class BaseVCloudApiTest extends BaseRestAnnotationProcessingTest { - - @Override - protected void checkFilters(HttpRequest request) { - assertEquals(request.getFilters().size(), 1); - assertEquals(request.getFilters().get(0).getClass(), AddVCloudAuthorizationAndCookieToRequest.class); - } - - @Override - protected Module createModule() { - return new VCloudHttpApiModuleExtension(); - } - - @Override - protected ProviderMetadata createProviderMetadata() { - return AnonymousProviderMetadata.forApiWithEndpoint(new VCloudApiMetadata(), "https://vcenterprise.bluelock.com/api/v1.0"); - } - - protected static final ReferenceTypeImpl ORG_REF = new ReferenceTypeImpl("org", VCloudMediaType.ORG_XML, - URI.create("https://vcenterprise.bluelock.com/api/v1.0/org/1")); - - protected static final ReferenceTypeImpl CATALOG_REF = new ReferenceTypeImpl("catalog", VCloudMediaType.CATALOG_XML, - URI.create("https://vcenterprise.bluelock.com/api/v1.0/catalog/1")); - - protected static final ReferenceTypeImpl TASKSLIST_REF = new ReferenceTypeImpl("tasksList", - VCloudMediaType.TASKSLIST_XML, URI.create("https://vcenterprise.bluelock.com/api/v1.0/tasksList/1")); - - protected static final ReferenceTypeImpl VDC_REF = new ReferenceTypeImpl("vdc", VCloudMediaType.VDC_XML, - URI.create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1")); - - protected static final ReferenceTypeImpl NETWORK_REF = new ReferenceTypeImpl("network", VCloudMediaType.NETWORK_XML, - URI.create("https://vcloud.safesecureweb.com/network/1990")); - - protected static final Org ORG = new OrgImpl(ORG_REF.getName(), ORG_REF.getType(), ORG_REF.getHref(), "org", null, - ImmutableMap. of(CATALOG_REF.getName(), CATALOG_REF), - ImmutableMap. of(VDC_REF.getName(), VDC_REF), ImmutableMap. of( - NETWORK_REF.getName(), NETWORK_REF), TASKSLIST_REF, ImmutableList. of()); - - protected static final VDC VDC = new VDCImpl(VDC_REF.getName(), VDC_REF.getType(), VDC_REF.getHref(), - VDCStatus.READY, null, "description", ImmutableSet. of(), AllocationModel.ALLOCATION_POOL, null, null, - null, ImmutableMap. of( - "vapp", - new ReferenceTypeImpl("vapp", "application/vnd.vmware.vcloud.vApp+xml", URI - .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/188849-1")), - "network", - new ReferenceTypeImpl("network", "application/vnd.vmware.vcloud.vAppTemplate+xml", URI - .create("https://vcenterprise.bluelock.com/api/v1.0/vdcItem/2"))), - ImmutableMap. of(NETWORK_REF.getName(), NETWORK_REF), 0, 0, 0, false); - - @ConfiguresHttpApi - public static class VCloudHttpApiModuleExtension extends VCloudHttpApiModule { - - @Override - protected Supplier provideAuthenticationURI(VCloudVersionsApi versionService, String version) { - return Suppliers.ofInstance(URI.create("https://vcenterprise.bluelock.com/api/v1.0/login")); - } - - @Override - protected Supplier provideOrg(Supplier> orgSupplier, - @org.jclouds.vcloud.endpoints.Org Supplier defaultOrg) { - return Suppliers.ofInstance(ORG); - } - - @Override - protected void installDefaultVCloudEndpointsModule() { - install(new AbstractModule() { - - @Override - protected void configure() { - TypeLiteral> refTypeSupplier = new TypeLiteral>() { - }; - bind(refTypeSupplier).annotatedWith(org.jclouds.vcloud.endpoints.Org.class).toInstance( - Suppliers. ofInstance(ORG_REF)); - bind(refTypeSupplier).annotatedWith(org.jclouds.vcloud.endpoints.Catalog.class).toInstance( - Suppliers. ofInstance(CATALOG_REF)); - bind(refTypeSupplier).annotatedWith(org.jclouds.vcloud.endpoints.TasksList.class).toInstance( - Suppliers. ofInstance(TASKSLIST_REF)); - bind(refTypeSupplier).annotatedWith(org.jclouds.vcloud.endpoints.VDC.class).toInstance( - Suppliers. ofInstance(VDC_REF)); - bind(refTypeSupplier).annotatedWith(org.jclouds.vcloud.endpoints.Network.class).toInstance( - Suppliers. ofInstance(NETWORK_REF)); - } - - }); - } - - @Override - protected Supplier provideVCloudTokenCache(@Named(PROPERTY_SESSION_INTERVAL) long seconds, - AtomicReference authException, final VCloudLoginApi login) { - return Suppliers. ofInstance(new VCloudSession() { - - @Override - public Map getOrgs() { - return ImmutableMap. of(ORG_REF.getName(), ORG_REF); - } - - @Override - public String getVCloudToken() { - return "token"; - } - - }); - - } - - @Override - protected void configure() { - super.configure(); - bind(OrgMapSupplier.class).to(TestOrgMapSupplier.class); - bind(OrgCatalogSupplier.class).to(TestOrgCatalogSupplier.class); - bind(OrgCatalogItemSupplier.class).to(TestOrgCatalogItemSupplier.class); - } - - @SuppressWarnings("unchecked") - @Override - protected void bindCacheLoaders() { - bind(new TypeLiteral>() { - }).toInstance(CacheLoader.class.cast(CacheLoader.from(Functions.constant(VAppTemplateHandlerTest.parseTemplate())))); - - bind(new TypeLiteral>() { - }).toInstance(CacheLoader.class.cast(CacheLoader.from(Functions.constant(EnvelopeHandlerTest.parseEnvelope())))); - } - - @Override - protected Supplier>> provideOrgVDCSupplierCache( - @Named(PROPERTY_SESSION_INTERVAL) long seconds, AtomicReference authException, - OrgVDCSupplier supplier) { - return Suppliers.>> ofInstance(ImmutableMap - .> of(ORG_REF.getName(), - ImmutableMap. of(VDC.getName(), VDC))); - } - - @Singleton - public static class TestOrgMapSupplier extends OrgMapSupplier { - - @Inject - protected TestOrgMapSupplier() { - super(null, null); - } - - @Override - public Map get() { - return ImmutableMap. of(ORG.getName(), ORG); - } - } - - @Singleton - public static class TestOrgCatalogSupplier extends OrgCatalogSupplier { - @Inject - protected TestOrgCatalogSupplier() { - super(null, null); - } - - @Override - public Map> get() { - return ImmutableMap.> of( - ORG_REF.getName(), ImmutableMap. of( - CATALOG_REF.getName(), - new CatalogImpl(CATALOG_REF.getName(), CATALOG_REF.getType(), CATALOG_REF.getHref(), null, - "description", ImmutableMap. of( - "item", - new ReferenceTypeImpl("item", "application/vnd.vmware.vcloud.catalogItem+xml", URI - .create("https://vcenterprise.bluelock.com/api/v1.0/catalogItem/1")), - "template", - new ReferenceTypeImpl("template", "application/vnd.vmware.vcloud.vAppTemplate+xml", - URI.create("https://vcenterprise.bluelock.com/api/v1.0/catalogItem/2"))), - ImmutableList. of(), true, false))); - } - } - - @Singleton - public static class TestOrgCatalogItemSupplier extends OrgCatalogItemSupplier { - protected TestOrgCatalogItemSupplier() { - super(null, null); - } - - @Override - public Map>> get() { - return ImmutableMap.>> of( - ORG_REF.getName(), ImmutableMap - .> of(CATALOG_REF - .getName(), ImmutableMap. of( - "template", - new CatalogItemImpl("template", URI - .create("https://vcenterprise.bluelock.com/api/v1.0/catalogItem/2"), "description", - new ReferenceTypeImpl("template", "application/vnd.vmware.vcloud.vAppTemplate+xml", - URI.create("https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/2")), - ImmutableMap. of())))); - - } - } - - } - -} diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/internal/VCloudLoginApiTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/internal/VCloudLoginApiTest.java deleted file mode 100644 index c2896dc367..0000000000 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/internal/VCloudLoginApiTest.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.internal; - -import static org.jclouds.reflect.Reflection2.method; -import static org.testng.Assert.assertEquals; - -import java.io.IOException; -import java.net.URI; - -import org.jclouds.http.HttpRequest; -import org.jclouds.http.filters.BasicAuthentication; -import org.jclouds.location.Provider; -import org.jclouds.providers.AnonymousProviderMetadata; -import org.jclouds.providers.ProviderMetadata; -import org.jclouds.rest.internal.BaseRestAnnotationProcessingTest; -import org.jclouds.rest.internal.GeneratedHttpRequest; -import org.jclouds.vcloud.endpoints.VCloudLogin; -import org.jclouds.vcloud.functions.ParseLoginResponseFromHeaders; -import org.testng.annotations.Test; - -import com.google.common.base.Supplier; -import com.google.common.collect.ImmutableList; -import com.google.common.net.HttpHeaders; -import com.google.common.reflect.Invokable; -import com.google.inject.Binder; -import com.google.inject.Module; -import com.google.inject.Provides; -/** - * Tests behavior of {@code VCloudLoginApi} - */ -// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire -@Test(groups = "unit", testName = "VCloudLoginApiTest") -public class VCloudLoginApiTest extends BaseRestAnnotationProcessingTest { - - public void testLogin() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(VCloudLoginApi.class, "login"); - GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.of()); - - assertEquals(request.getRequestLine(), "POST http://localhost:8080/login HTTP/1.1"); - assertNonPayloadHeadersEqual(request, HttpHeaders.ACCEPT + ": application/vnd.vmware.vcloud.orgList+xml\n"); - assertPayloadEquals(request, null, null, false); - - assertResponseParserClassEquals(method, request, ParseLoginResponseFromHeaders.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - @Override - protected void checkFilters(HttpRequest request) { - assertEquals(request.getFilters().size(), 1); - assertEquals(request.getFilters().get(0).getClass(), BasicAuthentication.class); - } - - @Override - protected Module createModule() { - return new Module() { - - @Override - public void configure(Binder binder) { - } - - @Provides - @VCloudLogin - Supplier provideURI(@Provider Supplier uri) { - return uri; - } - - }; - } - - @Override - protected ProviderMetadata createProviderMetadata() { - return AnonymousProviderMetadata.forApiOnEndpoint(VCloudLoginApi.class, - "http://localhost:8080/login"); - } - -} diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/options/InstantiateVAppTemplateOptionsTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/options/InstantiateVAppTemplateOptionsTest.java deleted file mode 100644 index 89942844e8..0000000000 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/options/InstantiateVAppTemplateOptionsTest.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.options; - -import static org.jclouds.vcloud.options.InstantiateVAppTemplateOptions.Builder.addNetworkConfig; -import static org.jclouds.vcloud.options.InstantiateVAppTemplateOptions.Builder.description; -import static org.testng.Assert.assertEquals; - -import java.net.URI; - -import org.jclouds.http.functions.config.SaxParserModule; -import org.jclouds.vcloud.domain.network.FenceMode; -import org.jclouds.vcloud.domain.network.NetworkConfig; -import org.testng.annotations.Test; - -import com.google.common.collect.Iterables; -import com.google.inject.Guice; -import com.google.inject.Injector; - -/** - * Tests behavior of {@code InstantiateVAppTemplateOptions} - */ -@Test(groups = "unit") -public class InstantiateVAppTemplateOptionsTest { - - Injector injector = Guice.createInjector(new SaxParserModule()); - - @Test - public void testAddNetworkConfig() { - InstantiateVAppTemplateOptions options = new InstantiateVAppTemplateOptions(); - options.addNetworkConfig(new NetworkConfig("default", URI.create("http://localhost"), FenceMode.BRIDGED)); - assertEquals(Iterables.get(options.getNetworkConfig(), 0).getNetworkName(), "default"); - assertEquals(Iterables.get(options.getNetworkConfig(), 0).getParentNetwork(), URI.create("http://localhost")); - assertEquals(Iterables.get(options.getNetworkConfig(), 0).getFenceMode(), FenceMode.BRIDGED); - } - - @Test - public void testAddNetworkConfigStatic() { - InstantiateVAppTemplateOptions options = addNetworkConfig(new NetworkConfig("default", - URI.create("http://localhost"), FenceMode.BRIDGED)); - assertEquals(Iterables.get(options.getNetworkConfig(), 0).getNetworkName(), "default"); - assertEquals(Iterables.get(options.getNetworkConfig(), 0).getParentNetwork(), URI.create("http://localhost")); - assertEquals(Iterables.get(options.getNetworkConfig(), 0).getFenceMode(), FenceMode.BRIDGED); - } - - @Test - public void testDescription() { - InstantiateVAppTemplateOptions options = new InstantiateVAppTemplateOptions(); - options.description("foo"); - assertEquals(options.getDescription(), "foo"); - } - - @Test - public void testDescriptionStatic() { - InstantiateVAppTemplateOptions options = description("foo"); - assertEquals(options.getDescription(), "foo"); - } -} diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/suppliers/OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefaultTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/suppliers/OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefaultTest.java deleted file mode 100644 index 4bdb5b8ab6..0000000000 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/suppliers/OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefaultTest.java +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.suppliers; - -import static org.easymock.EasyMock.createMock; -import static org.testng.Assert.assertEquals; - -import java.util.NoSuchElementException; - -import org.jclouds.config.ValueOfConfigurationKeyOrNull; -import org.jclouds.vcloud.domain.ReferenceType; -import org.jclouds.vcloud.domain.internal.ReferenceTypeImpl; -import org.testng.annotations.Test; - -import com.google.common.base.Predicates; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableSet; -import com.google.inject.AbstractModule; -import com.google.inject.Guice; -import com.google.inject.name.Names; - -/** - * Tests behavior of - * {@code OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefault} - */ -// NOTE:without testName, this will not call @Before* and fail w/NPE during -// surefire -@Test(groups = "unit", testName = "OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefaultTest") -public class OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefaultTest { - ValueOfConfigurationKeyOrNull valueOfConfigurationKeyOrNull = Guice.createInjector().getInstance( - ValueOfConfigurationKeyOrNull.class); - - @Test(expectedExceptions = IllegalArgumentException.class) - public void testIllegalArgumentWhenResourcesEmpty() { - new OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefault(valueOfConfigurationKeyOrNull, "foo", - Predicates. alwaysTrue()).apply(ImmutableSet. of()); - } - - @Test - public void testReturnsOnlyResource() { - ReferenceType reference = createMock(ReferenceType.class); - - assertEquals(new OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefault(valueOfConfigurationKeyOrNull, - "foo", Predicates. alwaysTrue()).apply(ImmutableSet. of(reference)), - reference); - - } - - @Test - public void testReturnsFirstResourceWhenConfigurationUnspecified() { - ReferenceType reference1 = createMock(ReferenceType.class); - ReferenceType reference2 = createMock(ReferenceType.class); - - assertEquals(new OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefault(valueOfConfigurationKeyOrNull, - "foo", Predicates. alwaysTrue()).apply(ImmutableList. of(reference1, - reference2)), reference1); - - } - - @Test - public void testReturnsResourceMatchingDefaultPredicateWhenConfigurationUnspecified() { - ReferenceType reference1 = createMock(ReferenceType.class); - ReferenceType reference2 = createMock(ReferenceType.class); - - assertEquals(new OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefault(valueOfConfigurationKeyOrNull, - "foo", Predicates.equalTo(reference2)).apply(ImmutableList. of(reference1, reference2)), - reference2); - - } - - @Test - public void testReturnsResourceWithNameMatchingConfigurationKey() { - ReferenceType reference1 = new ReferenceTypeImpl("travis tritt", null, null); - ReferenceType reference2 = new ReferenceTypeImpl("hail mary", null, null); - - assertEquals( - new OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefault(Guice.createInjector( - new AbstractModule() { - protected void configure() { - bindConstant().annotatedWith(Names.named("foo")).to(".*mary.*"); - } - }).getInstance(ValueOfConfigurationKeyOrNull.class), "foo", Predicates. alwaysTrue()).apply(ImmutableList - . of(reference1, reference2)), reference2); - - } - - @Test(expectedExceptions = NoSuchElementException.class) - public void testThrowsNoSuchElementWhenNoneMatchConfigurationKey() { - ReferenceType reference1 = new ReferenceTypeImpl("travis tritt", null, null); - ReferenceType reference2 = new ReferenceTypeImpl("hail mary", null, null); - - new OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefault(Guice.createInjector(new AbstractModule() { - protected void configure() { - bindConstant().annotatedWith(Names.named("foo")).to(".*happy.*"); - } - }).getInstance(ValueOfConfigurationKeyOrNull.class), "foo", Predicates. alwaysTrue()) - .apply(ImmutableList. of(reference1, reference2)); - } -} diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/utils/TestUtils.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/utils/TestUtils.java deleted file mode 100644 index 9a844ed728..0000000000 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/utils/TestUtils.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.utils; - - -/** - * Utility class for test - */ -public class TestUtils { - public static final Object[][] NO_INVOCATIONS = new Object[0][0]; - public static final Object[][] SINGLE_NO_ARG_INVOCATION = { new Object[0] }; - - public static boolean isWindowsOs() { - return System.getProperty("os.name", "").toLowerCase().contains("windows"); - } -} diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/xml/CatalogHandlerTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/xml/CatalogHandlerTest.java deleted file mode 100644 index 2a883e61bb..0000000000 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/xml/CatalogHandlerTest.java +++ /dev/null @@ -1,133 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.xml; - -import static org.jclouds.vcloud.VCloudMediaType.CATALOGITEM_XML; -import static org.testng.Assert.assertEquals; - -import java.io.InputStream; -import java.net.URI; - -import org.jclouds.http.functions.ParseSax; -import org.jclouds.http.functions.ParseSax.Factory; -import org.jclouds.http.functions.config.SaxParserModule; -import org.jclouds.vcloud.domain.Catalog; -import org.jclouds.vcloud.domain.ReferenceType; -import org.jclouds.vcloud.domain.Task; -import org.jclouds.vcloud.domain.internal.CatalogImpl; -import org.jclouds.vcloud.domain.internal.ReferenceTypeImpl; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; -import com.google.inject.Guice; -import com.google.inject.Injector; - -/** - * Tests behavior of {@code CatalogHandler} - */ -@Test(groups = "unit") -public class CatalogHandlerTest { - - private Injector injector; - - private Factory factory; - - public void testVCloud1_0() { - InputStream is = getClass().getResourceAsStream("/catalog-blank.xml"); - injector = Guice.createInjector(new SaxParserModule()); - factory = injector.getInstance(ParseSax.Factory.class); - Catalog result = factory.create(injector.getInstance(CatalogHandler.class)).parse(is); - assertEquals(result, new CatalogImpl("Jclouds-private", "application/vnd.vmware.vcloud.catalog+xml", URI - .create("https://vcenterprise.bluelock.com/api/v1.0/catalog/921222081"), new ReferenceTypeImpl(null, - "application/vnd.vmware.vcloud.org+xml", URI - .create("https://vcenterprise.bluelock.com/api/v1.0/org/9566014")), null, ImmutableMap - . of(), ImmutableList. of(), false, false)); - } - - public void testTerremark() { - InputStream is = getClass().getResourceAsStream("/catalog.xml"); - injector = Guice.createInjector(new SaxParserModule()); - factory = injector.getInstance(ParseSax.Factory.class); - Catalog result = factory.create(injector.getInstance(CatalogHandler.class)).parse(is); - assertEquals(result.getName(), "Miami Environment 1"); - assert result.getDescription() == null; - - assertEquals(result.getHref(), URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/32/catalog")); - assertEquals(result.get("CentOS 5.3 (32-bit)"), new ReferenceTypeImpl("CentOS 5.3 (32-bit)", CATALOGITEM_XML, URI - .create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/5"))); - assertEquals(result.get("CentOS 5.3 (64-bit)"), new ReferenceTypeImpl("CentOS 5.3 (64-bit)", CATALOGITEM_XML, URI - .create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/6"))); - assertEquals(result.get("RHEL 5.3 (32-bit)"), new ReferenceTypeImpl("RHEL 5.3 (32-bit)", CATALOGITEM_XML, URI - .create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/7"))); - assertEquals(result.get("RHEL 5.3 (64-bit)"), new ReferenceTypeImpl("RHEL 5.3 (64-bit)", CATALOGITEM_XML, URI - .create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/8"))); - assertEquals(result.get("Ubuntu JeOS 9.04 (32-bit)"), new ReferenceTypeImpl("Ubuntu JeOS 9.04 (32-bit)", - CATALOGITEM_XML, URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/11"))); - assertEquals(result.get("Ubuntu JeOS 9.04 (64-bit)"), new ReferenceTypeImpl("Ubuntu JeOS 9.04 (64-bit)", - CATALOGITEM_XML, URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/12"))); - assertEquals(result.get("Ubuntu Server 9.04 (32-bit)"), new ReferenceTypeImpl("Ubuntu Server 9.04 (32-bit)", - CATALOGITEM_XML, URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/9"))); - assertEquals(result.get("Ubuntu Server 9.04 (64-bit)"), new ReferenceTypeImpl("Ubuntu Server 9.04 (64-bit)", - CATALOGITEM_XML, URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/10"))); - assertEquals(result.get("Windows 2003 Enterprise R2 (32-bit)"), new ReferenceTypeImpl( - "Windows 2003 Enterprise R2 (32-bit)", CATALOGITEM_XML, URI - .create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/1"))); - assertEquals(result.get("Windows 2003 Enterprise R2 (64-bit)"), new ReferenceTypeImpl( - "Windows 2003 Enterprise R2 (64-bit)", CATALOGITEM_XML, URI - .create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/2"))); - assertEquals(result.get("Windows 2003 Standard R2 (32-bit)"), new ReferenceTypeImpl( - "Windows 2003 Standard R2 (32-bit)", CATALOGITEM_XML, URI - .create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/3"))); - assertEquals(result.get("Windows 2003 Standard R2 (64-bit)"), new ReferenceTypeImpl( - "Windows 2003 Standard R2 (64-bit)", CATALOGITEM_XML, URI - .create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/4"))); - assertEquals(result.get("Windows 2003 Standard R2 w.SQL 2008 Web (64-bit)"), new ReferenceTypeImpl( - "Windows 2003 Standard R2 w.SQL 2008 Web (64-bit)", CATALOGITEM_XML, URI - .create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/23"))); - assertEquals(result.get("Windows Server 2008 Enterprise (32-bit)"), new ReferenceTypeImpl( - "Windows Server 2008 Enterprise (32-bit)", CATALOGITEM_XML, URI - .create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/13"))); - assertEquals(result.get("Windows Server 2008 Enterprise (64-bit)"), new ReferenceTypeImpl( - "Windows Server 2008 Enterprise (64-bit)", CATALOGITEM_XML, URI - .create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/15"))); - assertEquals(result.get("Windows Server 2008 Enterprise R2 (64-bit)"), new ReferenceTypeImpl( - "Windows Server 2008 Enterprise R2 (64-bit)", CATALOGITEM_XML, URI - .create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/16"))); - assertEquals(result.get("Windows Server 2008 Standard (32-bit)"), new ReferenceTypeImpl( - "Windows Server 2008 Standard (32-bit)", CATALOGITEM_XML, URI - .create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/17"))); - assertEquals(result.get("Windows Server 2008 Standard (64-bit)"), new ReferenceTypeImpl( - "Windows Server 2008 Standard (64-bit)", CATALOGITEM_XML, URI - .create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/18"))); - assertEquals(result.get("Windows Server 2008 Standard R2 (64-bit)"), new ReferenceTypeImpl( - "Windows Server 2008 Standard R2 (64-bit)", CATALOGITEM_XML, URI - .create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/19"))); - assertEquals(result.get("Windows Server 2008 Standard w.SQL 2008 Web (64-bit)"), new ReferenceTypeImpl( - "Windows Server 2008 Standard w.SQL 2008 Web (64-bit)", CATALOGITEM_XML, URI - .create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/14"))); - assertEquals(result.get("Windows Web Server 2008 (32-bit)"), new ReferenceTypeImpl( - "Windows Web Server 2008 (32-bit)", CATALOGITEM_XML, URI - .create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/20"))); - assertEquals(result.get("Windows Web Server 2008 (64-bit)"), new ReferenceTypeImpl( - "Windows Web Server 2008 (64-bit)", CATALOGITEM_XML, URI - .create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/21"))); - assertEquals(result.get("Windows Web Server 2008 R2 (64-bit)"), new ReferenceTypeImpl( - "Windows Web Server 2008 R2 (64-bit)", CATALOGITEM_XML, URI - .create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/22"))); - } -} diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/xml/CatalogItemHandlerTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/xml/CatalogItemHandlerTest.java deleted file mode 100644 index 6f2b100860..0000000000 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/xml/CatalogItemHandlerTest.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.xml; - -import static org.testng.Assert.assertEquals; - -import java.io.InputStream; -import java.net.URI; - -import org.jclouds.http.functions.ParseSax; -import org.jclouds.http.functions.ParseSax.Factory; -import org.jclouds.http.functions.config.SaxParserModule; -import org.jclouds.vcloud.domain.CatalogItem; -import org.jclouds.vcloud.domain.internal.CatalogItemImpl; -import org.jclouds.vcloud.domain.internal.ReferenceTypeImpl; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableSortedMap; -import com.google.inject.Guice; -import com.google.inject.Injector; - -/** - * Tests behavior of {@code CatalogItemHandler} - */ -@Test(groups = "unit") -public class CatalogItemHandlerTest { - - public void testApplyInputStream() { - InputStream is = getClass().getResourceAsStream("/catalogItem-hosting.xml"); - Injector injector = Guice.createInjector(new SaxParserModule()); - Factory factory = injector.getInstance(ParseSax.Factory.class); - CatalogItem result = factory.create(injector.getInstance(CatalogItemHandler.class)).parse(is); - - assertEquals(result, new CatalogItemImpl("Windows 2008 Datacenter 64 Bit", URI - .create("https://vcloud.safesecureweb.com/api/v0.8/catalogItem/2"), "Windows 2008 Datacenter 64 Bit", - new ReferenceTypeImpl("Windows 2008 Datacenter 64 Bit", - "application/vnd.vmware.vcloud.vAppTemplate+xml", URI - .create("https://vcloud.safesecureweb.com/api/v0.8/vAppTemplate/2")), - ImmutableSortedMap.of("Foo", "Bar", "Hello", "World" - - ))); - - } - - public void testApplyInputStreamWithNamespaceUsingVcloud() { - InputStream is = getClass().getResourceAsStream("/catalogItem-carrenza-with-vcloud-namespace.xml"); - Injector injector = Guice.createInjector(new SaxParserModule()); - Factory factory = injector.getInstance(ParseSax.Factory.class); - CatalogItem result = factory.create(injector.getInstance(CatalogItemHandler.class)).parse(is); - - assertEquals(result, new CatalogItemImpl("ubuntu10.10x64", - URI.create("https://myvdc.carrenza.net/api/v1.0/catalogItem/ecd4d3a0-0d12-4195-a6d2-14cdf9f925a3"), - null, new ReferenceTypeImpl("ubuntu10.10x64", "application/vnd.vmware.vcloud.vAppTemplate+xml", - URI.create("https://myvdc.carrenza.net/api/v1.0/vAppTemplate/vappTemplate-123766ea-2b55-482c-8adf-735ab1952834")), - ImmutableSortedMap.of())); - } - - public void testApplyInputStreamWithNamespaceUsingDefault() { - InputStream is = getClass().getResourceAsStream("/catalogItem-carrenza-with-default-namespace.xml"); - Injector injector = Guice.createInjector(new SaxParserModule()); - Factory factory = injector.getInstance(ParseSax.Factory.class); - CatalogItem result = factory.create(injector.getInstance(CatalogItemHandler.class)).parse(is); - - assertEquals(result, new CatalogItemImpl("ubuntu10.10x64", - URI.create("https://myvdc.carrenza.net/api/v1.0/catalogItem/ecd4d3a0-0d12-4195-a6d2-14cdf9f925a3"), - null, new ReferenceTypeImpl("ubuntu10.10x64", "application/vnd.vmware.vcloud.vAppTemplate+xml", - URI.create("https://myvdc.carrenza.net/api/v1.0/vAppTemplate/vappTemplate-123766ea-2b55-482c-8adf-735ab1952834")), - ImmutableSortedMap.of())); - } -} diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/xml/GuestCustomizationSectionHandlerTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/xml/GuestCustomizationSectionHandlerTest.java deleted file mode 100644 index 503611eb68..0000000000 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/xml/GuestCustomizationSectionHandlerTest.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.xml; - -import static org.testng.Assert.assertEquals; - -import java.io.InputStream; -import java.net.URI; -import java.net.UnknownHostException; - -import org.jclouds.http.functions.BaseHandlerTest; -import org.jclouds.vcloud.VCloudMediaType; -import org.jclouds.vcloud.domain.GuestCustomizationSection; -import org.jclouds.vcloud.domain.internal.ReferenceTypeImpl; -import org.testng.annotations.Test; - -/** - * Tests behavior of {@code GuestCustomizationSectionHandler} - */ -// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire -@Test(groups = "unit", testName = "GuestCustomizationSectionHandlerTest") -public class GuestCustomizationSectionHandlerTest extends BaseHandlerTest { - - public void testDefault() throws UnknownHostException { - InputStream is = getClass().getResourceAsStream("/guestCustomization.xml"); - - GuestCustomizationSection result = factory.create(injector.getInstance(GuestCustomizationSectionHandler.class)) - .parse(is); - - checkGuestCustomization(result); - - } - - @Test(enabled = false) - public static void checkGuestCustomization(GuestCustomizationSection result) { - assertEquals(result.getType(), VCloudMediaType.GUESTCUSTOMIZATIONSECTION_XML); - assertEquals(result.getHref(), - URI.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/vm-2087535248/guestCustomizationSection/")); - assertEquals(result.getInfo(), "Specifies Guest OS Customization Settings"); - assertEquals(result.isEnabled(), Boolean.TRUE); - assertEquals(result.shouldChangeSid(), Boolean.FALSE); - assertEquals(result.getVirtualMachineId(), "2087535248"); - assertEquals(result.isJoinDomainEnabled(), Boolean.FALSE); - assertEquals(result.useOrgSettings(), Boolean.FALSE); - assertEquals(result.getDomainName(), null); - assertEquals(result.getDomainUserName(), null); - assertEquals(result.getDomainUserPassword(), null); - assertEquals(result.isAdminPasswordEnabled(), Boolean.TRUE); - assertEquals(result.isAdminPasswordAuto(), Boolean.TRUE); - assertEquals(result.getAdminPassword(), null); - assertEquals(result.isResetPasswordRequired(), Boolean.FALSE); - assertEquals(result.getCustomizationScript(), "cat > /root/foo.txt< of(), ImmutableMap. of("GravDataCenter1(Saved)", - new ReferenceTypeImpl("GravDataCenter1(Saved)", "application/vnd.vmware.vcloud.vdc+xml", URI - .create("https://api.symphonyVPDC.savvis.net/rest/api/v0.8/org/607968.0/vdc/2826"))), - ImmutableMap. of(), null, ImmutableSet. of())); - - } -} diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/xml/OrgListHandlerTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/xml/OrgListHandlerTest.java deleted file mode 100644 index 68bf197f5d..0000000000 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/xml/OrgListHandlerTest.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.xml; - -import static org.testng.Assert.assertEquals; - -import java.io.InputStream; -import java.net.URI; -import java.util.Map; - -import org.jclouds.http.functions.BaseHandlerTest; -import org.jclouds.vcloud.domain.ReferenceType; -import org.jclouds.vcloud.domain.internal.ReferenceTypeImpl; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableMap; - -/** - * Tests behavior of {@code OrgListHandler} - */ -// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire -@Test(groups = "unit", testName = "OrgListHandlerTest") -public class OrgListHandlerTest extends BaseHandlerTest { - - public void testApplyInputStream() { - InputStream is = getClass().getResourceAsStream("/orglist.xml"); - - Map result = factory.create(injector.getInstance(OrgListHandler.class)).parse(is); - assertEquals(result, ImmutableMap.of("adrian@jclouds.org", new ReferenceTypeImpl("adrian@jclouds.org", - "application/vnd.vmware.vcloud.org+xml", URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/org/48")))); - } - - - public void testSavvis() { - InputStream is = getClass().getResourceAsStream("/orglist-savvis.xml"); - - Map result = factory.create(injector.getInstance(OrgListHandler.class)).parse(is); - assertEquals(result, ImmutableMap.of("SAVVISStation Integration Testing", new ReferenceTypeImpl("SAVVISStation Integration Testing", - "application/vnd.vmware.vcloud.org+xml", URI.create("https://api.sandbox.symphonyvpdc.savvis.net/rest/api/v0.8/org/100000.0")))); - } -} diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/xml/OrgNetworkHandlerTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/xml/OrgNetworkHandlerTest.java deleted file mode 100644 index 22b81c692f..0000000000 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/xml/OrgNetworkHandlerTest.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.xml; - -import static org.testng.Assert.assertEquals; - -import java.io.InputStream; -import java.net.URI; - -import org.jclouds.http.functions.ParseSax; -import org.jclouds.http.functions.ParseSax.Factory; -import org.jclouds.http.functions.config.SaxParserModule; -import org.jclouds.vcloud.VCloudMediaType; -import org.jclouds.vcloud.domain.internal.ReferenceTypeImpl; -import org.jclouds.vcloud.domain.network.DhcpService; -import org.jclouds.vcloud.domain.network.FenceMode; -import org.jclouds.vcloud.domain.network.IpRange; -import org.jclouds.vcloud.domain.network.IpScope; -import org.jclouds.vcloud.domain.network.OrgNetwork; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableSet; -import com.google.inject.Guice; -import com.google.inject.Injector; - -/** - * Tests behavior of {@code OrgNetworkHandler} - */ -@Test(groups = "unit") -public class OrgNetworkHandlerTest { - public void testIsolated() { - InputStream is = getClass().getResourceAsStream("/orgnetwork-isolated.xml"); - Injector injector = Guice.createInjector(new SaxParserModule()); - Factory factory = injector.getInstance(ParseSax.Factory.class); - OrgNetwork result = factory.create(injector.getInstance(OrgNetworkHandler.class)).parse(is); - assertEquals(result.getName(), "isolation01"); - assertEquals(result.getHref(), URI.create("https://vcenterprise.bluelock.com/api/v1.0/network/990419644")); - assertEquals(result.getType(), "application/vnd.vmware.vcloud.network+xml"); - assertEquals(result.getOrg(), new ReferenceTypeImpl(null, VCloudMediaType.ORG_XML, URI - .create("https://vcenterprise.bluelock.com/api/v1.0/org/9566014"))); - assertEquals(result.getDescription(), null); - assertEquals(result.getTasks(), ImmutableList.of()); - assert result.getConfiguration() != null; - - assertEquals(result.getConfiguration().getIpScope(), new IpScope(false, "192.168.15.1", "255.255.255.0", - "23.172.173.113", null, null, - ImmutableSet. of(new IpRange("192.168.15.100", "192.168.15.199")), ImmutableSet. of())); - assertEquals(result.getConfiguration().getParentNetwork(), null); - assertEquals(result.getConfiguration().getFenceMode(), FenceMode.ISOLATED); - assert result.getConfiguration().getFeatures() != null; - - assertEquals(result.getConfiguration().getFeatures().getDhcpService(), new DhcpService(false, 3600, 7200, - new IpRange("192.168.15.2", "192.168.15.99"))); - assertEquals(result.getConfiguration().getFeatures().getFirewallService(), null); - assertEquals(result.getConfiguration().getFeatures().getNatService(), null); - - assertEquals(result.getNetworkPool(), null); - assertEquals(result.getAllowedExternalIpAddresses(), ImmutableSet. of()); - - } - - public void testBridged() { - InputStream is = getClass().getResourceAsStream("/orgnetwork-bridged.xml"); - Injector injector = Guice.createInjector(new SaxParserModule()); - Factory factory = injector.getInstance(ParseSax.Factory.class); - OrgNetwork result = factory.create(injector.getInstance(OrgNetworkHandler.class)).parse(is); - assertEquals(result.getName(), "internet01"); - assertEquals(result.getHref(), URI.create("https://vcenterprise.bluelock.com/api/v1.0/network/758634723")); - assertEquals(result.getType(), "application/vnd.vmware.vcloud.network+xml"); - assertEquals(result.getOrg(), new ReferenceTypeImpl(null, VCloudMediaType.ORG_XML, URI - .create("https://vcenterprise.bluelock.com/api/v1.0/org/9566014"))); - assertEquals(result.getDescription(), null); - assertEquals(result.getTasks(), ImmutableList.of()); - assert result.getConfiguration() != null; - - assertEquals(result.getConfiguration().getIpScope(), new IpScope(true, "174.47.101.161", "255.255.255.224", - "24.172.173.113", null, null, - ImmutableSet. of(new IpRange("174.47.101.164", "174.47.101.190")), ImmutableSet. of())); - assertEquals(result.getConfiguration().getParentNetwork(), null); - assertEquals(result.getConfiguration().getFenceMode(), FenceMode.BRIDGED); - assert result.getConfiguration().getFeatures() == null; - assertEquals(result.getNetworkPool(), null); - assertEquals(result.getAllowedExternalIpAddresses(), ImmutableSet. of()); - - } - -} diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/xml/SupportedVersionsHandlerTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/xml/SupportedVersionsHandlerTest.java deleted file mode 100644 index c264c60ad4..0000000000 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/xml/SupportedVersionsHandlerTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.xml; - -import static org.testng.Assert.assertEquals; - -import java.io.InputStream; -import java.net.URI; -import java.util.SortedMap; - -import org.jclouds.http.functions.ParseSax; -import org.jclouds.http.functions.ParseSax.Factory; -import org.jclouds.http.functions.config.SaxParserModule; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableSortedMap; -import com.google.inject.Guice; -import com.google.inject.Injector; - -/** - * Tests behavior of {@code SupportedVersionsHandler} - */ -@Test(groups = "unit") -public class SupportedVersionsHandlerTest { - - public void testApplyInputStream() { - InputStream is = getClass().getResourceAsStream("/versions.xml"); - - Injector injector = Guice.createInjector(new SaxParserModule()); - Factory factory = injector.getInstance(ParseSax.Factory.class); - - SortedMap result = factory.create( - injector.getInstance(SupportedVersionsHandler.class)).parse(is); - assertEquals(result, ImmutableSortedMap.of("0.8", URI - .create("https://services.vcloudexpress.terremark.com/api/v0.8/login"))); - } -} diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/xml/TaskHandlerTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/xml/TaskHandlerTest.java deleted file mode 100644 index f5a4688cdb..0000000000 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/xml/TaskHandlerTest.java +++ /dev/null @@ -1,133 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.xml; - -import static org.testng.Assert.assertEquals; - -import java.io.InputStream; -import java.net.URI; - -import org.jclouds.date.DateService; -import org.jclouds.http.functions.BaseHandlerTest; -import org.jclouds.vcloud.VCloudMediaType; -import org.jclouds.vcloud.domain.Task; -import org.jclouds.vcloud.domain.TaskStatus; -import org.jclouds.vcloud.domain.VCloudError.MinorCode; -import org.jclouds.vcloud.domain.internal.ErrorImpl; -import org.jclouds.vcloud.domain.internal.ReferenceTypeImpl; -import org.jclouds.vcloud.domain.internal.TaskImpl; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.Test; - -/** - * Tests behavior of {@code TaskHandler} - */ -// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire -@Test(groups = "unit", testName = "TaskHandlerTest") -public class TaskHandlerTest extends BaseHandlerTest { - - private DateService dateService; - - @BeforeTest - @Override - protected void setUpInjector() { - super.setUpInjector(); - dateService = injector.getInstance(DateService.class); - } - - public void testHrefWhenTaskElementIsNamespaced() { - InputStream is = getClass().getResourceAsStream("/task-vcd15.xml"); - Task result = factory.create(injector.getInstance(TaskHandler.class)).parse(is); - assertEquals(result.getHref(), URI.create("https://mycloud.greenhousedata.com/api/v1.0/task/77a33fd4-3401-423c-8167-6711fc51ee9a")); - } - - public void test() { - InputStream is = getClass().getResourceAsStream("/task-1.0.xml"); - - Task result = factory.create(injector.getInstance(TaskHandler.class)).parse(is); - - Task expects = new TaskImpl(URI.create("https://vcenterprise.bluelock.com/api/v1.0/task/3cc08ir8oczbze3n1a3"), - "Creating Virtual Application vApp_acole_2(607806320)", TaskStatus.RUNNING, dateService - .iso8601DateParse("2010-08-23T02:09:52.443-04:00"), dateService - .iso8601DateParse("9999-12-31T23:59:59.999-05:00"), dateService - .iso8601DateParse("2010-11-21T02:09:52.443-05:00"), new ReferenceTypeImpl("vApp_acole_2", - VCloudMediaType.VAPP_XML, URI - .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/vapp-607806320")) - - , null - - ); - assertEquals(result, expects); - - } - - public void testTerremark() { - InputStream is = getClass().getResourceAsStream("/task.xml"); - - Task result = factory.create(injector.getInstance(TaskHandler.class)).parse(is); - Task expects = new TaskImpl(URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/task/3299"), null, - TaskStatus.SUCCESS, dateService.iso8601DateParse("2009-08-24T21:29:32.983Z"), dateService - .iso8601DateParse("2009-08-24T21:29:44.65Z"), null, new ReferenceTypeImpl("Server1", - VCloudMediaType.VAPP_XML, URI - .create("https://services.vcloudexpress.terremark.com/api/v0.8/vapp/4012")), null - - ); - assertEquals(result, expects); - - } - - public void testSelf() { - InputStream is = getClass().getResourceAsStream("/task-self.xml"); - - Task result = factory.create(injector.getInstance(TaskHandler.class)).parse(is); - - Task expects = new TaskImpl(URI.create("https://vcloud.safesecureweb.com/api/v0.8/task/d188849-78"), null, - TaskStatus.QUEUED, null, null, null, null, null); - assertEquals(result, expects); - - } - - public void testApplyInputStream2() { - InputStream is = getClass().getResourceAsStream("/task-hosting.xml"); - - Task result = factory.create(injector.getInstance(TaskHandler.class)).parse(is); - - Task expects = new TaskImpl(URI.create("https://vcloud.safesecureweb.com/api/v0.8/task/97806"), null, - TaskStatus.SUCCESS, dateService.iso8601SecondsDateParse("2010-01-14T20:04:51Z"), dateService - .iso8601SecondsDateParse("2010-01-14T20:05:02Z"), dateService - .iso8601SecondsDateParse("2010-01-15T20:05:02Z"), - - new ReferenceTypeImpl("188849-96", VCloudMediaType.VAPP_XML, URI - .create("https://vcloud.safesecureweb.com/api/v0.8/vapp/188849-96")), null); - assertEquals(result, expects); - } - - public void testError() { - InputStream is = getClass().getResourceAsStream("/task-error.xml"); - - Task result = factory.create(injector.getInstance(TaskHandler.class)).parse(is); - - Task expects = new TaskImpl(URI.create("http://10.150.4.49/api/v0.8/task/23"), null, TaskStatus.ERROR, - dateService.iso8601SecondsDateParse("2009-12-07T19:05:02Z"), dateService - .iso8601SecondsDateParse("2009-12-10T14:40:32Z"), null, new ReferenceTypeImpl("testapp1", - VCloudMediaType.VAPP_XML, URI.create("http://10.150.4.49/api/v0.8/vapp/1")), new ErrorImpl( - "Error processing job", 500, MinorCode.UNRECOGNIZED, - " Error in runDailySummaries date used:2009-12-09 19:40:30.577326+00:00", null)); - assertEquals(result, expects); - - } -} diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/xml/TasksListHandlerTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/xml/TasksListHandlerTest.java deleted file mode 100644 index 24552b0300..0000000000 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/xml/TasksListHandlerTest.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.xml; - -import static org.testng.Assert.assertEquals; - -import java.io.InputStream; -import java.net.URI; - -import org.jclouds.date.DateService; -import org.jclouds.http.functions.BaseHandlerTest; -import org.jclouds.vcloud.VCloudMediaType; -import org.jclouds.vcloud.domain.Task; -import org.jclouds.vcloud.domain.TaskStatus; -import org.jclouds.vcloud.domain.TasksList; -import org.jclouds.vcloud.domain.internal.ReferenceTypeImpl; -import org.jclouds.vcloud.domain.internal.TaskImpl; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableSortedSet; - -/** - * Tests behavior of {@code TasksListHandler} - */ -// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire -@Test(groups = "unit", testName = "TasksListHandlerTest") -public class TasksListHandlerTest extends BaseHandlerTest { - - private DateService dateService; - - @BeforeTest - @Override - protected void setUpInjector() { - super.setUpInjector(); - dateService = injector.getInstance(DateService.class); - } - - public void testApplyInputStream() { - InputStream is = getClass().getResourceAsStream("/taskslist.xml"); - - TasksList result = factory.create(injector.getInstance(TasksListHandler.class)).parse(is); - assertEquals(result.getLocation(), URI - .create("https://services.vcloudexpress.terremark.com/api/v0.8/tasksList/1")); - Task task1 = new TaskImpl(URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/task/3300"), - null, TaskStatus.SUCCESS, dateService.iso8601DateParse("2009-08-24T21:30:19.587Z"), dateService - .iso8601DateParse("2009-08-24T21:30:32.63Z"), null, new ReferenceTypeImpl("Server1", - VCloudMediaType.VAPP_XML, URI - .create("https://services.vcloudexpress.terremark.com/api/v0.8/vapp/4012")), null); - Task task2 = new TaskImpl(URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/task/3299"), - null, TaskStatus.SUCCESS, dateService.iso8601DateParse("2009-08-24T21:29:32.983Z"), dateService - .iso8601DateParse("2009-08-24T21:29:44.65Z"), null, new ReferenceTypeImpl("Server1", - VCloudMediaType.VAPP_XML, URI - .create("https://services.vcloudexpress.terremark.com/api/v0.8/vapp/4012")), null); - assertEquals(result.getTasks(), ImmutableSortedSet.of(task1, task2)); - } - - public void testApplyInputStreamHosting() { - InputStream is = getClass().getResourceAsStream("/taskslist-hosting.xml"); - - TasksList result = factory.create(injector.getInstance(TasksListHandler.class)).parse(is); - assertEquals(result.getLocation(), URI.create("https://vcloud.safesecureweb.com/api/v0.8/tasksList/188849")); - - } - -} diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/xml/VAppHandlerTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/xml/VAppHandlerTest.java deleted file mode 100644 index 992e3432da..0000000000 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/xml/VAppHandlerTest.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.xml; - -import static org.testng.Assert.assertEquals; - -import java.io.InputStream; -import java.net.URI; - -import org.jclouds.cim.xml.ResourceAllocationSettingDataHandler; -import org.jclouds.http.functions.ParseSax; -import org.jclouds.http.functions.ParseSax.Factory; -import org.jclouds.http.functions.config.SaxParserModule; -import org.jclouds.vcloud.VCloudMediaType; -import org.jclouds.vcloud.domain.Status; -import org.jclouds.vcloud.domain.VApp; -import org.jclouds.vcloud.domain.Vm; -import org.jclouds.vcloud.domain.internal.ReferenceTypeImpl; -import org.jclouds.vcloud.xml.ovf.VCloudResourceAllocationSettingDataHandler; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableList; -import com.google.common.collect.Iterables; -import com.google.inject.Guice; -import com.google.inject.Injector; - -/** - * Tests behavior of {@code VAppHandler} - */ -@Test(groups = "unit") -public class VAppHandlerTest { - - public void testRhelOffStatic() { - InputStream is = getClass().getResourceAsStream("/vapp-rhel-off-static.xml"); - Injector injector = Guice.createInjector(new SaxParserModule() { - - @Override - protected void configure() { - super.configure(); - bind(ResourceAllocationSettingDataHandler.class).to(VCloudResourceAllocationSettingDataHandler.class); - } - }); - Factory factory = injector.getInstance(ParseSax.Factory.class); - VApp result = factory.create(injector.getInstance(VAppHandler.class)).parse(is); - assertEquals(result.getName(), "vApp_acole_2"); - assertEquals(result.getDescription(), "foo"); - assertEquals(result.getHref(), URI.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/vapp-607806320")); - assertEquals(result.getType(), "application/vnd.vmware.vcloud.vApp+xml"); - assertEquals(result.getStatus(), Status.OFF); - assertEquals( - result.getVDC(), - new ReferenceTypeImpl(null, VCloudMediaType.VDC_XML, URI - .create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1014839439"))); - assertEquals(result.getTasks(), ImmutableList.of()); - assert result.isOvfDescriptorUploaded(); - assert result.getNetworkSection() != null; - Vm vm = Iterables.getOnlyElement(result.getChildren()); - VmHandlerTest.checkVm(vm); - } - -} diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/xml/VAppTemplateHandlerTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/xml/VAppTemplateHandlerTest.java deleted file mode 100644 index c0cc110357..0000000000 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/xml/VAppTemplateHandlerTest.java +++ /dev/null @@ -1,162 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.xml; - -import static org.testng.Assert.assertEquals; - -import java.io.InputStream; -import java.net.URI; - -import org.jclouds.date.DateService; -import org.jclouds.http.functions.ParseSax; -import org.jclouds.http.functions.ParseSax.Factory; -import org.jclouds.http.functions.config.SaxParserModule; -import org.jclouds.ovf.Network; -import org.jclouds.vcloud.VCloudMediaType; -import org.jclouds.vcloud.domain.GuestCustomizationSection; -import org.jclouds.vcloud.domain.Status; -import org.jclouds.vcloud.domain.TaskStatus; -import org.jclouds.vcloud.domain.VAppTemplate; -import org.jclouds.vcloud.domain.Vm; -import org.jclouds.vcloud.domain.internal.ReferenceTypeImpl; -import org.jclouds.vcloud.domain.internal.TaskImpl; -import org.jclouds.vcloud.domain.ovf.VCloudNetworkSection; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Iterables; -import com.google.inject.Guice; -import com.google.inject.Injector; - -/** - * Tests behavior of {@code VAppTemplateHandler} - */ -@Test(groups = "unit") -public class VAppTemplateHandlerTest { - - public void testUbuntuTemplate() { - VAppTemplate result = parseTemplate(); - assertEquals(result.getName(), "Ubuntu Template"); - assertEquals(result.getHref(), URI - .create("https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/vappTemplate-1201908921")); - assertEquals(result.getType(), "application/vnd.vmware.vcloud.vAppTemplate+xml"); - assertEquals(result.getStatus(), Status.OFF); - assertEquals(result.getVDC(), new ReferenceTypeImpl(null, VCloudMediaType.VDC_XML, URI - .create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1014839439"))); - assertEquals(result.getDescription(), null); - assertEquals(result.getTasks(), ImmutableList.of()); - assertEquals(result.getVAppScopedLocalId(), null); - assert result.isOvfDescriptorUploaded(); - Vm vm = Iterables.getOnlyElement(result.getChildren()); - assertEquals(vm.getName(), "Ubuntu1004"); - assertEquals(vm.getHref(), URI.create("https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/vm-172837194")); - // NOTE this is vAppTemplate not VM! - assertEquals(vm.getType(), "application/vnd.vmware.vcloud.vAppTemplate+xml"); - assertEquals(vm.getStatus(), null); - assertEquals(vm.getParent(), new ReferenceTypeImpl(null, VCloudMediaType.VAPPTEMPLATE_XML, URI - .create("https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/vappTemplate-1201908921"))); - assertEquals(vm.getDescription(), null); - assertEquals(vm.getTasks(), ImmutableList.of()); - assertEquals(vm.getVAppScopedLocalId(), "02_ubuntu_template"); - - GuestCustomizationSection guestC = vm.getGuestCustomizationSection(); - - assertEquals(guestC.getType(), VCloudMediaType.GUESTCUSTOMIZATIONSECTION_XML); - assertEquals( - guestC.getHref(), - URI - .create("https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/vm-172837194/guestCustomizationSection/")); - assertEquals(guestC.getInfo(), "Specifies Guest OS Customization Settings"); - assertEquals(guestC.isEnabled(), Boolean.TRUE); - assertEquals(guestC.shouldChangeSid(), Boolean.FALSE); - assertEquals(guestC.getVirtualMachineId(), "172837194"); - assertEquals(guestC.isJoinDomainEnabled(), Boolean.FALSE); - assertEquals(guestC.useOrgSettings(), Boolean.FALSE); - assertEquals(guestC.getDomainName(), null); - assertEquals(guestC.getDomainUserName(), null); - assertEquals(guestC.getDomainUserPassword(), null); - assertEquals(guestC.isAdminPasswordEnabled(), Boolean.TRUE); - assertEquals(guestC.isAdminPasswordAuto(), Boolean.TRUE); - assertEquals(guestC.getAdminPassword(), "%3eD%gmF"); - assertEquals(guestC.isResetPasswordRequired(), Boolean.FALSE); - assertEquals( - guestC.getCustomizationScript(), - "#!/bin/bash if [ \"$1\" = \"postcustomization\" ]; then echo \"post customization\" touch /root/.postcustomization sleep 30 #regenerate keys /bin/rm /etc/ssh/ssh_host_* /usr/sbin/dpkg-reconfigure openssh-server echo \"completed\" fi"); - assertEquals(guestC.getComputerName(), "Ubuntu1004"); - assertEquals(guestC.getEdit(), null); - - VCloudNetworkSection network = result.getNetworkSection(); - assertEquals( - network.getHref(), - URI - .create("https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/vappTemplate-1201908921/networkSection/")); - assertEquals(network.getType(), VCloudMediaType.NETWORKSECTION_XML); - assertEquals(network.getInfo(), "The list of logical networks"); - assertEquals(network.getNetworks(), ImmutableSet.of(new Network("vAppNet-vApp Internal", null))); - - } - - public static VAppTemplate parseTemplate() { - InputStream is = VAppTemplateHandlerTest.class.getResourceAsStream("/vAppTemplate.xml"); - Injector injector = Guice.createInjector(new SaxParserModule()); - Factory factory = injector.getInstance(ParseSax.Factory.class); - VAppTemplate result = factory.create(injector.getInstance(VAppTemplateHandler.class)).parse(is); - return result; - } - - public void testCopyingTemplate() { - InputStream is = getClass().getResourceAsStream("/vAppTemplate-copying.xml"); - Injector injector = Guice.createInjector(new SaxParserModule()); - Factory factory = injector.getInstance(ParseSax.Factory.class); - DateService dateService = injector.getInstance(DateService.class); - - VAppTemplate result = factory.create(injector.getInstance(VAppTemplateHandler.class)).parse(is); - assertEquals(result.getName(), "Ubuntu10.04_v2"); - assertEquals(result.getHref(), URI - .create("https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/vappTemplate-699683881")); - assertEquals(result.getType(), "application/vnd.vmware.vcloud.vAppTemplate+xml"); - assertEquals(result.getStatus(), Status.UNRESOLVED); - assertEquals(result.getVDC(), new ReferenceTypeImpl(null, VCloudMediaType.VDC_XML, URI - .create("https://vcenterprise.bluelock.com/api/v1.0/vdc/105186609"))); - assertEquals(result.getDescription(), null); - assertEquals(result.getTasks(), ImmutableList.of(new TaskImpl(URI - .create("https://vcenterprise.bluelock.com/api/v1.0/task/q62gxhi32xgd9yrqvr"), - "Copying Virtual Application Template Ubuntu10.04_v2(699683881)", TaskStatus.RUNNING, dateService - .iso8601DateParse("2010-09-17T23:20:46.039-04:00"), dateService - .iso8601DateParse("9999-12-31T23:59:59.999-05:00"), dateService - .iso8601DateParse("2010-12-16T23:20:46.039-05:00"), new ReferenceTypeImpl("Ubuntu10.04_v2", - "application/vnd.vmware.vcloud.vAppTemplate+xml", - URI.create("https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/vappTemplate-699683881")), - null))); - assertEquals(result.getVAppScopedLocalId(), null); - assert result.isOvfDescriptorUploaded(); - assertEquals(result.getChildren(), ImmutableList.of()); - assertEquals(result.getNetworkSection(), null); - - } - - public void testVAppTemplateWithNewlinesAndNamespacedElements() { - InputStream is = getClass().getResourceAsStream("/vAppTemplate1.0-vcd15_withNewlines.xml"); - Injector injector = Guice.createInjector(new SaxParserModule()); - Factory factory = injector.getInstance(ParseSax.Factory.class); - - factory.create(injector.getInstance(VAppTemplateHandler.class)).parse(is); - } - - -} diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/xml/VDCHandlerTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/xml/VDCHandlerTest.java deleted file mode 100644 index d5cc9da247..0000000000 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/xml/VDCHandlerTest.java +++ /dev/null @@ -1,134 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.xml; - -import static org.testng.Assert.assertEquals; - -import java.io.InputStream; -import java.net.URI; - -import org.jclouds.http.functions.ParseSax; -import org.jclouds.http.functions.ParseSax.Factory; -import org.jclouds.http.functions.config.SaxParserModule; -import org.jclouds.vcloud.VCloudMediaType; -import org.jclouds.vcloud.domain.AllocationModel; -import org.jclouds.vcloud.domain.Capacity; -import org.jclouds.vcloud.domain.ReferenceType; -import org.jclouds.vcloud.domain.VDC; -import org.jclouds.vcloud.domain.VDCStatus; -import org.jclouds.vcloud.domain.internal.ReferenceTypeImpl; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; -import com.google.inject.Guice; -import com.google.inject.Injector; - -/** - * Tests behavior of {@code VDCHandler} - */ -@Test(groups = "unit") -public class VDCHandlerTest { - public void testVCloud1_0() { - InputStream is = getClass().getResourceAsStream("/vdc-1.0.xml"); - Injector injector = Guice.createInjector(new SaxParserModule()); - Factory factory = injector.getInstance(ParseSax.Factory.class); - VDC result = factory.create(injector.getInstance(VDCHandler.class)).parse(is); - assertEquals(result.getName(), "Jclouds-Commit-compG1xstorA01"); - assertEquals(result.getHref(), URI.create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1014839439")); - assertEquals(result.getType(), "application/vnd.vmware.vcloud.vdc+xml"); - assertEquals(result.getStatus(), VDCStatus.READY); - assertEquals(result.getOrg(), new ReferenceTypeImpl(null, VCloudMediaType.ORG_XML, URI - .create("https://vcenterprise.bluelock.com/api/v1.0/org/9566014"))); - assertEquals(result.getDescription(), null); - assertEquals(result.getTasks(), ImmutableList.of()); - assertEquals(result.getAllocationModel(), AllocationModel.ALLOCATION_POOL); - assertEquals(result.getStorageCapacity(), new Capacity("MB", 1024000, 1024000, 0, 0)); - assertEquals(result.getCpuCapacity(), new Capacity("MHz", 20000, 20000, 0, 0)); - assertEquals(result.getMemoryCapacity(), new Capacity("MB", 30720, 30720, 0, 0)); - assertEquals(result.getResourceEntities(), ImmutableMap. of()); - assertEquals(result.getAvailableNetworks(), ImmutableMap.of("isolation01", new ReferenceTypeImpl("isolation01", - "application/vnd.vmware.vcloud.network+xml", URI - .create("https://vcenterprise.bluelock.com/api/v1.0/network/990419644")), "internet01", - new ReferenceTypeImpl("internet01", "application/vnd.vmware.vcloud.network+xml", URI - .create("https://vcenterprise.bluelock.com/api/v1.0/network/758634723")))); - assertEquals(result.getNicQuota(), 0); - assertEquals(result.getNetworkQuota(), 100); - assertEquals(result.getVmQuota(), 50); - assert result.isEnabled(); - } - - public void testTerremark() { - InputStream is = getClass().getResourceAsStream("/vdc.xml"); - Injector injector = Guice.createInjector(new SaxParserModule()); - Factory factory = injector.getInstance(ParseSax.Factory.class); - VDC result = factory.create(injector.getInstance(VDCHandler.class)).parse(is); - assertEquals(result.getName(), "Miami Environment 1"); - assertEquals(result.getHref(), URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/32")); - assertEquals(result.getDescription(), null); - assertEquals(result.getStorageCapacity(), new Capacity("bytes * 10^9", 100, 0, 8, 0)); - assertEquals(result.getCpuCapacity(), new Capacity("hz * 10^6", 5000, 0, 0, 0)); - assertEquals(result.getMemoryCapacity(), new Capacity("bytes * 2^20", 10240, 0, 0, 0)); - assertEquals(result.getVmQuota(), 0); - assertEquals(result.getResourceEntities(), ImmutableMap. of("adriantest", - new ReferenceTypeImpl("adriantest", VCloudMediaType.VAPP_XML, URI - .create("https://services.vcloudexpress.terremark.com/api/v0.8/vapp/15124")), "centos-53", - new ReferenceTypeImpl("centos-53", VCloudMediaType.VAPP_XML, URI - .create("https://services.vcloudexpress.terremark.com/api/v0.8/vapp/15120")))); - assertEquals(result.getAvailableNetworks(), ImmutableMap.of("10.114.34.128/26", new ReferenceTypeImpl( - "10.114.34.128/26", "application/vnd.vmware.vcloud.network+xml", URI - .create("https://services.vcloudexpress.terremark.com/api/v0.8/network/1708")))); - } - - public void testHostingDotCom() { - InputStream is = getClass().getResourceAsStream("/vdc-hosting.xml"); - Injector injector = Guice.createInjector(new SaxParserModule()); - Factory factory = injector.getInstance(ParseSax.Factory.class); - VDC result = factory.create(injector.getInstance(VDCHandler.class)).parse(is); - assertEquals(result.getName(), "vDC Name"); - assertEquals(result.getHref(), URI.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/188849")); - assertEquals(result.getDescription(), "vDC Name"); - assertEquals(result.getStorageCapacity(), new Capacity("bytes * 10^9", 0, 0, 40960, 0)); - assertEquals(result.getCpuCapacity(), new Capacity("hz * 10^6", 0, 0, 2400, 0)); - assertEquals(result.getMemoryCapacity(), new Capacity("bytes * 10^9", 0, 0, 2, 0)); - assertEquals(result.getVmQuota(), 0); - assertEquals(result.getResourceEntities(), new ImmutableMap.Builder().put( - "Plesk (Linux) 64-bit Template", - new ReferenceTypeImpl("Plesk (Linux) 64-bit Template", "application/vnd.vmware.vcloud.vAppTemplate+xml", - URI.create("https://vcloud.safesecureweb.com/api/v0.8/vAppTemplate/1"))).put( - - "Windows 2008 Datacenter 64 Bit Template", - new ReferenceTypeImpl("Windows 2008 Datacenter 64 Bit Template", - "application/vnd.vmware.vcloud.vAppTemplate+xml", URI - .create("https://vcloud.safesecureweb.com/api/v0.8/vAppTemplate/2"))).put( - "Cent OS 64 Bit Template", - new ReferenceTypeImpl("Cent OS 64 Bit Template", "application/vnd.vmware.vcloud.vAppTemplate+xml", URI - .create("https://vcloud.safesecureweb.com/api/v0.8/vAppTemplate/3"))).put( - "cPanel (Linux) 64 Bit Template", - new ReferenceTypeImpl("cPanel (Linux) 64 Bit Template", - "application/vnd.vmware.vcloud.vAppTemplate+xml", URI - .create("https://vcloud.safesecureweb.com/api/v0.8/vAppTemplate/4"))).put( - "188849-1", - new ReferenceTypeImpl("188849-1", "application/vnd.vmware.vcloud.vApp+xml", URI - .create("https://vcloud.safesecureweb.com/api/v0.8/vApp/188849-1"))).put( - "188849-2", - new ReferenceTypeImpl("188849-2", "application/vnd.vmware.vcloud.vApp+xml", URI - .create("https://vcloud.safesecureweb.com/api/v0.8/vApp/188849-2"))).build()); - - assertEquals(result.getAvailableNetworks(), ImmutableMap. of()); - } -} diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/xml/VmHandlerTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/xml/VmHandlerTest.java deleted file mode 100644 index 342b04a4a1..0000000000 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/xml/VmHandlerTest.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.xml; - -import static org.testng.Assert.assertEquals; - -import java.io.InputStream; -import java.net.URI; - -import org.jclouds.cim.xml.ResourceAllocationSettingDataHandler; -import org.jclouds.http.functions.ParseSax; -import org.jclouds.http.functions.ParseSax.Factory; -import org.jclouds.http.functions.config.SaxParserModule; -import org.jclouds.vcloud.VCloudMediaType; -import org.jclouds.vcloud.domain.Status; -import org.jclouds.vcloud.domain.Vm; -import org.jclouds.vcloud.domain.internal.ReferenceTypeImpl; -import org.jclouds.vcloud.xml.ovf.VCloudOperatingSystemSectionHandlerTest; -import org.jclouds.vcloud.xml.ovf.VCloudResourceAllocationSettingDataHandler; -import org.jclouds.vcloud.xml.ovf.VCloudVirtualHardwareSectionHandlerTest; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableList; -import com.google.inject.Guice; -import com.google.inject.Injector; - -/** - * Tests behavior of {@code VmHandler} - */ -@Test(groups = "unit") -public class VmHandlerTest { - public void testVCloud1_0() { - InputStream is = getClass().getResourceAsStream("/vm-rhel-off-static.xml"); - Injector injector = Guice.createInjector(new SaxParserModule() { - - @Override - protected void configure() { - super.configure(); - bind(ResourceAllocationSettingDataHandler.class).to(VCloudResourceAllocationSettingDataHandler.class); - } - }); - Factory factory = injector.getInstance(ParseSax.Factory.class); - Vm result = factory.create(injector.getInstance(VmHandler.class)).parse(is); - checkVm(result); - } - - static void checkVm(Vm result) { - assertEquals(result.getName(), "RHEL5"); - assertEquals(result.getHref(), URI.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/vm-2087535248")); - assertEquals(result.getType(), "application/vnd.vmware.vcloud.vm+xml"); - assertEquals(result.getStatus(), Status.OFF); - assertEquals(result.getParent(), new ReferenceTypeImpl(null, VCloudMediaType.VAPP_XML, URI - .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/vapp-607806320"))); - assertEquals(result.getDescription(), null); - assertEquals(result.getTasks(), ImmutableList.of()); - assertEquals(result.getVAppScopedLocalId(), "10_rhel_template"); - VCloudVirtualHardwareSectionHandlerTest.checkHardware(result.getVirtualHardwareSection()); - VCloudOperatingSystemSectionHandlerTest.checkOs(result.getOperatingSystemSection()); - NetworkConnectionSectionHandlerTest.checkNetworkConnectionSection(result.getNetworkConnectionSection()); - GuestCustomizationSectionHandlerTest.checkGuestCustomization(result.getGuestCustomizationSection()); - } - -} diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/xml/ovf/VCloudOperatingSystemSectionHandlerTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/xml/ovf/VCloudOperatingSystemSectionHandlerTest.java deleted file mode 100644 index 307b3f1ef5..0000000000 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/xml/ovf/VCloudOperatingSystemSectionHandlerTest.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.xml.ovf; - -import static org.testng.Assert.assertEquals; - -import java.io.InputStream; -import java.net.URI; -import java.net.UnknownHostException; - -import org.jclouds.http.functions.BaseHandlerTest; -import org.jclouds.vcloud.domain.internal.ReferenceTypeImpl; -import org.jclouds.vcloud.domain.ovf.VCloudOperatingSystemSection; -import org.testng.annotations.Test; - -/** - * Tests behavior of {@code VCloudOperatingSystemSectionHandler} - */ -// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire -@Test(groups = "unit", testName = "VCloudOperatingSystemSectionHandlerTest") -public class VCloudOperatingSystemSectionHandlerTest extends BaseHandlerTest { - - public void testDefault() throws UnknownHostException { - InputStream is = getClass().getResourceAsStream("/os.xml"); - - VCloudOperatingSystemSection result = factory.create(injector.getInstance(VCloudOperatingSystemHandler.class)).parse(is); - - checkOs(result); - - } - - @Test(enabled = false) - public static void checkOs(VCloudOperatingSystemSection result) { - assertEquals(result.getHref(), URI - .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/vm-2087535248/operatingSystemSection/")); - assertEquals(result.getDescription(), "Red Hat Enterprise Linux 5 (64-bit)"); - assertEquals(result.getEdit(), new ReferenceTypeImpl(null, - "application/vnd.vmware.vcloud.operatingSystemSection+xml", - URI.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/vm-2087535248/operatingSystemSection/"))); - assertEquals(result.getId(), Integer.valueOf(80)); - assertEquals(result.getVmwOsType(), "rhel5_64Guest"); - assertEquals(result.getType(), "application/vnd.vmware.vcloud.operatingSystemSection+xml"); - assertEquals(result.getInfo(), "Specifies the operating system installed"); - } -} diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/xml/ovf/VCloudVirtualHardwareSectionHandlerTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/xml/ovf/VCloudVirtualHardwareSectionHandlerTest.java deleted file mode 100644 index 8e480de5e8..0000000000 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/xml/ovf/VCloudVirtualHardwareSectionHandlerTest.java +++ /dev/null @@ -1,151 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.vcloud.xml.ovf; - -import static org.testng.Assert.assertEquals; - -import java.io.InputStream; -import java.net.URI; -import java.net.UnknownHostException; - -import org.jclouds.cim.ResourceAllocationSettingData; -import org.jclouds.cim.ResourceAllocationSettingData.ResourceType; -import org.jclouds.cim.VirtualSystemSettingData; -import org.jclouds.cim.xml.ResourceAllocationSettingDataHandler; -import org.jclouds.http.functions.BaseHandlerTest; -import org.jclouds.http.functions.ParseSax; -import org.jclouds.http.functions.config.SaxParserModule; -import org.jclouds.vcloud.domain.internal.ReferenceTypeImpl; -import org.jclouds.vcloud.domain.ovf.EditableResourceAllocationSettingData; -import org.jclouds.vcloud.domain.ovf.VCloudHardDisk; -import org.jclouds.vcloud.domain.ovf.VCloudNetworkAdapter; -import org.jclouds.vcloud.domain.ovf.VCloudVirtualHardwareSection; -import org.jclouds.vcloud.xml.VCloudVirtualHardwareHandler; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.Test; - -import com.google.common.collect.Iterables; -import com.google.inject.Guice; - -/** - * Tests behavior of {@code VCloudVirtualHardwareSectionHandler} - */ -// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire -@Test(groups = "unit", testName = "VCloudVirtualHardwareSectionHandlerTest") -public class VCloudVirtualHardwareSectionHandlerTest extends BaseHandlerTest { - @BeforeTest - @Override - protected void setUpInjector() { - injector = Guice.createInjector(new SaxParserModule() { - public void configure() { - super.configure(); - bind(ResourceAllocationSettingDataHandler.class).to(VCloudResourceAllocationSettingDataHandler.class); - } - }); - factory = injector.getInstance(ParseSax.Factory.class); - assert factory != null; - } - - public void testDefault() throws UnknownHostException { - InputStream is = getClass().getResourceAsStream("/virtualhardwaresection.xml"); - - VCloudVirtualHardwareSection result = factory.create(injector.getInstance(VCloudVirtualHardwareHandler.class)) - .parse(is); - - checkHardware(result); - - } - - @Test(enabled = false) - public static void checkHardware(VCloudVirtualHardwareSection result) { - VirtualSystemSettingData system = VirtualSystemSettingData.builder().instanceID("0").elementName( - "Virtual Hardware Family").virtualSystemIdentifier("RHEL5").virtualSystemType("vmx-07").build(); - - assertEquals(result.getHref(), URI - .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/vm-2087535248/virtualHardwareSection/")); - assertEquals(result.getType(), "application/vnd.vmware.vcloud.virtualHardwareSection+xml"); - assertEquals(result.getSystem().toString(), system.toString()); - assertEquals(result.getInfo(), "Virtual hardware requirements"); - - assertEquals(Iterables.get(result.getItems(), 0).toString(), VCloudNetworkAdapter.builder() - .instanceID("1").elementName("Network adapter 0").description("PCNet32 ethernet adapter").resourceType( - ResourceType.ETHERNET_ADAPTER).resourceSubType("PCNet32").automaticAllocation(true).connection( - "internet01").address("00:50:56:01:01:f2").addressOnParent("0").ipAddress("174.47.101.164") - .primaryNetworkConnection(true).ipAddressingMode("POOL").build().toString()); - - assertEquals(Iterables.get(result.getItems(), 1).toString(), ResourceAllocationSettingData - .builder().instanceID("2").elementName("SCSI Controller 0").description("SCSI Controller").resourceType( - ResourceType.PARALLEL_SCSI_HBA).resourceSubType("lsilogic").address("0").build().toString()); - - assertEquals(Iterables.get(result.getItems(), 2).toString(), VCloudHardDisk.builder().instanceID( - "2000").elementName("Hard disk 1").description("Hard disk").resourceType(ResourceType.DISK_DRIVE) - .addressOnParent("0").parent("2").capacity(30720).busType(6).busSubType("lsilogic").build().toString()); - - assertEquals(Iterables.get(result.getItems(), 3).toString(), ResourceAllocationSettingData - .builder().instanceID("3").elementName("IDE Controller 0").description("IDE Controller").resourceType( - ResourceType.IDE_CONTROLLER).address("0").build().toString()); - - assertEquals(Iterables.get(result.getItems(), 4).toString(), ResourceAllocationSettingData - .builder().instanceID("3002").elementName("CD/DVD Drive 1").description("CD/DVD Drive").resourceType( - ResourceType.CD_DRIVE).addressOnParent("0").automaticAllocation(false).parent("3").build() - .toString()); - - assertEquals(Iterables.get(result.getItems(), 5).toString(), ResourceAllocationSettingData - .builder().instanceID("8000").elementName("Floppy Drive 1").description("Floppy Drive").resourceType( - ResourceType.FLOPPY_DRIVE).addressOnParent("0").automaticAllocation(false).build().toString()); - - assertEquals( - Iterables.get(result.getItems(), 6).toString(), - EditableResourceAllocationSettingData - .builder() - .instanceID("4") - .elementName("1 virtual CPU(s)") - .description("Number of Virtual CPUs") - .resourceType(ResourceType.PROCESSOR) - .virtualQuantity(1l) - .allocationUnits("hertz * 10^6") - .reservation(0l) - .weight(0) - .edit( - new ReferenceTypeImpl( - null, - "application/vnd.vmware.vcloud.rasdItem+xml", - URI - .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/vm-2087535248/virtualHardwareSection/cpu"))) - .build().toString()); - - assertEquals( - Iterables.get(result.getItems(), 7).toString(), - EditableResourceAllocationSettingData - .builder() - .instanceID("5") - .elementName("384 MB of memory") - .description("Memory Size") - .resourceType(ResourceType.MEMORY) - .virtualQuantity(384l) - .allocationUnits("byte * 2^20") - .reservation(0l) - .weight(0) - .edit( - new ReferenceTypeImpl( - null, - "application/vnd.vmware.vcloud.rasdItem+xml", - URI - .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/vm-2087535248/virtualHardwareSection/memory"))) - .build().toString()); - } -} diff --git a/apis/vcloud/src/test/resources/captureVApp-default.xml b/apis/vcloud/src/test/resources/captureVApp-default.xml deleted file mode 100644 index 057087207f..0000000000 --- a/apis/vcloud/src/test/resources/captureVApp-default.xml +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/apis/vcloud/src/test/resources/captureVApp.xml b/apis/vcloud/src/test/resources/captureVApp.xml deleted file mode 100644 index 35e62d06c8..0000000000 --- a/apis/vcloud/src/test/resources/captureVApp.xml +++ /dev/null @@ -1 +0,0 @@ -The description of the new vApp Template \ No newline at end of file diff --git a/apis/vcloud/src/test/resources/catalog-blank.xml b/apis/vcloud/src/test/resources/catalog-blank.xml deleted file mode 100644 index 6bc4038083..0000000000 --- a/apis/vcloud/src/test/resources/catalog-blank.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - false - diff --git a/apis/vcloud/src/test/resources/catalog-hosting.xml b/apis/vcloud/src/test/resources/catalog-hosting.xml deleted file mode 100644 index be510a9aa2..0000000000 --- a/apis/vcloud/src/test/resources/catalog-hosting.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - HMS Shared Catalog - - - - - - - - - - diff --git a/apis/vcloud/src/test/resources/catalog.xml b/apis/vcloud/src/test/resources/catalog.xml deleted file mode 100644 index f2d5eaa196..0000000000 --- a/apis/vcloud/src/test/resources/catalog.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/apis/vcloud/src/test/resources/catalog1.0-vcd15.xml b/apis/vcloud/src/test/resources/catalog1.0-vcd15.xml deleted file mode 100644 index 0208e5947a..0000000000 --- a/apis/vcloud/src/test/resources/catalog1.0-vcd15.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - false - \ No newline at end of file diff --git a/apis/vcloud/src/test/resources/catalogItem-carrenza-with-default-namespace.xml b/apis/vcloud/src/test/resources/catalogItem-carrenza-with-default-namespace.xml deleted file mode 100644 index 88fec20ef4..0000000000 --- a/apis/vcloud/src/test/resources/catalogItem-carrenza-with-default-namespace.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/apis/vcloud/src/test/resources/catalogItem-carrenza-with-vcloud-namespace.xml b/apis/vcloud/src/test/resources/catalogItem-carrenza-with-vcloud-namespace.xml deleted file mode 100644 index 917c143b95..0000000000 --- a/apis/vcloud/src/test/resources/catalogItem-carrenza-with-vcloud-namespace.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/apis/vcloud/src/test/resources/catalogItem-hosting.xml b/apis/vcloud/src/test/resources/catalogItem-hosting.xml deleted file mode 100644 index 6f88d046f6..0000000000 --- a/apis/vcloud/src/test/resources/catalogItem-hosting.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - Windows 2008 Datacenter 64 Bit - - Bar - World - diff --git a/apis/vcloud/src/test/resources/catalogItem-terremark.xml b/apis/vcloud/src/test/resources/catalogItem-terremark.xml deleted file mode 100644 index feb8b826a5..0000000000 --- a/apis/vcloud/src/test/resources/catalogItem-terremark.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - 0 - \ No newline at end of file diff --git a/apis/vcloud/src/test/resources/catalogItem1.0-vcd15.xml b/apis/vcloud/src/test/resources/catalogItem1.0-vcd15.xml deleted file mode 100644 index b344071608..0000000000 --- a/apis/vcloud/src/test/resources/catalogItem1.0-vcd15.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/apis/vcloud/src/test/resources/copyVApp-default.xml b/apis/vcloud/src/test/resources/copyVApp-default.xml deleted file mode 100644 index 0e8ba8df38..0000000000 --- a/apis/vcloud/src/test/resources/copyVApp-default.xml +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/apis/vcloud/src/test/resources/copyVApp.xml b/apis/vcloud/src/test/resources/copyVApp.xml deleted file mode 100644 index b6cd73359a..0000000000 --- a/apis/vcloud/src/test/resources/copyVApp.xml +++ /dev/null @@ -1 +0,0 @@ -The description of the new vApp \ No newline at end of file diff --git a/apis/vcloud/src/test/resources/copyVAppTemplate-default.xml b/apis/vcloud/src/test/resources/copyVAppTemplate-default.xml deleted file mode 100644 index 00b11e7746..0000000000 --- a/apis/vcloud/src/test/resources/copyVAppTemplate-default.xml +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/apis/vcloud/src/test/resources/copyVAppTemplate.xml b/apis/vcloud/src/test/resources/copyVAppTemplate.xml deleted file mode 100644 index e612b98b62..0000000000 --- a/apis/vcloud/src/test/resources/copyVAppTemplate.xml +++ /dev/null @@ -1 +0,0 @@ -The description of the new vAppTemplate \ No newline at end of file diff --git a/apis/vcloud/src/test/resources/cpuItem.xml b/apis/vcloud/src/test/resources/cpuItem.xml deleted file mode 100644 index d5e437b849..0000000000 --- a/apis/vcloud/src/test/resources/cpuItem.xml +++ /dev/null @@ -1 +0,0 @@ -hertz * 10^6Number of Virtual CPUs2 virtual CPU(s)4320 \ No newline at end of file diff --git a/apis/vcloud/src/test/resources/guestCustomization.xml b/apis/vcloud/src/test/resources/guestCustomization.xml deleted file mode 100644 index 644720f3d0..0000000000 --- a/apis/vcloud/src/test/resources/guestCustomization.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - Specifies Guest OS Customization Settings - true - false - 2087535248 - false - false - true - true - false - cat > /root/foo.txt<<EOF -I '"love"' {asc|!}*& -EOF - - RHEL5 - - diff --git a/apis/vcloud/src/test/resources/guestCustomizationSection.xml b/apis/vcloud/src/test/resources/guestCustomizationSection.xml deleted file mode 100644 index 2fadb53120..0000000000 --- a/apis/vcloud/src/test/resources/guestCustomizationSection.xml +++ /dev/null @@ -1,3 +0,0 @@ -Specifies Guest OS Customization Settingscat > /tmp/foo.txt<<EOF -I love candy -EOF \ No newline at end of file diff --git a/apis/vcloud/src/test/resources/instantiatedvapp.xml b/apis/vcloud/src/test/resources/instantiatedvapp.xml deleted file mode 100644 index 9d98c2daec..0000000000 --- a/apis/vcloud/src/test/resources/instantiatedvapp.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - OS-Ubuntu10.04_x64 - - - - - - - \ No newline at end of file diff --git a/apis/vcloud/src/test/resources/instantiationparams-description.xml b/apis/vcloud/src/test/resources/instantiationparams-description.xml deleted file mode 100644 index 672829018e..0000000000 --- a/apis/vcloud/src/test/resources/instantiationparams-description.xml +++ /dev/null @@ -1 +0,0 @@ -my fooConfiguration parameters for logical networksbridgedtrue \ No newline at end of file diff --git a/apis/vcloud/src/test/resources/instantiationparams-network.xml b/apis/vcloud/src/test/resources/instantiationparams-network.xml deleted file mode 100644 index e3bcb5844b..0000000000 --- a/apis/vcloud/src/test/resources/instantiationparams-network.xml +++ /dev/null @@ -1 +0,0 @@ -Configuration parameters for logical networksnatRoutedtrue \ No newline at end of file diff --git a/apis/vcloud/src/test/resources/instantiationparams.xml b/apis/vcloud/src/test/resources/instantiationparams.xml deleted file mode 100644 index 9df99619b8..0000000000 --- a/apis/vcloud/src/test/resources/instantiationparams.xml +++ /dev/null @@ -1 +0,0 @@ -Configuration parameters for logical networksbridgedtrue \ No newline at end of file diff --git a/apis/vcloud/src/test/resources/log4j.xml b/apis/vcloud/src/test/resources/log4j.xml deleted file mode 100644 index 63810d3ca0..0000000000 --- a/apis/vcloud/src/test/resources/log4j.xml +++ /dev/null @@ -1,151 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/apis/vcloud/src/test/resources/memoryItem.xml b/apis/vcloud/src/test/resources/memoryItem.xml deleted file mode 100644 index df35b837a5..0000000000 --- a/apis/vcloud/src/test/resources/memoryItem.xml +++ /dev/null @@ -1 +0,0 @@ -byte * 2^20Memory Size512 MB of memory5045120 \ No newline at end of file diff --git a/apis/vcloud/src/test/resources/moveVApp.xml b/apis/vcloud/src/test/resources/moveVApp.xml deleted file mode 100644 index 919d13655f..0000000000 --- a/apis/vcloud/src/test/resources/moveVApp.xml +++ /dev/null @@ -1 +0,0 @@ -The description of the new vApptrue \ No newline at end of file diff --git a/apis/vcloud/src/test/resources/moveVAppTemplate.xml b/apis/vcloud/src/test/resources/moveVAppTemplate.xml deleted file mode 100644 index 2f72f2bf7f..0000000000 --- a/apis/vcloud/src/test/resources/moveVAppTemplate.xml +++ /dev/null @@ -1 +0,0 @@ -The description of the new vAppTemplatetrue \ No newline at end of file diff --git a/apis/vcloud/src/test/resources/networkconnection.xml b/apis/vcloud/src/test/resources/networkconnection.xml deleted file mode 100644 index 5400fc72b4..0000000000 --- a/apis/vcloud/src/test/resources/networkconnection.xml +++ /dev/null @@ -1,7 +0,0 @@ - - 0 - 174.47.101.164 - true - 00:50:56:01:01:f2 - POOL - \ No newline at end of file diff --git a/apis/vcloud/src/test/resources/networkconnectionsection.xml b/apis/vcloud/src/test/resources/networkconnectionsection.xml deleted file mode 100644 index 9550ef60b6..0000000000 --- a/apis/vcloud/src/test/resources/networkconnectionsection.xml +++ /dev/null @@ -1,18 +0,0 @@ - - Specifies the available VM network connections - 0 - - 0 - 174.47.101.164 - true - 00:50:56:01:01:f2 - POOL - - - - \ No newline at end of file diff --git a/apis/vcloud/src/test/resources/org-1.0.xml b/apis/vcloud/src/test/resources/org-1.0.xml deleted file mode 100644 index af9803fc59..0000000000 --- a/apis/vcloud/src/test/resources/org-1.0.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - - - - - Example Corp's Primary Organization. - \ No newline at end of file diff --git a/apis/vcloud/src/test/resources/org-hosting.xml b/apis/vcloud/src/test/resources/org-hosting.xml deleted file mode 100644 index 3bd9842058..0000000000 --- a/apis/vcloud/src/test/resources/org-hosting.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - \ No newline at end of file diff --git a/apis/vcloud/src/test/resources/org-savvis.xml b/apis/vcloud/src/test/resources/org-savvis.xml deleted file mode 100644 index c2517c7046..0000000000 --- a/apis/vcloud/src/test/resources/org-savvis.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - Gravitant Inc - \ No newline at end of file diff --git a/apis/vcloud/src/test/resources/org.xml b/apis/vcloud/src/test/resources/org.xml deleted file mode 100644 index 1728721aa0..0000000000 --- a/apis/vcloud/src/test/resources/org.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/apis/vcloud/src/test/resources/org1.0-vcd15.xml b/apis/vcloud/src/test/resources/org1.0-vcd15.xml deleted file mode 100644 index d0ca5b725c..0000000000 --- a/apis/vcloud/src/test/resources/org1.0-vcd15.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - Customer jclouds - jclouds - \ No newline at end of file diff --git a/apis/vcloud/src/test/resources/orgList1.0-vcd15.xml b/apis/vcloud/src/test/resources/orgList1.0-vcd15.xml deleted file mode 100644 index 40f3cbe788..0000000000 --- a/apis/vcloud/src/test/resources/orgList1.0-vcd15.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/apis/vcloud/src/test/resources/orglist-savvis.xml b/apis/vcloud/src/test/resources/orglist-savvis.xml deleted file mode 100644 index 4de503bd5c..0000000000 --- a/apis/vcloud/src/test/resources/orglist-savvis.xml +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/apis/vcloud/src/test/resources/orglist.xml b/apis/vcloud/src/test/resources/orglist.xml deleted file mode 100644 index e6117b32bb..0000000000 --- a/apis/vcloud/src/test/resources/orglist.xml +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/apis/vcloud/src/test/resources/orgnetwork-bridged.xml b/apis/vcloud/src/test/resources/orgnetwork-bridged.xml deleted file mode 100644 index cb2a0d3c23..0000000000 --- a/apis/vcloud/src/test/resources/orgnetwork-bridged.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - true - 174.47.101.161 - 255.255.255.224 - 24.172.173.113 - - - 174.47.101.164 - 174.47.101.190 - - - - bridged - - \ No newline at end of file diff --git a/apis/vcloud/src/test/resources/orgnetwork-isolated.xml b/apis/vcloud/src/test/resources/orgnetwork-isolated.xml deleted file mode 100644 index ac3a66a2d3..0000000000 --- a/apis/vcloud/src/test/resources/orgnetwork-isolated.xml +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - false - 192.168.15.1 - 255.255.255.0 - 23.172.173.113 - - - 192.168.15.100 - 192.168.15.199 - - - - isolated - - - false - 3600 - 7200 - - 192.168.15.2 - 192.168.15.99 - - - - - diff --git a/apis/vcloud/src/test/resources/os.xml b/apis/vcloud/src/test/resources/os.xml deleted file mode 100644 index 3196a272f6..0000000000 --- a/apis/vcloud/src/test/resources/os.xml +++ /dev/null @@ -1,11 +0,0 @@ - - Specifies the operating system installed - Red Hat Enterprise Linux 5 (64-bit) - - \ No newline at end of file diff --git a/apis/vcloud/src/test/resources/ovf-multi-vm.xml b/apis/vcloud/src/test/resources/ovf-multi-vm.xml deleted file mode 100644 index fa4bb37236..0000000000 --- a/apis/vcloud/src/test/resources/ovf-multi-vm.xml +++ /dev/null @@ -1,285 +0,0 @@ - - - - - The list of logical networks - - - - - - The configuration parameters for logical networks - - - - - false - 192.168.2.1 - 255.255.255.0 - 195.225.219.131 - - - 192.168.2.100 - 192.168.2.199 - - - - isolated - - - false - 7200 - 7200 - - - - - false - - - - Lease settings section - 0 - 0 - - - VApp template customization section - true - - - A collection of virtual machines: - centos-web/db-5.5 - - VApp startup section - - - - - A virtual machine: - centos-db - - Specifies the operating system installed - Other 2.6x Linux (64-bit) - - - Virtual hardware requirements - - Virtual Hardware Family - 0 - centos-db - vmx-07 - - - 00:50:56:01:06:81 - 0 - true - vapp net - - PCNet32 ethernet adapter - Network adapter 0 - 1 - PCNet32 - 10 - - - 0 - SCSI Controller - SCSI Controller 0 - 2 - lsilogic - 6 - - - 0 - Hard disk - Hard disk 1 - - 2000 - 2 - 17 - - - 0 - IDE Controller - IDE Controller 0 - 3 - 5 - - - 0 - false - CD/DVD Drive - CD/DVD Drive 1 - - 3000 - 3 - 15 - - - 0 - false - Floppy Drive - Floppy Drive 1 - - 8000 - 14 - - - hertz * 10^6 - Number of Virtual CPUs - 1 virtual CPU(s) - 4 - 0 - 3 - 1 - 0 - - - byte * 2^20 - Memory Size - 2048 MB of memory - 5 - 0 - 4 - 2048 - 0 - - - - Specifies the available VM network connections - 0 - - 0 - 192.168.2.100 - true - 00:50:56:01:06:81 - POOL - - - - Specifies Guest OS Customization Settings - true - false - false - false - false - true - false - centos-db - - - - A virtual machine: - centos-web - - Specifies the operating system installed - Other 2.6x Linux (64-bit) - - - Virtual hardware requirements - - Virtual Hardware Family - 0 - centos-web - vmx-07 - - - 00:50:56:01:06:82 0 - true - vapp net - - PCNet32 ethernet adapter - Network adapter 0 - 1 - PCNet32 - 10 - - - 0 - SCSI Controller - SCSI Controller 0 - 2 - lsilogic - 6 - - - 0 - Hard disk - Hard disk 1 - - 2000 - 2 - 17 - - - 0 - IDE Controller - IDE Controller 0 - 3 - 5 - - - 0 - false - CD/DVD Drive - CD/DVD Drive 1 - - 3000 - 3 - 15 - - - 0 - false - Floppy Drive - Floppy Drive 1 - - 8000 - 14 - - - hertz * 10^6 - Number of Virtual CPUs - 1 virtual CPU(s) - 4 - 0 - 3 - 1 - 0 - - - byte * 2^20 - Memory Size - 2048 MB of memory - 5 - 0 - 4 - 2048 - 0 - - - - Specifies the available VM network connections - 0 - - 0 - 192.168.2.101 - true - 00:50:56:01:06:82 - POOL - - - - Specifies Guest OS Customization Settings - true - false - false - false - false - true - false - centos-web - - - - diff --git a/apis/vcloud/src/test/resources/ovf-ubuntu64.xml b/apis/vcloud/src/test/resources/ovf-ubuntu64.xml deleted file mode 100644 index 767957362b..0000000000 --- a/apis/vcloud/src/test/resources/ovf-ubuntu64.xml +++ /dev/null @@ -1,148 +0,0 @@ - - - - - The list of logical networks - - This is a special place-holder used for disconnected network interfaces. - - - - The configuration parameters for logical networks - - This is a special place-holder used for disconnected network interfaces. - - - false - 196.254.254.254 - 255.255.0.0 - 196.254.254.254 - - isolated - - false - - - - Lease settings section - 0 - 5184000 - 2012-03-12T17:40:44.491-06:00 - - - VApp template customization section - true - - - A virtual machine: - UbuntuServer-x64-2GB - - Specifies the operating system installed - Ubuntu Linux (64-bit) - - - Virtual hardware requirements - - Virtual Hardware Family - 0 - UbuntuServer-x64-2GB - vmx-07 - - - 00:50:56:01:02:9f - 0 - false - none - PCNet32 ethernet adapter - Network adapter 0 - 1 - PCNet32 - 10 - - - 0 - SCSI Controller - SCSI Controller 0 - 2 - lsilogic - 6 - - - 0 - Hard disk - Hard disk 1 - - 2000 - 2 - 17 - - - 0 - IDE Controller - IDE Controller 0 - 3 - 5 - - - 0 - false - CD/DVD Drive - CD/DVD Drive 1 - - 3000 - 3 - 15 - - - 0 - false - Floppy Drive - Floppy Drive 1 - - 8000 - 14 - - - hertz * 10^6 - Number of Virtual CPUs - 1 virtual CPU(s) - 4 - 0 - 3 - 1 - 0 - - - byte * 2^20 - Memory Size - 256 MB of memory - 5 - 0 - 4 - 256 - 0 - - - - Specifies the available VM network connections - 0 - - 0 - false - 00:50:56:01:02:9f - NONE - - - - Specifies Guest OS Customization Settings - true - false - false - false - true - true - false - UbuntuServer - - - \ No newline at end of file diff --git a/apis/vcloud/src/test/resources/task-1.0.xml b/apis/vcloud/src/test/resources/task-1.0.xml deleted file mode 100644 index 20fde3f84f..0000000000 --- a/apis/vcloud/src/test/resources/task-1.0.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - diff --git a/apis/vcloud/src/test/resources/task-error.xml b/apis/vcloud/src/test/resources/task-error.xml deleted file mode 100644 index 77147f8bc7..0000000000 --- a/apis/vcloud/src/test/resources/task-error.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - \ No newline at end of file diff --git a/apis/vcloud/src/test/resources/task-hosting.xml b/apis/vcloud/src/test/resources/task-hosting.xml deleted file mode 100644 index f4af4a2461..0000000000 --- a/apis/vcloud/src/test/resources/task-hosting.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - diff --git a/apis/vcloud/src/test/resources/task-self.xml b/apis/vcloud/src/test/resources/task-self.xml deleted file mode 100644 index 4a174248ee..0000000000 --- a/apis/vcloud/src/test/resources/task-self.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - \ No newline at end of file diff --git a/apis/vcloud/src/test/resources/task-vcd15.xml b/apis/vcloud/src/test/resources/task-vcd15.xml deleted file mode 100644 index 452287dadd..0000000000 --- a/apis/vcloud/src/test/resources/task-vcd15.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/apis/vcloud/src/test/resources/task.xml b/apis/vcloud/src/test/resources/task.xml deleted file mode 100644 index bd0514e376..0000000000 --- a/apis/vcloud/src/test/resources/task.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - \ No newline at end of file diff --git a/apis/vcloud/src/test/resources/taskslist-hosting.xml b/apis/vcloud/src/test/resources/taskslist-hosting.xml deleted file mode 100644 index 1511d134f4..0000000000 --- a/apis/vcloud/src/test/resources/taskslist-hosting.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - \ No newline at end of file diff --git a/apis/vcloud/src/test/resources/taskslist.xml b/apis/vcloud/src/test/resources/taskslist.xml deleted file mode 100644 index fe0d8c171d..0000000000 --- a/apis/vcloud/src/test/resources/taskslist.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/apis/vcloud/src/test/resources/template1.0-vcd15-multi-vm.xml b/apis/vcloud/src/test/resources/template1.0-vcd15-multi-vm.xml deleted file mode 100644 index 46b3c83011..0000000000 --- a/apis/vcloud/src/test/resources/template1.0-vcd15-multi-vm.xml +++ /dev/null @@ -1,68 +0,0 @@ - - - - - - - - - - - - - - - - - Specifies the available VM network connections - 0 - - 0 - false - 00:50:56:b5:09:dc - NONE - - - - Specifies Guest OS Customization Settings - true - false - false - false - true - true - true WindowsServ-001 - - Windows Server 2008 R2 - - - The list of logical networks - - This is a special place-holder used for disconnected network interfaces. - - - The configuration parameters for logical networks - - This is a special place-holder used for disconnected network interfaces. - - - false - 196.254.254.254 - 255.255.0.0 - 196.254.254.254 - - isolated - - false - - - - Lease settings section - 0 - - - VApp template customization section - true - - - diff --git a/apis/vcloud/src/test/resources/template1.0-vcd15.xml b/apis/vcloud/src/test/resources/template1.0-vcd15.xml deleted file mode 100644 index 35393eec2f..0000000000 --- a/apis/vcloud/src/test/resources/template1.0-vcd15.xml +++ /dev/null @@ -1,72 +0,0 @@ - - - - - - - - - - - - - - - - - Specifies the available VM network connections - 0 - - 0 - false - 00:50:56:01:02:9f - NONE - - - - Specifies Guest OS Customization Settings - true - false - false - false - true - true - false - UbuntuServer - - f114ade7-a63f-4f8b-b30b-44e9ff77e068 - - - - The list of logical networks - - This is a special place-holder used for disconnected network interfaces. - - - - The configuration parameters for logical networks - - This is a special place-holder used for disconnected network interfaces. - - - false - 196.254.254.254 - 255.255.0.0 - 196.254.254.254 - - isolated - - false - - - - Lease settings section - - 5184000 - 2012-03-12T17:40:44.491-06:00 - - - VApp template customization section - true - - \ No newline at end of file diff --git a/apis/vcloud/src/test/resources/vAppTemplate-copying.xml b/apis/vcloud/src/test/resources/vAppTemplate-copying.xml deleted file mode 100644 index 8ffa7d7625..0000000000 --- a/apis/vcloud/src/test/resources/vAppTemplate-copying.xml +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - - - - - - Lease settings section - - 0 - - - VApp template customization section - true - - diff --git a/apis/vcloud/src/test/resources/vAppTemplate.xml b/apis/vcloud/src/test/resources/vAppTemplate.xml deleted file mode 100644 index bb5fcafff8..0000000000 --- a/apis/vcloud/src/test/resources/vAppTemplate.xml +++ /dev/null @@ -1,143 +0,0 @@ - - - - - - - - - - - - - - - - Specifies the available VM network connections - 0 - - 0 - 192.168.2.100 - true - 00:50:56:8c:00:13 - POOL - - - - Specifies Guest OS Customization Settings - true - false - 172837194 - false - false - true - true - %3eD%gmF - false - #!/bin/bash if [ "$1" = "postcustomization" ]; then echo "post customization" touch /root/.postcustomization sleep 30 #regenerate keys /bin/rm /etc/ssh/ssh_host_* /usr/sbin/dpkg-reconfigure openssh-server echo "completed" fi - Ubuntu1004 - - 02_ubuntu_template - - - - The list of logical networks - - - - - - The configuration parameters for logical networks - - - - - false - 192.168.2.1 - 255.255.255.0 - 8.8.8.8 - - - 192.168.2.100 - 192.168.2.199 - - - - 192.168.2.100 - - - isolated - - - false - 7200 - 7200 - - - - true - - - true - ipTranslation - allowTraffic - - - automatic - 02_ubuntu_template - 0 - - - - - - false - - - - Lease settings section - - 0 - - - VApp template customization section - true - - - diff --git a/apis/vcloud/src/test/resources/vAppTemplate1.0-vcd15_withNewlines.xml b/apis/vcloud/src/test/resources/vAppTemplate1.0-vcd15_withNewlines.xml deleted file mode 100644 index 9f41d81442..0000000000 --- a/apis/vcloud/src/test/resources/vAppTemplate1.0-vcd15_withNewlines.xml +++ /dev/null @@ -1,109 +0,0 @@ - - - - - - - - Windows 2008 R2 Standard Edition -Service Pack 1 -Internet Explorer 9 - - - - Windows 2008 R2 Standard Edition -Service Pack 1 -Internet Explorer 9 - - Specifies the available VM network connections - 0 - - 0 - 212.54.128.56 - true - 00:50:56:01:0d:3c - POOL - - - - Specifies Guest OS Customization Settings - true - true - false - false - true - true - $6fEPL93 - false - Win2008r2Stand - - ac2ce03d-0491-46f7-afc6-37ffe5b30f74 - - - - The list of logical networks - - - - - - The configuration parameters for logical networks - - - - - true - 212.54.128.1 - 255.255.255.0 - 109.233.48.141 - 109.233.48.142 - - - 212.54.128.4 - 212.54.128.220 - - - - bridged - - - false - 3600 - 7200 - - 212.54.128.201 - 212.54.128.254 - - - - true - - - true - ipTranslation - allowTraffic - - - automatic - ac2ce03d-0491-46f7-afc6-37ffe5b30f74 - 0 - - - - - - false - - - - Lease settings section - - 0 - - - VApp template customization section - true - - \ No newline at end of file diff --git a/apis/vcloud/src/test/resources/vapp-hosting.xml b/apis/vcloud/src/test/resources/vapp-hosting.xml deleted file mode 100644 index c746cbab04..0000000000 --- a/apis/vcloud/src/test/resources/vapp-hosting.xml +++ /dev/null @@ -1,235 +0,0 @@ - - - - - Network Information about the vApp - - 204.12.11.167 - - - - - Virtual hardware - - - - - - - - - - - - - Virtual Hardware Family - 0 - - - - - - SimpleVM - vmx-07 - - -
- - hertz * 10^6 - - - - - Number of Virtual CPUs - 1 virtual CPU(s) - 1 - - - - - - - - 3 - 1 - - - -
- - byte * 2^20 - - - - - Memory Size - 512MB of memory - 2 - - - - - - - - 4 - 512 - - - -
0
- - - - - - - SCSI Controller - SCSI Controller 0 - 3 - - - - - - - lsilogic - 6 - - -
- -
- 0 - - - - - - - Hard Disk 1 - 20971520 - 9 - - - - 3 - - - - 17 - 20971520 - - - - \ No newline at end of file diff --git a/apis/vcloud/src/test/resources/vapp-none.xml b/apis/vcloud/src/test/resources/vapp-none.xml deleted file mode 100644 index 62b4f32580..0000000000 --- a/apis/vcloud/src/test/resources/vapp-none.xml +++ /dev/null @@ -1,237 +0,0 @@ - - - - - - - - - - - - - - Lease settings section - - 0 - 7776000 - - - VApp startup section - - - - - The list of logical networks - - - - - This is a special place-holder used for disconnected network interfaces. - - - - The configuration parameters for logical networks - - - - - - true - 172.16.7.1 - 255.255.255.0 - 208.95.232.10 - 208.95.232.11 - - - 172.16.7.230 - 172.16.7.239 - - - - - bridged - - - false - 3600 - 7200 - - 172.16.7.2 - 172.16.7.229 - - - - true - - - true - ipTranslation - allowTraffic - - - - true - - - This is a special place-holder used for disconnected network interfaces. - - - false - 196.254.254.254 - 255.255.0.0 - 196.254.254.254 - - isolated - - false - - - - - - - - - - - - - - - - - - - Virtual hardware requirements - - Virtual Hardware Family - 0 - Centos-5.5_x64 - vmx-07 - - - 00:50:56:01:02:38 - 0 - false - none - PCNet32 ethernet adapter - Network adapter 0 - 1 - PCNet32 - 10 - - - 0 - SCSI Controller - SCSI Controller 0 - 2 - lsilogic - 6 - - - 0 - Hard disk - Hard disk 1 - - 2000 - 2 - 17 - - - 0 - IDE Controller - IDE Controller 0 - 3 - 5 - - - 0 - false - CD/DVD Drive - CD/DVD Drive 1 - - 3002 - 3 - 15 - - - 0 - false - Floppy Drive - Floppy Drive 1 - - 8000 - 14 - - - hertz * 10^6 - Number of Virtual CPUs - 1 virtual CPU(s) - 4 - 0 - 3 - 1 - 0 - - - - byte * 2^20 - Memory Size - 2048 MB of memory - 5 - 0 - 4 - 2048 - 0 - - - - - - - - - - - - - - - Specifies the operating system installed - Red Hat Enterprise Linux 5 (64-bit) - - - - Specifies the available VM network connections - 0 - - 0 - false - 00:50:56:01:02:38 - NONE - - - - - Specifies Guest OS Customization Settings - true - false - 1 - false - false - true - true - secret - false - cat > /root/foo.txt<<EOF -I love candy -EOF - - Centos-5.5_x64 - - - Centos-5.5_x64 - - - diff --git a/apis/vcloud/src/test/resources/vapp-pool.xml b/apis/vcloud/src/test/resources/vapp-pool.xml deleted file mode 100644 index 1ac8ff3736..0000000000 --- a/apis/vcloud/src/test/resources/vapp-pool.xml +++ /dev/null @@ -1,227 +0,0 @@ - - - - - - - - - - - - - Example FTP Server vApp - - Lease settings section - - 0 - 0 - - - VApp startup section - - - - - The list of logical networks - - - - - - The configuration parameters for logical networks - - - - - - true - 172.16.7.1 - 255.255.255.0 - 1.1.1.2 - 1.1.1.3 - - - 172.16.7.230 - 172.16.7.239 - - - - - bridged - - - false - 3600 - 7200 - - 172.16.7.2 - 172.16.7.229 - - - - true - - - true - ipTranslation - allowTraffic - - - automatic - 100c208b-4f43-40bb-98d6-a046f6e48c3a - 0 - - - - - - true - - - - - - - - - - - - - - - - - - - Virtual hardware requirements - - Virtual Hardware Family - 0 - my-app - vmx-07 - - - 00:50:56:01:02:33 - 0 - true - Direct - PCNet32 ethernet adapter - Network adapter 0 - 1 - PCNet32 - 10 - - - 0 - SCSI Controller - SCSI Controller 0 - 2 - lsilogic - 6 - - - 0 - Hard disk - Hard disk 1 - - 2000 - 2 - 17 - - - 0 - IDE Controller - IDE Controller 0 - 3 - 5 - - - 0 - false - CD/DVD Drive - CD/DVD Drive 1 - - 3002 - 3 - 15 - - - 0 - false - Floppy Drive - Floppy Drive 1 - - 8000 - 14 - - - hertz * 10^6 - Number of Virtual CPUs - 1 virtual CPU(s) - 4 - 0 - 3 - 1 - 0 - - - - byte * 2^20 - Memory Size - 2048 MB of memory - 5 - 0 - 4 - 2048 - 0 - - - - - - - - - - - - - - - Specifies the operating system installed - Red Hat Enterprise Linux 5 (64-bit) - - - - Specifies the available VM network connections - 0 - - 0 - 172.16.7.230 - true - 00:50:56:01:02:33 - POOL - - - - - Specifies Guest OS Customization Settings - true - false - 1 - false - false - true - true - Favor - false - - my-app - - - 100c208b-4f43-40bb-98d6-a046f6e48c3a - - - diff --git a/apis/vcloud/src/test/resources/vapp-rhel-off-static.xml b/apis/vcloud/src/test/resources/vapp-rhel-off-static.xml deleted file mode 100644 index 7e29ffcbd2..0000000000 --- a/apis/vcloud/src/test/resources/vapp-rhel-off-static.xml +++ /dev/null @@ -1,325 +0,0 @@ - - - - - - - - - - foo - - Lease settings section - - 0 - 0 - - - VApp startup section - - - - - The list of logical networks - - - - - - The configuration parameters for logical networks - - - - - - true - 174.47.101.161 - 255.255.255.224 - 24.172.173.113 - - - 174.47.101.164 - 174.47.101.190 - - - - - bridged - - - false - 3600 - 7200 - - 174.47.101.162 - 174.47.101.163 - - - - true - - - true - ipTranslation - allowTraffic - - - automatic - 10_rhel_template - 0 - - - - - - false - - - - - - - - - - - - - - - - Virtual hardware requirements - - Virtual Hardware Family - 0 - RHEL5 - vmx-07 - - - 00:50:56:01:01:f2 - 0 - true - internet01 - PCNet32 ethernet adapter - Network adapter 0 - 1 - PCNet32 - 10 - - - 0 - SCSI Controller - SCSI Controller 0 - 2 - lsilogic - 6 - - - 0 - Hard disk - Hard disk 1 - - 2000 - 2 - 17 - - - 0 - IDE Controller - IDE Controller 0 - 3 - 5 - - - 0 - false - CD/DVD Drive - CD/DVD Drive 1 - - 3002 - 3 - 15 - - - 0 - false - Floppy Drive - Floppy Drive 1 - - 8000 - 14 - - - hertz * 10^6 - Number of Virtual CPUs - 1 virtual CPU(s) - 4 - 0 - 3 - 1 - 0 - - - - byte * 2^20 - Memory Size - 384 MB of memory - 5 - 0 - 4 - 384 - 0 - - - - - - - - - - - - - - - Specifies the operating system installed - Red Hat Enterprise Linux 5 (64-bit) - - - - Specifies the available VM network connections - 0 - - 0 - 174.47.101.164 - true - 00:50:56:01:01:f2 - POOL - - - - - Specifies Guest OS Customization Settings - true - false - 2087535248 - false - false - true - true - false - cat > /root/foo.txt<<EOF -I '"love"' {asc|!}*& -EOF - - RHEL5 - - - 10_rhel_template - - - diff --git a/apis/vcloud/src/test/resources/vapp-ubuntu-off-dhcp.xml b/apis/vcloud/src/test/resources/vapp-ubuntu-off-dhcp.xml deleted file mode 100644 index d8406fcbfc..0000000000 --- a/apis/vcloud/src/test/resources/vapp-ubuntu-off-dhcp.xml +++ /dev/null @@ -1,213 +0,0 @@ - - - - - - - - - - - - - Lease settings section - - 0 - 0 - - - VApp startup section - - - - - The list of logical networks - - - - - - The configuration parameters for logical networks - - - - - - true - 174.47.101.161 - 255.255.255.224 - 24.172.173.113 - - - 174.47.101.164 - 174.47.101.190 - - - - - bridged - - - false - 3600 - 7200 - - 174.47.101.162 - 174.47.101.163 - - - - true - - - true - ipTranslation - allowTraffic - - - - false - - - - - - - - - - - - - - - - Virtual hardware requirements - - Virtual Hardware Family - 0 - Ubuntu1004 - vmx-07 - - - 00:50:56:01:01:f1 - 0 - true - internet01 - PCNet32 ethernet adapter - Network adapter 0 - 1 - PCNet32 - 10 - - - 0 - SCSI Controller - SCSI Controller 0 - 2 - lsilogic - 6 - - - 0 - Hard disk - Hard disk 1 - - 2000 - 2 - 17 - - - 0 - IDE Controller - IDE Controller 0 - 3 - 5 - - - 0 - false - CD/DVD Drive - CD/DVD Drive 1 - - 3002 - 3 - 15 - - - 0 - false - Floppy Drive - Floppy Drive 1 - - 8000 - 14 - - - hertz * 10^6 - Number of Virtual CPUs - 1 virtual CPU(s) - 4 - 0 - 3 - 1 - 0 - - - - byte * 2^20 - Memory Size - 512 MB of memory - 5 - 0 - 4 - 512 - 0 - - - - - - - - - - - - - - - Specifies the operating system installed - Ubuntu Linux (64-bit) - - - - Specifies the available VM network connections - 0 - - 0 - true - 00:50:56:01:01:f1 - DHCP - - - - - Specifies Guest OS Customization Settings - true - false - 2093098975 - false - false - true - true - %3eD%gmF - false - #regenerate keys /bin/rm /etc/ssh/ssh_host_* /usr/sbin/dpkg-reconfigure openssh-server - Ubuntu1004 - - - 02_ubuntu_template - - - \ No newline at end of file diff --git a/apis/vcloud/src/test/resources/vapp-unresolved.xml b/apis/vcloud/src/test/resources/vapp-unresolved.xml deleted file mode 100644 index 995bc298f6..0000000000 --- a/apis/vcloud/src/test/resources/vapp-unresolved.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - - - diff --git a/apis/vcloud/src/test/resources/vapp-win-off-static.xml b/apis/vcloud/src/test/resources/vapp-win-off-static.xml deleted file mode 100644 index 6282766222..0000000000 --- a/apis/vcloud/src/test/resources/vapp-win-off-static.xml +++ /dev/null @@ -1,219 +0,0 @@ - - - - - - - - - - - - Lease settings section - - 0 - 0 - - - VApp startup section - - - - - The list of logical networks - - - - - - The configuration parameters for logical networks - - - - - - true - 174.47.101.161 - 255.255.255.224 - 24.172.173.113 - - - 174.47.101.164 - 174.47.101.190 - - - - - bridged - - - false - 3600 - 7200 - - 174.47.101.162 - 174.47.101.163 - - - - true - - - true - ipTranslation - allowTraffic - - - automatic - 04_windows_template - 0 - - - - - - false - - - - - - - - - - - - - - - - Virtual hardware requirements - - Virtual Hardware Family - 0 - Windows2008R2 - vmx-07 - - - 00:50:56:01:02:33 - 0 - true - internet01 - PCNet32 ethernet adapter - Network adapter 0 - 1 - PCNet32 - 10 - - - 0 - SCSI Controller - SCSI Controller 0 - 2 - lsilogicsas - 6 - - - 0 - Hard disk - Hard disk 1 - - 2000 - 2 - 17 - - - 0 - IDE Controller - IDE Controller 0 - 3 - 5 - - - 0 - false - CD/DVD Drive - CD/DVD Drive 1 - - 3002 - 3 - 15 - - - 0 - false - Floppy Drive - Floppy Drive 1 - - 8000 - 14 - - - hertz * 10^6 - Number of Virtual CPUs - 1 virtual CPU(s) - 4 - 0 - 3 - 1 - 0 - - - - byte * 2^20 - Memory Size - 4096 MB of memory - 5 - 0 - 4 - 4096 - 0 - - - - - - - - - - - - - - - Specifies the operating system installed - Microsoft Windows Server 2008 R2 (64-bit) - - - - Specifies the available VM network connections - 0 - - 0 - 174.47.101.165 - true - 00:50:56:01:02:33 - POOL - - - - - Specifies Guest OS Customization Settings - true - true - 904484461 - false - false - true - true - false - - Windows2008R2 - - - 04_windows_template - - - \ No newline at end of file diff --git a/apis/vcloud/src/test/resources/vdc-1.0.xml b/apis/vcloud/src/test/resources/vdc-1.0.xml deleted file mode 100644 index 286e42ca64..0000000000 --- a/apis/vcloud/src/test/resources/vdc-1.0.xml +++ /dev/null @@ -1,49 +0,0 @@ - - - - - - - - - - - - - - - AllocationPool - - MB - 1024000 - 1024000 - 0 - 0 - - - - MHz - 20000 - 20000 - 0 - 0 - - - MB - 30720 - 30720 - 0 - 0 - - - - - - - - 0 - 100 - 50 - true - diff --git a/apis/vcloud/src/test/resources/vdc-hosting.xml b/apis/vcloud/src/test/resources/vdc-hosting.xml deleted file mode 100644 index 6254112cf8..0000000000 --- a/apis/vcloud/src/test/resources/vdc-hosting.xml +++ /dev/null @@ -1,60 +0,0 @@ - - - - - - vDC Name - - bytes * 10^9 - 0 - 40960 - - - - hz * 10^6 - 0 - 2400 - - - bytes * 10^9 - 0 - 2 - - - 0 - 2 - - - 0 - 2 - - - - - - - - - - - diff --git a/apis/vcloud/src/test/resources/vdc-nonet.xml b/apis/vcloud/src/test/resources/vdc-nonet.xml deleted file mode 100644 index eebf132002..0000000000 --- a/apis/vcloud/src/test/resources/vdc-nonet.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - Workand Pension Apps - - - - - - - \ No newline at end of file diff --git a/apis/vcloud/src/test/resources/vdc.xml b/apis/vcloud/src/test/resources/vdc.xml deleted file mode 100644 index d5df92fb9f..0000000000 --- a/apis/vcloud/src/test/resources/vdc.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - bytes * 10^9 - 100 - 8 - - - - hz * 10^6 - 5000 - - - bytes * 2^20 - 10240 - - - -1 - -1 - - - -1 - -1 - - - - - - - - - - \ No newline at end of file diff --git a/apis/vcloud/src/test/resources/vdc1.0-vcd15.xml b/apis/vcloud/src/test/resources/vdc1.0-vcd15.xml deleted file mode 100644 index d705891a0c..0000000000 --- a/apis/vcloud/src/test/resources/vdc1.0-vcd15.xml +++ /dev/null @@ -1,47 +0,0 @@ - - - - - - - - - - - - Pay As You go resources for organization jclouds - AllocationVApp - - MB - 0 - 0 - 14336 - 0 - - - - MHz - 0 - 0 - 0 - 0 - - - MB - 0 - 0 - 0 - 0 - - - - - - - - - 0 - 10 - 10 - true - \ No newline at end of file diff --git a/apis/vcloud/src/test/resources/versions-vcd15.xml b/apis/vcloud/src/test/resources/versions-vcd15.xml deleted file mode 100644 index ed24d3a8b4..0000000000 --- a/apis/vcloud/src/test/resources/versions-vcd15.xml +++ /dev/null @@ -1,906 +0,0 @@ - - - - 1.0 - https://zone.myvcloud.com/api/v1.0/login - - application/vnd.vmware.vcloud.customizationSection+xml - CustomizationSectionType - https://zone.myvcloud.com/api/v1.0/schema/master.xsd - - - application/vnd.vmware.vcloud.catalogItem+xml - CatalogItemType - https://zone.myvcloud.com/api/v1.0/schema/master.xsd - - - application/vnd.vmware.vcloud.networkConnectionSection+xml - NetworkConnectionSectionType - https://zone.myvcloud.com/api/v1.0/schema/master.xsd - - - application/vnd.vmware.vcloud.owner+xml - OwnerType - https://zone.myvcloud.com/api/v1.0/schema/master.xsd - - - application/vnd.vmware.admin.licensingReportList+xml - LicensingReportListType - https://zone.myvcloud.com/api/v1.0/schema/vmwextensions.xsd - - - application/vnd.vmware.admin.group+xml - GroupType - https://zone.myvcloud.com/api/v1.0/schema/master.xsd - - - application/vnd.vmware.admin.vdc+xml - AdminVdcType - https://zone.myvcloud.com/api/v1.0/schema/master.xsd - - - application/vnd.vmware.admin.licensingReport+xml - LicensingReportType - https://zone.myvcloud.com/api/v1.0/schema/vmwextensions.xsd - - - application/vnd.vmware.admin.importVmAsVAppTemplateParams+xml - ImportVmAsVAppTemplateParamsType - https://zone.myvcloud.com/api/v1.0/schema/vmwextensions.xsd - - - application/vnd.vmware.admin.vmwVimServerReferences+xml - VMWVimServerReferencesType - https://zone.myvcloud.com/api/v1.0/schema/vmwextensions.xsd - - - application/vnd.vmware.vcloud.vm+xml - VmType - https://zone.myvcloud.com/api/v1.0/schema/master.xsd - - - application/vnd.vmware.vcloud.uploadVAppTemplateParams+xml - UploadVAppTemplateParamsType - https://zone.myvcloud.com/api/v1.0/schema/master.xsd - - - application/vnd.vmware.vcloud.composeVAppParams+xml - ComposeVAppParamsType - https://zone.myvcloud.com/api/v1.0/schema/master.xsd - - - application/vnd.vmware.vcloud.orgList+xml - OrgListType - https://zone.myvcloud.com/api/v1.0/schema/master.xsd - - - application/vnd.vmware.vcloud.cloneMediaParams+xml - CloneMediaParamsType - https://zone.myvcloud.com/api/v1.0/schema/master.xsd - - - application/vnd.vmware.vcloud.vmPendingQuestion+xml - VmPendingQuestionType - https://zone.myvcloud.com/api/v1.0/schema/master.xsd - - - application/vnd.vmware.admin.vmwHostReferences+xml - VMWHostReferencesType - https://zone.myvcloud.com/api/v1.0/schema/vmwextensions.xsd - - - application/vnd.vmware.vcloud.undeployVAppParams+xml - UndeployVAppParamsType - https://zone.myvcloud.com/api/v1.0/schema/master.xsd - - - application/vnd.vmware.vcloud.leaseSettingsSection+xml - LeaseSettingsSectionType - https://zone.myvcloud.com/api/v1.0/schema/master.xsd - - - application/vnd.vmware.vcloud.network+xml - OrgNetworkType - https://zone.myvcloud.com/api/v1.0/schema/master.xsd - - - application/vnd.vmware.vcloud.deployVAppParams+xml - DeployVAppParamsType - https://zone.myvcloud.com/api/v1.0/schema/master.xsd - - - application/vnd.vmware.vcloud.cloneVAppTemplateParams+xml - CloneVAppTemplateParamsType - https://zone.myvcloud.com/api/v1.0/schema/master.xsd - - - application/vnd.vmware.vcloud.media+xml - MediaType - https://zone.myvcloud.com/api/v1.0/schema/master.xsd - - - application/vnd.vmware.admin.vmwprovidervdc+xml - VMWProviderVdcType - https://zone.myvcloud.com/api/v1.0/schema/vmwextensions.xsd - - - application/vnd.vmware.vcloud.vAppTemplate+xml - VAppTemplateType - https://zone.myvcloud.com/api/v1.0/schema/master.xsd - - - application/vnd.vmware.vcloud.org+xml - OrgType - https://zone.myvcloud.com/api/v1.0/schema/master.xsd - - - application/vnd.vmware.vcloud.vApp+xml - VAppType - https://zone.myvcloud.com/api/v1.0/schema/master.xsd - - - application/vnd.vmware.vcloud.catalog+xml - CatalogType - https://zone.myvcloud.com/api/v1.0/schema/master.xsd - - - application/vnd.vmware.admin.vmwNetworkPool+xml - VMWNetworkPoolType - https://zone.myvcloud.com/api/v1.0/schema/vmwextensions.xsd - - - application/vnd.vmware.vcloud.tasksList+xml - TasksListType - https://zone.myvcloud.com/api/v1.0/schema/master.xsd - - - application/vnd.vmware.admin.vdcReferences+xml - VdcReferencesType - https://zone.myvcloud.com/api/v1.0/schema/master.xsd - - - application/vnd.vmware.vcloud.screenTicket+xml - ScreenTicketType - https://zone.myvcloud.com/api/v1.0/schema/master.xsd - - - application/vnd.vmware.admin.prepareHostParams+xml - PrepareHostParamsType - https://zone.myvcloud.com/api/v1.0/schema/vmwextensions.xsd - - - application/vnd.vmware.admin.vcloud+xml - VCloudType - https://zone.myvcloud.com/api/v1.0/schema/master.xsd - - - application/vnd.vmware.admin.publishCatalogParams+xml - PublishCatalogParamsType - https://zone.myvcloud.com/api/v1.0/schema/master.xsd - - - application/vnd.vmware.vcloud.networkConfigSection+xml - NetworkConfigSectionType - https://zone.myvcloud.com/api/v1.0/schema/master.xsd - - - application/vnd.vmware.admin.resourcePoolList+xml - ResourcePoolListType - https://zone.myvcloud.com/api/v1.0/schema/vmwextensions.xsd - - - application/vnd.vmware.admin.right+xml - RightType - https://zone.myvcloud.com/api/v1.0/schema/master.xsd - - - application/vnd.vmware.admin.vmwExtension+xml - VMWExtensionType - https://zone.myvcloud.com/api/v1.0/schema/vmwextensions.xsd - - - application/vnd.vmware.admin.importVmAsVAppParams+xml - ImportVmAsVAppParamsType - https://zone.myvcloud.com/api/v1.0/schema/vmwextensions.xsd - - - application/vnd.vmware.admin.vmwvirtualcenter+xml - VimServerType - https://zone.myvcloud.com/api/v1.0/schema/vmwextensions.xsd - - - application/vnd.vmware.admin.vmsObjectRefsList+xml - VmObjectRefsListType - https://zone.myvcloud.com/api/v1.0/schema/vmwextensions.xsd - - - application/vnd.vmware.vcloud.controlAccess+xml - ControlAccessParamsType - https://zone.myvcloud.com/api/v1.0/schema/master.xsd - - - application/vnd.vmware.vcloud.vdc+xml - VdcType - https://zone.myvcloud.com/api/v1.0/schema/master.xsd - - - application/vnd.vmware.admin.role+xml - RoleType - https://zone.myvcloud.com/api/v1.0/schema/master.xsd - - - application/vnd.vmware.vcloud.cloneVAppParams+xml - CloneVAppParamsType - https://zone.myvcloud.com/api/v1.0/schema/master.xsd - - - application/vnd.vmware.admin.host+xml - HostType - https://zone.myvcloud.com/api/v1.0/schema/vmwextensions.xsd - - - application/vnd.vmware.admin.organization+xml - AdminOrgType - https://zone.myvcloud.com/api/v1.0/schema/master.xsd - - - application/vnd.vmware.admin.providervdc+xml - ProviderVdcType - https://zone.myvcloud.com/api/v1.0/schema/master.xsd - - - application/vnd.vmware.admin.user+xml - UserType - https://zone.myvcloud.com/api/v1.0/schema/master.xsd - - - application/vnd.vmware.admin.vmwProviderVdcReferences+xml - VMWProviderVdcReferencesType - https://zone.myvcloud.com/api/v1.0/schema/vmwextensions.xsd - - - application/vnd.vmware.vcloud.mediaInsertOrEjectParams+xml - MediaInsertOrEjectParamsType - https://zone.myvcloud.com/api/v1.0/schema/master.xsd - - - application/vnd.vmware.vcloud.instantiateVAppTemplateParams+xml - InstantiateVAppTemplateParamsType - https://zone.myvcloud.com/api/v1.0/schema/master.xsd - - - application/vnd.vmware.vcloud.rasdItemsList+xml - RasdItemsListType - https://zone.myvcloud.com/api/v1.0/schema/master.xsd - - - application/vnd.vmware.vcloud.task+xml - TaskType - https://zone.myvcloud.com/api/v1.0/schema/master.xsd - - - application/vnd.vmware.admin.vmwNetworkPoolReferences+xml - VMWNetworkPoolReferencesType - https://zone.myvcloud.com/api/v1.0/schema/vmwextensions.xsd - - - application/vnd.vmware.vcloud.guestCustomizationSection+xml - GuestCustomizationSectionType - https://zone.myvcloud.com/api/v1.0/schema/master.xsd - - - application/vnd.vmware.vcloud.recomposeVAppParams+xml - RecomposeVAppParamsType - https://zone.myvcloud.com/api/v1.0/schema/master.xsd - - - application/vnd.vmware.admin.importMediaParams+xml - ImportMediaParamsType - https://zone.myvcloud.com/api/v1.0/schema/vmwextensions.xsd - - - application/vnd.vmware.admin.vmwExternalNetworkReferences+xml - VMWExternalNetworkReferencesType - https://zone.myvcloud.com/api/v1.0/schema/vmwextensions.xsd - - - application/vnd.vmware.admin.vmwexternalnet+xml - VMWExternalNetworkType - https://zone.myvcloud.com/api/v1.0/schema/vmwextensions.xsd - - - application/vnd.vmware.vcloud.captureVAppParams+xml - CaptureVAppParamsType - https://zone.myvcloud.com/api/v1.0/schema/master.xsd - - - application/vnd.vmware.vcloud.vmPendingAnswer+xml - VmQuestionAnswerType - https://zone.myvcloud.com/api/v1.0/schema/master.xsd - - - application/vnd.vmware.admin.registerVimServerParams+xml - RegisterVimServerParamsType - https://zone.myvcloud.com/api/v1.0/schema/vmwextensions.xsd - - - application/vnd.vmware.vcloud.rasdItem+xml - RASD_Type - https://zone.myvcloud.com/api/v1.0/schema/master.xsd - - - application/vnd.vmware.vcloud.startupSection+xml - StartupSection_Type - http://schemas.dmtf.org/ovf/envelope/1/dsp8023_1.1.0.xsd - - - application/vnd.vmware.vcloud.virtualHardwareSection+xml - VirtualHardwareSection_Type - http://schemas.dmtf.org/ovf/envelope/1/dsp8023_1.1.0.xsd - - - application/vnd.vmware.vcloud.operatingSystemSection+xml - OperatingSystemSection_Type - http://schemas.dmtf.org/ovf/envelope/1/dsp8023_1.1.0.xsd - - - application/vnd.vmware.vcloud.networkSection+xml - NetworkSection_Type - http://schemas.dmtf.org/ovf/envelope/1/dsp8023_1.1.0.xsd - - - - 1.5 - https://zone.myvcloud.com/api/sessions - - application/vnd.vmware.vcloud.instantiateVAppTemplateParams+xml - InstantiateVAppTemplateParamsType - https://zone.myvcloud.com/api/v1.5/schema/master.xsd - - - application/vnd.vmware.admin.vmwProviderVdcReferences+xml - VMWProviderVdcReferencesType - https://zone.myvcloud.com/api/v1.5/schema/vmwextensions.xsd - - - application/vnd.vmware.vcloud.customizationSection+xml - CustomizationSectionType - https://zone.myvcloud.com/api/v1.5/schema/master.xsd - - - application/vnd.vmware.admin.prepareHostParams+xml - PrepareHostParamsType - https://zone.myvcloud.com/api/v1.5/schema/vmwextensions.xsd - - - application/vnd.vmware.vcloud.relocateVmParams+xml - RelocateParamsType - https://zone.myvcloud.com/api/v1.5/schema/master.xsd - - - application/vnd.vmware.vcloud.org+xml - OrgType - https://zone.myvcloud.com/api/v1.5/schema/master.xsd - - - application/vnd.vmware.admin.vmwExternalNetworkReferences+xml - VMWExternalNetworkReferencesType - https://zone.myvcloud.com/api/v1.5/schema/vmwextensions.xsd - - - application/vnd.vmware.vcloud.networkConnectionSection+xml - NetworkConnectionSectionType - https://zone.myvcloud.com/api/v1.5/schema/master.xsd - - - application/vnd.vmware.admin.host+xml - HostType - https://zone.myvcloud.com/api/v1.5/schema/vmwextensions.xsd - - - application/vnd.vmware.vcloud.catalogItem+xml - CatalogItemType - https://zone.myvcloud.com/api/v1.5/schema/master.xsd - - - application/vnd.vmware.vcloud.owner+xml - OwnerType - https://zone.myvcloud.com/api/v1.5/schema/master.xsd - - - application/vnd.vmware.vcloud.vdc+xml - VdcType - https://zone.myvcloud.com/api/v1.5/schema/master.xsd - - - application/vnd.vmware.admin.vdc+xml - AdminVdcType - https://zone.myvcloud.com/api/v1.5/schema/master.xsd - - - application/vnd.vmware.admin.catalog+xml - AdminCatalogType - https://zone.myvcloud.com/api/v1.5/schema/master.xsd - - - application/vnd.vmware.vcloud.recomposeVAppParams+xml - RecomposeVAppParamsType - https://zone.myvcloud.com/api/v1.5/schema/master.xsd - - - application/vnd.vmware.admin.importVmIntoExistingVAppParams+xml - ImportVmIntoExistingVAppParamsType - https://zone.myvcloud.com/api/v1.5/schema/vmwextensions.xsd - - - application/vnd.vmware.admin.taskExtensionRequestUpdateProgressOperationParams+xml - TaskExtensionRequestUpdateProgressParamsType - https://zone.myvcloud.com/api/v1.5/schema/vmwextensions.xsd - - - application/vnd.vmware.vcloud.catalog+xml - CatalogType - https://zone.myvcloud.com/api/v1.5/schema/master.xsd - - - application/vnd.vmware.vcloud.cloneVAppTemplateParams+xml - CloneVAppTemplateParamsType - https://zone.myvcloud.com/api/v1.5/schema/master.xsd - - - application/vnd.vmware.admin.providervdc+xml - ProviderVdcType - https://zone.myvcloud.com/api/v1.5/schema/master.xsd - - - application/vnd.vmware.admin.vmsObjectRefsList+xml - VmObjectRefsListType - https://zone.myvcloud.com/api/v1.5/schema/vmwextensions.xsd - - - application/vnd.vmware.vcloud.undeployVAppParams+xml - UndeployVAppParamsType - https://zone.myvcloud.com/api/v1.5/schema/master.xsd - - - application/vnd.vmware.admin.vdcReferences+xml - VdcReferencesType - https://zone.myvcloud.com/api/v1.5/schema/master.xsd - - - application/vnd.vmware.admin.systemPasswordPolicySettings+xml - SystemPasswordPolicySettingsType - https://zone.myvcloud.com/api/v1.5/schema/vmwextensions.xsd - - - application/vnd.vmware.vcloud.vApp+xml - VAppType - https://zone.myvcloud.com/api/v1.5/schema/master.xsd - - - application/vnd.vmware.admin.taskExtensionRequest+xml - TaskExtensionRequestType - https://zone.myvcloud.com/api/v1.5/schema/vmwextensions.xsd - - - application/vnd.vmware.admin.vimServerNetworks+xml - VimObjectRefListType - https://zone.myvcloud.com/api/v1.5/schema/vmwextensions.xsd - - - application/vnd.vmware.admin.vmwprovidervdc+xml - VMWProviderVdcType - https://zone.myvcloud.com/api/v1.5/schema/vmwextensions.xsd - - - application/vnd.vmware.admin.orgSettings+xml - OrgSettingsType - https://zone.myvcloud.com/api/v1.5/schema/master.xsd - - - application/vnd.vmware.vcloud.captureVAppParams+xml - CaptureVAppParamsType - https://zone.myvcloud.com/api/v1.5/schema/master.xsd - - - application/vnd.vmware.vcloud.screenTicket+xml - ScreenTicketType - https://zone.myvcloud.com/api/v1.5/schema/master.xsd - - - application/vnd.vmware.vcloud.runtimeInfoSection+xml - RuntimeInfoSectionType - https://zone.myvcloud.com/api/v1.5/schema/master.xsd - - - application/vnd.vmware.vcloud.tasksList+xml - TasksListType - https://zone.myvcloud.com/api/v1.5/schema/master.xsd - - - application/vnd.vmware.admin.amqpSettingsTest+xml - AmqpSettingsTestType - https://zone.myvcloud.com/api/v1.5/schema/vmwextensions.xsd - - - application/vnd.vmware.admin.extensionSettings+xml - TaskExtensionSettingsType - https://zone.myvcloud.com/api/v1.5/schema/vmwextensions.xsd - - - application/vnd.vmware.admin.importVmAsVAppTemplateParams+xml - ImportVmAsVAppTemplateParamsType - https://zone.myvcloud.com/api/v1.5/schema/vmwextensions.xsd - - - application/vnd.vmware.admin.organizationGeneralSettings+xml - OrgGeneralSettingsType - https://zone.myvcloud.com/api/v1.5/schema/master.xsd - - - application/vnd.vmware.admin.registerVimServerParams+xml - RegisterVimServerParamsType - https://zone.myvcloud.com/api/v1.5/schema/vmwextensions.xsd - - - application/vnd.vmware.admin.network+xml - OrgNetworkType - https://zone.myvcloud.com/api/v1.5/schema/master.xsd - - - application/vnd.vmware.vcloud.uploadVAppTemplateParams+xml - UploadVAppTemplateParamsType - https://zone.myvcloud.com/api/v1.5/schema/master.xsd - - - application/vnd.vmware.admin.datastore+xml - DatastoreType - https://zone.myvcloud.com/api/v1.5/schema/vmwextensions.xsd - - - application/vnd.vmware.vcloud.metadata+xml - MetadataType - https://zone.myvcloud.com/api/v1.5/schema/master.xsd - - - application/vnd.vmware.admin.licensingReportList+xml - LicensingReportListType - https://zone.myvcloud.com/api/v1.5/schema/vmwextensions.xsd - - - application/vnd.vmware.admin.vmwNetworkPool+xml - VMWNetworkPoolType - https://zone.myvcloud.com/api/v1.5/schema/vmwextensions.xsd - - - application/vnd.vmware.admin.systemSettings+xml - SystemSettingsType - https://zone.myvcloud.com/api/v1.5/schema/vmwextensions.xsd - - - application/vnd.vmware.admin.vmwHostReferences+xml - VMWHostReferencesType - https://zone.myvcloud.com/api/v1.5/schema/vmwextensions.xsd - - - application/vnd.vmware.admin.taskExtensionRequestOperationParams+xml - TaskExtensionRequestOperationParamsType - https://zone.myvcloud.com/api/v1.5/schema/vmwextensions.xsd - - - application/vnd.vmware.vcloud.metadata.value+xml - MetadataValueType - https://zone.myvcloud.com/api/v1.5/schema/master.xsd - - - application/vnd.vmware.admin.taskOperationList+xml - TaskOperationListType - https://zone.myvcloud.com/api/v1.5/schema/master.xsd - - - application/vnd.vmware.vcloud.media+xml - MediaType - https://zone.myvcloud.com/api/v1.5/schema/master.xsd - - - application/vnd.vmware.vcloud.productSections+xml - ProductSectionListType - https://zone.myvcloud.com/api/v1.5/schema/master.xsd - - - application/vnd.vmware.admin.amqpSettings+xml - AmqpSettingsType - https://zone.myvcloud.com/api/v1.5/schema/vmwextensions.xsd - - - application/vnd.vmware.vcloud.vAppTemplate+xml - VAppTemplateType - https://zone.myvcloud.com/api/v1.5/schema/master.xsd - - - application/vnd.vmware.vcloud.deployVAppParams+xml - DeployVAppParamsType - https://zone.myvcloud.com/api/v1.5/schema/master.xsd - - - application/vnd.vmware.admin.importVmIntoExistingVAppTemplateParams+xml - ImportVmIntoExistingVAppTemplateParamsType - https://zone.myvcloud.com/api/v1.5/schema/vmwextensions.xsd - - - application/vnd.vmware.admin.resourcePoolList+xml - ResourcePoolListType - https://zone.myvcloud.com/api/v1.5/schema/vmwextensions.xsd - - - application/vnd.vmware.vcloud.networkConfigSection+xml - NetworkConfigSectionType - https://zone.myvcloud.com/api/v1.5/schema/master.xsd - - - application/vnd.vmware.admin.OrganizationVdcResourcePoolSet+xml - OrganizationResourcePoolSetType - https://zone.myvcloud.com/api/v1.5/schema/vmwextensions.xsd - - - application/vnd.vmware.admin.organizationPasswordPolicySettings+xml - OrgPasswordPolicySettingsType - https://zone.myvcloud.com/api/v1.5/schema/master.xsd - - - application/vnd.vmware.admin.publishCatalogParams+xml - PublishCatalogParamsType - https://zone.myvcloud.com/api/v1.5/schema/master.xsd - - - application/vnd.vmware.admin.vmwExtension+xml - VMWExtensionType - https://zone.myvcloud.com/api/v1.5/schema/vmwextensions.xsd - - - application/vnd.vmware.vcloud.mediaInsertOrEjectParams+xml - MediaInsertOrEjectParamsType - https://zone.myvcloud.com/api/v1.5/schema/master.xsd - - - application/vnd.vmware.vcloud.vmPendingQuestion+xml - VmPendingQuestionType - https://zone.myvcloud.com/api/v1.5/schema/master.xsd - - - application/vnd.vmware.admin.notificationsSettings+xml - NotificationsSettingsType - https://zone.myvcloud.com/api/v1.5/schema/vmwextensions.xsd - - - application/vnd.vmware.admin.ldapUserSettings+xml - LdapUserAttributesType - https://zone.myvcloud.com/api/v1.5/schema/vmwextensions.xsd - - - application/vnd.vmware.admin.right+xml - RightType - https://zone.myvcloud.com/api/v1.5/schema/master.xsd - - - application/vnd.vmware.admin.ldapSettings+xml - LdapSettingsType - https://zone.myvcloud.com/api/v1.5/schema/vmwextensions.xsd - - - application/vnd.vmware.admin.organization+xml - AdminOrgType - https://zone.myvcloud.com/api/v1.5/schema/master.xsd - - - application/vnd.vmware.vcloud.orgList+xml - OrgListType - https://zone.myvcloud.com/api/v1.5/schema/master.xsd - - - application/vnd.vmware.admin.vAppTemplateLeaseSettings+xml - OrgVAppTemplateLeaseSettingsType - https://zone.myvcloud.com/api/v1.5/schema/master.xsd - - - application/vnd.vmware.admin.vmwVimServerReferences+xml - VMWVimServerReferencesType - https://zone.myvcloud.com/api/v1.5/schema/vmwextensions.xsd - - - application/vnd.vmware.admin.vmwexternalnet+xml - VMWExternalNetworkType - https://zone.myvcloud.com/api/v1.5/schema/vmwextensions.xsd - - - application/vnd.vmware.vcloud.entity+xml - EntityType - https://zone.myvcloud.com/api/v1.5/schema/master.xsd - - - application/vnd.vmware.vcloud.cloneMediaParams+xml - CloneMediaParamsType - https://zone.myvcloud.com/api/v1.5/schema/master.xsd - - - application/vnd.vmware.admin.licensingReport+xml - LicensingReportType - https://zone.myvcloud.com/api/v1.5/schema/vmwextensions.xsd - - - application/vnd.vmware.admin.importMediaParams+xml - ImportMediaParamsType - https://zone.myvcloud.com/api/v1.5/schema/vmwextensions.xsd - - - application/vnd.vmware.admin.resourcePoolSetUpdateParams+xml - UpdateResourcePoolSetParamsType - https://zone.myvcloud.com/api/v1.5/schema/vmwextensions.xsd - - - application/vnd.vmware.admin.taskExtensionRequestList+xml - ReferencesType - https://zone.myvcloud.com/api/v1.5/schema/master.xsd - - - application/vnd.vmware.vcloud.vmPendingAnswer+xml - VmQuestionAnswerType - https://zone.myvcloud.com/api/v1.5/schema/master.xsd - - - application/vnd.vmware.vcloud.rasdItemsList+xml - RasdItemsListType - https://zone.myvcloud.com/api/v1.5/schema/master.xsd - - - application/vnd.vmware.admin.generalSettings+xml - GeneralSettingsType - https://zone.myvcloud.com/api/v1.5/schema/vmwextensions.xsd - - - application/vnd.vmware.admin.vmwNetworkPoolReferences+xml - VMWNetworkPoolReferencesType - https://zone.myvcloud.com/api/v1.5/schema/vmwextensions.xsd - - - application/vnd.vmware.admin.group+xml - GroupType - https://zone.myvcloud.com/api/v1.5/schema/master.xsd - - - application/vnd.vmware.vcloud.controlAccess+xml - ControlAccessParamsType - https://zone.myvcloud.com/api/v1.5/schema/master.xsd - - - application/vnd.vmware.admin.ldapGroupSettings+xml - LdapGroupAttributesType - https://zone.myvcloud.com/api/v1.5/schema/vmwextensions.xsd - - - application/vnd.vmware.admin.user+xml - UserType - https://zone.myvcloud.com/api/v1.5/schema/master.xsd - - - application/vnd.vmware.admin.vcloud+xml - VCloudType - https://zone.myvcloud.com/api/v1.5/schema/master.xsd - - - application/vnd.vmware.admin.uberAdminSettings+xml - UberAdminSettingsType - https://zone.myvcloud.com/api/v1.5/schema/vmwextensions.xsd - - - application/vnd.vmware.admin.vmwvirtualcenter+xml - VimServerType - https://zone.myvcloud.com/api/v1.5/schema/vmwextensions.xsd - - - application/vnd.vmware.vcloud.leaseSettingsSection+xml - LeaseSettingsSectionType - https://zone.myvcloud.com/api/v1.5/schema/master.xsd - - - application/vnd.vmware.vcloud.composeVAppParams+xml - ComposeVAppParamsType - https://zone.myvcloud.com/api/v1.5/schema/master.xsd - - - application/vnd.vmware.admin.organizationEmailSettings+xml - OrgEmailSettingsType - https://zone.myvcloud.com/api/v1.5/schema/master.xsd - - - application/vnd.vmware.vcloud.vm+xml - VmType - https://zone.myvcloud.com/api/v1.5/schema/master.xsd - - - application/vnd.vmware.admin.vmwProviderVdcResourcePoolSet+xml - VMWProviderVdcResourcePoolSetType - https://zone.myvcloud.com/api/v1.5/schema/vmwextensions.xsd - - - application/vnd.vmware.vcloud.cloneVAppParams+xml - CloneVAppParamsType - https://zone.myvcloud.com/api/v1.5/schema/master.xsd - - - application/vnd.vmware.vcloud.guestCustomizationSection+xml - GuestCustomizationSectionType - https://zone.myvcloud.com/api/v1.5/schema/master.xsd - - - application/vnd.vmware.vcloud.task+xml - TaskType - https://zone.myvcloud.com/api/v1.5/schema/master.xsd - - - application/vnd.vmware.vcloud.session+xml - SessionType - https://zone.myvcloud.com/api/v1.5/schema/master.xsd - - - application/vnd.vmware.admin.vAppLeaseSettings+xml - OrgLeaseSettingsType - https://zone.myvcloud.com/api/v1.5/schema/master.xsd - - - application/vnd.vmware.admin.importVmAsVAppParams+xml - ImportVmAsVAppParamsType - https://zone.myvcloud.com/api/v1.5/schema/vmwextensions.xsd - - - application/vnd.vmware.admin.role+xml - RoleType - https://zone.myvcloud.com/api/v1.5/schema/master.xsd - - - application/vnd.vmware.vcloud.rasdItem+xml - RASD_Type - https://zone.myvcloud.com/api/v1.5/schema/master.xsd - - - application/vnd.vmware.vcloud.startupSection+xml - StartupSection_Type - http://schemas.dmtf.org/ovf/envelope/1/dsp8023_1.1.0.xsd - - - application/vnd.vmware.vcloud.virtualHardwareSection+xml - VirtualHardwareSection_Type - http://schemas.dmtf.org/ovf/envelope/1/dsp8023_1.1.0.xsd - - - application/vnd.vmware.vcloud.operatingSystemSection+xml - OperatingSystemSection_Type - http://schemas.dmtf.org/ovf/envelope/1/dsp8023_1.1.0.xsd - - - application/vnd.vmware.vcloud.networkSection+xml - NetworkSection_Type - http://schemas.dmtf.org/ovf/envelope/1/dsp8023_1.1.0.xsd - - - application/vnd.vmware.vcloud.vAppNetwork+xml - VAppNetworkType - https://zone.myvcloud.com/api/v1.5/schema/master.xsd - - - application/vnd.vmware.vcloud.network+xml - NetworkType - https://zone.myvcloud.com/api/v1.5/schema/master.xsd - - - application/vnd.vmware.vcloud.orgNetwork+xml - OrgNetworkType - https://zone.myvcloud.com/api/v1.5/schema/master.xsd - - - application/vnd.vmware.admin.vmwexternalnet+xml - VMWExternalNetworkType - https://zone.myvcloud.com/api/v1.5/schema/vmwextensions.xsd - - - diff --git a/apis/vcloud/src/test/resources/versions.xml b/apis/vcloud/src/test/resources/versions.xml deleted file mode 100644 index 4651754418..0000000000 --- a/apis/vcloud/src/test/resources/versions.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - 0.8 - https://services.vcloudexpress.terremark.com/api/v0.8/login - - \ No newline at end of file diff --git a/apis/vcloud/src/test/resources/virtualhardwaresection.xml b/apis/vcloud/src/test/resources/virtualhardwaresection.xml deleted file mode 100644 index 24a0dd6e53..0000000000 --- a/apis/vcloud/src/test/resources/virtualhardwaresection.xml +++ /dev/null @@ -1,118 +0,0 @@ - - - Virtual hardware requirements - - Virtual Hardware Family - 0 - RHEL5 - vmx-07 - - - 00:50:56:01:01:f2 - 0 - true - internet01 - PCNet32 ethernet adapter - Network adapter 0 - 1 - PCNet32 - 10 - - - 0 - SCSI Controller - SCSI Controller 0 - 2 - lsilogic - 6 - - - 0 - Hard disk - Hard disk 1 - - 2000 - 2 - 17 - - - 0 - IDE Controller - IDE Controller 0 - 3 - 5 - - - 0 - false - CD/DVD Drive - CD/DVD Drive 1 - - 3002 - 3 - 15 - - - 0 - false - Floppy Drive - Floppy Drive 1 - - 8000 - 14 - - - hertz * 10^6 - Number of Virtual CPUs - 1 virtual CPU(s) - 4 - 0 - 3 - 1 - 0 - - - - byte * 2^20 - Memory Size - 384 MB of memory - 5 - 0 - 4 - 384 - 0 - - - - - - - - - - - - - \ No newline at end of file diff --git a/apis/vcloud/src/test/resources/vm-rhel-off-static.xml b/apis/vcloud/src/test/resources/vm-rhel-off-static.xml deleted file mode 100644 index 1df38a394e..0000000000 --- a/apis/vcloud/src/test/resources/vm-rhel-off-static.xml +++ /dev/null @@ -1,197 +0,0 @@ - - - - - - - - - - - - - Virtual hardware requirements - - Virtual Hardware Family - 0 - RHEL5 - vmx-07 - - - 00:50:56:01:01:f2 - 0 - true - internet01 - PCNet32 ethernet adapter - Network adapter 0 - 1 - PCNet32 - 10 - - - 0 - SCSI Controller - SCSI Controller 0 - 2 - lsilogic - 6 - - - 0 - Hard disk - Hard disk 1 - - 2000 - 2 - 17 - - - 0 - IDE Controller - IDE Controller 0 - 3 - 5 - - - 0 - false - CD/DVD Drive - CD/DVD Drive 1 - - 3002 - 3 - 15 - - - 0 - false - Floppy Drive - Floppy Drive 1 - - 8000 - 14 - - - hertz * 10^6 - Number of Virtual CPUs - 1 virtual CPU(s) - 4 - 0 - 3 - 1 - 0 - - - - byte * 2^20 - Memory Size - 384 MB of memory - 5 - 0 - 4 - 384 - 0 - - - - - - - - - - - - - - - Specifies the operating system installed - Red Hat Enterprise Linux 5 (64-bit) - - - - Specifies the available VM network connections - 0 - - 0 - 174.47.101.164 - true - 00:50:56:01:01:f2 - POOL - - - - - Specifies Guest OS Customization Settings - true - false - 2087535248 - false - false - true - true - false - cat > /root/foo.txt<<EOF -I '"love"' {asc|!}*& -EOF - - RHEL5 - - - 10_rhel_template - \ No newline at end of file diff --git a/compute/src/main/clojure/org/jclouds/compute2.clj b/compute/src/main/clojure/org/jclouds/compute2.clj index 75d80ba064..f9653a4835 100644 --- a/compute/src/main/clojure/org/jclouds/compute2.clj +++ b/compute/src/main/clojure/org/jclouds/compute2.clj @@ -19,8 +19,8 @@ "A clojure binding to the jclouds ComputeService. jclouds supports many compute providers including Amazon EC2 (aws-ec2), - Rackspace Cloud Servers (cloudservers-us), GoGrid (gogrid), and BlueLock - vCloud (bluelock-vcloud-zone01). There are over a dozen to choose from. + Rackspace Cloud Servers (cloudservers-us), GoGrid (gogrid), + There are over a dozen to choose from. Current supported providers are available via the following dependency: org.jclouds/jclouds-allcompute @@ -338,7 +338,7 @@ Here's an example of creating and running a small linux node in the group webser (merge (make-option-map kw-memfn-0arg - [;; ec2 trmk-ecloud trmk-vcloudexpress + [;; ec2 :no-key-pair ;; aws-ec2 :enable-monitoring :no-placement-group]) @@ -368,11 +368,7 @@ Here's an example of creating and running a small linux node in the group webser ;; cloudstack aws-ec2 :security-group-ids ;; softlayer - :domain-name - ;; trmk-ecloud trmk-vcloudexpress - :ssh-key-fingerprint - ;; vcloud - :description :customization-script :ip-address-allocation-mode]) + :domain-name]) (make-option-map kw-memfn-varargs [;; from TemplateOptions diff --git a/compute/src/test/java/org/jclouds/cim/xml/ResourceAllocationSettingDataHandlerTest.java b/compute/src/test/java/org/jclouds/cim/xml/ResourceAllocationSettingDataHandlerTest.java deleted file mode 100644 index abe2b7ea7c..0000000000 --- a/compute/src/test/java/org/jclouds/cim/xml/ResourceAllocationSettingDataHandlerTest.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.cim.xml; - -import static org.testng.Assert.assertEquals; - -import java.io.InputStream; - -import org.jclouds.cim.ResourceAllocationSettingData; -import org.jclouds.http.functions.BaseHandlerTest; -import org.testng.annotations.Test; - -/** - * Tests behavior of {@code ResourceAllocationSettingDataHandler} - */ -// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire -@Test(groups = "unit", testName = "ResourceAllocationSettingDataHandlerTest") -public class ResourceAllocationSettingDataHandlerTest extends BaseHandlerTest { - - public void testNormal() { - InputStream is = getClass().getResourceAsStream("/resourceallocation.xml"); - - ResourceAllocationSettingData result = factory.create( - injector.getInstance(ResourceAllocationSettingDataHandler.class)).parse(is); - - ResourceAllocationSettingData expects = ResourceAllocationSettingData.builder().allocationUnits("Gigabytes") - .caption("1234568").description("Hard Disk").elementName("D:\\").hostResource("data").instanceID("6") - .resourceType(ResourceAllocationSettingData.ResourceType.PARTITIONABLE_UNIT).virtualQuantity(50l) - .build(); - assertEquals(result.toString(), expects.toString()); - } - - public void testHosting() { - InputStream is = getClass().getResourceAsStream("/resourceallocation-hosting.xml"); - - ResourceAllocationSettingData result = factory.create( - injector.getInstance(ResourceAllocationSettingDataHandler.class)).parse(is); - - ResourceAllocationSettingData expects = ResourceAllocationSettingData.builder().elementName("1 virtual CPU(s)") - .allocationUnits("hertz * 10^6").instanceID("1").resourceType(ResourceAllocationSettingData.ResourceType.PROCESSOR) - .virtualQuantity(1l).description("Number of Virtual CPUs").virtualQuantityUnits("count").build(); - assertEquals(result.toString(), expects.toString()); - - } -} diff --git a/compute/src/test/java/org/jclouds/cim/xml/VirtualSystemSettingDataHandlerTest.java b/compute/src/test/java/org/jclouds/cim/xml/VirtualSystemSettingDataHandlerTest.java deleted file mode 100644 index 912c2bfc79..0000000000 --- a/compute/src/test/java/org/jclouds/cim/xml/VirtualSystemSettingDataHandlerTest.java +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.cim.xml; - -import static org.testng.Assert.assertEquals; - -import java.io.InputStream; - -import org.jclouds.cim.ResourceAllocationSettingData; -import org.jclouds.cim.VirtualSystemSettingData; -import org.jclouds.cim.ResourceAllocationSettingData.ResourceType; -import org.jclouds.http.functions.BaseHandlerTest; -import org.jclouds.http.functions.ParseSax; -import org.jclouds.http.functions.ParseSax.Factory; -import org.jclouds.http.functions.config.SaxParserModule; -import org.jclouds.ovf.OperatingSystemSection; -import org.jclouds.ovf.VirtualHardwareSection; -import org.jclouds.ovf.VirtualSystem; -import org.jclouds.ovf.internal.BaseVirtualSystem; -import org.jclouds.ovf.xml.VirtualSystemHandler; -import org.testng.annotations.Test; - -import com.google.common.collect.Iterables; -import com.google.inject.Guice; -import com.google.inject.Injector; - -/** - * Tests behavior of {@code VirtualSystemSettingDataHandler} - */ -// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire -@Test(groups = "unit", testName = "VirtualSystemSettingDataHandlerTest") -public class VirtualSystemSettingDataHandlerTest extends BaseHandlerTest { - - public void testApplyInputStream() { - InputStream is = getClass().getResourceAsStream("/virtualsystem-hosting.xml"); - - VirtualSystemSettingData result = factory.create(injector.getInstance(VirtualSystemSettingDataHandler.class)) - .parse(is); - - VirtualSystemSettingData expects = VirtualSystemSettingData.builder().instanceID("0").elementName( - "Virtual Hardware Family").virtualSystemIdentifier("SimpleVM").virtualSystemType("vmx-04").build(); - assertEquals(result, expects); - - } - - public void testVCloud1_0() { - InputStream is = getClass().getResourceAsStream("/virtualsystem.xml"); - Injector injector = Guice.createInjector(new SaxParserModule()); - Factory factory = injector.getInstance(ParseSax.Factory.class); - VirtualSystem result = factory.create(injector.getInstance(VirtualSystemHandler.class)).parse(is); - checkVirtualSystem(result); - } - - @Test(enabled = false) - public static > void checkVirtualSystem(BaseVirtualSystem result) { - assertEquals(result.getId(), "Ubuntu1004"); - assertEquals(result.getName(), "Ubuntu1004"); - assertEquals(result.getInfo(), "A virtual machine:"); - checkHardware(Iterables.get(result.getVirtualHardwareSections(), 0)); - checkOs(result.getOperatingSystemSection()); - } - - @Test(enabled = false) - public static void checkHardware(VirtualHardwareSection result) { - assertEquals(result.getSystem(), VirtualSystemSettingData.builder().instanceID("0").elementName( - "Virtual Hardware Family").virtualSystemIdentifier("Ubuntu1004").virtualSystemType("vmx-07").build()); - assertEquals(result.getInfo(), "Virtual hardware requirements"); - - assertEquals(Iterables.get(result.getItems(), 0).toString(), ResourceAllocationSettingData - .builder().instanceID("1").elementName("Network adapter 0").description("PCNet32 ethernet adapter") - .resourceType(ResourceType.ETHERNET_ADAPTER).resourceSubType("PCNet32").address("00:50:56:8c:00:13") - .automaticAllocation(true).connection("vAppNet-vApp Internal").addressOnParent("0").build().toString()); - - assertEquals(Iterables.get(result.getItems(), 1).toString(), ResourceAllocationSettingData - .builder().instanceID("2").elementName("SCSI Controller 0").description("SCSI Controller").resourceType( - ResourceType.PARALLEL_SCSI_HBA).resourceSubType("lsilogic").address("0").build().toString()); - - assertEquals(Iterables.get(result.getItems(), 2).toString(), ResourceAllocationSettingData - .builder().instanceID("2000").elementName("Hard disk 1").description("Hard disk").resourceType( - ResourceType.DISK_DRIVE).addressOnParent("0").parent("2").build().toString()); - - assertEquals(Iterables.get(result.getItems(), 3).toString(), ResourceAllocationSettingData - .builder().instanceID("3").elementName("IDE Controller 0").description("IDE Controller").resourceType( - ResourceType.IDE_CONTROLLER).address("0").build().toString()); - - assertEquals(Iterables.get(result.getItems(), 4).toString(), ResourceAllocationSettingData - .builder().instanceID("3002").elementName("CD/DVD Drive 1").description("CD/DVD Drive").resourceType( - ResourceType.CD_DRIVE).addressOnParent("0").parent("3").automaticAllocation(false).build() - .toString()); - - assertEquals(Iterables.get(result.getItems(), 5).toString(), ResourceAllocationSettingData - .builder().instanceID("8000").elementName("Floppy Drive 1").description("Floppy Drive").resourceType( - ResourceType.FLOPPY_DRIVE).addressOnParent("0").automaticAllocation(false).build().toString()); - - assertEquals(Iterables.get(result.getItems(), 6).toString(), ResourceAllocationSettingData - .builder().instanceID("4").elementName("1 virtual CPU(s)").description("Number of Virtual CPUs") - .resourceType(ResourceType.PROCESSOR).virtualQuantity(1l).allocationUnits("hertz * 10^6") - .reservation(0l).weight(0).build().toString()); - - assertEquals(Iterables.get(result.getItems(), 7).toString(), ResourceAllocationSettingData - .builder().instanceID("5").elementName("512 MB of memory").description("Memory Size").resourceType( - ResourceType.MEMORY).virtualQuantity(512l).allocationUnits("byte * 2^20").reservation(0l) - .weight(0).build().toString()); - } - - @Test(enabled = false) - public static void checkOs(OperatingSystemSection result) { - assertEquals(result.getDescription(), "Ubuntu Linux (64-bit)"); - assertEquals(result.getId(), Integer.valueOf(94)); - assertEquals(result.getInfo(), "Specifies the operating system installed"); - } -} diff --git a/compute/src/test/java/org/jclouds/ovf/xml/EnvelopeHandlerTest.java b/compute/src/test/java/org/jclouds/ovf/xml/EnvelopeHandlerTest.java deleted file mode 100644 index e8a237b6f0..0000000000 --- a/compute/src/test/java/org/jclouds/ovf/xml/EnvelopeHandlerTest.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.ovf.xml; - -import java.io.InputStream; - -import org.jclouds.cim.xml.VirtualSystemSettingDataHandlerTest; -import org.jclouds.http.functions.ParseSax; -import org.jclouds.http.functions.ParseSax.Factory; -import org.jclouds.http.functions.config.SaxParserModule; -import org.jclouds.ovf.Envelope; -import org.testng.annotations.Test; - -import com.google.inject.Guice; -import com.google.inject.Injector; - -/** - * Tests behavior of {@code EnvelopeHandler} - */ -@Test(groups = "unit") -public class EnvelopeHandlerTest { - public void testVCloud1_0() { - Envelope result = parseEnvelope(); - checkOvfEnvelope(result); - } - - public static Envelope parseEnvelope() { - InputStream is = EnvelopeHandlerTest.class.getResourceAsStream("/ovf.xml"); - Injector injector = Guice.createInjector(new SaxParserModule()); - Factory factory = injector.getInstance(ParseSax.Factory.class); - Envelope result = factory.create(injector.getInstance(EnvelopeHandler.class)).parse(is); - return result; - } - - //TODO: create a parser that can! - @Test(expectedExceptions = IllegalArgumentException.class) - public void testThrowIllegalArgumentAsWeDontYetSupportVirtualSystemCollections() { - InputStream is = getClass().getResourceAsStream("/ovf-vcd1.5.xml"); - Injector injector = Guice.createInjector(new SaxParserModule()); - Factory factory = injector.getInstance(ParseSax.Factory.class); - factory.create(injector.getInstance(EnvelopeHandler.class)).parse(is).getVirtualSystem(); - } - - static void checkOvfEnvelope(Envelope result) { - VirtualSystemSettingDataHandlerTest.checkVirtualSystem(result.getVirtualSystem()); - } - -} diff --git a/compute/src/test/resources/os.xml b/compute/src/test/resources/os.xml deleted file mode 100644 index 3196a272f6..0000000000 --- a/compute/src/test/resources/os.xml +++ /dev/null @@ -1,11 +0,0 @@ - - Specifies the operating system installed - Red Hat Enterprise Linux 5 (64-bit) - - \ No newline at end of file diff --git a/compute/src/test/resources/ovf-vcd1.5.xml b/compute/src/test/resources/ovf-vcd1.5.xml deleted file mode 100644 index d815e42786..0000000000 --- a/compute/src/test/resources/ovf-vcd1.5.xml +++ /dev/null @@ -1,338 +0,0 @@ - - - - - The list of logical networks - - - - - - - - - The configuration parameters for logical networks - - - - - false - 192.168.2.1 - 255.255.255.0 - 109.233.48.141 - - - 192.168.2.100 - 192.168.2.199 - - - - isolated - - - false - 3600 - 7200 - - 192.168.2.2 - 192.168.2.99 - - - - - false - - - - - - true - 212.54.128.1 - 255.255.255.0 - 109.233.48.141 - 109.233.48.142 - - - 212.54.128.4 - 212.54.128.220 - - - - bridged - - - false - 3600 - 7200 - - 212.54.128.2 - 212.54.128.3 - - - - true - - - true - ipTranslation - allowTraffic - - - automatic - 72591b67-ea8f-4ae8-8a05-3e0a857d1e7b - 0 - - - - - - false - - - - Lease settings section - 0 - 0 - - - VApp template customization section - true - - - A collection of virtual machines: - Windows 2008 R2 Standard (base) no service pack - - VApp startup section - - - - - A virtual machine: Standard Edition - Windows 2008R2 Standard - - Specifies the operating system installed - Microsoft Windows Server 2008 R2 (64-bit) - - - Virtual hardware requirements - - Virtual Hardware Family - 0 - Windows 2008R2 Standard - vmx-07 - - - 00:50:56:01:00:02 - 0 - true - StratoGen Ext Net - PCNet32 ethernet adapter - Network adapter 0 - 1 - PCNet32 - 10 - - - 0 - SCSI Controller - SCSI Controller 0 - 2 - lsilogicsas - 6 - - - 0 - Hard disk - Hard disk 1 - - 2000 - 2 - 17 - - - 0 - IDE Controller - IDE Controller 0 - 3 - 5 - - - 0 - false - CD/DVD Drive - CD/DVD Drive 1 - - 3000 - 3 - 15 - - - 0 - false - Floppy Drive - Floppy Drive 1 - - 8000 - 14 - - - hertz * 10^6 - Number of Virtual CPUs - 1 virtual CPU(s) - 4 - 0 - 3 - 1 - 0 - - - byte * 2^20 - Memory Size - 2048 MB of memory - 5 - 0 - 4 - 2048 - 0 - - - - Specifies the available VM network connections - 0 - - 0 - 212.54.128.101 - true - 00:50:56:01:00:02 - POOL - - - - Specifies Guest OS Customization Settings - true - true - false - false - true - true - 7qS$$3d# - false - WindowsServ-0 - - - - A virtual machine: Windows 2008 R2 Standard Edition[\r] - Windows 2008 R2 Standard (Base) NO SP1 - - Specifies the operating system installed - Microsoft Windows Server 2008 R2 (64-bit) - - - Virtual hardware requirements - - Virtual Hardware Family - 0 - Windows 2008 R2 Standard (Base) NO SP1 - vmx-07 - - - 00:50:56:01:02:38 - 0 - true - int - PCNet32 ethernet adapter - Network adapter 0 - 1 - PCNet32 - 10 - - - 0 - SCSI Controller - SCSI Controller 0 - 2 - lsilogicsas - 6 - - - 0 - Hard disk - Hard disk 1 - - 2000 - 2 - 17 - - - 0 - IDE Controller - IDE Controller 0 - 3 - 5 - - - 0 - false - CD/DVD Drive - CD/DVD Drive 1 - - 3000 - 3 - 15 - - - 0 - false - Floppy Drive - Floppy Drive 1 - - 8000 - 14 - - - hertz * 10^6 - Number of Virtual CPUs - 1 virtual CPU(s) - 4 - 0 - 3 - 1 - 0 - - - byte * 2^20 - Memory Size - 2048 MB of memory - 5 - 0 - 4 - 2048 - 0 - - - - Specifies the available VM network connections - 0 - - 0 - 192.168.2.100 - true - 00:50:56:01:02:38 - POOL - - - - Specifies Guest OS Customization Settings - true - true - false - false - true - true - 4cV!Lunc - false - WindowsServer20 - - - - \ No newline at end of file diff --git a/compute/src/test/resources/ovf.xml b/compute/src/test/resources/ovf.xml deleted file mode 100644 index 383c27cc71..0000000000 --- a/compute/src/test/resources/ovf.xml +++ /dev/null @@ -1,183 +0,0 @@ - - - - - The list of logical networks - - - - - - The configuration parameters for logical networks - - - - - false - 192.168.2.1 - 255.255.255.0 - 8.8.8.8 - - - 192.168.2.100 - 192.168.2.199 - - - - 192.168.2.100 - - - isolated - - - false - 7200 - 7200 - - - - true - - - true - ipTranslation - allowTraffic - - - automatic - 02_ubuntu_template - 0 - - - - - - false - - - - Lease settings section - 0 - 0 - - - VApp template customization section - true - - - A virtual machine: - Ubuntu1004 - - Specifies the operating system installed - Ubuntu Linux (64-bit) - - - Virtual hardware requirements - - Virtual Hardware Family - 0 - Ubuntu1004 - vmx-07 - - - 00:50:56:8c:00:13 - 0 - true - vAppNet-vApp Internal - PCNet32 ethernet adapter - Network adapter 0 - 1 - PCNet32 - 10 - - - 0 - SCSI Controller - SCSI Controller 0 - 2 - lsilogic - 6 - - - 0 - Hard disk - Hard disk 1 - - 2000 - 2 - 17 - - - 0 - IDE Controller - IDE Controller 0 - 3 - 5 - - - 0 - false - CD/DVD Drive - CD/DVD Drive 1 - - 3002 - 3 - 15 - - - 0 - false - Floppy Drive - Floppy Drive 1 - - 8000 - 14 - - - hertz * 10^6 - Number of Virtual CPUs - 1 virtual CPU(s) - 4 - 0 - 3 - 1 - 0 - - - byte * 2^20 - Memory Size - 512 MB of memory - 5 - 0 - 4 - 512 - 0 - - - - Specifies the available VM network connections - 0 - - 0 - 192.168.2.100 - true - 00:50:56:8c:00:13 - POOL - - - - Specifies Guest OS Customization Settings - true - false - 172837194 - false - false - true - true - %3eD%gmF - false - #!/bin/bash if [ "$1" = "postcustomization" ]; then echo "post customization" touch /root/.postcustomization sleep 30 #regenerate keys /bin/rm /etc/ssh/ssh_host_* /usr/sbin/dpkg-reconfigure openssh-server echo "completed" fi - Ubuntu1004 - - - \ No newline at end of file diff --git a/compute/src/test/resources/resourceallocation-hosting.xml b/compute/src/test/resources/resourceallocation-hosting.xml deleted file mode 100644 index e9a1ead3ca..0000000000 --- a/compute/src/test/resources/resourceallocation-hosting.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - hertz * 10^6 - Number of Virtual CPUs - 1 virtual CPU(s) - 1 - 3 - 1 - count - - \ No newline at end of file diff --git a/compute/src/test/resources/virtualhardwaresection.xml b/compute/src/test/resources/virtualhardwaresection.xml deleted file mode 100644 index 24a0dd6e53..0000000000 --- a/compute/src/test/resources/virtualhardwaresection.xml +++ /dev/null @@ -1,118 +0,0 @@ - - - Virtual hardware requirements - - Virtual Hardware Family - 0 - RHEL5 - vmx-07 - - - 00:50:56:01:01:f2 - 0 - true - internet01 - PCNet32 ethernet adapter - Network adapter 0 - 1 - PCNet32 - 10 - - - 0 - SCSI Controller - SCSI Controller 0 - 2 - lsilogic - 6 - - - 0 - Hard disk - Hard disk 1 - - 2000 - 2 - 17 - - - 0 - IDE Controller - IDE Controller 0 - 3 - 5 - - - 0 - false - CD/DVD Drive - CD/DVD Drive 1 - - 3002 - 3 - 15 - - - 0 - false - Floppy Drive - Floppy Drive 1 - - 8000 - 14 - - - hertz * 10^6 - Number of Virtual CPUs - 1 virtual CPU(s) - 4 - 0 - 3 - 1 - 0 - - - - byte * 2^20 - Memory Size - 384 MB of memory - 5 - 0 - 4 - 384 - 0 - - - - - - - - - - - - - \ No newline at end of file diff --git a/compute/src/test/resources/virtualsystem-hosting.xml b/compute/src/test/resources/virtualsystem-hosting.xml deleted file mode 100644 index 15d8567974..0000000000 --- a/compute/src/test/resources/virtualsystem-hosting.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - Virtual Hardware Family - 0 - SimpleVM - vmx-04 - - - \ No newline at end of file diff --git a/compute/src/test/resources/virtualsystem.xml b/compute/src/test/resources/virtualsystem.xml deleted file mode 100644 index 0eb2a03098..0000000000 --- a/compute/src/test/resources/virtualsystem.xml +++ /dev/null @@ -1,127 +0,0 @@ - - - A virtual machine: - Ubuntu1004 - - Specifies the operating system installed - Ubuntu Linux (64-bit) - - - Virtual hardware requirements - - Virtual Hardware Family - 0 - Ubuntu1004 - vmx-07 - - - 00:50:56:8c:00:13 - 0 - true - vAppNet-vApp Internal - PCNet32 ethernet adapter - Network adapter 0 - 1 - PCNet32 - 10 - - - 0 - SCSI Controller - SCSI Controller 0 - 2 - lsilogic - 6 - - - 0 - Hard disk - Hard disk 1 - - 2000 - 2 - 17 - - - 0 - IDE Controller - IDE Controller 0 - 3 - 5 - - - 0 - false - CD/DVD Drive - CD/DVD Drive 1 - - 3002 - 3 - 15 - - - 0 - false - Floppy Drive - Floppy Drive 1 - - 8000 - 14 - - - hertz * 10^6 - Number of Virtual CPUs - 1 virtual CPU(s) - 4 - 0 - 3 - 1 - 0 - - - byte * 2^20 - Memory Size - 512 MB of memory - 5 - 0 - 4 - 512 - 0 - - - - Specifies the available VM network connections - 0 - - 0 - 192.168.2.100 - true - 00:50:56:8c:00:13 - POOL - - - - Specifies Guest OS Customization Settings - true - false - 172837194 - false - false - true - true - %3eD%gmF - false - #!/bin/bash if [ "$1" = "postcustomization" ]; then echo "post customization" touch /root/.postcustomization sleep 30 #regenerate keys /bin/rm /etc/ssh/ssh_host_* /usr/sbin/dpkg-reconfigure openssh-server echo "completed" fi - Ubuntu1004 - - \ No newline at end of file diff --git a/core/src/main/java/org/jclouds/Constants.java b/core/src/main/java/org/jclouds/Constants.java index a1e77a149d..b58551192e 100644 --- a/core/src/main/java/org/jclouds/Constants.java +++ b/core/src/main/java/org/jclouds/Constants.java @@ -231,8 +231,7 @@ public final class Constants { * Explicitly identifies the build that the server jclouds connects to is running. * * For example, for virtualbox, the api version may be {@code 4.1.8} while the build version is - * {@code 4.1.8r75467}. Or a vcloud endpoint may be api version {@code 1.0} while the build is - * {@code 1.5.0.0.124312} + * {@code 4.1.8r75467}. */ public static final String PROPERTY_BUILD_VERSION = "jclouds.build-version"; diff --git a/core/src/main/java/org/jclouds/apis/ApiMetadata.java b/core/src/main/java/org/jclouds/apis/ApiMetadata.java index 96595abbca..acc48bc04f 100644 --- a/core/src/main/java/org/jclouds/apis/ApiMetadata.java +++ b/core/src/main/java/org/jclouds/apis/ApiMetadata.java @@ -142,7 +142,7 @@ public interface ApiMetadata { /** * - * @return the api's unique identifier (ex. vcloud, virtualbox) + * @return the api's unique identifier (ex. ec2, openstack-nova) */ String getId(); @@ -164,7 +164,7 @@ public interface ApiMetadata { *

* * @return the name (display name) of an endpoint to this api (ex. Keystone - * url, vCloud Director URL). + * url). */ String getEndpointName(); @@ -193,8 +193,7 @@ public interface ApiMetadata { * running. * * For example, for virtualbox, the api version may be {@code 4.1.8} while - * the build version is {@code 4.1.8r75467}. Or a vcloud endpoint may be api - * version {@code 1.0} while the build is {@code 1.5.0.0.124312} + * the build version is {@code 4.1.8r75467}. */ Optional getBuildVersion(); diff --git a/core/src/test/java/org/jclouds/http/UrisTest.java b/core/src/test/java/org/jclouds/http/UrisTest.java index 8abdd527b6..2dbef5ed25 100644 --- a/core/src/test/java/org/jclouds/http/UrisTest.java +++ b/core/src/test/java/org/jclouds/http/UrisTest.java @@ -113,13 +113,7 @@ public class UrisTest { @Test public void testNoDoubleSlashInPath() { - assertEquals(uriBuilder("https://vcloud/api/").appendPath("/").build().toASCIIString(), "https://vcloud/api/"); - } - - @Test - public void testWhenUrnInPath() { - assertEquals(uriBuilder("https://vcloud/api").appendPath("urn::acme:foo").build(templateParams).toASCIIString(), - "https://vcloud/api/urn::acme:foo"); + assertEquals(uriBuilder("https://cloud/api/").appendPath("/").build().toASCIIString(), "https://cloud/api/"); } @Test