refactored to use new vcloud 1.0 status type

This commit is contained in:
Adrian Cole 2010-08-22 22:45:42 -07:00
parent a87747a6b2
commit 250f2f67cb
31 changed files with 426 additions and 259 deletions

View File

@ -31,7 +31,7 @@ import org.jclouds.domain.Credentials;
import org.jclouds.vcloud.VCloudClient; import org.jclouds.vcloud.VCloudClient;
import org.jclouds.vcloud.compute.internal.VCloudComputeClientImpl; import org.jclouds.vcloud.compute.internal.VCloudComputeClientImpl;
import org.jclouds.vcloud.domain.VApp; 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.VAppTemplate;
import com.google.common.base.Predicate; import com.google.common.base.Predicate;
@ -45,7 +45,7 @@ public class BlueLockVCloudDirectorComputeClient extends VCloudComputeClientImpl
@Inject @Inject
protected BlueLockVCloudDirectorComputeClient(PopulateDefaultLoginCredentialsForImageStrategy credentialsProvider, protected BlueLockVCloudDirectorComputeClient(PopulateDefaultLoginCredentialsForImageStrategy credentialsProvider,
VCloudClient client, Predicate<URI> successTester, Map<VAppStatus, NodeState> vAppStatusToNodeState) { VCloudClient client, Predicate<URI> successTester, Map<Status, NodeState> vAppStatusToNodeState) {
super(client, successTester, vAppStatusToNodeState); super(client, successTester, vAppStatusToNodeState);
this.credentialsProvider = credentialsProvider; this.credentialsProvider = credentialsProvider;
} }

View File

@ -31,7 +31,7 @@ import org.jclouds.domain.Credentials;
import org.jclouds.vcloud.VCloudExpressClient; import org.jclouds.vcloud.VCloudExpressClient;
import org.jclouds.vcloud.compute.internal.VCloudExpressComputeClientImpl; import org.jclouds.vcloud.compute.internal.VCloudExpressComputeClientImpl;
import org.jclouds.vcloud.domain.VApp; 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.VAppTemplate;
import com.google.common.base.Predicate; import com.google.common.base.Predicate;
@ -45,7 +45,7 @@ public class BlueLockVCloudExpressComputeClient extends VCloudExpressComputeClie
@Inject @Inject
protected BlueLockVCloudExpressComputeClient(PopulateDefaultLoginCredentialsForImageStrategy credentialsProvider, protected BlueLockVCloudExpressComputeClient(PopulateDefaultLoginCredentialsForImageStrategy credentialsProvider,
VCloudExpressClient client, Predicate<URI> successTester, Map<VAppStatus, NodeState> vAppStatusToNodeState) { VCloudExpressClient client, Predicate<URI> successTester, Map<Status, NodeState> vAppStatusToNodeState) {
super(client, successTester, vAppStatusToNodeState); super(client, successTester, vAppStatusToNodeState);
this.credentialsProvider = credentialsProvider; this.credentialsProvider = credentialsProvider;
} }

View File

