diff --git a/vcloud/bluelock/src/main/java/org/jclouds/vcloud/bluelock/compute/BlueLockVCloudDirectorComputeClient.java b/vcloud/bluelock/src/main/java/org/jclouds/vcloud/bluelock/compute/BlueLockVCloudDirectorComputeClient.java index 1a6f6494d4..c3fb7c564e 100644 --- a/vcloud/bluelock/src/main/java/org/jclouds/vcloud/bluelock/compute/BlueLockVCloudDirectorComputeClient.java +++ b/vcloud/bluelock/src/main/java/org/jclouds/vcloud/bluelock/compute/BlueLockVCloudDirectorComputeClient.java @@ -45,7 +45,7 @@ public class BlueLockVCloudDirectorComputeClient extends VCloudComputeClientImpl @Inject protected BlueLockVCloudDirectorComputeClient(PopulateDefaultLoginCredentialsForImageStrategy credentialsProvider, - VCloudClient client, Predicate successTester, Map vAppStatusToNodeState) { + VCloudClient client, Predicate successTester, Map vAppStatusToNodeState) { super(client, successTester, vAppStatusToNodeState); this.credentialsProvider = credentialsProvider; } diff --git a/vcloud/bluelock/src/main/java/org/jclouds/vcloud/bluelock/compute/BlueLockVCloudExpressComputeClient.java b/vcloud/bluelock/src/main/java/org/jclouds/vcloud/bluelock/compute/BlueLockVCloudExpressComputeClient.java index 6e38405efe..382bcd87c9 100644 --- a/vcloud/bluelock/src/main/java/org/jclouds/vcloud/bluelock/compute/BlueLockVCloudExpressComputeClient.java +++ b/vcloud/bluelock/src/main/java/org/jclouds/vcloud/bluelock/compute/BlueLockVCloudExpressComputeClient.java @@ -30,8 +30,8 @@ import org.jclouds.compute.strategy.PopulateDefaultLoginCredentialsForImageStrat import org.jclouds.domain.Credentials; import org.jclouds.vcloud.VCloudExpressClient; import org.jclouds.vcloud.compute.internal.VCloudExpressComputeClientImpl; -import org.jclouds.vcloud.domain.VApp; import org.jclouds.vcloud.domain.Status; +import org.jclouds.vcloud.domain.VCloudExpressVApp; import org.jclouds.vcloud.domain.VCloudExpressVAppTemplate; import com.google.common.base.Predicate; @@ -45,13 +45,14 @@ public class BlueLockVCloudExpressComputeClient extends VCloudExpressComputeClie @Inject protected BlueLockVCloudExpressComputeClient(PopulateDefaultLoginCredentialsForImageStrategy credentialsProvider, - VCloudExpressClient client, Predicate successTester, Map vAppStatusToNodeState) { + VCloudExpressClient client, Predicate successTester, Map vAppStatusToNodeState) { super(client, successTester, vAppStatusToNodeState); this.credentialsProvider = credentialsProvider; } @Override - protected Map parseAndValidateResponse(VCloudExpressVAppTemplate template, VApp vAppResponse) { + protected Map parseAndValidateResponse(VCloudExpressVAppTemplate template, + VCloudExpressVApp vAppResponse) { Credentials credentials = credentialsProvider.execute(template); Map toReturn = super.parseResponse(template, vAppResponse); toReturn.put("username", credentials.identity); diff --git a/vcloud/core/src/main/java/org/jclouds/vcloud/CommonVCloudAsyncClient.java b/vcloud/core/src/main/java/org/jclouds/vcloud/CommonVCloudAsyncClient.java index 45e5f340a8..731055b628 100644 --- a/vcloud/core/src/main/java/org/jclouds/vcloud/CommonVCloudAsyncClient.java +++ b/vcloud/core/src/main/java/org/jclouds/vcloud/CommonVCloudAsyncClient.java @@ -25,7 +25,6 @@ import static org.jclouds.vcloud.VCloudMediaType.NETWORK_XML; import static org.jclouds.vcloud.VCloudMediaType.ORG_XML; import static org.jclouds.vcloud.VCloudMediaType.TASKSLIST_XML; import static org.jclouds.vcloud.VCloudMediaType.TASK_XML; -import static org.jclouds.vcloud.VCloudMediaType.VAPP_XML; import static org.jclouds.vcloud.VCloudMediaType.VDC_XML; import java.net.URI; @@ -48,7 +47,6 @@ import org.jclouds.vcloud.domain.CatalogItem; import org.jclouds.vcloud.domain.Org; import org.jclouds.vcloud.domain.Task; import org.jclouds.vcloud.domain.TasksList; -import org.jclouds.vcloud.domain.VApp; import org.jclouds.vcloud.domain.VDC; import org.jclouds.vcloud.domain.network.OrgNetwork; import org.jclouds.vcloud.filters.SetVCloudTokenCookie; @@ -64,7 +62,6 @@ import org.jclouds.vcloud.xml.OrgHandler; import org.jclouds.vcloud.xml.OrgNetworkHandler; import org.jclouds.vcloud.xml.TaskHandler; import org.jclouds.vcloud.xml.TasksListHandler; -import org.jclouds.vcloud.xml.VAppHandler; import org.jclouds.vcloud.xml.VDCHandler; import com.google.common.util.concurrent.ListenableFuture; @@ -283,25 +280,5 @@ public interface CommonVCloudAsyncClient { @Path("/action/cancel") ListenableFuture cancelTask(@EndpointParam URI taskId); - /** - * @see VCloudClient#findVAppInOrgVDCNamed - */ - @GET - @Consumes(VAPP_XML) - @XMLResponseParser(VAppHandler.class) - @ExceptionParser(ReturnNullOnNotFoundOr404.class) - ListenableFuture findVAppInOrgVDCNamed( - @Nullable @EndpointParam(parser = OrgNameVDCNameResourceEntityNameToEndpoint.class) String orgName, - @Nullable @EndpointParam(parser = OrgNameVDCNameResourceEntityNameToEndpoint.class) String catalogName, - @EndpointParam(parser = OrgNameVDCNameResourceEntityNameToEndpoint.class) String vAppName); - - /** - * @see VCloudClient#getVApp - */ - @GET - @Consumes(VAPP_XML) - @XMLResponseParser(VAppHandler.class) - @ExceptionParser(ReturnNullOnNotFoundOr404.class) - ListenableFuture getVApp(@EndpointParam URI vApp); } diff --git a/vcloud/core/src/main/java/org/jclouds/vcloud/CommonVCloudClient.java b/vcloud/core/src/main/java/org/jclouds/vcloud/CommonVCloudClient.java index 744547350f..0ef26f4966 100644 --- a/vcloud/core/src/main/java/org/jclouds/vcloud/CommonVCloudClient.java +++ b/vcloud/core/src/main/java/org/jclouds/vcloud/CommonVCloudClient.java @@ -31,7 +31,6 @@ import org.jclouds.vcloud.domain.CatalogItem; import org.jclouds.vcloud.domain.Org; import org.jclouds.vcloud.domain.Task; import org.jclouds.vcloud.domain.TasksList; -import org.jclouds.vcloud.domain.VApp; import org.jclouds.vcloud.domain.VDC; import org.jclouds.vcloud.domain.network.OrgNetwork; @@ -149,8 +148,5 @@ public interface CommonVCloudClient { void cancelTask(URI taskId); - VApp findVAppInOrgVDCNamed(@Nullable String orgName, @Nullable String catalogName, String vAppName); - - VApp getVApp(URI vApp); } diff --git a/vcloud/core/src/main/java/org/jclouds/vcloud/VCloudAsyncClient.java b/vcloud/core/src/main/java/org/jclouds/vcloud/VCloudAsyncClient.java index 894005b27c..8ce555b2e1 100644 --- a/vcloud/core/src/main/java/org/jclouds/vcloud/VCloudAsyncClient.java +++ b/vcloud/core/src/main/java/org/jclouds/vcloud/VCloudAsyncClient.java @@ -48,6 +48,7 @@ import org.jclouds.vcloud.domain.VApp; import org.jclouds.vcloud.domain.VAppTemplate; import org.jclouds.vcloud.filters.SetVCloudTokenCookie; import org.jclouds.vcloud.functions.OrgNameCatalogNameVAppTemplateNameToEndpoint; +import org.jclouds.vcloud.functions.OrgNameVDCNameResourceEntityNameToEndpoint; import org.jclouds.vcloud.options.CloneVAppOptions; import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions; import org.jclouds.vcloud.xml.TaskHandler; @@ -60,8 +61,7 @@ import com.google.common.util.concurrent.ListenableFuture; * Provides access to VCloud resources via their REST API. *

* - * @see + * @see * @author Adrian Cole */ @RequestFilters(SetVCloudTokenCookie.class) @@ -84,9 +84,9 @@ public interface VCloudAsyncClient extends CommonVCloudAsyncClient { @XMLResponseParser(VAppTemplateHandler.class) @ExceptionParser(ReturnNullOnNotFoundOr404.class) ListenableFuture findVAppTemplateInOrgCatalogNamed( - @Nullable @EndpointParam(parser = OrgNameCatalogNameVAppTemplateNameToEndpoint.class) String orgName, - @Nullable @EndpointParam(parser = OrgNameCatalogNameVAppTemplateNameToEndpoint.class) String catalogName, - @EndpointParam(parser = OrgNameCatalogNameVAppTemplateNameToEndpoint.class) String itemName); + @Nullable @EndpointParam(parser = OrgNameCatalogNameVAppTemplateNameToEndpoint.class) String orgName, + @Nullable @EndpointParam(parser = OrgNameCatalogNameVAppTemplateNameToEndpoint.class) String catalogName, + @EndpointParam(parser = OrgNameCatalogNameVAppTemplateNameToEndpoint.class) String itemName); /** * @see VCloudClient#instantiateVAppTemplateInVDC @@ -99,9 +99,9 @@ public interface VCloudAsyncClient extends CommonVCloudAsyncClient { // TODO convert this. @MapBinder(BindInstantiateVCloudExpressVAppTemplateParamsToXmlPayload.class) ListenableFuture instantiateVAppTemplateInVDC(@EndpointParam URI vdc, - @MapPayloadParam("template") URI template, - @MapPayloadParam("name") @ParamValidators(DnsNameValidator.class) String appName, - InstantiateVAppTemplateOptions... options); + @MapPayloadParam("template") URI template, + @MapPayloadParam("name") @ParamValidators(DnsNameValidator.class) String appName, + InstantiateVAppTemplateOptions... options); /** * @see VCloudClient#cloneVAppInVDC @@ -113,7 +113,27 @@ public interface VCloudAsyncClient extends CommonVCloudAsyncClient { @XMLResponseParser(TaskHandler.class) @MapBinder(BindCloneVAppParamsToXmlPayload.class) ListenableFuture cloneVAppInVDC(@EndpointParam URI vdc, @MapPayloadParam("vApp") URI toClone, - @MapPayloadParam("newName") @ParamValidators(DnsNameValidator.class) String newName, - CloneVAppOptions... options); + @MapPayloadParam("newName") @ParamValidators(DnsNameValidator.class) String newName, + CloneVAppOptions... options); + /** + * @see VCloudClient#findVAppInOrgVDCNamed + */ + @GET + @Consumes(VAPP_XML) + @XMLResponseParser(VAppHandler.class) + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + ListenableFuture findVAppInOrgVDCNamed( + @Nullable @EndpointParam(parser = OrgNameVDCNameResourceEntityNameToEndpoint.class) String orgName, + @Nullable @EndpointParam(parser = OrgNameVDCNameResourceEntityNameToEndpoint.class) String catalogName, + @EndpointParam(parser = OrgNameVDCNameResourceEntityNameToEndpoint.class) String vAppName); + + /** + * @see VCloudClient#getVApp + */ + @GET + @Consumes(VAPP_XML) + @XMLResponseParser(VAppHandler.class) + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + ListenableFuture getVApp(@EndpointParam URI vApp); } diff --git a/vcloud/core/src/main/java/org/jclouds/vcloud/VCloudClient.java b/vcloud/core/src/main/java/org/jclouds/vcloud/VCloudClient.java index 7712181672..7caa1d4b71 100644 --- a/vcloud/core/src/main/java/org/jclouds/vcloud/VCloudClient.java +++ b/vcloud/core/src/main/java/org/jclouds/vcloud/VCloudClient.java @@ -36,9 +36,7 @@ import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions; * Provides access to VCloud resources via their REST API. *

* - * @see + * @see * @author Adrian Cole */ @Timeout(duration = 300, timeUnit = TimeUnit.SECONDS) @@ -51,9 +49,8 @@ public interface VCloudClient extends CommonVCloudClient { VAppTemplate getVAppTemplate(URI vAppTemplate); /** - * 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. + * 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 @@ -63,9 +60,12 @@ public interface VCloudClient extends CommonVCloudClient { * item you wish to lookup * * @throws NoSuchElementException - * if you specified an org, catalog, or catalog item name that - * isn't present + * if you specified an org, catalog, or catalog item name that isn't present */ VAppTemplate findVAppTemplateInOrgCatalogNamed(@Nullable String orgName, @Nullable String catalogName, - String itemName); + String itemName); + + VApp findVAppInOrgVDCNamed(@Nullable String orgName, @Nullable String catalogName, String vAppName); + + VApp getVApp(URI vApp); } diff --git a/vcloud/core/src/main/java/org/jclouds/vcloud/VCloudExpressAsyncClient.java b/vcloud/core/src/main/java/org/jclouds/vcloud/VCloudExpressAsyncClient.java index 3e7c1ad38d..f7217eec4b 100644 --- a/vcloud/core/src/main/java/org/jclouds/vcloud/VCloudExpressAsyncClient.java +++ b/vcloud/core/src/main/java/org/jclouds/vcloud/VCloudExpressAsyncClient.java @@ -45,7 +45,7 @@ import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; import org.jclouds.vcloud.binders.BindCloneVAppParamsToXmlPayload; import org.jclouds.vcloud.binders.BindInstantiateVCloudExpressVAppTemplateParamsToXmlPayload; import org.jclouds.vcloud.domain.Task; -import org.jclouds.vcloud.domain.VApp; +import org.jclouds.vcloud.domain.VCloudExpressVApp; import org.jclouds.vcloud.domain.VCloudExpressVAppTemplate; import org.jclouds.vcloud.domain.network.OrgNetwork; import org.jclouds.vcloud.filters.SetVCloudTokenCookie; @@ -55,7 +55,7 @@ import org.jclouds.vcloud.options.CloneVAppOptions; import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions; import org.jclouds.vcloud.xml.OrgNetworkFromVCloudExpressNetworkHandler; import org.jclouds.vcloud.xml.TaskHandler; -import org.jclouds.vcloud.xml.VAppHandler; +import org.jclouds.vcloud.xml.VCloudExpressVAppHandler; import org.jclouds.vcloud.xml.VCloudExpressVAppTemplateHandler; import com.google.common.util.concurrent.ListenableFuture; @@ -64,8 +64,7 @@ import com.google.common.util.concurrent.ListenableFuture; * Provides access to VCloud resources via their REST API. *

