mirror of https://github.com/apache/jclouds.git
refactored to use new vcloud 1.0 status type
This commit is contained in:
parent
a87747a6b2
commit
250f2f67cb
|
@ -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<URI> successTester, Map<VAppStatus, NodeState> vAppStatusToNodeState) {
|
||||
VCloudClient client, Predicate<URI> successTester, Map<Status, NodeState> vAppStatusToNodeState) {
|
||||
super(client, successTester, vAppStatusToNodeState);
|
||||
this.credentialsProvider = credentialsProvider;
|
||||
}
|
||||
|
|
|
@ -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<URI> successTester, Map<VAppStatus, NodeState> vAppStatusToNodeState) {
|
||||
VCloudExpressClient client, Predicate<URI> successTester, Map<Status, NodeState> vAppStatusToNodeState) {
|
||||
super(client, successTester, vAppStatusToNodeState);
|
||||
this.credentialsProvider = credentialsProvider;
|
||||
}
|
||||
|
|
|
@ -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<VAppStatus, NodeState> vAppStatusToNodeState = ImmutableMap.<VAppStatus, NodeState> builder().put(
|
||||
VAppStatus.OFF, NodeState.SUSPENDED).put(VAppStatus.ON, NodeState.RUNNING).put(VAppStatus.RESOLVED,
|
||||
NodeState.PENDING).put(VAppStatus.SUSPENDED, NodeState.SUSPENDED).put(VAppStatus.UNRESOLVED,
|
||||
static final Map<Status, NodeState> vAppStatusToNodeState = ImmutableMap.<Status, NodeState> 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<VAppStatus, NodeState> provideVAppStatusToNodeState() {
|
||||
Map<Status, NodeState> provideVAppStatusToNodeState() {
|
||||
return vAppStatusToNodeState;
|
||||
}
|
||||
|
||||
|
|
|
@ -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())) {
|
||||
|
|
|
@ -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<VAppStatus, NodeState> vAppStatusToNodeState;
|
||||
protected final Map<Status, NodeState> vAppStatusToNodeState;
|
||||
|
||||
@Inject
|
||||
public VCloudComputeClientImpl(VCloudClient client, Predicate<URI> successTester,
|
||||
Map<VAppStatus, NodeState> vAppStatusToNodeState) {
|
||||
Map<Status, NodeState> vAppStatusToNodeState) {
|
||||
super(client, successTester);
|
||||
this.vAppStatusToNodeState = vAppStatusToNodeState;
|
||||
}
|
||||
|
|
|
@ -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<VAppStatus, NodeState> vAppStatusToNodeState;
|
||||
protected final Map<Status, NodeState> vAppStatusToNodeState;
|
||||
|
||||
@Inject
|
||||
public VCloudExpressComputeClientImpl(VCloudExpressClient client, Predicate<URI> successTester,
|
||||
Map<VAppStatus, NodeState> vAppStatusToNodeState) {
|
||||
Map<Status, NodeState> vAppStatusToNodeState) {
|
||||
super(client, successTester);
|
||||
this.vAppStatusToNodeState = vAppStatusToNodeState;
|
||||
}
|
||||
|
|
|
@ -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<VAppStatus, NodeState> vAppStatusToNodeState;
|
||||
protected final Map<Status, NodeState> vAppStatusToNodeState;
|
||||
|
||||
@Inject
|
||||
protected VCloudAddNodeWithTagStrategy(VCloudClient client, VCloudComputeClient computeClient,
|
||||
Map<VAppStatus, NodeState> vAppStatusToNodeState) {
|
||||
Map<Status, NodeState> vAppStatusToNodeState) {
|
||||
this.client = client;
|
||||
this.computeClient = computeClient;
|
||||
this.vAppStatusToNodeState = vAppStatusToNodeState;
|
||||
|
|
|
@ -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<VAppStatus, NodeState> vAppStatusToNodeState;
|
||||
protected final Map<Status, NodeState> vAppStatusToNodeState;
|
||||
|
||||
@Inject
|
||||
protected VCloudExpressAddNodeWithTagStrategy(VCloudExpressClient client, VCloudExpressComputeClient computeClient,
|
||||
Map<VAppStatus, NodeState> vAppStatusToNodeState) {
|
||||
Map<Status, NodeState> vAppStatusToNodeState) {
|
||||
this.client = client;
|
||||
this.computeClient = computeClient;
|
||||
this.vAppStatusToNodeState = vAppStatusToNodeState;
|
||||
|
|
|
@ -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<Set<? extends Image>> images;
|
||||
protected final FindLocationForResource findLocationForResourceInVDC;
|
||||
protected final GetExtra getExtra;
|
||||
protected final Map<VAppStatus, NodeState> vAppStatusToNodeState;
|
||||
protected final Map<Status, NodeState> vAppStatusToNodeState;
|
||||
|
||||
@Inject
|
||||
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) {
|
||||
this.client = checkNotNull(client, "client");
|
||||
this.images = checkNotNull(images, "images");
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -39,7 +39,7 @@ import com.google.inject.ImplementedBy;
|
|||
public interface VApp extends NamedResource {
|
||||
NamedResource getVDC();
|
||||
|
||||
VAppStatus getStatus();
|
||||
Status getStatus();
|
||||
|
||||
Long getSize();
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -25,7 +25,7 @@ package org.jclouds.vcloud.domain;
|
|||
*/
|
||||
public interface VAppTemplate extends NamedResource {
|
||||
|
||||
VAppStatus getStatus();
|
||||
Status getStatus();
|
||||
|
||||
String getDescription();
|
||||
|
||||
|
|
|
@ -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<String, String> 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<String, String> networkToAddresses, Integer osType, String operatingSystemDescription,
|
||||
VirtualSystem system, Set<ResourceAllocation> resourceAllocations) {
|
||||
this.name = checkNotNull(name, "name");
|
||||
|
@ -69,7 +69,7 @@ public class VAppImpl implements VApp {
|
|||
}
|
||||
|
||||
@Override
|
||||
public VAppStatus getStatus() {
|
||||
public Status getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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<VApp> {
|
||||
|
||||
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<ResourceAllocation> allocations = Sets.newLinkedHashSet();
|
||||
protected VAppStatus status;
|
||||
protected Status status;
|
||||
protected final ListMultimap<String, String> networkToAddresses = ArrayListMultimap.create();
|
||||
protected StringBuilder currentText = new StringBuilder();
|
||||
protected String operatingSystemDescription;
|
||||
|
@ -82,7 +87,11 @@ public class VAppHandler extends ParseSax.HandlerWithResult<VApp> {
|
|||
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
|
||||
|
|
|
@ -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<VAppTemplate
|
|||
|
||||
private NamedResource catalog;
|
||||
private String description;
|
||||
private VAppStatus status;
|
||||
private Status status;
|
||||
|
||||
public VAppTemplate getResult() {
|
||||
return new VAppTemplateImpl(catalog.getName(), catalog.getId(), description, status);
|
||||
|
@ -47,7 +47,7 @@ public class VAppTemplateHandler extends ParseSax.HandlerWithResult<VAppTemplate
|
|||
if (qName.equals("VAppTemplate")) {
|
||||
catalog = Utils.newNamedResource(attributes);
|
||||
if (attributes.getIndex("status") != -1)
|
||||
status = VAppStatus.fromValue(attributes.getValue(attributes.getIndex("status")));
|
||||
status = Status.fromValue(attributes.getValue(attributes.getIndex("status")));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ import org.jclouds.rest.RestContextFactory;
|
|||
import org.jclouds.vcloud.VCloudClient;
|
||||
import org.jclouds.vcloud.domain.ResourceType;
|
||||
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.options.InstantiateVAppTemplateOptions;
|
||||
import org.testng.annotations.AfterTest;
|
||||
|
@ -105,7 +105,7 @@ public class VCloudComputeClientLiveTest {
|
|||
|
||||
VApp vApp = client.getVApp(id);
|
||||
verifyConfigurationOfVApp(vApp, serverName, expectation.os, processorCount, memory, expectation.hardDisk);
|
||||
assertEquals(vApp.getStatus(), VAppStatus.ON);
|
||||
assertEquals(vApp.getStatus(), Status.ON);
|
||||
}
|
||||
|
||||
private String getCompatibleServerName(OsFamily toTest) {
|
||||
|
|
|
@ -37,7 +37,7 @@ import org.jclouds.rest.RestContextFactory;
|
|||
import org.jclouds.vcloud.VCloudExpressClient;
|
||||
import org.jclouds.vcloud.domain.ResourceType;
|
||||
import org.jclouds.vcloud.domain.VApp;
|
||||
import org.jclouds.vcloud.domain.VAppStatus;
|
||||
import org.jclouds.vcloud.domain.Status;
|
||||
import org.jclouds.vcloud.domain.VAppTemplate;
|
||||
import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions;
|
||||
import org.testng.annotations.AfterTest;
|
||||
|
@ -102,7 +102,7 @@ public class VCloudExpressComputeClientLiveTest {
|
|||
|
||||
VApp vApp = client.getVApp(id);
|
||||
verifyConfigurationOfVApp(vApp, serverName, expectation.os, processorCount, memory, expectation.hardDisk);
|
||||
assertEquals(vApp.getStatus(), VAppStatus.ON);
|
||||
assertEquals(vApp.getStatus(), Status.ON);
|
||||
}
|
||||
|
||||
private String getCompatibleServerName(OsFamily toTest) {
|
||||
|
|
|
@ -19,7 +19,9 @@
|
|||
|
||||
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;
|
||||
|
||||
/**
|
||||
|
@ -28,10 +30,13 @@ import org.testng.annotations.Test;
|
|||
@Test(groups = "unit", testName = "vcloud.VCloudComputeServiceContextModuleTest")
|
||||
public class VCloudComputeServiceContextModuleTest {
|
||||
|
||||
@SuppressWarnings("static-access")
|
||||
public void testAllStatusCovered() {
|
||||
|
||||
for (VAppStatus state : VAppStatus.values()) {
|
||||
assert VCloudComputeServiceContextModule.vAppStatusToNodeState.containsKey(state) : state;
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -19,7 +19,9 @@
|
|||
|
||||
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;
|
||||
|
||||
/**
|
||||
|
@ -28,9 +30,12 @@ import org.testng.annotations.Test;
|
|||
@Test(groups = "unit", testName = "vcloud.VCloudExpressComputeServiceContextModuleTest")
|
||||
public class VCloudExpressComputeServiceContextModuleTest {
|
||||
|
||||
@SuppressWarnings("static-access")
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,6 @@ import org.jclouds.http.functions.BaseHandlerTest;
|
|||
import org.jclouds.vcloud.VCloudExpressMediaType;
|
||||
import org.jclouds.vcloud.domain.Task;
|
||||
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.TaskImpl;
|
||||
import org.testng.annotations.BeforeTest;
|
||||
|
@ -60,7 +59,8 @@ public class TaskHandlerTest extends BaseHandlerTest {
|
|||
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
|
||||
.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
|
||||
.create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/1")),
|
||||
new NamedResourceImpl("Server1", VCloudExpressMediaType.VAPP_XML, URI
|
||||
.create("https://services.vcloudexpress.terremark.com/api/v0.8/vapp/4012")
|
||||
|
||||
|
@ -71,12 +71,6 @@ public class TaskHandlerTest extends BaseHandlerTest {
|
|||
|
||||
}
|
||||
|
||||
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() {
|
||||
InputStream is = getClass().getResourceAsStream("/task-self.xml");
|
||||
|
||||
|
|
|
@ -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<String, String> networkToAddresses = ImmutableListMultimap.<String, String> of("Network 1",
|
||||
"204.12.11.167");
|
||||
|
||||
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);
|
||||
});
|
||||
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.<String, String> 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,
|
||||
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);
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<Ob
|
|||
|
||||
protected final String ns;
|
||||
protected final String schema;
|
||||
private final BindToStringPayload stringBinder;
|
||||
protected final BindToStringPayload stringBinder;
|
||||
protected final String apiVersion;
|
||||
|
||||
@Inject
|
||||
public BindVAppConfigurationToXmlPayload(BindToStringPayload stringBinder,
|
||||
@Named(PROPERTY_VCLOUD_XML_NAMESPACE) String ns, @Named(PROPERTY_VCLOUD_XML_SCHEMA) String schema) {
|
||||
public BindVAppConfigurationToXmlPayload(@Named(PROPERTY_API_VERSION) String apiVersion,
|
||||
BindToStringPayload stringBinder, @Named(PROPERTY_VCLOUD_XML_NAMESPACE) String ns,
|
||||
@Named(PROPERTY_VCLOUD_XML_SCHEMA) String schema) {
|
||||
this.apiVersion = apiVersion;
|
||||
this.ns = ns;
|
||||
this.schema = schema;
|
||||
this.stringBinder = stringBinder;
|
||||
|
@ -82,7 +86,7 @@ public class BindVAppConfigurationToXmlPayload implements MapBinder, Function<Ob
|
|||
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 {
|
||||
|
@ -163,8 +167,11 @@ public class BindVAppConfigurationToXmlPayload implements MapBinder, Function<Ob
|
|||
|
||||
protected XMLBuilder buildRoot(VApp vApp, String name) throws ParserConfigurationException,
|
||||
FactoryConfigurationError {
|
||||
XMLBuilder rootBuilder = XMLBuilder.create("VApp").a("type", vApp.getType()).a("name", name).a("status",
|
||||
vApp.getStatus().value()).a("size", vApp.getSize() + "").a("xmlns", ns).a("xmlns:xsi",
|
||||
String status = vApp.getStatus().value();
|
||||
if (apiVersion.indexOf("0.8") != -1 && "8".equals(status))
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ import org.jclouds.vcloud.domain.Task;
|
|||
import org.jclouds.vcloud.domain.TaskStatus;
|
||||
import org.jclouds.vcloud.domain.TasksList;
|
||||
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.options.InstantiateVAppTemplateOptions;
|
||||
import org.jclouds.vcloud.terremark.TerremarkECloudClient;
|
||||
|
@ -71,7 +71,7 @@ public class TerremarkVCloudComputeClient extends VCloudExpressComputeClientImpl
|
|||
protected TerremarkVCloudComputeClient(TerremarkVCloudExpressClient client,
|
||||
PopulateDefaultLoginCredentialsForImageStrategy credentialsProvider,
|
||||
@Named("PASSWORD") Provider<String> passwordGenerator, Predicate<URI> successTester,
|
||||
Map<VAppStatus, NodeState> vAppStatusToNodeState) {
|
||||
Map<Status, NodeState> 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<PublicIpAddress> ipAddresses = deleteInternetServicesAndNodesAssociatedWithVApp(vApp);
|
||||
deletePublicIpAddressesWithNoServicesAttached(ipAddresses);
|
||||
if (vApp.getStatus() != VAppStatus.OFF) {
|
||||
if (vApp.getStatus() != Status.OFF) {
|
||||
try {
|
||||
powerOffAndWait(vApp);
|
||||
} catch (IllegalStateException e) {
|
||||
|
|
|
@ -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<VAppStatus, NodeState> vAppStatusToNodeState, GetExtra getExtra,
|
||||
Map<Status, NodeState> vAppStatusToNodeState, GetExtra getExtra,
|
||||
FindLocationForResource findLocationForResourceInVDC, Supplier<Set<? extends Image>> images,
|
||||
ConcurrentMap<OrgAndName, KeyPairCredentials> credentialsMap) {
|
||||
super(client, computeClient, vAppStatusToNodeState, getExtra, findLocationForResourceInVDC, images);
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -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.<String, String> 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.<String, String> 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.<String, String> 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.<String, String> 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,
|
||||
|
|
|
@ -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<VApp> notFoundTester = createMock(Predicate.class);
|
||||
Map<VAppStatus, NodeState> vAppStatusToNodeState = createMock(Map.class);
|
||||
Map<Status, NodeState> vAppStatusToNodeState = createMock(Map.class);
|
||||
|
||||
TerremarkVCloudComputeClient computeClient = new TerremarkVCloudComputeClient(client,
|
||||
new ParseVAppTemplateDescriptionToGetDefaultLoginCredentials(), new Provider<String>() {
|
||||
|
|
|
@ -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,7 +82,7 @@ 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);
|
||||
|
||||
|
@ -85,7 +98,7 @@ 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)");
|
||||
|
@ -123,7 +136,7 @@ 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)");
|
||||
|
|
Loading…
Reference in New Issue