@ -45,7 +45,7 @@ import org.jclouds.vcloud.compute.strategy.VCloudRebootNodeStrategy;
import org.jclouds.vcloud.compute.suppliers.OrgAndVDCToLocationSupplier; import org.jclouds.vcloud.compute.suppliers.OrgAndVDCToLocationSupplier;
import org.jclouds.vcloud.compute.suppliers.StaticSizeSupplier; import org.jclouds.vcloud.compute.suppliers.StaticSizeSupplier;
import org.jclouds.vcloud.compute.suppliers.VCloudImageSupplier; 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.annotations.VisibleForTesting;
import com.google.common.base.Supplier; import com.google.common.base.Supplier;
@ -63,14 +63,17 @@ import com.google.inject.util.Providers;
public abstract class CommonVCloudComputeServiceContextModule extends BaseComputeServiceContextModule { public abstract class CommonVCloudComputeServiceContextModule extends BaseComputeServiceContextModule {
@VisibleForTesting @VisibleForTesting
static final Map<VAppStatus, NodeState> vAppStatusToNodeState = ImmutableMap.<VAppStatus, NodeState> builder().put( static final Map<Status, NodeState> vAppStatusToNodeState = ImmutableMap.<Status, NodeState> builder().put(
VAppStatus.OFF, NodeState.SUSPENDED).put(VAppStatus.ON, NodeState.RUNNING).put(VAppStatus.RESOLVED, Status.OFF, NodeState.SUSPENDED).put(Status.ON, NodeState.RUNNING).put(Status.RESOLVED, NodeState.PENDING)
NodeState.PENDING).put(VAppStatus.SUSPENDED, NodeState.SUSPENDED).put(VAppStatus.UNRESOLVED, .put(Status.ERROR, NodeState.ERROR).put(Status.UNRECOGNIZED, NodeState.UNKNOWN).put(Status.DEPLOYED,
NodeState.PENDING).build(); 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 @Singleton
@Provides @Provides
Map<VAppStatus, NodeState> provideVAppStatusToNodeState() { Map<Status, NodeState> provideVAppStatusToNodeState() {
return vAppStatusToNodeState; return vAppStatusToNodeState;
} }

View File

@ -35,7 +35,7 @@ import org.jclouds.vcloud.CommonVCloudClient;
import org.jclouds.vcloud.compute.CommonVCloudComputeClient; import org.jclouds.vcloud.compute.CommonVCloudComputeClient;
import org.jclouds.vcloud.domain.Task; import org.jclouds.vcloud.domain.Task;
import org.jclouds.vcloud.domain.VApp; 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.VAppTemplate;
import com.google.common.base.Predicate; import com.google.common.base.Predicate;
@ -104,7 +104,7 @@ public class CommonVCloudComputeClientImpl implements CommonVCloudComputeClient
} }
private VApp undeployVAppIfDeployed(VApp vApp) { 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()); logger.debug(">> undeploying vApp(%s), current status: %s", vApp.getName(), vApp.getStatus());
Task task = client.undeployVApp(vApp.getId()); Task task = client.undeployVApp(vApp.getId());
if (!taskTester.apply(task.getLocation())) { if (!taskTester.apply(task.getLocation())) {
@ -117,7 +117,7 @@ public class CommonVCloudComputeClientImpl implements CommonVCloudComputeClient
} }
private VApp powerOffVAppIfDeployed(VApp vApp) { 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()); logger.debug(">> powering off vApp(%s), current status: %s", vApp.getName(), vApp.getStatus());
Task task = client.powerOffVApp(vApp.getId()); Task task = client.powerOffVApp(vApp.getId());
if (!taskTester.apply(task.getLocation())) { if (!taskTester.apply(task.getLocation())) {

View File

@ -32,7 +32,7 @@ import org.jclouds.vcloud.VCloudClient;
import org.jclouds.vcloud.compute.VCloudComputeClient; import org.jclouds.vcloud.compute.VCloudComputeClient;
import org.jclouds.vcloud.domain.Task; import org.jclouds.vcloud.domain.Task;
import org.jclouds.vcloud.domain.VApp; 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.VAppTemplate;
import org.jclouds.vcloud.domain.VDC; import org.jclouds.vcloud.domain.VDC;
import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions; import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions;
@ -46,11 +46,11 @@ import com.google.inject.Inject;
@Singleton @Singleton
public class VCloudComputeClientImpl extends CommonVCloudComputeClientImpl implements VCloudComputeClient { public class VCloudComputeClientImpl extends CommonVCloudComputeClientImpl implements VCloudComputeClient {
protected final Map<VAppStatus, NodeState> vAppStatusToNodeState; protected final Map<Status, NodeState> vAppStatusToNodeState;
@Inject @Inject
public VCloudComputeClientImpl(VCloudClient client, Predicate<URI> successTester, public VCloudComputeClientImpl(VCloudClient client, Predicate<URI> successTester,
Map<VAppStatus, NodeState> vAppStatusToNodeState) { Map<Status, NodeState> vAppStatusToNodeState) {
super(client, successTester); super(client, successTester);
this.vAppStatusToNodeState = vAppStatusToNodeState; this.vAppStatusToNodeState = vAppStatusToNodeState;
} }

View File

@ -32,7 +32,7 @@ import org.jclouds.vcloud.VCloudExpressClient;
import org.jclouds.vcloud.compute.VCloudExpressComputeClient; import org.jclouds.vcloud.compute.VCloudExpressComputeClient;
import org.jclouds.vcloud.domain.Task; import org.jclouds.vcloud.domain.Task;
import org.jclouds.vcloud.domain.VApp; 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.VAppTemplate;
import org.jclouds.vcloud.domain.VDC; import org.jclouds.vcloud.domain.VDC;
import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions; import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions;
@ -46,11 +46,11 @@ import com.google.inject.Inject;
@Singleton @Singleton
public class VCloudExpressComputeClientImpl extends CommonVCloudComputeClientImpl implements VCloudExpressComputeClient { public class VCloudExpressComputeClientImpl extends CommonVCloudComputeClientImpl implements VCloudExpressComputeClient {
protected final Map<VAppStatus, NodeState> vAppStatusToNodeState; protected final Map<Status, NodeState> vAppStatusToNodeState;
@Inject @Inject
public VCloudExpressComputeClientImpl(VCloudExpressClient client, Predicate<URI> successTester, public VCloudExpressComputeClientImpl(VCloudExpressClient client, Predicate<URI> successTester,
Map<VAppStatus, NodeState> vAppStatusToNodeState) { Map<Status, NodeState> vAppStatusToNodeState) {
super(client, successTester); super(client, successTester);
this.vAppStatusToNodeState = vAppStatusToNodeState; this.vAppStatusToNodeState = vAppStatusToNodeState;
} }

View File

@ -38,7 +38,7 @@ import org.jclouds.domain.Credentials;
import org.jclouds.vcloud.VCloudClient; import org.jclouds.vcloud.VCloudClient;
import org.jclouds.vcloud.compute.VCloudComputeClient; import org.jclouds.vcloud.compute.VCloudComputeClient;
import org.jclouds.vcloud.domain.VApp; 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 org.jclouds.vcloud.options.InstantiateVAppTemplateOptions;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
@ -50,11 +50,11 @@ import com.google.common.collect.ImmutableMap;
public class VCloudAddNodeWithTagStrategy implements AddNodeWithTagStrategy { public class VCloudAddNodeWithTagStrategy implements AddNodeWithTagStrategy {
protected final VCloudClient client; protected final VCloudClient client;
protected final VCloudComputeClient computeClient; protected final VCloudComputeClient computeClient;
protected final Map<VAppStatus, NodeState> vAppStatusToNodeState; protected final Map<Status, NodeState> vAppStatusToNodeState;
@Inject @Inject
protected VCloudAddNodeWithTagStrategy(VCloudClient client, VCloudComputeClient computeClient, protected VCloudAddNodeWithTagStrategy(VCloudClient client, VCloudComputeClient computeClient,
Map<VAppStatus, NodeState> vAppStatusToNodeState) { Map<Status, NodeState> vAppStatusToNodeState) {
this.client = client; this.client = client;
this.computeClient = computeClient; this.computeClient = computeClient;
this.vAppStatusToNodeState = vAppStatusToNodeState; this.vAppStatusToNodeState = vAppStatusToNodeState;

View File

@ -38,7 +38,7 @@ import org.jclouds.domain.Credentials;
import org.jclouds.vcloud.VCloudExpressClient; import org.jclouds.vcloud.VCloudExpressClient;
import org.jclouds.vcloud.compute.VCloudExpressComputeClient; import org.jclouds.vcloud.compute.VCloudExpressComputeClient;
import org.jclouds.vcloud.domain.VApp; 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 org.jclouds.vcloud.options.InstantiateVAppTemplateOptions;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
@ -50,11 +50,11 @@ import com.google.common.collect.ImmutableMap;
public class VCloudExpressAddNodeWithTagStrategy implements AddNodeWithTagStrategy { public class VCloudExpressAddNodeWithTagStrategy implements AddNodeWithTagStrategy {
protected final VCloudExpressClient client; protected final VCloudExpressClient client;
protected final VCloudExpressComputeClient computeClient; protected final VCloudExpressComputeClient computeClient;
protected final Map<VAppStatus, NodeState> vAppStatusToNodeState; protected final Map<Status, NodeState> vAppStatusToNodeState;
@Inject @Inject
protected VCloudExpressAddNodeWithTagStrategy(VCloudExpressClient client, VCloudExpressComputeClient computeClient, protected VCloudExpressAddNodeWithTagStrategy(VCloudExpressClient client, VCloudExpressComputeClient computeClient,
Map<VAppStatus, NodeState> vAppStatusToNodeState) { Map<Status, NodeState> vAppStatusToNodeState) {
this.client = client; this.client = client;
this.computeClient = computeClient; this.computeClient = computeClient;
this.vAppStatusToNodeState = vAppStatusToNodeState; this.vAppStatusToNodeState = vAppStatusToNodeState;

View File

@ -45,7 +45,7 @@ import org.jclouds.vcloud.compute.CommonVCloudComputeClient;
import org.jclouds.vcloud.compute.functions.FindLocationForResource; import org.jclouds.vcloud.compute.functions.FindLocationForResource;
import org.jclouds.vcloud.compute.functions.GetExtra; import org.jclouds.vcloud.compute.functions.GetExtra;
import org.jclouds.vcloud.domain.VApp; 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.base.Supplier;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
@ -63,11 +63,11 @@ public class VCloudGetNodeMetadataStrategy implements GetNodeMetadataStrategy {
protected final Supplier<Set<? extends Image>> images; protected final Supplier<Set<? extends Image>> images;
protected final FindLocationForResource findLocationForResourceInVDC; protected final FindLocationForResource findLocationForResourceInVDC;
protected final GetExtra getExtra; protected final GetExtra getExtra;
protected final Map<VAppStatus, NodeState> vAppStatusToNodeState; protected final Map<Status, NodeState> vAppStatusToNodeState;
@Inject @Inject
protected VCloudGetNodeMetadataStrategy(CommonVCloudClient client, CommonVCloudComputeClient computeClient, protected VCloudGetNodeMetadataStrategy(CommonVCloudClient client, CommonVCloudComputeClient computeClient,
Map<VAppStatus, NodeState> vAppStatusToNodeState, GetExtra getExtra, Map<Status, NodeState> vAppStatusToNodeState, GetExtra getExtra,
FindLocationForResource findLocationForResourceInVDC, Supplier<Set<? extends Image>> images) { FindLocationForResource findLocationForResourceInVDC, Supplier<Set<? extends Image>> images) {
this.client = checkNotNull(client, "client"); this.client = checkNotNull(client, "client");
this.images = checkNotNull(images, "images"); this.images = checkNotNull(images, "images");

View File

@ -0,0 +1,225 @@
/**
*
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
*
* ====================================================================
* 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.
*
* <h2>NOTE</h2>
* <p/>
* 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.
* <p/>
* 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);
}
}
}

View File

@ -39,7 +39,7 @@ import com.google.inject.ImplementedBy;
public interface VApp extends NamedResource { public interface VApp extends NamedResource {
NamedResource getVDC(); NamedResource getVDC();
VAppStatus getStatus(); Status getStatus();
Long getSize(); Long getSize();

View File

@ -1,89 +0,0 @@
/**
*
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
*
* ====================================================================
* 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);
}
}
}

View File

@ -25,7 +25,7 @@ package org.jclouds.vcloud.domain;
*/ */
public interface VAppTemplate extends NamedResource { public interface VAppTemplate extends NamedResource {
VAppStatus getStatus(); Status getStatus();
String getDescription(); String getDescription();

View File

@ -28,7 +28,7 @@ import org.jclouds.vcloud.VCloudExpressMediaType;
import org.jclouds.vcloud.domain.NamedResource; import org.jclouds.vcloud.domain.NamedResource;
import org.jclouds.vcloud.domain.ResourceAllocation; import org.jclouds.vcloud.domain.ResourceAllocation;
import org.jclouds.vcloud.domain.VApp; 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.VirtualSystem;
import com.google.common.collect.ListMultimap; import com.google.common.collect.ListMultimap;
@ -42,7 +42,7 @@ public class VAppImpl implements VApp {
private final String name; private final String name;
private final URI id; private final URI id;
private final NamedResource vDC; private final NamedResource vDC;
private final VAppStatus status; private final Status status;
private final Long size; private final Long size;
private final ListMultimap<String, String> networkToAddresses; private final ListMultimap<String, String> networkToAddresses;
private final String operatingSystemDescription; private final String operatingSystemDescription;
@ -53,7 +53,7 @@ public class VAppImpl implements VApp {
/** The serialVersionUID */ /** The serialVersionUID */
private static final long serialVersionUID = 8464716396538298809L; 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<String, String> networkToAddresses, Integer osType, String operatingSystemDescription, ListMultimap<String, String> networkToAddresses, Integer osType, String operatingSystemDescription,
VirtualSystem system, Set<ResourceAllocation> resourceAllocations) { VirtualSystem system, Set<ResourceAllocation> resourceAllocations) {
this.name = checkNotNull(name, "name"); this.name = checkNotNull(name, "name");
@ -69,7 +69,7 @@ public class VAppImpl implements VApp {
} }
@Override @Override
public VAppStatus getStatus() { public Status getStatus() {
return status; return status;
} }

View File

@ -24,7 +24,7 @@ import java.net.URI;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import org.jclouds.vcloud.VCloudExpressMediaType; import org.jclouds.vcloud.VCloudExpressMediaType;
import org.jclouds.vcloud.domain.VAppStatus; import org.jclouds.vcloud.domain.Status;
import org.jclouds.vcloud.domain.VAppTemplate; import org.jclouds.vcloud.domain.VAppTemplate;
/** /**
@ -37,9 +37,9 @@ public class VAppTemplateImpl extends NamedResourceImpl implements VAppTemplate
/** The serialVersionUID */ /** The serialVersionUID */
private static final long serialVersionUID = 8464716396538298809L; private static final long serialVersionUID = 8464716396538298809L;
private final String description; 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); super(name, VCloudExpressMediaType.VAPPTEMPLATE_XML, id);
this.description = description; this.description = description;
this.status = status; this.status = status;
@ -50,7 +50,7 @@ public class VAppTemplateImpl extends NamedResourceImpl implements VAppTemplate
return description; return description;
} }
public VAppStatus getStatus() { public Status getStatus() {
return status; return status;
} }

View File

@ -19,11 +19,14 @@
package org.jclouds.vcloud.xml; package org.jclouds.vcloud.xml;
import static org.jclouds.Constants.PROPERTY_API_VERSION;
import java.net.URI; import java.net.URI;
import java.util.Set; import java.util.Set;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Named;
import org.jclouds.http.functions.ParseSax; import org.jclouds.http.functions.ParseSax;
import org.jclouds.logging.Logger; 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.NamedResource;
import org.jclouds.vcloud.domain.ResourceAllocation; import org.jclouds.vcloud.domain.ResourceAllocation;
import org.jclouds.vcloud.domain.VApp; 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.VirtualSystem;
import org.jclouds.vcloud.domain.internal.VAppImpl; import org.jclouds.vcloud.domain.internal.VAppImpl;
import org.jclouds.vcloud.util.Utils; import org.jclouds.vcloud.util.Utils;
@ -46,21 +49,23 @@ import com.google.common.collect.Sets;
* @author Adrian Cole * @author Adrian Cole
*/ */
public class VAppHandler extends ParseSax.HandlerWithResult<VApp> { public class VAppHandler extends ParseSax.HandlerWithResult<VApp> {
private final String apiVersion;
private final VirtualSystemHandler systemHandler; private final VirtualSystemHandler systemHandler;
private final ResourceAllocationHandler allocationHandler; private final ResourceAllocationHandler allocationHandler;
@Resource @Resource
protected Logger logger = Logger.NULL; protected Logger logger = Logger.NULL;
@Inject @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.systemHandler = systemHandler;
this.allocationHandler = allocationHandler; this.allocationHandler = allocationHandler;
} }
protected VirtualSystem system; protected VirtualSystem system;
protected Set<ResourceAllocation> allocations = Sets.newLinkedHashSet(); protected Set<ResourceAllocation> allocations = Sets.newLinkedHashSet();
protected VAppStatus status; protected Status status;
protected final ListMultimap<String, String> networkToAddresses = ArrayListMultimap.create(); protected final ListMultimap<String, String> networkToAddresses = ArrayListMultimap.create();
protected StringBuilder currentText = new StringBuilder(); protected StringBuilder currentText = new StringBuilder();
protected String operatingSystemDescription; protected String operatingSystemDescription;
@ -82,7 +87,11 @@ public class VAppHandler extends ParseSax.HandlerWithResult<VApp> {
NamedResource resource = Utils.newNamedResource(attributes); NamedResource resource = Utils.newNamedResource(attributes);
name = resource.getName(); name = resource.getName();
location = resource.getId(); 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) if (attributes.getIndex("size") != -1)
size = new Long(attributes.getValue(attributes.getIndex("size"))); size = new Long(attributes.getValue(attributes.getIndex("size")));
} else if (qName.equals("Link")) { // type should never be missing } else if (qName.equals("Link")) { // type should never be missing

View File

@ -21,7 +21,7 @@ package org.jclouds.vcloud.xml;
import org.jclouds.http.functions.ParseSax; import org.jclouds.http.functions.ParseSax;
import org.jclouds.vcloud.domain.NamedResource; 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.VAppTemplate;
import org.jclouds.vcloud.domain.internal.VAppTemplateImpl; import org.jclouds.vcloud.domain.internal.VAppTemplateImpl;
import org.jclouds.vcloud.util.Utils; import org.jclouds.vcloud.util.Utils;
@ -36,7 +36,7 @@ public class VAppTemplateHandler extends ParseSax.HandlerWithResult<VAppTemplate
private NamedResource catalog; private NamedResource catalog;
private String description; private String description;
private VAppStatus status; private Status status;
public VAppTemplate getResult() { public VAppTemplate getResult() {
return new VAppTemplateImpl(catalog.getName(), catalog.getId(), description, status); return new VAppTemplateImpl(catalog.getName(), catalog.getId(), description, status);
@ -47,7 +47,7 @@ public class VAppTemplateHandler extends ParseSax.HandlerWithResult<VAppTemplate
if (qName.equals("VAppTemplate")) { if (qName.equals("VAppTemplate")) {
catalog = Utils.newNamedResource(attributes); catalog = Utils.newNamedResource(attributes);
if (attributes.getIndex("status") != -1) if (attributes.getIndex("status") != -1)
status = VAppStatus.fromValue(attributes.getValue(attributes.getIndex("status"))); status = Status.fromValue(attributes.getValue(attributes.getIndex("status")));
} }
} }

View File

@ -40,7 +40,7 @@ import org.jclouds.rest.RestContextFactory;
import org.jclouds.vcloud.VCloudClient; import org.jclouds.vcloud.VCloudClient;
import org.jclouds.vcloud.domain.ResourceType; import org.jclouds.vcloud.domain.ResourceType;
import org.jclouds.vcloud.domain.VApp; 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.VAppTemplate;
import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions; import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions;
import org.testng.annotations.AfterTest; import org.testng.annotations.AfterTest;
@ -105,7 +105,7 @@ public class VCloudComputeClientLiveTest {
VApp vApp = client.getVApp(id); VApp vApp = client.getVApp(id);
verifyConfigurationOfVApp(vApp, serverName, expectation.os, processorCount, memory, expectation.hardDisk); verifyConfigurationOfVApp(vApp, serverName, expectation.os, processorCount, memory, expectation.hardDisk);
assertEquals(vApp.getStatus(), VAppStatus.ON); assertEquals(vApp.getStatus(), Status.ON);
} }
private String getCompatibleServerName(OsFamily toTest) { private String getCompatibleServerName(OsFamily toTest) {

View File

@ -37,7 +37,7 @@ import org.jclouds.rest.RestContextFactory;
import org.jclouds.vcloud.VCloudExpressClient; import org.jclouds.vcloud.VCloudExpressClient;
import org.jclouds.vcloud.domain.ResourceType; import org.jclouds.vcloud.domain.ResourceType;
import org.jclouds.vcloud.domain.VApp; 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.VAppTemplate;
import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions; import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions;
import org.testng.annotations.AfterTest; import org.testng.annotations.AfterTest;
@ -102,7 +102,7 @@ public class VCloudExpressComputeClientLiveTest {
VApp vApp = client.getVApp(id); VApp vApp = client.getVApp(id);
verifyConfigurationOfVApp(vApp, serverName, expectation.os, processorCount, memory, expectation.hardDisk); verifyConfigurationOfVApp(vApp, serverName, expectation.os, processorCount, memory, expectation.hardDisk);
assertEquals(vApp.getStatus(), VAppStatus.ON); assertEquals(vApp.getStatus(), Status.ON);
} }
private String getCompatibleServerName(OsFamily toTest) { private String getCompatibleServerName(OsFamily toTest) {

View File

@ -19,7 +19,9 @@
package org.jclouds.vcloud.compute.config; package org.jclouds.vcloud.compute.config;
import org.jclouds.vcloud.domain.VAppStatus; import java.util.EnumSet;
import org.jclouds.vcloud.domain.Status;
import org.testng.annotations.Test; import org.testng.annotations.Test;
/** /**
@ -28,10 +30,13 @@ import org.testng.annotations.Test;
@Test(groups = "unit", testName = "vcloud.VCloudComputeServiceContextModuleTest") @Test(groups = "unit", testName = "vcloud.VCloudComputeServiceContextModuleTest")
public class VCloudComputeServiceContextModuleTest { public class VCloudComputeServiceContextModuleTest {
@SuppressWarnings("static-access")
public void testAllStatusCovered() { public void testAllStatusCovered() {
for (VAppStatus state : VAppStatus.values()) { for (Status state : EnumSet.allOf(Status.class).complementOf(
assert VCloudComputeServiceContextModule.vAppStatusToNodeState.containsKey(state) : state; EnumSet.of(Status.PENDING_DESCRIPTOR, Status.PENDING_CONTENTS, Status.COPYING, Status.QUARANTINED,
Status.QUARANTINE_EXPIRED))) {
assert VCloudExpressComputeServiceContextModule.vAppStatusToNodeState.containsKey(state) : state;
} }
} }

View File

@ -19,7 +19,9 @@
package org.jclouds.vcloud.compute.config; package org.jclouds.vcloud.compute.config;
import org.jclouds.vcloud.domain.VAppStatus; import java.util.EnumSet;
import org.jclouds.vcloud.domain.Status;
import org.testng.annotations.Test; import org.testng.annotations.Test;
/** /**
@ -28,9 +30,12 @@ import org.testng.annotations.Test;
@Test(groups = "unit", testName = "vcloud.VCloudExpressComputeServiceContextModuleTest") @Test(groups = "unit", testName = "vcloud.VCloudExpressComputeServiceContextModuleTest")
public class VCloudExpressComputeServiceContextModuleTest { public class VCloudExpressComputeServiceContextModuleTest {
@SuppressWarnings("static-access")
public void testAllStatusCovered() { public void testAllStatusCovered() {
for (VAppStatus state : VAppStatus.values()) { for (Status state : EnumSet.allOf(Status.class).complementOf(
EnumSet.of(Status.PENDING_DESCRIPTOR, Status.PENDING_CONTENTS, Status.COPYING, Status.QUARANTINED,
Status.QUARANTINE_EXPIRED))) {
assert VCloudExpressComputeServiceContextModule.vAppStatusToNodeState.containsKey(state) : state; assert VCloudExpressComputeServiceContextModule.vAppStatusToNodeState.containsKey(state) : state;
} }

View File

@ -29,7 +29,6 @@ import org.jclouds.http.functions.BaseHandlerTest;
import org.jclouds.vcloud.VCloudExpressMediaType; import org.jclouds.vcloud.VCloudExpressMediaType;
import org.jclouds.vcloud.domain.Task; import org.jclouds.vcloud.domain.Task;
import org.jclouds.vcloud.domain.TaskStatus; import org.jclouds.vcloud.domain.TaskStatus;
import org.jclouds.vcloud.domain.VAppStatus;
import org.jclouds.vcloud.domain.internal.NamedResourceImpl; import org.jclouds.vcloud.domain.internal.NamedResourceImpl;
import org.jclouds.vcloud.domain.internal.TaskImpl; import org.jclouds.vcloud.domain.internal.TaskImpl;
import org.testng.annotations.BeforeTest; import org.testng.annotations.BeforeTest;
@ -58,32 +57,27 @@ public class TaskHandlerTest extends BaseHandlerTest {
Task result = factory.create(injector.getInstance(TaskHandler.class)).parse(is); Task result = factory.create(injector.getInstance(TaskHandler.class)).parse(is);
Task expects = new TaskImpl(URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/task/3299"), Task expects = new TaskImpl(URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/task/3299"),
TaskStatus.SUCCESS, dateService.iso8601DateParse("2009-08-24T21:29:32.983Z"), dateService TaskStatus.SUCCESS, dateService.iso8601DateParse("2009-08-24T21:29:32.983Z"), dateService
.iso8601DateParse("2009-08-24T21:29:44.65Z"), null, new NamedResourceImpl("VDC Name", .iso8601DateParse("2009-08-24T21:29:44.65Z"), null, new NamedResourceImpl("VDC Name",
VCloudExpressMediaType.VDC_XML, URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/1")), VCloudExpressMediaType.VDC_XML, URI
new NamedResourceImpl("Server1", VCloudExpressMediaType.VAPP_XML, URI .create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/1")),
.create("https://services.vcloudexpress.terremark.com/api/v0.8/vapp/4012") new NamedResourceImpl("Server1", VCloudExpressMediaType.VAPP_XML, URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/vapp/4012")
), null ), null
); );
assertEquals(result, expects); assertEquals(result, expects);
} }
public void testStates() {
assert VAppStatus.ON.compareTo(VAppStatus.OFF) > 0;
assert VAppStatus.SUSPENDED.compareTo(VAppStatus.OFF) > 0;
assert VAppStatus.OFF.compareTo(VAppStatus.OFF) == 0;
}
public void testSelf() { public void testSelf() {
InputStream is = getClass().getResourceAsStream("/task-self.xml"); InputStream is = getClass().getResourceAsStream("/task-self.xml");
Task result = factory.create(injector.getInstance(TaskHandler.class)).parse(is); 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"), 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); assertEquals(result, expects);
} }
@ -94,12 +88,12 @@ public class TaskHandlerTest extends BaseHandlerTest {
Task result = factory.create(injector.getInstance(TaskHandler.class)).parse(is); 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"), 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 TaskStatus.SUCCESS, dateService.iso8601SecondsDateParse("2010-01-14T20:04:51Z"), dateService
.iso8601SecondsDateParse("2010-01-14T20:05:02Z"), dateService .iso8601SecondsDateParse("2010-01-14T20:05:02Z"), dateService
.iso8601SecondsDateParse("2010-01-15T20:05:02Z"), .iso8601SecondsDateParse("2010-01-15T20:05:02Z"),
new NamedResourceImpl("188849-96", VCloudExpressMediaType.VAPP_XML, URI new NamedResourceImpl("188849-96", VCloudExpressMediaType.VAPP_XML, URI
.create("https://vcloud.safesecureweb.com/api/v0.8/vapp/188849-96")), null, null); .create("https://vcloud.safesecureweb.com/api/v0.8/vapp/188849-96")), null, null);
assertEquals(result, expects); assertEquals(result, expects);
} }
@ -109,12 +103,12 @@ public class TaskHandlerTest extends BaseHandlerTest {
Task result = factory.create(injector.getInstance(TaskHandler.class)).parse(is); 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 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-07T19:05:02Z"), dateService
.iso8601SecondsDateParse("2009-12-10T14:40:32Z"), null, new NamedResourceImpl("APIOrg", .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( 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")), "testapp1", VCloudExpressMediaType.VAPP_XML, URI.create("http://10.150.4.49/api/v0.8/vapp/1")),
new TaskImpl.ErrorImpl("Error processing job", "500", new TaskImpl.ErrorImpl("Error processing job", "500",
" Error in runDailySummaries date used:2009-12-09 19:40:30.577326+00:00")); " Error in runDailySummaries date used:2009-12-09 19:40:30.577326+00:00"));
assertEquals(result, expects); assertEquals(result, expects);
} }

View File

@ -24,22 +24,30 @@ import static org.testng.Assert.assertEquals;
import java.io.InputStream; import java.io.InputStream;
import java.net.URI; import java.net.URI;
import java.net.UnknownHostException; import java.net.UnknownHostException;
import java.util.Properties;
import java.util.SortedSet; import java.util.SortedSet;
import org.jclouds.Constants;
import org.jclouds.http.functions.BaseHandlerTest; 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.ResourceAllocation;
import org.jclouds.vcloud.domain.ResourceType; import org.jclouds.vcloud.domain.ResourceType;
import org.jclouds.vcloud.domain.Status;
import org.jclouds.vcloud.domain.VApp; import org.jclouds.vcloud.domain.VApp;
import org.jclouds.vcloud.domain.VAppStatus;
import org.jclouds.vcloud.domain.VirtualSystem; import org.jclouds.vcloud.domain.VirtualSystem;
import org.jclouds.vcloud.domain.internal.NamedResourceImpl; import org.jclouds.vcloud.domain.internal.NamedResourceImpl;
import org.jclouds.vcloud.domain.internal.VAppImpl; import org.jclouds.vcloud.domain.internal.VAppImpl;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import com.google.common.collect.ImmutableListMultimap; import com.google.common.collect.ImmutableListMultimap;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.google.common.collect.ImmutableSortedSet; import com.google.common.collect.ImmutableSortedSet;
import com.google.common.collect.ListMultimap; 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} * Tests behavior of {@code VAppHandler}
@ -48,33 +56,20 @@ import com.google.common.collect.ListMultimap;
*/ */
@Test(groups = "unit", testName = "vcloud.VAppHandlerTest") @Test(groups = "unit", testName = "vcloud.VAppHandlerTest")
public class VAppHandlerTest extends BaseHandlerTest { public class VAppHandlerTest extends BaseHandlerTest {
@Test(enabled = false) @BeforeTest
public void testHosting() throws UnknownHostException { @Override
InputStream is = getClass().getResourceAsStream("/vapp-hosting.xml"); 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<String, String> networkToAddresses = ImmutableListMultimap.<String, String> of("Network 1", });
"204.12.11.167"); factory = injector.getInstance(ParseSax.Factory.class);
VirtualSystem system = new VirtualSystem(0, "Virtual Hardware Family", "SimpleVM", "vmx-07");
SortedSet<ResourceAllocation> resourceAllocations = ImmutableSortedSet.<ResourceAllocation> 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);
} }
public void testInstantiated() throws UnknownHostException { 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 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 123456789l, new NamedResourceImpl(null, "application/vnd.vmware.vcloud.vdc+xml", URI
.create("http://10.150.4.49/api/v0.8/vdc/4")), ImmutableListMultimap.<String, String> of(), .create("http://10.150.4.49/api/v0.8/vdc/4")), ImmutableListMultimap.<String, String> of(),
null, null, null, ImmutableSet.<ResourceAllocation> of()); null, null, null, ImmutableSet.<ResourceAllocation> 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, new ResourceAllocation(9, "Hard Disk 1", null, ResourceType.DISK_DRIVE, null, "104857", null, 0, 3,
null, 104857, "byte * 2^20")).build(); 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, VApp expects = new VAppImpl("centos53", URI.create("http://10.150.4.49/api/v0.8/vApp/10"), Status.ON, new Long(
new Long(104857), new NamedResourceImpl(null, "application/vnd.vmware.vcloud.vdc+xml", URI 104857), new NamedResourceImpl(null, "application/vnd.vmware.vcloud.vdc+xml", URI
.create("http://10.150.4.49/api/v0.8/vdc/4")), networkToAddresses, null, .create("http://10.150.4.49/api/v0.8/vdc/4")), networkToAddresses, null, "Other Linux (32-bit)", system,
"Other Linux (32-bit)", system, resourceAllocations); resourceAllocations);
assertEquals(result.getId(), expects.getId()); assertEquals(result.getId(), expects.getId());
assertEquals(result.getName(), expects.getName()); assertEquals(result.getName(), expects.getName());
assertEquals(result.getNetworkToAddresses(), expects.getNetworkToAddresses()); 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, new ResourceAllocation(9, "Hard Disk 1", null, ResourceType.DISK_DRIVE, null, "10485760", null, 0, 3,
null, 10485760, "byte * 2^20")).build(); 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 10485760), new NamedResourceImpl(null, "application/vnd.vmware.vcloud.vdc+xml", URI
.create("http://localhost:8000/api/v0.8/vdc/28")), networkToAddresses, null, .create("http://localhost:8000/api/v0.8/vdc/28")), networkToAddresses, null,
"Microsoft Windows XP Professional (32-bit)", system, resourceAllocations); "Microsoft Windows XP Professional (32-bit)", system, resourceAllocations);

View File

@ -27,7 +27,7 @@ import java.net.URI;
import org.jclouds.http.functions.ParseSax; import org.jclouds.http.functions.ParseSax;
import org.jclouds.http.functions.ParseSax.Factory; import org.jclouds.http.functions.ParseSax.Factory;
import org.jclouds.http.functions.config.SaxParserModule; 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.VAppTemplate;
import org.jclouds.vcloud.domain.internal.VAppTemplateImpl; import org.jclouds.vcloud.domain.internal.VAppTemplateImpl;
import org.testng.annotations.Test; import org.testng.annotations.Test;
@ -64,6 +64,6 @@ public class VAppTemplateHandlerTest {
VAppTemplate result = (VAppTemplate) factory.create(injector.getInstance(VAppTemplateHandler.class)).parse(is); VAppTemplate result = (VAppTemplate) factory.create(injector.getInstance(VAppTemplateHandler.class)).parse(is);
assertEquals(result, new VAppTemplateImpl("cPanel (Linux) 64 Bit", URI assertEquals(result, new VAppTemplateImpl("cPanel (Linux) 64 Bit", URI
.create("https://vcloud.safesecureweb.com/api/v0.8/catalogItem/4"), "cPanel (Linux) 64 Bit", .create("https://vcloud.safesecureweb.com/api/v0.8/catalogItem/4"), "cPanel (Linux) 64 Bit",
VAppStatus.RESOLVED)); Status.RESOLVED));
} }
} }

View File

@ -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.base.Preconditions.checkState;
import static com.google.common.collect.Iterables.filter; import static com.google.common.collect.Iterables.filter;
import static com.google.common.collect.Iterables.find; 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.predicates.VCloudPredicates.resourceType;
import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_XML_NAMESPACE; import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_XML_NAMESPACE;
import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_XML_SCHEMA; 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.rest.internal.GeneratedHttpRequest;
import org.jclouds.vcloud.domain.ResourceAllocation; import org.jclouds.vcloud.domain.ResourceAllocation;
import org.jclouds.vcloud.domain.ResourceType; import org.jclouds.vcloud.domain.ResourceType;
import org.jclouds.vcloud.domain.Status;
import org.jclouds.vcloud.domain.VApp; import org.jclouds.vcloud.domain.VApp;
import org.jclouds.vcloud.domain.VAppStatus;
import org.jclouds.vcloud.terremark.domain.VAppConfiguration; import org.jclouds.vcloud.terremark.domain.VAppConfiguration;
import com.google.common.base.Function; import com.google.common.base.Function;
@ -64,11 +65,14 @@ public class BindVAppConfigurationToXmlPayload implements MapBinder, Function<Ob
protected final String ns; protected final String ns;
protected final String schema; protected final String schema;
private final BindToStringPayload stringBinder; protected final BindToStringPayload stringBinder;
protected final String apiVersion;
@Inject @Inject
public BindVAppConfigurationToXmlPayload(BindToStringPayload stringBinder, public BindVAppConfigurationToXmlPayload(@Named(PROPERTY_API_VERSION) String apiVersion,
@Named(PROPERTY_VCLOUD_XML_NAMESPACE) String ns, @Named(PROPERTY_VCLOUD_XML_SCHEMA) String schema) { BindToStringPayload stringBinder, @Named(PROPERTY_VCLOUD_XML_NAMESPACE) String ns,
@Named(PROPERTY_VCLOUD_XML_SCHEMA) String schema) {
this.apiVersion = apiVersion;
this.ns = ns; this.ns = ns;
this.schema = schema; this.schema = schema;
this.stringBinder = stringBinder; this.stringBinder = stringBinder;
@ -77,12 +81,12 @@ public class BindVAppConfigurationToXmlPayload implements MapBinder, Function<Ob
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public void bindToRequest(HttpRequest request, Map<String, String> postParams) { public void bindToRequest(HttpRequest request, Map<String, String> postParams) {
checkArgument(checkNotNull(request, "request") instanceof GeneratedHttpRequest, checkArgument(checkNotNull(request, "request") instanceof GeneratedHttpRequest,
"this binder is only valid for GeneratedHttpRequests!"); "this binder is only valid for GeneratedHttpRequests!");
GeneratedHttpRequest gRequest = (GeneratedHttpRequest) request; GeneratedHttpRequest gRequest = (GeneratedHttpRequest) request;
checkState(gRequest.getArgs() != null, "args should be initialized at this point"); checkState(gRequest.getArgs() != null, "args should be initialized at this point");
VApp vApp = checkNotNull(findVAppInArgsOrNull(gRequest), "vApp"); 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"); VAppConfiguration configuration = checkNotNull(findConfigInArgsOrNull(gRequest), "config");
try { try {
@ -98,13 +102,13 @@ public class BindVAppConfigurationToXmlPayload implements MapBinder, Function<Ob
} }
protected String generateXml(VApp vApp, VAppConfiguration configuration) throws ParserConfigurationException, protected String generateXml(VApp vApp, VAppConfiguration configuration) throws ParserConfigurationException,
FactoryConfigurationError, TransformerException { FactoryConfigurationError, TransformerException {
String name = configuration.getName() != null ? configuration.getName() : vApp.getName(); String name = configuration.getName() != null ? configuration.getName() : vApp.getName();
XMLBuilder rootBuilder = buildRoot(vApp, name); XMLBuilder rootBuilder = buildRoot(vApp, name);
XMLBuilder sectionBuilder = rootBuilder.e("Section").a("xsi:type", "VirtualHardwareSection_Type").a("xmlns", XMLBuilder sectionBuilder = rootBuilder.e("Section").a("xsi:type", "VirtualHardwareSection_Type").a("xmlns",
"http://schemas.dmtf.org/ovf/envelope/1").a("xmlns:q2", "http://www.vmware.com/vcloud/v1"); "http://schemas.dmtf.org/ovf/envelope/1").a("xmlns:q2", "http://www.vmware.com/vcloud/v1");
sectionBuilder.e("Info").t("Virtual Hardware"); sectionBuilder.e("Info").t("Virtual Hardware");
addProcessorItem(sectionBuilder, vApp, configuration); addProcessorItem(sectionBuilder, vApp, configuration);
@ -119,7 +123,7 @@ public class BindVAppConfigurationToXmlPayload implements MapBinder, Function<Ob
private void addProcessorItem(XMLBuilder sectionBuilder, VApp vApp, VAppConfiguration configuration) { private void addProcessorItem(XMLBuilder sectionBuilder, VApp vApp, VAppConfiguration configuration) {
ResourceAllocation cpu = find(vApp.getResourceAllocations(), resourceType(ResourceType.PROCESSOR)); ResourceAllocation cpu = find(vApp.getResourceAllocations(), resourceType(ResourceType.PROCESSOR));
long quantity = configuration.getProcessorCount() != null ? configuration.getProcessorCount() : cpu long quantity = configuration.getProcessorCount() != null ? configuration.getProcessorCount() : cpu
.getVirtualQuantity(); .getVirtualQuantity();
addResourceWithQuantity(sectionBuilder, cpu, quantity); addResourceWithQuantity(sectionBuilder, cpu, quantity);
} }
@ -136,7 +140,7 @@ public class BindVAppConfigurationToXmlPayload implements MapBinder, Function<Ob
} }
for (Long quantity : configuration.getDisks()) { for (Long quantity : configuration.getDisks()) {
ResourceAllocation disk = new ResourceAllocation(9, "n/a", null, ResourceType.DISK_DRIVE, null, "1048576", ResourceAllocation disk = new ResourceAllocation(9, "n/a", null, ResourceType.DISK_DRIVE, null, "1048576",
null, -1, null, null, quantity, null); null, -1, null, null, quantity, null);
addDiskWithQuantity(sectionBuilder, disk); addDiskWithQuantity(sectionBuilder, disk);
} }
} }
@ -162,10 +166,13 @@ public class BindVAppConfigurationToXmlPayload implements MapBinder, Function<Ob
} }
protected XMLBuilder buildRoot(VApp vApp, String name) throws ParserConfigurationException, protected XMLBuilder buildRoot(VApp vApp, String name) throws ParserConfigurationException,
FactoryConfigurationError { FactoryConfigurationError {
XMLBuilder rootBuilder = XMLBuilder.create("VApp").a("type", vApp.getType()).a("name", name).a("status", String status = vApp.getStatus().value();
vApp.getStatus().value()).a("size", vApp.getSize() + "").a("xmlns", ns).a("xmlns:xsi", if (apiVersion.indexOf("0.8") != -1 && "8".equals(status))
"http://www.w3.org/2001/XMLSchema-instance").a("xsi:schemaLocation", ns + " " + schema); status = "2";
XMLBuilder rootBuilder = XMLBuilder.create("VApp").a("type", vApp.getType()).a("name", name).a("status", status)
.a("size", vApp.getSize() + "").a("xmlns", ns).a("xmlns:xsi",
"http://www.w3.org/2001/XMLSchema-instance").a("xsi:schemaLocation", ns + " " + schema);
return rootBuilder; return rootBuilder;
} }

View File

@ -43,7 +43,7 @@ import org.jclouds.vcloud.domain.Task;
import org.jclouds.vcloud.domain.TaskStatus; import org.jclouds.vcloud.domain.TaskStatus;
import org.jclouds.vcloud.domain.TasksList; import org.jclouds.vcloud.domain.TasksList;
import org.jclouds.vcloud.domain.VApp; 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.VAppTemplate;
import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions; import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions;
import org.jclouds.vcloud.terremark.TerremarkECloudClient; import org.jclouds.vcloud.terremark.TerremarkECloudClient;
@ -71,7 +71,7 @@ public class TerremarkVCloudComputeClient extends VCloudExpressComputeClientImpl
protected TerremarkVCloudComputeClient(TerremarkVCloudExpressClient client, protected TerremarkVCloudComputeClient(TerremarkVCloudExpressClient client,
PopulateDefaultLoginCredentialsForImageStrategy credentialsProvider, PopulateDefaultLoginCredentialsForImageStrategy credentialsProvider,
@Named("PASSWORD") Provider<String> passwordGenerator, Predicate<URI> successTester, @Named("PASSWORD") Provider<String> passwordGenerator, Predicate<URI> successTester,
Map<VAppStatus, NodeState> vAppStatusToNodeState) { Map<Status, NodeState> vAppStatusToNodeState) {
super(client, successTester, vAppStatusToNodeState); super(client, successTester, vAppStatusToNodeState);
this.client = client; this.client = client;
this.credentialsProvider = credentialsProvider; this.credentialsProvider = credentialsProvider;
@ -213,7 +213,7 @@ public class TerremarkVCloudComputeClient extends VCloudExpressComputeClientImpl
VApp vApp = client.getVApp(id); VApp vApp = client.getVApp(id);
Set<PublicIpAddress> ipAddresses = deleteInternetServicesAndNodesAssociatedWithVApp(vApp); Set<PublicIpAddress> ipAddresses = deleteInternetServicesAndNodesAssociatedWithVApp(vApp);
deletePublicIpAddressesWithNoServicesAttached(ipAddresses); deletePublicIpAddressesWithNoServicesAttached(ipAddresses);
if (vApp.getStatus() != VAppStatus.OFF) { if (vApp.getStatus() != Status.OFF) {
try { try {
powerOffAndWait(vApp); powerOffAndWait(vApp);
} catch (IllegalStateException e) { } catch (IllegalStateException e) {

View File

@ -44,7 +44,7 @@ import org.jclouds.vcloud.compute.domain.VCloudLocation;
import org.jclouds.vcloud.compute.functions.FindLocationForResource; import org.jclouds.vcloud.compute.functions.FindLocationForResource;
import org.jclouds.vcloud.compute.functions.GetExtra; import org.jclouds.vcloud.compute.functions.GetExtra;
import org.jclouds.vcloud.compute.strategy.VCloudGetNodeMetadataStrategy; 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.KeyPairCredentials;
import org.jclouds.vcloud.terremark.compute.domain.OrgAndName; import org.jclouds.vcloud.terremark.compute.domain.OrgAndName;
@ -63,7 +63,7 @@ public class TerremarkVCloudGetNodeMetadataStrategy extends VCloudGetNodeMetadat
@Inject @Inject
protected TerremarkVCloudGetNodeMetadataStrategy(CommonVCloudClient client, CommonVCloudComputeClient computeClient, protected TerremarkVCloudGetNodeMetadataStrategy(CommonVCloudClient client, CommonVCloudComputeClient computeClient,
Map<VAppStatus, NodeState> vAppStatusToNodeState, GetExtra getExtra, Map<Status, NodeState> vAppStatusToNodeState, GetExtra getExtra,
FindLocationForResource findLocationForResourceInVDC, Supplier<Set<? extends Image>> images, FindLocationForResource findLocationForResourceInVDC, Supplier<Set<? extends Image>> images,
ConcurrentMap<OrgAndName, KeyPairCredentials> credentialsMap) { ConcurrentMap<OrgAndName, KeyPairCredentials> credentialsMap) {
super(client, computeClient, vAppStatusToNodeState, getExtra, findLocationForResourceInVDC, images); super(client, computeClient, vAppStatusToNodeState, getExtra, findLocationForResourceInVDC, images);

View File

@ -55,7 +55,7 @@ import org.jclouds.vcloud.domain.ResourceAllocation;
import org.jclouds.vcloud.domain.ResourceType; import org.jclouds.vcloud.domain.ResourceType;
import org.jclouds.vcloud.domain.Task; import org.jclouds.vcloud.domain.Task;
import org.jclouds.vcloud.domain.VApp; 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.VAppTemplate;
import org.jclouds.vcloud.domain.VDC; import org.jclouds.vcloud.domain.VDC;
import org.jclouds.vcloud.options.CloneVAppOptions; import org.jclouds.vcloud.options.CloneVAppOptions;
@ -176,7 +176,7 @@ public abstract class TerremarkClientLiveTest extends VCloudExpressClientLiveTes
// instantiate, noting vApp returned has minimal details // instantiate, noting vApp returned has minimal details
vApp = tmClient.instantiateVAppTemplateInVDC(vdc.getId(), vAppTemplate.getId(), serverName, instantiateOptions); 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 // in terremark, this should be a no-op, as it should simply return the
// above task, which is // above task, which is
@ -189,7 +189,7 @@ public abstract class TerremarkClientLiveTest extends VCloudExpressClientLiveTes
vApp = tmClient.getVApp(vApp.getId()); vApp = tmClient.getVApp(vApp.getId());
assertEquals(vApp.getStatus(), VAppStatus.RESOLVED); assertEquals(vApp.getStatus(), Status.RESOLVED);
try {// per docs, this is not supported try {// per docs, this is not supported
tmClient.cancelTask(deployTask.getLocation()); tmClient.cancelTask(deployTask.getLocation());
@ -208,13 +208,13 @@ public abstract class TerremarkClientLiveTest extends VCloudExpressClientLiveTes
int processorCount = 1; int processorCount = 1;
long memory = 512; long memory = 512;
verifyConfigurationOfVApp(vApp, serverName, expectedOs, processorCount, memory, hardDisk); 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()); assert successTester.apply(tmClient.powerOnVApp(vApp.getId()).getLocation());
System.out.printf("%d: done powering on vApp%n", System.currentTimeMillis()); System.out.printf("%d: done powering on vApp%n", System.currentTimeMillis());
vApp = tmClient.getVApp(vApp.getId()); vApp = tmClient.getVApp(vApp.getId());
assertEquals(vApp.getStatus(), VAppStatus.ON); assertEquals(vApp.getStatus(), Status.ON);
} }
protected void prepare() { protected void prepare() {
@ -264,7 +264,7 @@ public abstract class TerremarkClientLiveTest extends VCloudExpressClientLiveTes
task = tmClient.getTask(task.getLocation()); task = tmClient.getTask(task.getLocation());
clone = tmClient.getVApp(task.getResult().getId()); clone = tmClient.getVApp(task.getResult().getId());
assertEquals(clone.getStatus(), VAppStatus.ON); assertEquals(clone.getStatus(), Status.ON);
assertEquals(clone.getName(), newName); assertEquals(clone.getName(), newName);
assertEquals(clone.getNetworkToAddresses().values().size(), 1); assertEquals(clone.getNetworkToAddresses().values().size(), 1);
@ -316,7 +316,7 @@ public abstract class TerremarkClientLiveTest extends VCloudExpressClientLiveTes
vApp = tmClient.getVApp(vApp.getId()); 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 // TODO we need to determine whether shutdown is supported before invoking
// it. // it.
@ -327,7 +327,7 @@ public abstract class TerremarkClientLiveTest extends VCloudExpressClientLiveTes
assert successTester.apply(tmClient.powerOffVApp(vApp.getId()).getLocation()); assert successTester.apply(tmClient.powerOffVApp(vApp.getId()).getLocation());
vApp = tmClient.getVApp(vApp.getId()); vApp = tmClient.getVApp(vApp.getId());
assertEquals(vApp.getStatus(), VAppStatus.OFF); assertEquals(vApp.getStatus(), Status.OFF);
} }
@Test(enabled = true, dependsOnMethods = "testLifeCycle") @Test(enabled = true, dependsOnMethods = "testLifeCycle")

View File

@ -34,7 +34,7 @@ import org.jclouds.rest.internal.GeneratedHttpRequest;
import org.jclouds.util.Utils; import org.jclouds.util.Utils;
import org.jclouds.vcloud.domain.ResourceAllocation; import org.jclouds.vcloud.domain.ResourceAllocation;
import org.jclouds.vcloud.domain.ResourceType; 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.domain.internal.VAppImpl;
import org.jclouds.vcloud.terremark.TerremarkVCloudExpressPropertiesBuilder; import org.jclouds.vcloud.terremark.TerremarkVCloudExpressPropertiesBuilder;
import org.jclouds.vcloud.terremark.domain.VAppConfiguration; import org.jclouds.vcloud.terremark.domain.VAppConfiguration;
@ -66,7 +66,7 @@ public class BindVAppConfigurationToXmlPayloadTest {
public void testChangeName() throws IOException { public void testChangeName() throws IOException {
VAppImpl vApp = new VAppImpl("MyAppServer6", URI 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.<String, String> of(), null, null, null, ImmutableSet.of( null, ImmutableListMultimap.<String, String> of(), null, null, null, ImmutableSet.of(
new ResourceAllocation(1, "n/a", null, ResourceType.PROCESSOR, null, null, null, null, null, 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, null, 2, null), new ResourceAllocation(2, "n/a", null, ResourceType.MEMORY, null,
@ -93,7 +93,7 @@ public class BindVAppConfigurationToXmlPayloadTest {
public void testRemoveDisk() throws IOException { public void testRemoveDisk() throws IOException {
VAppImpl vApp = new VAppImpl("MyAppServer6", URI 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.<String, String> of(), null, null, null, ImmutableSet.of( null, ImmutableListMultimap.<String, String> of(), null, null, null, ImmutableSet.of(
new ResourceAllocation(1, "n/a", null, ResourceType.PROCESSOR, null, null, null, null, null, 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, null, 2, null), new ResourceAllocation(2, "n/a", null, ResourceType.MEMORY, null,
@ -122,7 +122,7 @@ public class BindVAppConfigurationToXmlPayloadTest {
public void testChangeCPUCountTo4() throws IOException { public void testChangeCPUCountTo4() throws IOException {
VAppImpl vApp = new VAppImpl("eduardo", URI 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.<String, String> of(), null, null, null, ImmutableSet.of( null, ImmutableListMultimap.<String, String> of(), null, null, null, ImmutableSet.of(
new ResourceAllocation(1, "n/a", null, ResourceType.PROCESSOR, null, null, null, null, null, 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, null, 4, null), new ResourceAllocation(2, "n/a", null, ResourceType.MEMORY, null,
@ -147,7 +147,7 @@ public class BindVAppConfigurationToXmlPayloadTest {
public void testChangeMemoryTo1536() throws IOException { public void testChangeMemoryTo1536() throws IOException {
VAppImpl vApp = new VAppImpl("MyAppServer6", URI 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.<String, String> of(), null, null, null, ImmutableSet.of( null, ImmutableListMultimap.<String, String> of(), null, null, null, ImmutableSet.of(
new ResourceAllocation(1, "n/a", null, ResourceType.PROCESSOR, null, null, null, null, null, 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, null, 2, null), new ResourceAllocation(2, "n/a", null, ResourceType.MEMORY, null,

View File

@ -35,7 +35,7 @@ import javax.inject.Provider;
import org.jclouds.compute.domain.NodeState; import org.jclouds.compute.domain.NodeState;
import org.jclouds.vcloud.domain.Task; import org.jclouds.vcloud.domain.Task;
import org.jclouds.vcloud.domain.VApp; 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.VAppTemplate;
import org.jclouds.vcloud.terremark.TerremarkVCloudExpressClient; import org.jclouds.vcloud.terremark.TerremarkVCloudExpressClient;
import org.jclouds.vcloud.terremark.compute.strategy.ParseVAppTemplateDescriptionToGetDefaultLoginCredentials; import org.jclouds.vcloud.terremark.compute.strategy.ParseVAppTemplateDescriptionToGetDefaultLoginCredentials;
@ -89,7 +89,7 @@ public class TerremarkVCloudComputeClientTest {
expect(client.powerOnVApp(vappLocation)).andReturn(task); expect(client.powerOnVApp(vappLocation)).andReturn(task);
Predicate<VApp> notFoundTester = createMock(Predicate.class); Predicate<VApp> notFoundTester = createMock(Predicate.class);
Map<VAppStatus, NodeState> vAppStatusToNodeState = createMock(Map.class); Map<Status, NodeState> vAppStatusToNodeState = createMock(Map.class);
TerremarkVCloudComputeClient computeClient = new TerremarkVCloudComputeClient(client, TerremarkVCloudComputeClient computeClient = new TerremarkVCloudComputeClient(client,
new ParseVAppTemplateDescriptionToGetDefaultLoginCredentials(), new Provider<String>() { new ParseVAppTemplateDescriptionToGetDefaultLoginCredentials(), new Provider<String>() {

View File

@ -28,15 +28,17 @@ import java.io.InputStream;
import java.net.URI; import java.net.URI;
import java.net.UnknownHostException; import java.net.UnknownHostException;
import java.util.List; import java.util.List;
import java.util.Properties;
import org.jclouds.Constants;
import org.jclouds.http.functions.BaseHandlerTest; import org.jclouds.http.functions.BaseHandlerTest;
import org.jclouds.http.functions.ParseSax; import org.jclouds.http.functions.ParseSax;
import org.jclouds.http.functions.config.SaxParserModule; import org.jclouds.http.functions.config.SaxParserModule;
import org.jclouds.vcloud.VCloudExpressMediaType; import org.jclouds.vcloud.VCloudExpressMediaType;
import org.jclouds.vcloud.domain.ResourceAllocation; import org.jclouds.vcloud.domain.ResourceAllocation;
import org.jclouds.vcloud.domain.ResourceType; import org.jclouds.vcloud.domain.ResourceType;
import org.jclouds.vcloud.domain.Status;
import org.jclouds.vcloud.domain.VApp; import org.jclouds.vcloud.domain.VApp;
import org.jclouds.vcloud.domain.VAppStatus;
import org.jclouds.vcloud.domain.VirtualSystem; import org.jclouds.vcloud.domain.VirtualSystem;
import org.jclouds.vcloud.domain.internal.NamedResourceImpl; import org.jclouds.vcloud.domain.internal.NamedResourceImpl;
import org.jclouds.vcloud.xml.VAppHandler; 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.ImmutableList;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.inject.AbstractModule;
import com.google.inject.Guice; import com.google.inject.Guice;
import com.google.inject.name.Names;
/** /**
* Tests behavior of {@code VAppHandler} * Tests behavior of {@code VAppHandler}
@ -59,7 +63,16 @@ public class VAppHandlerTest extends BaseHandlerTest {
@BeforeTest @BeforeTest
@Override @Override
protected void setUpInjector() { 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); 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); VApp result = (VApp) factory.create(injector.getInstance(VAppHandler.class)).parse(is);
assertEquals(result.getName(), "adriantest"); assertEquals(result.getName(), "adriantest");
assertEquals(result.getStatus(), VAppStatus.UNRESOLVED); assertEquals(result.getStatus(), Status.UNRESOLVED);
assertEquals(result.getSize().longValue(), 4l); assertEquals(result.getSize().longValue(), 4l);
assertEquals(result.getId(), URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/vapp/13775")); 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 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); VApp result = (VApp) factory.create(injector.getInstance(VAppHandler.class)).parse(is);
assertEquals(result.getName(), "centos-53"); assertEquals(result.getName(), "centos-53");
assertEquals(result.getStatus(), VAppStatus.OFF); assertEquals(result.getStatus(), Status.OFF);
assertEquals(result.getSize().longValue(), 10485760); assertEquals(result.getSize().longValue(), 10485760);
assertEquals(result.getOperatingSystemDescription(), "Red Hat Enterprise Linux 5 (64-bit)"); 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.getId(), URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/vapp/16238"));
assertEquals(result.getVDC(), new NamedResourceImpl(null, VCloudExpressMediaType.VDC_XML, URI 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.getSystem(), new VirtualSystem(0, "Virtual Hardware Family", "centos-53", "vmx-07"));
assertEquals(result.getNetworkToAddresses().get("Internal"), ImmutableList.<String> of("10.114.34.132")); assertEquals(result.getNetworkToAddresses().get("Internal"), ImmutableList.<String> of("10.114.34.132"));
ResourceAllocation cpu = new ResourceAllocation(1, "1 virtual CPU(s)", "Number of Virtual CPUs", 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", 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, 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, 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(result.getResourceAllocations(), ImmutableSet.of(cpu, memory, controller, disk));
assertEquals(find(result.getResourceAllocations(), resourceType(ResourceType.PROCESSOR)).getVirtualQuantity(), 1); assertEquals(find(result.getResourceAllocations(), resourceType(ResourceType.PROCESSOR)).getVirtualQuantity(), 1);
assertEquals(find(result.getResourceAllocations(), resourceType(ResourceType.SCSI_CONTROLLER)) 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.MEMORY)).getVirtualQuantity(), 512);
assertEquals(find(result.getResourceAllocations(), resourceType(ResourceType.DISK_DRIVE)).getVirtualQuantity(), assertEquals(find(result.getResourceAllocations(), resourceType(ResourceType.DISK_DRIVE)).getVirtualQuantity(),
10485760); 10485760);
assertEquals(result.getSize().longValue(), find(result.getResourceAllocations(), assertEquals(result.getSize().longValue(), find(result.getResourceAllocations(),
resourceType(ResourceType.DISK_DRIVE)).getVirtualQuantity()); resourceType(ResourceType.DISK_DRIVE)).getVirtualQuantity());
} }
public void testGetVApp2disks() throws UnknownHostException { public void testGetVApp2disks() throws UnknownHostException {
@ -123,39 +136,39 @@ public class VAppHandlerTest extends BaseHandlerTest {
VApp vApp = factory.create(injector.getInstance(VAppHandler.class)).parse(is); VApp vApp = factory.create(injector.getInstance(VAppHandler.class)).parse(is);
assertEquals(vApp.getName(), "eduardo"); assertEquals(vApp.getName(), "eduardo");
assertEquals(vApp.getStatus(), VAppStatus.OFF); assertEquals(vApp.getStatus(), Status.OFF);
assertEquals(vApp.getSize().longValue(), 30408704); assertEquals(vApp.getSize().longValue(), 30408704);
assertEquals(vApp.getOperatingSystemDescription(), "Ubuntu Linux (32-bit)"); assertEquals(vApp.getOperatingSystemDescription(), "Ubuntu Linux (32-bit)");
assertEquals(vApp.getId(), URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/vapp/15639")); 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 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.getSystem(), new VirtualSystem(0, "Virtual Hardware Family", "eduardo", "vmx-07"));
assertEquals(vApp.getNetworkToAddresses().get("Internal"), ImmutableList.of("10.114.34.131")); assertEquals(vApp.getNetworkToAddresses().get("Internal"), ImmutableList.of("10.114.34.131"));
ResourceAllocation cpu = new ResourceAllocation(1, "2 virtual CPU(s)", "Number of Virtual CPUs", 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", 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, 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, 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, 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(vApp.getResourceAllocations(), ImmutableSet.of(cpu, memory, controller, disk, disk2));
assertEquals(find(vApp.getResourceAllocations(), resourceType(ResourceType.PROCESSOR)).getVirtualQuantity(), 2); assertEquals(find(vApp.getResourceAllocations(), resourceType(ResourceType.PROCESSOR)).getVirtualQuantity(), 2);
assertEquals( 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); assertEquals(find(vApp.getResourceAllocations(), resourceType(ResourceType.MEMORY)).getVirtualQuantity(), 1024);
// extract the disks on the vApp sorted by addressOnParent // extract the disks on the vApp sorted by addressOnParent
List<ResourceAllocation> disks = Lists.newArrayList(filter(vApp.getResourceAllocations(), List<ResourceAllocation> disks = Lists.newArrayList(filter(vApp.getResourceAllocations(),
resourceType(ResourceType.DISK_DRIVE))); resourceType(ResourceType.DISK_DRIVE)));
assertEquals(disks.get(0).getVirtualQuantity(), 4194304); assertEquals(disks.get(0).getVirtualQuantity(), 4194304);
assertEquals(disks.get(1).getVirtualQuantity(), 26214400); assertEquals(disks.get(1).getVirtualQuantity(), 26214400);