* - * @see + * @see * @author Adrian Cole */ @RequestFilters(SetVCloudTokenCookie.class) @@ -88,9 +87,9 @@ public interface VCloudExpressAsyncClient extends CommonVCloudAsyncClient { @XMLResponseParser(VCloudExpressVAppTemplateHandler.class) @ExceptionParser(ReturnNullOnNotFoundOr404.class) ListenableFuture findVAppTemplateInOrgCatalogNamed( - @Nullable @EndpointParam(parser = OrgNameCatalogNameVAppTemplateNameToEndpoint.class) String orgName, - @Nullable @EndpointParam(parser = OrgNameCatalogNameVAppTemplateNameToEndpoint.class) String catalogName, - @EndpointParam(parser = OrgNameCatalogNameVAppTemplateNameToEndpoint.class) String itemName); + @Nullable @EndpointParam(parser = OrgNameCatalogNameVAppTemplateNameToEndpoint.class) String orgName, + @Nullable @EndpointParam(parser = OrgNameCatalogNameVAppTemplateNameToEndpoint.class) String catalogName, + @EndpointParam(parser = OrgNameCatalogNameVAppTemplateNameToEndpoint.class) String itemName); /** * @see VCloudClient#findNetworkInOrgVDCNamed @@ -101,9 +100,9 @@ public interface VCloudExpressAsyncClient extends CommonVCloudAsyncClient { @XMLResponseParser(OrgNetworkFromVCloudExpressNetworkHandler.class) @ExceptionParser(ReturnNullOnNotFoundOr404.class) ListenableFuture findNetworkInOrgVDCNamed( - @Nullable @EndpointParam(parser = OrgNameVDCNameResourceEntityNameToEndpoint.class) String orgName, - @Nullable @EndpointParam(parser = OrgNameVDCNameResourceEntityNameToEndpoint.class) String catalogName, - @EndpointParam(parser = OrgNameVDCNameResourceEntityNameToEndpoint.class) String networkName); + @Nullable @EndpointParam(parser = OrgNameVDCNameResourceEntityNameToEndpoint.class) String orgName, + @Nullable @EndpointParam(parser = OrgNameVDCNameResourceEntityNameToEndpoint.class) String catalogName, + @EndpointParam(parser = OrgNameVDCNameResourceEntityNameToEndpoint.class) String networkName); /** * @see VCloudClient#getNetwork @@ -122,12 +121,12 @@ public interface VCloudExpressAsyncClient extends CommonVCloudAsyncClient { @Path("action/instantiateVAppTemplate") @Produces("application/vnd.vmware.vcloud.instantiateVAppTemplateParams+xml") @Consumes(VAPP_XML) - @XMLResponseParser(VAppHandler.class) + @XMLResponseParser(VCloudExpressVAppHandler.class) @MapBinder(BindInstantiateVCloudExpressVAppTemplateParamsToXmlPayload.class) - ListenableFuture instantiateVAppTemplateInVDC(@EndpointParam URI vdc, - @MapPayloadParam("template") URI template, - @MapPayloadParam("name") @ParamValidators(DnsNameValidator.class) String appName, - InstantiateVAppTemplateOptions... options); + ListenableFuture instantiateVAppTemplateInVDC(@EndpointParam URI vdc, + @MapPayloadParam("template") URI template, + @MapPayloadParam("name") @ParamValidators(DnsNameValidator.class) String appName, + InstantiateVAppTemplateOptions... options); /** * @see VCloudExpressClient#cloneVAppInVDC @@ -139,7 +138,27 @@ public interface VCloudExpressAsyncClient extends CommonVCloudAsyncClient { @XMLResponseParser(TaskHandler.class) @MapBinder(BindCloneVAppParamsToXmlPayload.class) ListenableFuture cloneVAppInVDC(@EndpointParam URI vdc, @MapPayloadParam("vApp") URI toClone, - @MapPayloadParam("newName") @ParamValidators(DnsNameValidator.class) String newName, - CloneVAppOptions... options); + @MapPayloadParam("newName") @ParamValidators(DnsNameValidator.class) String newName, + CloneVAppOptions... options); + /** + * @see VCloudClient#findVAppInOrgVDCNamed + */ + @GET + @Consumes(VAPP_XML) + @XMLResponseParser(VCloudExpressVAppHandler.class) + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + ListenableFuture findVAppInOrgVDCNamed( + @Nullable @EndpointParam(parser = OrgNameVDCNameResourceEntityNameToEndpoint.class) String orgName, + @Nullable @EndpointParam(parser = OrgNameVDCNameResourceEntityNameToEndpoint.class) String catalogName, + @EndpointParam(parser = OrgNameVDCNameResourceEntityNameToEndpoint.class) String vAppName); + + /** + * @see VCloudClient#getVApp + */ + @GET + @Consumes(VAPP_XML) + @XMLResponseParser(VCloudExpressVAppHandler.class) + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + ListenableFuture getVApp(@EndpointParam URI vApp); } diff --git a/vcloud/core/src/main/java/org/jclouds/vcloud/VCloudExpressClient.java b/vcloud/core/src/main/java/org/jclouds/vcloud/VCloudExpressClient.java index acd6926c32..6a1223f00c 100644 --- a/vcloud/core/src/main/java/org/jclouds/vcloud/VCloudExpressClient.java +++ b/vcloud/core/src/main/java/org/jclouds/vcloud/VCloudExpressClient.java @@ -27,7 +27,7 @@ import javax.annotation.Nullable; import org.jclouds.concurrent.Timeout; import org.jclouds.vcloud.domain.Task; -import org.jclouds.vcloud.domain.VApp; +import org.jclouds.vcloud.domain.VCloudExpressVApp; import org.jclouds.vcloud.domain.VCloudExpressVAppTemplate; import org.jclouds.vcloud.options.CloneVAppOptions; import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions; @@ -36,23 +36,22 @@ import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions; * Provides access to VCloud resources via their REST API. *

