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 4409d1c3e5..58411a6e40 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 @@ -31,7 +31,7 @@ import org.jclouds.domain.Credentials; import org.jclouds.vcloud.VCloudClient; import org.jclouds.vcloud.compute.internal.VCloudComputeClientImpl; import org.jclouds.vcloud.domain.VApp; -import org.jclouds.vcloud.domain.VAppStatus; +import org.jclouds.vcloud.domain.Status; import org.jclouds.vcloud.domain.VAppTemplate; import com.google.common.base.Predicate; @@ -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 0cef4655d6..cfda41e4ba 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 @@ -31,7 +31,7 @@ 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.VAppStatus; +import org.jclouds.vcloud.domain.Status; import org.jclouds.vcloud.domain.VAppTemplate; import com.google.common.base.Predicate; @@ -45,7 +45,7 @@ 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; } 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 4e9239c94d..c1b926d71a 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 @@ -45,7 +45,7 @@ import org.jclouds.vcloud.compute.strategy.VCloudRebootNodeStrategy; import org.jclouds.vcloud.compute.suppliers.OrgAndVDCToLocationSupplier; import org.jclouds.vcloud.compute.suppliers.StaticSizeSupplier; import org.jclouds.vcloud.compute.suppliers.VCloudImageSupplier; -import org.jclouds.vcloud.domain.VAppStatus; +import org.jclouds.vcloud.domain.Status; import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Supplier; @@ -63,14 +63,17 @@ import com.google.inject.util.Providers; public abstract class CommonVCloudComputeServiceContextModule extends BaseComputeServiceContextModule { @VisibleForTesting - static final Map vAppStatusToNodeState = ImmutableMap. builder().put( - VAppStatus.OFF, NodeState.SUSPENDED).put(VAppStatus.ON, NodeState.RUNNING).put(VAppStatus.RESOLVED, - NodeState.PENDING).put(VAppStatus.SUSPENDED, NodeState.SUSPENDED).put(VAppStatus.UNRESOLVED, - NodeState.PENDING).build(); + static final Map vAppStatusToNodeState = ImmutableMap. builder().put( + Status.OFF, NodeState.SUSPENDED).put(Status.ON, NodeState.RUNNING).put(Status.RESOLVED, NodeState.PENDING) + .put(Status.ERROR, NodeState.ERROR).put(Status.UNRECOGNIZED, NodeState.UNKNOWN).put(Status.DEPLOYED, + NodeState.PENDING).put(Status.INCONSISTENT, NodeState.PENDING).put(Status.UNKNOWN, + NodeState.UNKNOWN).put(Status.MIXED, NodeState.PENDING).put(Status.WAITING_FOR_INPUT, + NodeState.PENDING).put(Status.SUSPENDED, NodeState.SUSPENDED).put(Status.UNRESOLVED, + NodeState.PENDING).build(); @Singleton @Provides - Map provideVAppStatusToNodeState() { + Map provideVAppStatusToNodeState() { return vAppStatusToNodeState; } 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 a42241b275..9f34d2c50c 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 @@ -35,7 +35,7 @@ import org.jclouds.vcloud.CommonVCloudClient; import org.jclouds.vcloud.compute.CommonVCloudComputeClient; import org.jclouds.vcloud.domain.Task; import org.jclouds.vcloud.domain.VApp; -import org.jclouds.vcloud.domain.VAppStatus; +import org.jclouds.vcloud.domain.Status; import org.jclouds.vcloud.domain.VAppTemplate; import com.google.common.base.Predicate; @@ -104,7 +104,7 @@ public class CommonVCloudComputeClientImpl implements CommonVCloudComputeClient } private VApp undeployVAppIfDeployed(VApp vApp) { - if (vApp.getStatus().compareTo(VAppStatus.RESOLVED) > 0) { + if (vApp.getStatus().compareTo(Status.RESOLVED) > 0) { logger.debug(">> undeploying vApp(%s), current status: %s", vApp.getName(), vApp.getStatus()); Task task = client.undeployVApp(vApp.getId()); if (!taskTester.apply(task.getLocation())) { @@ -117,7 +117,7 @@ public class CommonVCloudComputeClientImpl implements CommonVCloudComputeClient } private VApp powerOffVAppIfDeployed(VApp vApp) { - if (vApp.getStatus().compareTo(VAppStatus.OFF) > 0) { + if (vApp.getStatus().compareTo(Status.OFF) > 0) { logger.debug(">> powering off vApp(%s), current status: %s", vApp.getName(), vApp.getStatus()); Task task = client.powerOffVApp(vApp.getId()); if (!taskTester.apply(task.getLocation())) { 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 da79879ebc..452af905f3 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 @@ -32,7 +32,7 @@ import org.jclouds.vcloud.VCloudClient; import org.jclouds.vcloud.compute.VCloudComputeClient; import org.jclouds.vcloud.domain.Task; import org.jclouds.vcloud.domain.VApp; -import org.jclouds.vcloud.domain.VAppStatus; +import org.jclouds.vcloud.domain.Status; import org.jclouds.vcloud.domain.VAppTemplate; import org.jclouds.vcloud.domain.VDC; import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions; @@ -46,11 +46,11 @@ import com.google.inject.Inject; @Singleton public class VCloudComputeClientImpl extends CommonVCloudComputeClientImpl implements VCloudComputeClient { - protected final Map vAppStatusToNodeState; + protected final Map vAppStatusToNodeState; @Inject public VCloudComputeClientImpl(VCloudClient client, Predicate successTester, - Map vAppStatusToNodeState) { + Map vAppStatusToNodeState) { super(client, successTester); this.vAppStatusToNodeState = vAppStatusToNodeState; } 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 cd13619818..5809b77c91 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 @@ -32,7 +32,7 @@ import org.jclouds.vcloud.VCloudExpressClient; import org.jclouds.vcloud.compute.VCloudExpressComputeClient; import org.jclouds.vcloud.domain.Task; import org.jclouds.vcloud.domain.VApp; -import org.jclouds.vcloud.domain.VAppStatus; +import org.jclouds.vcloud.domain.Status; import org.jclouds.vcloud.domain.VAppTemplate; import org.jclouds.vcloud.domain.VDC; import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions; @@ -46,11 +46,11 @@ import com.google.inject.Inject; @Singleton public class VCloudExpressComputeClientImpl extends CommonVCloudComputeClientImpl implements VCloudExpressComputeClient { - protected final Map vAppStatusToNodeState; + protected final Map vAppStatusToNodeState; @Inject public VCloudExpressComputeClientImpl(VCloudExpressClient client, Predicate successTester, - Map vAppStatusToNodeState) { + Map vAppStatusToNodeState) { super(client, successTester); this.vAppStatusToNodeState = vAppStatusToNodeState; } 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 d33ad7dfb5..b496ce1d7c 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 @@ -38,7 +38,7 @@ 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.VAppStatus; +import org.jclouds.vcloud.domain.Status; import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions; import com.google.common.collect.ImmutableMap; @@ -50,11 +50,11 @@ import com.google.common.collect.ImmutableMap; public class VCloudAddNodeWithTagStrategy implements AddNodeWithTagStrategy { protected final VCloudClient client; protected final VCloudComputeClient computeClient; - protected final Map vAppStatusToNodeState; + protected final Map vAppStatusToNodeState; @Inject protected VCloudAddNodeWithTagStrategy(VCloudClient client, VCloudComputeClient computeClient, - Map vAppStatusToNodeState) { + Map vAppStatusToNodeState) { this.client = client; this.computeClient = computeClient; this.vAppStatusToNodeState = vAppStatusToNodeState; 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 b62872f063..154a7a33ff 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 @@ -38,7 +38,7 @@ 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.VAppStatus; +import org.jclouds.vcloud.domain.Status; import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions; import com.google.common.collect.ImmutableMap; @@ -50,11 +50,11 @@ import com.google.common.collect.ImmutableMap; public class VCloudExpressAddNodeWithTagStrategy implements AddNodeWithTagStrategy { protected final VCloudExpressClient client; protected final VCloudExpressComputeClient computeClient; - protected final Map vAppStatusToNodeState; + protected final Map vAppStatusToNodeState; @Inject protected VCloudExpressAddNodeWithTagStrategy(VCloudExpressClient client, VCloudExpressComputeClient computeClient, - Map vAppStatusToNodeState) { + Map vAppStatusToNodeState) { this.client = client; this.computeClient = computeClient; this.vAppStatusToNodeState = vAppStatusToNodeState; 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 e561d02be5..28f9d0ad4f 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 @@ -45,7 +45,7 @@ import org.jclouds.vcloud.compute.CommonVCloudComputeClient; import org.jclouds.vcloud.compute.functions.FindLocationForResource; import org.jclouds.vcloud.compute.functions.GetExtra; import org.jclouds.vcloud.domain.VApp; -import org.jclouds.vcloud.domain.VAppStatus; +import org.jclouds.vcloud.domain.Status; import com.google.common.base.Supplier; import com.google.common.collect.ImmutableMap; @@ -63,11 +63,11 @@ public class VCloudGetNodeMetadataStrategy implements GetNodeMetadataStrategy { protected final Supplier> images; protected final FindLocationForResource findLocationForResourceInVDC; protected final GetExtra getExtra; - protected final Map vAppStatusToNodeState; + protected final Map vAppStatusToNodeState; @Inject protected VCloudGetNodeMetadataStrategy(CommonVCloudClient client, CommonVCloudComputeClient computeClient, - Map vAppStatusToNodeState, GetExtra getExtra, + Map vAppStatusToNodeState, GetExtra getExtra, FindLocationForResource findLocationForResourceInVDC, Supplier> images) { this.client = checkNotNull(client, "client"); this.images = checkNotNull(images, "images"); diff --git a/vcloud/core/src/main/java/org/jclouds/vcloud/domain/Status.java b/vcloud/core/src/main/java/org/jclouds/vcloud/domain/Status.java new file mode 100644 index 0000000000..fdd2dc4de6 --- /dev/null +++ b/vcloud/core/src/main/java/org/jclouds/vcloud/domain/Status.java @@ -0,0 +1,225 @@ +/** + * + * 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 static com.google.common.base.Preconditions.checkNotNull; + +/** + * Objects such as vAppTemplate, vApp, and Vm have a status attribute whose value indicates the + * state of the object. Status for an object, such as a vAppTemplate or vApp, whose Children (Vm + * objects) each have a status of their own, is computed from the status of the Children. + * + *

NOTE

+ *

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

+ * note that the documentation does not reference use of this. + * + * @since vcloud api 1.0 + */ + DEPLOYED, + /** + * The {@link VApp} or {@link Vm} is suspended. + * + * @since vcloud api 0.8 + */ + SUSPENDED, + /** + * The {@link VApp} or {@link Vm} is powered on + * + * @since vcloud api 0.8 + */ + ON, + /** + * The {@link VApp} or {@link Vm} waiting for user input. + * + * @since vcloud api 1.0 + */ + WAITING_FOR_INPUT, + /** + * The {@link VAppTemplate}, {@link VApp}, or {@link Vm} is in an unknown state. + * + * @since vcloud api 1.0 + */ + UNKNOWN, + /** + * The {@link VAppTemplate}, {@link VApp}, or {@link Vm} is in an unrecognized state. + * + * @since vcloud api 1.0 + */ + UNRECOGNIZED, + /** + * The {@link VAppTemplate}, {@link VApp}, or {@link Vm} is off. + * + * @since vcloud api 0.8 + */ + OFF, + /** + * The {@link VApp} or {@link Vm} is in an inconsistent state. + * + * @since vcloud api 1.0 + */ + INCONSISTENT, + /** + * The {@link VAppTemplate} or {@link VApp} have children do not all have the same status. + * + * @since vcloud api 1.0 + */ + MIXED, + /** + * The {@link VAppTemplate} Upload initiated, OVF descriptor pending + * + * @since vcloud api 1.0 + */ + PENDING_DESCRIPTOR, + /** + * The {@link VAppTemplate} Upload initiated, copying contents + * + * @since vcloud api 1.0 + */ + COPYING, + /** + * The {@link VAppTemplate} Upload initiated, disk contents pending + * + * @since vcloud api 1.0 + */ + PENDING_CONTENTS, + /** + * The {@link VAppTemplate} Upload has been quarantined + * + * @since vcloud api 1.0 + */ + QUARANTINED, + /** + * The {@link VAppTemplate} Upload quarantine period has expired + * + * @since vcloud api 1.0 + */ + QUARANTINE_EXPIRED; + + public String value() { + switch (this) { + case UNRESOLVED: + return "0"; + case RESOLVED: + return "1"; + case DEPLOYED: + return "2"; + case SUSPENDED: + return "3"; + case ON: + return "4"; + case WAITING_FOR_INPUT: + return "5"; + case UNKNOWN: + return "6"; + case UNRECOGNIZED: + return "7"; + case OFF: + return "8"; + case INCONSISTENT: + return "9"; + case MIXED: + return "10"; + case PENDING_DESCRIPTOR: + return "11"; + case COPYING: + return "12"; + case PENDING_CONTENTS: + return "13"; + case QUARANTINED: + return "14"; + case QUARANTINE_EXPIRED: + return "15"; + default: + throw new IllegalArgumentException("invalid status:" + this); + } + } + + public static Status fromValue(String status) { + return fromValue(Integer.parseInt(checkNotNull(status, "status"))); + } + + public static Status fromValue(int v) { + switch (v) { + case 0: + return UNRESOLVED; + case 1: + return RESOLVED; + case 2: + return DEPLOYED; + case 3: + return SUSPENDED; + case 4: + return ON; + case 5: + return WAITING_FOR_INPUT; + case 6: + return UNKNOWN; + case 7: + return UNRECOGNIZED; + case 8: + return OFF; + case 9: + return INCONSISTENT; + case 10: + return MIXED; + case 11: + return PENDING_DESCRIPTOR; + case 12: + return COPYING; + case 13: + return PENDING_CONTENTS; + case 14: + return QUARANTINED; + case 15: + return QUARANTINE_EXPIRED; + default: + throw new IllegalArgumentException("invalid status:" + v); + } + } + +} \ 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 90c599eff9..035538f177 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 @@ -39,7 +39,7 @@ import com.google.inject.ImplementedBy; public interface VApp extends NamedResource { NamedResource getVDC(); - VAppStatus getStatus(); + Status getStatus(); Long getSize(); diff --git a/vcloud/core/src/main/java/org/jclouds/vcloud/domain/VAppStatus.java b/vcloud/core/src/main/java/org/jclouds/vcloud/domain/VAppStatus.java deleted file mode 100644 index 62eab9e304..0000000000 --- a/vcloud/core/src/main/java/org/jclouds/vcloud/domain/VAppStatus.java +++ /dev/null @@ -1,89 +0,0 @@ -/** - * - * 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 static com.google.common.base.Preconditions.checkNotNull; - -/** - * Indicates the status of the VApp. - * - * @author Adrian Cole - */ -public enum VAppStatus { - /** - * The vApp is unresolved (one or more file references are unavailable in the cloud) - */ - UNRESOLVED, - /** - * The vApp is resolved (all file references are available in the cloud) but not deployed - */ - RESOLVED, - /** - * The vApp is deployed and powered off - */ - OFF, - /** - * The vApp is deployed and suspended - */ - SUSPENDED, - /** - * The vApp is deployed and powered on - */ - ON; - - public String value() { - switch (this) { - case UNRESOLVED: - return "0"; - case RESOLVED: - return "1"; - case OFF: - return "2"; - case SUSPENDED: - return "3"; - case ON: - return "4"; - default: - throw new IllegalArgumentException("invalid status:" + this); - } - } - - public static VAppStatus fromValue(String status) { - return fromValue(Integer.parseInt(checkNotNull(status, "status"))); - } - - public static VAppStatus fromValue(int v) { - switch (v) { - case 0: - return UNRESOLVED; - case 1: - return RESOLVED; - case 2: - return OFF; - case 3: - return SUSPENDED; - case 4: - return ON; - default: - throw new IllegalArgumentException("invalid status:" + v); - } - } - -} \ No newline at end of file diff --git a/vcloud/core/src/main/java/org/jclouds/vcloud/domain/VAppTemplate.java b/vcloud/core/src/main/java/org/jclouds/vcloud/domain/VAppTemplate.java index 31f3b16e77..5145754b33 100644 --- a/vcloud/core/src/main/java/org/jclouds/vcloud/domain/VAppTemplate.java +++ b/vcloud/core/src/main/java/org/jclouds/vcloud/domain/VAppTemplate.java @@ -25,7 +25,7 @@ package org.jclouds.vcloud.domain; */ public interface VAppTemplate extends NamedResource { - VAppStatus getStatus(); + Status getStatus(); String getDescription(); 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 8757d0fc4e..97f1497e7e 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 @@ -28,7 +28,7 @@ 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.VAppStatus; +import org.jclouds.vcloud.domain.Status; import org.jclouds.vcloud.domain.VirtualSystem; import com.google.common.collect.ListMultimap; @@ -42,7 +42,7 @@ public class VAppImpl implements VApp { private final String name; private final URI id; private final NamedResource vDC; - private final VAppStatus status; + private final Status status; private final Long size; private final ListMultimap networkToAddresses; private final String operatingSystemDescription; @@ -53,7 +53,7 @@ public class VAppImpl implements VApp { /** The serialVersionUID */ private static final long serialVersionUID = 8464716396538298809L; - public VAppImpl(String name, URI id, VAppStatus status, Long size, NamedResource vDC, + 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"); @@ -69,7 +69,7 @@ public class VAppImpl implements VApp { } @Override - public VAppStatus getStatus() { + public Status getStatus() { return status; } diff --git a/vcloud/core/src/main/java/org/jclouds/vcloud/domain/internal/VAppTemplateImpl.java b/vcloud/core/src/main/java/org/jclouds/vcloud/domain/internal/VAppTemplateImpl.java index b79e252111..b385c35dd6 100644 --- a/vcloud/core/src/main/java/org/jclouds/vcloud/domain/internal/VAppTemplateImpl.java +++ b/vcloud/core/src/main/java/org/jclouds/vcloud/domain/internal/VAppTemplateImpl.java @@ -24,7 +24,7 @@ import java.net.URI; import javax.annotation.Nullable; import org.jclouds.vcloud.VCloudExpressMediaType; -import org.jclouds.vcloud.domain.VAppStatus; +import org.jclouds.vcloud.domain.Status; import org.jclouds.vcloud.domain.VAppTemplate; /** @@ -37,9 +37,9 @@ public class VAppTemplateImpl extends NamedResourceImpl implements VAppTemplate /** The serialVersionUID */ private static final long serialVersionUID = 8464716396538298809L; private final String description; - private final VAppStatus status; + private final Status status; - public VAppTemplateImpl(String name, URI id, @Nullable String description, @Nullable VAppStatus status) { + public VAppTemplateImpl(String name, URI id, @Nullable String description, @Nullable Status status) { super(name, VCloudExpressMediaType.VAPPTEMPLATE_XML, id); this.description = description; this.status = status; @@ -50,7 +50,7 @@ public class VAppTemplateImpl extends NamedResourceImpl implements VAppTemplate return description; } - public VAppStatus getStatus() { + public Status getStatus() { return status; } 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 7c1e5aad0e..e3d08ee1b7 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 @@ -19,11 +19,14 @@ 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; @@ -31,7 +34,7 @@ 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.VAppStatus; +import org.jclouds.vcloud.domain.Status; import org.jclouds.vcloud.domain.VirtualSystem; import org.jclouds.vcloud.domain.internal.VAppImpl; import org.jclouds.vcloud.util.Utils; @@ -46,21 +49,23 @@ import com.google.common.collect.Sets; * @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; @Inject - public VAppHandler(VirtualSystemHandler systemHandler, ResourceAllocationHandler allocationHandler) { + public VAppHandler(@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 VAppStatus status; + protected Status status; protected final ListMultimap networkToAddresses = ArrayListMultimap.create(); protected StringBuilder currentText = new StringBuilder(); protected String operatingSystemDescription; @@ -82,7 +87,11 @@ public class VAppHandler extends ParseSax.HandlerWithResult { NamedResource resource = Utils.newNamedResource(attributes); name = resource.getName(); location = resource.getId(); - status = VAppStatus.fromValue(attributes.getValue(attributes.getIndex("status"))); + 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 diff --git a/vcloud/core/src/main/java/org/jclouds/vcloud/xml/VAppTemplateHandler.java b/vcloud/core/src/main/java/org/jclouds/vcloud/xml/VAppTemplateHandler.java index bbe0d048c0..a5a3a895aa 100644 --- a/vcloud/core/src/main/java/org/jclouds/vcloud/xml/VAppTemplateHandler.java +++ b/vcloud/core/src/main/java/org/jclouds/vcloud/xml/VAppTemplateHandler.java @@ -21,7 +21,7 @@ package org.jclouds.vcloud.xml; import org.jclouds.http.functions.ParseSax; import org.jclouds.vcloud.domain.NamedResource; -import org.jclouds.vcloud.domain.VAppStatus; +import org.jclouds.vcloud.domain.Status; import org.jclouds.vcloud.domain.VAppTemplate; import org.jclouds.vcloud.domain.internal.VAppTemplateImpl; import org.jclouds.vcloud.util.Utils; @@ -36,7 +36,7 @@ public class VAppTemplateHandler extends ParseSax.HandlerWithResult 0; - assert VAppStatus.SUSPENDED.compareTo(VAppStatus.OFF) > 0; - assert VAppStatus.OFF.compareTo(VAppStatus.OFF) == 0; - } - public void testSelf() { InputStream is = getClass().getResourceAsStream("/task-self.xml"); Task result = factory.create(injector.getInstance(TaskHandler.class)).parse(is); Task expects = new TaskImpl(URI.create("https://vcloud.safesecureweb.com/api/v0.8/task/d188849-78"), - TaskStatus.QUEUED, null, null, null, null, null, null); + TaskStatus.QUEUED, null, null, null, null, null, null); assertEquals(result, expects); } @@ -94,12 +88,12 @@ public class TaskHandlerTest extends BaseHandlerTest { Task result = factory.create(injector.getInstance(TaskHandler.class)).parse(is); Task expects = new TaskImpl(URI.create("https://vcloud.safesecureweb.com/api/v0.8/task/97806"), - TaskStatus.SUCCESS, dateService.iso8601SecondsDateParse("2010-01-14T20:04:51Z"), dateService - .iso8601SecondsDateParse("2010-01-14T20:05:02Z"), dateService - .iso8601SecondsDateParse("2010-01-15T20:05:02Z"), + TaskStatus.SUCCESS, dateService.iso8601SecondsDateParse("2010-01-14T20:04:51Z"), dateService + .iso8601SecondsDateParse("2010-01-14T20:05:02Z"), dateService + .iso8601SecondsDateParse("2010-01-15T20:05:02Z"), - new NamedResourceImpl("188849-96", VCloudExpressMediaType.VAPP_XML, URI - .create("https://vcloud.safesecureweb.com/api/v0.8/vapp/188849-96")), null, null); + new NamedResourceImpl("188849-96", VCloudExpressMediaType.VAPP_XML, URI + .create("https://vcloud.safesecureweb.com/api/v0.8/vapp/188849-96")), null, null); assertEquals(result, expects); } @@ -109,12 +103,12 @@ public class TaskHandlerTest extends BaseHandlerTest { Task result = factory.create(injector.getInstance(TaskHandler.class)).parse(is); Task expects = new TaskImpl(URI.create("http://10.150.4.49/api/v0.8/task/23"), TaskStatus.ERROR, dateService - .iso8601SecondsDateParse("2009-12-07T19:05:02Z"), dateService - .iso8601SecondsDateParse("2009-12-10T14:40:32Z"), null, new NamedResourceImpl("APIOrg", - VCloudExpressMediaType.ORG_XML, URI.create("http://10.150.4.49/api/v0.8/org/1")), new NamedResourceImpl( - "testapp1", VCloudExpressMediaType.VAPP_XML, URI.create("http://10.150.4.49/api/v0.8/vapp/1")), - new TaskImpl.ErrorImpl("Error processing job", "500", - " Error in runDailySummaries date used:2009-12-09 19:40:30.577326+00:00")); + .iso8601SecondsDateParse("2009-12-07T19:05:02Z"), dateService + .iso8601SecondsDateParse("2009-12-10T14:40:32Z"), null, new NamedResourceImpl("APIOrg", + VCloudExpressMediaType.ORG_XML, URI.create("http://10.150.4.49/api/v0.8/org/1")), new NamedResourceImpl( + "testapp1", VCloudExpressMediaType.VAPP_XML, URI.create("http://10.150.4.49/api/v0.8/vapp/1")), + new TaskImpl.ErrorImpl("Error processing job", "500", + " Error in runDailySummaries date used:2009-12-09 19:40:30.577326+00:00")); assertEquals(result, expects); } diff --git a/vcloud/core/src/test/java/org/jclouds/vcloud/xml/VAppHandlerTest.java b/vcloud/core/src/test/java/org/jclouds/vcloud/xml/VAppHandlerTest.java index db1181542d..bbaa05717d 100644 --- a/vcloud/core/src/test/java/org/jclouds/vcloud/xml/VAppHandlerTest.java +++ b/vcloud/core/src/test/java/org/jclouds/vcloud/xml/VAppHandlerTest.java @@ -24,22 +24,30 @@ import static org.testng.Assert.assertEquals; import java.io.InputStream; import java.net.URI; import java.net.UnknownHostException; +import java.util.Properties; import java.util.SortedSet; +import org.jclouds.Constants; import org.jclouds.http.functions.BaseHandlerTest; +import org.jclouds.http.functions.ParseSax; +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.VAppStatus; import org.jclouds.vcloud.domain.VirtualSystem; import org.jclouds.vcloud.domain.internal.NamedResourceImpl; import org.jclouds.vcloud.domain.internal.VAppImpl; +import org.testng.annotations.BeforeTest; import org.testng.annotations.Test; import com.google.common.collect.ImmutableListMultimap; import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSortedSet; import com.google.common.collect.ListMultimap; +import com.google.inject.AbstractModule; +import com.google.inject.Guice; +import com.google.inject.name.Names; /** * Tests behavior of {@code VAppHandler} @@ -48,33 +56,20 @@ import com.google.common.collect.ListMultimap; */ @Test(groups = "unit", testName = "vcloud.VAppHandlerTest") public class VAppHandlerTest extends BaseHandlerTest { - @Test(enabled = false) - public void testHosting() throws UnknownHostException { - InputStream is = getClass().getResourceAsStream("/vapp-hosting.xml"); + @BeforeTest + @Override + protected void setUpInjector() { + injector = Guice.createInjector(new SaxParserModule(), new AbstractModule() { - VApp result = factory.create(injector.getInstance(VAppHandler.class)).parse(is); + @Override + protected void configure() { + Properties toBind = new Properties(); + toBind.setProperty(Constants.PROPERTY_API_VERSION, "0.8"); + Names.bindProperties(binder(), toBind); + } - ListMultimap networkToAddresses = ImmutableListMultimap. of("Network 1", - "204.12.11.167"); - - VirtualSystem system = new VirtualSystem(0, "Virtual Hardware Family", "SimpleVM", "vmx-07"); - - SortedSet resourceAllocations = ImmutableSortedSet. naturalOrder().add( - new ResourceAllocation(1, "1 virtual CPU(s)", "Number of Virtual CPUs", ResourceType.PROCESSOR, null, - null, null, null, null, null, 1, "hertz * 10^6"), - new ResourceAllocation(2, "512MB of memory", "Memory Size", ResourceType.MEMORY, null, null, null, null, - null, null, 512, "byte * 2^20")).add( - - new ResourceAllocation(3, "SCSI Controller 0", "SCSI Controller", ResourceType.SCSI_CONTROLLER, - "lsilogic", null, 0, null, null, null, 1, null)).add( - - new ResourceAllocation(9, "Hard Disk 1", null, ResourceType.DISK_DRIVE, null, "20971520", null, 0, 3, - null, 20971520, "byte * 2^20")).build(); - - VApp expects = new VAppImpl("188849-96", URI.create("https://vcloud.safesecureweb.com/api/v0.8/vapp/188849-96"), - VAppStatus.OFF, new Long(20971520), null, networkToAddresses, null, null, system, resourceAllocations); - - assertEquals(result, expects); + }); + factory = injector.getInstance(ParseSax.Factory.class); } public void testInstantiated() throws UnknownHostException { @@ -82,7 +77,7 @@ public class VAppHandlerTest extends BaseHandlerTest { VApp result = factory.create(injector.getInstance(VAppHandler.class)).parse(is); - VApp expects = new VAppImpl("centos53", URI.create("http://10.150.4.49/api/v0.8/vApp/10"), VAppStatus.RESOLVED, + 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()); @@ -110,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"), VAppStatus.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); + 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); assertEquals(result.getId(), expects.getId()); assertEquals(result.getName(), expects.getName()); assertEquals(result.getNetworkToAddresses(), expects.getNetworkToAddresses()); @@ -147,7 +142,7 @@ 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"), VAppStatus.ON, new Long( + 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, "Microsoft Windows XP Professional (32-bit)", system, resourceAllocations); diff --git a/vcloud/core/src/test/java/org/jclouds/vcloud/xml/VAppTemplateHandlerTest.java b/vcloud/core/src/test/java/org/jclouds/vcloud/xml/VAppTemplateHandlerTest.java index c5045151e4..2bc57d1499 100644 --- a/vcloud/core/src/test/java/org/jclouds/vcloud/xml/VAppTemplateHandlerTest.java +++ b/vcloud/core/src/test/java/org/jclouds/vcloud/xml/VAppTemplateHandlerTest.java @@ -27,7 +27,7 @@ import java.net.URI; import org.jclouds.http.functions.ParseSax; import org.jclouds.http.functions.ParseSax.Factory; import org.jclouds.http.functions.config.SaxParserModule; -import org.jclouds.vcloud.domain.VAppStatus; +import org.jclouds.vcloud.domain.Status; import org.jclouds.vcloud.domain.VAppTemplate; import org.jclouds.vcloud.domain.internal.VAppTemplateImpl; import org.testng.annotations.Test; @@ -64,6 +64,6 @@ public class VAppTemplateHandlerTest { VAppTemplate result = (VAppTemplate) factory.create(injector.getInstance(VAppTemplateHandler.class)).parse(is); assertEquals(result, new VAppTemplateImpl("cPanel (Linux) 64 Bit", URI .create("https://vcloud.safesecureweb.com/api/v0.8/catalogItem/4"), "cPanel (Linux) 64 Bit", - VAppStatus.RESOLVED)); + Status.RESOLVED)); } } 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 163f8defc7..ec272129f4 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 @@ -24,6 +24,7 @@ import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkState; import static com.google.common.collect.Iterables.filter; import static com.google.common.collect.Iterables.find; +import static org.jclouds.Constants.PROPERTY_API_VERSION; import static org.jclouds.vcloud.predicates.VCloudPredicates.resourceType; import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_XML_NAMESPACE; import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_XML_SCHEMA; @@ -44,8 +45,8 @@ import org.jclouds.rest.binders.BindToStringPayload; 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.VAppStatus; import org.jclouds.vcloud.terremark.domain.VAppConfiguration; import com.google.common.base.Function; @@ -64,11 +65,14 @@ public class BindVAppConfigurationToXmlPayload implements MapBinder, Function postParams) { checkArgument(checkNotNull(request, "request") instanceof GeneratedHttpRequest, - "this binder is only valid for GeneratedHttpRequests!"); + "this binder is only valid for GeneratedHttpRequests!"); GeneratedHttpRequest gRequest = (GeneratedHttpRequest) request; checkState(gRequest.getArgs() != null, "args should be initialized at this point"); VApp vApp = checkNotNull(findVAppInArgsOrNull(gRequest), "vApp"); - checkArgument(vApp.getStatus() == VAppStatus.OFF, "vApp must be off!"); + checkArgument(vApp.getStatus() == Status.OFF, "vApp must be off!"); VAppConfiguration configuration = checkNotNull(findConfigInArgsOrNull(gRequest), "config"); try { @@ -98,13 +102,13 @@ public class BindVAppConfigurationToXmlPayload implements MapBinder, Function passwordGenerator, Predicate successTester, - Map vAppStatusToNodeState) { + Map vAppStatusToNodeState) { super(client, successTester, vAppStatusToNodeState); this.client = client; this.credentialsProvider = credentialsProvider; @@ -213,7 +213,7 @@ public class TerremarkVCloudComputeClient extends VCloudExpressComputeClientImpl VApp vApp = client.getVApp(id); Set ipAddresses = deleteInternetServicesAndNodesAssociatedWithVApp(vApp); deletePublicIpAddressesWithNoServicesAttached(ipAddresses); - if (vApp.getStatus() != VAppStatus.OFF) { + if (vApp.getStatus() != Status.OFF) { try { powerOffAndWait(vApp); } catch (IllegalStateException e) { 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 18882f444b..cd440a673a 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 @@ -44,7 +44,7 @@ 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.domain.VAppStatus; +import org.jclouds.vcloud.domain.Status; import org.jclouds.vcloud.terremark.compute.domain.KeyPairCredentials; import org.jclouds.vcloud.terremark.compute.domain.OrgAndName; @@ -63,7 +63,7 @@ public class TerremarkVCloudGetNodeMetadataStrategy extends VCloudGetNodeMetadat @Inject protected TerremarkVCloudGetNodeMetadataStrategy(CommonVCloudClient client, CommonVCloudComputeClient computeClient, - Map vAppStatusToNodeState, GetExtra getExtra, + Map vAppStatusToNodeState, GetExtra getExtra, FindLocationForResource findLocationForResourceInVDC, Supplier> images, ConcurrentMap credentialsMap) { super(client, computeClient, vAppStatusToNodeState, getExtra, findLocationForResourceInVDC, images); 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 c35bf9a469..f64c556f33 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 @@ -55,7 +55,7 @@ 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.VAppStatus; +import org.jclouds.vcloud.domain.Status; import org.jclouds.vcloud.domain.VAppTemplate; import org.jclouds.vcloud.domain.VDC; import org.jclouds.vcloud.options.CloneVAppOptions; @@ -176,7 +176,7 @@ public abstract class TerremarkClientLiveTest extends VCloudExpressClientLiveTes // instantiate, noting vApp returned has minimal details vApp = tmClient.instantiateVAppTemplateInVDC(vdc.getId(), vAppTemplate.getId(), serverName, instantiateOptions); - assertEquals(vApp.getStatus(), VAppStatus.RESOLVED); + assertEquals(vApp.getStatus(), Status.RESOLVED); // in terremark, this should be a no-op, as it should simply return the // above task, which is @@ -189,7 +189,7 @@ public abstract class TerremarkClientLiveTest extends VCloudExpressClientLiveTes vApp = tmClient.getVApp(vApp.getId()); - assertEquals(vApp.getStatus(), VAppStatus.RESOLVED); + assertEquals(vApp.getStatus(), Status.RESOLVED); try {// per docs, this is not supported tmClient.cancelTask(deployTask.getLocation()); @@ -208,13 +208,13 @@ public abstract class TerremarkClientLiveTest extends VCloudExpressClientLiveTes int processorCount = 1; long memory = 512; verifyConfigurationOfVApp(vApp, serverName, expectedOs, processorCount, memory, hardDisk); - assertEquals(vApp.getStatus(), VAppStatus.OFF); + assertEquals(vApp.getStatus(), Status.OFF); assert successTester.apply(tmClient.powerOnVApp(vApp.getId()).getLocation()); System.out.printf("%d: done powering on vApp%n", System.currentTimeMillis()); vApp = tmClient.getVApp(vApp.getId()); - assertEquals(vApp.getStatus(), VAppStatus.ON); + assertEquals(vApp.getStatus(), Status.ON); } protected void prepare() { @@ -264,7 +264,7 @@ public abstract class TerremarkClientLiveTest extends VCloudExpressClientLiveTes task = tmClient.getTask(task.getLocation()); clone = tmClient.getVApp(task.getResult().getId()); - assertEquals(clone.getStatus(), VAppStatus.ON); + assertEquals(clone.getStatus(), Status.ON); assertEquals(clone.getName(), newName); assertEquals(clone.getNetworkToAddresses().values().size(), 1); @@ -316,7 +316,7 @@ public abstract class TerremarkClientLiveTest extends VCloudExpressClientLiveTes vApp = tmClient.getVApp(vApp.getId()); - assertEquals(vApp.getStatus(), VAppStatus.ON); + assertEquals(vApp.getStatus(), Status.ON); // TODO we need to determine whether shutdown is supported before invoking // it. @@ -327,7 +327,7 @@ public abstract class TerremarkClientLiveTest extends VCloudExpressClientLiveTes assert successTester.apply(tmClient.powerOffVApp(vApp.getId()).getLocation()); vApp = tmClient.getVApp(vApp.getId()); - assertEquals(vApp.getStatus(), VAppStatus.OFF); + assertEquals(vApp.getStatus(), Status.OFF); } @Test(enabled = true, dependsOnMethods = "testLifeCycle") diff --git a/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/binders/BindVAppConfigurationToXmlPayloadTest.java b/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/binders/BindVAppConfigurationToXmlPayloadTest.java index 77ff6d22ed..9c030fefab 100644 --- a/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/binders/BindVAppConfigurationToXmlPayloadTest.java +++ b/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/binders/BindVAppConfigurationToXmlPayloadTest.java @@ -34,7 +34,7 @@ import org.jclouds.rest.internal.GeneratedHttpRequest; import org.jclouds.util.Utils; import org.jclouds.vcloud.domain.ResourceAllocation; import org.jclouds.vcloud.domain.ResourceType; -import org.jclouds.vcloud.domain.VAppStatus; +import org.jclouds.vcloud.domain.Status; import org.jclouds.vcloud.domain.internal.VAppImpl; import org.jclouds.vcloud.terremark.TerremarkVCloudExpressPropertiesBuilder; import org.jclouds.vcloud.terremark.domain.VAppConfiguration; @@ -66,7 +66,7 @@ public class BindVAppConfigurationToXmlPayloadTest { public void testChangeName() throws IOException { VAppImpl vApp = new VAppImpl("MyAppServer6", URI - .create("https://services.vcloudexpress/terremark.com/api/v0.8/vapp/4213"), VAppStatus.OFF, 4194304l, + .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, null, 2, null), new ResourceAllocation(2, "n/a", null, ResourceType.MEMORY, null, @@ -93,7 +93,7 @@ public class BindVAppConfigurationToXmlPayloadTest { public void testRemoveDisk() throws IOException { VAppImpl vApp = new VAppImpl("MyAppServer6", URI - .create("https://services.vcloudexpress/terremark.com/api/v0.8/vapp/4213"), VAppStatus.OFF, 4194304l, + .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, null, 2, null), new ResourceAllocation(2, "n/a", null, ResourceType.MEMORY, null, @@ -122,7 +122,7 @@ public class BindVAppConfigurationToXmlPayloadTest { public void testChangeCPUCountTo4() throws IOException { VAppImpl vApp = new VAppImpl("eduardo", URI - .create("https://services.vcloudexpress/terremark.com/api/v0.8/vapp/4213"), VAppStatus.OFF, 4194304l, + .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, null, 4, null), new ResourceAllocation(2, "n/a", null, ResourceType.MEMORY, null, @@ -147,7 +147,7 @@ public class BindVAppConfigurationToXmlPayloadTest { public void testChangeMemoryTo1536() throws IOException { VAppImpl vApp = new VAppImpl("MyAppServer6", URI - .create("https://services.vcloudexpress/terremark.com/api/v0.8/vapp/4213"), VAppStatus.OFF, 4194304l, + .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, null, 2, null), new ResourceAllocation(2, "n/a", null, ResourceType.MEMORY, 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 8602cc4857..5f23e4f5ca 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 @@ -35,7 +35,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.VAppStatus; +import org.jclouds.vcloud.domain.Status; import org.jclouds.vcloud.domain.VAppTemplate; import org.jclouds.vcloud.terremark.TerremarkVCloudExpressClient; import org.jclouds.vcloud.terremark.compute.strategy.ParseVAppTemplateDescriptionToGetDefaultLoginCredentials; @@ -89,7 +89,7 @@ public class TerremarkVCloudComputeClientTest { expect(client.powerOnVApp(vappLocation)).andReturn(task); Predicate notFoundTester = createMock(Predicate.class); - Map vAppStatusToNodeState = createMock(Map.class); + Map vAppStatusToNodeState = createMock(Map.class); TerremarkVCloudComputeClient computeClient = new TerremarkVCloudComputeClient(client, new ParseVAppTemplateDescriptionToGetDefaultLoginCredentials(), new Provider() { 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 93b814603c..cbfb98ddaf 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 @@ -28,15 +28,17 @@ import java.io.InputStream; import java.net.URI; import java.net.UnknownHostException; import java.util.List; +import java.util.Properties; +import org.jclouds.Constants; import org.jclouds.http.functions.BaseHandlerTest; import org.jclouds.http.functions.ParseSax; import org.jclouds.http.functions.config.SaxParserModule; 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.VAppStatus; import org.jclouds.vcloud.domain.VirtualSystem; import org.jclouds.vcloud.domain.internal.NamedResourceImpl; import org.jclouds.vcloud.xml.VAppHandler; @@ -46,7 +48,9 @@ import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Lists; +import com.google.inject.AbstractModule; import com.google.inject.Guice; +import com.google.inject.name.Names; /** * Tests behavior of {@code VAppHandler} @@ -59,7 +63,16 @@ public class VAppHandlerTest extends BaseHandlerTest { @BeforeTest @Override protected void setUpInjector() { - injector = Guice.createInjector(new SaxParserModule()); + injector = Guice.createInjector(new SaxParserModule(), new AbstractModule() { + + @Override + protected void configure() { + Properties toBind = new Properties(); + toBind.setProperty(Constants.PROPERTY_API_VERSION, "0.8"); + Names.bindProperties(binder(), toBind); + } + + }); factory = injector.getInstance(ParseSax.Factory.class); } @@ -69,13 +82,13 @@ public class VAppHandlerTest extends BaseHandlerTest { VApp result = (VApp) factory.create(injector.getInstance(VAppHandler.class)).parse(is); assertEquals(result.getName(), "adriantest"); - assertEquals(result.getStatus(), VAppStatus.UNRESOLVED); + assertEquals(result.getStatus(), Status.UNRESOLVED); assertEquals(result.getSize().longValue(), 4l); assertEquals(result.getId(), URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/vapp/13775")); assertEquals(result.getVDC(), new NamedResourceImpl(null, "application/vnd.vmware.vcloud.vdc+xml", URI - .create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/32"))); + .create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/32"))); } @@ -85,36 +98,36 @@ public class VAppHandlerTest extends BaseHandlerTest { VApp result = (VApp) factory.create(injector.getInstance(VAppHandler.class)).parse(is); assertEquals(result.getName(), "centos-53"); - assertEquals(result.getStatus(), VAppStatus.OFF); + assertEquals(result.getStatus(), Status.OFF); assertEquals(result.getSize().longValue(), 10485760); assertEquals(result.getOperatingSystemDescription(), "Red Hat Enterprise Linux 5 (64-bit)"); assertEquals(result.getId(), URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/vapp/16238")); assertEquals(result.getVDC(), new NamedResourceImpl(null, VCloudExpressMediaType.VDC_XML, URI - .create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/32"))); + .create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/32"))); assertEquals(result.getSystem(), new VirtualSystem(0, "Virtual Hardware Family", "centos-53", "vmx-07")); assertEquals(result.getNetworkToAddresses().get("Internal"), ImmutableList. of("10.114.34.132")); ResourceAllocation cpu = new ResourceAllocation(1, "1 virtual CPU(s)", "Number of Virtual CPUs", - ResourceType.PROCESSOR, null, null, null, null, null, null, 1, "hertz * 10^6"); + ResourceType.PROCESSOR, null, null, null, null, null, null, 1, "hertz * 10^6"); ResourceAllocation controller = new ResourceAllocation(3, "SCSI Controller 0", "SCSI Controller", - ResourceType.SCSI_CONTROLLER, "lsilogic", null, 0, null, null, null, 1, null); + ResourceType.SCSI_CONTROLLER, "lsilogic", null, 0, null, null, null, 1, null); ResourceAllocation memory = new ResourceAllocation(2, "512MB of memory", "Memory Size", ResourceType.MEMORY, - null, null, null, null, null, null, 512, "byte * 2^20"); + null, null, null, null, null, null, 512, "byte * 2^20"); ResourceAllocation disk = new ResourceAllocation(9, "Hard Disk 1", null, ResourceType.DISK_DRIVE, null, - "10485760", null, 0, 3, null, 10485760, "byte * 2^20"); + "10485760", null, 0, 3, null, 10485760, "byte * 2^20"); assertEquals(result.getResourceAllocations(), ImmutableSet.of(cpu, memory, controller, disk)); assertEquals(find(result.getResourceAllocations(), resourceType(ResourceType.PROCESSOR)).getVirtualQuantity(), 1); assertEquals(find(result.getResourceAllocations(), resourceType(ResourceType.SCSI_CONTROLLER)) - .getVirtualQuantity(), 1); + .getVirtualQuantity(), 1); assertEquals(find(result.getResourceAllocations(), resourceType(ResourceType.MEMORY)).getVirtualQuantity(), 512); assertEquals(find(result.getResourceAllocations(), resourceType(ResourceType.DISK_DRIVE)).getVirtualQuantity(), - 10485760); + 10485760); assertEquals(result.getSize().longValue(), find(result.getResourceAllocations(), - resourceType(ResourceType.DISK_DRIVE)).getVirtualQuantity()); + resourceType(ResourceType.DISK_DRIVE)).getVirtualQuantity()); } public void testGetVApp2disks() throws UnknownHostException { @@ -123,39 +136,39 @@ public class VAppHandlerTest extends BaseHandlerTest { VApp vApp = factory.create(injector.getInstance(VAppHandler.class)).parse(is); assertEquals(vApp.getName(), "eduardo"); - assertEquals(vApp.getStatus(), VAppStatus.OFF); + assertEquals(vApp.getStatus(), Status.OFF); assertEquals(vApp.getSize().longValue(), 30408704); assertEquals(vApp.getOperatingSystemDescription(), "Ubuntu Linux (32-bit)"); assertEquals(vApp.getId(), URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/vapp/15639")); assertEquals(vApp.getVDC(), new NamedResourceImpl(null, VCloudExpressMediaType.VDC_XML, URI - .create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/32"))); + .create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/32"))); assertEquals(vApp.getSystem(), new VirtualSystem(0, "Virtual Hardware Family", "eduardo", "vmx-07")); assertEquals(vApp.getNetworkToAddresses().get("Internal"), ImmutableList.of("10.114.34.131")); ResourceAllocation cpu = new ResourceAllocation(1, "2 virtual CPU(s)", "Number of Virtual CPUs", - ResourceType.PROCESSOR, null, null, null, null, null, null, 2, "hertz * 10^6"); + ResourceType.PROCESSOR, null, null, null, null, null, null, 2, "hertz * 10^6"); ResourceAllocation controller = new ResourceAllocation(3, "SCSI Controller 0", "SCSI Controller", - ResourceType.SCSI_CONTROLLER, "lsilogic", null, 0, null, null, null, 1, null); + ResourceType.SCSI_CONTROLLER, "lsilogic", null, 0, null, null, null, 1, null); ResourceAllocation memory = new ResourceAllocation(2, "1024MB of memory", "Memory Size", ResourceType.MEMORY, - null, null, null, null, null, null, 1024, "byte * 2^20"); + null, null, null, null, null, null, 1024, "byte * 2^20"); ResourceAllocation disk = new ResourceAllocation(9, "Hard Disk 1", null, ResourceType.DISK_DRIVE, null, - "4194304", null, 0, 3, null, 4194304, "byte * 2^20"); + "4194304", null, 0, 3, null, 4194304, "byte * 2^20"); ResourceAllocation disk2 = new ResourceAllocation(9, "Hard Disk 2", null, ResourceType.DISK_DRIVE, null, - "26214400", null, 1, 3, null, 26214400, "byte * 2^20"); + "26214400", null, 1, 3, null, 26214400, "byte * 2^20"); assertEquals(vApp.getResourceAllocations(), ImmutableSet.of(cpu, memory, controller, disk, disk2)); assertEquals(find(vApp.getResourceAllocations(), resourceType(ResourceType.PROCESSOR)).getVirtualQuantity(), 2); assertEquals( - find(vApp.getResourceAllocations(), resourceType(ResourceType.SCSI_CONTROLLER)).getVirtualQuantity(), 1); + find(vApp.getResourceAllocations(), resourceType(ResourceType.SCSI_CONTROLLER)).getVirtualQuantity(), 1); assertEquals(find(vApp.getResourceAllocations(), resourceType(ResourceType.MEMORY)).getVirtualQuantity(), 1024); // extract the disks on the vApp sorted by addressOnParent List disks = Lists.newArrayList(filter(vApp.getResourceAllocations(), - resourceType(ResourceType.DISK_DRIVE))); + resourceType(ResourceType.DISK_DRIVE))); assertEquals(disks.get(0).getVirtualQuantity(), 4194304); assertEquals(disks.get(1).getVirtualQuantity(), 26214400);