* - * @see + * @see * @author Adrian Cole */ @Timeout(duration = 300, timeUnit = TimeUnit.SECONDS) public interface VCloudExpressClient extends CommonVCloudClient { - VApp instantiateVAppTemplateInVDC(URI vDC, URI template, String appName, InstantiateVAppTemplateOptions... options); + VCloudExpressVApp instantiateVAppTemplateInVDC(URI vDC, URI template, String appName, + InstantiateVAppTemplateOptions... options); Task cloneVAppInVDC(URI vDC, URI toClone, String newName, CloneVAppOptions... options); VCloudExpressVAppTemplate getVAppTemplate(URI vAppTemplate); /** - * 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. + * 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 @@ -62,9 +61,12 @@ public interface VCloudExpressClient extends CommonVCloudClient { * item you wish to lookup * * @throws NoSuchElementException - * if you specified an org, catalog, or catalog item name that - * isn't present + * if you specified an org, catalog, or catalog item name that isn't present */ VCloudExpressVAppTemplate findVAppTemplateInOrgCatalogNamed(@Nullable String orgName, @Nullable String catalogName, - String itemName); + String itemName); + + VCloudExpressVApp findVAppInOrgVDCNamed(@Nullable String orgName, @Nullable String catalogName, String vAppName); + + VCloudExpressVApp getVApp(URI vApp); } diff --git a/vcloud/core/src/main/java/org/jclouds/vcloud/compute/config/CommonVCloudComputeServiceContextModule.java b/vcloud/core/src/main/java/org/jclouds/vcloud/compute/config/CommonVCloudComputeServiceContextModule.java index c1b926d71a..ed3c4835fd 100644 --- a/vcloud/core/src/main/java/org/jclouds/vcloud/compute/config/CommonVCloudComputeServiceContextModule.java +++ b/vcloud/core/src/main/java/org/jclouds/vcloud/compute/config/CommonVCloudComputeServiceContextModule.java @@ -31,16 +31,12 @@ import org.jclouds.compute.domain.Image; import org.jclouds.compute.domain.NodeState; import org.jclouds.compute.domain.Size; import org.jclouds.compute.strategy.DestroyNodeStrategy; -import org.jclouds.compute.strategy.GetNodeMetadataStrategy; -import org.jclouds.compute.strategy.ListNodesStrategy; import org.jclouds.compute.strategy.RebootNodeStrategy; import org.jclouds.compute.strategy.RunNodesAndAddToSetStrategy; import org.jclouds.compute.strategy.impl.EncodeTagIntoNameRunNodesAndAddToSetStrategy; import org.jclouds.domain.Location; import org.jclouds.vcloud.compute.internal.VCloudComputeClientImpl; import org.jclouds.vcloud.compute.strategy.VCloudDestroyNodeStrategy; -import org.jclouds.vcloud.compute.strategy.VCloudGetNodeMetadataStrategy; -import org.jclouds.vcloud.compute.strategy.VCloudListNodesStrategy; import org.jclouds.vcloud.compute.strategy.VCloudRebootNodeStrategy; import org.jclouds.vcloud.compute.suppliers.OrgAndVDCToLocationSupplier; import org.jclouds.vcloud.compute.suppliers.StaticSizeSupplier; @@ -82,8 +78,6 @@ public abstract class CommonVCloudComputeServiceContextModule extends BaseComput install(new ComputeServiceTimeoutsModule()); bind(DestroyNodeStrategy.class).to(VCloudDestroyNodeStrategy.class); bind(RunNodesAndAddToSetStrategy.class).to(EncodeTagIntoNameRunNodesAndAddToSetStrategy.class); - bind(ListNodesStrategy.class).to(VCloudListNodesStrategy.class); - bind(GetNodeMetadataStrategy.class).to(VCloudGetNodeMetadataStrategy.class); bind(RebootNodeStrategy.class).to(VCloudRebootNodeStrategy.class); bindLoadBalancer(); } diff --git a/vcloud/core/src/main/java/org/jclouds/vcloud/compute/config/VCloudComputeServiceContextModule.java b/vcloud/core/src/main/java/org/jclouds/vcloud/compute/config/VCloudComputeServiceContextModule.java index e8b6a8c5bf..598de01280 100644 --- a/vcloud/core/src/main/java/org/jclouds/vcloud/compute/config/VCloudComputeServiceContextModule.java +++ b/vcloud/core/src/main/java/org/jclouds/vcloud/compute/config/VCloudComputeServiceContextModule.java @@ -25,6 +25,8 @@ import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.Image; import org.jclouds.compute.internal.ComputeServiceContextImpl; import org.jclouds.compute.strategy.AddNodeWithTagStrategy; +import org.jclouds.compute.strategy.GetNodeMetadataStrategy; +import org.jclouds.compute.strategy.ListNodesStrategy; import org.jclouds.rest.RestContext; import org.jclouds.rest.internal.RestContextImpl; import org.jclouds.vcloud.VCloudClient; @@ -33,6 +35,8 @@ import org.jclouds.vcloud.compute.VCloudComputeClient; import org.jclouds.vcloud.compute.functions.ImagesInOrg; import org.jclouds.vcloud.compute.internal.VCloudComputeClientImpl; import org.jclouds.vcloud.compute.strategy.VCloudAddNodeWithTagStrategy; +import org.jclouds.vcloud.compute.strategy.VCloudGetNodeMetadataStrategy; +import org.jclouds.vcloud.compute.strategy.VCloudListNodesStrategy; import org.jclouds.vcloud.domain.Org; import com.google.common.base.Function; @@ -51,6 +55,7 @@ public class VCloudComputeServiceContextModule extends CommonVCloudComputeServic @Override protected void configure() { super.configure(); + bind(GetNodeMetadataStrategy.class).to(VCloudGetNodeMetadataStrategy.class); bind(new TypeLiteral() { }).to(new TypeLiteral>() { }).in(Scopes.SINGLETON); @@ -61,6 +66,7 @@ public class VCloudComputeServiceContextModule extends CommonVCloudComputeServic }).to(new TypeLiteral() { }); bind(AddNodeWithTagStrategy.class).to(VCloudAddNodeWithTagStrategy.class); + bind(ListNodesStrategy.class).to(VCloudListNodesStrategy.class); } @Provides diff --git a/vcloud/core/src/main/java/org/jclouds/vcloud/compute/config/VCloudExpressComputeServiceContextModule.java b/vcloud/core/src/main/java/org/jclouds/vcloud/compute/config/VCloudExpressComputeServiceContextModule.java index 8fb87981b8..2d7735878a 100755 --- a/vcloud/core/src/main/java/org/jclouds/vcloud/compute/config/VCloudExpressComputeServiceContextModule.java +++ b/vcloud/core/src/main/java/org/jclouds/vcloud/compute/config/VCloudExpressComputeServiceContextModule.java @@ -25,6 +25,8 @@ import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.Image; import org.jclouds.compute.internal.ComputeServiceContextImpl; import org.jclouds.compute.strategy.AddNodeWithTagStrategy; +import org.jclouds.compute.strategy.GetNodeMetadataStrategy; +import org.jclouds.compute.strategy.ListNodesStrategy; import org.jclouds.rest.RestContext; import org.jclouds.rest.internal.RestContextImpl; import org.jclouds.vcloud.VCloudExpressClient; @@ -33,6 +35,8 @@ import org.jclouds.vcloud.compute.VCloudExpressComputeClient; import org.jclouds.vcloud.compute.functions.ImagesInVCloudExpressOrg; import org.jclouds.vcloud.compute.internal.VCloudExpressComputeClientImpl; import org.jclouds.vcloud.compute.strategy.VCloudExpressAddNodeWithTagStrategy; +import org.jclouds.vcloud.compute.strategy.VCloudExpressGetNodeMetadataStrategy; +import org.jclouds.vcloud.compute.strategy.VCloudExpressListNodesStrategy; import org.jclouds.vcloud.domain.Org; import com.google.common.base.Function; @@ -51,6 +55,7 @@ public class VCloudExpressComputeServiceContextModule extends CommonVCloudComput @Override protected void configure() { super.configure(); + bind(GetNodeMetadataStrategy.class).to(VCloudExpressGetNodeMetadataStrategy.class); bind(new TypeLiteral() { }).to(new TypeLiteral>() { }).in(Scopes.SINGLETON); @@ -61,6 +66,7 @@ public class VCloudExpressComputeServiceContextModule extends CommonVCloudComput }).to(new TypeLiteral() { }); bind(AddNodeWithTagStrategy.class).to(VCloudExpressAddNodeWithTagStrategy.class); + bind(ListNodesStrategy.class).to(VCloudExpressListNodesStrategy.class); } @Provides diff --git a/vcloud/core/src/main/java/org/jclouds/vcloud/compute/functions/GetExtraFromVApp.java b/vcloud/core/src/main/java/org/jclouds/vcloud/compute/functions/GetExtraFromVApp.java new file mode 100644 index 0000000000..2fcd398eda --- /dev/null +++ b/vcloud/core/src/main/java/org/jclouds/vcloud/compute/functions/GetExtraFromVApp.java @@ -0,0 +1,73 @@ +/** + * + * Copyright (C) 2010 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS 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.collect.Maps.newHashMap; + +import java.util.Map; + +import javax.annotation.Resource; +import javax.inject.Singleton; + +import org.jclouds.logging.Logger; +import org.jclouds.vcloud.compute.internal.VCloudExpressComputeClientImpl; +import org.jclouds.vcloud.domain.VApp; + +import com.google.common.base.Function; + +/** + * Configures the {@link VCloudComputeServiceContext}; requires + * {@link VCloudExpressComputeClientImpl} bound. + * + * @author Adrian Cole + */ +@Singleton +public class GetExtraFromVApp implements Function> { + + @Resource + protected Logger logger = Logger.NULL; + + public Map apply(VApp vApp) { + Map extra = newHashMap(); + try { + // TODO + // extra.put("memory/mb", find(vApp.getResourceAllocations(), + // resourceType(ResourceType.MEMORY)) + // .getVirtualQuantity() + // + ""); + // extra.put("processor/count", find(vApp.getResourceAllocations(), + // resourceType(ResourceType.PROCESSOR)) + // .getVirtualQuantity() + // + ""); + // for (ResourceAllocation disk : filter(vApp.getResourceAllocations(), + // resourceType(ResourceType.DISK_DRIVE))) { + // extra.put(String.format("disk_drive/%s/kb", disk.getAddressOnParent()), + // disk.getVirtualQuantity() + ""); + // } + // + // for (Entry net : vApp.getNetworkToAddresses().entries()) { + // extra.put(String.format("network/%s/ip", net.getKey()), net.getValue()); + // } + } catch (Exception e) { + logger.error(e, "error getting extra data for vApp: %s", vApp); + } + return extra; + } +} \ No newline at end of file diff --git a/vcloud/core/src/main/java/org/jclouds/vcloud/compute/functions/GetExtra.java b/vcloud/core/src/main/java/org/jclouds/vcloud/compute/functions/GetExtraFromVCloudExpressVApp.java similarity index 92% rename from vcloud/core/src/main/java/org/jclouds/vcloud/compute/functions/GetExtra.java rename to vcloud/core/src/main/java/org/jclouds/vcloud/compute/functions/GetExtraFromVCloudExpressVApp.java index 87ea870f6a..c41a7917ea 100644 --- a/vcloud/core/src/main/java/org/jclouds/vcloud/compute/functions/GetExtra.java +++ b/vcloud/core/src/main/java/org/jclouds/vcloud/compute/functions/GetExtraFromVCloudExpressVApp.java @@ -34,7 +34,7 @@ import org.jclouds.logging.Logger; import org.jclouds.vcloud.compute.internal.VCloudExpressComputeClientImpl; import org.jclouds.vcloud.domain.ResourceAllocation; import org.jclouds.vcloud.domain.ResourceType; -import org.jclouds.vcloud.domain.VApp; +import org.jclouds.vcloud.domain.VCloudExpressVApp; import com.google.common.base.Function; @@ -45,12 +45,12 @@ import com.google.common.base.Function; * @author Adrian Cole */ @Singleton -public class GetExtra implements Function> { +public class GetExtraFromVCloudExpressVApp implements Function> { @Resource protected Logger logger = Logger.NULL; - public Map apply(VApp vApp) { + public Map apply(VCloudExpressVApp vApp) { Map extra = newHashMap(); try { extra.put("memory/mb", find(vApp.getResourceAllocations(), resourceType(ResourceType.MEMORY)) diff --git a/vcloud/core/src/main/java/org/jclouds/vcloud/compute/internal/CommonVCloudComputeClientImpl.java b/vcloud/core/src/main/java/org/jclouds/vcloud/compute/internal/CommonVCloudComputeClientImpl.java index 2d953a9f82..c061da6120 100644 --- a/vcloud/core/src/main/java/org/jclouds/vcloud/compute/internal/CommonVCloudComputeClientImpl.java +++ b/vcloud/core/src/main/java/org/jclouds/vcloud/compute/internal/CommonVCloudComputeClientImpl.java @@ -33,21 +33,19 @@ import org.jclouds.compute.reference.ComputeServiceConstants; import org.jclouds.logging.Logger; import org.jclouds.vcloud.CommonVCloudClient; import org.jclouds.vcloud.compute.CommonVCloudComputeClient; +import org.jclouds.vcloud.domain.NamedResource; import org.jclouds.vcloud.domain.Status; import org.jclouds.vcloud.domain.Task; -import org.jclouds.vcloud.domain.VApp; import com.google.common.base.Predicate; -import com.google.common.collect.ImmutableSet; import com.google.common.collect.Maps; -import com.google.common.collect.Sets; import com.google.inject.Inject; /** * @author Adrian Cole */ @Singleton -public class CommonVCloudComputeClientImpl implements CommonVCloudComputeClient { +public abstract class CommonVCloudComputeClientImpl implements CommonVCloudComputeClient { @Resource @Named(ComputeServiceConstants.COMPUTE_LOGGER) protected Logger logger = Logger.NULL; @@ -61,7 +59,7 @@ public class CommonVCloudComputeClientImpl implements CommonVCloudComputeClie this.taskTester = successTester; } - protected Map parseAndValidateResponse(T template, VApp vAppResponse) { + protected Map parseAndValidateResponse(T template, A vAppResponse) { Map response = parseResponse(template, vAppResponse); checkState(response.containsKey("id"), "bad configuration: [id] should be in response"); checkState(response.containsKey("username"), "bad configuration: [username] should be in response"); @@ -69,7 +67,7 @@ public class CommonVCloudComputeClientImpl implements CommonVCloudComputeClie return response; } - protected Map parseResponse(T template, VApp vAppResponse) { + protected Map parseResponse(T template, A vAppResponse) { Map config = Maps.newLinkedHashMap();// Allows nulls config.put("id", vAppResponse.getId().toASCIIString()); config.put("username", null); @@ -79,99 +77,65 @@ public class CommonVCloudComputeClientImpl implements CommonVCloudComputeClie @Override public void reboot(URI id) { - VApp vApp = client.getVApp(id); + A vApp = refreshVApp(id); logger.debug(">> resetting vApp(%s)", vApp.getName()); Task task = client.resetVApp(vApp.getId()); if (!taskTester.apply(task.getLocation())) { - throw new TaskException("resetVApp", vApp, task); + throw new RuntimeException(String.format("failed to %s %s: %s", "resetVApp", vApp.getName(), task)); } logger.debug("<< on vApp(%s)", vApp.getName()); } + protected abstract A refreshVApp(URI id); + @Override public void stop(URI id) { - VApp vApp = client.getVApp(id); + A vApp = refreshVApp(id); vApp = powerOffVAppIfDeployed(vApp); vApp = undeployVAppIfDeployed(vApp); deleteVApp(vApp); logger.debug("<< deleted vApp(%s)", vApp.getName()); } - private void deleteVApp(VApp vApp) { + private void deleteVApp(A vApp) { logger.debug(">> deleting vApp(%s)", vApp.getName()); client.deleteVApp(vApp.getId()); } - private VApp undeployVAppIfDeployed(VApp vApp) { - if (vApp.getStatus().compareTo(Status.RESOLVED) > 0) { - logger.debug(">> undeploying vApp(%s), current status: %s", vApp.getName(), vApp.getStatus()); + private A undeployVAppIfDeployed(A vApp) { + if (getStatus(vApp).compareTo(Status.RESOLVED) > 0) { + logger.debug(">> undeploying vApp(%s), current status: %s", vApp.getName(), getStatus(vApp)); Task task = client.undeployVApp(vApp.getId()); if (!taskTester.apply(task.getLocation())) { - throw new TaskException("undeploy", vApp, task); + // TODO timeout + throw new RuntimeException(String.format("failed to %s %s: %s", "undeploy", vApp.getName(), task)); } - vApp = client.getVApp(vApp.getId()); - logger.debug("<< %s vApp(%s)", vApp.getStatus(), vApp.getName()); + vApp = refreshVApp(vApp.getId()); + logger.debug("<< %s vApp(%s)", getStatus(vApp), vApp.getName()); } return vApp; } - private VApp powerOffVAppIfDeployed(VApp vApp) { - if (vApp.getStatus().compareTo(Status.OFF) > 0) { - logger.debug(">> powering off vApp(%s), current status: %s", vApp.getName(), vApp.getStatus()); + private A powerOffVAppIfDeployed(A vApp) { + if (getStatus(vApp).compareTo(Status.OFF) > 0) { + logger.debug(">> powering off vApp(%s), current status: %s", vApp.getName(), getStatus(vApp)); Task task = client.powerOffVApp(vApp.getId()); if (!taskTester.apply(task.getLocation())) { - throw new TaskException("powerOff", vApp, task); + // TODO timeout + throw new RuntimeException(String.format("failed to %s %s: %s", "powerOff", vApp.getName(), task)); } - vApp = client.getVApp(vApp.getId()); - logger.debug("<< %s vApp(%s)", vApp.getStatus(), vApp.getName()); + vApp = refreshVApp(vApp.getId()); + logger.debug("<< %s vApp(%s)", getStatus(vApp), vApp.getName()); } return vApp; } - public static class TaskException extends VAppException { - - private final Task task; - /** The serialVersionUID */ - private static final long serialVersionUID = 251801929573211256L; - - public TaskException(String type, VApp vApp, Task task) { - super(String.format("failed to %s vApp %s status %s;task %s status %s", type, vApp.getName(), - vApp.getStatus(), task.getLocation(), task.getStatus()), vApp); - this.task = task; - } - - public Task getTask() { - return task; - } - - } - - public static class VAppException extends RuntimeException { - - private final VApp vApp; - /** The serialVersionUID */ - private static final long serialVersionUID = 251801929573211256L; - - public VAppException(String message, VApp vApp) { - super(message); - this.vApp = vApp; - } - - public VApp getvApp() { - return vApp; - } - - } + protected abstract Status getStatus(A vApp); @Override - public Set getPrivateAddresses(URI id) { - return ImmutableSet.of(); - } + public abstract Set getPrivateAddresses(URI id); @Override - public Set getPublicAddresses(URI id) { - VApp vApp = client.getVApp(id); - return Sets.newHashSet(vApp.getNetworkToAddresses().values()); - } + public abstract Set getPublicAddresses(URI id); } \ No newline at end of file diff --git a/vcloud/core/src/main/java/org/jclouds/vcloud/compute/internal/VCloudComputeClientImpl.java b/vcloud/core/src/main/java/org/jclouds/vcloud/compute/internal/VCloudComputeClientImpl.java index d6c0a10f1e..becb98aef3 100644 --- a/vcloud/core/src/main/java/org/jclouds/vcloud/compute/internal/VCloudComputeClientImpl.java +++ b/vcloud/core/src/main/java/org/jclouds/vcloud/compute/internal/VCloudComputeClientImpl.java @@ -23,6 +23,7 @@ import static com.google.common.base.Preconditions.checkNotNull; import java.net.URI; import java.util.Map; +import java.util.Set; import javax.annotation.Nullable; import javax.inject.Singleton; @@ -38,26 +39,28 @@ import org.jclouds.vcloud.domain.VDC; import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions; import com.google.common.base.Predicate; +import com.google.common.collect.ImmutableSet; import com.google.inject.Inject; /** * @author Adrian Cole */ @Singleton -public class VCloudComputeClientImpl extends CommonVCloudComputeClientImpl implements VCloudComputeClient { +public class VCloudComputeClientImpl extends CommonVCloudComputeClientImpl implements + VCloudComputeClient { protected final Map vAppStatusToNodeState; @Inject public VCloudComputeClientImpl(VCloudClient client, Predicate successTester, - Map vAppStatusToNodeState) { + Map vAppStatusToNodeState) { super(client, successTester); this.vAppStatusToNodeState = vAppStatusToNodeState; } @Override public Map start(@Nullable URI VDC, URI templateId, String name, - InstantiateVAppTemplateOptions options, int... portsToOpen) { + InstantiateVAppTemplateOptions options, int... portsToOpen) { checkNotNull(options, "options"); logger.debug(">> instantiating vApp vDC(%s) template(%s) name(%s) options(%s) ", VDC, templateId, name, options); @@ -65,7 +68,7 @@ public class VCloudComputeClientImpl extends CommonVCloudComputeClientImpl> deploying vApp(%s)", vAppResponse.getName()); @@ -73,17 +76,40 @@ public class VCloudComputeClientImpl extends CommonVCloudComputeClientImpl> powering vApp(%s)", vAppResponse.getName()); task = client.powerOnVApp(vAppResponse.getId()); if (!taskTester.apply(task.getLocation())) { - throw new TaskException("powerOn", vAppResponse, task); + throw new RuntimeException(String.format("failed to %s %s: %s", "powerOn", vAppResponse.getName(), task)); } logger.debug("<< on vApp(%s)", vAppResponse.getName()); } return parseAndValidateResponse(template, vAppResponse); } + + @Override + public Set getPrivateAddresses(URI id) { + return ImmutableSet.of(); + } + + @Override + public Set getPublicAddresses(URI id) { + return ImmutableSet.of(); + // TODO + // VApp vApp = refreshVApp(id); + // return Sets.newHashSet(vApp.getNetworkToAddresses().values()); + } + + @Override + protected Status getStatus(VApp vApp) { + return vApp.getStatus(); + } + + @Override + protected VApp refreshVApp(URI id) { + return VCloudClient.class.cast(client).getVApp(id); + } } \ No newline at end of file diff --git a/vcloud/core/src/main/java/org/jclouds/vcloud/compute/internal/VCloudExpressComputeClientImpl.java b/vcloud/core/src/main/java/org/jclouds/vcloud/compute/internal/VCloudExpressComputeClientImpl.java index 3aa2dc7192..37899441bb 100644 --- a/vcloud/core/src/main/java/org/jclouds/vcloud/compute/internal/VCloudExpressComputeClientImpl.java +++ b/vcloud/core/src/main/java/org/jclouds/vcloud/compute/internal/VCloudExpressComputeClientImpl.java @@ -23,6 +23,7 @@ import static com.google.common.base.Preconditions.checkNotNull; import java.net.URI; import java.util.Map; +import java.util.Set; import javax.annotation.Nullable; import javax.inject.Singleton; @@ -32,41 +33,44 @@ import org.jclouds.vcloud.VCloudExpressClient; import org.jclouds.vcloud.compute.VCloudExpressComputeClient; import org.jclouds.vcloud.domain.Status; import org.jclouds.vcloud.domain.Task; -import org.jclouds.vcloud.domain.VApp; +import org.jclouds.vcloud.domain.VCloudExpressVApp; import org.jclouds.vcloud.domain.VCloudExpressVAppTemplate; import org.jclouds.vcloud.domain.VDC; import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions; import com.google.common.base.Predicate; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Sets; import com.google.inject.Inject; /** * @author Adrian Cole */ @Singleton -public class VCloudExpressComputeClientImpl extends CommonVCloudComputeClientImpl implements - VCloudExpressComputeClient { +public class VCloudExpressComputeClientImpl extends + CommonVCloudComputeClientImpl implements + VCloudExpressComputeClient { protected final Map vAppStatusToNodeState; @Inject public VCloudExpressComputeClientImpl(VCloudExpressClient client, Predicate successTester, - Map vAppStatusToNodeState) { + Map vAppStatusToNodeState) { super(client, successTester); this.vAppStatusToNodeState = vAppStatusToNodeState; } @Override public Map start(@Nullable URI VDC, URI templateId, String name, - InstantiateVAppTemplateOptions options, int... portsToOpen) { + InstantiateVAppTemplateOptions options, int... portsToOpen) { checkNotNull(options, "options"); logger.debug(">> instantiating vApp vDC(%s) template(%s) name(%s) options(%s) ", VDC, templateId, name, options); VDC vdc = client.getVDC(VDC); VCloudExpressVAppTemplate template = VCloudExpressClient.class.cast(client).getVAppTemplate(templateId); - VApp vAppResponse = VCloudExpressClient.class.cast(client).instantiateVAppTemplateInVDC(vdc.getId(), - template.getId(), name, options); + VCloudExpressVApp vAppResponse = VCloudExpressClient.class.cast(client).instantiateVAppTemplateInVDC(vdc.getId(), + template.getId(), name, options); logger.debug("<< instantiated VApp(%s)", vAppResponse.getName()); logger.debug(">> deploying vApp(%s)", vAppResponse.getName()); @@ -74,18 +78,38 @@ public class VCloudExpressComputeClientImpl extends CommonVCloudComputeClientImp Task task = client.deployVApp(vAppResponse.getId()); if (options.shouldBlockOnDeploy()) { if (!taskTester.apply(task.getLocation())) { - throw new TaskException("deploy", vAppResponse, task); + throw new RuntimeException(String.format("failed to %s %s: %s", "deploy", vAppResponse.getName(), task)); } logger.debug("<< deployed vApp(%s)", vAppResponse.getName()); logger.debug(">> powering vApp(%s)", vAppResponse.getName()); task = client.powerOnVApp(vAppResponse.getId()); if (!taskTester.apply(task.getLocation())) { - throw new TaskException("powerOn", vAppResponse, task); + throw new RuntimeException(String.format("failed to %s %s: %s", "powerOn", vAppResponse.getName(), task)); } logger.debug("<< on vApp(%s)", vAppResponse.getName()); } return parseAndValidateResponse(template, vAppResponse); } + @Override + public Set getPrivateAddresses(URI id) { + return ImmutableSet.of(); + } + + @Override + public Set getPublicAddresses(URI id) { + VCloudExpressVApp vApp = refreshVApp(id); + return Sets.newHashSet(vApp.getNetworkToAddresses().values()); + } + + @Override + protected Status getStatus(VCloudExpressVApp vApp) { + return vApp.getStatus(); + } + + @Override + protected VCloudExpressVApp refreshVApp(URI id) { + return VCloudExpressClient.class.cast(client).getVApp(id); + } } \ No newline at end of file diff --git a/vcloud/core/src/main/java/org/jclouds/vcloud/compute/strategy/VCloudAddNodeWithTagStrategy.java b/vcloud/core/src/main/java/org/jclouds/vcloud/compute/strategy/VCloudAddNodeWithTagStrategy.java index b496ce1d7c..7f0dc44392 100644 --- a/vcloud/core/src/main/java/org/jclouds/vcloud/compute/strategy/VCloudAddNodeWithTagStrategy.java +++ b/vcloud/core/src/main/java/org/jclouds/vcloud/compute/strategy/VCloudAddNodeWithTagStrategy.java @@ -37,8 +37,8 @@ import org.jclouds.compute.strategy.AddNodeWithTagStrategy; import org.jclouds.domain.Credentials; import org.jclouds.vcloud.VCloudClient; import org.jclouds.vcloud.compute.VCloudComputeClient; -import org.jclouds.vcloud.domain.VApp; import org.jclouds.vcloud.domain.Status; +import org.jclouds.vcloud.domain.VApp; import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions; import com.google.common.collect.ImmutableMap; @@ -82,8 +82,11 @@ public class VCloudAddNodeWithTagStrategy implements AddNodeWithTagStrategy { } private OperatingSystem getOperatingSystemForVAppOrDefaultTo(VApp vApp, OperatingSystem operatingSystem) { - return vApp.getOsType() != null ? new CIMOperatingSystem(CIMOperatingSystem.OSType.fromValue(vApp.getOsType()), - null, null, vApp.getOperatingSystemDescription()) : operatingSystem; + // TODO + return new CIMOperatingSystem(CIMOperatingSystem.OSType.UBUNTU_64, null, null, vApp.getDescription()); + // return vApp.getOsType() != null ? new + // CIMOperatingSystem(CIMOperatingSystem.OSType.fromValue(vApp.getOsType()), + // null, null, vApp.getOperatingSystemDescription()) : operatingSystem; } } \ No newline at end of file diff --git a/vcloud/core/src/main/java/org/jclouds/vcloud/compute/strategy/VCloudExpressAddNodeWithTagStrategy.java b/vcloud/core/src/main/java/org/jclouds/vcloud/compute/strategy/VCloudExpressAddNodeWithTagStrategy.java index 154a7a33ff..7ac660604e 100644 --- a/vcloud/core/src/main/java/org/jclouds/vcloud/compute/strategy/VCloudExpressAddNodeWithTagStrategy.java +++ b/vcloud/core/src/main/java/org/jclouds/vcloud/compute/strategy/VCloudExpressAddNodeWithTagStrategy.java @@ -37,7 +37,7 @@ import org.jclouds.compute.strategy.AddNodeWithTagStrategy; import org.jclouds.domain.Credentials; import org.jclouds.vcloud.VCloudExpressClient; import org.jclouds.vcloud.compute.VCloudExpressComputeClient; -import org.jclouds.vcloud.domain.VApp; +import org.jclouds.vcloud.domain.VCloudExpressVApp; import org.jclouds.vcloud.domain.Status; import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions; @@ -68,11 +68,11 @@ public class VCloudExpressAddNodeWithTagStrategy implements AddNodeWithTagStrate options.blockOnDeploy(false); Map metaMap = computeClient.start(URI.create(template.getLocation().getId()), URI.create(template .getImage().getId()), name, options, template.getOptions().getInboundPorts()); - VApp vApp = client.getVApp(URI.create(metaMap.get("id"))); + VCloudExpressVApp vApp = client.getVApp(URI.create(metaMap.get("id"))); return newCreateNodeResponse(tag, template, metaMap, vApp); } - protected NodeMetadata newCreateNodeResponse(String tag, Template template, Map metaMap, VApp vApp) { + protected NodeMetadata newCreateNodeResponse(String tag, Template template, Map metaMap, VCloudExpressVApp vApp) { return new NodeMetadataImpl(vApp.getId().toASCIIString(), vApp.getName(), vApp.getId().toASCIIString(), template .getLocation(), vApp.getId(), ImmutableMap. of(), tag, template.getImage().getId(), getOperatingSystemForVAppOrDefaultTo(vApp, template.getImage().getOperatingSystem()), @@ -81,7 +81,7 @@ public class VCloudExpressAddNodeWithTagStrategy implements AddNodeWithTagStrate metaMap.get("username"), metaMap.get("password"))); } - private OperatingSystem getOperatingSystemForVAppOrDefaultTo(VApp vApp, OperatingSystem operatingSystem) { + private OperatingSystem getOperatingSystemForVAppOrDefaultTo(VCloudExpressVApp vApp, OperatingSystem operatingSystem) { return vApp.getOsType() != null ? new CIMOperatingSystem(CIMOperatingSystem.OSType.fromValue(vApp.getOsType()), null, null, vApp.getOperatingSystemDescription()) : operatingSystem; } diff --git a/vcloud/core/src/main/java/org/jclouds/vcloud/compute/strategy/VCloudExpressGetNodeMetadataStrategy.java b/vcloud/core/src/main/java/org/jclouds/vcloud/compute/strategy/VCloudExpressGetNodeMetadataStrategy.java new file mode 100644 index 0000000000..f244436920 --- /dev/null +++ b/vcloud/core/src/main/java/org/jclouds/vcloud/compute/strategy/VCloudExpressGetNodeMetadataStrategy.java @@ -0,0 +1,94 @@ +/** + * + * Copyright (C) 2010 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS 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 org.jclouds.compute.util.ComputeServiceUtils.parseTagFromName; + +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.domain.Image; +import org.jclouds.compute.domain.NodeMetadata; +import org.jclouds.compute.domain.NodeState; +import org.jclouds.compute.domain.internal.NodeMetadataImpl; +import org.jclouds.compute.domain.os.CIMOperatingSystem; +import org.jclouds.compute.reference.ComputeServiceConstants; +import org.jclouds.compute.strategy.GetNodeMetadataStrategy; +import org.jclouds.domain.Location; +import org.jclouds.logging.Logger; +import org.jclouds.vcloud.VCloudExpressClient; +import org.jclouds.vcloud.compute.VCloudExpressComputeClient; +import org.jclouds.vcloud.compute.functions.FindLocationForResource; +import org.jclouds.vcloud.compute.functions.GetExtraFromVCloudExpressVApp; +import org.jclouds.vcloud.domain.Status; +import org.jclouds.vcloud.domain.VCloudExpressVApp; + +import com.google.common.base.Supplier; +import com.google.common.collect.ImmutableMap; + +/** + * @author Adrian Cole + */ +@Singleton +public class VCloudExpressGetNodeMetadataStrategy implements GetNodeMetadataStrategy { + @Resource + @Named(ComputeServiceConstants.COMPUTE_LOGGER) + public Logger logger = Logger.NULL; + protected final VCloudExpressClient client; + protected final VCloudExpressComputeClient computeClient; + protected final Supplier> images; + protected final FindLocationForResource findLocationForResourceInVDC; + protected final GetExtraFromVCloudExpressVApp getExtra; + protected final Map vAppStatusToNodeState; + + @Inject + protected VCloudExpressGetNodeMetadataStrategy(VCloudExpressClient client, VCloudExpressComputeClient computeClient, + Map vAppStatusToNodeState, GetExtraFromVCloudExpressVApp getExtra, + FindLocationForResource findLocationForResourceInVDC, Supplier> images) { + this.client = checkNotNull(client, "client"); + this.images = checkNotNull(images, "images"); + this.getExtra = checkNotNull(getExtra, "getExtra"); + this.findLocationForResourceInVDC = checkNotNull(findLocationForResourceInVDC, "findLocationForResourceInVDC"); + this.computeClient = checkNotNull(computeClient, "computeClient"); + this.vAppStatusToNodeState = checkNotNull(vAppStatusToNodeState, "vAppStatusToNodeState"); + } + + public NodeMetadata execute(String in) { + URI id = URI.create(in); + VCloudExpressVApp from = client.getVApp(id); + if (from == null) + return null; + String tag = parseTagFromName(from.getName()); + Location location = findLocationForResourceInVDC.apply(from.getVDC()); + return new NodeMetadataImpl(in, from.getName(), in, location, from.getId(), ImmutableMap. of(), + tag, null, from.getOsType() != null ? new CIMOperatingSystem(CIMOperatingSystem.OSType.fromValue(from + .getOsType()), null, null, from.getOperatingSystemDescription()) : null, vAppStatusToNodeState + .get(from.getStatus()), computeClient.getPublicAddresses(id), computeClient + .getPrivateAddresses(id), getExtra.apply(from), null); + } + +} \ No newline at end of file diff --git a/vcloud/core/src/main/java/org/jclouds/vcloud/compute/strategy/VCloudExpressListNodesStrategy.java b/vcloud/core/src/main/java/org/jclouds/vcloud/compute/strategy/VCloudExpressListNodesStrategy.java new file mode 100644 index 0000000000..f477c81d95 --- /dev/null +++ b/vcloud/core/src/main/java/org/jclouds/vcloud/compute/strategy/VCloudExpressListNodesStrategy.java @@ -0,0 +1,140 @@ +/** + * + * Copyright (C) 2010 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS 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.jclouds.compute.reference.ComputeServiceConstants.COMPUTE_LOGGER; +import static org.jclouds.compute.reference.ComputeServiceConstants.PROPERTY_BLACKLIST_NODES; + +import java.util.Map; +import java.util.Set; + +import javax.annotation.Resource; +import javax.inject.Named; +import javax.inject.Singleton; + +import org.jclouds.compute.domain.ComputeMetadata; +import org.jclouds.compute.domain.ComputeType; +import org.jclouds.compute.domain.NodeMetadata; +import org.jclouds.compute.domain.internal.ComputeMetadataImpl; +import org.jclouds.compute.strategy.ListNodesStrategy; +import org.jclouds.domain.Location; +import org.jclouds.logging.Logger; +import org.jclouds.vcloud.CommonVCloudClient; +import org.jclouds.vcloud.VCloudMediaType; +import org.jclouds.vcloud.compute.functions.FindLocationForResource; +import org.jclouds.vcloud.domain.NamedResource; +import org.jclouds.vcloud.endpoints.Org; + +import com.google.common.annotations.VisibleForTesting; +import com.google.common.base.Predicate; +import com.google.common.base.Splitter; +import com.google.common.base.Supplier; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.Sets; +import com.google.inject.Inject; +import com.google.inject.internal.util.ImmutableSet; + +/** + * @author Adrian Cole + */ +// TODO REFACTOR!!! needs to be parallel +@Singleton +public class VCloudExpressListNodesStrategy implements ListNodesStrategy { + @Resource + @Named(COMPUTE_LOGGER) + public Logger logger = Logger.NULL; + protected final VCloudExpressGetNodeMetadataStrategy getNodeMetadata; + protected final CommonVCloudClient client; + protected final FindLocationForResource findLocationForResourceInVDC; + Set blackListVAppNames = ImmutableSet. of(); + + @Inject(optional = true) + void setBlackList(@Named(PROPERTY_BLACKLIST_NODES) String blackListNodes) { + if (blackListNodes != null && !"".equals(blackListNodes)) + this.blackListVAppNames = ImmutableSet.copyOf(Splitter.on(',').split(blackListNodes)); + } + + private final Supplier> orgNameToEndpoint; + + @Inject + protected VCloudExpressListNodesStrategy(CommonVCloudClient client, + @Org Supplier> orgNameToEndpoint, VCloudExpressGetNodeMetadataStrategy getNodeMetadata, + FindLocationForResource findLocationForResourceInVDC) { + this.client = client; + this.orgNameToEndpoint = orgNameToEndpoint; + this.getNodeMetadata = getNodeMetadata; + this.findLocationForResourceInVDC = findLocationForResourceInVDC; + } + + @Override + public Iterable list() { + Set nodes = Sets.newHashSet(); + for (String org : orgNameToEndpoint.get().keySet()) { + for (NamedResource vdc : client.findOrgNamed(org).getVDCs().values()) { + for (NamedResource resource : client.getVDC(vdc.getId()).getResourceEntities().values()) { + if (validVApp(resource)) { + nodes.add(convertVAppToComputeMetadata(vdc, resource)); + } + } + } + } + return nodes; + } + + private boolean validVApp(NamedResource resource) { + return resource.getType().equals(VCloudMediaType.VAPP_XML) && !blackListVAppNames.contains(resource.getName()); + } + + private ComputeMetadata convertVAppToComputeMetadata(NamedResource vdc, NamedResource resource) { + Location location = findLocationForResourceInVDC.apply(vdc); + return new ComputeMetadataImpl(ComputeType.NODE, resource.getId().toASCIIString(), resource.getName(), resource + .getId().toASCIIString(), location, null, ImmutableMap. of()); + } + + @Override + public Iterable listDetailsOnNodesMatching(Predicate filter) { + Set nodes = Sets.newHashSet(); + for (String org : orgNameToEndpoint.get().keySet()) { + for (NamedResource vdc : client.findOrgNamed(org).getVDCs().values()) { + for (NamedResource resource : client.getVDC(vdc.getId()).getResourceEntities().values()) { + if (validVApp(resource) && filter.apply(convertVAppToComputeMetadata(vdc, resource))) { + addVAppToSetRetryingIfNotYetPresent(nodes, vdc, resource); + } + } + } + } + return nodes; + } + + @VisibleForTesting + void addVAppToSetRetryingIfNotYetPresent(Set nodes, NamedResource vdc, NamedResource resource) { + NodeMetadata node = null; + int i = 0; + while (node == null && i++ < 3) { + try { + node = getNodeMetadata.execute(resource.getId().toASCIIString()); + nodes.add(node); + } catch (NullPointerException e) { + logger.warn("vApp %s not yet present in vdc %s", resource.getName(), vdc.getName()); + } + } + } + +} \ No newline at end of file diff --git a/vcloud/core/src/main/java/org/jclouds/vcloud/compute/strategy/VCloudGetNodeMetadataStrategy.java b/vcloud/core/src/main/java/org/jclouds/vcloud/compute/strategy/VCloudGetNodeMetadataStrategy.java index 28f9d0ad4f..d3ceb7071d 100644 --- a/vcloud/core/src/main/java/org/jclouds/vcloud/compute/strategy/VCloudGetNodeMetadataStrategy.java +++ b/vcloud/core/src/main/java/org/jclouds/vcloud/compute/strategy/VCloudGetNodeMetadataStrategy.java @@ -34,18 +34,19 @@ import javax.inject.Singleton; import org.jclouds.compute.domain.Image; import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.domain.NodeState; +import org.jclouds.compute.domain.OperatingSystem; import org.jclouds.compute.domain.internal.NodeMetadataImpl; import org.jclouds.compute.domain.os.CIMOperatingSystem; import org.jclouds.compute.reference.ComputeServiceConstants; import org.jclouds.compute.strategy.GetNodeMetadataStrategy; import org.jclouds.domain.Location; import org.jclouds.logging.Logger; -import org.jclouds.vcloud.CommonVCloudClient; -import org.jclouds.vcloud.compute.CommonVCloudComputeClient; +import org.jclouds.vcloud.VCloudClient; +import org.jclouds.vcloud.compute.VCloudComputeClient; import org.jclouds.vcloud.compute.functions.FindLocationForResource; -import org.jclouds.vcloud.compute.functions.GetExtra; -import org.jclouds.vcloud.domain.VApp; +import org.jclouds.vcloud.compute.functions.GetExtraFromVApp; import org.jclouds.vcloud.domain.Status; +import org.jclouds.vcloud.domain.VApp; import com.google.common.base.Supplier; import com.google.common.collect.ImmutableMap; @@ -58,16 +59,16 @@ public class VCloudGetNodeMetadataStrategy implements GetNodeMetadataStrategy { @Resource @Named(ComputeServiceConstants.COMPUTE_LOGGER) public Logger logger = Logger.NULL; - protected final CommonVCloudClient client; - protected final CommonVCloudComputeClient computeClient; + protected final VCloudClient client; + protected final VCloudComputeClient computeClient; protected final Supplier> images; protected final FindLocationForResource findLocationForResourceInVDC; - protected final GetExtra getExtra; + protected final GetExtraFromVApp getExtra; protected final Map vAppStatusToNodeState; @Inject - protected VCloudGetNodeMetadataStrategy(CommonVCloudClient client, CommonVCloudComputeClient computeClient, - Map vAppStatusToNodeState, GetExtra getExtra, + protected VCloudGetNodeMetadataStrategy(VCloudClient client, VCloudComputeClient computeClient, + Map vAppStatusToNodeState, GetExtraFromVApp getExtra, FindLocationForResource findLocationForResourceInVDC, Supplier> images) { this.client = checkNotNull(client, "client"); this.images = checkNotNull(images, "images"); @@ -85,10 +86,17 @@ public class VCloudGetNodeMetadataStrategy implements GetNodeMetadataStrategy { String tag = parseTagFromName(from.getName()); Location location = findLocationForResourceInVDC.apply(from.getVDC()); return new NodeMetadataImpl(in, from.getName(), in, location, from.getId(), ImmutableMap. of(), - tag, null, from.getOsType() != null ? new CIMOperatingSystem(CIMOperatingSystem.OSType.fromValue(from - .getOsType()), null, null, from.getOperatingSystemDescription()) : null, vAppStatusToNodeState - .get(from.getStatus()), computeClient.getPublicAddresses(id), computeClient + tag, null, getOperatingSystemForVAppOrDefaultTo(from, null), + vAppStatusToNodeState.get(from.getStatus()), computeClient.getPublicAddresses(id), computeClient .getPrivateAddresses(id), getExtra.apply(from), null); } + private OperatingSystem getOperatingSystemForVAppOrDefaultTo(VApp vApp, OperatingSystem operatingSystem) { + // TODO + return new CIMOperatingSystem(CIMOperatingSystem.OSType.UBUNTU_64, null, null, vApp.getDescription()); + // return vApp.getOsType() != null ? new + // CIMOperatingSystem(CIMOperatingSystem.OSType.fromValue(vApp.getOsType()), + // null, null, vApp.getOperatingSystemDescription()) : operatingSystem; + } + } \ No newline at end of file diff --git a/vcloud/core/src/main/java/org/jclouds/vcloud/domain/VApp.java b/vcloud/core/src/main/java/org/jclouds/vcloud/domain/VApp.java index 035538f177..eed05164e5 100644 --- a/vcloud/core/src/main/java/org/jclouds/vcloud/domain/VApp.java +++ b/vcloud/core/src/main/java/org/jclouds/vcloud/domain/VApp.java @@ -19,49 +19,47 @@ package org.jclouds.vcloud.domain; -import java.util.Set; +import java.util.List; import javax.annotation.Nullable; -import org.jclouds.vcloud.domain.internal.VAppImpl; - -import com.google.common.collect.ListMultimap; -import com.google.inject.ImplementedBy; - /** - * A virtual application (vApp) is a software solution, packaged in OVF containing one or more - * virtual machines. A vApp can be authored by Developers at ISVs and VARs or by IT Administrators - * in Enterprises and Service Providers. - * + * 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. + * @author Adrian Cole */ -@ImplementedBy(VAppImpl.class) public interface VApp extends NamedResource { + /** + * 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 + */ NamedResource getVDC(); + /** + * The creation status of the vDC + * + * @since vcloud api 1.0 + */ Status getStatus(); - Long getSize(); - - ListMultimap getNetworkToAddresses(); - /** + * optional description * - * @return CIM OSType of the image or null, if this information isn't available yet - * @see DMTF CIM model + * @since vcloud api 0.8 */ @Nullable - Integer getOsType(); + String getDescription(); /** + * read‐only container for Task elements. Each element in the container represents a queued, + * running, or failed task owned by this object. * - * @return description or null, if this information isn't available yet + * @since vcloud api 1.0 */ - @Nullable - String getOperatingSystemDescription(); - - VirtualSystem getSystem(); - - Set getResourceAllocations(); + List getTasks(); } \ No newline at end of file diff --git a/vcloud/core/src/main/java/org/jclouds/vcloud/domain/VCloudExpressVApp.java b/vcloud/core/src/main/java/org/jclouds/vcloud/domain/VCloudExpressVApp.java new file mode 100644 index 0000000000..1739f6b479 --- /dev/null +++ b/vcloud/core/src/main/java/org/jclouds/vcloud/domain/VCloudExpressVApp.java @@ -0,0 +1,67 @@ +/** + * + * Copyright (C) 2010 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS 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 javax.annotation.Nullable; + +import org.jclouds.vcloud.domain.internal.VCloudExpressVAppImpl; + +import com.google.common.collect.ListMultimap; +import com.google.inject.ImplementedBy; + +/** + * A virtual application (vApp) is a software solution, packaged in OVF containing one or more + * virtual machines. A vApp can be authored by Developers at ISVs and VARs or by IT Administrators + * in Enterprises and Service Providers. + * + * @author Adrian Cole + */ +@ImplementedBy(VCloudExpressVAppImpl.class) +public interface VCloudExpressVApp extends NamedResource { + NamedResource getVDC(); + + Status getStatus(); + + Long getSize(); + + ListMultimap getNetworkToAddresses(); + + /** + * + * @return CIM OSType of the image or null, if this information isn't available yet + * @see DMTF CIM model + */ + @Nullable + Integer getOsType(); + + /** + * + * @return description or null, if this information isn't available yet + */ + @Nullable + String getOperatingSystemDescription(); + + VirtualSystem getSystem(); + + Set getResourceAllocations(); + +} \ No newline at end of file diff --git a/vcloud/core/src/main/java/org/jclouds/vcloud/domain/internal/VAppImpl.java b/vcloud/core/src/main/java/org/jclouds/vcloud/domain/internal/VAppImpl.java index 97f1497e7e..dd135b77f4 100644 --- a/vcloud/core/src/main/java/org/jclouds/vcloud/domain/internal/VAppImpl.java +++ b/vcloud/core/src/main/java/org/jclouds/vcloud/domain/internal/VAppImpl.java @@ -22,50 +22,38 @@ package org.jclouds.vcloud.domain.internal; import static com.google.common.base.Preconditions.checkNotNull; import java.net.URI; -import java.util.Set; +import java.util.List; + +import javax.annotation.Nullable; -import org.jclouds.vcloud.VCloudExpressMediaType; import org.jclouds.vcloud.domain.NamedResource; -import org.jclouds.vcloud.domain.ResourceAllocation; -import org.jclouds.vcloud.domain.VApp; import org.jclouds.vcloud.domain.Status; -import org.jclouds.vcloud.domain.VirtualSystem; +import org.jclouds.vcloud.domain.Task; +import org.jclouds.vcloud.domain.VApp; -import com.google.common.collect.ListMultimap; +import com.google.common.collect.Iterables; +import com.google.common.collect.Lists; /** * * @author Adrian Cole * */ -public class VAppImpl implements VApp { - private final String name; - private final URI id; - private final NamedResource vDC; +public class VAppImpl extends NamedResourceImpl implements VApp { private final Status status; - private final Long size; - private final ListMultimap networkToAddresses; - private final String operatingSystemDescription; - private final VirtualSystem system; - private final Set resourceAllocations; - private final Integer osType; + @Nullable + private final NamedResource vdc; + @Nullable + private final String description; + private final List tasks = Lists.newArrayList(); - /** The serialVersionUID */ - private static final long serialVersionUID = 8464716396538298809L; - - public VAppImpl(String name, URI id, Status status, Long size, NamedResource vDC, - ListMultimap networkToAddresses, Integer osType, String operatingSystemDescription, - VirtualSystem system, Set resourceAllocations) { - this.name = checkNotNull(name, "name"); - this.id = checkNotNull(id, "id"); + public VAppImpl(String name, String type, URI id, Status status, @Nullable NamedResource vdc, + @Nullable String description, Iterable tasks) { + super(name, type, id); this.status = checkNotNull(status, "status"); - this.size = size; - this.vDC = vDC; - this.networkToAddresses = checkNotNull(networkToAddresses, "networkToAddresses"); - this.osType = osType; - this.operatingSystemDescription = operatingSystemDescription; - this.system = system; - this.resourceAllocations = checkNotNull(resourceAllocations, "resourceAllocations"); + this.vdc = vdc; + this.description = description; + Iterables.addAll(this.tasks, checkNotNull(tasks, "tasks")); } @Override @@ -73,50 +61,29 @@ public class VAppImpl implements VApp { return status; } - @Override - public ListMultimap getNetworkToAddresses() { - return networkToAddresses; - } - - @Override - public Integer getOsType() { - return osType; - } - - @Override - public String getOperatingSystemDescription() { - return operatingSystemDescription; - } - - @Override - public VirtualSystem getSystem() { - return system; - } - - @Override - public Set getResourceAllocations() { - return resourceAllocations; - } - @Override public NamedResource getVDC() { - return vDC; + return vdc; + } + + @Override + public String getDescription() { + return description; + } + + @Override + public List getTasks() { + return tasks; } @Override public int hashCode() { final int prime = 31; - int result = 1; - result = prime * result + ((id == null) ? 0 : id.hashCode()); - result = prime * result + ((name == null) ? 0 : name.hashCode()); - result = prime * result + ((networkToAddresses == null) ? 0 : networkToAddresses.hashCode()); - result = prime * result + ((operatingSystemDescription == null) ? 0 : operatingSystemDescription.hashCode()); - result = prime * result + ((resourceAllocations == null) ? 0 : resourceAllocations.hashCode()); - result = prime * result + ((size == null) ? 0 : size.hashCode()); - result = prime * result + ((osType == null) ? 0 : osType.hashCode()); + int result = super.hashCode(); + result = prime * result + ((description == null) ? 0 : description.hashCode()); result = prime * result + ((status == null) ? 0 : status.hashCode()); - result = prime * result + ((system == null) ? 0 : system.hashCode()); - result = prime * result + ((vDC == null) ? 0 : vDC.hashCode()); + result = prime * result + ((tasks == null) ? 0 : tasks.hashCode()); + result = prime * result + ((vdc == null) ? 0 : vdc.hashCode()); return result; } @@ -124,95 +91,43 @@ public class VAppImpl implements VApp { public boolean equals(Object obj) { if (this == obj) return true; - if (obj == null) + if (!super.equals(obj)) return false; if (getClass() != obj.getClass()) return false; VAppImpl other = (VAppImpl) obj; - if (id == null) { - if (other.id != null) + if (description == null) { + if (other.description != null) return false; - } else if (!id.equals(other.id)) - return false; - if (name == null) { - if (other.name != null) - return false; - } else if (!name.equals(other.name)) - return false; - if (osType == null) { - if (other.osType != null) - return false; - } else if (!osType.equals(other.osType)) - return false; - if (networkToAddresses == null) { - if (other.networkToAddresses != null) - return false; - } else if (!networkToAddresses.equals(other.networkToAddresses)) - return false; - if (operatingSystemDescription == null) { - if (other.operatingSystemDescription != null) - return false; - } else if (!operatingSystemDescription.equals(other.operatingSystemDescription)) - return false; - if (resourceAllocations == null) { - if (other.resourceAllocations != null) - return false; - } else if (!resourceAllocations.equals(other.resourceAllocations)) - return false; - if (size == null) { - if (other.size != null) - return false; - } else if (!size.equals(other.size)) + } else if (!description.equals(other.description)) return false; if (status == null) { if (other.status != null) return false; } else if (!status.equals(other.status)) return false; - if (system == null) { - if (other.system != null) + if (tasks == null) { + if (other.tasks != null) return false; - } else if (!system.equals(other.system)) + } else if (!tasks.equals(other.tasks)) return false; - if (vDC == null) { - if (other.vDC != null) + if (vdc == null) { + if (other.vdc != null) return false; - } else if (!vDC.equals(other.vDC)) + } else if (!vdc.equals(other.vdc)) return false; return true; } - @Override - public String getName() { - return name; - } - - @Override - public URI getId() { - return id; - } - - @Override - public Long getSize() { - return size; - } - - @Override - public String toString() { - return "[id=" + id + ", name=" + name + ", networkToAddresses=" + networkToAddresses + ", osType=" + osType - + ", operatingSystemDescription=" + operatingSystemDescription + ", resourceAllocationByType=" - + resourceAllocations + ", size=" + size + ", status=" + status + ", system=" + system + ", vDC=" + vDC - + "]"; - } - - @Override - public String getType() { - return VCloudExpressMediaType.VAPP_XML; - } - @Override public int compareTo(NamedResource o) { return (this == o) ? 0 : getId().compareTo(o.getId()); } + @Override + public String toString() { + return "[id=" + getId() + ", name=" + getName() + ", type=" + getType() + ", status=" + getStatus() + ", vdc=" + + getVDC() + ", description=" + getDescription() + "]"; + } + } \ No newline at end of file diff --git a/vcloud/core/src/main/java/org/jclouds/vcloud/domain/internal/VCloudExpressVAppImpl.java b/vcloud/core/src/main/java/org/jclouds/vcloud/domain/internal/VCloudExpressVAppImpl.java new file mode 100644 index 0000000000..313fc16a0f --- /dev/null +++ b/vcloud/core/src/main/java/org/jclouds/vcloud/domain/internal/VCloudExpressVAppImpl.java @@ -0,0 +1,218 @@ +/** + * + * Copyright (C) 2010 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS 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.Set; + +import org.jclouds.vcloud.VCloudExpressMediaType; +import org.jclouds.vcloud.domain.NamedResource; +import org.jclouds.vcloud.domain.ResourceAllocation; +import org.jclouds.vcloud.domain.VCloudExpressVApp; +import org.jclouds.vcloud.domain.Status; +import org.jclouds.vcloud.domain.VirtualSystem; + +import com.google.common.collect.ListMultimap; + +/** + * + * @author Adrian Cole + * + */ +public class VCloudExpressVAppImpl implements VCloudExpressVApp { + private final String name; + private final URI id; + private final NamedResource vDC; + private final Status status; + private final Long size; + private final ListMultimap networkToAddresses; + private final String operatingSystemDescription; + private final VirtualSystem system; + private final Set resourceAllocations; + private final Integer osType; + + /** The serialVersionUID */ + private static final long serialVersionUID = 8464716396538298809L; + + public VCloudExpressVAppImpl(String name, URI id, Status status, Long size, NamedResource vDC, + ListMultimap networkToAddresses, Integer osType, String operatingSystemDescription, + VirtualSystem system, Set resourceAllocations) { + this.name = checkNotNull(name, "name"); + this.id = checkNotNull(id, "id"); + this.status = checkNotNull(status, "status"); + this.size = size; + this.vDC = vDC; + this.networkToAddresses = checkNotNull(networkToAddresses, "networkToAddresses"); + this.osType = osType; + this.operatingSystemDescription = operatingSystemDescription; + this.system = system; + this.resourceAllocations = checkNotNull(resourceAllocations, "resourceAllocations"); + } + + @Override + public Status getStatus() { + return status; + } + + @Override + public ListMultimap getNetworkToAddresses() { + return networkToAddresses; + } + + @Override + public Integer getOsType() { + return osType; + } + + @Override + public String getOperatingSystemDescription() { + return operatingSystemDescription; + } + + @Override + public VirtualSystem getSystem() { + return system; + } + + @Override + public Set getResourceAllocations() { + return resourceAllocations; + } + + @Override + public NamedResource getVDC() { + return vDC; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((id == null) ? 0 : id.hashCode()); + result = prime * result + ((name == null) ? 0 : name.hashCode()); + result = prime * result + ((networkToAddresses == null) ? 0 : networkToAddresses.hashCode()); + result = prime * result + ((operatingSystemDescription == null) ? 0 : operatingSystemDescription.hashCode()); + result = prime * result + ((resourceAllocations == null) ? 0 : resourceAllocations.hashCode()); + result = prime * result + ((size == null) ? 0 : size.hashCode()); + result = prime * result + ((osType == null) ? 0 : osType.hashCode()); + result = prime * result + ((status == null) ? 0 : status.hashCode()); + result = prime * result + ((system == null) ? 0 : system.hashCode()); + result = prime * result + ((vDC == null) ? 0 : vDC.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; + VCloudExpressVAppImpl other = (VCloudExpressVAppImpl) obj; + if (id == null) { + if (other.id != null) + return false; + } else if (!id.equals(other.id)) + return false; + if (name == null) { + if (other.name != null) + return false; + } else if (!name.equals(other.name)) + return false; + if (osType == null) { + if (other.osType != null) + return false; + } else if (!osType.equals(other.osType)) + return false; + if (networkToAddresses == null) { + if (other.networkToAddresses != null) + return false; + } else if (!networkToAddresses.equals(other.networkToAddresses)) + return false; + if (operatingSystemDescription == null) { + if (other.operatingSystemDescription != null) + return false; + } else if (!operatingSystemDescription.equals(other.operatingSystemDescription)) + return false; + if (resourceAllocations == null) { + if (other.resourceAllocations != null) + return false; + } else if (!resourceAllocations.equals(other.resourceAllocations)) + return false; + if (size == null) { + if (other.size != null) + return false; + } else if (!size.equals(other.size)) + return false; + if (status == null) { + if (other.status != null) + return false; + } else if (!status.equals(other.status)) + return false; + if (system == null) { + if (other.system != null) + return false; + } else if (!system.equals(other.system)) + return false; + if (vDC == null) { + if (other.vDC != null) + return false; + } else if (!vDC.equals(other.vDC)) + return false; + return true; + } + + @Override + public String getName() { + return name; + } + + @Override + public URI getId() { + return id; + } + + @Override + public Long getSize() { + return size; + } + + @Override + public String toString() { + return "[id=" + id + ", name=" + name + ", networkToAddresses=" + networkToAddresses + ", osType=" + osType + + ", operatingSystemDescription=" + operatingSystemDescription + ", resourceAllocationByType=" + + resourceAllocations + ", size=" + size + ", status=" + status + ", system=" + system + ", vDC=" + vDC + + "]"; + } + + @Override + public String getType() { + return VCloudExpressMediaType.VAPP_XML; + } + + @Override + public int compareTo(NamedResource o) { + return (this == o) ? 0 : getId().compareTo(o.getId()); + } + +} \ No newline at end of file diff --git a/vcloud/core/src/main/java/org/jclouds/vcloud/xml/VAppHandler.java b/vcloud/core/src/main/java/org/jclouds/vcloud/xml/VAppHandler.java index e3d08ee1b7..119f1f7268 100644 --- a/vcloud/core/src/main/java/org/jclouds/vcloud/xml/VAppHandler.java +++ b/vcloud/core/src/main/java/org/jclouds/vcloud/xml/VAppHandler.java @@ -7,7 +7,7 @@ * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.vdc/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -21,124 +21,79 @@ package org.jclouds.vcloud.xml; import static org.jclouds.Constants.PROPERTY_API_VERSION; -import java.net.URI; -import java.util.Set; +import java.util.List; -import javax.annotation.Resource; import javax.inject.Inject; import javax.inject.Named; import org.jclouds.http.functions.ParseSax; -import org.jclouds.logging.Logger; -import org.jclouds.vcloud.VCloudExpressMediaType; import org.jclouds.vcloud.domain.NamedResource; -import org.jclouds.vcloud.domain.ResourceAllocation; -import org.jclouds.vcloud.domain.VApp; import org.jclouds.vcloud.domain.Status; -import org.jclouds.vcloud.domain.VirtualSystem; +import org.jclouds.vcloud.domain.Task; +import org.jclouds.vcloud.domain.VApp; import org.jclouds.vcloud.domain.internal.VAppImpl; import org.jclouds.vcloud.util.Utils; import org.xml.sax.Attributes; import org.xml.sax.SAXException; -import com.google.common.collect.ArrayListMultimap; -import com.google.common.collect.ListMultimap; -import com.google.common.collect.Sets; +import com.google.common.collect.Lists; /** * @author Adrian Cole */ public class VAppHandler extends ParseSax.HandlerWithResult { - private final String apiVersion; - private final VirtualSystemHandler systemHandler; - private final ResourceAllocationHandler allocationHandler; - @Resource - protected Logger logger = Logger.NULL; + protected final String apiVersion; + protected final TaskHandler taskHandler; @Inject - public VAppHandler(@Named(PROPERTY_API_VERSION) String apiVersion, VirtualSystemHandler systemHandler, - ResourceAllocationHandler allocationHandler) { + public VAppHandler(@Named(PROPERTY_API_VERSION) String apiVersion, TaskHandler taskHandler) { this.apiVersion = apiVersion; - this.systemHandler = systemHandler; - this.allocationHandler = allocationHandler; + this.taskHandler = taskHandler; } - protected VirtualSystem system; - protected Set allocations = Sets.newLinkedHashSet(); + private StringBuilder currentText = new StringBuilder(); + + protected NamedResource vApp; + protected List tasks = Lists.newArrayList(); + protected String description; + protected NamedResource vdc; protected Status status; - protected final ListMultimap networkToAddresses = ArrayListMultimap.create(); - protected StringBuilder currentText = new StringBuilder(); - protected String operatingSystemDescription; - protected boolean inOs; - protected String networkName; - protected String name; - protected Integer osType; - protected URI location; - protected Long size; - protected NamedResource vDC; public VApp getResult() { - return new VAppImpl(name, location, status, size, vDC, networkToAddresses, osType, operatingSystemDescription, - system, allocations); - } - - public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { - if (qName.equals("VApp")) { - NamedResource resource = Utils.newNamedResource(attributes); - name = resource.getName(); - location = resource.getId(); - String statusString = attributes.getValue(attributes.getIndex("status")); - if (apiVersion.indexOf("0.8") != -1 && "2".equals(statusString)) - status = Status.OFF; - else - status = Status.fromValue(statusString); - if (attributes.getIndex("size") != -1) - size = new Long(attributes.getValue(attributes.getIndex("size"))); - } else if (qName.equals("Link")) { // type should never be missing - if (attributes.getIndex("type") != -1 - && attributes.getValue(attributes.getIndex("type")).equals(VCloudExpressMediaType.VDC_XML)) { - vDC = Utils.newNamedResource(attributes); - } - } else if (qName.equals("OperatingSystemSection")) { - inOs = true; - for (int i = 0; i < attributes.getLength(); i++) - if (attributes.getQName(i).indexOf("id") != -1) - osType = Integer.parseInt(attributes.getValue(i)); - } else if (qName.endsWith("NetworkConnection")) { - networkName = attributes.getValue(attributes.getIndex("Network")); - } else { - systemHandler.startElement(uri, localName, qName, attributes); - allocationHandler.startElement(uri, localName, qName, attributes); - } - + return new VAppImpl(vApp.getName(), vApp.getType(), vApp.getId(), status, vdc, description, tasks); } @Override - public void endElement(String uri, String localName, String qName) throws SAXException { - if (qName.equals("OperatingSystemSection")) { - inOs = false; - } else if (inOs && qName.equals("Description")) { - operatingSystemDescription = currentText.toString().trim(); - } else if (qName.endsWith("IpAddress")) { - networkToAddresses.put(networkName, currentText.toString().trim()); - } else if (qName.equals("System")) { - systemHandler.endElement(uri, localName, qName); - system = systemHandler.getResult(); - } else if (qName.equals("Item")) { - allocationHandler.endElement(uri, localName, qName); - allocations.add(allocationHandler.getResult()); + public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { + if (qName.equals("VApp")) { + vApp = Utils.newNamedResource(attributes); + String statusString = attributes.getValue(attributes.getIndex("status")); + status = Status.fromValue(statusString); + // } else if (qName.equals("VAppItem")) { + // Utils.putNamedResource(contents, attributes); + } else if (qName.equals("Link") && "up".equals(Utils.attrOrNull(attributes, "rel"))) { + vdc = Utils.newNamedResource(attributes); } else { - systemHandler.endElement(uri, localName, qName); - allocationHandler.endElement(uri, localName, qName); + taskHandler.startElement(uri, localName, qName, attributes); + } + } + + public void endElement(String uri, String name, String qName) { + taskHandler.endElement(uri, name, qName); + if (qName.equals("Task")) { + this.tasks.add(taskHandler.getResult()); + } else if (qName.equals("Description")) { + description = currentOrNull(); } currentText = new StringBuilder(); } - @Override public void characters(char ch[], int start, int length) { currentText.append(ch, start, length); - systemHandler.characters(ch, start, length); - allocationHandler.characters(ch, start, length); } + protected String currentOrNull() { + String returnVal = currentText.toString().trim(); + return returnVal.equals("") ? null : returnVal; + } } diff --git a/vcloud/core/src/main/java/org/jclouds/vcloud/xml/VCloudExpressVAppHandler.java b/vcloud/core/src/main/java/org/jclouds/vcloud/xml/VCloudExpressVAppHandler.java new file mode 100644 index 0000000000..1bcf81f52a --- /dev/null +++ b/vcloud/core/src/main/java/org/jclouds/vcloud/xml/VCloudExpressVAppHandler.java @@ -0,0 +1,144 @@ +/** + * + * Copyright (C) 2010 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS 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.Constants.PROPERTY_API_VERSION; + +import java.net.URI; +import java.util.Set; + +import javax.annotation.Resource; +import javax.inject.Inject; +import javax.inject.Named; + +import org.jclouds.http.functions.ParseSax; +import org.jclouds.logging.Logger; +import org.jclouds.vcloud.VCloudExpressMediaType; +import org.jclouds.vcloud.domain.NamedResource; +import org.jclouds.vcloud.domain.ResourceAllocation; +import org.jclouds.vcloud.domain.VCloudExpressVApp; +import org.jclouds.vcloud.domain.Status; +import org.jclouds.vcloud.domain.VirtualSystem; +import org.jclouds.vcloud.domain.internal.VCloudExpressVAppImpl; +import org.jclouds.vcloud.util.Utils; +import org.xml.sax.Attributes; +import org.xml.sax.SAXException; + +import com.google.common.collect.ArrayListMultimap; +import com.google.common.collect.ListMultimap; +import com.google.common.collect.Sets; + +/** + * @author Adrian Cole + */ +public class VCloudExpressVAppHandler extends ParseSax.HandlerWithResult { + private final String apiVersion; + private final VirtualSystemHandler systemHandler; + private final ResourceAllocationHandler allocationHandler; + @Resource + protected Logger logger = Logger.NULL; + + @Inject + public VCloudExpressVAppHandler(@Named(PROPERTY_API_VERSION) String apiVersion, VirtualSystemHandler systemHandler, + ResourceAllocationHandler allocationHandler) { + this.apiVersion = apiVersion; + this.systemHandler = systemHandler; + this.allocationHandler = allocationHandler; + } + + protected VirtualSystem system; + protected Set allocations = Sets.newLinkedHashSet(); + protected Status status; + protected final ListMultimap networkToAddresses = ArrayListMultimap.create(); + protected StringBuilder currentText = new StringBuilder(); + protected String operatingSystemDescription; + protected boolean inOs; + protected String networkName; + protected String name; + protected Integer osType; + protected URI location; + protected Long size; + protected NamedResource vDC; + + public VCloudExpressVApp getResult() { + return new VCloudExpressVAppImpl(name, location, status, size, vDC, networkToAddresses, osType, operatingSystemDescription, + system, allocations); + } + + public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { + if (qName.equals("VApp")) { + NamedResource resource = Utils.newNamedResource(attributes); + name = resource.getName(); + location = resource.getId(); + String statusString = attributes.getValue(attributes.getIndex("status")); + if (apiVersion.indexOf("0.8") != -1 && "2".equals(statusString)) + status = Status.OFF; + else + status = Status.fromValue(statusString); + if (attributes.getIndex("size") != -1) + size = new Long(attributes.getValue(attributes.getIndex("size"))); + } else if (qName.equals("Link")) { // type should never be missing + if (attributes.getIndex("type") != -1 + && attributes.getValue(attributes.getIndex("type")).equals(VCloudExpressMediaType.VDC_XML)) { + vDC = Utils.newNamedResource(attributes); + } + } else if (qName.equals("OperatingSystemSection")) { + inOs = true; + for (int i = 0; i < attributes.getLength(); i++) + if (attributes.getQName(i).indexOf("id") != -1) + osType = Integer.parseInt(attributes.getValue(i)); + } else if (qName.endsWith("NetworkConnection")) { + networkName = attributes.getValue(attributes.getIndex("Network")); + } else { + systemHandler.startElement(uri, localName, qName, attributes); + allocationHandler.startElement(uri, localName, qName, attributes); + } + + } + + @Override + public void endElement(String uri, String localName, String qName) throws SAXException { + if (qName.equals("OperatingSystemSection")) { + inOs = false; + } else if (inOs && qName.equals("Description")) { + operatingSystemDescription = currentText.toString().trim(); + } else if (qName.endsWith("IpAddress")) { + networkToAddresses.put(networkName, currentText.toString().trim()); + } else if (qName.equals("System")) { + systemHandler.endElement(uri, localName, qName); + system = systemHandler.getResult(); + } else if (qName.equals("Item")) { + allocationHandler.endElement(uri, localName, qName); + allocations.add(allocationHandler.getResult()); + } else { + systemHandler.endElement(uri, localName, qName); + allocationHandler.endElement(uri, localName, qName); + } + currentText = new StringBuilder(); + } + + @Override + public void characters(char ch[], int start, int length) { + currentText.append(ch, start, length); + systemHandler.characters(ch, start, length); + allocationHandler.characters(ch, start, length); + } + +} diff --git a/vcloud/core/src/test/java/org/jclouds/vcloud/CommonVCloudClientLiveTest.java b/vcloud/core/src/test/java/org/jclouds/vcloud/CommonVCloudClientLiveTest.java index 44f2e6d676..2af04662a0 100644 --- a/vcloud/core/src/test/java/org/jclouds/vcloud/CommonVCloudClientLiveTest.java +++ b/vcloud/core/src/test/java/org/jclouds/vcloud/CommonVCloudClientLiveTest.java @@ -33,7 +33,6 @@ import org.jclouds.vcloud.domain.CatalogItem; import org.jclouds.vcloud.domain.NamedResource; import org.jclouds.vcloud.domain.Org; import org.jclouds.vcloud.domain.Task; -import org.jclouds.vcloud.domain.VApp; import org.jclouds.vcloud.domain.VDC; import org.jclouds.vcloud.domain.network.OrgNetwork; import org.testng.annotations.BeforeGroups; @@ -135,14 +134,13 @@ public abstract class CommonVCloudClientLiveTest of(new Log4JLoggingModule()), props).getProviderSpecificContext(); + ImmutableSet. of(new Log4JLoggingModule()), props).getProviderSpecificContext(); connection = context.getApi(); } diff --git a/vcloud/core/src/test/java/org/jclouds/vcloud/VCloudClientLiveTest.java b/vcloud/core/src/test/java/org/jclouds/vcloud/VCloudClientLiveTest.java index f95e8c2d32..8f6a1c251a 100644 --- a/vcloud/core/src/test/java/org/jclouds/vcloud/VCloudClientLiveTest.java +++ b/vcloud/core/src/test/java/org/jclouds/vcloud/VCloudClientLiveTest.java @@ -27,6 +27,8 @@ import org.jclouds.vcloud.domain.Catalog; import org.jclouds.vcloud.domain.CatalogItem; import org.jclouds.vcloud.domain.NamedResource; import org.jclouds.vcloud.domain.Org; +import org.jclouds.vcloud.domain.VApp; +import org.jclouds.vcloud.domain.VDC; import org.testng.annotations.Test; /** @@ -63,6 +65,24 @@ public class VCloudClientLiveTest extends CommonVCloudClientLiveTest of(new Log4JLoggingModule()), properties).buildInjector(); + ImmutableSet. of(new Log4JLoggingModule()), properties).buildInjector(); computeClient = injector.getInstance(VCloudComputeClient.class); client = injector.getInstance(VCloudClient.class); addressTester = injector.getInstance(Key.get(new TypeLiteral>() { })); expectationMap = ImmutableMap. builder().put(OsFamily.CENTOS, - new Expectation(4194304 / 2 * 10, "Red Hat Enterprise Linux 5 (64-bit)")).build(); + new Expectation(4194304 / 2 * 10, "Red Hat Enterprise Linux 5 (64-bit)")).build(); provider = "vcloudtest"; templateName = "Ubuntu JeOS 9.10 (32-bit)"; } diff --git a/vcloud/core/src/test/java/org/jclouds/vcloud/compute/VCloudExpressComputeClientLiveTest.java b/vcloud/core/src/test/java/org/jclouds/vcloud/compute/VCloudExpressComputeClientLiveTest.java index 46c05f3cb2..ea1314d0a8 100644 --- a/vcloud/core/src/test/java/org/jclouds/vcloud/compute/VCloudExpressComputeClientLiveTest.java +++ b/vcloud/core/src/test/java/org/jclouds/vcloud/compute/VCloudExpressComputeClientLiveTest.java @@ -36,7 +36,7 @@ import org.jclouds.logging.log4j.config.Log4JLoggingModule; import org.jclouds.rest.RestContextFactory; import org.jclouds.vcloud.VCloudExpressClient; import org.jclouds.vcloud.domain.ResourceType; -import org.jclouds.vcloud.domain.VApp; +import org.jclouds.vcloud.domain.VCloudExpressVApp; import org.jclouds.vcloud.domain.Status; import org.jclouds.vcloud.domain.VCloudExpressVAppTemplate; import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions; @@ -100,7 +100,7 @@ public class VCloudExpressComputeClientLiveTest { id = URI.create(computeClient.start(null, template.getId(), templateName, options).get("id")); Expectation expectation = expectationMap.get(toTest); - VApp vApp = client.getVApp(id); + VCloudExpressVApp vApp = client.getVApp(id); verifyConfigurationOfVApp(vApp, serverName, expectation.os, processorCount, memory, expectation.hardDisk); assertEquals(vApp.getStatus(), Status.ON); } @@ -117,7 +117,7 @@ public class VCloudExpressComputeClientLiveTest { assert !addressTester.apply(publicAddress); } - private void verifyConfigurationOfVApp(VApp vApp, String serverName, String expectedOs, int processorCount, + private void verifyConfigurationOfVApp(VCloudExpressVApp vApp, String serverName, String expectedOs, int processorCount, int memory, long hardDisk) { // assertEquals(vApp.getName(), serverName); // assertEquals(vApp.getOperatingSystemDescription(), expectedOs); diff --git a/vcloud/core/src/test/java/org/jclouds/vcloud/xml/TaskHandlerTest.java b/vcloud/core/src/test/java/org/jclouds/vcloud/xml/TaskHandlerTest.java index 4c3996e0f7..41bc2d58be 100644 --- a/vcloud/core/src/test/java/org/jclouds/vcloud/xml/TaskHandlerTest.java +++ b/vcloud/core/src/test/java/org/jclouds/vcloud/xml/TaskHandlerTest.java @@ -52,7 +52,7 @@ public class TaskHandlerTest extends BaseHandlerTest { } public void testApplyInputStream() { - InputStream is = getClass().getResourceAsStream("/task.xml"); + InputStream is = getClass().getResourceAsStream("/express/task.xml"); Task result = factory.create(injector.getInstance(TaskHandler.class)).parse(is); @@ -72,7 +72,7 @@ public class TaskHandlerTest extends BaseHandlerTest { } public void testSelf() { - InputStream is = getClass().getResourceAsStream("/task-self.xml"); + InputStream is = getClass().getResourceAsStream("/express/task-self.xml"); Task result = factory.create(injector.getInstance(TaskHandler.class)).parse(is); @@ -83,7 +83,7 @@ public class TaskHandlerTest extends BaseHandlerTest { } public void testApplyInputStream2() { - InputStream is = getClass().getResourceAsStream("/task-hosting.xml"); + InputStream is = getClass().getResourceAsStream("/express/task-hosting.xml"); Task result = factory.create(injector.getInstance(TaskHandler.class)).parse(is); @@ -98,7 +98,7 @@ public class TaskHandlerTest extends BaseHandlerTest { } public void testError() { - InputStream is = getClass().getResourceAsStream("/task-error.xml"); + InputStream is = getClass().getResourceAsStream("/express/task-error.xml"); Task result = factory.create(injector.getInstance(TaskHandler.class)).parse(is); diff --git a/vcloud/core/src/test/java/org/jclouds/vcloud/xml/VAppHandlerTest.java b/vcloud/core/src/test/java/org/jclouds/vcloud/xml/VCloudExpressVAppHandlerTest.java similarity index 79% rename from vcloud/core/src/test/java/org/jclouds/vcloud/xml/VAppHandlerTest.java rename to vcloud/core/src/test/java/org/jclouds/vcloud/xml/VCloudExpressVAppHandlerTest.java index bbaa05717d..8d3daa837f 100644 --- a/vcloud/core/src/test/java/org/jclouds/vcloud/xml/VAppHandlerTest.java +++ b/vcloud/core/src/test/java/org/jclouds/vcloud/xml/VCloudExpressVAppHandlerTest.java @@ -34,10 +34,10 @@ import org.jclouds.http.functions.config.SaxParserModule; import org.jclouds.vcloud.domain.ResourceAllocation; import org.jclouds.vcloud.domain.ResourceType; import org.jclouds.vcloud.domain.Status; -import org.jclouds.vcloud.domain.VApp; +import org.jclouds.vcloud.domain.VCloudExpressVApp; import org.jclouds.vcloud.domain.VirtualSystem; import org.jclouds.vcloud.domain.internal.NamedResourceImpl; -import org.jclouds.vcloud.domain.internal.VAppImpl; +import org.jclouds.vcloud.domain.internal.VCloudExpressVAppImpl; import org.testng.annotations.BeforeTest; import org.testng.annotations.Test; @@ -50,12 +50,12 @@ import com.google.inject.Guice; import com.google.inject.name.Names; /** - * Tests behavior of {@code VAppHandler} + * Tests behavior of {@code VCloudExpressVAppHandler} * * @author Adrian Cole */ -@Test(groups = "unit", testName = "vcloud.VAppHandlerTest") -public class VAppHandlerTest extends BaseHandlerTest { +@Test(groups = "unit", testName = "vcloud.VCloudExpressVAppHandlerTest") +public class VCloudExpressVAppHandlerTest extends BaseHandlerTest { @BeforeTest @Override protected void setUpInjector() { @@ -75,19 +75,19 @@ public class VAppHandlerTest extends BaseHandlerTest { public void testInstantiated() throws UnknownHostException { InputStream is = getClass().getResourceAsStream("/instantiatedvapp.xml"); - VApp result = factory.create(injector.getInstance(VAppHandler.class)).parse(is); + VCloudExpressVApp result = factory.create(injector.getInstance(VCloudExpressVAppHandler.class)).parse(is); - VApp expects = new VAppImpl("centos53", URI.create("http://10.150.4.49/api/v0.8/vApp/10"), Status.RESOLVED, - 123456789l, new NamedResourceImpl(null, "application/vnd.vmware.vcloud.vdc+xml", URI - .create("http://10.150.4.49/api/v0.8/vdc/4")), ImmutableListMultimap. of(), - null, null, null, ImmutableSet. of()); + VCloudExpressVApp expects = new VCloudExpressVAppImpl("centos53", URI + .create("http://10.150.4.49/api/v0.8/vApp/10"), Status.RESOLVED, 123456789l, new NamedResourceImpl(null, + "application/vnd.vmware.vcloud.vdc+xml", URI.create("http://10.150.4.49/api/v0.8/vdc/4")), + ImmutableListMultimap. of(), null, null, null, ImmutableSet. of()); assertEquals(result, expects); } public void testDefault() throws UnknownHostException { InputStream is = getClass().getResourceAsStream("/vapp.xml"); - VApp result = factory.create(injector.getInstance(VAppHandler.class)).parse(is); + VCloudExpressVApp result = factory.create(injector.getInstance(VCloudExpressVAppHandler.class)).parse(is); ListMultimap networkToAddresses = ImmutableListMultimap. of("Public Network", "10.150.4.93"); @@ -105,10 +105,10 @@ public class VAppHandlerTest extends BaseHandlerTest { new ResourceAllocation(9, "Hard Disk 1", null, ResourceType.DISK_DRIVE, null, "104857", null, 0, 3, null, 104857, "byte * 2^20")).build(); - VApp expects = new VAppImpl("centos53", URI.create("http://10.150.4.49/api/v0.8/vApp/10"), Status.ON, new Long( - 104857), new NamedResourceImpl(null, "application/vnd.vmware.vcloud.vdc+xml", URI - .create("http://10.150.4.49/api/v0.8/vdc/4")), networkToAddresses, null, "Other Linux (32-bit)", system, - resourceAllocations); + VCloudExpressVApp expects = new VCloudExpressVAppImpl("centos53", URI + .create("http://10.150.4.49/api/v0.8/vApp/10"), Status.ON, new Long(104857), new NamedResourceImpl(null, + "application/vnd.vmware.vcloud.vdc+xml", URI.create("http://10.150.4.49/api/v0.8/vdc/4")), + networkToAddresses, null, "Other Linux (32-bit)", system, resourceAllocations); assertEquals(result.getId(), expects.getId()); assertEquals(result.getName(), expects.getName()); assertEquals(result.getNetworkToAddresses(), expects.getNetworkToAddresses()); @@ -124,7 +124,7 @@ public class VAppHandlerTest extends BaseHandlerTest { public void testLatest() throws UnknownHostException { InputStream is = getClass().getResourceAsStream("/vapp2.xml"); - VApp result = factory.create(injector.getInstance(VAppHandler.class)).parse(is); + VCloudExpressVApp result = factory.create(injector.getInstance(VCloudExpressVAppHandler.class)).parse(is); ListMultimap networkToAddresses = ImmutableListMultimap. of("Public Network", "10.23.119.221"); @@ -142,9 +142,9 @@ public class VAppHandlerTest extends BaseHandlerTest { new ResourceAllocation(9, "Hard Disk 1", null, ResourceType.DISK_DRIVE, null, "10485760", null, 0, 3, null, 10485760, "byte * 2^20")).build(); - VApp expects = new VAppImpl("m1", URI.create("http://localhost:8000/api/v0.8/vApp/80"), Status.ON, new Long( - 10485760), new NamedResourceImpl(null, "application/vnd.vmware.vcloud.vdc+xml", URI - .create("http://localhost:8000/api/v0.8/vdc/28")), networkToAddresses, null, + VCloudExpressVApp expects = new VCloudExpressVAppImpl("m1", URI.create("http://localhost:8000/api/v0.8/vApp/80"), + Status.ON, new Long(10485760), new NamedResourceImpl(null, "application/vnd.vmware.vcloud.vdc+xml", URI + .create("http://localhost:8000/api/v0.8/vdc/28")), networkToAddresses, null, "Microsoft Windows XP Professional (32-bit)", system, resourceAllocations); assertEquals(result.getId(), expects.getId()); assertEquals(result.getName(), expects.getName()); diff --git a/vcloud/core/src/test/resources/task-error.xml b/vcloud/core/src/test/resources/express/task-error.xml similarity index 100% rename from vcloud/core/src/test/resources/task-error.xml rename to vcloud/core/src/test/resources/express/task-error.xml diff --git a/vcloud/core/src/test/resources/task-hosting.xml b/vcloud/core/src/test/resources/express/task-hosting.xml similarity index 100% rename from vcloud/core/src/test/resources/task-hosting.xml rename to vcloud/core/src/test/resources/express/task-hosting.xml diff --git a/vcloud/core/src/test/resources/task-self.xml b/vcloud/core/src/test/resources/express/task-self.xml similarity index 100% rename from vcloud/core/src/test/resources/task-self.xml rename to vcloud/core/src/test/resources/express/task-self.xml diff --git a/vcloud/core/src/test/resources/task.xml b/vcloud/core/src/test/resources/express/task.xml similarity index 100% rename from vcloud/core/src/test/resources/task.xml rename to vcloud/core/src/test/resources/express/task.xml diff --git a/vcloud/core/src/test/resources/vapp-rhel-off-static.xml b/vcloud/core/src/test/resources/vapp-rhel-off-static.xml new file mode 100644 index 0000000000..7eabf4aa45 --- /dev/null +++ b/vcloud/core/src/test/resources/vapp-rhel-off-static.xml @@ -0,0 +1,322 @@ + + + + + + + + + + + + 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 + #!/bin/bash if [[ $1 == "postcustomization" ]]; then echo "post customization" touch /root/.postcustomization ping www.redhat.com -c 1 sleep 30 # register with RHN /usr/sbin/rhnreg_ks --profilename vic_`hostname`_`dmidecode -s system-uuid` --activationkey=281c9a9c77b8c001fe8ac8dd3b3f76d6 --force echo "rhn registered" # make hostname fully qualified to speed up sendmail start perl -i -pe "s/`hostname`/`hostname`.victory.blk/g" /etc/sysconfig/network rm /etc/ssh/*_key* service sshd restart echo "completed" fi + RHEL5 + + + 10_rhel_template + + + diff --git a/vcloud/core/src/test/resources/vapp-ubuntu-off-dhcp.xml b/vcloud/core/src/test/resources/vapp-ubuntu-off-dhcp.xml new file mode 100644 index 0000000000..d8406fcbfc --- /dev/null +++ b/vcloud/core/src/test/resources/vapp-ubuntu-off-dhcp.xml @@ -0,0 +1,213 @@ + + + + + + + + + + + + + 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/vcloud/core/src/test/resources/vapp-unresolved.xml b/vcloud/core/src/test/resources/vapp-unresolved.xml new file mode 100644 index 0000000000..995bc298f6 --- /dev/null +++ b/vcloud/core/src/test/resources/vapp-unresolved.xml @@ -0,0 +1,21 @@ + + + + + + + + + + diff --git a/vcloud/core/src/test/resources/vapp-win-off-static.xml b/vcloud/core/src/test/resources/vapp-win-off-static.xml new file mode 100644 index 0000000000..6282766222 --- /dev/null +++ b/vcloud/core/src/test/resources/vapp-win-off-static.xml @@ -0,0 +1,219 @@ + + + + + + + + + + + + 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/vcloud/core/src/test/resources/vm-rhel-off-static.xml b/vcloud/core/src/test/resources/vm-rhel-off-static.xml new file mode 100644 index 0000000000..507d5c4408 --- /dev/null +++ b/vcloud/core/src/test/resources/vm-rhel-off-static.xml @@ -0,0 +1,199 @@ + + + + + + + + + + + + + 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 + #!/bin/bash if [[ $1 == "postcustomization" + ]]; then echo "post customization" touch + /root/.postcustomization ping www.redhat.com -c 1 sleep 30 # + register with RHN /usr/sbin/rhnreg_ks --profilename + vic_`hostname`_`dmidecode -s system-uuid` + --activationkey=281c9a9c77b8c001fe8ac8dd3b3f76d6 --force + echo "rhn registered" # make hostname fully qualified to + speed up sendmail start perl -i -pe + "s/`hostname`/`hostname`.victory.blk/g" + /etc/sysconfig/network rm /etc/ssh/*_key* service sshd + restart echo "completed" fi + RHEL5 + + + 10_rhel_template + diff --git a/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/TerremarkVCloudAsyncClient.java b/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/TerremarkVCloudAsyncClient.java index 892501c2ef..948ee7cf2a 100644 --- a/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/TerremarkVCloudAsyncClient.java +++ b/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/TerremarkVCloudAsyncClient.java @@ -59,7 +59,7 @@ import org.jclouds.vcloud.VCloudExpressAsyncClient; import org.jclouds.vcloud.VCloudExpressClient; import org.jclouds.vcloud.domain.Catalog; import org.jclouds.vcloud.domain.Task; -import org.jclouds.vcloud.domain.VApp; +import org.jclouds.vcloud.domain.VCloudExpressVApp; import org.jclouds.vcloud.domain.VDC; import org.jclouds.vcloud.filters.SetVCloudTokenCookie; import org.jclouds.vcloud.functions.OrgNameAndVDCNameToEndpoint; @@ -94,7 +94,7 @@ import org.jclouds.vcloud.terremark.xml.TerremarkCatalogItemHandler; import org.jclouds.vcloud.terremark.xml.TerremarkOrgHandler; import org.jclouds.vcloud.terremark.xml.TerremarkVDCHandler; import org.jclouds.vcloud.xml.CatalogHandler; -import org.jclouds.vcloud.xml.VAppHandler; +import org.jclouds.vcloud.xml.VCloudExpressVAppHandler; import com.google.common.util.concurrent.ListenableFuture; @@ -188,9 +188,9 @@ public interface TerremarkVCloudAsyncClient extends VCloudExpressAsyncClient { @Path("action/instantiateVAppTemplate") @Produces("application/vnd.vmware.vcloud.instantiateVAppTemplateParams+xml") @Consumes(VAPP_XML) - @XMLResponseParser(VAppHandler.class) + @XMLResponseParser(VCloudExpressVAppHandler.class) @MapBinder(TerremarkBindInstantiateVAppTemplateParamsToXmlPayload.class) - ListenableFuture instantiateVAppTemplateInVDC(@EndpointParam URI vdc, + ListenableFuture instantiateVAppTemplateInVDC(@EndpointParam URI vdc, @MapPayloadParam("template") URI template, @MapPayloadParam("name") @ParamValidators(DnsNameValidator.class) String appName, InstantiateVAppTemplateOptions... options); @@ -330,7 +330,7 @@ public interface TerremarkVCloudAsyncClient extends VCloudExpressAsyncClient { @MapBinder(BindVAppConfigurationToXmlPayload.class) @ResponseParser(ParseTaskFromLocationHeader.class) ListenableFuture configureVApp( - @EndpointParam(parser = BindVAppConfigurationToXmlPayload.class) VApp vApp, VAppConfiguration configuration); + @EndpointParam(parser = BindVAppConfigurationToXmlPayload.class) VCloudExpressVApp vApp, VAppConfiguration configuration); /** * @see TerremarkVCloudClient#getCustomizationOptions diff --git a/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/TerremarkVCloudClient.java b/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/TerremarkVCloudClient.java index a3e7f740a5..7607018f06 100644 --- a/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/TerremarkVCloudClient.java +++ b/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/TerremarkVCloudClient.java @@ -28,7 +28,7 @@ import javax.annotation.Nullable; import org.jclouds.concurrent.Timeout; import org.jclouds.vcloud.VCloudExpressClient; import org.jclouds.vcloud.domain.Task; -import org.jclouds.vcloud.domain.VApp; +import org.jclouds.vcloud.domain.VCloudExpressVApp; import org.jclouds.vcloud.terremark.domain.CustomizationParameters; import org.jclouds.vcloud.terremark.domain.InternetService; import org.jclouds.vcloud.terremark.domain.Node; @@ -134,12 +134,12 @@ public interface TerremarkVCloudClient extends VCloudExpressClient { * You can make more than one change in a single request. For example, you can increase the * number of virtual CPUs and the amount of virtual memory in the same request. * - * @param VApp + * @param VCloudExpressVApp * vApp to change in power state off * @param configuration * (s) to change * @return task of configuration change */ - Task configureVApp(VApp vApp, VAppConfiguration configuration); + Task configureVApp(VCloudExpressVApp vApp, VAppConfiguration configuration); } \ No newline at end of file diff --git a/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/binders/BindVAppConfigurationToXmlPayload.java b/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/binders/BindVAppConfigurationToXmlPayload.java index ec272129f4..e4a60a76d6 100644 --- a/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/binders/BindVAppConfigurationToXmlPayload.java +++ b/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/binders/BindVAppConfigurationToXmlPayload.java @@ -46,7 +46,7 @@ import org.jclouds.rest.internal.GeneratedHttpRequest; import org.jclouds.vcloud.domain.ResourceAllocation; import org.jclouds.vcloud.domain.ResourceType; import org.jclouds.vcloud.domain.Status; -import org.jclouds.vcloud.domain.VApp; +import org.jclouds.vcloud.domain.VCloudExpressVApp; import org.jclouds.vcloud.terremark.domain.VAppConfiguration; import com.google.common.base.Function; @@ -85,7 +85,7 @@ public class BindVAppConfigurationToXmlPayload implements MapBinder, Function gRequest) { + protected VCloudExpressVApp findVAppInArgsOrNull(GeneratedHttpRequest gRequest) { for (Object arg : gRequest.getArgs()) { - if (arg instanceof VApp) { - return (VApp) arg; - } else if (arg instanceof VApp[]) { - VApp[] vapps = (VApp[]) arg; + if (arg instanceof VCloudExpressVApp) { + return (VCloudExpressVApp) arg; + } else if (arg instanceof VCloudExpressVApp[]) { + VCloudExpressVApp[] vapps = (VCloudExpressVApp[]) arg; return (vapps.length > 0) ? vapps[0] : null; } } @@ -210,6 +210,6 @@ public class BindVAppConfigurationToXmlPayload implements MapBinder, Function parseAndValidateResponse(VCloudExpressVAppTemplate template, VApp vAppResponse) { + protected Map parseAndValidateResponse(VCloudExpressVAppTemplate template, + VCloudExpressVApp vAppResponse) { Credentials credentials = credentialsProvider.execute(template); Map toReturn = super.parseResponse(template, vAppResponse); toReturn.put("username", credentials.identity); @@ -113,7 +114,7 @@ public class TerremarkVCloudComputeClient extends VCloudExpressComputeClientImpl } public String createPublicAddressMappedToPorts(URI vAppId, int... ports) { - VApp vApp = client.getVApp(vAppId); + VCloudExpressVApp vApp = client.getVApp(vAppId); PublicIpAddress ip = null; String privateAddress = getLast(vApp.getNetworkToAddresses().values()); for (int port : ports) { @@ -167,7 +168,7 @@ public class TerremarkVCloudComputeClient extends VCloudExpressComputeClientImpl return ip != null ? ip.getAddress() : null; } - private Set deleteInternetServicesAndNodesAssociatedWithVApp(VApp vApp) { + private Set deleteInternetServicesAndNodesAssociatedWithVApp(VCloudExpressVApp vApp) { Set ipAddresses = Sets.newHashSet(); SERVICE: for (InternetService service : client.getAllInternetServicesInVDC(vApp.getVDC().getId())) { for (Node node : client.getNodes(service.getId())) { @@ -210,7 +211,7 @@ public class TerremarkVCloudComputeClient extends VCloudExpressComputeClientImpl */ @Override public void stop(URI id) { - VApp vApp = client.getVApp(id); + VCloudExpressVApp vApp = client.getVApp(id); Set ipAddresses = deleteInternetServicesAndNodesAssociatedWithVApp(vApp); deletePublicIpAddressesWithNoServicesAttached(ipAddresses); if (vApp.getStatus() != Status.OFF) { @@ -229,14 +230,14 @@ public class TerremarkVCloudComputeClient extends VCloudExpressComputeClientImpl logger.debug("<< deleted vApp(%s))", vApp.getName()); } - private void powerOffAndWait(VApp vApp) { + private void powerOffAndWait(VCloudExpressVApp vApp) { logger.debug(">> powering off vApp(%s), current status: %s", vApp.getName(), vApp.getStatus()); Task task = client.powerOffVApp(vApp.getId()); if (!taskTester.apply(task.getLocation())) - throw new TaskException("powerOff", vApp, task); + throw new RuntimeException(String.format("failed to %s %s: %s", "powerOff", vApp.getName(), task)); } - void blockOnLastTask(VApp vApp) { + void blockOnLastTask(VCloudExpressVApp vApp) { TasksList list = client.findTasksListInOrgNamed(null); try { Task lastTask = getLast(filter(list.getTasks(), new Predicate() { @@ -248,7 +249,7 @@ public class TerremarkVCloudComputeClient extends VCloudExpressComputeClientImpl })); if (!taskTester.apply(lastTask.getLocation())) - throw new TaskException("powerOff", vApp, lastTask); + throw new RuntimeException(String.format("failed to %s %s: %s", "powerOff", vApp.getName(), lastTask)); } catch (NoSuchElementException ex) { } @@ -259,7 +260,7 @@ public class TerremarkVCloudComputeClient extends VCloudExpressComputeClientImpl */ @Override public Set getPrivateAddresses(URI id) { - VApp vApp = client.getVApp(id); + VCloudExpressVApp vApp = client.getVApp(id); if (vApp != null) return Sets.newHashSet(vApp.getNetworkToAddresses().values()); else @@ -271,7 +272,7 @@ public class TerremarkVCloudComputeClient extends VCloudExpressComputeClientImpl */ @Override public Set getPublicAddresses(URI id) { - VApp vApp = client.getVApp(id); + VCloudExpressVApp vApp = client.getVApp(id); if (vApp != null) { Set ipAddresses = Sets.newHashSet(); for (InternetService service : client.getAllInternetServicesInVDC(vApp.getVDC().getId())) { diff --git a/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/compute/config/TerremarkVCloudComputeServiceContextModule.java b/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/compute/config/TerremarkVCloudComputeServiceContextModule.java index 5360db058d..a1de4a687d 100755 --- a/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/compute/config/TerremarkVCloudComputeServiceContextModule.java +++ b/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/compute/config/TerremarkVCloudComputeServiceContextModule.java @@ -46,7 +46,7 @@ import org.jclouds.vcloud.VCloudExpressClient; import org.jclouds.vcloud.compute.VCloudExpressComputeClient; import org.jclouds.vcloud.compute.config.VCloudExpressComputeServiceContextModule; import org.jclouds.vcloud.compute.strategy.VCloudDestroyNodeStrategy; -import org.jclouds.vcloud.compute.strategy.VCloudListNodesStrategy; +import org.jclouds.vcloud.compute.strategy.VCloudExpressListNodesStrategy; import org.jclouds.vcloud.compute.strategy.VCloudRebootNodeStrategy; import org.jclouds.vcloud.terremark.compute.TerremarkVCloudComputeClient; import org.jclouds.vcloud.terremark.compute.TerremarkVCloudComputeService; @@ -97,7 +97,7 @@ public class TerremarkVCloudComputeServiceContextModule extends VCloudExpressCom }).in(Scopes.SINGLETON); // NOTE bind(RunNodesAndAddToSetStrategy.class).to(TerremarkEncodeTagIntoNameRunNodesAndAddToSetStrategy.class); - bind(ListNodesStrategy.class).to(VCloudListNodesStrategy.class); + bind(ListNodesStrategy.class).to(VCloudExpressListNodesStrategy.class); // NOTE bind(GetNodeMetadataStrategy.class).to(TerremarkVCloudGetNodeMetadataStrategy.class); bind(RebootNodeStrategy.class).to(VCloudRebootNodeStrategy.class); diff --git a/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/compute/strategy/TerremarkVCloudGetNodeMetadataStrategy.java b/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/compute/strategy/TerremarkVCloudGetNodeMetadataStrategy.java index cd440a673a..de9e33e2a7 100644 --- a/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/compute/strategy/TerremarkVCloudGetNodeMetadataStrategy.java +++ b/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/compute/strategy/TerremarkVCloudGetNodeMetadataStrategy.java @@ -38,12 +38,12 @@ import org.jclouds.compute.domain.NodeState; import org.jclouds.compute.reference.ComputeServiceConstants; import org.jclouds.domain.Credentials; import org.jclouds.logging.Logger; -import org.jclouds.vcloud.CommonVCloudClient; -import org.jclouds.vcloud.compute.CommonVCloudComputeClient; +import org.jclouds.vcloud.VCloudExpressClient; +import org.jclouds.vcloud.compute.VCloudExpressComputeClient; import org.jclouds.vcloud.compute.domain.VCloudLocation; import org.jclouds.vcloud.compute.functions.FindLocationForResource; -import org.jclouds.vcloud.compute.functions.GetExtra; -import org.jclouds.vcloud.compute.strategy.VCloudGetNodeMetadataStrategy; +import org.jclouds.vcloud.compute.functions.GetExtraFromVCloudExpressVApp; +import org.jclouds.vcloud.compute.strategy.VCloudExpressGetNodeMetadataStrategy; import org.jclouds.vcloud.domain.Status; import org.jclouds.vcloud.terremark.compute.domain.KeyPairCredentials; import org.jclouds.vcloud.terremark.compute.domain.OrgAndName; @@ -54,7 +54,7 @@ import com.google.common.base.Supplier; * @author Adrian Cole */ @Singleton -public class TerremarkVCloudGetNodeMetadataStrategy extends VCloudGetNodeMetadataStrategy { +public class TerremarkVCloudGetNodeMetadataStrategy extends VCloudExpressGetNodeMetadataStrategy { @Resource @Named(ComputeServiceConstants.COMPUTE_LOGGER) protected Logger logger = Logger.NULL; @@ -62,10 +62,10 @@ public class TerremarkVCloudGetNodeMetadataStrategy extends VCloudGetNodeMetadat private final ConcurrentMap credentialsMap; @Inject - protected TerremarkVCloudGetNodeMetadataStrategy(CommonVCloudClient client, CommonVCloudComputeClient computeClient, - Map vAppStatusToNodeState, GetExtra getExtra, - FindLocationForResource findLocationForResourceInVDC, Supplier> images, - ConcurrentMap credentialsMap) { + protected TerremarkVCloudGetNodeMetadataStrategy(VCloudExpressClient client, + VCloudExpressComputeClient computeClient, Map vAppStatusToNodeState, + GetExtraFromVCloudExpressVApp getExtra, FindLocationForResource findLocationForResourceInVDC, + Supplier> images, ConcurrentMap credentialsMap) { super(client, computeClient, vAppStatusToNodeState, getExtra, findLocationForResourceInVDC, images); this.credentialsMap = credentialsMap; } diff --git a/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/TerremarkClientLiveTest.java b/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/TerremarkClientLiveTest.java index bc9c27698a..bd3fb4d8dd 100644 --- a/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/TerremarkClientLiveTest.java +++ b/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/TerremarkClientLiveTest.java @@ -54,7 +54,7 @@ import org.jclouds.vcloud.domain.NamedResource; import org.jclouds.vcloud.domain.ResourceAllocation; import org.jclouds.vcloud.domain.ResourceType; import org.jclouds.vcloud.domain.Task; -import org.jclouds.vcloud.domain.VApp; +import org.jclouds.vcloud.domain.VCloudExpressVApp; import org.jclouds.vcloud.domain.Status; import org.jclouds.vcloud.domain.VCloudExpressVAppTemplate; import org.jclouds.vcloud.domain.VDC; @@ -96,10 +96,10 @@ public abstract class TerremarkClientLiveTest extends VCloudExpressClientLiveTes private String publicIp; private InternetService is; private Node node; - private VApp vApp; + private VCloudExpressVApp vApp; private RetryablePredicate socketTester; private RetryablePredicate successTester; - private VApp clone; + private VCloudExpressVApp clone; private VDC vdc; protected String credential; public static final String PREFIX = System.getProperty("user.name") + "-terremark"; @@ -365,7 +365,7 @@ public abstract class TerremarkClientLiveTest extends VCloudExpressClientLiveTes loopAndCheckPass(); } - private void verifyConfigurationOfVApp(VApp vApp, String serverName, String expectedOs, int processorCount, + private void verifyConfigurationOfVApp(VCloudExpressVApp vApp, String serverName, String expectedOs, int processorCount, long memory, long hardDisk) { assertEquals(vApp.getName(), serverName); assertEquals(vApp.getOperatingSystemDescription(), expectedOs); diff --git a/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/TerremarkECloudAsyncClientTest.java b/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/TerremarkECloudAsyncClientTest.java index bf30736e1a..c2ac5ae004 100644 --- a/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/TerremarkECloudAsyncClientTest.java +++ b/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/TerremarkECloudAsyncClientTest.java @@ -68,7 +68,7 @@ import org.jclouds.vcloud.terremark.xml.NodesHandler; import org.jclouds.vcloud.terremark.xml.PublicIpAddressesHandler; import org.jclouds.vcloud.terremark.xml.TerremarkVDCHandler; import org.jclouds.vcloud.xml.CatalogHandler; -import org.jclouds.vcloud.xml.VAppHandler; +import org.jclouds.vcloud.xml.VCloudExpressVAppHandler; import org.testng.annotations.Test; import com.google.common.base.Supplier; @@ -132,7 +132,7 @@ public class TerremarkECloudAsyncClientTest extends RestClientTest of(), null, null, null, ImmutableSet.of( new ResourceAllocation(1, "n/a", null, ResourceType.PROCESSOR, null, null, null, null, null, @@ -92,7 +92,7 @@ public class BindVAppConfigurationToXmlPayloadTest { } public void testRemoveDisk() throws IOException { - VAppImpl vApp = new VAppImpl("MyAppServer6", URI + VCloudExpressVAppImpl vApp = new VCloudExpressVAppImpl("MyAppServer6", URI .create("https://services.vcloudexpress/terremark.com/api/v0.8/vapp/4213"), Status.OFF, 4194304l, null, ImmutableListMultimap. of(), null, null, null, ImmutableSet.of( new ResourceAllocation(1, "n/a", null, ResourceType.PROCESSOR, null, null, null, null, null, @@ -121,7 +121,7 @@ public class BindVAppConfigurationToXmlPayloadTest { } public void testChangeCPUCountTo4() throws IOException { - VAppImpl vApp = new VAppImpl("eduardo", URI + VCloudExpressVAppImpl vApp = new VCloudExpressVAppImpl("eduardo", URI .create("https://services.vcloudexpress/terremark.com/api/v0.8/vapp/4213"), Status.OFF, 4194304l, null, ImmutableListMultimap. of(), null, null, null, ImmutableSet.of( new ResourceAllocation(1, "n/a", null, ResourceType.PROCESSOR, null, null, null, null, null, @@ -146,7 +146,7 @@ public class BindVAppConfigurationToXmlPayloadTest { } public void testChangeMemoryTo1536() throws IOException { - VAppImpl vApp = new VAppImpl("MyAppServer6", URI + VCloudExpressVAppImpl vApp = new VCloudExpressVAppImpl("MyAppServer6", URI .create("https://services.vcloudexpress/terremark.com/api/v0.8/vapp/4213"), Status.OFF, 4194304l, null, ImmutableListMultimap. of(), null, null, null, ImmutableSet.of( new ResourceAllocation(1, "n/a", null, ResourceType.PROCESSOR, null, null, null, null, null, diff --git a/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/compute/TerremarkVCloudComputeClientTest.java b/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/compute/TerremarkVCloudComputeClientTest.java index 9489ad471f..8026674746 100644 --- a/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/compute/TerremarkVCloudComputeClientTest.java +++ b/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/compute/TerremarkVCloudComputeClientTest.java @@ -34,7 +34,7 @@ import javax.inject.Provider; import org.jclouds.compute.domain.NodeState; import org.jclouds.vcloud.domain.Task; -import org.jclouds.vcloud.domain.VApp; +import org.jclouds.vcloud.domain.VCloudExpressVApp; import org.jclouds.vcloud.domain.Status; import org.jclouds.vcloud.domain.VCloudExpressVAppTemplate; import org.jclouds.vcloud.terremark.TerremarkVCloudExpressClient; @@ -63,7 +63,7 @@ public class TerremarkVCloudComputeClientTest { expect(template.getDescription()).andReturn(description).atLeastOnce(); TerremarkVCloudExpressClient client = createMock(TerremarkVCloudExpressClient.class); - VApp vApp = createMock(VApp.class); + VCloudExpressVApp vApp = createMock(VCloudExpressVApp.class); expect(client.getVDC(vdcURI)).andReturn(vdc); expect(client.getVAppTemplate(templateURI)).andReturn(template); @@ -88,7 +88,7 @@ public class TerremarkVCloudComputeClientTest { expect(successTester.apply(taskLocation)).andReturn(true).atLeastOnce(); expect(client.powerOnVApp(vappLocation)).andReturn(task); - Predicate notFoundTester = createMock(Predicate.class); + Predicate notFoundTester = createMock(Predicate.class); Map vAppStatusToNodeState = createMock(Map.class); TerremarkVCloudComputeClient computeClient = new TerremarkVCloudComputeClient(client, diff --git a/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/xml/VAppHandlerTest.java b/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/xml/VAppHandlerTest.java index cbfb98ddaf..9ebb5fd499 100644 --- a/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/xml/VAppHandlerTest.java +++ b/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/xml/VAppHandlerTest.java @@ -38,10 +38,10 @@ import org.jclouds.vcloud.VCloudExpressMediaType; import org.jclouds.vcloud.domain.ResourceAllocation; import org.jclouds.vcloud.domain.ResourceType; import org.jclouds.vcloud.domain.Status; -import org.jclouds.vcloud.domain.VApp; +import org.jclouds.vcloud.domain.VCloudExpressVApp; import org.jclouds.vcloud.domain.VirtualSystem; import org.jclouds.vcloud.domain.internal.NamedResourceImpl; -import org.jclouds.vcloud.xml.VAppHandler; +import org.jclouds.vcloud.xml.VCloudExpressVAppHandler; import org.testng.annotations.BeforeTest; import org.testng.annotations.Test; @@ -79,7 +79,7 @@ public class VAppHandlerTest extends BaseHandlerTest { public void testApplyInputStream() { InputStream is = getClass().getResourceAsStream("/terremark/launched_vapp.xml"); - VApp result = (VApp) factory.create(injector.getInstance(VAppHandler.class)).parse(is); + VCloudExpressVApp result = (VCloudExpressVApp) factory.create(injector.getInstance(VCloudExpressVAppHandler.class)).parse(is); assertEquals(result.getName(), "adriantest"); assertEquals(result.getStatus(), Status.UNRESOLVED); @@ -95,7 +95,7 @@ public class VAppHandlerTest extends BaseHandlerTest { public void testGetVApp() throws UnknownHostException { InputStream is = getClass().getResourceAsStream("/terremark/get_vapp.xml"); - VApp result = (VApp) factory.create(injector.getInstance(VAppHandler.class)).parse(is); + VCloudExpressVApp result = (VCloudExpressVApp) factory.create(injector.getInstance(VCloudExpressVAppHandler.class)).parse(is); assertEquals(result.getName(), "centos-53"); assertEquals(result.getStatus(), Status.OFF); @@ -133,7 +133,7 @@ public class VAppHandlerTest extends BaseHandlerTest { public void testGetVApp2disks() throws UnknownHostException { InputStream is = getClass().getResourceAsStream("/terremark/get_vapp2disks.xml"); - VApp vApp = factory.create(injector.getInstance(VAppHandler.class)).parse(is); + VCloudExpressVApp vApp = factory.create(injector.getInstance(VCloudExpressVAppHandler.class)).parse(is); assertEquals(vApp.getName(), "eduardo"); assertEquals(vApp.getStatus(), Status.OFF);