mirror of https://github.com/apache/jclouds.git
Issue 949:Introduce: ComputeMetadataIncludingStatus; Deprecate NodeState -> NodeMetadata.Status
This commit is contained in:
parent
cd08ce98cc
commit
07c2c24721
|
@ -36,9 +36,9 @@ import org.jclouds.byon.Node;
|
||||||
import org.jclouds.collect.Memoized;
|
import org.jclouds.collect.Memoized;
|
||||||
import org.jclouds.compute.domain.NodeMetadata;
|
import org.jclouds.compute.domain.NodeMetadata;
|
||||||
import org.jclouds.compute.domain.NodeMetadataBuilder;
|
import org.jclouds.compute.domain.NodeMetadataBuilder;
|
||||||
import org.jclouds.compute.domain.NodeState;
|
|
||||||
import org.jclouds.compute.domain.OperatingSystem;
|
import org.jclouds.compute.domain.OperatingSystem;
|
||||||
import org.jclouds.compute.domain.OsFamily;
|
import org.jclouds.compute.domain.OsFamily;
|
||||||
|
import org.jclouds.compute.domain.NodeMetadata.Status;
|
||||||
import org.jclouds.compute.reference.ComputeServiceConstants;
|
import org.jclouds.compute.reference.ComputeServiceConstants;
|
||||||
import org.jclouds.domain.Credentials;
|
import org.jclouds.domain.Credentials;
|
||||||
import org.jclouds.domain.Location;
|
import org.jclouds.domain.Location;
|
||||||
|
@ -90,7 +90,7 @@ public class NodeToNodeMetadata implements Function<Node, NodeMetadata> {
|
||||||
builder.operatingSystem(OperatingSystem.builder().arch(from.getOsArch()).family(
|
builder.operatingSystem(OperatingSystem.builder().arch(from.getOsArch()).family(
|
||||||
OsFamily.fromValue(from.getOsFamily())).description(from.getOsDescription())
|
OsFamily.fromValue(from.getOsFamily())).description(from.getOsDescription())
|
||||||
.version(from.getOsVersion()).build());
|
.version(from.getOsVersion()).build());
|
||||||
builder.state(NodeState.RUNNING);
|
builder.status(Status.RUNNING);
|
||||||
builder.publicAddresses(ImmutableSet.<String> of(from.getHostname()));
|
builder.publicAddresses(ImmutableSet.<String> of(from.getHostname()));
|
||||||
|
|
||||||
if (from.getUsername() != null) {
|
if (from.getUsername() != null) {
|
||||||
|
|
|
@ -27,9 +27,9 @@ import java.util.Set;
|
||||||
import org.jclouds.byon.suppliers.SupplyFromProviderURIOrNodesProperty;
|
import org.jclouds.byon.suppliers.SupplyFromProviderURIOrNodesProperty;
|
||||||
import org.jclouds.compute.domain.NodeMetadata;
|
import org.jclouds.compute.domain.NodeMetadata;
|
||||||
import org.jclouds.compute.domain.NodeMetadataBuilder;
|
import org.jclouds.compute.domain.NodeMetadataBuilder;
|
||||||
import org.jclouds.compute.domain.NodeState;
|
|
||||||
import org.jclouds.compute.domain.OperatingSystem;
|
import org.jclouds.compute.domain.OperatingSystem;
|
||||||
import org.jclouds.compute.domain.OsFamily;
|
import org.jclouds.compute.domain.OsFamily;
|
||||||
|
import org.jclouds.compute.domain.NodeMetadata.Status;
|
||||||
import org.jclouds.domain.Credentials;
|
import org.jclouds.domain.Credentials;
|
||||||
import org.jclouds.domain.Location;
|
import org.jclouds.domain.Location;
|
||||||
import org.jclouds.domain.LocationBuilder;
|
import org.jclouds.domain.LocationBuilder;
|
||||||
|
@ -88,7 +88,7 @@ public class NodeToNodeMetadataTest {
|
||||||
.location(location)
|
.location(location)
|
||||||
.userMetadata(ImmutableMap.of("Name", "foo"))
|
.userMetadata(ImmutableMap.of("Name", "foo"))
|
||||||
.tags(ImmutableSet.of("vanilla"))
|
.tags(ImmutableSet.of("vanilla"))
|
||||||
.state(NodeState.RUNNING)
|
.status(Status.RUNNING)
|
||||||
.operatingSystem(
|
.operatingSystem(
|
||||||
OperatingSystem.builder().description("redhat").family(OsFamily.RHEL).arch("x86").version("5.3")
|
OperatingSystem.builder().description("redhat").family(OsFamily.RHEL).arch("x86").version("5.3")
|
||||||
.build())
|
.build())
|
||||||
|
|
|
@ -37,8 +37,8 @@ import org.jclouds.compute.config.ComputeServiceAdapterContextModule;
|
||||||
import org.jclouds.compute.domain.Hardware;
|
import org.jclouds.compute.domain.Hardware;
|
||||||
import org.jclouds.compute.domain.Image;
|
import org.jclouds.compute.domain.Image;
|
||||||
import org.jclouds.compute.domain.NodeMetadata;
|
import org.jclouds.compute.domain.NodeMetadata;
|
||||||
import org.jclouds.compute.domain.NodeState;
|
|
||||||
import org.jclouds.compute.domain.OperatingSystem;
|
import org.jclouds.compute.domain.OperatingSystem;
|
||||||
|
import org.jclouds.compute.domain.NodeMetadata.Status;
|
||||||
import org.jclouds.compute.extensions.ImageExtension;
|
import org.jclouds.compute.extensions.ImageExtension;
|
||||||
import org.jclouds.compute.internal.BaseComputeService;
|
import org.jclouds.compute.internal.BaseComputeService;
|
||||||
import org.jclouds.domain.Location;
|
import org.jclouds.domain.Location;
|
||||||
|
@ -93,36 +93,36 @@ public class CloudServersComputeServiceContextModule extends
|
||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
public static final Map<ServerStatus, NodeState> serverToNodeState = ImmutableMap
|
public static final Map<ServerStatus, Status> serverToNodeStatus = ImmutableMap
|
||||||
.<ServerStatus, NodeState> builder().put(ServerStatus.ACTIVE, NodeState.RUNNING)//
|
.<ServerStatus, Status> builder().put(ServerStatus.ACTIVE, Status.RUNNING)//
|
||||||
.put(ServerStatus.SUSPENDED, NodeState.SUSPENDED)//
|
.put(ServerStatus.SUSPENDED, Status.SUSPENDED)//
|
||||||
.put(ServerStatus.DELETED, NodeState.TERMINATED)//
|
.put(ServerStatus.DELETED, Status.TERMINATED)//
|
||||||
.put(ServerStatus.QUEUE_RESIZE, NodeState.PENDING)//
|
.put(ServerStatus.QUEUE_RESIZE, Status.PENDING)//
|
||||||
.put(ServerStatus.PREP_RESIZE, NodeState.PENDING)//
|
.put(ServerStatus.PREP_RESIZE, Status.PENDING)//
|
||||||
.put(ServerStatus.RESIZE, NodeState.PENDING)//
|
.put(ServerStatus.RESIZE, Status.PENDING)//
|
||||||
.put(ServerStatus.VERIFY_RESIZE, NodeState.PENDING)//
|
.put(ServerStatus.VERIFY_RESIZE, Status.PENDING)//
|
||||||
.put(ServerStatus.QUEUE_MOVE, NodeState.PENDING)//
|
.put(ServerStatus.QUEUE_MOVE, Status.PENDING)//
|
||||||
.put(ServerStatus.PREP_MOVE, NodeState.PENDING)//
|
.put(ServerStatus.PREP_MOVE, Status.PENDING)//
|
||||||
.put(ServerStatus.MOVE, NodeState.PENDING)//
|
.put(ServerStatus.MOVE, Status.PENDING)//
|
||||||
.put(ServerStatus.VERIFY_MOVE, NodeState.PENDING)//
|
.put(ServerStatus.VERIFY_MOVE, Status.PENDING)//
|
||||||
.put(ServerStatus.RESCUE, NodeState.PENDING)//
|
.put(ServerStatus.RESCUE, Status.PENDING)//
|
||||||
.put(ServerStatus.ERROR, NodeState.ERROR)//
|
.put(ServerStatus.ERROR, Status.ERROR)//
|
||||||
.put(ServerStatus.BUILD, NodeState.PENDING)//
|
.put(ServerStatus.BUILD, Status.PENDING)//
|
||||||
.put(ServerStatus.RESTORING, NodeState.PENDING)//
|
.put(ServerStatus.RESTORING, Status.PENDING)//
|
||||||
.put(ServerStatus.PASSWORD, NodeState.PENDING)//
|
.put(ServerStatus.PASSWORD, Status.PENDING)//
|
||||||
.put(ServerStatus.REBUILD, NodeState.PENDING)//
|
.put(ServerStatus.REBUILD, Status.PENDING)//
|
||||||
.put(ServerStatus.DELETE_IP, NodeState.PENDING)//
|
.put(ServerStatus.DELETE_IP, Status.PENDING)//
|
||||||
.put(ServerStatus.SHARE_IP_NO_CONFIG, NodeState.PENDING)//
|
.put(ServerStatus.SHARE_IP_NO_CONFIG, Status.PENDING)//
|
||||||
.put(ServerStatus.SHARE_IP, NodeState.PENDING)//
|
.put(ServerStatus.SHARE_IP, Status.PENDING)//
|
||||||
.put(ServerStatus.REBOOT, NodeState.PENDING)//
|
.put(ServerStatus.REBOOT, Status.PENDING)//
|
||||||
.put(ServerStatus.HARD_REBOOT, NodeState.PENDING)//
|
.put(ServerStatus.HARD_REBOOT, Status.PENDING)//
|
||||||
.put(ServerStatus.UNKNOWN, NodeState.UNRECOGNIZED)//
|
.put(ServerStatus.UNKNOWN, Status.UNRECOGNIZED)//
|
||||||
.put(ServerStatus.UNRECOGNIZED, NodeState.UNRECOGNIZED).build();
|
.put(ServerStatus.UNRECOGNIZED, Status.UNRECOGNIZED).build();
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
@Provides
|
@Provides
|
||||||
Map<ServerStatus, NodeState> provideServerToNodeState() {
|
Map<ServerStatus, Status> provideServerToNodeStatus() {
|
||||||
return serverToNodeState;
|
return serverToNodeStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -37,8 +37,8 @@ import org.jclouds.compute.domain.Hardware;
|
||||||
import org.jclouds.compute.domain.Image;
|
import org.jclouds.compute.domain.Image;
|
||||||
import org.jclouds.compute.domain.NodeMetadata;
|
import org.jclouds.compute.domain.NodeMetadata;
|
||||||
import org.jclouds.compute.domain.NodeMetadataBuilder;
|
import org.jclouds.compute.domain.NodeMetadataBuilder;
|
||||||
import org.jclouds.compute.domain.NodeState;
|
|
||||||
import org.jclouds.compute.domain.OperatingSystem;
|
import org.jclouds.compute.domain.OperatingSystem;
|
||||||
|
import org.jclouds.compute.domain.NodeMetadata.Status;
|
||||||
import org.jclouds.compute.functions.GroupNamingConvention;
|
import org.jclouds.compute.functions.GroupNamingConvention;
|
||||||
import org.jclouds.compute.reference.ComputeServiceConstants;
|
import org.jclouds.compute.reference.ComputeServiceConstants;
|
||||||
import org.jclouds.domain.Location;
|
import org.jclouds.domain.Location;
|
||||||
|
@ -61,7 +61,7 @@ public class ServerToNodeMetadata implements Function<Server, NodeMetadata> {
|
||||||
protected Logger logger = Logger.NULL;
|
protected Logger logger = Logger.NULL;
|
||||||
|
|
||||||
protected final Supplier<Location> location;
|
protected final Supplier<Location> location;
|
||||||
protected final Map<ServerStatus, NodeState> serverToNodeState;
|
protected final Map<ServerStatus, Status> serverToNodeStatus;
|
||||||
protected final Supplier<Set<? extends Image>> images;
|
protected final Supplier<Set<? extends Image>> images;
|
||||||
protected final Supplier<Set<? extends Hardware>> hardwares;
|
protected final Supplier<Set<? extends Hardware>> hardwares;
|
||||||
protected final GroupNamingConvention nodeNamingConvention;
|
protected final GroupNamingConvention nodeNamingConvention;
|
||||||
|
@ -93,12 +93,12 @@ public class ServerToNodeMetadata implements Function<Server, NodeMetadata> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
ServerToNodeMetadata(Map<ServerStatus, NodeState> serverStateToNodeState,
|
ServerToNodeMetadata(Map<ServerStatus, Status> serverStateToNodeStatus,
|
||||||
@Memoized Supplier<Set<? extends Image>> images, Supplier<Location> location,
|
@Memoized Supplier<Set<? extends Image>> images, Supplier<Location> location,
|
||||||
@Memoized Supplier<Set<? extends Hardware>> hardwares,
|
@Memoized Supplier<Set<? extends Hardware>> hardwares,
|
||||||
GroupNamingConvention.Factory namingConvention) {
|
GroupNamingConvention.Factory namingConvention) {
|
||||||
this.nodeNamingConvention = checkNotNull(namingConvention, "namingConvention").createWithoutPrefix();
|
this.nodeNamingConvention = checkNotNull(namingConvention, "namingConvention").createWithoutPrefix();
|
||||||
this.serverToNodeState = checkNotNull(serverStateToNodeState, "serverStateToNodeState");
|
this.serverToNodeStatus = checkNotNull(serverStateToNodeStatus, "serverStateToNodeStatus");
|
||||||
this.images = checkNotNull(images, "images");
|
this.images = checkNotNull(images, "images");
|
||||||
this.location = checkNotNull(location, "location");
|
this.location = checkNotNull(location, "location");
|
||||||
this.hardwares = checkNotNull(hardwares, "hardwares");
|
this.hardwares = checkNotNull(hardwares, "hardwares");
|
||||||
|
@ -117,7 +117,7 @@ public class ServerToNodeMetadata implements Function<Server, NodeMetadata> {
|
||||||
builder.imageId(from.getImageId() + "");
|
builder.imageId(from.getImageId() + "");
|
||||||
builder.operatingSystem(parseOperatingSystem(from));
|
builder.operatingSystem(parseOperatingSystem(from));
|
||||||
builder.hardware(parseHardware(from));
|
builder.hardware(parseHardware(from));
|
||||||
builder.state(serverToNodeState.get(from.getStatus()));
|
builder.status(serverToNodeStatus.get(from.getStatus()));
|
||||||
builder.publicAddresses(from.getAddresses().getPublicAddresses());
|
builder.publicAddresses(from.getAddresses().getPublicAddresses());
|
||||||
builder.privateAddresses(from.getAddresses().getPrivateAddresses());
|
builder.privateAddresses(from.getAddresses().getPrivateAddresses());
|
||||||
return builder.build();
|
return builder.build();
|
||||||
|
|
|
@ -30,7 +30,7 @@ public class CloudServersComputeServiceContextModuleTest {
|
||||||
public void testAllStatusCovered() {
|
public void testAllStatusCovered() {
|
||||||
|
|
||||||
for (ServerStatus state : ServerStatus.values()) {
|
for (ServerStatus state : ServerStatus.values()) {
|
||||||
assert CloudServersComputeServiceContextModule.serverToNodeState.containsKey(state) : state;
|
assert CloudServersComputeServiceContextModule.serverToNodeStatus.containsKey(state) : state;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,12 +32,12 @@ import org.jclouds.compute.domain.HardwareBuilder;
|
||||||
import org.jclouds.compute.domain.Image;
|
import org.jclouds.compute.domain.Image;
|
||||||
import org.jclouds.compute.domain.NodeMetadata;
|
import org.jclouds.compute.domain.NodeMetadata;
|
||||||
import org.jclouds.compute.domain.NodeMetadataBuilder;
|
import org.jclouds.compute.domain.NodeMetadataBuilder;
|
||||||
import org.jclouds.compute.domain.NodeState;
|
|
||||||
import org.jclouds.compute.domain.OperatingSystem;
|
import org.jclouds.compute.domain.OperatingSystem;
|
||||||
import org.jclouds.compute.domain.OsFamily;
|
import org.jclouds.compute.domain.OsFamily;
|
||||||
import org.jclouds.compute.domain.Processor;
|
import org.jclouds.compute.domain.Processor;
|
||||||
import org.jclouds.compute.domain.Volume;
|
import org.jclouds.compute.domain.Volume;
|
||||||
import org.jclouds.compute.domain.VolumeBuilder;
|
import org.jclouds.compute.domain.VolumeBuilder;
|
||||||
|
import org.jclouds.compute.domain.NodeMetadata.Status;
|
||||||
import org.jclouds.compute.functions.GroupNamingConvention;
|
import org.jclouds.compute.functions.GroupNamingConvention;
|
||||||
import org.jclouds.domain.Location;
|
import org.jclouds.domain.Location;
|
||||||
import org.jclouds.domain.LocationBuilder;
|
import org.jclouds.domain.LocationBuilder;
|
||||||
|
@ -60,12 +60,12 @@ public class ServerToNodeMetadataTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testApplyWhereImageAndHardwareNotFound() {
|
public void testApplyWhereImageAndHardwareNotFound() {
|
||||||
Map<ServerStatus, NodeState> serverStateToNodeState = CloudServersComputeServiceContextModule.serverToNodeState;
|
Map<ServerStatus, Status> serverStateToNodeStatus = CloudServersComputeServiceContextModule.serverToNodeStatus;
|
||||||
Set<org.jclouds.compute.domain.Image> images = ImmutableSet.of();
|
Set<org.jclouds.compute.domain.Image> images = ImmutableSet.of();
|
||||||
Set<org.jclouds.compute.domain.Hardware> hardwares = ImmutableSet.of();
|
Set<org.jclouds.compute.domain.Hardware> hardwares = ImmutableSet.of();
|
||||||
Server server = ParseServerFromJsonResponseTest.parseServer();
|
Server server = ParseServerFromJsonResponseTest.parseServer();
|
||||||
|
|
||||||
ServerToNodeMetadata parser = new ServerToNodeMetadata(serverStateToNodeState, Suppliers.<Set<? extends Image>> ofInstance(images), Suppliers
|
ServerToNodeMetadata parser = new ServerToNodeMetadata(serverStateToNodeStatus, Suppliers.<Set<? extends Image>> ofInstance(images), Suppliers
|
||||||
.ofInstance(provider), Suppliers.<Set<? extends Hardware>> ofInstance(hardwares), namingConvention);
|
.ofInstance(provider), Suppliers.<Set<? extends Hardware>> ofInstance(hardwares), namingConvention);
|
||||||
|
|
||||||
NodeMetadata metadata = parser.apply(server);
|
NodeMetadata metadata = parser.apply(server);
|
||||||
|
@ -73,7 +73,7 @@ public class ServerToNodeMetadataTest {
|
||||||
assertEquals(
|
assertEquals(
|
||||||
metadata,
|
metadata,
|
||||||
new NodeMetadataBuilder()
|
new NodeMetadataBuilder()
|
||||||
.state(NodeState.PENDING)
|
.status(Status.PENDING)
|
||||||
.publicAddresses(ImmutableSet.of("67.23.10.132", "67.23.10.131"))
|
.publicAddresses(ImmutableSet.of("67.23.10.132", "67.23.10.131"))
|
||||||
.privateAddresses(ImmutableSet.of("10.176.42.16"))
|
.privateAddresses(ImmutableSet.of("10.176.42.16"))
|
||||||
.imageId("2")
|
.imageId("2")
|
||||||
|
@ -91,13 +91,13 @@ public class ServerToNodeMetadataTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testApplyWhereImageFoundAndHardwareNotFound() {
|
public void testApplyWhereImageFoundAndHardwareNotFound() {
|
||||||
Map<ServerStatus, NodeState> serverStateToNodeState = CloudServersComputeServiceContextModule.serverToNodeState;
|
Map<ServerStatus, Status> serverStateToNodeStatus = CloudServersComputeServiceContextModule.serverToNodeStatus;
|
||||||
org.jclouds.compute.domain.Image jcImage = CloudServersImageToImageTest.convertImage();
|
org.jclouds.compute.domain.Image jcImage = CloudServersImageToImageTest.convertImage();
|
||||||
Set<org.jclouds.compute.domain.Image> images = ImmutableSet.of(jcImage);
|
Set<org.jclouds.compute.domain.Image> images = ImmutableSet.of(jcImage);
|
||||||
Set<org.jclouds.compute.domain.Hardware> hardwares = ImmutableSet.of();
|
Set<org.jclouds.compute.domain.Hardware> hardwares = ImmutableSet.of();
|
||||||
Server server = ParseServerFromJsonResponseTest.parseServer();
|
Server server = ParseServerFromJsonResponseTest.parseServer();
|
||||||
|
|
||||||
ServerToNodeMetadata parser = new ServerToNodeMetadata(serverStateToNodeState, Suppliers.<Set<? extends Image>> ofInstance(images), Suppliers
|
ServerToNodeMetadata parser = new ServerToNodeMetadata(serverStateToNodeStatus, Suppliers.<Set<? extends Image>> ofInstance(images), Suppliers
|
||||||
.ofInstance(provider), Suppliers.<Set<? extends Hardware>> ofInstance(hardwares), namingConvention);
|
.ofInstance(provider), Suppliers.<Set<? extends Hardware>> ofInstance(hardwares), namingConvention);
|
||||||
|
|
||||||
NodeMetadata metadata = parser.apply(server);
|
NodeMetadata metadata = parser.apply(server);
|
||||||
|
@ -105,7 +105,7 @@ public class ServerToNodeMetadataTest {
|
||||||
assertEquals(
|
assertEquals(
|
||||||
metadata,
|
metadata,
|
||||||
new NodeMetadataBuilder()
|
new NodeMetadataBuilder()
|
||||||
.state(NodeState.PENDING)
|
.status(Status.PENDING)
|
||||||
.publicAddresses(ImmutableSet.of("67.23.10.132", "67.23.10.131"))
|
.publicAddresses(ImmutableSet.of("67.23.10.132", "67.23.10.131"))
|
||||||
.privateAddresses(ImmutableSet.of("10.176.42.16"))
|
.privateAddresses(ImmutableSet.of("10.176.42.16"))
|
||||||
.imageId("2")
|
.imageId("2")
|
||||||
|
@ -126,12 +126,12 @@ public class ServerToNodeMetadataTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testApplyWhereImageAndHardwareFound() {
|
public void testApplyWhereImageAndHardwareFound() {
|
||||||
Map<ServerStatus, NodeState> serverStateToNodeState = CloudServersComputeServiceContextModule.serverToNodeState;
|
Map<ServerStatus, Status> serverStateToNodeStatus = CloudServersComputeServiceContextModule.serverToNodeStatus;
|
||||||
Set<org.jclouds.compute.domain.Image> images = ImmutableSet.of(CloudServersImageToImageTest.convertImage());
|
Set<org.jclouds.compute.domain.Image> images = ImmutableSet.of(CloudServersImageToImageTest.convertImage());
|
||||||
Set<org.jclouds.compute.domain.Hardware> hardwares = ImmutableSet.of(FlavorToHardwareTest.convertFlavor());
|
Set<org.jclouds.compute.domain.Hardware> hardwares = ImmutableSet.of(FlavorToHardwareTest.convertFlavor());
|
||||||
Server server = ParseServerFromJsonResponseTest.parseServer();
|
Server server = ParseServerFromJsonResponseTest.parseServer();
|
||||||
|
|
||||||
ServerToNodeMetadata parser = new ServerToNodeMetadata(serverStateToNodeState, Suppliers.<Set<? extends Image>> ofInstance(images), Suppliers
|
ServerToNodeMetadata parser = new ServerToNodeMetadata(serverStateToNodeStatus, Suppliers.<Set<? extends Image>> ofInstance(images), Suppliers
|
||||||
.ofInstance(provider), Suppliers.<Set<? extends Hardware>> ofInstance(hardwares), namingConvention);
|
.ofInstance(provider), Suppliers.<Set<? extends Hardware>> ofInstance(hardwares), namingConvention);
|
||||||
|
|
||||||
NodeMetadata metadata = parser.apply(server);
|
NodeMetadata metadata = parser.apply(server);
|
||||||
|
@ -139,7 +139,7 @@ public class ServerToNodeMetadataTest {
|
||||||
assertEquals(
|
assertEquals(
|
||||||
metadata,
|
metadata,
|
||||||
new NodeMetadataBuilder()
|
new NodeMetadataBuilder()
|
||||||
.state(NodeState.PENDING)
|
.status(Status.PENDING)
|
||||||
.publicAddresses(ImmutableSet.of("67.23.10.132", "67.23.10.131"))
|
.publicAddresses(ImmutableSet.of("67.23.10.132", "67.23.10.131"))
|
||||||
.privateAddresses(ImmutableSet.of("10.176.42.16"))
|
.privateAddresses(ImmutableSet.of("10.176.42.16"))
|
||||||
.imageId("2")
|
.imageId("2")
|
||||||
|
|
|
@ -38,10 +38,10 @@ import org.jclouds.compute.domain.HardwareBuilder;
|
||||||
import org.jclouds.compute.domain.Image;
|
import org.jclouds.compute.domain.Image;
|
||||||
import org.jclouds.compute.domain.NodeMetadata;
|
import org.jclouds.compute.domain.NodeMetadata;
|
||||||
import org.jclouds.compute.domain.NodeMetadataBuilder;
|
import org.jclouds.compute.domain.NodeMetadataBuilder;
|
||||||
import org.jclouds.compute.domain.NodeState;
|
|
||||||
import org.jclouds.compute.domain.Processor;
|
import org.jclouds.compute.domain.Processor;
|
||||||
import org.jclouds.compute.domain.Volume;
|
import org.jclouds.compute.domain.Volume;
|
||||||
import org.jclouds.compute.domain.VolumeBuilder;
|
import org.jclouds.compute.domain.VolumeBuilder;
|
||||||
|
import org.jclouds.compute.domain.NodeMetadata.Status;
|
||||||
import org.jclouds.compute.functions.GroupNamingConvention;
|
import org.jclouds.compute.functions.GroupNamingConvention;
|
||||||
import org.jclouds.domain.Location;
|
import org.jclouds.domain.Location;
|
||||||
import org.jclouds.logging.Logger;
|
import org.jclouds.logging.Logger;
|
||||||
|
@ -60,13 +60,13 @@ import com.google.common.util.concurrent.UncheckedExecutionException;
|
||||||
*/
|
*/
|
||||||
@Singleton
|
@Singleton
|
||||||
public class ServerInfoToNodeMetadata implements Function<ServerInfo, NodeMetadata> {
|
public class ServerInfoToNodeMetadata implements Function<ServerInfo, NodeMetadata> {
|
||||||
public static final Map<ServerStatus, NodeState> serverStatusToNodeState = ImmutableMap
|
public static final Map<ServerStatus, Status> serverStatusToNodeStatus = ImmutableMap
|
||||||
.<ServerStatus, NodeState> builder().put(ServerStatus.ACTIVE, NodeState.RUNNING)//
|
.<ServerStatus, Status> builder().put(ServerStatus.ACTIVE, Status.RUNNING)//
|
||||||
.put(ServerStatus.STOPPED, NodeState.SUSPENDED)//
|
.put(ServerStatus.STOPPED, Status.SUSPENDED)//
|
||||||
.put(ServerStatus.PAUSED, NodeState.SUSPENDED)//
|
.put(ServerStatus.PAUSED, Status.SUSPENDED)//
|
||||||
.put(ServerStatus.DUMPED, NodeState.PENDING)//
|
.put(ServerStatus.DUMPED, Status.PENDING)//
|
||||||
.put(ServerStatus.DEAD, NodeState.TERMINATED)//
|
.put(ServerStatus.DEAD, Status.TERMINATED)//
|
||||||
.put(ServerStatus.UNRECOGNIZED, NodeState.UNRECOGNIZED)//
|
.put(ServerStatus.UNRECOGNIZED, Status.UNRECOGNIZED)//
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
private final Function<Server, String> getImageIdFromServer;
|
private final Function<Server, String> getImageIdFromServer;
|
||||||
|
@ -104,7 +104,7 @@ public class ServerInfoToNodeMetadata implements Function<ServerInfo, NodeMetada
|
||||||
builder.hardware(new HardwareBuilder().ids(from.getUuid()).hypervisor("kvm")
|
builder.hardware(new HardwareBuilder().ids(from.getUuid()).hypervisor("kvm")
|
||||||
.processors(ImmutableList.of(new Processor(1, from.getCpu()))).ram(from.getMem())
|
.processors(ImmutableList.of(new Processor(1, from.getCpu()))).ram(from.getMem())
|
||||||
.volumes(Iterables.transform(from.getDevices().values(), deviceToVolume)).build());
|
.volumes(Iterables.transform(from.getDevices().values(), deviceToVolume)).build());
|
||||||
builder.state(serverStatusToNodeState.get(from.getStatus()));
|
builder.status(serverStatusToNodeStatus.get(from.getStatus()));
|
||||||
builder.publicAddresses(ImmutableSet.<String> of(from.getVnc().getIp()));
|
builder.publicAddresses(ImmutableSet.<String> of(from.getVnc().getIp()));
|
||||||
builder.privateAddresses(ImmutableSet.<String> of());
|
builder.privateAddresses(ImmutableSet.<String> of());
|
||||||
return builder.build();
|
return builder.build();
|
||||||
|
|
|
@ -41,8 +41,8 @@ import org.jclouds.compute.domain.HardwareBuilder;
|
||||||
import org.jclouds.compute.domain.Image;
|
import org.jclouds.compute.domain.Image;
|
||||||
import org.jclouds.compute.domain.NodeMetadata;
|
import org.jclouds.compute.domain.NodeMetadata;
|
||||||
import org.jclouds.compute.domain.NodeMetadataBuilder;
|
import org.jclouds.compute.domain.NodeMetadataBuilder;
|
||||||
import org.jclouds.compute.domain.NodeState;
|
|
||||||
import org.jclouds.compute.domain.Processor;
|
import org.jclouds.compute.domain.Processor;
|
||||||
|
import org.jclouds.compute.domain.NodeMetadata.Status;
|
||||||
import org.jclouds.compute.functions.GroupNamingConvention;
|
import org.jclouds.compute.functions.GroupNamingConvention;
|
||||||
import org.jclouds.domain.Location;
|
import org.jclouds.domain.Location;
|
||||||
import org.jclouds.rest.ResourceNotFoundException;
|
import org.jclouds.rest.ResourceNotFoundException;
|
||||||
|
@ -64,17 +64,17 @@ import com.google.common.util.concurrent.UncheckedExecutionException;
|
||||||
@Singleton
|
@Singleton
|
||||||
public class VirtualMachineToNodeMetadata implements Function<VirtualMachine, NodeMetadata> {
|
public class VirtualMachineToNodeMetadata implements Function<VirtualMachine, NodeMetadata> {
|
||||||
|
|
||||||
public static final Map<VirtualMachine.State, NodeState> vmStateToNodeState = ImmutableMap
|
public static final Map<VirtualMachine.State, Status> vmStateToNodeStatus = ImmutableMap
|
||||||
.<VirtualMachine.State, NodeState> builder().put(VirtualMachine.State.STARTING, NodeState.PENDING)
|
.<VirtualMachine.State, Status> builder().put(VirtualMachine.State.STARTING, Status.PENDING)
|
||||||
.put(VirtualMachine.State.RUNNING, NodeState.RUNNING).put(VirtualMachine.State.STOPPING, NodeState.PENDING)
|
.put(VirtualMachine.State.RUNNING, Status.RUNNING).put(VirtualMachine.State.STOPPING, Status.PENDING)
|
||||||
.put(VirtualMachine.State.STOPPED, NodeState.SUSPENDED)
|
.put(VirtualMachine.State.STOPPED, Status.SUSPENDED)
|
||||||
.put(VirtualMachine.State.DESTROYED, NodeState.TERMINATED)
|
.put(VirtualMachine.State.DESTROYED, Status.TERMINATED)
|
||||||
.put(VirtualMachine.State.EXPUNGING, NodeState.TERMINATED)
|
.put(VirtualMachine.State.EXPUNGING, Status.TERMINATED)
|
||||||
.put(VirtualMachine.State.MIGRATING, NodeState.PENDING).put(VirtualMachine.State.ERROR, NodeState.ERROR)
|
.put(VirtualMachine.State.MIGRATING, Status.PENDING).put(VirtualMachine.State.ERROR, Status.ERROR)
|
||||||
.put(VirtualMachine.State.UNKNOWN, NodeState.UNRECOGNIZED)
|
.put(VirtualMachine.State.UNKNOWN, Status.UNRECOGNIZED)
|
||||||
// TODO: is this really a state?
|
// TODO: is this really a state?
|
||||||
.put(VirtualMachine.State.SHUTDOWNED, NodeState.PENDING)
|
.put(VirtualMachine.State.SHUTDOWNED, Status.PENDING)
|
||||||
.put(VirtualMachine.State.UNRECOGNIZED, NodeState.UNRECOGNIZED).build();
|
.put(VirtualMachine.State.UNRECOGNIZED, Status.UNRECOGNIZED).build();
|
||||||
|
|
||||||
private final FindLocationForVirtualMachine findLocationForVirtualMachine;
|
private final FindLocationForVirtualMachine findLocationForVirtualMachine;
|
||||||
private final FindImageForVirtualMachine findImageForVirtualMachine;
|
private final FindImageForVirtualMachine findImageForVirtualMachine;
|
||||||
|
@ -123,7 +123,7 @@ public class VirtualMachineToNodeMetadata implements Function<VirtualMachine, No
|
||||||
.hypervisor(from.getHypervisor())//
|
.hypervisor(from.getHypervisor())//
|
||||||
.build());
|
.build());
|
||||||
|
|
||||||
builder.state(vmStateToNodeState.get(from.getState()));
|
builder.status(vmStateToNodeStatus.get(from.getState()));
|
||||||
|
|
||||||
Set<String> publicAddresses = newHashSet(), privateAddresses = newHashSet();
|
Set<String> publicAddresses = newHashSet(), privateAddresses = newHashSet();
|
||||||
if (from.getIPAddress() != null) {
|
if (from.getIPAddress() != null) {
|
||||||
|
|
|
@ -36,7 +36,7 @@ import org.jclouds.compute.domain.HardwareBuilder;
|
||||||
import org.jclouds.compute.domain.Image;
|
import org.jclouds.compute.domain.Image;
|
||||||
import org.jclouds.compute.domain.NodeMetadata;
|
import org.jclouds.compute.domain.NodeMetadata;
|
||||||
import org.jclouds.compute.domain.NodeMetadataBuilder;
|
import org.jclouds.compute.domain.NodeMetadataBuilder;
|
||||||
import org.jclouds.compute.domain.NodeState;
|
import org.jclouds.compute.domain.NodeMetadata.Status;
|
||||||
import org.jclouds.compute.functions.GroupNamingConvention;
|
import org.jclouds.compute.functions.GroupNamingConvention;
|
||||||
import org.jclouds.date.internal.SimpleDateFormatDateService;
|
import org.jclouds.date.internal.SimpleDateFormatDateService;
|
||||||
import org.jclouds.domain.Location;
|
import org.jclouds.domain.Location;
|
||||||
|
@ -87,7 +87,7 @@ public class VirtualMachineToNodeMetadataTest {
|
||||||
assertEquals(
|
assertEquals(
|
||||||
node.toString(),
|
node.toString(),
|
||||||
new NodeMetadataBuilder().id("54").providerId("54").name("i-3-54-VM").group("i-3-54")
|
new NodeMetadataBuilder().id("54").providerId("54").name("i-3-54-VM").group("i-3-54")
|
||||||
.location(ZoneToLocationTest.one).state(NodeState.PENDING).hostname("i-3-54-VM")
|
.location(ZoneToLocationTest.one).status(Status.PENDING).hostname("i-3-54-VM")
|
||||||
.privateAddresses(ImmutableSet.of("10.1.1.18")).publicAddresses(ImmutableSet.of("1.1.1.1"))
|
.privateAddresses(ImmutableSet.of("10.1.1.18")).publicAddresses(ImmutableSet.of("1.1.1.1"))
|
||||||
.hardware(addHypervisor(ServiceOfferingToHardwareTest.one, "XenServer"))
|
.hardware(addHypervisor(ServiceOfferingToHardwareTest.one, "XenServer"))
|
||||||
.imageId(TemplateToImageTest.one.getId())
|
.imageId(TemplateToImageTest.one.getId())
|
||||||
|
@ -150,7 +150,7 @@ public class VirtualMachineToNodeMetadataTest {
|
||||||
assertEquals(
|
assertEquals(
|
||||||
node.toString(),
|
node.toString(),
|
||||||
new NodeMetadataBuilder().id("54").providerId("54").name("i-3-54-VM").group("i-3-54")
|
new NodeMetadataBuilder().id("54").providerId("54").name("i-3-54-VM").group("i-3-54")
|
||||||
.location(ZoneToLocationTest.one).state(NodeState.PENDING).hostname("i-3-54-VM")
|
.location(ZoneToLocationTest.one).status(Status.PENDING).hostname("i-3-54-VM")
|
||||||
.privateAddresses(ImmutableSet.<String>of())
|
.privateAddresses(ImmutableSet.<String>of())
|
||||||
.publicAddresses(ImmutableSet.<String>of("1.1.1.5"))
|
.publicAddresses(ImmutableSet.<String>of("1.1.1.5"))
|
||||||
.hardware(addHypervisor(ServiceOfferingToHardwareTest.one, "XenServer"))
|
.hardware(addHypervisor(ServiceOfferingToHardwareTest.one, "XenServer"))
|
||||||
|
@ -186,7 +186,7 @@ public class VirtualMachineToNodeMetadataTest {
|
||||||
assertEquals(
|
assertEquals(
|
||||||
node.toString(),
|
node.toString(),
|
||||||
new NodeMetadataBuilder().id("54").providerId("54").name("i-3-54-VM").group("i-3-54")
|
new NodeMetadataBuilder().id("54").providerId("54").name("i-3-54-VM").group("i-3-54")
|
||||||
.location(ZoneToLocationTest.one).state(NodeState.PENDING).hostname("i-3-54-VM")
|
.location(ZoneToLocationTest.one).status(Status.PENDING).hostname("i-3-54-VM")
|
||||||
.privateAddresses(ImmutableSet.of("10.1.1.18"))
|
.privateAddresses(ImmutableSet.of("10.1.1.18"))
|
||||||
.hardware(addHypervisor(ServiceOfferingToHardwareTest.one, "XenServer"))
|
.hardware(addHypervisor(ServiceOfferingToHardwareTest.one, "XenServer"))
|
||||||
.imageId(TemplateToImageTest.one.getId())
|
.imageId(TemplateToImageTest.one.getId())
|
||||||
|
|
|
@ -34,8 +34,8 @@ import org.jclouds.compute.domain.Hardware;
|
||||||
import org.jclouds.compute.domain.Image;
|
import org.jclouds.compute.domain.Image;
|
||||||
import org.jclouds.compute.domain.NodeMetadata;
|
import org.jclouds.compute.domain.NodeMetadata;
|
||||||
import org.jclouds.compute.domain.NodeMetadataBuilder;
|
import org.jclouds.compute.domain.NodeMetadataBuilder;
|
||||||
import org.jclouds.compute.domain.NodeState;
|
|
||||||
import org.jclouds.compute.domain.OperatingSystem;
|
import org.jclouds.compute.domain.OperatingSystem;
|
||||||
|
import org.jclouds.compute.domain.NodeMetadata.Status;
|
||||||
import org.jclouds.compute.functions.GroupNamingConvention;
|
import org.jclouds.compute.functions.GroupNamingConvention;
|
||||||
import org.jclouds.compute.reference.ComputeServiceConstants;
|
import org.jclouds.compute.reference.ComputeServiceConstants;
|
||||||
import org.jclouds.deltacloud.domain.Instance;
|
import org.jclouds.deltacloud.domain.Instance;
|
||||||
|
@ -54,11 +54,11 @@ import com.google.common.collect.Iterables;
|
||||||
@Singleton
|
@Singleton
|
||||||
public class InstanceToNodeMetadata implements Function<Instance, NodeMetadata> {
|
public class InstanceToNodeMetadata implements Function<Instance, NodeMetadata> {
|
||||||
|
|
||||||
public static final Map<Instance.State, NodeState> instanceToNodeState = ImmutableMap
|
public static final Map<Instance.State, Status> instanceToNodeStatus = ImmutableMap
|
||||||
.<Instance.State, NodeState> builder().put(Instance.State.STOPPED, NodeState.SUSPENDED)
|
.<Instance.State, Status> builder().put(Instance.State.STOPPED, Status.SUSPENDED)
|
||||||
.put(Instance.State.RUNNING, NodeState.RUNNING).put(Instance.State.PENDING, NodeState.PENDING)
|
.put(Instance.State.RUNNING, Status.RUNNING).put(Instance.State.PENDING, Status.PENDING)
|
||||||
.put(Instance.State.UNRECOGNIZED, NodeState.UNRECOGNIZED).put(Instance.State.SHUTTING_DOWN, NodeState.PENDING)
|
.put(Instance.State.UNRECOGNIZED, Status.UNRECOGNIZED).put(Instance.State.SHUTTING_DOWN, Status.PENDING)
|
||||||
.put(Instance.State.START, NodeState.PENDING).build();
|
.put(Instance.State.START, Status.PENDING).build();
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
@Named(ComputeServiceConstants.COMPUTE_LOGGER)
|
@Named(ComputeServiceConstants.COMPUTE_LOGGER)
|
||||||
|
@ -155,7 +155,7 @@ public class InstanceToNodeMetadata implements Function<Instance, NodeMetadata>
|
||||||
builder.imageId(from.getImage().toASCIIString());
|
builder.imageId(from.getImage().toASCIIString());
|
||||||
builder.operatingSystem(parseOperatingSystem(from));
|
builder.operatingSystem(parseOperatingSystem(from));
|
||||||
builder.hardware(parseHardware(from));
|
builder.hardware(parseHardware(from));
|
||||||
builder.state(instanceToNodeState.get(from.getState()));
|
builder.status(instanceToNodeStatus.get(from.getState()));
|
||||||
builder.publicAddresses(from.getPublicAddresses());
|
builder.publicAddresses(from.getPublicAddresses());
|
||||||
builder.privateAddresses(from.getPrivateAddresses());
|
builder.privateAddresses(from.getPrivateAddresses());
|
||||||
return builder.build();
|
return builder.build();
|
||||||
|
|
|
@ -31,8 +31,8 @@ import javax.inject.Singleton;
|
||||||
import org.jclouds.compute.ComputeService;
|
import org.jclouds.compute.ComputeService;
|
||||||
import org.jclouds.compute.domain.Image;
|
import org.jclouds.compute.domain.Image;
|
||||||
import org.jclouds.compute.domain.NodeMetadata;
|
import org.jclouds.compute.domain.NodeMetadata;
|
||||||
import org.jclouds.compute.domain.NodeState;
|
|
||||||
import org.jclouds.compute.domain.TemplateBuilder;
|
import org.jclouds.compute.domain.TemplateBuilder;
|
||||||
|
import org.jclouds.compute.domain.NodeMetadata.Status;
|
||||||
import org.jclouds.compute.extensions.ImageExtension;
|
import org.jclouds.compute.extensions.ImageExtension;
|
||||||
import org.jclouds.compute.options.TemplateOptions;
|
import org.jclouds.compute.options.TemplateOptions;
|
||||||
import org.jclouds.domain.Credentials;
|
import org.jclouds.domain.Credentials;
|
||||||
|
@ -79,17 +79,17 @@ import com.google.inject.name.Names;
|
||||||
*/
|
*/
|
||||||
public class EC2ComputeServiceDependenciesModule extends AbstractModule {
|
public class EC2ComputeServiceDependenciesModule extends AbstractModule {
|
||||||
|
|
||||||
public static final Map<InstanceState, NodeState> instanceToNodeState = ImmutableMap
|
public static final Map<InstanceState, Status> instanceToNodeStatus = ImmutableMap
|
||||||
.<InstanceState, NodeState> builder().put(InstanceState.PENDING, NodeState.PENDING).put(
|
.<InstanceState, Status> builder().put(InstanceState.PENDING, Status.PENDING).put(
|
||||||
InstanceState.RUNNING, NodeState.RUNNING).put(InstanceState.SHUTTING_DOWN, NodeState.PENDING).put(
|
InstanceState.RUNNING, Status.RUNNING).put(InstanceState.SHUTTING_DOWN, Status.PENDING).put(
|
||||||
InstanceState.TERMINATED, NodeState.TERMINATED).put(InstanceState.STOPPING, NodeState.PENDING)
|
InstanceState.TERMINATED, Status.TERMINATED).put(InstanceState.STOPPING, Status.PENDING)
|
||||||
.put(InstanceState.STOPPED, NodeState.SUSPENDED).put(InstanceState.UNRECOGNIZED, NodeState.UNRECOGNIZED)
|
.put(InstanceState.STOPPED, Status.SUSPENDED).put(InstanceState.UNRECOGNIZED, Status.UNRECOGNIZED)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
@Provides
|
@Provides
|
||||||
Map<InstanceState, NodeState> provideServerToNodeState() {
|
Map<InstanceState, Status> provideServerToNodeStatus() {
|
||||||
return instanceToNodeState;
|
return instanceToNodeStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -24,9 +24,9 @@ import static com.google.common.collect.Iterables.filter;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
@ -37,8 +37,8 @@ import org.jclouds.compute.domain.HardwareBuilder;
|
||||||
import org.jclouds.compute.domain.Image;
|
import org.jclouds.compute.domain.Image;
|
||||||
import org.jclouds.compute.domain.NodeMetadata;
|
import org.jclouds.compute.domain.NodeMetadata;
|
||||||
import org.jclouds.compute.domain.NodeMetadataBuilder;
|
import org.jclouds.compute.domain.NodeMetadataBuilder;
|
||||||
import org.jclouds.compute.domain.NodeState;
|
|
||||||
import org.jclouds.compute.domain.Volume;
|
import org.jclouds.compute.domain.Volume;
|
||||||
|
import org.jclouds.compute.domain.NodeMetadata.Status;
|
||||||
import org.jclouds.compute.domain.internal.VolumeImpl;
|
import org.jclouds.compute.domain.internal.VolumeImpl;
|
||||||
import org.jclouds.compute.functions.GroupNamingConvention;
|
import org.jclouds.compute.functions.GroupNamingConvention;
|
||||||
import org.jclouds.domain.Credentials;
|
import org.jclouds.domain.Credentials;
|
||||||
|
@ -60,10 +60,10 @@ import com.google.common.base.Supplier;
|
||||||
import com.google.common.cache.CacheLoader;
|
import com.google.common.cache.CacheLoader;
|
||||||
import com.google.common.cache.LoadingCache;
|
import com.google.common.cache.LoadingCache;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.collect.ImmutableSet.Builder;
|
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
|
import com.google.common.collect.ImmutableSet.Builder;
|
||||||
import com.google.common.util.concurrent.UncheckedExecutionException;
|
import com.google.common.util.concurrent.UncheckedExecutionException;
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
|
|
||||||
|
@ -80,18 +80,18 @@ public class RunningInstanceToNodeMetadata implements Function<RunningInstance,
|
||||||
protected final Supplier<Set<? extends Hardware>> hardware;
|
protected final Supplier<Set<? extends Hardware>> hardware;
|
||||||
protected final Supplier<LoadingCache<RegionAndName, ? extends Image>> imageMap;
|
protected final Supplier<LoadingCache<RegionAndName, ? extends Image>> imageMap;
|
||||||
protected final Map<String, Credentials> credentialStore;
|
protected final Map<String, Credentials> credentialStore;
|
||||||
protected final Map<InstanceState, NodeState> instanceToNodeState;
|
protected final Map<InstanceState, Status> instanceToNodeStatus;
|
||||||
protected final GroupNamingConvention.Factory namingConvention;
|
protected final GroupNamingConvention.Factory namingConvention;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
protected RunningInstanceToNodeMetadata(Map<InstanceState, NodeState> instanceToNodeState,
|
protected RunningInstanceToNodeMetadata(Map<InstanceState, Status> instanceToNodeStatus,
|
||||||
Map<String, Credentials> credentialStore, Supplier<LoadingCache<RegionAndName, ? extends Image>> imageMap,
|
Map<String, Credentials> credentialStore, Supplier<LoadingCache<RegionAndName, ? extends Image>> imageMap,
|
||||||
@Memoized Supplier<Set<? extends Location>> locations, @Memoized Supplier<Set<? extends Hardware>> hardware,
|
@Memoized Supplier<Set<? extends Location>> locations, @Memoized Supplier<Set<? extends Hardware>> hardware,
|
||||||
GroupNamingConvention.Factory namingConvention) {
|
GroupNamingConvention.Factory namingConvention) {
|
||||||
this.locations = checkNotNull(locations, "locations");
|
this.locations = checkNotNull(locations, "locations");
|
||||||
this.hardware = checkNotNull(hardware, "hardware");
|
this.hardware = checkNotNull(hardware, "hardware");
|
||||||
this.imageMap = checkNotNull(imageMap, "imageMap");
|
this.imageMap = checkNotNull(imageMap, "imageMap");
|
||||||
this.instanceToNodeState = checkNotNull(instanceToNodeState, "instanceToNodeState");
|
this.instanceToNodeStatus = checkNotNull(instanceToNodeStatus, "instanceToNodeStatus");
|
||||||
this.credentialStore = checkNotNull(credentialStore, "credentialStore");
|
this.credentialStore = checkNotNull(credentialStore, "credentialStore");
|
||||||
this.namingConvention = checkNotNull(namingConvention, "namingConvention");
|
this.namingConvention = checkNotNull(namingConvention, "namingConvention");
|
||||||
}
|
}
|
||||||
|
@ -114,7 +114,7 @@ public class RunningInstanceToNodeMetadata implements Function<RunningInstance,
|
||||||
if (instance.getPrivateDnsName() != null)
|
if (instance.getPrivateDnsName() != null)
|
||||||
builder.hostname(instance.getPrivateDnsName().replaceAll("\\..*", ""));
|
builder.hostname(instance.getPrivateDnsName().replaceAll("\\..*", ""));
|
||||||
addCredentialsForInstance(builder, instance);
|
addCredentialsForInstance(builder, instance);
|
||||||
builder.state(instanceToNodeState.get(instance.getInstanceState()));
|
builder.status(instanceToNodeStatus.get(instance.getInstanceState()));
|
||||||
|
|
||||||
// collect all ip addresses into one bundle in case the api mistakenly put a private address
|
// collect all ip addresses into one bundle in case the api mistakenly put a private address
|
||||||
// into the public address field
|
// into the public address field
|
||||||
|
|
|
@ -22,7 +22,7 @@ import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
import org.jclouds.compute.domain.NodeMetadata;
|
import org.jclouds.compute.domain.NodeMetadata;
|
||||||
import org.jclouds.compute.domain.NodeMetadataBuilder;
|
import org.jclouds.compute.domain.NodeMetadataBuilder;
|
||||||
import org.jclouds.compute.domain.NodeState;
|
import org.jclouds.compute.domain.NodeMetadata.Status;
|
||||||
import org.jclouds.ec2.compute.domain.RegionAndName;
|
import org.jclouds.ec2.compute.domain.RegionAndName;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ import com.google.common.collect.ImmutableSet;
|
||||||
@Test(groups = "unit", singleThreaded = true, testName = "AddElasticIpsToNodemetadataTest")
|
@Test(groups = "unit", singleThreaded = true, testName = "AddElasticIpsToNodemetadataTest")
|
||||||
public class AddElasticIpsToNodemetadataTest {
|
public class AddElasticIpsToNodemetadataTest {
|
||||||
|
|
||||||
NodeMetadata node = new NodeMetadataBuilder().state(NodeState.RUNNING).group("zkclustertest").name("foo").hostname(
|
NodeMetadata node = new NodeMetadataBuilder().status(Status.RUNNING).group("zkclustertest").name("foo").hostname(
|
||||||
"ip-10-212-81-7").privateAddresses(ImmutableSet.of("10.212.81.7")).publicAddresses(
|
"ip-10-212-81-7").privateAddresses(ImmutableSet.of("10.212.81.7")).publicAddresses(
|
||||||
ImmutableSet.of("174.129.173.155")).imageId("us-east-1/ami-63be790a").id("us-east-1/i-911444f0")
|
ImmutableSet.of("174.129.173.155")).imageId("us-east-1/ami-63be790a").id("us-east-1/i-911444f0")
|
||||||
.providerId("i-911444f0").tags(ImmutableSet.of("Empty")).userMetadata(ImmutableMap.of("Name", "foo"))
|
.providerId("i-911444f0").tags(ImmutableSet.of("Empty")).userMetadata(ImmutableMap.of("Name", "foo"))
|
||||||
|
|
|
@ -29,9 +29,9 @@ import org.jclouds.compute.domain.Hardware;
|
||||||
import org.jclouds.compute.domain.Image;
|
import org.jclouds.compute.domain.Image;
|
||||||
import org.jclouds.compute.domain.NodeMetadata;
|
import org.jclouds.compute.domain.NodeMetadata;
|
||||||
import org.jclouds.compute.domain.NodeMetadataBuilder;
|
import org.jclouds.compute.domain.NodeMetadataBuilder;
|
||||||
import org.jclouds.compute.domain.NodeState;
|
|
||||||
import org.jclouds.compute.domain.OperatingSystem;
|
import org.jclouds.compute.domain.OperatingSystem;
|
||||||
import org.jclouds.compute.domain.OsFamily;
|
import org.jclouds.compute.domain.OsFamily;
|
||||||
|
import org.jclouds.compute.domain.NodeMetadata.Status;
|
||||||
import org.jclouds.compute.functions.GroupNamingConvention;
|
import org.jclouds.compute.functions.GroupNamingConvention;
|
||||||
import org.jclouds.domain.Credentials;
|
import org.jclouds.domain.Credentials;
|
||||||
import org.jclouds.domain.Location;
|
import org.jclouds.domain.Location;
|
||||||
|
@ -67,8 +67,8 @@ public class RunningInstanceToNodeMetadataTest {
|
||||||
|
|
||||||
public void testAllStatesCovered() {
|
public void testAllStatesCovered() {
|
||||||
|
|
||||||
for (InstanceState state : InstanceState.values()) {
|
for (InstanceState status : InstanceState.values()) {
|
||||||
assert EC2ComputeServiceDependenciesModule.instanceToNodeState.containsKey(state) : state;
|
assert EC2ComputeServiceDependenciesModule.instanceToNodeStatus.containsKey(status) : status;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -81,7 +81,7 @@ public class RunningInstanceToNodeMetadataTest {
|
||||||
RunningInstanceToNodeMetadata parser = createNodeParser(ImmutableSet.<Hardware> of(), ImmutableSet
|
RunningInstanceToNodeMetadata parser = createNodeParser(ImmutableSet.<Hardware> of(), ImmutableSet
|
||||||
.<Location> of(), ImmutableSet.<Image> of(), ImmutableMap.<String, Credentials> of());
|
.<Location> of(), ImmutableSet.<Image> of(), ImmutableMap.<String, Credentials> of());
|
||||||
|
|
||||||
assertEquals(parser.apply(instance), new NodeMetadataBuilder().state(NodeState.RUNNING).publicAddresses(
|
assertEquals(parser.apply(instance), new NodeMetadataBuilder().status(Status.RUNNING).publicAddresses(
|
||||||
ImmutableSet.<String> of()).privateAddresses(ImmutableSet.of("10.1.1.1")).id("us-east-1/id").imageId(
|
ImmutableSet.<String> of()).privateAddresses(ImmutableSet.of("10.1.1.1")).id("us-east-1/id").imageId(
|
||||||
"us-east-1/image").providerId("id").build());
|
"us-east-1/image").providerId("id").build());
|
||||||
}
|
}
|
||||||
|
@ -94,7 +94,7 @@ public class RunningInstanceToNodeMetadataTest {
|
||||||
RunningInstanceToNodeMetadata parser = createNodeParser(ImmutableSet.<Hardware> of(), ImmutableSet
|
RunningInstanceToNodeMetadata parser = createNodeParser(ImmutableSet.<Hardware> of(), ImmutableSet
|
||||||
.<Location> of(), ImmutableSet.<Image> of(), ImmutableMap.<String, Credentials> of());
|
.<Location> of(), ImmutableSet.<Image> of(), ImmutableMap.<String, Credentials> of());
|
||||||
|
|
||||||
assertEquals(parser.apply(instance), new NodeMetadataBuilder().state(NodeState.RUNNING).privateAddresses(
|
assertEquals(parser.apply(instance), new NodeMetadataBuilder().status(Status.RUNNING).privateAddresses(
|
||||||
ImmutableSet.<String> of()).publicAddresses(ImmutableSet.of("1.1.1.1")).id("us-east-1/id").imageId(
|
ImmutableSet.<String> of()).publicAddresses(ImmutableSet.of("1.1.1.1")).id("us-east-1/id").imageId(
|
||||||
"us-east-1/image").providerId("id").build());
|
"us-east-1/image").providerId("id").build());
|
||||||
}
|
}
|
||||||
|
@ -115,7 +115,7 @@ public class RunningInstanceToNodeMetadataTest {
|
||||||
|
|
||||||
assertEquals(
|
assertEquals(
|
||||||
parser.apply(server),
|
parser.apply(server),
|
||||||
new NodeMetadataBuilder().state(NodeState.RUNNING).hostname("ip-10-243-42-70")
|
new NodeMetadataBuilder().status(Status.RUNNING).hostname("ip-10-243-42-70")
|
||||||
.publicAddresses(ImmutableSet.<String> of()).privateAddresses(ImmutableSet.of("10.243.42.70"))
|
.publicAddresses(ImmutableSet.<String> of()).privateAddresses(ImmutableSet.of("10.243.42.70"))
|
||||||
.publicAddresses(ImmutableSet.of("174.129.81.68")).credentials(creds)
|
.publicAddresses(ImmutableSet.of("174.129.81.68")).credentials(creds)
|
||||||
.imageId("us-east-1/ami-82e4b5c7").id("us-east-1/i-0799056f").providerId("i-0799056f").build());
|
.imageId("us-east-1/ami-82e4b5c7").id("us-east-1/i-0799056f").providerId("i-0799056f").build());
|
||||||
|
@ -129,7 +129,7 @@ public class RunningInstanceToNodeMetadataTest {
|
||||||
RunningInstance server = firstInstanceFromResource("/describe_instances_running.xml");
|
RunningInstance server = firstInstanceFromResource("/describe_instances_running.xml");
|
||||||
|
|
||||||
assertEquals(parser.apply(server),
|
assertEquals(parser.apply(server),
|
||||||
new NodeMetadataBuilder().hostname("ip-10-243-42-70").state(NodeState.RUNNING)
|
new NodeMetadataBuilder().hostname("ip-10-243-42-70").status(Status.RUNNING)
|
||||||
.publicAddresses(ImmutableSet.<String> of()).privateAddresses(ImmutableSet.of("10.243.42.70"))
|
.publicAddresses(ImmutableSet.<String> of()).privateAddresses(ImmutableSet.of("10.243.42.70"))
|
||||||
.publicAddresses(ImmutableSet.of("174.129.81.68")).imageId("us-east-1/ami-82e4b5c7")
|
.publicAddresses(ImmutableSet.of("174.129.81.68")).imageId("us-east-1/ami-82e4b5c7")
|
||||||
.id("us-east-1/i-0799056f").providerId("i-0799056f").build());
|
.id("us-east-1/i-0799056f").providerId("i-0799056f").build());
|
||||||
|
@ -141,7 +141,7 @@ public class RunningInstanceToNodeMetadataTest {
|
||||||
ImmutableSet.<Image> of(), ImmutableMap.<String, Credentials> of());
|
ImmutableSet.<Image> of(), ImmutableMap.<String, Credentials> of());
|
||||||
|
|
||||||
RunningInstance server = firstInstanceFromResource("/describe_instances_running.xml");
|
RunningInstance server = firstInstanceFromResource("/describe_instances_running.xml");
|
||||||
NodeMetadata expected = new NodeMetadataBuilder().hostname("ip-10-243-42-70").state(NodeState.RUNNING)
|
NodeMetadata expected = new NodeMetadataBuilder().hostname("ip-10-243-42-70").status(Status.RUNNING)
|
||||||
.privateAddresses(ImmutableSet.of("10.243.42.70")).publicAddresses(ImmutableSet.of("174.129.81.68"))
|
.privateAddresses(ImmutableSet.of("10.243.42.70")).publicAddresses(ImmutableSet.of("174.129.81.68"))
|
||||||
.imageId("us-east-1/ami-82e4b5c7").id("us-east-1/i-0799056f").providerId("i-0799056f")
|
.imageId("us-east-1/ami-82e4b5c7").id("us-east-1/i-0799056f").providerId("i-0799056f")
|
||||||
.location(provider).build();
|
.location(provider).build();
|
||||||
|
@ -159,7 +159,7 @@ public class RunningInstanceToNodeMetadataTest {
|
||||||
assertEquals(
|
assertEquals(
|
||||||
parser.apply(server),
|
parser.apply(server),
|
||||||
new NodeMetadataBuilder()
|
new NodeMetadataBuilder()
|
||||||
.state(NodeState.RUNNING)
|
.status(Status.RUNNING)
|
||||||
.hostname("ip-10-243-42-70")
|
.hostname("ip-10-243-42-70")
|
||||||
.privateAddresses(ImmutableSet.of("10.243.42.70"))
|
.privateAddresses(ImmutableSet.of("10.243.42.70"))
|
||||||
.publicAddresses(ImmutableSet.of("174.129.81.68"))
|
.publicAddresses(ImmutableSet.of("174.129.81.68"))
|
||||||
|
@ -182,7 +182,7 @@ public class RunningInstanceToNodeMetadataTest {
|
||||||
parser.apply(server),
|
parser.apply(server),
|
||||||
new NodeMetadataBuilder()
|
new NodeMetadataBuilder()
|
||||||
.hostname("ip-10-243-42-70")
|
.hostname("ip-10-243-42-70")
|
||||||
.state(NodeState.RUNNING)
|
.status(Status.RUNNING)
|
||||||
.privateAddresses(ImmutableSet.of("10.243.42.70"))
|
.privateAddresses(ImmutableSet.of("10.243.42.70"))
|
||||||
.publicAddresses(ImmutableSet.of("174.129.81.68"))
|
.publicAddresses(ImmutableSet.of("174.129.81.68"))
|
||||||
.imageId("us-east-1/ami-82e4b5c7")
|
.imageId("us-east-1/ami-82e4b5c7")
|
||||||
|
@ -210,13 +210,13 @@ public class RunningInstanceToNodeMetadataTest {
|
||||||
|
|
||||||
RunningInstanceToNodeMetadata parser = createNodeParser(ImmutableSet.of(m1_small().build()), ImmutableSet
|
RunningInstanceToNodeMetadata parser = createNodeParser(ImmutableSet.of(m1_small().build()), ImmutableSet
|
||||||
.of(provider), ImmutableMap.<String, Credentials> of(),
|
.of(provider), ImmutableMap.<String, Credentials> of(),
|
||||||
EC2ComputeServiceDependenciesModule.instanceToNodeState, instanceToImage);
|
EC2ComputeServiceDependenciesModule.instanceToNodeStatus, instanceToImage);
|
||||||
|
|
||||||
RunningInstance server = firstInstanceFromResource("/describe_instances_running.xml");
|
RunningInstance server = firstInstanceFromResource("/describe_instances_running.xml");
|
||||||
|
|
||||||
assertEquals(
|
assertEquals(
|
||||||
parser.apply(server),
|
parser.apply(server),
|
||||||
new NodeMetadataBuilder().hostname("ip-10-243-42-70").state(NodeState.RUNNING)
|
new NodeMetadataBuilder().hostname("ip-10-243-42-70").status(Status.RUNNING)
|
||||||
.privateAddresses(ImmutableSet.of("10.243.42.70")).publicAddresses(ImmutableSet.of("174.129.81.68"))
|
.privateAddresses(ImmutableSet.of("10.243.42.70")).publicAddresses(ImmutableSet.of("174.129.81.68"))
|
||||||
.imageId("us-east-1/ami-82e4b5c7").id("us-east-1/i-0799056f").providerId("i-0799056f")
|
.imageId("us-east-1/ami-82e4b5c7").id("us-east-1/i-0799056f").providerId("i-0799056f")
|
||||||
.hardware(m1_small().build()).location(provider).build());
|
.hardware(m1_small().build()).location(provider).build());
|
||||||
|
@ -245,7 +245,7 @@ public class RunningInstanceToNodeMetadataTest {
|
||||||
protected RunningInstanceToNodeMetadata createNodeParser(final ImmutableSet<Hardware> hardware,
|
protected RunningInstanceToNodeMetadata createNodeParser(final ImmutableSet<Hardware> hardware,
|
||||||
final ImmutableSet<Location> locations, final Set<org.jclouds.compute.domain.Image> images,
|
final ImmutableSet<Location> locations, final Set<org.jclouds.compute.domain.Image> images,
|
||||||
Map<String, Credentials> credentialStore) {
|
Map<String, Credentials> credentialStore) {
|
||||||
Map<InstanceState, NodeState> instanceToNodeState = EC2ComputeServiceDependenciesModule.instanceToNodeState;
|
Map<InstanceState, Status> instanceToNodeStatus = EC2ComputeServiceDependenciesModule.instanceToNodeStatus;
|
||||||
|
|
||||||
CacheLoader<RegionAndName, Image> getRealImage = new CacheLoader<RegionAndName, Image>() {
|
CacheLoader<RegionAndName, Image> getRealImage = new CacheLoader<RegionAndName, Image>() {
|
||||||
|
|
||||||
|
@ -255,7 +255,7 @@ public class RunningInstanceToNodeMetadataTest {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
LoadingCache<RegionAndName, Image> instanceToImage = CacheBuilder.newBuilder().build(getRealImage);
|
LoadingCache<RegionAndName, Image> instanceToImage = CacheBuilder.newBuilder().build(getRealImage);
|
||||||
return createNodeParser(hardware, locations, credentialStore, instanceToNodeState, instanceToImage);
|
return createNodeParser(hardware, locations, credentialStore, instanceToNodeStatus, instanceToImage);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkGroupName(RunningInstance instance) {
|
private void checkGroupName(RunningInstance instance) {
|
||||||
|
@ -266,7 +266,7 @@ public class RunningInstanceToNodeMetadataTest {
|
||||||
|
|
||||||
private RunningInstanceToNodeMetadata createNodeParser(final ImmutableSet<Hardware> hardware,
|
private RunningInstanceToNodeMetadata createNodeParser(final ImmutableSet<Hardware> hardware,
|
||||||
final ImmutableSet<Location> locations, Map<String, Credentials> credentialStore,
|
final ImmutableSet<Location> locations, Map<String, Credentials> credentialStore,
|
||||||
Map<InstanceState, NodeState> instanceToNodeState, LoadingCache<RegionAndName, Image> instanceToImage) {
|
Map<InstanceState, Status> instanceToNodeStatus, LoadingCache<RegionAndName, Image> instanceToImage) {
|
||||||
Supplier<Set<? extends Location>> locationSupplier = new Supplier<Set<? extends Location>>() {
|
Supplier<Set<? extends Location>> locationSupplier = new Supplier<Set<? extends Location>>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -293,7 +293,7 @@ public class RunningInstanceToNodeMetadataTest {
|
||||||
|
|
||||||
}).getInstance(GroupNamingConvention.Factory.class);
|
}).getInstance(GroupNamingConvention.Factory.class);
|
||||||
|
|
||||||
RunningInstanceToNodeMetadata parser = new RunningInstanceToNodeMetadata(instanceToNodeState, credentialStore,
|
RunningInstanceToNodeMetadata parser = new RunningInstanceToNodeMetadata(instanceToNodeStatus, credentialStore,
|
||||||
Suppliers.<LoadingCache<RegionAndName, ? extends Image>> ofInstance(instanceToImage), locationSupplier,
|
Suppliers.<LoadingCache<RegionAndName, ? extends Image>> ofInstance(instanceToImage), locationSupplier,
|
||||||
hardwareSupplier, namingConvention);
|
hardwareSupplier, namingConvention);
|
||||||
return parser;
|
return parser;
|
||||||
|
|
|
@ -34,9 +34,9 @@ import org.jclouds.compute.domain.Hardware;
|
||||||
import org.jclouds.compute.domain.Image;
|
import org.jclouds.compute.domain.Image;
|
||||||
import org.jclouds.compute.domain.NodeMetadata;
|
import org.jclouds.compute.domain.NodeMetadata;
|
||||||
import org.jclouds.compute.domain.NodeMetadataBuilder;
|
import org.jclouds.compute.domain.NodeMetadataBuilder;
|
||||||
import org.jclouds.compute.domain.NodeState;
|
|
||||||
import org.jclouds.compute.domain.Template;
|
import org.jclouds.compute.domain.Template;
|
||||||
import org.jclouds.compute.domain.TemplateBuilder;
|
import org.jclouds.compute.domain.TemplateBuilder;
|
||||||
|
import org.jclouds.compute.domain.NodeMetadata.Status;
|
||||||
import org.jclouds.compute.predicates.AtomicNodeRunning;
|
import org.jclouds.compute.predicates.AtomicNodeRunning;
|
||||||
import org.jclouds.compute.strategy.GetNodeMetadataStrategy;
|
import org.jclouds.compute.strategy.GetNodeMetadataStrategy;
|
||||||
import org.jclouds.compute.util.ComputeUtils;
|
import org.jclouds.compute.util.ComputeUtils;
|
||||||
|
@ -78,7 +78,7 @@ public class EC2CreateNodesInGroupThenAddToSetTest {
|
||||||
String imageId = "ami1";
|
String imageId = "ami1";
|
||||||
String instanceCreatedId = "instance1";
|
String instanceCreatedId = "instance1";
|
||||||
NodeMetadata nodeMetadata = new NodeMetadataBuilder().id(region + "/" + instanceCreatedId)
|
NodeMetadata nodeMetadata = new NodeMetadataBuilder().id(region + "/" + instanceCreatedId)
|
||||||
.providerId(instanceCreatedId).state(NodeState.RUNNING).build();
|
.providerId(instanceCreatedId).status(Status.RUNNING).build();
|
||||||
// setup mocks
|
// setup mocks
|
||||||
TemplateBuilder templateBuilder = createMock(TemplateBuilder.class);
|
TemplateBuilder templateBuilder = createMock(TemplateBuilder.class);
|
||||||
EC2CreateNodesInGroupThenAddToSet strategy = setupStrategy(templateBuilder, nodeMetadata);
|
EC2CreateNodesInGroupThenAddToSet strategy = setupStrategy(templateBuilder, nodeMetadata);
|
||||||
|
@ -190,7 +190,7 @@ public class EC2CreateNodesInGroupThenAddToSetTest {
|
||||||
String imageId = "ami1";
|
String imageId = "ami1";
|
||||||
String instanceCreatedId = "instance1";
|
String instanceCreatedId = "instance1";
|
||||||
NodeMetadata nodeMetadata = new NodeMetadataBuilder().id(region + "/" + instanceCreatedId)
|
NodeMetadata nodeMetadata = new NodeMetadataBuilder().id(region + "/" + instanceCreatedId)
|
||||||
.providerId(instanceCreatedId).state(NodeState.RUNNING).build();
|
.providerId(instanceCreatedId).status(Status.RUNNING).build();
|
||||||
|
|
||||||
// setup mocks
|
// setup mocks
|
||||||
TemplateBuilder templateBuilder = createMock(TemplateBuilder.class);
|
TemplateBuilder templateBuilder = createMock(TemplateBuilder.class);
|
||||||
|
|
|
@ -34,10 +34,10 @@ import org.jclouds.compute.domain.HardwareBuilder;
|
||||||
import org.jclouds.compute.domain.Image;
|
import org.jclouds.compute.domain.Image;
|
||||||
import org.jclouds.compute.domain.NodeMetadata;
|
import org.jclouds.compute.domain.NodeMetadata;
|
||||||
import org.jclouds.compute.domain.NodeMetadataBuilder;
|
import org.jclouds.compute.domain.NodeMetadataBuilder;
|
||||||
import org.jclouds.compute.domain.NodeState;
|
|
||||||
import org.jclouds.compute.domain.Processor;
|
import org.jclouds.compute.domain.Processor;
|
||||||
import org.jclouds.compute.domain.Volume;
|
import org.jclouds.compute.domain.Volume;
|
||||||
import org.jclouds.compute.domain.VolumeBuilder;
|
import org.jclouds.compute.domain.VolumeBuilder;
|
||||||
|
import org.jclouds.compute.domain.NodeMetadata.Status;
|
||||||
import org.jclouds.compute.functions.GroupNamingConvention;
|
import org.jclouds.compute.functions.GroupNamingConvention;
|
||||||
import org.jclouds.domain.Location;
|
import org.jclouds.domain.Location;
|
||||||
import org.jclouds.elasticstack.domain.Device;
|
import org.jclouds.elasticstack.domain.Device;
|
||||||
|
@ -61,13 +61,13 @@ import com.google.common.util.concurrent.UncheckedExecutionException;
|
||||||
*/
|
*/
|
||||||
@Singleton
|
@Singleton
|
||||||
public class ServerInfoToNodeMetadata implements Function<ServerInfo, NodeMetadata> {
|
public class ServerInfoToNodeMetadata implements Function<ServerInfo, NodeMetadata> {
|
||||||
public static final Map<ServerStatus, NodeState> serverStatusToNodeState = ImmutableMap
|
public static final Map<ServerStatus, Status> serverStatusToNodeStatus = ImmutableMap
|
||||||
.<ServerStatus, NodeState> builder().put(ServerStatus.ACTIVE, NodeState.RUNNING)//
|
.<ServerStatus, Status> builder().put(ServerStatus.ACTIVE, Status.RUNNING)//
|
||||||
.put(ServerStatus.STOPPED, NodeState.SUSPENDED)//
|
.put(ServerStatus.STOPPED, Status.SUSPENDED)//
|
||||||
.put(ServerStatus.PAUSED, NodeState.SUSPENDED)//
|
.put(ServerStatus.PAUSED, Status.SUSPENDED)//
|
||||||
.put(ServerStatus.DUMPED, NodeState.PENDING)//
|
.put(ServerStatus.DUMPED, Status.PENDING)//
|
||||||
.put(ServerStatus.DEAD, NodeState.TERMINATED)//
|
.put(ServerStatus.DEAD, Status.TERMINATED)//
|
||||||
.put(ServerStatus.UNRECOGNIZED, NodeState.UNRECOGNIZED)//
|
.put(ServerStatus.UNRECOGNIZED, Status.UNRECOGNIZED)//
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
private final Function<Server, String> getImageIdFromServer;
|
private final Function<Server, String> getImageIdFromServer;
|
||||||
|
@ -106,7 +106,7 @@ public class ServerInfoToNodeMetadata implements Function<ServerInfo, NodeMetada
|
||||||
builder.hardware(new HardwareBuilder().ids(from.getUuid()).hypervisor("kvm")
|
builder.hardware(new HardwareBuilder().ids(from.getUuid()).hypervisor("kvm")
|
||||||
.processors(ImmutableList.of(new Processor(1, from.getCpu()))).ram(from.getMem())
|
.processors(ImmutableList.of(new Processor(1, from.getCpu()))).ram(from.getMem())
|
||||||
.volumes((List) ImmutableList.of(Iterables.transform(from.getDevices().values(), deviceToVolume))).build());
|
.volumes((List) ImmutableList.of(Iterables.transform(from.getDevices().values(), deviceToVolume))).build());
|
||||||
builder.state(serverStatusToNodeState.get(from.getStatus()));
|
builder.status(serverStatusToNodeStatus.get(from.getStatus()));
|
||||||
builder.publicAddresses(ImmutableSet.<String> of(from.getNics().get(0).getDhcp()));
|
builder.publicAddresses(ImmutableSet.<String> of(from.getNics().get(0).getDhcp()));
|
||||||
builder.privateAddresses(ImmutableSet.<String> of());
|
builder.privateAddresses(ImmutableSet.<String> of());
|
||||||
return builder.build();
|
return builder.build();
|
||||||
|
|
|
@ -27,8 +27,8 @@ import org.jclouds.compute.config.ComputeServiceAdapterContextModule;
|
||||||
import org.jclouds.compute.domain.Hardware;
|
import org.jclouds.compute.domain.Hardware;
|
||||||
import org.jclouds.compute.domain.Image;
|
import org.jclouds.compute.domain.Image;
|
||||||
import org.jclouds.compute.domain.NodeMetadata;
|
import org.jclouds.compute.domain.NodeMetadata;
|
||||||
import org.jclouds.compute.domain.NodeState;
|
|
||||||
import org.jclouds.compute.domain.OperatingSystem;
|
import org.jclouds.compute.domain.OperatingSystem;
|
||||||
|
import org.jclouds.compute.domain.NodeMetadata.Status;
|
||||||
import org.jclouds.compute.internal.BaseComputeService;
|
import org.jclouds.compute.internal.BaseComputeService;
|
||||||
import org.jclouds.domain.Location;
|
import org.jclouds.domain.Location;
|
||||||
import org.jclouds.functions.IdentityFunction;
|
import org.jclouds.functions.IdentityFunction;
|
||||||
|
@ -80,28 +80,28 @@ public class NovaComputeServiceContextModule extends
|
||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
public static final Map<ServerStatus, NodeState> serverToNodeState = ImmutableMap
|
public static final Map<ServerStatus, Status> serverToNodeStatus = ImmutableMap
|
||||||
.<ServerStatus, NodeState> builder().put(ServerStatus.ACTIVE, NodeState.RUNNING)//
|
.<ServerStatus, Status> builder().put(ServerStatus.ACTIVE, Status.RUNNING)//
|
||||||
.put(ServerStatus.SUSPENDED, NodeState.SUSPENDED)//
|
.put(ServerStatus.SUSPENDED, Status.SUSPENDED)//
|
||||||
.put(ServerStatus.DELETED, NodeState.TERMINATED)//
|
.put(ServerStatus.DELETED, Status.TERMINATED)//
|
||||||
.put(ServerStatus.QUEUE_RESIZE, NodeState.PENDING)//
|
.put(ServerStatus.QUEUE_RESIZE, Status.PENDING)//
|
||||||
.put(ServerStatus.PREP_RESIZE, NodeState.PENDING)//
|
.put(ServerStatus.PREP_RESIZE, Status.PENDING)//
|
||||||
.put(ServerStatus.RESIZE, NodeState.PENDING)//
|
.put(ServerStatus.RESIZE, Status.PENDING)//
|
||||||
.put(ServerStatus.VERIFY_RESIZE, NodeState.PENDING)//
|
.put(ServerStatus.VERIFY_RESIZE, Status.PENDING)//
|
||||||
.put(ServerStatus.RESCUE, NodeState.PENDING)//
|
.put(ServerStatus.RESCUE, Status.PENDING)//
|
||||||
.put(ServerStatus.BUILD, NodeState.PENDING)//
|
.put(ServerStatus.BUILD, Status.PENDING)//
|
||||||
.put(ServerStatus.PASSWORD, NodeState.PENDING)//
|
.put(ServerStatus.PASSWORD, Status.PENDING)//
|
||||||
.put(ServerStatus.REBUILD, NodeState.PENDING)//
|
.put(ServerStatus.REBUILD, Status.PENDING)//
|
||||||
.put(ServerStatus.DELETE_IP, NodeState.PENDING)//
|
.put(ServerStatus.DELETE_IP, Status.PENDING)//
|
||||||
.put(ServerStatus.REBOOT, NodeState.PENDING)//
|
.put(ServerStatus.REBOOT, Status.PENDING)//
|
||||||
.put(ServerStatus.HARD_REBOOT, NodeState.PENDING)//
|
.put(ServerStatus.HARD_REBOOT, Status.PENDING)//
|
||||||
.put(ServerStatus.UNKNOWN, NodeState.UNRECOGNIZED)//
|
.put(ServerStatus.UNKNOWN, Status.UNRECOGNIZED)//
|
||||||
.put(ServerStatus.UNRECOGNIZED, NodeState.UNRECOGNIZED).build();
|
.put(ServerStatus.UNRECOGNIZED, Status.UNRECOGNIZED).build();
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
@Provides
|
@Provides
|
||||||
Map<ServerStatus, NodeState> provideServerToNodeState() {
|
Map<ServerStatus, Status> provideServerToNodeStatus() {
|
||||||
return serverToNodeState;
|
return serverToNodeStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,7 @@ import org.jclouds.compute.domain.Hardware;
|
||||||
import org.jclouds.compute.domain.Image;
|
import org.jclouds.compute.domain.Image;
|
||||||
import org.jclouds.compute.domain.NodeMetadata;
|
import org.jclouds.compute.domain.NodeMetadata;
|
||||||
import org.jclouds.compute.domain.NodeMetadataBuilder;
|
import org.jclouds.compute.domain.NodeMetadataBuilder;
|
||||||
import org.jclouds.compute.domain.NodeState;
|
import org.jclouds.compute.domain.NodeMetadata.Status;
|
||||||
import org.jclouds.compute.functions.GroupNamingConvention;
|
import org.jclouds.compute.functions.GroupNamingConvention;
|
||||||
import org.jclouds.compute.reference.ComputeServiceConstants;
|
import org.jclouds.compute.reference.ComputeServiceConstants;
|
||||||
import org.jclouds.domain.Location;
|
import org.jclouds.domain.Location;
|
||||||
|
@ -60,7 +60,7 @@ public class ServerToNodeMetadata implements Function<Server, NodeMetadata> {
|
||||||
protected Logger logger = Logger.NULL;
|
protected Logger logger = Logger.NULL;
|
||||||
|
|
||||||
protected final Supplier<Location> location;
|
protected final Supplier<Location> location;
|
||||||
protected final Map<ServerStatus, NodeState> serverToNodeState;
|
protected final Map<ServerStatus, Status> serverToNodeStatus;
|
||||||
protected final Supplier<Set<? extends Image>> images;
|
protected final Supplier<Set<? extends Image>> images;
|
||||||
protected final Supplier<Set<? extends Hardware>> hardwares;
|
protected final Supplier<Set<? extends Hardware>> hardwares;
|
||||||
protected final GroupNamingConvention nodeNamingConvention;
|
protected final GroupNamingConvention nodeNamingConvention;
|
||||||
|
@ -92,12 +92,12 @@ public class ServerToNodeMetadata implements Function<Server, NodeMetadata> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
ServerToNodeMetadata(Map<ServerStatus, NodeState> serverStateToNodeState,
|
ServerToNodeMetadata(Map<ServerStatus, Status> serverStateToNodeStatus,
|
||||||
@Memoized Supplier<Set<? extends Image>> images, Supplier<Location> location,
|
@Memoized Supplier<Set<? extends Image>> images, Supplier<Location> location,
|
||||||
@Memoized Supplier<Set<? extends Hardware>> hardwares,
|
@Memoized Supplier<Set<? extends Hardware>> hardwares,
|
||||||
GroupNamingConvention.Factory namingConvention) {
|
GroupNamingConvention.Factory namingConvention) {
|
||||||
this.nodeNamingConvention = checkNotNull(namingConvention, "namingConvention").createWithoutPrefix();
|
this.nodeNamingConvention = checkNotNull(namingConvention, "namingConvention").createWithoutPrefix();
|
||||||
this.serverToNodeState = checkNotNull(serverStateToNodeState, "serverStateToNodeState");
|
this.serverToNodeStatus = checkNotNull(serverStateToNodeStatus, "serverStateToNodeStatus");
|
||||||
this.images = checkNotNull(images, "images");
|
this.images = checkNotNull(images, "images");
|
||||||
this.location = checkNotNull(location, "location");
|
this.location = checkNotNull(location, "location");
|
||||||
this.hardwares = checkNotNull(hardwares, "hardwares");
|
this.hardwares = checkNotNull(hardwares, "hardwares");
|
||||||
|
@ -118,7 +118,7 @@ public class ServerToNodeMetadata implements Function<Server, NodeMetadata> {
|
||||||
builder.operatingSystem(image.getOperatingSystem());
|
builder.operatingSystem(image.getOperatingSystem());
|
||||||
}
|
}
|
||||||
builder.hardware(parseHardware(from));
|
builder.hardware(parseHardware(from));
|
||||||
builder.state(serverToNodeState.get(from.getStatus()));
|
builder.status(serverToNodeStatus.get(from.getStatus()));
|
||||||
builder.publicAddresses(Iterables.transform(from.getAddresses().getPublicAddresses(), Address.newAddress2StringFunction()));
|
builder.publicAddresses(Iterables.transform(from.getAddresses().getPublicAddresses(), Address.newAddress2StringFunction()));
|
||||||
builder.privateAddresses(Iterables.transform(from.getAddresses().getPrivateAddresses(), Address.newAddress2StringFunction()));
|
builder.privateAddresses(Iterables.transform(from.getAddresses().getPrivateAddresses(), Address.newAddress2StringFunction()));
|
||||||
builder.uri(from.getURI());
|
builder.uri(from.getURI());
|
||||||
|
|
|
@ -30,7 +30,7 @@ public class NovaComputeServiceContextModuleTest {
|
||||||
public void testAllStatusCovered() {
|
public void testAllStatusCovered() {
|
||||||
|
|
||||||
for (ServerStatus state : ServerStatus.values()) {
|
for (ServerStatus state : ServerStatus.values()) {
|
||||||
assert NovaComputeServiceContextModule.serverToNodeState.containsKey(state) : state;
|
assert NovaComputeServiceContextModule.serverToNodeStatus.containsKey(state) : state;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,12 +31,12 @@ import org.jclouds.compute.domain.HardwareBuilder;
|
||||||
import org.jclouds.compute.domain.Image;
|
import org.jclouds.compute.domain.Image;
|
||||||
import org.jclouds.compute.domain.NodeMetadata;
|
import org.jclouds.compute.domain.NodeMetadata;
|
||||||
import org.jclouds.compute.domain.NodeMetadataBuilder;
|
import org.jclouds.compute.domain.NodeMetadataBuilder;
|
||||||
import org.jclouds.compute.domain.NodeState;
|
|
||||||
import org.jclouds.compute.domain.OperatingSystem;
|
import org.jclouds.compute.domain.OperatingSystem;
|
||||||
import org.jclouds.compute.domain.OsFamily;
|
import org.jclouds.compute.domain.OsFamily;
|
||||||
import org.jclouds.compute.domain.Processor;
|
import org.jclouds.compute.domain.Processor;
|
||||||
import org.jclouds.compute.domain.Volume;
|
import org.jclouds.compute.domain.Volume;
|
||||||
import org.jclouds.compute.domain.VolumeBuilder;
|
import org.jclouds.compute.domain.VolumeBuilder;
|
||||||
|
import org.jclouds.compute.domain.NodeMetadata.Status;
|
||||||
import org.jclouds.compute.functions.GroupNamingConvention;
|
import org.jclouds.compute.functions.GroupNamingConvention;
|
||||||
import org.jclouds.domain.Location;
|
import org.jclouds.domain.Location;
|
||||||
import org.jclouds.domain.LocationBuilder;
|
import org.jclouds.domain.LocationBuilder;
|
||||||
|
@ -64,12 +64,12 @@ public class ServerToNodeMetadataTest {
|
||||||
@Test
|
@Test
|
||||||
public void testApplyWhereImageAndHardwareNotFound() throws UnknownHostException, NoSuchMethodException,
|
public void testApplyWhereImageAndHardwareNotFound() throws UnknownHostException, NoSuchMethodException,
|
||||||
ClassNotFoundException, URISyntaxException {
|
ClassNotFoundException, URISyntaxException {
|
||||||
Map<ServerStatus, NodeState> serverStateToNodeState = NovaComputeServiceContextModule.serverToNodeState;
|
Map<ServerStatus, Status> serverStateToNodeStatus = NovaComputeServiceContextModule.serverToNodeStatus;
|
||||||
Set<org.jclouds.compute.domain.Image> images = ImmutableSet.of();
|
Set<org.jclouds.compute.domain.Image> images = ImmutableSet.of();
|
||||||
Set<org.jclouds.compute.domain.Hardware> hardwares = ImmutableSet.of();
|
Set<org.jclouds.compute.domain.Hardware> hardwares = ImmutableSet.of();
|
||||||
Server server = ParseServerFromJsonResponseTest.parseServer();
|
Server server = ParseServerFromJsonResponseTest.parseServer();
|
||||||
|
|
||||||
ServerToNodeMetadata parser = new ServerToNodeMetadata(serverStateToNodeState,
|
ServerToNodeMetadata parser = new ServerToNodeMetadata(serverStateToNodeStatus,
|
||||||
Suppliers.<Set<? extends Image>> ofInstance(images), Suppliers.ofInstance(provider),
|
Suppliers.<Set<? extends Image>> ofInstance(images), Suppliers.ofInstance(provider),
|
||||||
Suppliers.<Set<? extends Hardware>> ofInstance(hardwares), namingConvention);
|
Suppliers.<Set<? extends Hardware>> ofInstance(hardwares), namingConvention);
|
||||||
|
|
||||||
|
@ -83,7 +83,7 @@ public class ServerToNodeMetadataTest {
|
||||||
|
|
||||||
private NodeMetadataBuilder newNodeMetadataBuilder() throws URISyntaxException {
|
private NodeMetadataBuilder newNodeMetadataBuilder() throws URISyntaxException {
|
||||||
return new NodeMetadataBuilder()
|
return new NodeMetadataBuilder()
|
||||||
.state(NodeState.PENDING)
|
.status(Status.PENDING)
|
||||||
.publicAddresses(ImmutableSet.of("67.23.10.132", "::babe:67.23.10.132", "67.23.10.131", "::babe:4317:0A83"))
|
.publicAddresses(ImmutableSet.of("67.23.10.132", "::babe:67.23.10.132", "67.23.10.131", "::babe:4317:0A83"))
|
||||||
.privateAddresses(ImmutableSet.of("10.176.42.16", "::babe:10.176.42.16"))
|
.privateAddresses(ImmutableSet.of("10.176.42.16", "::babe:10.176.42.16"))
|
||||||
.id("1234")
|
.id("1234")
|
||||||
|
@ -100,13 +100,13 @@ public class ServerToNodeMetadataTest {
|
||||||
@Test
|
@Test
|
||||||
public void testApplyWhereImageFoundAndHardwareNotFound() throws UnknownHostException, NoSuchMethodException,
|
public void testApplyWhereImageFoundAndHardwareNotFound() throws UnknownHostException, NoSuchMethodException,
|
||||||
ClassNotFoundException, URISyntaxException {
|
ClassNotFoundException, URISyntaxException {
|
||||||
Map<ServerStatus, NodeState> serverStateToNodeState = NovaComputeServiceContextModule.serverToNodeState;
|
Map<ServerStatus, Status> serverStateToNodeStatus = NovaComputeServiceContextModule.serverToNodeStatus;
|
||||||
org.jclouds.compute.domain.Image jcImage = NovaImageToImageTest.convertImage();
|
org.jclouds.compute.domain.Image jcImage = NovaImageToImageTest.convertImage();
|
||||||
Set<org.jclouds.compute.domain.Image> images = ImmutableSet.of(jcImage);
|
Set<org.jclouds.compute.domain.Image> images = ImmutableSet.of(jcImage);
|
||||||
Set<org.jclouds.compute.domain.Hardware> hardwares = ImmutableSet.of();
|
Set<org.jclouds.compute.domain.Hardware> hardwares = ImmutableSet.of();
|
||||||
Server server = ParseServerFromJsonResponseTest.parseServer();
|
Server server = ParseServerFromJsonResponseTest.parseServer();
|
||||||
|
|
||||||
ServerToNodeMetadata parser = new ServerToNodeMetadata(serverStateToNodeState,
|
ServerToNodeMetadata parser = new ServerToNodeMetadata(serverStateToNodeStatus,
|
||||||
Suppliers.<Set<? extends Image>> ofInstance(images), Suppliers.ofInstance(provider),
|
Suppliers.<Set<? extends Image>> ofInstance(images), Suppliers.ofInstance(provider),
|
||||||
Suppliers.<Set<? extends Hardware>> ofInstance(hardwares), namingConvention);
|
Suppliers.<Set<? extends Hardware>> ofInstance(hardwares), namingConvention);
|
||||||
|
|
||||||
|
@ -125,12 +125,12 @@ public class ServerToNodeMetadataTest {
|
||||||
@Test
|
@Test
|
||||||
public void testApplyWhereImageAndHardwareFound() throws UnknownHostException, NoSuchMethodException,
|
public void testApplyWhereImageAndHardwareFound() throws UnknownHostException, NoSuchMethodException,
|
||||||
ClassNotFoundException, URISyntaxException {
|
ClassNotFoundException, URISyntaxException {
|
||||||
Map<ServerStatus, NodeState> serverStateToNodeState = NovaComputeServiceContextModule.serverToNodeState;
|
Map<ServerStatus, Status> serverStateToNodeStatus = NovaComputeServiceContextModule.serverToNodeStatus;
|
||||||
Set<org.jclouds.compute.domain.Image> images = ImmutableSet.of(NovaImageToImageTest.convertImage());
|
Set<org.jclouds.compute.domain.Image> images = ImmutableSet.of(NovaImageToImageTest.convertImage());
|
||||||
Set<org.jclouds.compute.domain.Hardware> hardwares = ImmutableSet.of(FlavorToHardwareTest.convertFlavor());
|
Set<org.jclouds.compute.domain.Hardware> hardwares = ImmutableSet.of(FlavorToHardwareTest.convertFlavor());
|
||||||
Server server = ParseServerFromJsonResponseTest.parseServer();
|
Server server = ParseServerFromJsonResponseTest.parseServer();
|
||||||
|
|
||||||
ServerToNodeMetadata parser = new ServerToNodeMetadata(serverStateToNodeState,
|
ServerToNodeMetadata parser = new ServerToNodeMetadata(serverStateToNodeStatus,
|
||||||
Suppliers.<Set<? extends Image>> ofInstance(images), Suppliers.ofInstance(provider),
|
Suppliers.<Set<? extends Image>> ofInstance(images), Suppliers.ofInstance(provider),
|
||||||
Suppliers.<Set<? extends Hardware>> ofInstance(hardwares), namingConvention);
|
Suppliers.<Set<? extends Hardware>> ofInstance(hardwares), namingConvention);
|
||||||
|
|
||||||
|
|
|
@ -103,7 +103,7 @@ public class ServerInZoneToNodeMetadata implements Function<ServerInZone, NodeMe
|
||||||
builder.imageId(ZoneAndId.fromZoneAndId(serverInZone.getZone(), from.getImage().getId()).slashEncode());
|
builder.imageId(ZoneAndId.fromZoneAndId(serverInZone.getZone(), from.getImage().getId()).slashEncode());
|
||||||
builder.operatingSystem(findOperatingSystemForServerOrNull(serverInZone));
|
builder.operatingSystem(findOperatingSystemForServerOrNull(serverInZone));
|
||||||
builder.hardware(findHardwareForServerOrNull(serverInZone));
|
builder.hardware(findHardwareForServerOrNull(serverInZone));
|
||||||
builder.state(from.getStatus().getNodeState());
|
builder.status(from.getStatus().getNodeStatus());
|
||||||
builder.publicAddresses(filter(
|
builder.publicAddresses(filter(
|
||||||
transform(filter(from.getAddresses().values(), Predicates.not(isPrivateAddress)),
|
transform(filter(from.getAddresses().values(), Predicates.not(isPrivateAddress)),
|
||||||
AddressToStringTransformationFunction.INSTANCE), isInet4Address));
|
AddressToStringTransformationFunction.INSTANCE), isInet4Address));
|
||||||
|
|
|
@ -24,16 +24,16 @@ import java.util.Date;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.jclouds.compute.domain.NodeState;
|
import org.jclouds.compute.domain.NodeMetadata;
|
||||||
import org.jclouds.javax.annotation.Nullable;
|
import org.jclouds.javax.annotation.Nullable;
|
||||||
import org.jclouds.openstack.domain.Resource;
|
import org.jclouds.openstack.domain.Resource;
|
||||||
import org.jclouds.openstack.nova.v1_1.extensions.KeyPairClient;
|
import org.jclouds.openstack.nova.v1_1.extensions.KeyPairClient;
|
||||||
import org.jclouds.util.Multimaps2;
|
import org.jclouds.util.Multimaps2;
|
||||||
|
|
||||||
import com.google.common.base.Objects.ToStringHelper;
|
|
||||||
import com.google.common.base.Optional;
|
import com.google.common.base.Optional;
|
||||||
import com.google.common.base.Predicates;
|
import com.google.common.base.Predicates;
|
||||||
import com.google.common.base.Strings;
|
import com.google.common.base.Strings;
|
||||||
|
import com.google.common.base.Objects.ToStringHelper;
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.common.collect.ImmutableMultimap;
|
import com.google.common.collect.ImmutableMultimap;
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
|
@ -62,15 +62,17 @@ public class Server extends Resource {
|
||||||
*/
|
*/
|
||||||
public static enum Status {
|
public static enum Status {
|
||||||
|
|
||||||
ACTIVE(NodeState.RUNNING), BUILD(NodeState.PENDING), REBUILD(NodeState.PENDING), SUSPENDED(NodeState.SUSPENDED), RESIZE(
|
ACTIVE(NodeMetadata.Status.RUNNING), BUILD(NodeMetadata.Status.PENDING), REBUILD(NodeMetadata.Status.PENDING), SUSPENDED(
|
||||||
NodeState.PENDING), VERIFY_RESIZE(NodeState.PENDING), REVERT_RESIZE(NodeState.PENDING), PASSWORD(
|
NodeMetadata.Status.SUSPENDED), RESIZE(NodeMetadata.Status.PENDING), VERIFY_RESIZE(
|
||||||
NodeState.PENDING), REBOOT(NodeState.PENDING), HARD_REBOOT(NodeState.PENDING), DELETED(
|
NodeMetadata.Status.PENDING), REVERT_RESIZE(NodeMetadata.Status.PENDING), PASSWORD(
|
||||||
NodeState.TERMINATED), UNKNOWN(NodeState.UNRECOGNIZED), ERROR(NodeState.ERROR), UNRECOGNIZED(
|
NodeMetadata.Status.PENDING), REBOOT(NodeMetadata.Status.PENDING), HARD_REBOOT(
|
||||||
NodeState.UNRECOGNIZED), PAUSED(NodeState.SUSPENDED);
|
NodeMetadata.Status.PENDING), DELETED(NodeMetadata.Status.TERMINATED), UNKNOWN(
|
||||||
|
NodeMetadata.Status.UNRECOGNIZED), ERROR(NodeMetadata.Status.ERROR), UNRECOGNIZED(
|
||||||
|
NodeMetadata.Status.UNRECOGNIZED), PAUSED(NodeMetadata.Status.SUSPENDED);
|
||||||
|
|
||||||
protected final NodeState nodeState;
|
protected final NodeMetadata.Status nodeState;
|
||||||
|
|
||||||
Status(NodeState nodeState) {
|
Status(NodeMetadata.Status nodeState) {
|
||||||
this.nodeState = nodeState;
|
this.nodeState = nodeState;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,7 +88,7 @@ public class Server extends Resource {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public NodeState getNodeState() {
|
public NodeMetadata.Status getNodeStatus() {
|
||||||
return nodeState;
|
return nodeState;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@ import java.util.concurrent.atomic.AtomicReference;
|
||||||
|
|
||||||
import org.jclouds.compute.domain.NodeMetadata;
|
import org.jclouds.compute.domain.NodeMetadata;
|
||||||
import org.jclouds.compute.domain.NodeMetadataBuilder;
|
import org.jclouds.compute.domain.NodeMetadataBuilder;
|
||||||
import org.jclouds.compute.domain.NodeState;
|
import org.jclouds.compute.domain.NodeMetadata.Status;
|
||||||
import org.jclouds.domain.Location;
|
import org.jclouds.domain.Location;
|
||||||
import org.jclouds.domain.LocationBuilder;
|
import org.jclouds.domain.LocationBuilder;
|
||||||
import org.jclouds.domain.LocationScope;
|
import org.jclouds.domain.LocationScope;
|
||||||
|
@ -54,7 +54,7 @@ public class AllocateAndAddFloatingIpToNodeExpectTest extends BaseNovaComputeSer
|
||||||
final Location host = new LocationBuilder().scope(LocationScope.HOST).id("hostId").description("hostId")
|
final Location host = new LocationBuilder().scope(LocationScope.HOST).id("hostId").description("hostId")
|
||||||
.parent(zone).build();
|
.parent(zone).build();
|
||||||
final NodeMetadata node = new NodeMetadataBuilder().id("az-1.region-a.geo-1/71592").providerId("71592").location(
|
final NodeMetadata node = new NodeMetadataBuilder().id("az-1.region-a.geo-1/71592").providerId("71592").location(
|
||||||
host).name("Server 71592").state(NodeState.RUNNING).privateAddresses(ImmutableSet.of("10.4.27.237"))
|
host).name("Server 71592").status(Status.RUNNING).privateAddresses(ImmutableSet.of("10.4.27.237"))
|
||||||
.credentials(LoginCredentials.builder().password("foo").build()).build();
|
.credentials(LoginCredentials.builder().password("foo").build()).build();
|
||||||
|
|
||||||
HttpRequest allocateFloatingIP = HttpRequest.builder().method("POST").endpoint(
|
HttpRequest allocateFloatingIP = HttpRequest.builder().method("POST").endpoint(
|
||||||
|
|
|
@ -32,7 +32,6 @@ import org.jclouds.domain.LocationBuilder;
|
||||||
import org.jclouds.domain.LocationScope;
|
import org.jclouds.domain.LocationScope;
|
||||||
import org.jclouds.openstack.nova.v1_1.domain.zonescoped.ServerInZone;
|
import org.jclouds.openstack.nova.v1_1.domain.zonescoped.ServerInZone;
|
||||||
import org.jclouds.openstack.nova.v1_1.domain.zonescoped.ZoneAndName;
|
import org.jclouds.openstack.nova.v1_1.domain.zonescoped.ZoneAndName;
|
||||||
import org.jclouds.openstack.nova.v1_1.parse.ParseCreatedServerTest;
|
|
||||||
import org.jclouds.openstack.nova.v1_1.parse.ParseServerTest;
|
import org.jclouds.openstack.nova.v1_1.parse.ParseServerTest;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,6 @@ import org.jclouds.openstack.domain.Link;
|
||||||
import org.jclouds.openstack.domain.Resource;
|
import org.jclouds.openstack.domain.Resource;
|
||||||
import org.jclouds.openstack.nova.v1_1.domain.Server;
|
import org.jclouds.openstack.nova.v1_1.domain.Server;
|
||||||
import org.jclouds.openstack.nova.v1_1.domain.zonescoped.ServerInZone;
|
import org.jclouds.openstack.nova.v1_1.domain.zonescoped.ServerInZone;
|
||||||
import org.jclouds.openstack.nova.v1_1.parse.ParseCreatedServerTest;
|
|
||||||
import org.jclouds.openstack.nova.v1_1.parse.ParseServerTest;
|
import org.jclouds.openstack.nova.v1_1.parse.ParseServerTest;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
@ -128,7 +127,7 @@ public class ServerInZoneToNodeMetadataTest {
|
||||||
|
|
||||||
assertEquals(convertedNodeMetadata.getHardware(), expectedHardware);
|
assertEquals(convertedNodeMetadata.getHardware(), expectedHardware);
|
||||||
|
|
||||||
assertEquals(serverToConvert.getStatus().getNodeState(), convertedNodeMetadata.getState());
|
assertEquals(serverToConvert.getStatus().getNodeStatus(), convertedNodeMetadata.getStatus());
|
||||||
|
|
||||||
assertNotNull(convertedNodeMetadata.getPrivateAddresses());
|
assertNotNull(convertedNodeMetadata.getPrivateAddresses());
|
||||||
assertEquals(convertedNodeMetadata.getPrivateAddresses(), ImmutableSet.of("10.176.42.16"));
|
assertEquals(convertedNodeMetadata.getPrivateAddresses(), ImmutableSet.of("10.176.42.16"));
|
||||||
|
|
|
@ -23,15 +23,11 @@ import java.net.URI;
|
||||||
import javax.ws.rs.Consumes;
|
import javax.ws.rs.Consumes;
|
||||||
import javax.ws.rs.core.MediaType;
|
import javax.ws.rs.core.MediaType;
|
||||||
|
|
||||||
import org.jclouds.date.internal.SimpleDateFormatDateService;
|
|
||||||
import org.jclouds.json.BaseItemParserTest;
|
import org.jclouds.json.BaseItemParserTest;
|
||||||
import org.jclouds.json.config.GsonModule;
|
import org.jclouds.json.config.GsonModule;
|
||||||
import org.jclouds.openstack.domain.Link;
|
import org.jclouds.openstack.domain.Link;
|
||||||
import org.jclouds.openstack.domain.Link.Relation;
|
import org.jclouds.openstack.domain.Link.Relation;
|
||||||
import org.jclouds.openstack.domain.Resource;
|
|
||||||
import org.jclouds.openstack.nova.v1_1.config.NovaParserModule;
|
import org.jclouds.openstack.nova.v1_1.config.NovaParserModule;
|
||||||
import org.jclouds.openstack.nova.v1_1.domain.Server;
|
|
||||||
import org.jclouds.openstack.nova.v1_1.domain.Server.Status;
|
|
||||||
import org.jclouds.openstack.nova.v1_1.domain.ServerCreated;
|
import org.jclouds.openstack.nova.v1_1.domain.ServerCreated;
|
||||||
import org.jclouds.rest.annotations.SelectJson;
|
import org.jclouds.rest.annotations.SelectJson;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
|
@ -27,7 +27,6 @@ import org.jclouds.compute.ComputeServiceAdapter;
|
||||||
import org.jclouds.compute.domain.Hardware;
|
import org.jclouds.compute.domain.Hardware;
|
||||||
import org.jclouds.compute.domain.Image;
|
import org.jclouds.compute.domain.Image;
|
||||||
import org.jclouds.compute.domain.NodeMetadata;
|
import org.jclouds.compute.domain.NodeMetadata;
|
||||||
import org.jclouds.compute.domain.NodeState;
|
|
||||||
import org.jclouds.compute.domain.TemplateBuilder;
|
import org.jclouds.compute.domain.TemplateBuilder;
|
||||||
import org.jclouds.compute.options.TemplateOptions;
|
import org.jclouds.compute.options.TemplateOptions;
|
||||||
import org.jclouds.domain.Location;
|
import org.jclouds.domain.Location;
|
||||||
|
@ -65,17 +64,17 @@ import com.google.inject.TypeLiteral;
|
||||||
public class VCloudComputeServiceDependenciesModule extends AbstractModule {
|
public class VCloudComputeServiceDependenciesModule extends AbstractModule {
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
public static final Map<Status, NodeState> VAPPSTATUS_TO_NODESTATE = ImmutableMap.<Status, NodeState> builder().put(
|
public static final Map<Status, NodeMetadata.Status> VAPPSTATUS_TO_NODESTATE = ImmutableMap.<Status, NodeMetadata.Status> builder().put(
|
||||||
Status.OFF, NodeState.SUSPENDED).put(Status.ON, NodeState.RUNNING).put(Status.RESOLVED, NodeState.PENDING)
|
Status.OFF, NodeMetadata.Status.SUSPENDED).put(Status.ON, NodeMetadata.Status.RUNNING).put(Status.RESOLVED, NodeMetadata.Status.PENDING)
|
||||||
.put(Status.ERROR, NodeState.ERROR).put(Status.UNRECOGNIZED, NodeState.UNRECOGNIZED).put(Status.DEPLOYED,
|
.put(Status.ERROR, NodeMetadata.Status.ERROR).put(Status.UNRECOGNIZED, NodeMetadata.Status.UNRECOGNIZED).put(Status.DEPLOYED,
|
||||||
NodeState.PENDING).put(Status.INCONSISTENT, NodeState.PENDING).put(Status.UNKNOWN,
|
NodeMetadata.Status.PENDING).put(Status.INCONSISTENT, NodeMetadata.Status.PENDING).put(Status.UNKNOWN,
|
||||||
NodeState.UNRECOGNIZED).put(Status.MIXED, NodeState.PENDING).put(Status.WAITING_FOR_INPUT,
|
NodeMetadata.Status.UNRECOGNIZED).put(Status.MIXED, NodeMetadata.Status.PENDING).put(Status.WAITING_FOR_INPUT,
|
||||||
NodeState.PENDING).put(Status.SUSPENDED, NodeState.SUSPENDED).put(Status.UNRESOLVED,
|
NodeMetadata.Status.PENDING).put(Status.SUSPENDED, NodeMetadata.Status.SUSPENDED).put(Status.UNRESOLVED,
|
||||||
NodeState.PENDING).build();
|
NodeMetadata.Status.PENDING).build();
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
@Provides
|
@Provides
|
||||||
protected Map<Status, NodeState> provideVAppStatusToNodeState() {
|
protected Map<Status, NodeMetadata.Status> provideVAppStatusToNodeStatus() {
|
||||||
return VAPPSTATUS_TO_NODESTATE;
|
return VAPPSTATUS_TO_NODESTATE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,6 @@ import javax.inject.Singleton;
|
||||||
import org.jclouds.compute.domain.Hardware;
|
import org.jclouds.compute.domain.Hardware;
|
||||||
import org.jclouds.compute.domain.NodeMetadata;
|
import org.jclouds.compute.domain.NodeMetadata;
|
||||||
import org.jclouds.compute.domain.NodeMetadataBuilder;
|
import org.jclouds.compute.domain.NodeMetadataBuilder;
|
||||||
import org.jclouds.compute.domain.NodeState;
|
|
||||||
import org.jclouds.compute.functions.GroupNamingConvention;
|
import org.jclouds.compute.functions.GroupNamingConvention;
|
||||||
import org.jclouds.domain.Credentials;
|
import org.jclouds.domain.Credentials;
|
||||||
import org.jclouds.logging.Logger;
|
import org.jclouds.logging.Logger;
|
||||||
|
@ -55,19 +54,19 @@ public class VAppToNodeMetadata implements Function<VApp, NodeMetadata> {
|
||||||
|
|
||||||
protected final FindLocationForResource findLocationForResourceInVDC;
|
protected final FindLocationForResource findLocationForResourceInVDC;
|
||||||
protected final Function<VApp, Hardware> hardwareForVApp;
|
protected final Function<VApp, Hardware> hardwareForVApp;
|
||||||
protected final Map<Status, NodeState> vAppStatusToNodeState;
|
protected final Map<Status, NodeMetadata.Status> vAppStatusToNodeStatus;
|
||||||
protected final Map<String, Credentials> credentialStore;
|
protected final Map<String, Credentials> credentialStore;
|
||||||
protected final GroupNamingConvention nodeNamingConvention;
|
protected final GroupNamingConvention nodeNamingConvention;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
protected VAppToNodeMetadata(Map<Status, NodeState> vAppStatusToNodeState, Map<String, Credentials> credentialStore,
|
protected VAppToNodeMetadata(Map<Status, NodeMetadata.Status> vAppStatusToNodeStatus, Map<String, Credentials> credentialStore,
|
||||||
FindLocationForResource findLocationForResourceInVDC, Function<VApp, Hardware> hardwareForVApp,
|
FindLocationForResource findLocationForResourceInVDC, Function<VApp, Hardware> hardwareForVApp,
|
||||||
GroupNamingConvention.Factory namingConvention) {
|
GroupNamingConvention.Factory namingConvention) {
|
||||||
this.nodeNamingConvention = checkNotNull(namingConvention, "namingConvention").createWithoutPrefix();
|
this.nodeNamingConvention = checkNotNull(namingConvention, "namingConvention").createWithoutPrefix();
|
||||||
this.hardwareForVApp = checkNotNull(hardwareForVApp, "hardwareForVApp");
|
this.hardwareForVApp = checkNotNull(hardwareForVApp, "hardwareForVApp");
|
||||||
this.findLocationForResourceInVDC = checkNotNull(findLocationForResourceInVDC, "findLocationForResourceInVDC");
|
this.findLocationForResourceInVDC = checkNotNull(findLocationForResourceInVDC, "findLocationForResourceInVDC");
|
||||||
this.credentialStore = checkNotNull(credentialStore, "credentialStore");
|
this.credentialStore = checkNotNull(credentialStore, "credentialStore");
|
||||||
this.vAppStatusToNodeState = checkNotNull(vAppStatusToNodeState, "vAppStatusToNodeState");
|
this.vAppStatusToNodeStatus = checkNotNull(vAppStatusToNodeStatus, "vAppStatusToNodeStatus");
|
||||||
}
|
}
|
||||||
|
|
||||||
public NodeMetadata apply(VApp from) {
|
public NodeMetadata apply(VApp from) {
|
||||||
|
@ -80,7 +79,7 @@ public class VAppToNodeMetadata implements Function<VApp, NodeMetadata> {
|
||||||
builder.group(nodeNamingConvention.groupInUniqueNameOrNull(from.getName()));
|
builder.group(nodeNamingConvention.groupInUniqueNameOrNull(from.getName()));
|
||||||
builder.operatingSystem(toComputeOs(from, null));
|
builder.operatingSystem(toComputeOs(from, null));
|
||||||
builder.hardware(hardwareForVApp.apply(from));
|
builder.hardware(hardwareForVApp.apply(from));
|
||||||
builder.state(vAppStatusToNodeState.get(from.getStatus()));
|
builder.status(vAppStatusToNodeStatus.get(from.getStatus()));
|
||||||
Set<String> addresses = getIpsFromVApp(from);
|
Set<String> addresses = getIpsFromVApp(from);
|
||||||
builder.publicAddresses(filter(addresses, not(IsPrivateIPAddress.INSTANCE)));
|
builder.publicAddresses(filter(addresses, not(IsPrivateIPAddress.INSTANCE)));
|
||||||
builder.privateAddresses(filter(addresses, IsPrivateIPAddress.INSTANCE));
|
builder.privateAddresses(filter(addresses, IsPrivateIPAddress.INSTANCE));
|
||||||
|
|
|
@ -31,7 +31,6 @@ import org.jclouds.cim.xml.ResourceAllocationSettingDataHandler;
|
||||||
import org.jclouds.collect.Memoized;
|
import org.jclouds.collect.Memoized;
|
||||||
import org.jclouds.compute.domain.Hardware;
|
import org.jclouds.compute.domain.Hardware;
|
||||||
import org.jclouds.compute.domain.NodeMetadata;
|
import org.jclouds.compute.domain.NodeMetadata;
|
||||||
import org.jclouds.compute.domain.NodeState;
|
|
||||||
import org.jclouds.domain.Credentials;
|
import org.jclouds.domain.Credentials;
|
||||||
import org.jclouds.domain.Location;
|
import org.jclouds.domain.Location;
|
||||||
import org.jclouds.domain.LocationBuilder;
|
import org.jclouds.domain.LocationBuilder;
|
||||||
|
@ -101,7 +100,7 @@ public class VAppToNodeMetadataTest {
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
@Singleton
|
@Singleton
|
||||||
@Provides
|
@Provides
|
||||||
protected Map<Status, NodeState> provideVAppStatusToNodeState() {
|
protected Map<Status, NodeMetadata.Status> provideVAppStatusToNodeStatus() {
|
||||||
return VCloudComputeServiceDependenciesModule.VAPPSTATUS_TO_NODESTATE;
|
return VCloudComputeServiceDependenciesModule.VAPPSTATUS_TO_NODESTATE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,9 +25,9 @@ import static org.jclouds.trmk.vcloud_0_8.options.AddInternetServiceOptions.Buil
|
||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
@ -36,7 +36,7 @@ import javax.inject.Provider;
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
import org.jclouds.compute.ComputeServiceAdapter;
|
import org.jclouds.compute.ComputeServiceAdapter;
|
||||||
import org.jclouds.compute.domain.NodeState;
|
import org.jclouds.compute.domain.NodeMetadata;
|
||||||
import org.jclouds.compute.reference.ComputeServiceConstants;
|
import org.jclouds.compute.reference.ComputeServiceConstants;
|
||||||
import org.jclouds.domain.Credentials;
|
import org.jclouds.domain.Credentials;
|
||||||
import org.jclouds.domain.LoginCredentials;
|
import org.jclouds.domain.LoginCredentials;
|
||||||
|
@ -72,18 +72,18 @@ public class TerremarkVCloudComputeClient {
|
||||||
protected final TerremarkVCloudClient client;
|
protected final TerremarkVCloudClient client;
|
||||||
protected final Provider<String> passwordGenerator;
|
protected final Provider<String> passwordGenerator;
|
||||||
protected final InternetServiceAndPublicIpAddressSupplier internetServiceAndPublicIpAddressSupplier;
|
protected final InternetServiceAndPublicIpAddressSupplier internetServiceAndPublicIpAddressSupplier;
|
||||||
protected final Map<Status, NodeState> vAppStatusToNodeState;
|
protected final Map<Status, NodeMetadata.Status> vAppStatusToNodeStatus;
|
||||||
protected final Predicate<URI> taskTester;
|
protected final Predicate<URI> taskTester;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
protected TerremarkVCloudComputeClient(TerremarkVCloudClient client,
|
protected TerremarkVCloudComputeClient(TerremarkVCloudClient client,
|
||||||
@Named("PASSWORD") Provider<String> passwordGenerator, Predicate<URI> successTester,
|
@Named("PASSWORD") Provider<String> passwordGenerator, Predicate<URI> successTester,
|
||||||
Map<Status, NodeState> vAppStatusToNodeState, Map<String, Credentials> credentialStore,
|
Map<Status, NodeMetadata.Status> vAppStatusToNodeStatus, Map<String, Credentials> credentialStore,
|
||||||
InternetServiceAndPublicIpAddressSupplier internetServiceAndPublicIpAddressSupplier) {
|
InternetServiceAndPublicIpAddressSupplier internetServiceAndPublicIpAddressSupplier) {
|
||||||
this.client = client;
|
this.client = client;
|
||||||
this.passwordGenerator = passwordGenerator;
|
this.passwordGenerator = passwordGenerator;
|
||||||
this.internetServiceAndPublicIpAddressSupplier = internetServiceAndPublicIpAddressSupplier;
|
this.internetServiceAndPublicIpAddressSupplier = internetServiceAndPublicIpAddressSupplier;
|
||||||
this.vAppStatusToNodeState = vAppStatusToNodeState;
|
this.vAppStatusToNodeStatus = vAppStatusToNodeStatus;
|
||||||
this.taskTester = successTester;
|
this.taskTester = successTester;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,6 @@ import org.jclouds.compute.ComputeService;
|
||||||
import org.jclouds.compute.config.BaseComputeServiceContextModule;
|
import org.jclouds.compute.config.BaseComputeServiceContextModule;
|
||||||
import org.jclouds.compute.domain.Image;
|
import org.jclouds.compute.domain.Image;
|
||||||
import org.jclouds.compute.domain.NodeMetadata;
|
import org.jclouds.compute.domain.NodeMetadata;
|
||||||
import org.jclouds.compute.domain.NodeState;
|
|
||||||
import org.jclouds.compute.domain.OperatingSystem;
|
import org.jclouds.compute.domain.OperatingSystem;
|
||||||
import org.jclouds.compute.options.TemplateOptions;
|
import org.jclouds.compute.options.TemplateOptions;
|
||||||
import org.jclouds.compute.strategy.PopulateDefaultLoginCredentialsForImageStrategy;
|
import org.jclouds.compute.strategy.PopulateDefaultLoginCredentialsForImageStrategy;
|
||||||
|
@ -60,15 +59,16 @@ import com.google.inject.TypeLiteral;
|
||||||
public class TerremarkVCloudComputeServiceContextModule extends BaseComputeServiceContextModule {
|
public class TerremarkVCloudComputeServiceContextModule extends BaseComputeServiceContextModule {
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
public static final Map<Status, NodeState> VAPPSTATUS_TO_NODESTATE = ImmutableMap.<Status, NodeState> builder()
|
public static final Map<Status, NodeMetadata.Status> VAPPSTATUS_TO_NODESTATE = ImmutableMap
|
||||||
.put(Status.OFF, NodeState.SUSPENDED).put(Status.ON, NodeState.RUNNING)
|
.<Status, NodeMetadata.Status> builder().put(Status.OFF, NodeMetadata.Status.SUSPENDED).put(Status.ON,
|
||||||
.put(Status.RESOLVED, NodeState.PENDING).put(Status.UNRECOGNIZED, NodeState.UNRECOGNIZED)
|
NodeMetadata.Status.RUNNING).put(Status.RESOLVED, NodeMetadata.Status.PENDING).put(
|
||||||
.put(Status.DEPLOYED, NodeState.PENDING).put(Status.SUSPENDED, NodeState.SUSPENDED)
|
Status.UNRECOGNIZED, NodeMetadata.Status.UNRECOGNIZED).put(Status.DEPLOYED,
|
||||||
.put(Status.UNRESOLVED, NodeState.PENDING).build();
|
NodeMetadata.Status.PENDING).put(Status.SUSPENDED, NodeMetadata.Status.SUSPENDED).put(
|
||||||
|
Status.UNRESOLVED, NodeMetadata.Status.PENDING).build();
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
@Provides
|
@Provides
|
||||||
protected Map<Status, NodeState> provideVAppStatusToNodeState() {
|
protected Map<Status, NodeMetadata.Status> provideVAppStatusToNodeStatus() {
|
||||||
return VAPPSTATUS_TO_NODESTATE;
|
return VAPPSTATUS_TO_NODESTATE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,6 @@ import org.jclouds.compute.domain.CIMOperatingSystem;
|
||||||
import org.jclouds.compute.domain.Image;
|
import org.jclouds.compute.domain.Image;
|
||||||
import org.jclouds.compute.domain.NodeMetadata;
|
import org.jclouds.compute.domain.NodeMetadata;
|
||||||
import org.jclouds.compute.domain.NodeMetadataBuilder;
|
import org.jclouds.compute.domain.NodeMetadataBuilder;
|
||||||
import org.jclouds.compute.domain.NodeState;
|
|
||||||
import org.jclouds.compute.domain.OperatingSystem;
|
import org.jclouds.compute.domain.OperatingSystem;
|
||||||
import org.jclouds.compute.functions.GroupNamingConvention;
|
import org.jclouds.compute.functions.GroupNamingConvention;
|
||||||
import org.jclouds.compute.util.ComputeServiceUtils;
|
import org.jclouds.compute.util.ComputeServiceUtils;
|
||||||
|
@ -57,12 +56,12 @@ public class VAppToNodeMetadata implements Function<VApp, NodeMetadata> {
|
||||||
protected final Supplier<Set<? extends Image>> images;
|
protected final Supplier<Set<? extends Image>> images;
|
||||||
protected final FindLocationForResource findLocationForResourceInVDC;
|
protected final FindLocationForResource findLocationForResourceInVDC;
|
||||||
protected final HardwareForVCloudExpressVApp hardwareForVCloudExpressVApp;
|
protected final HardwareForVCloudExpressVApp hardwareForVCloudExpressVApp;
|
||||||
protected final Map<Status, NodeState> vAppStatusToNodeState;
|
protected final Map<Status, NodeMetadata.Status> vAppStatusToNodeStatus;
|
||||||
protected final GroupNamingConvention nodeNamingConvention;
|
protected final GroupNamingConvention nodeNamingConvention;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
protected VAppToNodeMetadata(TerremarkVCloudComputeClient computeClient, Map<String, Credentials> credentialStore,
|
protected VAppToNodeMetadata(TerremarkVCloudComputeClient computeClient, Map<String, Credentials> credentialStore,
|
||||||
Map<Status, NodeState> vAppStatusToNodeState, HardwareForVCloudExpressVApp hardwareForVCloudExpressVApp,
|
Map<Status, NodeMetadata.Status> vAppStatusToNodeStatus, HardwareForVCloudExpressVApp hardwareForVCloudExpressVApp,
|
||||||
FindLocationForResource findLocationForResourceInVDC, @Memoized Supplier<Set<? extends Image>> images,
|
FindLocationForResource findLocationForResourceInVDC, @Memoized Supplier<Set<? extends Image>> images,
|
||||||
GroupNamingConvention.Factory namingConvention) {
|
GroupNamingConvention.Factory namingConvention) {
|
||||||
this.nodeNamingConvention = checkNotNull(namingConvention, "namingConvention").createWithoutPrefix();
|
this.nodeNamingConvention = checkNotNull(namingConvention, "namingConvention").createWithoutPrefix();
|
||||||
|
@ -71,7 +70,7 @@ public class VAppToNodeMetadata implements Function<VApp, NodeMetadata> {
|
||||||
this.findLocationForResourceInVDC = checkNotNull(findLocationForResourceInVDC, "findLocationForResourceInVDC");
|
this.findLocationForResourceInVDC = checkNotNull(findLocationForResourceInVDC, "findLocationForResourceInVDC");
|
||||||
this.credentialStore = checkNotNull(credentialStore, "credentialStore");
|
this.credentialStore = checkNotNull(credentialStore, "credentialStore");
|
||||||
this.computeClient = checkNotNull(computeClient, "computeClient");
|
this.computeClient = checkNotNull(computeClient, "computeClient");
|
||||||
this.vAppStatusToNodeState = checkNotNull(vAppStatusToNodeState, "vAppStatusToNodeState");
|
this.vAppStatusToNodeStatus = checkNotNull(vAppStatusToNodeStatus, "vAppStatusToNodeStatus");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -97,7 +96,7 @@ public class VAppToNodeMetadata implements Function<VApp, NodeMetadata> {
|
||||||
builder.operatingSystem(osBuilder.build());
|
builder.operatingSystem(osBuilder.build());
|
||||||
}
|
}
|
||||||
builder.hardware(hardwareForVCloudExpressVApp.apply(from));
|
builder.hardware(hardwareForVCloudExpressVApp.apply(from));
|
||||||
builder.state(vAppStatusToNodeState.get(from.getStatus()));
|
builder.status(vAppStatusToNodeStatus.get(from.getStatus()));
|
||||||
builder.publicAddresses(computeClient.getPublicAddresses(from.getHref()));
|
builder.publicAddresses(computeClient.getPublicAddresses(from.getHref()));
|
||||||
builder.privateAddresses(computeClient.getPrivateAddresses(from.getHref()));
|
builder.privateAddresses(computeClient.getPrivateAddresses(from.getHref()));
|
||||||
builder.group(nodeNamingConvention.groupInUniqueNameOrNull(from.getName()));
|
builder.group(nodeNamingConvention.groupInUniqueNameOrNull(from.getName()));
|
||||||
|
|
|
@ -32,7 +32,7 @@ import java.util.Map;
|
||||||
import javax.inject.Provider;
|
import javax.inject.Provider;
|
||||||
|
|
||||||
import org.jclouds.compute.ComputeServiceAdapter.NodeAndInitialCredentials;
|
import org.jclouds.compute.ComputeServiceAdapter.NodeAndInitialCredentials;
|
||||||
import org.jclouds.compute.domain.NodeState;
|
import org.jclouds.compute.domain.NodeMetadata;
|
||||||
import org.jclouds.domain.Credentials;
|
import org.jclouds.domain.Credentials;
|
||||||
import org.jclouds.domain.LoginCredentials;
|
import org.jclouds.domain.LoginCredentials;
|
||||||
import org.jclouds.trmk.vcloud_0_8.TerremarkVCloudClient;
|
import org.jclouds.trmk.vcloud_0_8.TerremarkVCloudClient;
|
||||||
|
@ -86,7 +86,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<Status, NodeState> vAppStatusToNodeState = createMock(Map.class);
|
Map<Status, NodeMetadata.Status> vAppStatusToNodeStatus = createMock(Map.class);
|
||||||
|
|
||||||
TerremarkVCloudComputeClient computeClient = new TerremarkVCloudComputeClient(client,
|
TerremarkVCloudComputeClient computeClient = new TerremarkVCloudComputeClient(client,
|
||||||
new Provider<String>() {
|
new Provider<String>() {
|
||||||
|
@ -96,7 +96,7 @@ public class TerremarkVCloudComputeClientTest {
|
||||||
return "password";
|
return "password";
|
||||||
}
|
}
|
||||||
|
|
||||||
}, successTester, vAppStatusToNodeState, credentialStore, supplier);
|
}, successTester, vAppStatusToNodeStatus, credentialStore, supplier);
|
||||||
|
|
||||||
replay(vdc);
|
replay(vdc);
|
||||||
replay(template);
|
replay(template);
|
||||||
|
@ -105,7 +105,7 @@ public class TerremarkVCloudComputeClientTest {
|
||||||
replay(client);
|
replay(client);
|
||||||
replay(successTester);
|
replay(successTester);
|
||||||
replay(notFoundTester);
|
replay(notFoundTester);
|
||||||
replay(vAppStatusToNodeState);
|
replay(vAppStatusToNodeStatus);
|
||||||
|
|
||||||
NodeAndInitialCredentials<VApp> response = computeClient.startAndReturnCredentials(vdcURI, templateURI, "name", new InstantiateVAppTemplateOptions());
|
NodeAndInitialCredentials<VApp> response = computeClient.startAndReturnCredentials(vdcURI, templateURI, "name", new InstantiateVAppTemplateOptions());
|
||||||
|
|
||||||
|
@ -120,6 +120,6 @@ public class TerremarkVCloudComputeClientTest {
|
||||||
verify(client);
|
verify(client);
|
||||||
verify(successTester);
|
verify(successTester);
|
||||||
verify(notFoundTester);
|
verify(notFoundTester);
|
||||||
verify(vAppStatusToNodeState);
|
verify(vAppStatusToNodeStatus);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ import java.net.URI;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.jclouds.compute.domain.NodeMetadata;
|
import org.jclouds.compute.domain.NodeMetadata;
|
||||||
import org.jclouds.compute.domain.NodeState;
|
import org.jclouds.compute.domain.NodeMetadata.Status;
|
||||||
import org.jclouds.compute.strategy.ListNodesStrategy;
|
import org.jclouds.compute.strategy.ListNodesStrategy;
|
||||||
import org.jclouds.domain.Credentials;
|
import org.jclouds.domain.Credentials;
|
||||||
import org.jclouds.trmk.vcloud_0_8.compute.domain.OrgAndName;
|
import org.jclouds.trmk.vcloud_0_8.compute.domain.OrgAndName;
|
||||||
|
@ -94,7 +94,7 @@ public class CleanupOrphanKeysTest {
|
||||||
expect((Object) strategy.listNodes.listDetailsOnNodesMatching(parentLocationId(orgTag.getOrg().toASCIIString())))
|
expect((Object) strategy.listNodes.listDetailsOnNodesMatching(parentLocationId(orgTag.getOrg().toASCIIString())))
|
||||||
.andReturn(ImmutableSet.of(nodeMetadata));
|
.andReturn(ImmutableSet.of(nodeMetadata));
|
||||||
expect(nodeMetadata.getGroup()).andReturn(orgTag.getName()).atLeastOnce();
|
expect(nodeMetadata.getGroup()).andReturn(orgTag.getName()).atLeastOnce();
|
||||||
expect(nodeMetadata.getState()).andReturn(NodeState.RUNNING).atLeastOnce();
|
expect(nodeMetadata.getStatus()).andReturn(Status.RUNNING).atLeastOnce();
|
||||||
expectCleanupCredentialStore(strategy, nodeMetadata);
|
expectCleanupCredentialStore(strategy, nodeMetadata);
|
||||||
|
|
||||||
// replay mocks
|
// replay mocks
|
||||||
|
@ -121,7 +121,7 @@ public class CleanupOrphanKeysTest {
|
||||||
expect((Object) strategy.listNodes.listDetailsOnNodesMatching(parentLocationId(orgTag.getOrg().toASCIIString())))
|
expect((Object) strategy.listNodes.listDetailsOnNodesMatching(parentLocationId(orgTag.getOrg().toASCIIString())))
|
||||||
.andReturn(ImmutableSet.of(nodeMetadata));
|
.andReturn(ImmutableSet.of(nodeMetadata));
|
||||||
expect(nodeMetadata.getGroup()).andReturn(orgTag.getName()).atLeastOnce();
|
expect(nodeMetadata.getGroup()).andReturn(orgTag.getName()).atLeastOnce();
|
||||||
expect(nodeMetadata.getState()).andReturn(NodeState.TERMINATED).atLeastOnce();
|
expect(nodeMetadata.getStatus()).andReturn(Status.TERMINATED).atLeastOnce();
|
||||||
strategy.deleteKeyPair.execute(orgTag);
|
strategy.deleteKeyPair.execute(orgTag);
|
||||||
expectCleanupCredentialStore(strategy, nodeMetadata);
|
expectCleanupCredentialStore(strategy, nodeMetadata);
|
||||||
|
|
||||||
|
|
|
@ -243,41 +243,41 @@ Here's an example of creating and running a small linux node in the group webser
|
||||||
([#^ComputeService compute pred command #^RunScriptOptions options]
|
([#^ComputeService compute pred command #^RunScriptOptions options]
|
||||||
(.runScriptOnNodesMatching compute (to-predicate pred) command options)))
|
(.runScriptOnNodesMatching compute (to-predicate pred) command options)))
|
||||||
|
|
||||||
(defmacro state-predicate [node state]
|
(defmacro status-predicate [node status]
|
||||||
`(= (.getState ~node)
|
`(= (.getStatus ~node)
|
||||||
(. org.jclouds.compute.domain.NodeState ~state)))
|
(. org.jclouds.compute.domain.NodeMetadata$Status ~status)))
|
||||||
|
|
||||||
(defn pending?
|
(defn pending?
|
||||||
"Predicate for the node being in transition"
|
"Predicate for the node being in transition"
|
||||||
[#^NodeMetadata node]
|
[#^NodeMetadata node]
|
||||||
(state-predicate node PENDING))
|
(status-predicate node PENDING))
|
||||||
|
|
||||||
(defn running?
|
(defn running?
|
||||||
"Predicate for the node being available for requests."
|
"Predicate for the node being available for requests."
|
||||||
[#^NodeMetadata node]
|
[#^NodeMetadata node]
|
||||||
(state-predicate node RUNNING))
|
(status-predicate node RUNNING))
|
||||||
|
|
||||||
(defn terminated?
|
(defn terminated?
|
||||||
"Predicate for the node being halted."
|
"Predicate for the node being halted."
|
||||||
[#^NodeMetadata node]
|
[#^NodeMetadata node]
|
||||||
(or
|
(or
|
||||||
(= node nil)
|
(= node nil)
|
||||||
(state-predicate node TERMINATED)))
|
(status-predicate node TERMINATED)))
|
||||||
|
|
||||||
(defn suspended?
|
(defn suspended?
|
||||||
"Predicate for the node being suspended."
|
"Predicate for the node being suspended."
|
||||||
[#^NodeMetadata node]
|
[#^NodeMetadata node]
|
||||||
(state-predicate node SUSPENDED))
|
(status-predicate node SUSPENDED))
|
||||||
|
|
||||||
(defn error-state?
|
(defn error-status?
|
||||||
"Predicate for the node being in an error state."
|
"Predicate for the node being in an error status."
|
||||||
[#^NodeMetadata node]
|
[#^NodeMetadata node]
|
||||||
(state-predicate node ERROR))
|
(status-predicate node ERROR))
|
||||||
|
|
||||||
(defn unrecognized-state?
|
(defn unrecognized-status?
|
||||||
"Predicate for the node being in an unrecognized state."
|
"Predicate for the node being in an unrecognized status."
|
||||||
[#^NodeMetadata node]
|
[#^NodeMetadata node]
|
||||||
(state-predicate node UNRECOGNIZED))
|
(status-predicate node UNRECOGNIZED))
|
||||||
|
|
||||||
(defn in-group?
|
(defn in-group?
|
||||||
"Returns a predicate fn which returns true if the node is in the given group, false otherwise"
|
"Returns a predicate fn which returns true if the node is in the given group, false otherwise"
|
||||||
|
@ -317,7 +317,7 @@ Here's an example of creating and running a small linux node in the group webser
|
||||||
(define-accessors Template image hardware location options)
|
(define-accessors Template image hardware location options)
|
||||||
(define-accessors Image version os-family os-description architecture)
|
(define-accessors Image version os-family os-description architecture)
|
||||||
(define-accessors Hardware processors ram volumes)
|
(define-accessors Hardware processors ram volumes)
|
||||||
(define-accessors NodeMetadata "node" credentials hardware state group)
|
(define-accessors NodeMetadata "node" credentials hardware status group)
|
||||||
|
|
||||||
(def
|
(def
|
||||||
^{:doc "TemplateBuilder functions" :private true}
|
^{:doc "TemplateBuilder functions" :private true}
|
||||||
|
|
|
@ -29,7 +29,7 @@ import org.jclouds.compute.domain.NodeMetadata;
|
||||||
import org.jclouds.compute.predicates.AtomicNodeRunning;
|
import org.jclouds.compute.predicates.AtomicNodeRunning;
|
||||||
import org.jclouds.compute.predicates.AtomicNodeSuspended;
|
import org.jclouds.compute.predicates.AtomicNodeSuspended;
|
||||||
import org.jclouds.compute.predicates.ScriptStatusReturnsZero;
|
import org.jclouds.compute.predicates.ScriptStatusReturnsZero;
|
||||||
import org.jclouds.compute.predicates.TrueIfNullOrTerminatedRefreshAndDoubleCheckOnFalse;
|
import org.jclouds.compute.predicates.AtomicNodeTerminated;
|
||||||
import org.jclouds.compute.predicates.ScriptStatusReturnsZero.CommandUsingClient;
|
import org.jclouds.compute.predicates.ScriptStatusReturnsZero.CommandUsingClient;
|
||||||
import org.jclouds.compute.reference.ComputeServiceConstants.Timeouts;
|
import org.jclouds.compute.reference.ComputeServiceConstants.Timeouts;
|
||||||
import org.jclouds.predicates.RetryablePredicate;
|
import org.jclouds.predicates.RetryablePredicate;
|
||||||
|
@ -56,7 +56,7 @@ public class ComputeServiceTimeoutsModule extends AbstractModule {
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
@Named("NODE_TERMINATED")
|
@Named("NODE_TERMINATED")
|
||||||
protected Predicate<AtomicReference<NodeMetadata>> serverTerminated(TrueIfNullOrTerminatedRefreshAndDoubleCheckOnFalse stateTerminated, Timeouts timeouts) {
|
protected Predicate<AtomicReference<NodeMetadata>> serverTerminated(AtomicNodeTerminated stateTerminated, Timeouts timeouts) {
|
||||||
return timeouts.nodeTerminated == 0 ? stateTerminated : new RetryablePredicate<AtomicReference<NodeMetadata>>(stateTerminated,
|
return timeouts.nodeTerminated == 0 ? stateTerminated : new RetryablePredicate<AtomicReference<NodeMetadata>>(stateTerminated,
|
||||||
timeouts.nodeTerminated);
|
timeouts.nodeTerminated);
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
/**
|
||||||
|
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||||
|
* contributor license agreements. See the NOTICE file
|
||||||
|
* distributed with this work for additional information
|
||||||
|
* regarding copyright ownership. jclouds licenses this file
|
||||||
|
* to you under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance
|
||||||
|
* with the License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
package org.jclouds.compute.domain;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
public interface ComputeMetadataIncludingStatus<S extends Enum<S>> extends ComputeMetadata {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* status of the resource
|
||||||
|
* @since 1.5
|
||||||
|
*/
|
||||||
|
public S getStatus();
|
||||||
|
|
||||||
|
}
|
|
@ -32,7 +32,36 @@ import com.google.inject.ImplementedBy;
|
||||||
* @author Ivan Meredith
|
* @author Ivan Meredith
|
||||||
*/
|
*/
|
||||||
@ImplementedBy(NodeMetadataImpl.class)
|
@ImplementedBy(NodeMetadataImpl.class)
|
||||||
public interface NodeMetadata extends ComputeMetadata {
|
public interface NodeMetadata extends ComputeMetadataIncludingStatus<NodeMetadata.Status> {
|
||||||
|
|
||||||
|
public static enum Status {
|
||||||
|
/**
|
||||||
|
* The node is in transition
|
||||||
|
*/
|
||||||
|
PENDING,
|
||||||
|
/**
|
||||||
|
* The node is visible, and in the process of being deleted.
|
||||||
|
*/
|
||||||
|
TERMINATED,
|
||||||
|
/**
|
||||||
|
* The node is deployed, but suspended or stopped.
|
||||||
|
*/
|
||||||
|
SUSPENDED,
|
||||||
|
/**
|
||||||
|
* The node is available for requests
|
||||||
|
*/
|
||||||
|
RUNNING,
|
||||||
|
/**
|
||||||
|
* There is an error on the node
|
||||||
|
*/
|
||||||
|
ERROR,
|
||||||
|
/**
|
||||||
|
* The state of the node is unrecognized.
|
||||||
|
*/
|
||||||
|
UNRECOGNIZED;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <h4>note</h4> hostname is something that is set in the operating system image, so this value,
|
* <h4>note</h4> hostname is something that is set in the operating system image, so this value,
|
||||||
* if present, cannot be guaranteed on images not directly controlled by the cloud provider.
|
* if present, cannot be guaranteed on images not directly controlled by the cloud provider.
|
||||||
|
@ -75,8 +104,12 @@ public interface NodeMetadata extends ComputeMetadata {
|
||||||
OperatingSystem getOperatingSystem();
|
OperatingSystem getOperatingSystem();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Current State of the node
|
* Current State of the node; replaced by {@link #getStatus()}
|
||||||
|
* <h3>Note</h3>
|
||||||
|
* will be removed in jclouds 1.6!
|
||||||
|
* @see #getStatus()
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
NodeState getState();
|
NodeState getState();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -24,11 +24,10 @@ import java.net.URI;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.jclouds.compute.domain.NodeMetadata.Status;
|
||||||
import org.jclouds.compute.domain.internal.NodeMetadataImpl;
|
import org.jclouds.compute.domain.internal.NodeMetadataImpl;
|
||||||
import org.jclouds.domain.Credentials;
|
|
||||||
import org.jclouds.domain.Location;
|
import org.jclouds.domain.Location;
|
||||||
import org.jclouds.domain.LoginCredentials;
|
import org.jclouds.domain.LoginCredentials;
|
||||||
import org.jclouds.domain.LoginCredentials.Builder;
|
|
||||||
import org.jclouds.javax.annotation.Nullable;
|
import org.jclouds.javax.annotation.Nullable;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
@ -38,7 +37,7 @@ import com.google.common.collect.Sets;
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
public class NodeMetadataBuilder extends ComputeMetadataBuilder {
|
public class NodeMetadataBuilder extends ComputeMetadataBuilder {
|
||||||
private NodeState state;
|
private Status status;
|
||||||
private Set<String> publicAddresses = Sets.newLinkedHashSet();
|
private Set<String> publicAddresses = Sets.newLinkedHashSet();
|
||||||
private Set<String> privateAddresses = Sets.newLinkedHashSet();
|
private Set<String> privateAddresses = Sets.newLinkedHashSet();
|
||||||
@Nullable
|
@Nullable
|
||||||
|
@ -64,8 +63,19 @@ public class NodeMetadataBuilder extends ComputeMetadataBuilder {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public NodeMetadataBuilder status(Status status) {
|
||||||
|
this.status = checkNotNull(status, "status");
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <h3>Note</h3>
|
||||||
|
* will be removed in jclouds 1.6!
|
||||||
|
* @see #status
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
public NodeMetadataBuilder state(NodeState state) {
|
public NodeMetadataBuilder state(NodeState state) {
|
||||||
this.state = checkNotNull(state, "state");
|
this.status = checkNotNull(state, "state").toStatus();
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,39 +89,11 @@ public class NodeMetadataBuilder extends ComputeMetadataBuilder {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* <h4>will be removed in jclouds 1.4.0</h4>
|
|
||||||
*
|
|
||||||
* @see LoginCredentials#shouldAuthenticateSudo
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public NodeMetadataBuilder adminPassword(@Nullable String adminPassword) {
|
|
||||||
if (adminPassword != null) {
|
|
||||||
Builder builder = credentials != null ? credentials.toBuilder() : LoginCredentials
|
|
||||||
.builder();
|
|
||||||
builder.authenticateSudo(true);
|
|
||||||
builder.password(adminPassword);
|
|
||||||
this.credentials = builder.build();
|
|
||||||
}
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <h4>will be removed in jclouds 1.4.0</h4>
|
|
||||||
*
|
|
||||||
* @see #credentials(LoginCredentials)
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public NodeMetadataBuilder credentials(@Nullable Credentials credentials) {
|
|
||||||
return credentials(LoginCredentials.fromCredentials(credentials));
|
|
||||||
}
|
|
||||||
|
|
||||||
public NodeMetadataBuilder credentials(@Nullable LoginCredentials credentials) {
|
public NodeMetadataBuilder credentials(@Nullable LoginCredentials credentials) {
|
||||||
this.credentials = credentials;
|
this.credentials = credentials;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public NodeMetadataBuilder group(@Nullable String group) {
|
public NodeMetadataBuilder group(@Nullable String group) {
|
||||||
this.group = group;
|
this.group = group;
|
||||||
return this;
|
return this;
|
||||||
|
@ -180,14 +162,14 @@ public class NodeMetadataBuilder extends ComputeMetadataBuilder {
|
||||||
@Override
|
@Override
|
||||||
public NodeMetadata build() {
|
public NodeMetadata build() {
|
||||||
return new NodeMetadataImpl(providerId, name, id, location, uri, userMetadata, tags, group, hardware, imageId,
|
return new NodeMetadataImpl(providerId, name, id, location, uri, userMetadata, tags, group, hardware, imageId,
|
||||||
os, state, loginPort, publicAddresses, privateAddresses, credentials, hostname);
|
os, status, loginPort, publicAddresses, privateAddresses, credentials, hostname);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static NodeMetadataBuilder fromNodeMetadata(NodeMetadata node) {
|
public static NodeMetadataBuilder fromNodeMetadata(NodeMetadata node) {
|
||||||
return new NodeMetadataBuilder().providerId(node.getProviderId()).name(node.getName()).id(node.getId()).location(
|
return new NodeMetadataBuilder().providerId(node.getProviderId()).name(node.getName()).id(node.getId()).location(
|
||||||
node.getLocation()).uri(node.getUri()).userMetadata(node.getUserMetadata()).tags(node.getTags()).group(
|
node.getLocation()).uri(node.getUri()).userMetadata(node.getUserMetadata()).tags(node.getTags()).group(
|
||||||
node.getGroup()).hardware(node.getHardware()).imageId(node.getImageId()).operatingSystem(
|
node.getGroup()).hardware(node.getHardware()).imageId(node.getImageId()).operatingSystem(
|
||||||
node.getOperatingSystem()).state(node.getState()).loginPort(node.getLoginPort()).publicAddresses(
|
node.getOperatingSystem()).status(node.getStatus()).loginPort(node.getLoginPort()).publicAddresses(
|
||||||
node.getPublicAddresses()).privateAddresses(node.getPrivateAddresses()).credentials(node.getCredentials()).hostname(node.getHostname());
|
node.getPublicAddresses()).privateAddresses(node.getPrivateAddresses()).credentials(node.getCredentials()).hostname(node.getHostname());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,35 +18,84 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.compute.domain;
|
package org.jclouds.compute.domain;
|
||||||
|
|
||||||
|
import org.jclouds.compute.domain.NodeMetadata.Status;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Indicates the status of a node
|
* Indicates the status of a node. Replaced by {@link Status}
|
||||||
*
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
|
* @see NodeMetadata#getStatus()
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public enum NodeState {
|
public enum NodeState {
|
||||||
/**
|
/**
|
||||||
* The node is in transition
|
* The node is in transition
|
||||||
|
*
|
||||||
|
* @see Status#PENDING
|
||||||
*/
|
*/
|
||||||
PENDING,
|
PENDING,
|
||||||
/**
|
/**
|
||||||
* The node is visible, and in the process of being deleted.
|
* The node is visible, and in the process of being deleted.
|
||||||
|
*
|
||||||
|
* @see Status#TERMINATED
|
||||||
*/
|
*/
|
||||||
TERMINATED,
|
TERMINATED,
|
||||||
/**
|
/**
|
||||||
* The node is deployed, but suspended or stopped.
|
* The node is deployed, but suspended or stopped.
|
||||||
|
*
|
||||||
|
* @see Status#SUSPENDED
|
||||||
*/
|
*/
|
||||||
SUSPENDED,
|
SUSPENDED,
|
||||||
/**
|
/**
|
||||||
* The node is available for requests
|
* The node is available for requests
|
||||||
|
*
|
||||||
|
* @see Status#RUNNING
|
||||||
*/
|
*/
|
||||||
RUNNING,
|
RUNNING,
|
||||||
/**
|
/**
|
||||||
* There is an error on the node
|
* There is an error on the node
|
||||||
|
*
|
||||||
|
* @see Status#ERROR
|
||||||
*/
|
*/
|
||||||
ERROR,
|
ERROR,
|
||||||
/**
|
/**
|
||||||
* The state of the node is unrecognized.
|
* The state of the node is unrecognized.
|
||||||
|
*
|
||||||
|
* @see Status#UNRECOGNIZED
|
||||||
*/
|
*/
|
||||||
UNRECOGNIZED;
|
UNRECOGNIZED;
|
||||||
|
|
||||||
|
public static NodeState from(Status in) {
|
||||||
|
switch (in) {
|
||||||
|
case PENDING:
|
||||||
|
return PENDING;
|
||||||
|
case TERMINATED:
|
||||||
|
return TERMINATED;
|
||||||
|
case SUSPENDED:
|
||||||
|
return SUSPENDED;
|
||||||
|
case RUNNING:
|
||||||
|
return RUNNING;
|
||||||
|
case ERROR:
|
||||||
|
return ERROR;
|
||||||
|
default:
|
||||||
|
return UNRECOGNIZED;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Status toStatus() {
|
||||||
|
switch (this) {
|
||||||
|
case PENDING:
|
||||||
|
return Status.PENDING;
|
||||||
|
case TERMINATED:
|
||||||
|
return Status.TERMINATED;
|
||||||
|
case SUSPENDED:
|
||||||
|
return Status.SUSPENDED;
|
||||||
|
case RUNNING:
|
||||||
|
return Status.RUNNING;
|
||||||
|
case ERROR:
|
||||||
|
return Status.ERROR;
|
||||||
|
default:
|
||||||
|
return Status.UNRECOGNIZED;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -184,7 +184,13 @@ public class TemplateBuilderSpec implements Serializable {
|
||||||
|
|
||||||
/** Specification; used for toParseableString(). */
|
/** Specification; used for toParseableString(). */
|
||||||
// transient in case people using serializers don't want this to show up
|
// transient in case people using serializers don't want this to show up
|
||||||
protected transient final String specification;
|
protected transient String specification;
|
||||||
|
|
||||||
|
protected TemplateBuilderSpec() {
|
||||||
|
// we want serializers like Gson to work w/o using sun.misc.Unsafe,
|
||||||
|
// prohibited in GAE. This also implies fields are not final.
|
||||||
|
// see http://code.google.com/p/jclouds/issues/detail?spec=925
|
||||||
|
}
|
||||||
|
|
||||||
protected TemplateBuilderSpec(String specification) {
|
protected TemplateBuilderSpec(String specification) {
|
||||||
this.specification = specification;
|
this.specification = specification;
|
||||||
|
|
|
@ -27,12 +27,9 @@ import java.util.Set;
|
||||||
import org.jclouds.compute.domain.ComputeType;
|
import org.jclouds.compute.domain.ComputeType;
|
||||||
import org.jclouds.compute.domain.Hardware;
|
import org.jclouds.compute.domain.Hardware;
|
||||||
import org.jclouds.compute.domain.NodeMetadata;
|
import org.jclouds.compute.domain.NodeMetadata;
|
||||||
import org.jclouds.compute.domain.NodeState;
|
|
||||||
import org.jclouds.compute.domain.OperatingSystem;
|
import org.jclouds.compute.domain.OperatingSystem;
|
||||||
import org.jclouds.domain.Credentials;
|
|
||||||
import org.jclouds.domain.Location;
|
import org.jclouds.domain.Location;
|
||||||
import org.jclouds.domain.LoginCredentials;
|
import org.jclouds.domain.LoginCredentials;
|
||||||
import org.jclouds.domain.LoginCredentials.Builder;
|
|
||||||
import org.jclouds.javax.annotation.Nullable;
|
import org.jclouds.javax.annotation.Nullable;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
@ -46,7 +43,7 @@ public class NodeMetadataImpl extends ComputeMetadataImpl implements NodeMetadat
|
||||||
/** The serialVersionUID */
|
/** The serialVersionUID */
|
||||||
private static final long serialVersionUID = 7924307572338157887L;
|
private static final long serialVersionUID = 7924307572338157887L;
|
||||||
|
|
||||||
private final NodeState state;
|
private final Status status;
|
||||||
private final int loginPort;
|
private final int loginPort;
|
||||||
private final Set<String> publicAddresses;
|
private final Set<String> publicAddresses;
|
||||||
private final Set<String> privateAddresses;
|
private final Set<String> privateAddresses;
|
||||||
|
@ -63,36 +60,9 @@ public class NodeMetadataImpl extends ComputeMetadataImpl implements NodeMetadat
|
||||||
@Nullable
|
@Nullable
|
||||||
private final String hostname;
|
private final String hostname;
|
||||||
|
|
||||||
/**
|
|
||||||
* <h4>will be removed in jclouds 1.4.0</h4>
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public NodeMetadataImpl(String providerId, String name, String id, Location location, URI uri,
|
public NodeMetadataImpl(String providerId, String name, String id, Location location, URI uri,
|
||||||
Map<String, String> userMetadata, Set<String> tags, @Nullable String group, @Nullable Hardware hardware,
|
Map<String, String> userMetadata, Set<String> tags, @Nullable String group, @Nullable Hardware hardware,
|
||||||
@Nullable String imageId, @Nullable OperatingSystem os, NodeState state, int loginPort,
|
@Nullable String imageId, @Nullable OperatingSystem os, Status status, int loginPort,
|
||||||
Iterable<String> publicAddresses, Iterable<String> privateAddresses, @Nullable String adminPassword,
|
|
||||||
@Nullable Credentials credentials, String hostname) {
|
|
||||||
super(ComputeType.NODE, providerId, name, id, location, uri, userMetadata, tags);
|
|
||||||
this.group = group;
|
|
||||||
this.hardware = hardware;
|
|
||||||
this.imageId = imageId;
|
|
||||||
this.os = os;
|
|
||||||
this.state = checkNotNull(state, "state");
|
|
||||||
this.loginPort = loginPort;
|
|
||||||
this.publicAddresses = ImmutableSet.copyOf(checkNotNull(publicAddresses, "publicAddresses"));
|
|
||||||
this.privateAddresses = ImmutableSet.copyOf(checkNotNull(privateAddresses, "privateAddresses"));
|
|
||||||
this.hostname = hostname;
|
|
||||||
Builder builder = LoginCredentials.builder(credentials);
|
|
||||||
if (adminPassword != null) {
|
|
||||||
builder.authenticateSudo(true);
|
|
||||||
builder.password(adminPassword);
|
|
||||||
}
|
|
||||||
this.credentials = builder.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
public NodeMetadataImpl(String providerId, String name, String id, Location location, URI uri,
|
|
||||||
Map<String, String> userMetadata, Set<String> tags, @Nullable String group, @Nullable Hardware hardware,
|
|
||||||
@Nullable String imageId, @Nullable OperatingSystem os, NodeState state, int loginPort,
|
|
||||||
Iterable<String> publicAddresses, Iterable<String> privateAddresses, @Nullable LoginCredentials credentials,
|
Iterable<String> publicAddresses, Iterable<String> privateAddresses, @Nullable LoginCredentials credentials,
|
||||||
String hostname) {
|
String hostname) {
|
||||||
super(ComputeType.NODE, providerId, name, id, location, uri, userMetadata, tags);
|
super(ComputeType.NODE, providerId, name, id, location, uri, userMetadata, tags);
|
||||||
|
@ -100,7 +70,7 @@ public class NodeMetadataImpl extends ComputeMetadataImpl implements NodeMetadat
|
||||||
this.hardware = hardware;
|
this.hardware = hardware;
|
||||||
this.imageId = imageId;
|
this.imageId = imageId;
|
||||||
this.os = os;
|
this.os = os;
|
||||||
this.state = checkNotNull(state, "state");
|
this.status = checkNotNull(status, "status");
|
||||||
this.loginPort = loginPort;
|
this.loginPort = loginPort;
|
||||||
this.publicAddresses = ImmutableSet.copyOf(checkNotNull(publicAddresses, "publicAddresses"));
|
this.publicAddresses = ImmutableSet.copyOf(checkNotNull(publicAddresses, "publicAddresses"));
|
||||||
this.privateAddresses = ImmutableSet.copyOf(checkNotNull(privateAddresses, "privateAddresses"));
|
this.privateAddresses = ImmutableSet.copyOf(checkNotNull(privateAddresses, "privateAddresses"));
|
||||||
|
@ -161,8 +131,17 @@ public class NodeMetadataImpl extends ComputeMetadataImpl implements NodeMetadat
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public NodeState getState() {
|
@Deprecated
|
||||||
return state;
|
public org.jclouds.compute.domain.NodeState getState() {
|
||||||
|
return org.jclouds.compute.domain.NodeState.from(status);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Status getStatus() {
|
||||||
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -201,7 +180,7 @@ public class NodeMetadataImpl extends ComputeMetadataImpl implements NodeMetadat
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "[id=" + getId() + ", providerId=" + getProviderId() + ", group=" + getGroup() + ", name=" + getName()
|
return "[id=" + getId() + ", providerId=" + getProviderId() + ", group=" + getGroup() + ", name=" + getName()
|
||||||
+ ", location=" + getLocation() + ", uri=" + getUri() + ", imageId=" + getImageId() + ", os="
|
+ ", location=" + getLocation() + ", uri=" + getUri() + ", imageId=" + getImageId() + ", os="
|
||||||
+ getOperatingSystem() + ", state=" + getState() + ", loginPort=" + getLoginPort() + ", hostname="
|
+ getOperatingSystem() + ", status=" + getStatus() + ", loginPort=" + getLoginPort() + ", hostname="
|
||||||
+ getHostname() + ", privateAddresses=" + privateAddresses + ", publicAddresses=" + publicAddresses
|
+ getHostname() + ", privateAddresses=" + privateAddresses + ", publicAddresses=" + publicAddresses
|
||||||
+ ", hardware=" + getHardware() + ", loginUser=" + ((credentials != null) ? credentials.identity : null)
|
+ ", hardware=" + getHardware() + ", loginUser=" + ((credentials != null) ? credentials.identity : null)
|
||||||
+ ", userMetadata=" + getUserMetadata() + ", tags=" + tags + "]";
|
+ ", userMetadata=" + getUserMetadata() + ", tags=" + tags + "]";
|
||||||
|
|
|
@ -61,9 +61,9 @@ import org.jclouds.compute.domain.Hardware;
|
||||||
import org.jclouds.compute.domain.Image;
|
import org.jclouds.compute.domain.Image;
|
||||||
import org.jclouds.compute.domain.NodeMetadata;
|
import org.jclouds.compute.domain.NodeMetadata;
|
||||||
import org.jclouds.compute.domain.NodeMetadataBuilder;
|
import org.jclouds.compute.domain.NodeMetadataBuilder;
|
||||||
import org.jclouds.compute.domain.NodeState;
|
|
||||||
import org.jclouds.compute.domain.Template;
|
import org.jclouds.compute.domain.Template;
|
||||||
import org.jclouds.compute.domain.TemplateBuilder;
|
import org.jclouds.compute.domain.TemplateBuilder;
|
||||||
|
import org.jclouds.compute.domain.NodeMetadata.Status;
|
||||||
import org.jclouds.compute.extensions.ImageExtension;
|
import org.jclouds.compute.extensions.ImageExtension;
|
||||||
import org.jclouds.compute.options.RunScriptOptions;
|
import org.jclouds.compute.options.RunScriptOptions;
|
||||||
import org.jclouds.compute.options.TemplateOptions;
|
import org.jclouds.compute.options.TemplateOptions;
|
||||||
|
@ -576,9 +576,9 @@ public class BaseComputeService implements ComputeService {
|
||||||
NodeMetadata node = this.getNodeMetadata(id);
|
NodeMetadata node = this.getNodeMetadata(id);
|
||||||
if (node == null)
|
if (node == null)
|
||||||
throw new NoSuchElementException(id);
|
throw new NoSuchElementException(id);
|
||||||
if (node.getState() != NodeState.RUNNING)
|
if (node.getStatus() != Status.RUNNING)
|
||||||
throw new IllegalStateException("node " + id
|
throw new IllegalStateException("node " + id
|
||||||
+ " needs to be running before executing a script on it. current state: " + node.getState());
|
+ " needs to be running before executing a script on it. current state: " + node.getStatus());
|
||||||
initAdminAccess.visit(runScript);
|
initAdminAccess.visit(runScript);
|
||||||
node = updateNodeWithCredentialsIfPresent(node, options);
|
node = updateNodeWithCredentialsIfPresent(node, options);
|
||||||
ExecResponse response = runScriptOnNodeFactory.create(node, runScript, options).init().call();
|
ExecResponse response = runScriptOnNodeFactory.create(node, runScript, options).init().call();
|
||||||
|
@ -595,9 +595,9 @@ public class BaseComputeService implements ComputeService {
|
||||||
NodeMetadata node = this.getNodeMetadata(id);
|
NodeMetadata node = this.getNodeMetadata(id);
|
||||||
if (node == null)
|
if (node == null)
|
||||||
throw new NoSuchElementException(id);
|
throw new NoSuchElementException(id);
|
||||||
if (node.getState() != NodeState.RUNNING)
|
if (node.getStatus() != Status.RUNNING)
|
||||||
throw new IllegalStateException("node " + id
|
throw new IllegalStateException("node " + id
|
||||||
+ " needs to be running before executing a script on it. current state: " + node.getState());
|
+ " needs to be running before executing a script on it. current state: " + node.getStatus());
|
||||||
initAdminAccess.visit(runScript);
|
initAdminAccess.visit(runScript);
|
||||||
final NodeMetadata node1 = updateNodeWithCredentialsIfPresent(node, options);
|
final NodeMetadata node1 = updateNodeWithCredentialsIfPresent(node, options);
|
||||||
ListenableFuture<ExecResponse> response = runScriptOnNodeFactory.submit(node1, runScript, options);
|
ListenableFuture<ExecResponse> response = runScriptOnNodeFactory.submit(node1, runScript, options);
|
||||||
|
|
|
@ -26,7 +26,7 @@ import java.util.Arrays;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.jclouds.compute.domain.NodeState;
|
import org.jclouds.compute.domain.NodeMetadata.Status;
|
||||||
import org.jclouds.domain.LoginCredentials;
|
import org.jclouds.domain.LoginCredentials;
|
||||||
import org.jclouds.io.Payload;
|
import org.jclouds.io.Payload;
|
||||||
import org.jclouds.scriptbuilder.domain.Statement;
|
import org.jclouds.scriptbuilder.domain.Statement;
|
||||||
|
@ -588,7 +588,7 @@ public class TemplateOptions extends RunScriptOptions implements Cloneable {
|
||||||
*
|
*
|
||||||
* @param blockUntilRunning
|
* @param blockUntilRunning
|
||||||
* (default true) whether to block until the nodes in this template
|
* (default true) whether to block until the nodes in this template
|
||||||
* are in {@link NodeState#RUNNING} state
|
* are in {@link Status#RUNNING} state
|
||||||
*/
|
*/
|
||||||
public TemplateOptions blockUntilRunning(boolean blockUntilRunning) {
|
public TemplateOptions blockUntilRunning(boolean blockUntilRunning) {
|
||||||
this.blockUntilRunning = blockUntilRunning;
|
this.blockUntilRunning = blockUntilRunning;
|
||||||
|
|
|
@ -18,13 +18,14 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.compute.predicates;
|
package org.jclouds.compute.predicates;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
import org.jclouds.compute.domain.NodeState;
|
import org.jclouds.compute.domain.NodeMetadata.Status;
|
||||||
|
import org.jclouds.compute.predicates.internal.RefreshNodeAndDoubleCheckOnFailUnlessStatusInvalid;
|
||||||
import org.jclouds.compute.strategy.GetNodeMetadataStrategy;
|
import org.jclouds.compute.strategy.GetNodeMetadataStrategy;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.inject.Inject;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -33,10 +34,10 @@ import com.google.inject.Inject;
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Singleton
|
@Singleton
|
||||||
public class AtomicNodeRunning extends RefreshAndDoubleCheckOnFailUnlessStateInvalid {
|
public class AtomicNodeRunning extends RefreshNodeAndDoubleCheckOnFailUnlessStatusInvalid {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public AtomicNodeRunning(GetNodeMetadataStrategy client) {
|
public AtomicNodeRunning(GetNodeMetadataStrategy client) {
|
||||||
super(NodeState.RUNNING, ImmutableSet.of(NodeState.ERROR, NodeState.TERMINATED), client);
|
super(Status.RUNNING, ImmutableSet.of(Status.ERROR, Status.TERMINATED), client);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,13 +18,14 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.compute.predicates;
|
package org.jclouds.compute.predicates;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
import org.jclouds.compute.domain.NodeState;
|
import org.jclouds.compute.domain.NodeMetadata.Status;
|
||||||
|
import org.jclouds.compute.predicates.internal.RefreshNodeAndDoubleCheckOnFailUnlessStatusInvalid;
|
||||||
import org.jclouds.compute.strategy.GetNodeMetadataStrategy;
|
import org.jclouds.compute.strategy.GetNodeMetadataStrategy;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.inject.Inject;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -33,10 +34,10 @@ import com.google.inject.Inject;
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Singleton
|
@Singleton
|
||||||
public class AtomicNodeSuspended extends RefreshAndDoubleCheckOnFailUnlessStateInvalid {
|
public class AtomicNodeSuspended extends RefreshNodeAndDoubleCheckOnFailUnlessStatusInvalid {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public AtomicNodeSuspended(GetNodeMetadataStrategy client) {
|
public AtomicNodeSuspended(GetNodeMetadataStrategy client) {
|
||||||
super(NodeState.SUSPENDED, ImmutableSet.of(NodeState.ERROR, NodeState.TERMINATED), client);
|
super(Status.SUSPENDED, ImmutableSet.of(Status.ERROR, Status.TERMINATED), client);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,16 +18,13 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.compute.predicates;
|
package org.jclouds.compute.predicates;
|
||||||
|
|
||||||
import java.util.concurrent.atomic.AtomicReference;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
|
||||||
|
|
||||||
import org.jclouds.compute.domain.NodeMetadata;
|
import org.jclouds.compute.domain.NodeMetadata;
|
||||||
import org.jclouds.compute.domain.NodeState;
|
import org.jclouds.compute.domain.NodeMetadata.Status;
|
||||||
|
import org.jclouds.compute.predicates.internal.TrueIfNullOrDeletedRefreshAndDoubleCheckOnFalse;
|
||||||
import org.jclouds.compute.strategy.GetNodeMetadataStrategy;
|
import org.jclouds.compute.strategy.GetNodeMetadataStrategy;
|
||||||
import org.jclouds.logging.Logger;
|
|
||||||
|
|
||||||
import com.google.common.base.Predicate;
|
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -35,35 +32,20 @@ import com.google.inject.Inject;
|
||||||
*
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
public class TrueIfNullOrTerminatedRefreshAndDoubleCheckOnFalse implements Predicate<AtomicReference<NodeMetadata>> {
|
public class AtomicNodeTerminated extends TrueIfNullOrDeletedRefreshAndDoubleCheckOnFalse<NodeMetadata.Status, NodeMetadata> {
|
||||||
|
|
||||||
private final GetNodeMetadataStrategy client;
|
private final GetNodeMetadataStrategy client;
|
||||||
|
|
||||||
@Resource
|
|
||||||
protected Logger logger = Logger.NULL;
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public TrueIfNullOrTerminatedRefreshAndDoubleCheckOnFalse(GetNodeMetadataStrategy client) {
|
public AtomicNodeTerminated(GetNodeMetadataStrategy client) {
|
||||||
this.client = client;
|
super(Status.TERMINATED);
|
||||||
|
this.client = checkNotNull(client, "client");
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean apply(AtomicReference<NodeMetadata> atomicNode) {
|
@Override
|
||||||
NodeMetadata node = atomicNode.get();
|
protected NodeMetadata refreshOrNull(NodeMetadata resource) {
|
||||||
if (checkState(node))
|
if (resource == null || resource.getId() == null)
|
||||||
return true;
|
return null;
|
||||||
node = refresh(node);
|
return client.getNode(resource.getId());
|
||||||
atomicNode.set(node);
|
|
||||||
return checkState(node);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean checkState(NodeMetadata node) {
|
|
||||||
if (node == null)
|
|
||||||
return true;
|
|
||||||
logger.trace("%s: looking for node state %s: currently: %s", node.getId(), NodeState.TERMINATED, node.getState());
|
|
||||||
return node.getState() == NodeState.TERMINATED;
|
|
||||||
}
|
|
||||||
|
|
||||||
private NodeMetadata refresh(NodeMetadata node) {
|
|
||||||
return client.getNode(node.getId());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -24,7 +24,7 @@ import java.util.Set;
|
||||||
|
|
||||||
import org.jclouds.compute.domain.ComputeMetadata;
|
import org.jclouds.compute.domain.ComputeMetadata;
|
||||||
import org.jclouds.compute.domain.NodeMetadata;
|
import org.jclouds.compute.domain.NodeMetadata;
|
||||||
import org.jclouds.compute.domain.NodeState;
|
import org.jclouds.compute.domain.NodeMetadata.Status;
|
||||||
import org.jclouds.util.Preconditions2;
|
import org.jclouds.util.Preconditions2;
|
||||||
|
|
||||||
import com.google.common.base.Predicate;
|
import com.google.common.base.Predicate;
|
||||||
|
@ -235,7 +235,7 @@ public class NodePredicates {
|
||||||
return new Predicate<NodeMetadata>() {
|
return new Predicate<NodeMetadata>() {
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(NodeMetadata nodeMetadata) {
|
public boolean apply(NodeMetadata nodeMetadata) {
|
||||||
return group.equals(nodeMetadata.getGroup()) && nodeMetadata.getState() == NodeState.RUNNING;
|
return group.equals(nodeMetadata.getGroup()) && nodeMetadata.getStatus() == Status.RUNNING;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -251,7 +251,7 @@ public class NodePredicates {
|
||||||
public static final Predicate<NodeMetadata> RUNNING = new Predicate<NodeMetadata>() {
|
public static final Predicate<NodeMetadata> RUNNING = new Predicate<NodeMetadata>() {
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(NodeMetadata nodeMetadata) {
|
public boolean apply(NodeMetadata nodeMetadata) {
|
||||||
return nodeMetadata.getState() == NodeState.RUNNING;
|
return nodeMetadata.getStatus() == Status.RUNNING;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -266,7 +266,7 @@ public class NodePredicates {
|
||||||
public static final Predicate<NodeMetadata> TERMINATED = new Predicate<NodeMetadata>() {
|
public static final Predicate<NodeMetadata> TERMINATED = new Predicate<NodeMetadata>() {
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(NodeMetadata nodeMetadata) {
|
public boolean apply(NodeMetadata nodeMetadata) {
|
||||||
return nodeMetadata.getState() == NodeState.TERMINATED;
|
return nodeMetadata.getStatus() == Status.TERMINATED;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1,90 +0,0 @@
|
||||||
/**
|
|
||||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
|
||||||
* contributor license agreements. See the NOTICE file
|
|
||||||
* distributed with this work for additional information
|
|
||||||
* regarding copyright ownership. jclouds licenses this file
|
|
||||||
* to you under the Apache License, Version 2.0 (the
|
|
||||||
* "License"); you may not use this file except in compliance
|
|
||||||
* with the License. You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing,
|
|
||||||
* software distributed under the License is distributed on an
|
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
||||||
* KIND, either express or implied. See the License for the
|
|
||||||
* specific language governing permissions and limitations
|
|
||||||
* under the License.
|
|
||||||
*/
|
|
||||||
package org.jclouds.compute.predicates;
|
|
||||||
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.concurrent.atomic.AtomicReference;
|
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
|
||||||
import javax.inject.Singleton;
|
|
||||||
|
|
||||||
import org.jclouds.compute.ComputeService;
|
|
||||||
import org.jclouds.compute.domain.NodeMetadata;
|
|
||||||
import org.jclouds.compute.domain.NodeState;
|
|
||||||
import org.jclouds.compute.strategy.GetNodeMetadataStrategy;
|
|
||||||
import org.jclouds.logging.Logger;
|
|
||||||
|
|
||||||
import com.google.common.base.Predicate;
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
|
||||||
import com.google.inject.Inject;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* The point of RefreshAndDoubleCheckOnFailUnlessStateInvalid is to keep an atomic reference to a
|
|
||||||
* node, so as to eliminate a redundant {@link ComputeService#getNodeMetadata} call after the
|
|
||||||
* predicate passes.
|
|
||||||
*
|
|
||||||
* @author Adrian Cole
|
|
||||||
*/
|
|
||||||
@Singleton
|
|
||||||
public class RefreshAndDoubleCheckOnFailUnlessStateInvalid implements Predicate<AtomicReference<NodeMetadata>> {
|
|
||||||
|
|
||||||
private final GetNodeMetadataStrategy client;
|
|
||||||
private final NodeState intended;
|
|
||||||
private final Set<NodeState> invalids;
|
|
||||||
@Resource
|
|
||||||
protected Logger logger = Logger.NULL;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
public RefreshAndDoubleCheckOnFailUnlessStateInvalid(NodeState intended, GetNodeMetadataStrategy client) {
|
|
||||||
this(intended, ImmutableSet.of(NodeState.ERROR), client);
|
|
||||||
}
|
|
||||||
|
|
||||||
public RefreshAndDoubleCheckOnFailUnlessStateInvalid(NodeState intended, Set<NodeState> invalids,
|
|
||||||
GetNodeMetadataStrategy client) {
|
|
||||||
this.intended = intended;
|
|
||||||
this.client = client;
|
|
||||||
this.invalids = invalids;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean apply(AtomicReference<NodeMetadata> atomicNode) {
|
|
||||||
NodeMetadata node = atomicNode.get();
|
|
||||||
if (checkState(node))
|
|
||||||
return true;
|
|
||||||
node = refresh(node);
|
|
||||||
atomicNode.set(node);
|
|
||||||
return checkState(node);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean checkState(NodeMetadata node) {
|
|
||||||
if (node == null)
|
|
||||||
return false;
|
|
||||||
logger.trace("%s: looking for node state %s: currently: %s", node.getId(), intended, node.getState());
|
|
||||||
if (invalids.contains(node.getState()))
|
|
||||||
throw new IllegalStateException("node " + node.getId() + " in location " + node.getLocation()
|
|
||||||
+ " is in invalid state " + node.getState());
|
|
||||||
return node.getState() == intended;
|
|
||||||
}
|
|
||||||
|
|
||||||
private NodeMetadata refresh(NodeMetadata node) {
|
|
||||||
if (node == null || node.getId() == null)
|
|
||||||
return null;
|
|
||||||
return client.getNode(node.getId());
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,77 @@
|
||||||
|
/**
|
||||||
|
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||||
|
* contributor license agreements. See the NOTICE file
|
||||||
|
* distributed with this work for additional information
|
||||||
|
* regarding copyright ownership. jclouds licenses this file
|
||||||
|
* to you under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance
|
||||||
|
* with the License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
package org.jclouds.compute.predicates.internal;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
|
import org.jclouds.compute.ComputeService;
|
||||||
|
import org.jclouds.compute.domain.ComputeMetadataIncludingStatus;
|
||||||
|
import org.jclouds.logging.Logger;
|
||||||
|
|
||||||
|
import com.google.common.base.Predicate;
|
||||||
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Keep an atomic reference to a
|
||||||
|
* resource, so as to eliminate a redundant {@link ComputeService#getNodeMetadata} call after the
|
||||||
|
* predicate passes.
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
@Singleton
|
||||||
|
public abstract class RefreshAndDoubleCheckOnFailUnlessStatusInvalid<S extends Enum<S>, C extends ComputeMetadataIncludingStatus<S>> implements Predicate<AtomicReference<C>> {
|
||||||
|
|
||||||
|
private final S intended;
|
||||||
|
private final Set<S> invalids;
|
||||||
|
@Resource
|
||||||
|
protected Logger logger = Logger.NULL;
|
||||||
|
|
||||||
|
public RefreshAndDoubleCheckOnFailUnlessStatusInvalid(S intended, Set<S> invalids) {
|
||||||
|
this.intended = checkNotNull(intended, "intended");
|
||||||
|
this.invalids = ImmutableSet.copyOf(checkNotNull(invalids, "invalids"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean apply(AtomicReference<C> atomicResource) {
|
||||||
|
C resource = atomicResource.get();
|
||||||
|
if (checkStatus(resource))
|
||||||
|
return true;
|
||||||
|
resource = refreshOrNull(resource);
|
||||||
|
atomicResource.set(resource);
|
||||||
|
return checkStatus(resource);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean checkStatus(C resource) {
|
||||||
|
if (resource == null)
|
||||||
|
return false;
|
||||||
|
logger.trace("%s: looking for resource state %s: currently: %s", resource.getId(), intended, resource.getStatus());
|
||||||
|
if (invalids.contains(resource.getStatus()))
|
||||||
|
throw new IllegalStateException("resource " + resource.getId() + " in location " + resource.getLocation()
|
||||||
|
+ " is in invalid status " + resource.getStatus());
|
||||||
|
return resource.getStatus() == intended;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract C refreshOrNull(C resource);
|
||||||
|
}
|
|
@ -0,0 +1,65 @@
|
||||||
|
/**
|
||||||
|
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||||
|
* contributor license agreements. See the NOTICE file
|
||||||
|
* distributed with this work for additional information
|
||||||
|
* regarding copyright ownership. jclouds licenses this file
|
||||||
|
* to you under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance
|
||||||
|
* with the License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
package org.jclouds.compute.predicates.internal;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
|
import org.jclouds.compute.ComputeService;
|
||||||
|
import org.jclouds.compute.domain.NodeMetadata;
|
||||||
|
import org.jclouds.compute.domain.NodeMetadata.Status;
|
||||||
|
import org.jclouds.compute.strategy.GetNodeMetadataStrategy;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
import com.google.inject.Inject;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* The point of RefreshAndDoubleCheckOnFailUnlessStateInvalid is to keep an atomic reference to a
|
||||||
|
* node, so as to eliminate a redundant {@link ComputeService#getNodeMetadata} call after the
|
||||||
|
* predicate passes.
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
@Singleton
|
||||||
|
public class RefreshNodeAndDoubleCheckOnFailUnlessStatusInvalid extends RefreshAndDoubleCheckOnFailUnlessStatusInvalid<NodeMetadata.Status, NodeMetadata> {
|
||||||
|
|
||||||
|
private final GetNodeMetadataStrategy client;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
public RefreshNodeAndDoubleCheckOnFailUnlessStatusInvalid(Status intended, GetNodeMetadataStrategy client) {
|
||||||
|
this(intended, ImmutableSet.of(Status.ERROR), client);
|
||||||
|
}
|
||||||
|
|
||||||
|
public RefreshNodeAndDoubleCheckOnFailUnlessStatusInvalid(Status intended, Set<Status> invalids,
|
||||||
|
GetNodeMetadataStrategy client) {
|
||||||
|
super(intended, invalids);
|
||||||
|
this.client = checkNotNull(client, "client");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected NodeMetadata refreshOrNull(NodeMetadata resource) {
|
||||||
|
if (resource == null || resource.getId() == null)
|
||||||
|
return null;
|
||||||
|
return client.getNode(resource.getId());
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,67 @@
|
||||||
|
/**
|
||||||
|
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||||
|
* contributor license agreements. See the NOTICE file
|
||||||
|
* distributed with this work for additional information
|
||||||
|
* regarding copyright ownership. jclouds licenses this file
|
||||||
|
* to you under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance
|
||||||
|
* with the License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
package org.jclouds.compute.predicates.internal;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
|
import org.jclouds.compute.domain.ComputeMetadataIncludingStatus;
|
||||||
|
import org.jclouds.logging.Logger;
|
||||||
|
|
||||||
|
import com.google.common.base.Predicate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
public abstract class TrueIfNullOrDeletedRefreshAndDoubleCheckOnFalse<S extends Enum<S>, C extends ComputeMetadataIncludingStatus<S>>
|
||||||
|
implements Predicate<AtomicReference<C>> {
|
||||||
|
protected final S deletedStatus;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
protected Logger logger = Logger.NULL;
|
||||||
|
|
||||||
|
protected TrueIfNullOrDeletedRefreshAndDoubleCheckOnFalse(S deletedStatus) {
|
||||||
|
this.deletedStatus = checkNotNull(deletedStatus, "deletedStatus");
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean apply(AtomicReference<C> atomicResource) {
|
||||||
|
C resource = atomicResource.get();
|
||||||
|
if (checkStatus(resource))
|
||||||
|
return true;
|
||||||
|
resource = refreshOrNull(resource);
|
||||||
|
atomicResource.set(resource);
|
||||||
|
return checkStatus(resource);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean checkStatus(C resource) {
|
||||||
|
if (resource == null)
|
||||||
|
return true;
|
||||||
|
logger.trace("%s: looking for resource status %s: currently: %s", resource.getId(), deletedStatus, resource
|
||||||
|
.getStatus());
|
||||||
|
return resource.getStatus() == deletedStatus;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract C refreshOrNull(C resource);
|
||||||
|
|
||||||
|
}
|
|
@ -36,7 +36,7 @@ import org.jclouds.compute.callables.RunScriptOnNode;
|
||||||
import org.jclouds.compute.config.CustomizationResponse;
|
import org.jclouds.compute.config.CustomizationResponse;
|
||||||
import org.jclouds.compute.domain.ExecResponse;
|
import org.jclouds.compute.domain.ExecResponse;
|
||||||
import org.jclouds.compute.domain.NodeMetadata;
|
import org.jclouds.compute.domain.NodeMetadata;
|
||||||
import org.jclouds.compute.domain.NodeState;
|
import org.jclouds.compute.domain.NodeMetadata.Status;
|
||||||
import org.jclouds.compute.options.TemplateOptions;
|
import org.jclouds.compute.options.TemplateOptions;
|
||||||
import org.jclouds.compute.reference.ComputeServiceConstants;
|
import org.jclouds.compute.reference.ComputeServiceConstants;
|
||||||
import org.jclouds.compute.reference.ComputeServiceConstants.Timeouts;
|
import org.jclouds.compute.reference.ComputeServiceConstants.Timeouts;
|
||||||
|
@ -140,17 +140,17 @@ public class CustomizeNodeAndAddToGoodMapOrPutExceptionIntoBadMap implements Cal
|
||||||
} else if (timeWaited < (timeouts.nodeRunning - earlyReturnGrace)) {
|
} else if (timeWaited < (timeouts.nodeRunning - earlyReturnGrace)) {
|
||||||
throw new IllegalStateException(
|
throw new IllegalStateException(
|
||||||
format(
|
format(
|
||||||
"node(%s) didn't achieve the state running, so we couldn't customize; aborting prematurely after %d seconds with final state: %s",
|
"node(%s) didn't achieve the status running, so we couldn't customize; aborting prematurely after %d seconds with final status: %s",
|
||||||
originalId, timeWaited / 1000, node.get().getState()));
|
originalId, timeWaited / 1000, node.get().getStatus()));
|
||||||
} else {
|
} else {
|
||||||
throw new IllegalStateException(
|
throw new IllegalStateException(
|
||||||
format(
|
format(
|
||||||
"node(%s) didn't achieve the state running within %d seconds, so we couldn't customize; final state: %s",
|
"node(%s) didn't achieve the status running within %d seconds, so we couldn't customize; final status: %s",
|
||||||
originalId, timeouts.nodeRunning / 1000, node.get().getState()));
|
originalId, timeouts.nodeRunning / 1000, node.get().getStatus()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (IllegalStateException e) {
|
} catch (IllegalStateException e) {
|
||||||
if (node.get().getState() == NodeState.TERMINATED) {
|
if (node.get().getStatus() == Status.TERMINATED) {
|
||||||
throw new IllegalStateException(format("node(%s) terminated before we could customize", originalId));
|
throw new IllegalStateException(format("node(%s) terminated before we could customize", originalId));
|
||||||
} else {
|
} else {
|
||||||
throw e;
|
throw e;
|
||||||
|
|
|
@ -33,8 +33,8 @@ import org.jclouds.compute.ComputeServiceAdapter.NodeAndInitialCredentials;
|
||||||
import org.jclouds.compute.domain.ComputeMetadata;
|
import org.jclouds.compute.domain.ComputeMetadata;
|
||||||
import org.jclouds.compute.domain.NodeMetadata;
|
import org.jclouds.compute.domain.NodeMetadata;
|
||||||
import org.jclouds.compute.domain.NodeMetadataBuilder;
|
import org.jclouds.compute.domain.NodeMetadataBuilder;
|
||||||
import org.jclouds.compute.domain.NodeState;
|
|
||||||
import org.jclouds.compute.domain.Template;
|
import org.jclouds.compute.domain.Template;
|
||||||
|
import org.jclouds.compute.domain.NodeMetadata.Status;
|
||||||
import org.jclouds.compute.predicates.NodePredicates;
|
import org.jclouds.compute.predicates.NodePredicates;
|
||||||
import org.jclouds.compute.reference.ComputeServiceConstants;
|
import org.jclouds.compute.reference.ComputeServiceConstants;
|
||||||
import org.jclouds.compute.strategy.CreateNodeWithGroupEncodedIntoName;
|
import org.jclouds.compute.strategy.CreateNodeWithGroupEncodedIntoName;
|
||||||
|
@ -127,7 +127,7 @@ public class AdaptingComputeServiceStrategies<N, H, I, L> implements CreateNodeW
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkStateAvailable(NodeMetadata node) {
|
private void checkStateAvailable(NodeMetadata node) {
|
||||||
checkState(node != null && node.getState() != NodeState.TERMINATED, "node %s terminated or unavailable!", node);
|
checkState(node != null && node.getStatus() != Status.TERMINATED, "node %s terminated or unavailable!", node);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -41,8 +41,8 @@ import org.jclouds.Constants;
|
||||||
import org.jclouds.compute.config.CustomizationResponse;
|
import org.jclouds.compute.config.CustomizationResponse;
|
||||||
import org.jclouds.compute.domain.ComputeMetadata;
|
import org.jclouds.compute.domain.ComputeMetadata;
|
||||||
import org.jclouds.compute.domain.NodeMetadata;
|
import org.jclouds.compute.domain.NodeMetadata;
|
||||||
import org.jclouds.compute.domain.NodeState;
|
|
||||||
import org.jclouds.compute.domain.Template;
|
import org.jclouds.compute.domain.Template;
|
||||||
|
import org.jclouds.compute.domain.NodeMetadata.Status;
|
||||||
import org.jclouds.compute.functions.GroupNamingConvention;
|
import org.jclouds.compute.functions.GroupNamingConvention;
|
||||||
import org.jclouds.compute.reference.ComputeServiceConstants;
|
import org.jclouds.compute.reference.ComputeServiceConstants;
|
||||||
import org.jclouds.compute.strategy.CreateNodeWithGroupEncodedIntoName;
|
import org.jclouds.compute.strategy.CreateNodeWithGroupEncodedIntoName;
|
||||||
|
@ -79,7 +79,7 @@ public class CreateNodesWithGroupEncodedIntoNameThenAddToSet implements CreateNo
|
||||||
logger.debug(">> adding node location(%s) name(%s) image(%s) hardware(%s)", template.getLocation().getId(),
|
logger.debug(">> adding node location(%s) name(%s) image(%s) hardware(%s)", template.getLocation().getId(),
|
||||||
name, template.getImage().getProviderId(), template.getHardware().getProviderId());
|
name, template.getImage().getProviderId(), template.getHardware().getProviderId());
|
||||||
node = addNodeWithGroupStrategy.createNodeWithGroupEncodedIntoName(group, name, template);
|
node = addNodeWithGroupStrategy.createNodeWithGroupEncodedIntoName(group, name, template);
|
||||||
logger.debug("<< %s node(%s)", node.getState(), node.getId());
|
logger.debug("<< %s node(%s)", node.getStatus(), node.getId());
|
||||||
return new AtomicReference<NodeMetadata>(node);
|
return new AtomicReference<NodeMetadata>(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -133,7 +133,7 @@ public class CreateNodesWithGroupEncodedIntoNameThenAddToSet implements CreateNo
|
||||||
* to the jclouds {@link NodeMetadata} object. This call directly precedes customization, such as
|
* to the jclouds {@link NodeMetadata} object. This call directly precedes customization, such as
|
||||||
* executing scripts.
|
* executing scripts.
|
||||||
*
|
*
|
||||||
* </p> The outcome of this operation does not imply the node is {@link NodeState#RUNNING
|
* </p> The outcome of this operation does not imply the node is {@link Status#RUNNING
|
||||||
* running}. If you want to insert logic after the node is created, yet before an attempt to
|
* running}. If you want to insert logic after the node is created, yet before an attempt to
|
||||||
* customize the node, then append your behaviour to this method.
|
* customize the node, then append your behaviour to this method.
|
||||||
*
|
*
|
||||||
|
@ -162,7 +162,7 @@ public class CreateNodesWithGroupEncodedIntoNameThenAddToSet implements CreateNo
|
||||||
* @param group group the node belongs to
|
* @param group group the node belongs to
|
||||||
* @param name generated name of the node
|
* @param name generated name of the node
|
||||||
* @param template user-specified template
|
* @param template user-specified template
|
||||||
* @return node that is created, yet not necessarily in {@link NodeState#RUNNING}
|
* @return node that is created, yet not necessarily in {@link Status#RUNNING}
|
||||||
*/
|
*/
|
||||||
protected Future<AtomicReference<NodeMetadata>> createNodeInGroupWithNameAndTemplate(String group, String name,
|
protected Future<AtomicReference<NodeMetadata>> createNodeInGroupWithNameAndTemplate(String group, String name,
|
||||||
Template template) {
|
Template template) {
|
||||||
|
|
|
@ -36,10 +36,10 @@ import org.jclouds.compute.domain.Image;
|
||||||
import org.jclouds.compute.domain.ImageBuilder;
|
import org.jclouds.compute.domain.ImageBuilder;
|
||||||
import org.jclouds.compute.domain.NodeMetadata;
|
import org.jclouds.compute.domain.NodeMetadata;
|
||||||
import org.jclouds.compute.domain.NodeMetadataBuilder;
|
import org.jclouds.compute.domain.NodeMetadataBuilder;
|
||||||
import org.jclouds.compute.domain.NodeState;
|
|
||||||
import org.jclouds.compute.domain.OperatingSystem;
|
import org.jclouds.compute.domain.OperatingSystem;
|
||||||
import org.jclouds.compute.domain.OsFamily;
|
import org.jclouds.compute.domain.OsFamily;
|
||||||
import org.jclouds.compute.domain.Template;
|
import org.jclouds.compute.domain.Template;
|
||||||
|
import org.jclouds.compute.domain.NodeMetadata.Status;
|
||||||
import org.jclouds.domain.Location;
|
import org.jclouds.domain.Location;
|
||||||
import org.jclouds.domain.LoginCredentials;
|
import org.jclouds.domain.LoginCredentials;
|
||||||
import org.jclouds.location.suppliers.all.JustProvider;
|
import org.jclouds.location.suppliers.all.JustProvider;
|
||||||
|
@ -84,13 +84,13 @@ public class StubComputeServiceAdapter implements JCloudsNativeComputeServiceAda
|
||||||
this.osToVersionMap = osToVersionMap;
|
this.osToVersionMap = osToVersionMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setStateOnNode(NodeState state, NodeMetadata node) {
|
protected void setStateOnNode(Status status, NodeMetadata node) {
|
||||||
nodes.put(node.getId(), NodeMetadataBuilder.fromNodeMetadata(node).state(state).build());
|
nodes.put(node.getId(), NodeMetadataBuilder.fromNodeMetadata(node).status(status).build());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setStateOnNodeAfterDelay(final NodeState state, final NodeMetadata node, final long millis) {
|
protected void setStateOnNodeAfterDelay(final Status status, final NodeMetadata node, final long millis) {
|
||||||
if (millis == 0l)
|
if (millis == 0l)
|
||||||
setStateOnNode(state, node);
|
setStateOnNode(status, node);
|
||||||
else
|
else
|
||||||
ioThreads.execute(new Runnable() {
|
ioThreads.execute(new Runnable() {
|
||||||
|
|
||||||
|
@ -101,7 +101,7 @@ public class StubComputeServiceAdapter implements JCloudsNativeComputeServiceAda
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
Throwables.propagate(e);
|
Throwables.propagate(e);
|
||||||
}
|
}
|
||||||
setStateOnNode(state, node);
|
setStateOnNode(status, node);
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -120,13 +120,13 @@ public class StubComputeServiceAdapter implements JCloudsNativeComputeServiceAda
|
||||||
builder.location(location.get());
|
builder.location(location.get());
|
||||||
builder.imageId(template.getImage().getId());
|
builder.imageId(template.getImage().getId());
|
||||||
builder.operatingSystem(template.getImage().getOperatingSystem());
|
builder.operatingSystem(template.getImage().getOperatingSystem());
|
||||||
builder.state(NodeState.PENDING);
|
builder.status(Status.PENDING);
|
||||||
builder.publicAddresses(ImmutableSet.<String> of(publicIpPrefix + id));
|
builder.publicAddresses(ImmutableSet.<String> of(publicIpPrefix + id));
|
||||||
builder.privateAddresses(ImmutableSet.<String> of(privateIpPrefix + id));
|
builder.privateAddresses(ImmutableSet.<String> of(privateIpPrefix + id));
|
||||||
builder.credentials(LoginCredentials.builder().user("root").password(passwordPrefix + id).build());
|
builder.credentials(LoginCredentials.builder().user("root").password(passwordPrefix + id).build());
|
||||||
NodeMetadata node = builder.build();
|
NodeMetadata node = builder.build();
|
||||||
nodes.put(node.getId(), node);
|
nodes.put(node.getId(), node);
|
||||||
setStateOnNodeAfterDelay(NodeState.RUNNING, node, 100);
|
setStateOnNodeAfterDelay(Status.RUNNING, node, 100);
|
||||||
return new NodeWithInitialCredentials(node);
|
return new NodeWithInitialCredentials(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -176,8 +176,8 @@ public class StubComputeServiceAdapter implements JCloudsNativeComputeServiceAda
|
||||||
NodeMetadata node = nodes.get(id);
|
NodeMetadata node = nodes.get(id);
|
||||||
if (node == null)
|
if (node == null)
|
||||||
return;
|
return;
|
||||||
setStateOnNodeAfterDelay(NodeState.PENDING, node, 0);
|
setStateOnNodeAfterDelay(Status.PENDING, node, 0);
|
||||||
setStateOnNodeAfterDelay(NodeState.TERMINATED, node, 50);
|
setStateOnNodeAfterDelay(Status.TERMINATED, node, 50);
|
||||||
ioThreads.execute(new Runnable() {
|
ioThreads.execute(new Runnable() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -199,8 +199,8 @@ public class StubComputeServiceAdapter implements JCloudsNativeComputeServiceAda
|
||||||
NodeMetadata node = nodes.get(id);
|
NodeMetadata node = nodes.get(id);
|
||||||
if (node == null)
|
if (node == null)
|
||||||
throw new ResourceNotFoundException("node not found: " + id);
|
throw new ResourceNotFoundException("node not found: " + id);
|
||||||
setStateOnNode(NodeState.PENDING, node);
|
setStateOnNode(Status.PENDING, node);
|
||||||
setStateOnNodeAfterDelay(NodeState.RUNNING, node, 50);
|
setStateOnNodeAfterDelay(Status.RUNNING, node, 50);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -208,12 +208,12 @@ public class StubComputeServiceAdapter implements JCloudsNativeComputeServiceAda
|
||||||
NodeMetadata node = nodes.get(id);
|
NodeMetadata node = nodes.get(id);
|
||||||
if (node == null)
|
if (node == null)
|
||||||
throw new ResourceNotFoundException("node not found: " + id);
|
throw new ResourceNotFoundException("node not found: " + id);
|
||||||
if (node.getState() == NodeState.RUNNING)
|
if (node.getStatus() == Status.RUNNING)
|
||||||
return;
|
return;
|
||||||
if (node.getState() != NodeState.SUSPENDED)
|
if (node.getStatus() != Status.SUSPENDED)
|
||||||
throw new IllegalStateException("to resume a node, it must be in suspended state, not: " + node.getState());
|
throw new IllegalStateException("to resume a node, it must be in suspended status, not: " + node.getStatus());
|
||||||
setStateOnNode(NodeState.PENDING, node);
|
setStateOnNode(Status.PENDING, node);
|
||||||
setStateOnNodeAfterDelay(NodeState.RUNNING, node, 50);
|
setStateOnNodeAfterDelay(Status.RUNNING, node, 50);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -221,11 +221,11 @@ public class StubComputeServiceAdapter implements JCloudsNativeComputeServiceAda
|
||||||
NodeMetadata node = nodes.get(id);
|
NodeMetadata node = nodes.get(id);
|
||||||
if (node == null)
|
if (node == null)
|
||||||
throw new ResourceNotFoundException("node not found: " + id);
|
throw new ResourceNotFoundException("node not found: " + id);
|
||||||
if (node.getState() == NodeState.SUSPENDED)
|
if (node.getStatus() == Status.SUSPENDED)
|
||||||
return;
|
return;
|
||||||
if (node.getState() != NodeState.RUNNING)
|
if (node.getStatus() != Status.RUNNING)
|
||||||
throw new IllegalStateException("to suspend a node, it must be in running state, not: " + node.getState());
|
throw new IllegalStateException("to suspend a node, it must be in running status, not: " + node.getStatus());
|
||||||
setStateOnNode(NodeState.PENDING, node);
|
setStateOnNode(Status.PENDING, node);
|
||||||
setStateOnNodeAfterDelay(NodeState.SUSPENDED, node, 50);
|
setStateOnNodeAfterDelay(Status.SUSPENDED, node, 50);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -29,9 +29,9 @@ import javax.inject.Singleton;
|
||||||
|
|
||||||
import org.jclouds.compute.domain.Hardware;
|
import org.jclouds.compute.domain.Hardware;
|
||||||
import org.jclouds.compute.domain.NodeMetadata;
|
import org.jclouds.compute.domain.NodeMetadata;
|
||||||
import org.jclouds.compute.domain.NodeState;
|
|
||||||
import org.jclouds.compute.domain.Processor;
|
import org.jclouds.compute.domain.Processor;
|
||||||
import org.jclouds.compute.domain.Volume;
|
import org.jclouds.compute.domain.Volume;
|
||||||
|
import org.jclouds.compute.domain.NodeMetadata.Status;
|
||||||
import org.jclouds.compute.domain.internal.VolumeImpl;
|
import org.jclouds.compute.domain.internal.VolumeImpl;
|
||||||
import org.jclouds.predicates.SocketOpen;
|
import org.jclouds.predicates.SocketOpen;
|
||||||
import org.jclouds.rest.annotations.Identity;
|
import org.jclouds.rest.annotations.Identity;
|
||||||
|
@ -133,7 +133,7 @@ public class StubComputeServiceDependenciesModule extends AbstractModule {
|
||||||
return false;
|
return false;
|
||||||
String id = input.getHostText().replace(publicIpPrefix, "");
|
String id = input.getHostText().replace(publicIpPrefix, "");
|
||||||
NodeMetadata node = nodes.get(id);
|
NodeMetadata node = nodes.get(id);
|
||||||
return node != null && node.getState() == NodeState.RUNNING;
|
return node != null && node.getStatus() == Status.RUNNING;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,7 @@ import org.jclouds.compute.config.ComputeServiceProperties;
|
||||||
import org.jclouds.compute.domain.ExecResponse;
|
import org.jclouds.compute.domain.ExecResponse;
|
||||||
import org.jclouds.compute.domain.NodeMetadata;
|
import org.jclouds.compute.domain.NodeMetadata;
|
||||||
import org.jclouds.compute.domain.NodeMetadataBuilder;
|
import org.jclouds.compute.domain.NodeMetadataBuilder;
|
||||||
import org.jclouds.compute.domain.NodeState;
|
import org.jclouds.compute.domain.NodeMetadata.Status;
|
||||||
import org.jclouds.compute.options.RunScriptOptions;
|
import org.jclouds.compute.options.RunScriptOptions;
|
||||||
import org.jclouds.compute.reference.ComputeServiceConstants.Timeouts;
|
import org.jclouds.compute.reference.ComputeServiceConstants.Timeouts;
|
||||||
import org.jclouds.concurrent.MoreExecutors;
|
import org.jclouds.concurrent.MoreExecutors;
|
||||||
|
@ -91,7 +91,7 @@ public class RunScriptOnNodeAsInitScriptUsingSshAndBlockUntilCompleteTest {
|
||||||
@Test(expectedExceptions = IllegalStateException.class)
|
@Test(expectedExceptions = IllegalStateException.class)
|
||||||
public void testWithoutInitThrowsIllegalStateException() {
|
public void testWithoutInitThrowsIllegalStateException() {
|
||||||
Statement command = exec("doFoo");
|
Statement command = exec("doFoo");
|
||||||
NodeMetadata node = new NodeMetadataBuilder().ids("id").state(NodeState.RUNNING).credentials(
|
NodeMetadata node = new NodeMetadataBuilder().ids("id").status(Status.RUNNING).credentials(
|
||||||
new LoginCredentials("tester", "testpassword!", null, false)).build();
|
new LoginCredentials("tester", "testpassword!", null, false)).build();
|
||||||
|
|
||||||
SshClient sshClient = createMock(SshClient.class);
|
SshClient sshClient = createMock(SshClient.class);
|
||||||
|
@ -139,7 +139,7 @@ public class RunScriptOnNodeAsInitScriptUsingSshAndBlockUntilCompleteTest {
|
||||||
*/
|
*/
|
||||||
private void runDefaults(IAnswer<ExecResponse> answerForScriptStatus, int timesForScriptStatus) {
|
private void runDefaults(IAnswer<ExecResponse> answerForScriptStatus, int timesForScriptStatus) {
|
||||||
Statement command = exec("doFoo");
|
Statement command = exec("doFoo");
|
||||||
NodeMetadata node = new NodeMetadataBuilder().ids("id").state(NodeState.RUNNING)
|
NodeMetadata node = new NodeMetadataBuilder().ids("id").status(Status.RUNNING)
|
||||||
.credentials(LoginCredentials.builder().user("tester").password("testpassword!").build()).build();
|
.credentials(LoginCredentials.builder().user("tester").password("testpassword!").build()).build();
|
||||||
|
|
||||||
SshClient sshClient = createMock(SshClient.class);
|
SshClient sshClient = createMock(SshClient.class);
|
||||||
|
@ -193,7 +193,7 @@ public class RunScriptOnNodeAsInitScriptUsingSshAndBlockUntilCompleteTest {
|
||||||
|
|
||||||
public void testWithSudoPassword() {
|
public void testWithSudoPassword() {
|
||||||
Statement command = exec("doFoo");
|
Statement command = exec("doFoo");
|
||||||
NodeMetadata node = new NodeMetadataBuilder().ids("id").state(NodeState.RUNNING).credentials(
|
NodeMetadata node = new NodeMetadataBuilder().ids("id").status(Status.RUNNING).credentials(
|
||||||
new LoginCredentials("tester", "testpassword!", null, true)).build();
|
new LoginCredentials("tester", "testpassword!", null, true)).build();
|
||||||
|
|
||||||
SshClient sshClient = createMock(SshClient.class);
|
SshClient sshClient = createMock(SshClient.class);
|
||||||
|
@ -242,7 +242,7 @@ public class RunScriptOnNodeAsInitScriptUsingSshAndBlockUntilCompleteTest {
|
||||||
|
|
||||||
public void testNotRoot() {
|
public void testNotRoot() {
|
||||||
Statement command = exec("doFoo");
|
Statement command = exec("doFoo");
|
||||||
NodeMetadata node = new NodeMetadataBuilder().ids("id").state(NodeState.RUNNING).credentials(
|
NodeMetadata node = new NodeMetadataBuilder().ids("id").status(Status.RUNNING).credentials(
|
||||||
new LoginCredentials("tester", "testpassword!", null, true)).build();
|
new LoginCredentials("tester", "testpassword!", null, true)).build();
|
||||||
|
|
||||||
SshClient sshClient = createMock(SshClient.class);
|
SshClient sshClient = createMock(SshClient.class);
|
||||||
|
@ -292,7 +292,7 @@ public class RunScriptOnNodeAsInitScriptUsingSshAndBlockUntilCompleteTest {
|
||||||
|
|
||||||
public void testBadReturnCode() {
|
public void testBadReturnCode() {
|
||||||
Statement command = exec("doFoo");
|
Statement command = exec("doFoo");
|
||||||
NodeMetadata node = new NodeMetadataBuilder().ids("badreturncode").state(NodeState.RUNNING).credentials(
|
NodeMetadata node = new NodeMetadataBuilder().ids("badreturncode").status(Status.RUNNING).credentials(
|
||||||
new LoginCredentials("tester", "testpassword!", null, true)).build();
|
new LoginCredentials("tester", "testpassword!", null, true)).build();
|
||||||
|
|
||||||
SshClient sshClient = createMock(SshClient.class);
|
SshClient sshClient = createMock(SshClient.class);
|
||||||
|
|
|
@ -28,7 +28,7 @@ import static org.testng.Assert.assertEquals;
|
||||||
import org.jclouds.compute.domain.ExecResponse;
|
import org.jclouds.compute.domain.ExecResponse;
|
||||||
import org.jclouds.compute.domain.NodeMetadata;
|
import org.jclouds.compute.domain.NodeMetadata;
|
||||||
import org.jclouds.compute.domain.NodeMetadataBuilder;
|
import org.jclouds.compute.domain.NodeMetadataBuilder;
|
||||||
import org.jclouds.compute.domain.NodeState;
|
import org.jclouds.compute.domain.NodeMetadata.Status;
|
||||||
import org.jclouds.compute.options.RunScriptOptions;
|
import org.jclouds.compute.options.RunScriptOptions;
|
||||||
import org.jclouds.domain.LoginCredentials;
|
import org.jclouds.domain.LoginCredentials;
|
||||||
import org.jclouds.scriptbuilder.InitScript;
|
import org.jclouds.scriptbuilder.InitScript;
|
||||||
|
@ -51,7 +51,7 @@ public class RunScriptOnNodeAsInitScriptUsingSshTest {
|
||||||
@Test(expectedExceptions = IllegalStateException.class)
|
@Test(expectedExceptions = IllegalStateException.class)
|
||||||
public void testWithoutInitThrowsIllegalStateException() {
|
public void testWithoutInitThrowsIllegalStateException() {
|
||||||
Statement command = exec("doFoo");
|
Statement command = exec("doFoo");
|
||||||
NodeMetadata node = new NodeMetadataBuilder().ids("id").state(NodeState.RUNNING).credentials(
|
NodeMetadata node = new NodeMetadataBuilder().ids("id").status(Status.RUNNING).credentials(
|
||||||
LoginCredentials.builder().user("tester").password("notalot").build()).build();
|
LoginCredentials.builder().user("tester").password("notalot").build()).build();
|
||||||
|
|
||||||
SshClient sshClient = createMock(SshClient.class);
|
SshClient sshClient = createMock(SshClient.class);
|
||||||
|
@ -67,7 +67,7 @@ public class RunScriptOnNodeAsInitScriptUsingSshTest {
|
||||||
|
|
||||||
public void testDefault() {
|
public void testDefault() {
|
||||||
Statement command = exec("doFoo");
|
Statement command = exec("doFoo");
|
||||||
NodeMetadata node = new NodeMetadataBuilder().ids("id").state(NodeState.RUNNING).credentials(
|
NodeMetadata node = new NodeMetadataBuilder().ids("id").status(Status.RUNNING).credentials(
|
||||||
LoginCredentials.builder().user("tester").password("notalot").build()).build();
|
LoginCredentials.builder().user("tester").password("notalot").build()).build();
|
||||||
|
|
||||||
SshClient sshClient = createMock(SshClient.class);
|
SshClient sshClient = createMock(SshClient.class);
|
||||||
|
@ -108,7 +108,7 @@ public class RunScriptOnNodeAsInitScriptUsingSshTest {
|
||||||
|
|
||||||
public void testWithSudoPassword() {
|
public void testWithSudoPassword() {
|
||||||
Statement command = exec("doFoo");
|
Statement command = exec("doFoo");
|
||||||
NodeMetadata node = new NodeMetadataBuilder().ids("id").state(NodeState.RUNNING).credentials(
|
NodeMetadata node = new NodeMetadataBuilder().ids("id").status(Status.RUNNING).credentials(
|
||||||
LoginCredentials.builder().user("tester").password("notalot").authenticateSudo(true).build()).build();
|
LoginCredentials.builder().user("tester").password("notalot").authenticateSudo(true).build()).build();
|
||||||
|
|
||||||
SshClient sshClient = createMock(SshClient.class);
|
SshClient sshClient = createMock(SshClient.class);
|
||||||
|
@ -150,7 +150,7 @@ public class RunScriptOnNodeAsInitScriptUsingSshTest {
|
||||||
|
|
||||||
public void testNotRoot() {
|
public void testNotRoot() {
|
||||||
Statement command = exec("doFoo");
|
Statement command = exec("doFoo");
|
||||||
NodeMetadata node = new NodeMetadataBuilder().ids("id").state(NodeState.RUNNING).credentials(
|
NodeMetadata node = new NodeMetadataBuilder().ids("id").status(Status.RUNNING).credentials(
|
||||||
LoginCredentials.builder().user("tester").password("notalot").authenticateSudo(true).build()).build();
|
LoginCredentials.builder().user("tester").password("notalot").authenticateSudo(true).build()).build();
|
||||||
|
|
||||||
SshClient sshClient = createMock(SshClient.class);
|
SshClient sshClient = createMock(SshClient.class);
|
||||||
|
|
|
@ -30,7 +30,7 @@ import org.jclouds.compute.config.PersistNodeCredentialsModule.RefreshCredential
|
||||||
import org.jclouds.compute.config.PersistNodeCredentialsModule.RefreshCredentialsForNodeIfRanAdminAccess;
|
import org.jclouds.compute.config.PersistNodeCredentialsModule.RefreshCredentialsForNodeIfRanAdminAccess;
|
||||||
import org.jclouds.compute.domain.NodeMetadata;
|
import org.jclouds.compute.domain.NodeMetadata;
|
||||||
import org.jclouds.compute.domain.NodeMetadataBuilder;
|
import org.jclouds.compute.domain.NodeMetadataBuilder;
|
||||||
import org.jclouds.compute.domain.NodeState;
|
import org.jclouds.compute.domain.NodeMetadata.Status;
|
||||||
import org.jclouds.compute.internal.PersistNodeCredentials;
|
import org.jclouds.compute.internal.PersistNodeCredentials;
|
||||||
import org.jclouds.domain.Credentials;
|
import org.jclouds.domain.Credentials;
|
||||||
import org.jclouds.domain.LoginCredentials;
|
import org.jclouds.domain.LoginCredentials;
|
||||||
|
@ -72,7 +72,7 @@ public class PersistNodeCredentialsTest {
|
||||||
|
|
||||||
replay(credstore);
|
replay(credstore);
|
||||||
|
|
||||||
NodeMetadata node = new NodeMetadataBuilder().ids("id").state(NodeState.RUNNING).build();
|
NodeMetadata node = new NodeMetadataBuilder().ids("id").status(Status.RUNNING).build();
|
||||||
RefreshCredentialsForNodeIfRanAdminAccess fn = new PersistNodeCredentialsModule.RefreshCredentialsForNodeIfRanAdminAccess(
|
RefreshCredentialsForNodeIfRanAdminAccess fn = new PersistNodeCredentialsModule.RefreshCredentialsForNodeIfRanAdminAccess(
|
||||||
credstore, null);
|
credstore, null);
|
||||||
assertEquals(node, fn.apply(node));
|
assertEquals(node, fn.apply(node));
|
||||||
|
@ -90,7 +90,7 @@ public class PersistNodeCredentialsTest {
|
||||||
|
|
||||||
replay(credstore);
|
replay(credstore);
|
||||||
|
|
||||||
NodeMetadata node = new NodeMetadataBuilder().ids("id").state(NodeState.RUNNING).credentials(credentials).build();
|
NodeMetadata node = new NodeMetadataBuilder().ids("id").status(Status.RUNNING).credentials(credentials).build();
|
||||||
RefreshCredentialsForNode fn = new PersistNodeCredentialsModule.RefreshCredentialsForNode(credstore, null);
|
RefreshCredentialsForNode fn = new PersistNodeCredentialsModule.RefreshCredentialsForNode(credstore, null);
|
||||||
assertEquals(node, fn.apply(node));
|
assertEquals(node, fn.apply(node));
|
||||||
|
|
||||||
|
@ -111,7 +111,7 @@ public class PersistNodeCredentialsTest {
|
||||||
replay(statement);
|
replay(statement);
|
||||||
replay(credstore);
|
replay(credstore);
|
||||||
|
|
||||||
NodeMetadata node = new NodeMetadataBuilder().ids("id").state(NodeState.RUNNING).build();
|
NodeMetadata node = new NodeMetadataBuilder().ids("id").status(Status.RUNNING).build();
|
||||||
RefreshCredentialsForNodeIfRanAdminAccess fn = new PersistNodeCredentialsModule.RefreshCredentialsForNodeIfRanAdminAccess(
|
RefreshCredentialsForNodeIfRanAdminAccess fn = new PersistNodeCredentialsModule.RefreshCredentialsForNodeIfRanAdminAccess(
|
||||||
credstore, statement);
|
credstore, statement);
|
||||||
assertEquals(fn.apply(node).getCredentials(), credentials);
|
assertEquals(fn.apply(node).getCredentials(), credentials);
|
||||||
|
@ -136,7 +136,7 @@ public class PersistNodeCredentialsTest {
|
||||||
replay(statement);
|
replay(statement);
|
||||||
replay(credstore);
|
replay(credstore);
|
||||||
|
|
||||||
NodeMetadata node = new NodeMetadataBuilder().ids("id").state(NodeState.RUNNING).build();
|
NodeMetadata node = new NodeMetadataBuilder().ids("id").status(Status.RUNNING).build();
|
||||||
RefreshCredentialsForNode fn = new PersistNodeCredentialsModule.RefreshCredentialsForNode(credstore, statement);
|
RefreshCredentialsForNode fn = new PersistNodeCredentialsModule.RefreshCredentialsForNode(credstore, statement);
|
||||||
assertEquals(fn.apply(node).getCredentials(), credentials);
|
assertEquals(fn.apply(node).getCredentials(), credentials);
|
||||||
|
|
||||||
|
|
|
@ -52,10 +52,10 @@ import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.SortedSet;
|
import java.util.SortedSet;
|
||||||
|
import java.util.Map.Entry;
|
||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
import java.util.concurrent.CancellationException;
|
import java.util.concurrent.CancellationException;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
|
@ -77,10 +77,10 @@ import org.jclouds.compute.domain.ExecResponse;
|
||||||
import org.jclouds.compute.domain.Hardware;
|
import org.jclouds.compute.domain.Hardware;
|
||||||
import org.jclouds.compute.domain.Image;
|
import org.jclouds.compute.domain.Image;
|
||||||
import org.jclouds.compute.domain.NodeMetadata;
|
import org.jclouds.compute.domain.NodeMetadata;
|
||||||
import org.jclouds.compute.domain.NodeState;
|
|
||||||
import org.jclouds.compute.domain.OperatingSystem;
|
import org.jclouds.compute.domain.OperatingSystem;
|
||||||
import org.jclouds.compute.domain.Template;
|
import org.jclouds.compute.domain.Template;
|
||||||
import org.jclouds.compute.domain.TemplateBuilder;
|
import org.jclouds.compute.domain.TemplateBuilder;
|
||||||
|
import org.jclouds.compute.domain.NodeMetadata.Status;
|
||||||
import org.jclouds.compute.options.TemplateOptions;
|
import org.jclouds.compute.options.TemplateOptions;
|
||||||
import org.jclouds.domain.Credentials;
|
import org.jclouds.domain.Credentials;
|
||||||
import org.jclouds.domain.Location;
|
import org.jclouds.domain.Location;
|
||||||
|
@ -468,7 +468,7 @@ public abstract class BaseComputeServiceLiveTest extends BaseComputeServiceConte
|
||||||
assertNotNull(node.getProviderId());
|
assertNotNull(node.getProviderId());
|
||||||
assertNotNull(node.getGroup());
|
assertNotNull(node.getGroup());
|
||||||
assertEquals(node.getGroup(), group);
|
assertEquals(node.getGroup(), group);
|
||||||
assertEquals(node.getState(), NodeState.RUNNING);
|
assertEquals(node.getStatus(), Status.RUNNING);
|
||||||
Credentials fromStore = view.utils().credentialStore().get("node#" + node.getId());
|
Credentials fromStore = view.utils().credentialStore().get("node#" + node.getId());
|
||||||
assertEquals(fromStore, node.getCredentials());
|
assertEquals(fromStore, node.getCredentials());
|
||||||
assert node.getPublicAddresses().size() >= 1 || node.getPrivateAddresses().size() >= 1 : "no ips in" + node;
|
assert node.getPublicAddresses().size() >= 1 || node.getPrivateAddresses().size() >= 1 : "no ips in" + node;
|
||||||
|
@ -505,7 +505,7 @@ public abstract class BaseComputeServiceLiveTest extends BaseComputeServiceConte
|
||||||
assertLocationSameOrChild(metadata.getLocation(), template.getLocation());
|
assertLocationSameOrChild(metadata.getLocation(), template.getLocation());
|
||||||
checkImageIdMatchesTemplate(metadata);
|
checkImageIdMatchesTemplate(metadata);
|
||||||
checkOsMatchesTemplate(metadata);
|
checkOsMatchesTemplate(metadata);
|
||||||
assert (metadata.getState() == NodeState.RUNNING) : metadata;
|
assert (metadata.getStatus() == Status.RUNNING) : metadata;
|
||||||
// due to DHCP the addresses can actually change in-between runs.
|
// due to DHCP the addresses can actually change in-between runs.
|
||||||
assertEquals(metadata.getPrivateAddresses().size(), node.getPrivateAddresses().size(), String.format(
|
assertEquals(metadata.getPrivateAddresses().size(), node.getPrivateAddresses().size(), String.format(
|
||||||
"[%s] didn't match: [%s]", metadata.getPrivateAddresses(), node.getPrivateAddresses().size()));
|
"[%s] didn't match: [%s]", metadata.getPrivateAddresses(), node.getPrivateAddresses().size()));
|
||||||
|
@ -537,9 +537,9 @@ public abstract class BaseComputeServiceLiveTest extends BaseComputeServiceConte
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(NodeMetadata input) {
|
public boolean apply(NodeMetadata input) {
|
||||||
boolean returnVal = input.getState() == NodeState.SUSPENDED;
|
boolean returnVal = input.getStatus() == Status.SUSPENDED;
|
||||||
if (!returnVal)
|
if (!returnVal)
|
||||||
getAnonymousLogger().warning(format("node %s in state %s%n", input.getId(), input.getState()));
|
getAnonymousLogger().warning(format("node %s in state %s%n", input.getId(), input.getStatus()));
|
||||||
return returnVal;
|
return returnVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -571,7 +571,7 @@ public abstract class BaseComputeServiceLiveTest extends BaseComputeServiceConte
|
||||||
// assert nodeMetadata.getImage() != null : node;
|
// assert nodeMetadata.getImage() != null : node;
|
||||||
// user specified name is not always supported
|
// user specified name is not always supported
|
||||||
// assert nodeMetadata.getName() != null : nodeMetadata;
|
// assert nodeMetadata.getName() != null : nodeMetadata;
|
||||||
if (nodeMetadata.getState() == NodeState.RUNNING) {
|
if (nodeMetadata.getStatus() == Status.RUNNING) {
|
||||||
assert nodeMetadata.getPublicAddresses() != null : nodeMetadata;
|
assert nodeMetadata.getPublicAddresses() != null : nodeMetadata;
|
||||||
assert nodeMetadata.getPublicAddresses().size() > 0 || nodeMetadata.getPrivateAddresses().size() > 0 : nodeMetadata;
|
assert nodeMetadata.getPublicAddresses().size() > 0 || nodeMetadata.getPrivateAddresses().size() > 0 : nodeMetadata;
|
||||||
assertNotNull(nodeMetadata.getPrivateAddresses());
|
assertNotNull(nodeMetadata.getPrivateAddresses());
|
||||||
|
@ -585,7 +585,7 @@ public abstract class BaseComputeServiceLiveTest extends BaseComputeServiceConte
|
||||||
Set<? extends NodeMetadata> destroyed = client.destroyNodesMatching(inGroup(group));
|
Set<? extends NodeMetadata> destroyed = client.destroyNodesMatching(inGroup(group));
|
||||||
assertEquals(toDestroy, destroyed.size());
|
assertEquals(toDestroy, destroyed.size());
|
||||||
for (NodeMetadata node : filter(client.listNodesDetailsMatching(all()), inGroup(group))) {
|
for (NodeMetadata node : filter(client.listNodesDetailsMatching(all()), inGroup(group))) {
|
||||||
assert node.getState() == NodeState.TERMINATED : node;
|
assert node.getStatus() == Status.TERMINATED : node;
|
||||||
assert view.utils().credentialStore().get("node#" + node.getId()) == null : "credential should have been null for "
|
assert view.utils().credentialStore().get("node#" + node.getId()) == null : "credential should have been null for "
|
||||||
+ "node#" + node.getId();
|
+ "node#" + node.getId();
|
||||||
}
|
}
|
||||||
|
@ -794,7 +794,7 @@ public abstract class BaseComputeServiceLiveTest extends BaseComputeServiceConte
|
||||||
long time = currentTimeMillis();
|
long time = currentTimeMillis();
|
||||||
Set<? extends NodeMetadata> nodes = client.createNodesInGroup(group, 1, options);
|
Set<? extends NodeMetadata> nodes = client.createNodesInGroup(group, 1, options);
|
||||||
NodeMetadata node = getOnlyElement(nodes);
|
NodeMetadata node = getOnlyElement(nodes);
|
||||||
assert node.getState() != NodeState.RUNNING : node;
|
assert node.getStatus() != Status.RUNNING : node;
|
||||||
long duration = (currentTimeMillis() - time) / 1000;
|
long duration = (currentTimeMillis() - time) / 1000;
|
||||||
assert duration < nonBlockDurationSeconds : format("duration(%d) longer than expected(%d) seconds! ",
|
assert duration < nonBlockDurationSeconds : format("duration(%d) longer than expected(%d) seconds! ",
|
||||||
duration, nonBlockDurationSeconds);
|
duration, nonBlockDurationSeconds);
|
||||||
|
|
|
@ -27,7 +27,7 @@ import java.util.concurrent.atomic.AtomicReference;
|
||||||
|
|
||||||
import org.jclouds.compute.domain.NodeMetadata;
|
import org.jclouds.compute.domain.NodeMetadata;
|
||||||
import org.jclouds.compute.domain.NodeMetadataBuilder;
|
import org.jclouds.compute.domain.NodeMetadataBuilder;
|
||||||
import org.jclouds.compute.domain.NodeState;
|
import org.jclouds.compute.domain.NodeMetadata.Status;
|
||||||
import org.jclouds.compute.strategy.GetNodeMetadataStrategy;
|
import org.jclouds.compute.strategy.GetNodeMetadataStrategy;
|
||||||
import org.jclouds.domain.LoginCredentials;
|
import org.jclouds.domain.LoginCredentials;
|
||||||
import org.testng.Assert;
|
import org.testng.Assert;
|
||||||
|
@ -47,7 +47,7 @@ public class AtomicNodePredicatesTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNoUpdatesAtomicReferenceOnPass() {
|
public void testNoUpdatesAtomicReferenceOnPass() {
|
||||||
NodeMetadata running = new NodeMetadataBuilder().id("myid").state(NodeState.RUNNING).build();
|
NodeMetadata running = new NodeMetadataBuilder().id("myid").status(Status.RUNNING).build();
|
||||||
GetNodeMetadataStrategy computeService = createMock(GetNodeMetadataStrategy.class);
|
GetNodeMetadataStrategy computeService = createMock(GetNodeMetadataStrategy.class);
|
||||||
|
|
||||||
replay(computeService);
|
replay(computeService);
|
||||||
|
@ -63,7 +63,7 @@ public class AtomicNodePredicatesTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRefreshUpdatesAtomicReferenceOnRecheckPending() {
|
public void testRefreshUpdatesAtomicReferenceOnRecheckPending() {
|
||||||
NodeMetadata pending = new NodeMetadataBuilder().id("myid").state(NodeState.PENDING).build();
|
NodeMetadata pending = new NodeMetadataBuilder().id("myid").status(Status.PENDING).build();
|
||||||
GetNodeMetadataStrategy computeService = createMock(GetNodeMetadataStrategy.class);
|
GetNodeMetadataStrategy computeService = createMock(GetNodeMetadataStrategy.class);
|
||||||
|
|
||||||
expect(computeService.getNode("myid")).andReturn(pending);
|
expect(computeService.getNode("myid")).andReturn(pending);
|
||||||
|
@ -82,11 +82,11 @@ public class AtomicNodePredicatesTest {
|
||||||
@Test
|
@Test
|
||||||
public void testRefreshUpdatesAtomicReferenceOnRecheckPendingAcceptsNewCredentials() {
|
public void testRefreshUpdatesAtomicReferenceOnRecheckPendingAcceptsNewCredentials() {
|
||||||
LoginCredentials creds = LoginCredentials.builder().user("user").password("password").build();
|
LoginCredentials creds = LoginCredentials.builder().user("user").password("password").build();
|
||||||
NodeMetadata newNode = new NodeMetadataBuilder().id("myid").state(NodeState.UNRECOGNIZED).credentials(creds).build();
|
NodeMetadata newNode = new NodeMetadataBuilder().id("myid").status(Status.UNRECOGNIZED).credentials(creds).build();
|
||||||
|
|
||||||
LoginCredentials creds2 = LoginCredentials.builder().user("user").password("password2").build();
|
LoginCredentials creds2 = LoginCredentials.builder().user("user").password("password2").build();
|
||||||
|
|
||||||
NodeMetadata pending = new NodeMetadataBuilder().id("myid").state(NodeState.PENDING).credentials(creds2).build();
|
NodeMetadata pending = new NodeMetadataBuilder().id("myid").status(Status.PENDING).credentials(creds2).build();
|
||||||
|
|
||||||
GetNodeMetadataStrategy computeService = createMock(GetNodeMetadataStrategy.class);
|
GetNodeMetadataStrategy computeService = createMock(GetNodeMetadataStrategy.class);
|
||||||
|
|
||||||
|
@ -104,8 +104,8 @@ public class AtomicNodePredicatesTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRefreshUpdatesAtomicReferenceOnRecheckRunning() {
|
public void testRefreshUpdatesAtomicReferenceOnRecheckRunning() {
|
||||||
NodeMetadata running = new NodeMetadataBuilder().id("myid").state(NodeState.RUNNING).build();
|
NodeMetadata running = new NodeMetadataBuilder().id("myid").status(Status.RUNNING).build();
|
||||||
NodeMetadata pending = new NodeMetadataBuilder().id("myid").state(NodeState.PENDING).build();
|
NodeMetadata pending = new NodeMetadataBuilder().id("myid").status(Status.PENDING).build();
|
||||||
GetNodeMetadataStrategy computeService = createMock(GetNodeMetadataStrategy.class);
|
GetNodeMetadataStrategy computeService = createMock(GetNodeMetadataStrategy.class);
|
||||||
|
|
||||||
expect(computeService.getNode("myid")).andReturn(running);
|
expect(computeService.getNode("myid")).andReturn(running);
|
||||||
|
@ -133,7 +133,7 @@ public class AtomicNodePredicatesTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNodeRunningReturnsTrueWhenRunning() {
|
public void testNodeRunningReturnsTrueWhenRunning() {
|
||||||
expect(node.getState()).andReturn(NodeState.RUNNING).atLeastOnce();
|
expect(node.getStatus()).andReturn(Status.RUNNING).atLeastOnce();
|
||||||
replay(node);
|
replay(node);
|
||||||
replay(computeService);
|
replay(computeService);
|
||||||
|
|
||||||
|
@ -145,7 +145,7 @@ public class AtomicNodePredicatesTest {
|
||||||
|
|
||||||
@Test(expectedExceptions = IllegalStateException.class)
|
@Test(expectedExceptions = IllegalStateException.class)
|
||||||
public void testNodeRunningFailsOnTerminated() {
|
public void testNodeRunningFailsOnTerminated() {
|
||||||
expect(node.getState()).andReturn(NodeState.TERMINATED).atLeastOnce();
|
expect(node.getStatus()).andReturn(Status.TERMINATED).atLeastOnce();
|
||||||
replay(node);
|
replay(node);
|
||||||
replay(computeService);
|
replay(computeService);
|
||||||
|
|
||||||
|
@ -157,7 +157,7 @@ public class AtomicNodePredicatesTest {
|
||||||
|
|
||||||
@Test(expectedExceptions = IllegalStateException.class)
|
@Test(expectedExceptions = IllegalStateException.class)
|
||||||
public void testNodeRunningFailsOnError() {
|
public void testNodeRunningFailsOnError() {
|
||||||
expect(node.getState()).andReturn(NodeState.ERROR).atLeastOnce();
|
expect(node.getStatus()).andReturn(Status.ERROR).atLeastOnce();
|
||||||
replay(node);
|
replay(node);
|
||||||
replay(computeService);
|
replay(computeService);
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,7 @@ import java.util.concurrent.atomic.AtomicReference;
|
||||||
import org.jclouds.compute.config.CustomizationResponse;
|
import org.jclouds.compute.config.CustomizationResponse;
|
||||||
import org.jclouds.compute.domain.NodeMetadata;
|
import org.jclouds.compute.domain.NodeMetadata;
|
||||||
import org.jclouds.compute.domain.NodeMetadataBuilder;
|
import org.jclouds.compute.domain.NodeMetadataBuilder;
|
||||||
import org.jclouds.compute.domain.NodeState;
|
import org.jclouds.compute.domain.NodeMetadata.Status;
|
||||||
import org.jclouds.compute.functions.TemplateOptionsToStatement;
|
import org.jclouds.compute.functions.TemplateOptionsToStatement;
|
||||||
import org.jclouds.compute.options.TemplateOptions;
|
import org.jclouds.compute.options.TemplateOptions;
|
||||||
import org.jclouds.compute.predicates.AtomicNodeRunning;
|
import org.jclouds.compute.predicates.AtomicNodeRunning;
|
||||||
|
@ -54,7 +54,7 @@ import com.google.common.collect.Sets;
|
||||||
/**
|
/**
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Test(groups = "unit")
|
@Test(groups = "unit", testName = "CustomizeNodeAndAddToGoodMapOrPutExceptionIntoBadMapTest")
|
||||||
public class CustomizeNodeAndAddToGoodMapOrPutExceptionIntoBadMapTest {
|
public class CustomizeNodeAndAddToGoodMapOrPutExceptionIntoBadMapTest {
|
||||||
|
|
||||||
public void testBreakWhenNodeStillPending() {
|
public void testBreakWhenNodeStillPending() {
|
||||||
|
@ -69,7 +69,7 @@ public class CustomizeNodeAndAddToGoodMapOrPutExceptionIntoBadMapTest {
|
||||||
Map<NodeMetadata, Exception> badNodes = Maps.newLinkedHashMap();
|
Map<NodeMetadata, Exception> badNodes = Maps.newLinkedHashMap();
|
||||||
Multimap<NodeMetadata, CustomizationResponse> customizationResponses = LinkedHashMultimap.create();
|
Multimap<NodeMetadata, CustomizationResponse> customizationResponses = LinkedHashMultimap.create();
|
||||||
|
|
||||||
final NodeMetadata node = new NodeMetadataBuilder().ids("id").state(NodeState.PENDING).build();
|
final NodeMetadata node = new NodeMetadataBuilder().ids("id").status(Status.PENDING).build();
|
||||||
|
|
||||||
// node always stays pending
|
// node always stays pending
|
||||||
GetNodeMetadataStrategy nodeRunning = new GetNodeMetadataStrategy(){
|
GetNodeMetadataStrategy nodeRunning = new GetNodeMetadataStrategy(){
|
||||||
|
@ -93,7 +93,7 @@ public class CustomizeNodeAndAddToGoodMapOrPutExceptionIntoBadMapTest {
|
||||||
assertEquals(goodNodes.size(), 0);
|
assertEquals(goodNodes.size(), 0);
|
||||||
assertEquals(badNodes.keySet(), ImmutableSet.of(node));
|
assertEquals(badNodes.keySet(), ImmutableSet.of(node));
|
||||||
assertTrue(badNodes.get(node).getMessage() != null && badNodes.get(node).getMessage().matches(
|
assertTrue(badNodes.get(node).getMessage() != null && badNodes.get(node).getMessage().matches(
|
||||||
"node\\(id\\) didn't achieve the state running, so we couldn't customize; aborting prematurely after .* seconds with final state: PENDING"),
|
"node\\(id\\) didn't achieve the status running, so we couldn't customize; aborting prematurely after .* seconds with final status: PENDING"),
|
||||||
badNodes.get(node).getMessage());
|
badNodes.get(node).getMessage());
|
||||||
assertEquals(customizationResponses.size(), 0);
|
assertEquals(customizationResponses.size(), 0);
|
||||||
|
|
||||||
|
@ -113,8 +113,8 @@ public class CustomizeNodeAndAddToGoodMapOrPutExceptionIntoBadMapTest {
|
||||||
Map<NodeMetadata, Exception> badNodes = Maps.newLinkedHashMap();
|
Map<NodeMetadata, Exception> badNodes = Maps.newLinkedHashMap();
|
||||||
Multimap<NodeMetadata, CustomizationResponse> customizationResponses = LinkedHashMultimap.create();
|
Multimap<NodeMetadata, CustomizationResponse> customizationResponses = LinkedHashMultimap.create();
|
||||||
|
|
||||||
final NodeMetadata node = new NodeMetadataBuilder().ids("id").state(NodeState.PENDING).build();
|
final NodeMetadata node = new NodeMetadataBuilder().ids("id").status(Status.PENDING).build();
|
||||||
final NodeMetadata deadNnode = new NodeMetadataBuilder().ids("id").state(NodeState.TERMINATED).build();
|
final NodeMetadata deadNnode = new NodeMetadataBuilder().ids("id").status(Status.TERMINATED).build();
|
||||||
|
|
||||||
// node dies
|
// node dies
|
||||||
GetNodeMetadataStrategy nodeRunning = new GetNodeMetadataStrategy(){
|
GetNodeMetadataStrategy nodeRunning = new GetNodeMetadataStrategy(){
|
||||||
|
@ -156,8 +156,8 @@ public class CustomizeNodeAndAddToGoodMapOrPutExceptionIntoBadMapTest {
|
||||||
Map<NodeMetadata, Exception> badNodes = Maps.newLinkedHashMap();
|
Map<NodeMetadata, Exception> badNodes = Maps.newLinkedHashMap();
|
||||||
Multimap<NodeMetadata, CustomizationResponse> customizationResponses = LinkedHashMultimap.create();
|
Multimap<NodeMetadata, CustomizationResponse> customizationResponses = LinkedHashMultimap.create();
|
||||||
|
|
||||||
final NodeMetadata pendingNode = new NodeMetadataBuilder().ids("id").state(NodeState.PENDING).build();
|
final NodeMetadata pendingNode = new NodeMetadataBuilder().ids("id").status(Status.PENDING).build();
|
||||||
final NodeMetadata runningNode = new NodeMetadataBuilder().ids("id").state(NodeState.RUNNING).build();
|
final NodeMetadata runningNode = new NodeMetadataBuilder().ids("id").status(Status.RUNNING).build();
|
||||||
|
|
||||||
expect(openSocketFinder.findOpenSocketOnNode(runningNode, 22, portTimeoutSecs, TimeUnit.SECONDS))
|
expect(openSocketFinder.findOpenSocketOnNode(runningNode, 22, portTimeoutSecs, TimeUnit.SECONDS))
|
||||||
.andThrow(new NoSuchElementException("could not connect to any ip address port")).once();
|
.andThrow(new NoSuchElementException("could not connect to any ip address port")).once();
|
||||||
|
|
|
@ -35,10 +35,10 @@ import org.jclouds.compute.domain.HardwareBuilder;
|
||||||
import org.jclouds.compute.domain.Image;
|
import org.jclouds.compute.domain.Image;
|
||||||
import org.jclouds.compute.domain.NodeMetadata;
|
import org.jclouds.compute.domain.NodeMetadata;
|
||||||
import org.jclouds.compute.domain.NodeMetadataBuilder;
|
import org.jclouds.compute.domain.NodeMetadataBuilder;
|
||||||
import org.jclouds.compute.domain.NodeState;
|
|
||||||
import org.jclouds.compute.domain.OperatingSystem;
|
import org.jclouds.compute.domain.OperatingSystem;
|
||||||
import org.jclouds.compute.domain.Processor;
|
import org.jclouds.compute.domain.Processor;
|
||||||
import org.jclouds.compute.domain.Volume;
|
import org.jclouds.compute.domain.Volume;
|
||||||
|
import org.jclouds.compute.domain.NodeMetadata.Status;
|
||||||
import org.jclouds.compute.domain.internal.VolumeImpl;
|
import org.jclouds.compute.domain.internal.VolumeImpl;
|
||||||
import org.jclouds.compute.functions.GroupNamingConvention;
|
import org.jclouds.compute.functions.GroupNamingConvention;
|
||||||
import org.jclouds.compute.reference.ComputeServiceConstants;
|
import org.jclouds.compute.reference.ComputeServiceConstants;
|
||||||
|
@ -65,11 +65,11 @@ public class ServerDetailsToNodeMetadata implements Function<ServerDetails, Node
|
||||||
@Resource
|
@Resource
|
||||||
@Named(ComputeServiceConstants.COMPUTE_LOGGER)
|
@Named(ComputeServiceConstants.COMPUTE_LOGGER)
|
||||||
protected Logger logger = Logger.NULL;
|
protected Logger logger = Logger.NULL;
|
||||||
public static final Map<ServerDetails.State, NodeState> serverStateToNodeState = ImmutableMap
|
public static final Map<ServerDetails.State, Status> serverStateToNodeStatus = ImmutableMap
|
||||||
.<ServerDetails.State, NodeState> builder().put(ServerDetails.State.STOPPED, NodeState.SUSPENDED)
|
.<ServerDetails.State, Status> builder().put(ServerDetails.State.STOPPED, Status.SUSPENDED)
|
||||||
.put(ServerDetails.State.LOCKED, NodeState.PENDING)
|
.put(ServerDetails.State.LOCKED, Status.PENDING)
|
||||||
.put(ServerDetails.State.RUNNING, NodeState.RUNNING)
|
.put(ServerDetails.State.RUNNING, Status.RUNNING)
|
||||||
.put(ServerDetails.State.UNRECOGNIZED, NodeState.UNRECOGNIZED).build();
|
.put(ServerDetails.State.UNRECOGNIZED, Status.UNRECOGNIZED).build();
|
||||||
|
|
||||||
protected final Supplier<Set<? extends Image>> images;
|
protected final Supplier<Set<? extends Image>> images;
|
||||||
protected final FindLocationForServerDetails findLocationForServerDetails;
|
protected final FindLocationForServerDetails findLocationForServerDetails;
|
||||||
|
@ -112,7 +112,7 @@ public class ServerDetailsToNodeMetadata implements Function<ServerDetails, Node
|
||||||
.processors(ImmutableList.of(new Processor(from.getCpuCores(), 1.0)))
|
.processors(ImmutableList.of(new Processor(from.getCpuCores(), 1.0)))
|
||||||
.volumes(ImmutableList.<Volume> of(new VolumeImpl((float) from.getDiskSizeGB(), true, true)))
|
.volumes(ImmutableList.<Volume> of(new VolumeImpl((float) from.getDiskSizeGB(), true, true)))
|
||||||
.hypervisor(from.getPlatform()).build());
|
.hypervisor(from.getPlatform()).build());
|
||||||
builder.state(serverStateToNodeState.get(from.getState()));
|
builder.status(serverStateToNodeStatus.get(from.getState()));
|
||||||
Iterable<String> addresses = Iterables.filter(Iterables.transform(from.getIps(), new Function<Ip, String>() {
|
Iterable<String> addresses = Iterables.filter(Iterables.transform(from.getIps(), new Function<Ip, String>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -25,11 +25,11 @@ import java.net.URI;
|
||||||
|
|
||||||
import org.jclouds.compute.domain.HardwareBuilder;
|
import org.jclouds.compute.domain.HardwareBuilder;
|
||||||
import org.jclouds.compute.domain.NodeMetadataBuilder;
|
import org.jclouds.compute.domain.NodeMetadataBuilder;
|
||||||
import org.jclouds.compute.domain.NodeState;
|
|
||||||
import org.jclouds.compute.domain.OperatingSystem;
|
import org.jclouds.compute.domain.OperatingSystem;
|
||||||
import org.jclouds.compute.domain.OsFamily;
|
import org.jclouds.compute.domain.OsFamily;
|
||||||
import org.jclouds.compute.domain.Processor;
|
import org.jclouds.compute.domain.Processor;
|
||||||
import org.jclouds.compute.domain.Volume;
|
import org.jclouds.compute.domain.Volume;
|
||||||
|
import org.jclouds.compute.domain.NodeMetadata.Status;
|
||||||
import org.jclouds.compute.domain.internal.VolumeImpl;
|
import org.jclouds.compute.domain.internal.VolumeImpl;
|
||||||
import org.jclouds.glesys.compute.internal.BaseGleSYSComputeServiceExpectTest;
|
import org.jclouds.glesys.compute.internal.BaseGleSYSComputeServiceExpectTest;
|
||||||
import org.jclouds.glesys.features.ServerClientExpectTest;
|
import org.jclouds.glesys.features.ServerClientExpectTest;
|
||||||
|
@ -89,6 +89,6 @@ public class ServerDetailsToNodeMetadataTest extends BaseGleSYSComputeServiceExp
|
||||||
new HardwareBuilder().ids("xm3276891").ram(512)
|
new HardwareBuilder().ids("xm3276891").ram(512)
|
||||||
.processors(ImmutableList.of(new Processor(1, 1.0)))
|
.processors(ImmutableList.of(new Processor(1, 1.0)))
|
||||||
.volumes(ImmutableList.<Volume> of(new VolumeImpl(5f, true, true))).hypervisor("Xen")
|
.volumes(ImmutableList.<Volume> of(new VolumeImpl(5f, true, true))).hypervisor("Xen")
|
||||||
.build()).state(NodeState.RUNNING).build());
|
.build()).status(Status.RUNNING).build());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -176,8 +176,8 @@ public class AppTest extends TestCase {
|
||||||
if (NodeMetadata.class.isInstance(cm)) {
|
if (NodeMetadata.class.isInstance(cm)) {
|
||||||
String nodeGroup = ((NodeMetadata) cm).getGroup();
|
String nodeGroup = ((NodeMetadata) cm).getGroup();
|
||||||
|
|
||||||
if (!((NodeMetadata) cm).getState().equals(NodeState.SUSPENDED)
|
if (!((NodeMetadata) cm).getState().equals(Status.SUSPENDED)
|
||||||
&& !((NodeMetadata) cm).getState().equals(NodeState.TERMINATED)) {
|
&& !((NodeMetadata) cm).getState().equals(Status.TERMINATED)) {
|
||||||
nodeCount++;
|
nodeCount++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,6 +51,7 @@ import com.google.common.collect.ImmutableSet;
|
||||||
*
|
*
|
||||||
* @author Adam Lowe
|
* @author Adam Lowe
|
||||||
*/
|
*/
|
||||||
|
@Test(testName = "AdminClientExpectTest")
|
||||||
public class AdminClientExpectTest extends BaseKeystoneRestClientExpectTest<KeystoneClient> {
|
public class AdminClientExpectTest extends BaseKeystoneRestClientExpectTest<KeystoneClient> {
|
||||||
private DateService dateService = new SimpleDateFormatDateService();
|
private DateService dateService = new SimpleDateFormatDateService();
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,7 @@ import org.jclouds.collect.Memoized;
|
||||||
import org.jclouds.compute.domain.CIMOperatingSystem;
|
import org.jclouds.compute.domain.CIMOperatingSystem;
|
||||||
import org.jclouds.compute.domain.NodeMetadata;
|
import org.jclouds.compute.domain.NodeMetadata;
|
||||||
import org.jclouds.compute.domain.NodeMetadataBuilder;
|
import org.jclouds.compute.domain.NodeMetadataBuilder;
|
||||||
import org.jclouds.compute.domain.NodeState;
|
import org.jclouds.compute.domain.NodeMetadata.Status;
|
||||||
import org.jclouds.compute.functions.GroupNamingConvention;
|
import org.jclouds.compute.functions.GroupNamingConvention;
|
||||||
import org.jclouds.domain.Location;
|
import org.jclouds.domain.Location;
|
||||||
import org.jclouds.savvis.vpdc.domain.VM;
|
import org.jclouds.savvis.vpdc.domain.VM;
|
||||||
|
@ -51,11 +51,11 @@ import com.google.common.collect.Iterables;
|
||||||
@Singleton
|
@Singleton
|
||||||
public class VMToNodeMetadata implements Function<VM, NodeMetadata> {
|
public class VMToNodeMetadata implements Function<VM, NodeMetadata> {
|
||||||
|
|
||||||
public static final Map<VM.Status, NodeState> VAPPSTATUS_TO_NODESTATE = ImmutableMap
|
public static final Map<VM.Status, Status> VAPPSTATUS_TO_NODESTATE = ImmutableMap
|
||||||
.<VM.Status, NodeState> builder().put(VM.Status.OFF, NodeState.SUSPENDED).put(VM.Status.ON,
|
.<VM.Status, Status> builder().put(VM.Status.OFF, Status.SUSPENDED).put(VM.Status.ON,
|
||||||
NodeState.RUNNING).put(VM.Status.RESOLVED, NodeState.PENDING).put(VM.Status.UNRECOGNIZED,
|
Status.RUNNING).put(VM.Status.RESOLVED, Status.PENDING).put(VM.Status.UNRECOGNIZED,
|
||||||
NodeState.UNRECOGNIZED).put(VM.Status.UNKNOWN, NodeState.UNRECOGNIZED).put(VM.Status.SUSPENDED,
|
Status.UNRECOGNIZED).put(VM.Status.UNKNOWN, Status.UNRECOGNIZED).put(VM.Status.SUSPENDED,
|
||||||
NodeState.SUSPENDED).put(VM.Status.UNRESOLVED, NodeState.PENDING).build();
|
Status.SUSPENDED).put(VM.Status.UNRESOLVED, Status.PENDING).build();
|
||||||
|
|
||||||
private final FindLocationForVM findLocationForVM;
|
private final FindLocationForVM findLocationForVM;
|
||||||
private final GroupNamingConvention nodeNamingConvention;
|
private final GroupNamingConvention nodeNamingConvention;
|
||||||
|
@ -81,7 +81,7 @@ public class VMToNodeMetadata implements Function<VM, NodeMetadata> {
|
||||||
}
|
}
|
||||||
// TODO build from resource allocation section
|
// TODO build from resource allocation section
|
||||||
// builder.hardware(findHardwareForVM.apply(from));
|
// builder.hardware(findHardwareForVM.apply(from));
|
||||||
builder.state(VAPPSTATUS_TO_NODESTATE.get(from.getStatus()));
|
builder.status(VAPPSTATUS_TO_NODESTATE.get(from.getStatus()));
|
||||||
Set<String> addresses = Utils.getIpsFromVM(from);
|
Set<String> addresses = Utils.getIpsFromVM(from);
|
||||||
builder.publicAddresses(filter(addresses, not(IsPrivateIPAddress.INSTANCE)));
|
builder.publicAddresses(filter(addresses, not(IsPrivateIPAddress.INSTANCE)));
|
||||||
builder.privateAddresses(filter(addresses, IsPrivateIPAddress.INSTANCE));
|
builder.privateAddresses(filter(addresses, IsPrivateIPAddress.INSTANCE));
|
||||||
|
|
|
@ -35,14 +35,13 @@ import javax.inject.Singleton;
|
||||||
import org.jclouds.compute.domain.Hardware;
|
import org.jclouds.compute.domain.Hardware;
|
||||||
import org.jclouds.compute.domain.NodeMetadata;
|
import org.jclouds.compute.domain.NodeMetadata;
|
||||||
import org.jclouds.compute.domain.NodeMetadataBuilder;
|
import org.jclouds.compute.domain.NodeMetadataBuilder;
|
||||||
import org.jclouds.compute.domain.NodeState;
|
|
||||||
import org.jclouds.compute.functions.GroupNamingConvention;
|
import org.jclouds.compute.functions.GroupNamingConvention;
|
||||||
import org.jclouds.domain.Credentials;
|
import org.jclouds.domain.Credentials;
|
||||||
import org.jclouds.logging.Logger;
|
import org.jclouds.logging.Logger;
|
||||||
import org.jclouds.util.InetAddresses2.IsPrivateIPAddress;
|
import org.jclouds.util.InetAddresses2.IsPrivateIPAddress;
|
||||||
import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType;
|
import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType;
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.ResourceEntity.Status;
|
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.Vm;
|
import org.jclouds.vcloud.director.v1_5.domain.Vm;
|
||||||
|
import org.jclouds.vcloud.director.v1_5.domain.ResourceEntity.Status;
|
||||||
import org.jclouds.vcloud.director.v1_5.predicates.LinkPredicates;
|
import org.jclouds.vcloud.director.v1_5.predicates.LinkPredicates;
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
|
@ -58,19 +57,19 @@ public class VmToNodeMetadata implements Function<Vm, NodeMetadata> {
|
||||||
|
|
||||||
protected final FindLocationForResource findLocationForResourceInVDC;
|
protected final FindLocationForResource findLocationForResourceInVDC;
|
||||||
protected final Function<Vm, Hardware> hardwareForVm;
|
protected final Function<Vm, Hardware> hardwareForVm;
|
||||||
protected final Map<Status, NodeState> vAppStatusToNodeState;
|
protected final Map<Status, NodeMetadata.Status> vAppStatusToNodeStatus;
|
||||||
protected final Map<String, Credentials> credentialStore;
|
protected final Map<String, Credentials> credentialStore;
|
||||||
protected final GroupNamingConvention nodeNamingConvention;
|
protected final GroupNamingConvention nodeNamingConvention;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
protected VmToNodeMetadata(Map<Status, NodeState> vAppStatusToNodeState, Map<String, Credentials> credentialStore,
|
protected VmToNodeMetadata(Map<Status, NodeMetadata.Status> vAppStatusToNodeStatus, Map<String, Credentials> credentialStore,
|
||||||
FindLocationForResource findLocationForResourceInVDC, Function<Vm, Hardware> hardwareForVm,
|
FindLocationForResource findLocationForResourceInVDC, Function<Vm, Hardware> hardwareForVm,
|
||||||
GroupNamingConvention.Factory namingConvention) {
|
GroupNamingConvention.Factory namingConvention) {
|
||||||
this.nodeNamingConvention = checkNotNull(namingConvention, "namingConvention").createWithoutPrefix();
|
this.nodeNamingConvention = checkNotNull(namingConvention, "namingConvention").createWithoutPrefix();
|
||||||
this.hardwareForVm = checkNotNull(hardwareForVm, "hardwareForVm");
|
this.hardwareForVm = checkNotNull(hardwareForVm, "hardwareForVm");
|
||||||
this.findLocationForResourceInVDC = checkNotNull(findLocationForResourceInVDC, "findLocationForResourceInVDC");
|
this.findLocationForResourceInVDC = checkNotNull(findLocationForResourceInVDC, "findLocationForResourceInVDC");
|
||||||
this.credentialStore = checkNotNull(credentialStore, "credentialStore");
|
this.credentialStore = checkNotNull(credentialStore, "credentialStore");
|
||||||
this.vAppStatusToNodeState = checkNotNull(vAppStatusToNodeState, "vAppStatusToNodeState");
|
this.vAppStatusToNodeStatus = checkNotNull(vAppStatusToNodeStatus, "vAppStatusToNodeStatus");
|
||||||
}
|
}
|
||||||
|
|
||||||
public NodeMetadata apply(Vm from) {
|
public NodeMetadata apply(Vm from) {
|
||||||
|
@ -84,7 +83,7 @@ public class VmToNodeMetadata implements Function<Vm, NodeMetadata> {
|
||||||
builder.group(nodeNamingConvention.groupInUniqueNameOrNull(from.getName()));
|
builder.group(nodeNamingConvention.groupInUniqueNameOrNull(from.getName()));
|
||||||
builder.operatingSystem(toComputeOs(from));
|
builder.operatingSystem(toComputeOs(from));
|
||||||
builder.hardware(hardwareForVm.apply(from));
|
builder.hardware(hardwareForVm.apply(from));
|
||||||
builder.state(vAppStatusToNodeState.get(from.getStatus()));
|
builder.status(vAppStatusToNodeStatus.get(from.getStatus()));
|
||||||
Set<String> addresses = getIpsFromVm(from);
|
Set<String> addresses = getIpsFromVm(from);
|
||||||
builder.publicAddresses(filter(addresses, not(IsPrivateIPAddress.INSTANCE)));
|
builder.publicAddresses(filter(addresses, not(IsPrivateIPAddress.INSTANCE)));
|
||||||
builder.privateAddresses(filter(addresses, IsPrivateIPAddress.INSTANCE));
|
builder.privateAddresses(filter(addresses, IsPrivateIPAddress.INSTANCE));
|
||||||
|
|
|
@ -20,15 +20,16 @@ package org.jclouds.virtualbox.config;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.concurrent.Future;
|
||||||
|
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
import org.jclouds.compute.callables.RunScriptOnNode;
|
import org.jclouds.compute.callables.RunScriptOnNode;
|
||||||
import org.jclouds.compute.domain.NodeMetadata;
|
import org.jclouds.compute.domain.NodeMetadata;
|
||||||
import org.jclouds.compute.domain.NodeMetadataBuilder;
|
import org.jclouds.compute.domain.NodeMetadataBuilder;
|
||||||
import org.jclouds.compute.domain.NodeState;
|
|
||||||
import org.jclouds.compute.domain.OperatingSystem;
|
import org.jclouds.compute.domain.OperatingSystem;
|
||||||
import org.jclouds.compute.domain.OsFamily;
|
import org.jclouds.compute.domain.OsFamily;
|
||||||
|
import org.jclouds.compute.domain.NodeMetadata.Status;
|
||||||
import org.jclouds.domain.LocationBuilder;
|
import org.jclouds.domain.LocationBuilder;
|
||||||
import org.jclouds.domain.LocationScope;
|
import org.jclouds.domain.LocationScope;
|
||||||
import org.jclouds.domain.LoginCredentials;
|
import org.jclouds.domain.LoginCredentials;
|
||||||
|
@ -103,7 +104,7 @@ public class HardcodeLocalhostAsNodeMetadataSupplier extends AbstractModule {
|
||||||
.arch(System.getProperty("os.arch"))
|
.arch(System.getProperty("os.arch"))
|
||||||
.version(System.getProperty("os.version"))
|
.version(System.getProperty("os.version"))
|
||||||
.build())
|
.build())
|
||||||
.state(NodeState.RUNNING)
|
.status(Status.RUNNING)
|
||||||
.location(new LocationBuilder().id(HOST_ID)
|
.location(new LocationBuilder().id(HOST_ID)
|
||||||
.scope(LocationScope.HOST)
|
.scope(LocationScope.HOST)
|
||||||
.description(HOSTNAME)
|
.description(HOSTNAME)
|
||||||
|
|
|
@ -33,7 +33,7 @@ import org.jclouds.compute.config.ComputeServiceAdapterContextModule;
|
||||||
import org.jclouds.compute.domain.Hardware;
|
import org.jclouds.compute.domain.Hardware;
|
||||||
import org.jclouds.compute.domain.Image;
|
import org.jclouds.compute.domain.Image;
|
||||||
import org.jclouds.compute.domain.NodeMetadata;
|
import org.jclouds.compute.domain.NodeMetadata;
|
||||||
import org.jclouds.compute.domain.NodeState;
|
import org.jclouds.compute.domain.NodeMetadata.Status;
|
||||||
import org.jclouds.compute.extensions.ImageExtension;
|
import org.jclouds.compute.extensions.ImageExtension;
|
||||||
import org.jclouds.compute.reference.ComputeServiceConstants.Timeouts;
|
import org.jclouds.compute.reference.ComputeServiceConstants.Timeouts;
|
||||||
import org.jclouds.domain.Location;
|
import org.jclouds.domain.Location;
|
||||||
|
@ -174,23 +174,23 @@ public class VirtualBoxComputeServiceContextModule extends
|
||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
public static final Map<MachineState, NodeState> machineToNodeState = ImmutableMap
|
public static final Map<MachineState, Status> machineToNodeStatus = ImmutableMap
|
||||||
.<MachineState, NodeState> builder().put(MachineState.Running, NodeState.RUNNING)
|
.<MachineState, Status> builder().put(MachineState.Running, Status.RUNNING)
|
||||||
.put(MachineState.PoweredOff, NodeState.SUSPENDED)
|
.put(MachineState.PoweredOff, Status.SUSPENDED)
|
||||||
.put(MachineState.DeletingSnapshot, NodeState.PENDING)
|
.put(MachineState.DeletingSnapshot, Status.PENDING)
|
||||||
.put(MachineState.DeletingSnapshotOnline, NodeState.PENDING)
|
.put(MachineState.DeletingSnapshotOnline, Status.PENDING)
|
||||||
.put(MachineState.DeletingSnapshotPaused, NodeState.PENDING)
|
.put(MachineState.DeletingSnapshotPaused, Status.PENDING)
|
||||||
.put(MachineState.FaultTolerantSyncing, NodeState.PENDING)
|
.put(MachineState.FaultTolerantSyncing, Status.PENDING)
|
||||||
.put(MachineState.LiveSnapshotting, NodeState.PENDING)
|
.put(MachineState.LiveSnapshotting, Status.PENDING)
|
||||||
.put(MachineState.SettingUp, NodeState.PENDING)
|
.put(MachineState.SettingUp, Status.PENDING)
|
||||||
.put(MachineState.Starting, NodeState.PENDING)
|
.put(MachineState.Starting, Status.PENDING)
|
||||||
.put(MachineState.Stopping, NodeState.PENDING)
|
.put(MachineState.Stopping, Status.PENDING)
|
||||||
.put(MachineState.Restoring, NodeState.PENDING)
|
.put(MachineState.Restoring, Status.PENDING)
|
||||||
// TODO What to map these states to?
|
// TODO What to map these states to?
|
||||||
.put(MachineState.FirstOnline, NodeState.PENDING).put(MachineState.FirstTransient, NodeState.PENDING)
|
.put(MachineState.FirstOnline, Status.PENDING).put(MachineState.FirstTransient, Status.PENDING)
|
||||||
.put(MachineState.LastOnline, NodeState.PENDING).put(MachineState.LastTransient, NodeState.PENDING)
|
.put(MachineState.LastOnline, Status.PENDING).put(MachineState.LastTransient, Status.PENDING)
|
||||||
.put(MachineState.Teleported, NodeState.PENDING).put(MachineState.TeleportingIn, NodeState.PENDING)
|
.put(MachineState.Teleported, Status.PENDING).put(MachineState.TeleportingIn, Status.PENDING)
|
||||||
.put(MachineState.TeleportingPausedVM, NodeState.PENDING).put(MachineState.Aborted, NodeState.ERROR)
|
.put(MachineState.TeleportingPausedVM, Status.PENDING).put(MachineState.Aborted, Status.ERROR)
|
||||||
.put(MachineState.Stuck, NodeState.ERROR).put(MachineState.Null, NodeState.UNRECOGNIZED).build();
|
.put(MachineState.Stuck, Status.ERROR).put(MachineState.Null, Status.UNRECOGNIZED).build();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
|
|
||||||
package org.jclouds.virtualbox.functions;
|
package org.jclouds.virtualbox.functions;
|
||||||
|
|
||||||
import static org.jclouds.virtualbox.config.VirtualBoxComputeServiceContextModule.machineToNodeState;
|
import static org.jclouds.virtualbox.config.VirtualBoxComputeServiceContextModule.machineToNodeStatus;
|
||||||
import static org.jclouds.virtualbox.config.VirtualBoxConstants.VIRTUALBOX_NODE_NAME_SEPARATOR;
|
import static org.jclouds.virtualbox.config.VirtualBoxConstants.VIRTUALBOX_NODE_NAME_SEPARATOR;
|
||||||
import static org.jclouds.virtualbox.config.VirtualBoxConstants.VIRTUALBOX_NODE_PREFIX;
|
import static org.jclouds.virtualbox.config.VirtualBoxConstants.VIRTUALBOX_NODE_PREFIX;
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ import javax.inject.Named;
|
||||||
|
|
||||||
import org.jclouds.compute.domain.NodeMetadata;
|
import org.jclouds.compute.domain.NodeMetadata;
|
||||||
import org.jclouds.compute.domain.NodeMetadataBuilder;
|
import org.jclouds.compute.domain.NodeMetadataBuilder;
|
||||||
import org.jclouds.compute.domain.NodeState;
|
import org.jclouds.compute.domain.NodeMetadata.Status;
|
||||||
import org.jclouds.compute.reference.ComputeServiceConstants;
|
import org.jclouds.compute.reference.ComputeServiceConstants;
|
||||||
import org.jclouds.domain.LocationBuilder;
|
import org.jclouds.domain.LocationBuilder;
|
||||||
import org.jclouds.domain.LocationScope;
|
import org.jclouds.domain.LocationScope;
|
||||||
|
@ -90,10 +90,10 @@ public class IMachineToNodeMetadata implements Function<IMachine, NodeMetadata>
|
||||||
nodeMetadataBuilder.hostname(vm.getName());
|
nodeMetadataBuilder.hostname(vm.getName());
|
||||||
|
|
||||||
MachineState vmState = vm.getState();
|
MachineState vmState = vm.getState();
|
||||||
NodeState nodeState = machineToNodeState.get(vmState);
|
NodeMetadata.Status nodeState = machineToNodeStatus.get(vmState);
|
||||||
if (nodeState == null)
|
if (nodeState == null)
|
||||||
nodeState = NodeState.UNRECOGNIZED;
|
nodeState = Status.UNRECOGNIZED;
|
||||||
nodeMetadataBuilder.state(nodeState);
|
nodeMetadataBuilder.status(nodeState);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
// nat adapter
|
// nat adapter
|
||||||
|
|
|
@ -177,7 +177,7 @@ public class NodeCreator implements Function<NodeSpec, NodeAndInitialCredentials
|
||||||
private NodeMetadata buildPartialNodeMetadata(IMachine clone) {
|
private NodeMetadata buildPartialNodeMetadata(IMachine clone) {
|
||||||
NodeMetadataBuilder nodeMetadataBuilder = new NodeMetadataBuilder();
|
NodeMetadataBuilder nodeMetadataBuilder = new NodeMetadataBuilder();
|
||||||
nodeMetadataBuilder.id(clone.getName());
|
nodeMetadataBuilder.id(clone.getName());
|
||||||
nodeMetadataBuilder.state(VirtualBoxComputeServiceContextModule.machineToNodeState.get(clone.getState()));
|
nodeMetadataBuilder.status(VirtualBoxComputeServiceContextModule.machineToNodeStatus.get(clone.getState()));
|
||||||
nodeMetadataBuilder.publicAddresses(ImmutableSet.of(machineUtils.getIpAddressFromHostOnlyNIC(clone.getName())));
|
nodeMetadataBuilder.publicAddresses(ImmutableSet.of(machineUtils.getIpAddressFromHostOnlyNIC(clone.getName())));
|
||||||
|
|
||||||
LoginCredentials loginCredentials = new LoginCredentials("toor", "password", null, true);
|
LoginCredentials loginCredentials = new LoginCredentials("toor", "password", null, true);
|
||||||
|
|
|
@ -33,8 +33,8 @@ import org.jclouds.compute.callables.RunScriptOnNode.Factory;
|
||||||
import org.jclouds.compute.domain.ExecResponse;
|
import org.jclouds.compute.domain.ExecResponse;
|
||||||
import org.jclouds.compute.domain.NodeMetadata;
|
import org.jclouds.compute.domain.NodeMetadata;
|
||||||
import org.jclouds.compute.domain.NodeMetadataBuilder;
|
import org.jclouds.compute.domain.NodeMetadataBuilder;
|
||||||
import org.jclouds.compute.domain.NodeState;
|
|
||||||
import org.jclouds.compute.domain.OperatingSystem;
|
import org.jclouds.compute.domain.OperatingSystem;
|
||||||
|
import org.jclouds.compute.domain.NodeMetadata.Status;
|
||||||
import org.jclouds.scriptbuilder.domain.Statements;
|
import org.jclouds.scriptbuilder.domain.Statements;
|
||||||
import org.jclouds.virtualbox.predicates.RetryIfSocketNotYetOpen;
|
import org.jclouds.virtualbox.predicates.RetryIfSocketNotYetOpen;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
@ -54,7 +54,7 @@ public class StartVBoxIfNotAlreadyRunningLiveTest {
|
||||||
VirtualBoxManager manager = createMock(VirtualBoxManager.class);
|
VirtualBoxManager manager = createMock(VirtualBoxManager.class);
|
||||||
Factory runScriptOnNodeFactory = createMock(Factory.class);
|
Factory runScriptOnNodeFactory = createMock(Factory.class);
|
||||||
RetryIfSocketNotYetOpen client = createMock(RetryIfSocketNotYetOpen.class);
|
RetryIfSocketNotYetOpen client = createMock(RetryIfSocketNotYetOpen.class);
|
||||||
NodeMetadata host = new NodeMetadataBuilder().id("host").state(NodeState.RUNNING).build();
|
NodeMetadata host = new NodeMetadataBuilder().id("host").status(Status.RUNNING).build();
|
||||||
URI provider = URI.create("http://localhost:18083/");
|
URI provider = URI.create("http://localhost:18083/");
|
||||||
String identity = "adminstrator";
|
String identity = "adminstrator";
|
||||||
String credential = "12345";
|
String credential = "12345";
|
||||||
|
@ -80,7 +80,7 @@ public class StartVBoxIfNotAlreadyRunningLiveTest {
|
||||||
Factory runScriptOnNodeFactory = createMock(Factory.class);
|
Factory runScriptOnNodeFactory = createMock(Factory.class);
|
||||||
RetryIfSocketNotYetOpen client = createMock(RetryIfSocketNotYetOpen.class);
|
RetryIfSocketNotYetOpen client = createMock(RetryIfSocketNotYetOpen.class);
|
||||||
RunScriptOnNode runScriptOnNode = createMock(RunScriptOnNode.class);
|
RunScriptOnNode runScriptOnNode = createMock(RunScriptOnNode.class);
|
||||||
NodeMetadata host = new NodeMetadataBuilder().id("host").state(NodeState.RUNNING).operatingSystem(
|
NodeMetadata host = new NodeMetadataBuilder().id("host").status(Status.RUNNING).operatingSystem(
|
||||||
OperatingSystem.builder().description("unix").build()).build();
|
OperatingSystem.builder().description("unix").build()).build();
|
||||||
URI provider = URI.create("http://localhost:18083/");
|
URI provider = URI.create("http://localhost:18083/");
|
||||||
String identity = "adminstrator";
|
String identity = "adminstrator";
|
||||||
|
|
|
@ -32,7 +32,7 @@ import org.jclouds.compute.domain.Hardware;
|
||||||
import org.jclouds.compute.domain.HardwareBuilder;
|
import org.jclouds.compute.domain.HardwareBuilder;
|
||||||
import org.jclouds.compute.domain.Image;
|
import org.jclouds.compute.domain.Image;
|
||||||
import org.jclouds.compute.domain.NodeMetadataBuilder;
|
import org.jclouds.compute.domain.NodeMetadataBuilder;
|
||||||
import org.jclouds.compute.domain.NodeState;
|
import org.jclouds.compute.domain.NodeMetadata.Status;
|
||||||
import org.jclouds.compute.functions.GroupNamingConvention;
|
import org.jclouds.compute.functions.GroupNamingConvention;
|
||||||
import org.jclouds.domain.Credentials;
|
import org.jclouds.domain.Credentials;
|
||||||
import org.jclouds.domain.Location;
|
import org.jclouds.domain.Location;
|
||||||
|
@ -52,11 +52,11 @@ import com.google.common.cache.LoadingCache;
|
||||||
public class AWSRunningInstanceToNodeMetadata extends RunningInstanceToNodeMetadata {
|
public class AWSRunningInstanceToNodeMetadata extends RunningInstanceToNodeMetadata {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
protected AWSRunningInstanceToNodeMetadata(Map<InstanceState, NodeState> instanceToNodeState,
|
protected AWSRunningInstanceToNodeMetadata(Map<InstanceState, Status> instanceToNodeStatus,
|
||||||
Map<String, Credentials> credentialStore, Supplier<LoadingCache<RegionAndName, ? extends Image>> imageMap,
|
Map<String, Credentials> credentialStore, Supplier<LoadingCache<RegionAndName, ? extends Image>> imageMap,
|
||||||
@Memoized Supplier<Set<? extends Location>> locations, @Memoized Supplier<Set<? extends Hardware>> hardware,
|
@Memoized Supplier<Set<? extends Location>> locations, @Memoized Supplier<Set<? extends Hardware>> hardware,
|
||||||
GroupNamingConvention.Factory namingConvention) {
|
GroupNamingConvention.Factory namingConvention) {
|
||||||
super(instanceToNodeState, credentialStore, imageMap, locations, hardware, namingConvention);
|
super(instanceToNodeStatus, credentialStore, imageMap, locations, hardware, namingConvention);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -29,7 +29,7 @@ import org.jclouds.aws.ec2.domain.MonitoringState;
|
||||||
import org.jclouds.compute.domain.Hardware;
|
import org.jclouds.compute.domain.Hardware;
|
||||||
import org.jclouds.compute.domain.Image;
|
import org.jclouds.compute.domain.Image;
|
||||||
import org.jclouds.compute.domain.NodeMetadataBuilder;
|
import org.jclouds.compute.domain.NodeMetadataBuilder;
|
||||||
import org.jclouds.compute.domain.NodeState;
|
import org.jclouds.compute.domain.NodeMetadata.Status;
|
||||||
import org.jclouds.compute.functions.GroupNamingConvention;
|
import org.jclouds.compute.functions.GroupNamingConvention;
|
||||||
import org.jclouds.date.DateService;
|
import org.jclouds.date.DateService;
|
||||||
import org.jclouds.domain.Credentials;
|
import org.jclouds.domain.Credentials;
|
||||||
|
@ -135,7 +135,7 @@ public class AWSRunningInstanceToNodeMetadataTest {
|
||||||
assertEquals(
|
assertEquals(
|
||||||
parser.apply(Iterables.get(contents, 0)).toString(),
|
parser.apply(Iterables.get(contents, 0)).toString(),
|
||||||
new NodeMetadataBuilder()
|
new NodeMetadataBuilder()
|
||||||
.state(NodeState.RUNNING)
|
.status(Status.RUNNING)
|
||||||
.group("zkclustertest")
|
.group("zkclustertest")
|
||||||
.name("foo")
|
.name("foo")
|
||||||
.hostname("ip-10-212-81-7")
|
.hostname("ip-10-212-81-7")
|
||||||
|
@ -149,7 +149,7 @@ public class AWSRunningInstanceToNodeMetadataTest {
|
||||||
assertEquals(
|
assertEquals(
|
||||||
parser.apply(Iterables.get(contents, 1)),
|
parser.apply(Iterables.get(contents, 1)),
|
||||||
new NodeMetadataBuilder()
|
new NodeMetadataBuilder()
|
||||||
.state(NodeState.RUNNING)
|
.status(Status.RUNNING)
|
||||||
.group("zkclustertest")
|
.group("zkclustertest")
|
||||||
.hostname("ip-10-212-185-8")
|
.hostname("ip-10-212-185-8")
|
||||||
.privateAddresses(ImmutableSet.of("10.212.185.8"))
|
.privateAddresses(ImmutableSet.of("10.212.185.8"))
|
||||||
|
@ -163,7 +163,7 @@ public class AWSRunningInstanceToNodeMetadataTest {
|
||||||
protected AWSRunningInstanceToNodeMetadata createNodeParser(final ImmutableSet<Hardware> hardware,
|
protected AWSRunningInstanceToNodeMetadata createNodeParser(final ImmutableSet<Hardware> hardware,
|
||||||
final ImmutableSet<Location> locations, Set<org.jclouds.compute.domain.Image> images,
|
final ImmutableSet<Location> locations, Set<org.jclouds.compute.domain.Image> images,
|
||||||
Map<String, Credentials> credentialStore) {
|
Map<String, Credentials> credentialStore) {
|
||||||
Map<InstanceState, NodeState> instanceToNodeState = EC2ComputeServiceDependenciesModule.instanceToNodeState;
|
Map<InstanceState, Status> instanceToNodeStatus = EC2ComputeServiceDependenciesModule.instanceToNodeStatus;
|
||||||
|
|
||||||
final Map<RegionAndName, ? extends Image> backing = ImagesToRegionAndIdMap.imagesToMap(images);
|
final Map<RegionAndName, ? extends Image> backing = ImagesToRegionAndIdMap.imagesToMap(images);
|
||||||
|
|
||||||
|
@ -177,12 +177,12 @@ public class AWSRunningInstanceToNodeMetadataTest {
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
return createNodeParser(hardware, locations, credentialStore, instanceToNodeState, instanceToImage);
|
return createNodeParser(hardware, locations, credentialStore, instanceToNodeStatus, instanceToImage);
|
||||||
}
|
}
|
||||||
|
|
||||||
private AWSRunningInstanceToNodeMetadata createNodeParser(final ImmutableSet<Hardware> hardware,
|
private AWSRunningInstanceToNodeMetadata createNodeParser(final ImmutableSet<Hardware> hardware,
|
||||||
final ImmutableSet<Location> locations, Map<String, Credentials> credentialStore,
|
final ImmutableSet<Location> locations, Map<String, Credentials> credentialStore,
|
||||||
Map<InstanceState, NodeState> instanceToNodeState, LoadingCache<RegionAndName, ? extends Image> instanceToImage) {
|
Map<InstanceState, Status> instanceToNodeStatus, LoadingCache<RegionAndName, ? extends Image> instanceToImage) {
|
||||||
Supplier<Set<? extends Location>> locationSupplier = new Supplier<Set<? extends Location>>() {
|
Supplier<Set<? extends Location>> locationSupplier = new Supplier<Set<? extends Location>>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -209,7 +209,7 @@ public class AWSRunningInstanceToNodeMetadataTest {
|
||||||
|
|
||||||
}).getInstance(GroupNamingConvention.Factory.class);
|
}).getInstance(GroupNamingConvention.Factory.class);
|
||||||
|
|
||||||
AWSRunningInstanceToNodeMetadata parser = new AWSRunningInstanceToNodeMetadata(instanceToNodeState,
|
AWSRunningInstanceToNodeMetadata parser = new AWSRunningInstanceToNodeMetadata(instanceToNodeStatus,
|
||||||
credentialStore, Suppliers.<LoadingCache<RegionAndName, ? extends Image>> ofInstance(instanceToImage),
|
credentialStore, Suppliers.<LoadingCache<RegionAndName, ? extends Image>> ofInstance(instanceToImage),
|
||||||
locationSupplier, hardwareSupplier, namingConvention);
|
locationSupplier, hardwareSupplier, namingConvention);
|
||||||
return parser;
|
return parser;
|
||||||
|
|
|
@ -30,7 +30,7 @@ import org.jclouds.compute.config.ComputeServiceAdapterContextModule;
|
||||||
import org.jclouds.compute.domain.Hardware;
|
import org.jclouds.compute.domain.Hardware;
|
||||||
import org.jclouds.compute.domain.Image;
|
import org.jclouds.compute.domain.Image;
|
||||||
import org.jclouds.compute.domain.NodeMetadata;
|
import org.jclouds.compute.domain.NodeMetadata;
|
||||||
import org.jclouds.compute.domain.NodeState;
|
import org.jclouds.compute.domain.NodeMetadata.Status;
|
||||||
import org.jclouds.compute.options.TemplateOptions;
|
import org.jclouds.compute.options.TemplateOptions;
|
||||||
import org.jclouds.domain.Location;
|
import org.jclouds.domain.Location;
|
||||||
import org.jclouds.functions.IdentityFunction;
|
import org.jclouds.functions.IdentityFunction;
|
||||||
|
@ -85,21 +85,21 @@ public class GoGridComputeServiceContextModule extends
|
||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
static final Map<ServerState, NodeState> serverStateToNodeState = ImmutableMap.<ServerState, NodeState> builder()
|
static final Map<ServerState, Status> serverStateToNodeStatus = ImmutableMap.<ServerState, Status> builder()
|
||||||
.put(ServerState.ON, NodeState.RUNNING)//
|
.put(ServerState.ON, Status.RUNNING)//
|
||||||
.put(ServerState.STARTING, NodeState.PENDING)//
|
.put(ServerState.STARTING, Status.PENDING)//
|
||||||
.put(ServerState.OFF, NodeState.SUSPENDED)//
|
.put(ServerState.OFF, Status.SUSPENDED)//
|
||||||
.put(ServerState.STOPPING, NodeState.PENDING)//
|
.put(ServerState.STOPPING, Status.PENDING)//
|
||||||
.put(ServerState.RESTARTING, NodeState.PENDING)//
|
.put(ServerState.RESTARTING, Status.PENDING)//
|
||||||
.put(ServerState.SAVING, NodeState.PENDING)//
|
.put(ServerState.SAVING, Status.PENDING)//
|
||||||
.put(ServerState.UNRECOGNIZED, NodeState.UNRECOGNIZED)//
|
.put(ServerState.UNRECOGNIZED, Status.UNRECOGNIZED)//
|
||||||
.put(ServerState.RESTORING, NodeState.PENDING)//
|
.put(ServerState.RESTORING, Status.PENDING)//
|
||||||
.put(ServerState.UPDATING, NodeState.PENDING).build();
|
.put(ServerState.UPDATING, Status.PENDING).build();
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
@Provides
|
@Provides
|
||||||
Map<ServerState, NodeState> provideServerToNodeState() {
|
Map<ServerState, Status> provideServerToNodeStatus() {
|
||||||
return serverStateToNodeState;
|
return serverStateToNodeStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -32,7 +32,7 @@ import org.jclouds.compute.domain.Hardware;
|
||||||
import org.jclouds.compute.domain.Image;
|
import org.jclouds.compute.domain.Image;
|
||||||
import org.jclouds.compute.domain.NodeMetadata;
|
import org.jclouds.compute.domain.NodeMetadata;
|
||||||
import org.jclouds.compute.domain.NodeMetadataBuilder;
|
import org.jclouds.compute.domain.NodeMetadataBuilder;
|
||||||
import org.jclouds.compute.domain.NodeState;
|
import org.jclouds.compute.domain.NodeMetadata.Status;
|
||||||
import org.jclouds.compute.functions.GroupNamingConvention;
|
import org.jclouds.compute.functions.GroupNamingConvention;
|
||||||
import org.jclouds.domain.Location;
|
import org.jclouds.domain.Location;
|
||||||
import org.jclouds.gogrid.domain.Server;
|
import org.jclouds.gogrid.domain.Server;
|
||||||
|
@ -54,7 +54,7 @@ public class ServerToNodeMetadata implements Function<Server, NodeMetadata> {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
protected Logger logger = Logger.NULL;
|
protected Logger logger = Logger.NULL;
|
||||||
private final Map<ServerState, NodeState> serverStateToNodeState;
|
private final Map<ServerState, Status> serverStateToNodeStatus;
|
||||||
private final Supplier<Set<? extends Image>> images;
|
private final Supplier<Set<? extends Image>> images;
|
||||||
private final Supplier<Set<? extends Hardware>> hardwares;
|
private final Supplier<Set<? extends Hardware>> hardwares;
|
||||||
private final Supplier<Set<? extends Location>> locations;
|
private final Supplier<Set<? extends Location>> locations;
|
||||||
|
@ -91,12 +91,12 @@ public class ServerToNodeMetadata implements Function<Server, NodeMetadata> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
ServerToNodeMetadata(Map<ServerState, NodeState> serverStateToNodeState,
|
ServerToNodeMetadata(Map<ServerState, Status> serverStateToNodeStatus,
|
||||||
@Memoized Supplier<Set<? extends Image>> images, @Memoized Supplier<Set<? extends Hardware>> hardwares,
|
@Memoized Supplier<Set<? extends Image>> images, @Memoized Supplier<Set<? extends Hardware>> hardwares,
|
||||||
@Memoized Supplier<Set<? extends Location>> locations,
|
@Memoized Supplier<Set<? extends Location>> locations,
|
||||||
GroupNamingConvention.Factory namingConvention) {
|
GroupNamingConvention.Factory namingConvention) {
|
||||||
this.nodeNamingConvention = checkNotNull(namingConvention, "namingConvention").createWithoutPrefix();
|
this.nodeNamingConvention = checkNotNull(namingConvention, "namingConvention").createWithoutPrefix();
|
||||||
this.serverStateToNodeState = checkNotNull(serverStateToNodeState, "serverStateToNodeState");
|
this.serverStateToNodeStatus = checkNotNull(serverStateToNodeStatus, "serverStateToNodeStatus");
|
||||||
this.images = checkNotNull(images, "images");
|
this.images = checkNotNull(images, "images");
|
||||||
this.hardwares = checkNotNull(hardwares, "hardwares");
|
this.hardwares = checkNotNull(hardwares, "hardwares");
|
||||||
this.locations = checkNotNull(locations, "locations");
|
this.locations = checkNotNull(locations, "locations");
|
||||||
|
@ -117,7 +117,7 @@ public class ServerToNodeMetadata implements Function<Server, NodeMetadata> {
|
||||||
if (image != null)
|
if (image != null)
|
||||||
builder.operatingSystem(image.getOperatingSystem());
|
builder.operatingSystem(image.getOperatingSystem());
|
||||||
|
|
||||||
builder.state(serverStateToNodeState.get(from.getState()));
|
builder.status(serverStateToNodeStatus.get(from.getState()));
|
||||||
builder.publicAddresses(ImmutableSet.of(from.getIp().getIp()));
|
builder.publicAddresses(ImmutableSet.of(from.getIp().getIp()));
|
||||||
return builder.build();
|
return builder.build();
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@ public class GoGridComputeServiceContextModuleTest {
|
||||||
public void testAllStatusCovered() {
|
public void testAllStatusCovered() {
|
||||||
|
|
||||||
for (ServerState state : ServerState.values()) {
|
for (ServerState state : ServerState.values()) {
|
||||||
assert GoGridComputeServiceContextModule.serverStateToNodeState.containsKey(state) : state;
|
assert GoGridComputeServiceContextModule.serverStateToNodeStatus.containsKey(state) : state;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,8 +30,8 @@ import java.util.Set;
|
||||||
import org.jclouds.compute.domain.Hardware;
|
import org.jclouds.compute.domain.Hardware;
|
||||||
import org.jclouds.compute.domain.Image;
|
import org.jclouds.compute.domain.Image;
|
||||||
import org.jclouds.compute.domain.NodeMetadata;
|
import org.jclouds.compute.domain.NodeMetadata;
|
||||||
import org.jclouds.compute.domain.NodeState;
|
|
||||||
import org.jclouds.compute.domain.OperatingSystem;
|
import org.jclouds.compute.domain.OperatingSystem;
|
||||||
|
import org.jclouds.compute.domain.NodeMetadata.Status;
|
||||||
import org.jclouds.compute.functions.GroupNamingConvention;
|
import org.jclouds.compute.functions.GroupNamingConvention;
|
||||||
import org.jclouds.domain.Location;
|
import org.jclouds.domain.Location;
|
||||||
import org.jclouds.domain.LocationBuilder;
|
import org.jclouds.domain.LocationBuilder;
|
||||||
|
@ -60,7 +60,7 @@ public class ServerToNodeMetadataTest {
|
||||||
@Test
|
@Test
|
||||||
public void testApplySetsTagFromNameAndCredentialsFromName() {
|
public void testApplySetsTagFromNameAndCredentialsFromName() {
|
||||||
|
|
||||||
Map<ServerState, NodeState> serverStateToNodeState = createMock(Map.class);
|
Map<ServerState, Status> serverStateToNodeStatus = createMock(Map.class);
|
||||||
org.jclouds.compute.domain.Image jcImage = createMock(org.jclouds.compute.domain.Image.class);
|
org.jclouds.compute.domain.Image jcImage = createMock(org.jclouds.compute.domain.Image.class);
|
||||||
Option dc = new Option(1l, "US-West-1", "US West 1 Datacenter");
|
Option dc = new Option(1l, "US-West-1", "US West 1 Datacenter");
|
||||||
Option ram = new Option(1l, "512MB", "Server with 512MB RAM");
|
Option ram = new Option(1l, "512MB", "Server with 512MB RAM");
|
||||||
|
@ -72,7 +72,7 @@ public class ServerToNodeMetadataTest {
|
||||||
expect(server.getName()).andReturn("group-ff").atLeastOnce();
|
expect(server.getName()).andReturn("group-ff").atLeastOnce();
|
||||||
expect(server.getState()).andReturn(ServerState.ON).atLeastOnce();
|
expect(server.getState()).andReturn(ServerState.ON).atLeastOnce();
|
||||||
|
|
||||||
expect(serverStateToNodeState.get(ServerState.ON)).andReturn(NodeState.RUNNING);
|
expect(serverStateToNodeStatus.get(ServerState.ON)).andReturn(Status.RUNNING);
|
||||||
|
|
||||||
Location location = new LocationBuilder().scope(LocationScope.ZONE).id("1").description("US-West-1").build();
|
Location location = new LocationBuilder().scope(LocationScope.ZONE).id("1").description("US-West-1").build();
|
||||||
Set< ? extends Location> locations = ImmutableSet.< Location> of( location);
|
Set< ? extends Location> locations = ImmutableSet.< Location> of( location);
|
||||||
|
@ -88,12 +88,12 @@ public class ServerToNodeMetadataTest {
|
||||||
expect(jcImage.getLocation()).andReturn(location).atLeastOnce();
|
expect(jcImage.getLocation()).andReturn(location).atLeastOnce();
|
||||||
expect(jcImage.getOperatingSystem()).andReturn(createMock(OperatingSystem.class)).atLeastOnce();
|
expect(jcImage.getOperatingSystem()).andReturn(createMock(OperatingSystem.class)).atLeastOnce();
|
||||||
|
|
||||||
replay(serverStateToNodeState);
|
replay(serverStateToNodeStatus);
|
||||||
replay(server);
|
replay(server);
|
||||||
replay(image);
|
replay(image);
|
||||||
replay(jcImage);
|
replay(jcImage);
|
||||||
|
|
||||||
ServerToNodeMetadata parser = new ServerToNodeMetadata(serverStateToNodeState, Suppliers
|
ServerToNodeMetadata parser = new ServerToNodeMetadata(serverStateToNodeStatus, Suppliers
|
||||||
.<Set<? extends Image>> ofInstance(images), Suppliers
|
.<Set<? extends Image>> ofInstance(images), Suppliers
|
||||||
.<Set<? extends Hardware>> ofInstance(GoGridHardwareSupplier.H_ALL), Suppliers
|
.<Set<? extends Hardware>> ofInstance(GoGridHardwareSupplier.H_ALL), Suppliers
|
||||||
.<Set<? extends Location>> ofInstance(locations), namingConvention);
|
.<Set<? extends Location>> ofInstance(locations), namingConvention);
|
||||||
|
@ -103,7 +103,7 @@ public class ServerToNodeMetadataTest {
|
||||||
assertEquals(metadata.getImageId(), "2000");
|
assertEquals(metadata.getImageId(), "2000");
|
||||||
assertEquals(metadata.getGroup(), "group");
|
assertEquals(metadata.getGroup(), "group");
|
||||||
|
|
||||||
verify(serverStateToNodeState);
|
verify(serverStateToNodeStatus);
|
||||||
verify(image);
|
verify(image);
|
||||||
verify(server);
|
verify(server);
|
||||||
verify(jcImage);
|
verify(jcImage);
|
||||||
|
|
|
@ -18,7 +18,6 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.rimuhosting.miro.binder;
|
package org.jclouds.rimuhosting.miro.binder;
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
|
@ -23,7 +23,7 @@ import java.util.Map;
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
import org.jclouds.compute.domain.NodeMetadata;
|
import org.jclouds.compute.domain.NodeMetadata;
|
||||||
import org.jclouds.compute.domain.NodeState;
|
import org.jclouds.compute.domain.NodeMetadata.Status;
|
||||||
import org.jclouds.rimuhosting.miro.compute.functions.ServerToNodeMetadata;
|
import org.jclouds.rimuhosting.miro.compute.functions.ServerToNodeMetadata;
|
||||||
import org.jclouds.rimuhosting.miro.domain.Server;
|
import org.jclouds.rimuhosting.miro.domain.Server;
|
||||||
import org.jclouds.rimuhosting.miro.domain.internal.RunningState;
|
import org.jclouds.rimuhosting.miro.domain.internal.RunningState;
|
||||||
|
@ -55,18 +55,18 @@ public class RimuHostingComputeServiceDependenciesModule extends AbstractModule
|
||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
static final Map<RunningState, NodeState> runningStateToNodeState = ImmutableMap.<RunningState, NodeState> builder()
|
static final Map<RunningState, Status> runningStateToNodeStatus = ImmutableMap.<RunningState, Status> builder()
|
||||||
.put(RunningState.RUNNING, NodeState.RUNNING)//
|
.put(RunningState.RUNNING, Status.RUNNING)//
|
||||||
.put(RunningState.NOTRUNNING, NodeState.SUSPENDED)//
|
.put(RunningState.NOTRUNNING, Status.SUSPENDED)//
|
||||||
.put(RunningState.POWERCYCLING, NodeState.PENDING)//
|
.put(RunningState.POWERCYCLING, Status.PENDING)//
|
||||||
.put(RunningState.RESTARTING, NodeState.PENDING)//
|
.put(RunningState.RESTARTING, Status.PENDING)//
|
||||||
.put(RunningState.UNRECOGNIZED, NodeState.UNRECOGNIZED)//
|
.put(RunningState.UNRECOGNIZED, Status.UNRECOGNIZED)//
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
@Provides
|
@Provides
|
||||||
Map<RunningState, NodeState> provideServerToNodeState() {
|
Map<RunningState, Status> provideServerToNodeStatus() {
|
||||||
return runningStateToNodeState;
|
return runningStateToNodeStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
|
|
|
@ -32,8 +32,8 @@ import org.jclouds.collect.Memoized;
|
||||||
import org.jclouds.compute.domain.Image;
|
import org.jclouds.compute.domain.Image;
|
||||||
import org.jclouds.compute.domain.NodeMetadata;
|
import org.jclouds.compute.domain.NodeMetadata;
|
||||||
import org.jclouds.compute.domain.NodeMetadataBuilder;
|
import org.jclouds.compute.domain.NodeMetadataBuilder;
|
||||||
import org.jclouds.compute.domain.NodeState;
|
|
||||||
import org.jclouds.compute.domain.OperatingSystem;
|
import org.jclouds.compute.domain.OperatingSystem;
|
||||||
|
import org.jclouds.compute.domain.NodeMetadata.Status;
|
||||||
import org.jclouds.compute.functions.GroupNamingConvention;
|
import org.jclouds.compute.functions.GroupNamingConvention;
|
||||||
import org.jclouds.domain.Location;
|
import org.jclouds.domain.Location;
|
||||||
import org.jclouds.logging.Logger;
|
import org.jclouds.logging.Logger;
|
||||||
|
@ -57,7 +57,7 @@ public class ServerToNodeMetadata implements Function<Server, NodeMetadata> {
|
||||||
|
|
||||||
protected final Supplier<Set<? extends Location>> locations;
|
protected final Supplier<Set<? extends Location>> locations;
|
||||||
protected final Function<Server, Iterable<String>> getPublicAddresses;
|
protected final Function<Server, Iterable<String>> getPublicAddresses;
|
||||||
protected final Map<RunningState, NodeState> runningStateToNodeState;
|
protected final Map<RunningState, Status> runningStateToNodeStatus;
|
||||||
protected final Supplier<Set<? extends Image>> images;
|
protected final Supplier<Set<? extends Image>> images;
|
||||||
protected final GroupNamingConvention nodeNamingConvention;
|
protected final GroupNamingConvention nodeNamingConvention;
|
||||||
|
|
||||||
|
@ -80,13 +80,13 @@ public class ServerToNodeMetadata implements Function<Server, NodeMetadata> {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
ServerToNodeMetadata(Function<Server, Iterable<String>> getPublicAddresses,
|
ServerToNodeMetadata(Function<Server, Iterable<String>> getPublicAddresses,
|
||||||
@Memoized Supplier<Set<? extends Location>> locations, Map<RunningState, NodeState> runningStateToNodeState,
|
@Memoized Supplier<Set<? extends Location>> locations, Map<RunningState, Status> runningStateToNodeStatus,
|
||||||
@Memoized Supplier<Set<? extends Image>> images,
|
@Memoized Supplier<Set<? extends Image>> images,
|
||||||
GroupNamingConvention.Factory namingConvention) {
|
GroupNamingConvention.Factory namingConvention) {
|
||||||
this.nodeNamingConvention = checkNotNull(namingConvention, "namingConvention").createWithoutPrefix();
|
this.nodeNamingConvention = checkNotNull(namingConvention, "namingConvention").createWithoutPrefix();
|
||||||
this.getPublicAddresses = checkNotNull(getPublicAddresses, "serverStateToNodeState");
|
this.getPublicAddresses = checkNotNull(getPublicAddresses, "serverStateToNodeStatus");
|
||||||
this.locations = checkNotNull(locations, "locations");
|
this.locations = checkNotNull(locations, "locations");
|
||||||
this.runningStateToNodeState = checkNotNull(runningStateToNodeState, "serverStateToNodeState");
|
this.runningStateToNodeStatus = checkNotNull(runningStateToNodeStatus, "serverStateToNodeStatus");
|
||||||
this.images = checkNotNull(images, "images");
|
this.images = checkNotNull(images, "images");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,9 +104,9 @@ public class ServerToNodeMetadata implements Function<Server, NodeMetadata> {
|
||||||
builder.hardware(null);// TODO
|
builder.hardware(null);// TODO
|
||||||
if (from.getBillingData() != null && from.getBillingData().getDateCancelled() != null
|
if (from.getBillingData() != null && from.getBillingData().getDateCancelled() != null
|
||||||
&& RunningState.NOTRUNNING == from.getState())
|
&& RunningState.NOTRUNNING == from.getState())
|
||||||
builder.state(NodeState.TERMINATED);
|
builder.status(Status.TERMINATED);
|
||||||
else
|
else
|
||||||
builder.state(runningStateToNodeState.get(from.getState()));
|
builder.status(runningStateToNodeStatus.get(from.getState()));
|
||||||
builder.publicAddresses(getPublicAddresses.apply(from));
|
builder.publicAddresses(getPublicAddresses.apply(from));
|
||||||
return builder.build();
|
return builder.build();
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@ public class RimuHostingComputeServiceContextModuleTest {
|
||||||
public void testAllStatusCovered() {
|
public void testAllStatusCovered() {
|
||||||
|
|
||||||
for (RunningState state : RunningState.values()) {
|
for (RunningState state : RunningState.values()) {
|
||||||
assert RimuHostingComputeServiceDependenciesModule.runningStateToNodeState.containsKey(state) : state;
|
assert RimuHostingComputeServiceDependenciesModule.runningStateToNodeStatus.containsKey(state) : state;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,8 +27,8 @@ import org.jclouds.compute.config.ComputeServiceAdapterContextModule;
|
||||||
import org.jclouds.compute.domain.Hardware;
|
import org.jclouds.compute.domain.Hardware;
|
||||||
import org.jclouds.compute.domain.Image;
|
import org.jclouds.compute.domain.Image;
|
||||||
import org.jclouds.compute.domain.NodeMetadata;
|
import org.jclouds.compute.domain.NodeMetadata;
|
||||||
import org.jclouds.compute.domain.NodeState;
|
|
||||||
import org.jclouds.compute.domain.OperatingSystem;
|
import org.jclouds.compute.domain.OperatingSystem;
|
||||||
|
import org.jclouds.compute.domain.NodeMetadata.Status;
|
||||||
import org.jclouds.compute.internal.BaseComputeService;
|
import org.jclouds.compute.internal.BaseComputeService;
|
||||||
import org.jclouds.domain.Location;
|
import org.jclouds.domain.Location;
|
||||||
import org.jclouds.functions.IdentityFunction;
|
import org.jclouds.functions.IdentityFunction;
|
||||||
|
@ -79,18 +79,18 @@ public class SlicehostComputeServiceContextModule extends
|
||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
public static final Map<Slice.Status, NodeState> sliceStatusToNodeState = ImmutableMap
|
public static final Map<Slice.Status, Status> sliceStatusToNodeStatus = ImmutableMap
|
||||||
.<Slice.Status, NodeState> builder().put(Slice.Status.ACTIVE, NodeState.RUNNING)//
|
.<Slice.Status, Status> builder().put(Slice.Status.ACTIVE, Status.RUNNING)//
|
||||||
.put(Slice.Status.BUILD, NodeState.PENDING)//
|
.put(Slice.Status.BUILD, Status.PENDING)//
|
||||||
.put(Slice.Status.REBOOT, NodeState.PENDING)//
|
.put(Slice.Status.REBOOT, Status.PENDING)//
|
||||||
.put(Slice.Status.HARD_REBOOT, NodeState.PENDING)//
|
.put(Slice.Status.HARD_REBOOT, Status.PENDING)//
|
||||||
.put(Slice.Status.TERMINATED, NodeState.TERMINATED)//
|
.put(Slice.Status.TERMINATED, Status.TERMINATED)//
|
||||||
.put(Slice.Status.UNRECOGNIZED, NodeState.UNRECOGNIZED)//
|
.put(Slice.Status.UNRECOGNIZED, Status.UNRECOGNIZED)//
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
@Provides
|
@Provides
|
||||||
Map<Slice.Status, NodeState> provideSliceToNodeState() {
|
Map<Slice.Status, Status> provideSliceToNodeStatus() {
|
||||||
return sliceStatusToNodeState;
|
return sliceStatusToNodeStatus;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,8 +33,8 @@ import org.jclouds.compute.domain.Hardware;
|
||||||
import org.jclouds.compute.domain.Image;
|
import org.jclouds.compute.domain.Image;
|
||||||
import org.jclouds.compute.domain.NodeMetadata;
|
import org.jclouds.compute.domain.NodeMetadata;
|
||||||
import org.jclouds.compute.domain.NodeMetadataBuilder;
|
import org.jclouds.compute.domain.NodeMetadataBuilder;
|
||||||
import org.jclouds.compute.domain.NodeState;
|
|
||||||
import org.jclouds.compute.domain.OperatingSystem;
|
import org.jclouds.compute.domain.OperatingSystem;
|
||||||
|
import org.jclouds.compute.domain.NodeMetadata.Status;
|
||||||
import org.jclouds.compute.functions.GroupNamingConvention;
|
import org.jclouds.compute.functions.GroupNamingConvention;
|
||||||
import org.jclouds.domain.Location;
|
import org.jclouds.domain.Location;
|
||||||
import org.jclouds.logging.Logger;
|
import org.jclouds.logging.Logger;
|
||||||
|
@ -51,7 +51,7 @@ import com.google.common.collect.Iterables;
|
||||||
@Singleton
|
@Singleton
|
||||||
public class SliceToNodeMetadata implements Function<Slice, NodeMetadata> {
|
public class SliceToNodeMetadata implements Function<Slice, NodeMetadata> {
|
||||||
protected final Supplier<Location> location;
|
protected final Supplier<Location> location;
|
||||||
protected final Map<Slice.Status, NodeState> sliceToNodeState;
|
protected final Map<Slice.Status, Status> sliceToNodeStatus;
|
||||||
protected final Supplier<Set<? extends Image>> images;
|
protected final Supplier<Set<? extends Image>> images;
|
||||||
protected final Supplier<Set<? extends Hardware>> hardwares;
|
protected final Supplier<Set<? extends Hardware>> hardwares;
|
||||||
protected final GroupNamingConvention nodeNamingConvention;
|
protected final GroupNamingConvention nodeNamingConvention;
|
||||||
|
@ -86,12 +86,12 @@ public class SliceToNodeMetadata implements Function<Slice, NodeMetadata> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
SliceToNodeMetadata(Map<Slice.Status, NodeState> sliceStateToNodeState,
|
SliceToNodeMetadata(Map<Slice.Status, Status> sliceStateToNodeStatus,
|
||||||
@Memoized Supplier<Set<? extends Image>> images, Supplier<Location> location,
|
@Memoized Supplier<Set<? extends Image>> images, Supplier<Location> location,
|
||||||
@Memoized Supplier<Set<? extends Hardware>> hardwares,
|
@Memoized Supplier<Set<? extends Hardware>> hardwares,
|
||||||
GroupNamingConvention.Factory namingConvention) {
|
GroupNamingConvention.Factory namingConvention) {
|
||||||
this.nodeNamingConvention = checkNotNull(namingConvention, "namingConvention").createWithoutPrefix();
|
this.nodeNamingConvention = checkNotNull(namingConvention, "namingConvention").createWithoutPrefix();
|
||||||
this.sliceToNodeState = checkNotNull(sliceStateToNodeState, "sliceStateToNodeState");
|
this.sliceToNodeStatus = checkNotNull(sliceStateToNodeStatus, "sliceStateToNodeStatus");
|
||||||
this.images = checkNotNull(images, "images");
|
this.images = checkNotNull(images, "images");
|
||||||
this.location = checkNotNull(location, "location");
|
this.location = checkNotNull(location, "location");
|
||||||
this.hardwares = checkNotNull(hardwares, "hardwares");
|
this.hardwares = checkNotNull(hardwares, "hardwares");
|
||||||
|
@ -108,7 +108,7 @@ public class SliceToNodeMetadata implements Function<Slice, NodeMetadata> {
|
||||||
builder.imageId(from.getImageId() + "");
|
builder.imageId(from.getImageId() + "");
|
||||||
builder.operatingSystem(parseOperatingSystem(from));
|
builder.operatingSystem(parseOperatingSystem(from));
|
||||||
builder.hardware(parseHardware(from));
|
builder.hardware(parseHardware(from));
|
||||||
builder.state(sliceToNodeState.get(from.getStatus()));
|
builder.status(sliceToNodeStatus.get(from.getStatus()));
|
||||||
builder.publicAddresses(Iterables.filter(from.getAddresses(), new Predicate<String>() {
|
builder.publicAddresses(Iterables.filter(from.getAddresses(), new Predicate<String>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -30,7 +30,7 @@ public class SlicehostComputeServiceContextModuleTest {
|
||||||
public void testAllStatusCovered() {
|
public void testAllStatusCovered() {
|
||||||
|
|
||||||
for (Slice.Status state : Slice.Status.values()) {
|
for (Slice.Status state : Slice.Status.values()) {
|
||||||
assert SlicehostComputeServiceContextModule.sliceStatusToNodeState.containsKey(state) : state;
|
assert SlicehostComputeServiceContextModule.sliceStatusToNodeStatus.containsKey(state) : state;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,12 +28,12 @@ import org.jclouds.compute.domain.HardwareBuilder;
|
||||||
import org.jclouds.compute.domain.Image;
|
import org.jclouds.compute.domain.Image;
|
||||||
import org.jclouds.compute.domain.NodeMetadata;
|
import org.jclouds.compute.domain.NodeMetadata;
|
||||||
import org.jclouds.compute.domain.NodeMetadataBuilder;
|
import org.jclouds.compute.domain.NodeMetadataBuilder;
|
||||||
import org.jclouds.compute.domain.NodeState;
|
|
||||||
import org.jclouds.compute.domain.OperatingSystem;
|
import org.jclouds.compute.domain.OperatingSystem;
|
||||||
import org.jclouds.compute.domain.OsFamily;
|
import org.jclouds.compute.domain.OsFamily;
|
||||||
import org.jclouds.compute.domain.Processor;
|
import org.jclouds.compute.domain.Processor;
|
||||||
import org.jclouds.compute.domain.Volume;
|
import org.jclouds.compute.domain.Volume;
|
||||||
import org.jclouds.compute.domain.VolumeBuilder;
|
import org.jclouds.compute.domain.VolumeBuilder;
|
||||||
|
import org.jclouds.compute.domain.NodeMetadata.Status;
|
||||||
import org.jclouds.compute.functions.GroupNamingConvention;
|
import org.jclouds.compute.functions.GroupNamingConvention;
|
||||||
import org.jclouds.domain.Location;
|
import org.jclouds.domain.Location;
|
||||||
import org.jclouds.domain.LocationBuilder;
|
import org.jclouds.domain.LocationBuilder;
|
||||||
|
@ -59,18 +59,18 @@ public class SliceToNodeMetadataTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testApplyWhereImageAndHardwareNotFound() {
|
public void testApplyWhereImageAndHardwareNotFound() {
|
||||||
Map<Slice.Status, NodeState> sliceStateToNodeState = SlicehostComputeServiceContextModule.sliceStatusToNodeState;
|
Map<Slice.Status, Status> sliceStateToNodeStatus = SlicehostComputeServiceContextModule.sliceStatusToNodeStatus;
|
||||||
Set<org.jclouds.compute.domain.Image> images = ImmutableSet.of();
|
Set<org.jclouds.compute.domain.Image> images = ImmutableSet.of();
|
||||||
Set<org.jclouds.compute.domain.Hardware> hardwares = ImmutableSet.of();
|
Set<org.jclouds.compute.domain.Hardware> hardwares = ImmutableSet.of();
|
||||||
Slice slice = SliceHandlerTest.parseSlice();
|
Slice slice = SliceHandlerTest.parseSlice();
|
||||||
|
|
||||||
SliceToNodeMetadata parser = new SliceToNodeMetadata(sliceStateToNodeState, Suppliers
|
SliceToNodeMetadata parser = new SliceToNodeMetadata(sliceStateToNodeStatus, Suppliers
|
||||||
.<Set<? extends Image>> ofInstance(images), Suppliers.ofInstance(provider), Suppliers
|
.<Set<? extends Image>> ofInstance(images), Suppliers.ofInstance(provider), Suppliers
|
||||||
.<Set<? extends Hardware>> ofInstance(hardwares), namingConvention);
|
.<Set<? extends Hardware>> ofInstance(hardwares), namingConvention);
|
||||||
|
|
||||||
NodeMetadata metadata = parser.apply(slice);
|
NodeMetadata metadata = parser.apply(slice);
|
||||||
|
|
||||||
assertEquals(metadata, new NodeMetadataBuilder().state(NodeState.PENDING).publicAddresses(
|
assertEquals(metadata, new NodeMetadataBuilder().status(Status.PENDING).publicAddresses(
|
||||||
ImmutableSet.of("174.143.212.229")).privateAddresses(ImmutableSet.of("10.176.164.199")).group("jclouds")
|
ImmutableSet.of("174.143.212.229")).privateAddresses(ImmutableSet.of("10.176.164.199")).group("jclouds")
|
||||||
.imageId("2").id("1").providerId("1").name("jclouds-foo").hostname("jclouds-foo").location(provider)
|
.imageId("2").id("1").providerId("1").name("jclouds-foo").hostname("jclouds-foo").location(provider)
|
||||||
.userMetadata(ImmutableMap.of("Server Label", "Web Head 1", "Image Version", "2.1")).build());
|
.userMetadata(ImmutableMap.of("Server Label", "Web Head 1", "Image Version", "2.1")).build());
|
||||||
|
@ -78,18 +78,18 @@ public class SliceToNodeMetadataTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testApplyWhereImageFoundAndHardwareNotFound() {
|
public void testApplyWhereImageFoundAndHardwareNotFound() {
|
||||||
Map<Slice.Status, NodeState> sliceStateToNodeState = SlicehostComputeServiceContextModule.sliceStatusToNodeState;
|
Map<Slice.Status, Status> sliceStateToNodeStatus = SlicehostComputeServiceContextModule.sliceStatusToNodeStatus;
|
||||||
org.jclouds.compute.domain.Image jcImage = SlicehostImageToImageTest.convertImage();
|
org.jclouds.compute.domain.Image jcImage = SlicehostImageToImageTest.convertImage();
|
||||||
Set<org.jclouds.compute.domain.Image> images = ImmutableSet.of(jcImage);
|
Set<org.jclouds.compute.domain.Image> images = ImmutableSet.of(jcImage);
|
||||||
Set<org.jclouds.compute.domain.Hardware> hardwares = ImmutableSet.of();
|
Set<org.jclouds.compute.domain.Hardware> hardwares = ImmutableSet.of();
|
||||||
Slice slice = SliceHandlerTest.parseSlice();
|
Slice slice = SliceHandlerTest.parseSlice();
|
||||||
|
|
||||||
SliceToNodeMetadata parser = new SliceToNodeMetadata(sliceStateToNodeState, Suppliers
|
SliceToNodeMetadata parser = new SliceToNodeMetadata(sliceStateToNodeStatus, Suppliers
|
||||||
.<Set<? extends Image>> ofInstance(images), Suppliers.ofInstance(provider), Suppliers
|
.<Set<? extends Image>> ofInstance(images), Suppliers.ofInstance(provider), Suppliers
|
||||||
.<Set<? extends Hardware>> ofInstance(hardwares), namingConvention);
|
.<Set<? extends Hardware>> ofInstance(hardwares), namingConvention);
|
||||||
|
|
||||||
NodeMetadata metadata = parser.apply(slice);
|
NodeMetadata metadata = parser.apply(slice);
|
||||||
assertEquals(metadata, new NodeMetadataBuilder().state(NodeState.PENDING).publicAddresses(
|
assertEquals(metadata, new NodeMetadataBuilder().status(Status.PENDING).publicAddresses(
|
||||||
ImmutableSet.of("174.143.212.229")).privateAddresses(ImmutableSet.of("10.176.164.199")).group("jclouds")
|
ImmutableSet.of("174.143.212.229")).privateAddresses(ImmutableSet.of("10.176.164.199")).group("jclouds")
|
||||||
.imageId("2").operatingSystem(
|
.imageId("2").operatingSystem(
|
||||||
new OperatingSystem.Builder().family(OsFamily.CENTOS).description("CentOS 5.2").version("5.2")
|
new OperatingSystem.Builder().family(OsFamily.CENTOS).description("CentOS 5.2").version("5.2")
|
||||||
|
@ -100,17 +100,17 @@ public class SliceToNodeMetadataTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testApplyWhereImageAndHardwareFound() {
|
public void testApplyWhereImageAndHardwareFound() {
|
||||||
Map<Slice.Status, NodeState> sliceStateToNodeState = SlicehostComputeServiceContextModule.sliceStatusToNodeState;
|
Map<Slice.Status, Status> sliceStateToNodeStatus = SlicehostComputeServiceContextModule.sliceStatusToNodeStatus;
|
||||||
Set<org.jclouds.compute.domain.Image> images = ImmutableSet.of(SlicehostImageToImageTest.convertImage());
|
Set<org.jclouds.compute.domain.Image> images = ImmutableSet.of(SlicehostImageToImageTest.convertImage());
|
||||||
Set<org.jclouds.compute.domain.Hardware> hardwares = ImmutableSet.of(FlavorToHardwareTest.convertFlavor());
|
Set<org.jclouds.compute.domain.Hardware> hardwares = ImmutableSet.of(FlavorToHardwareTest.convertFlavor());
|
||||||
Slice slice = SliceHandlerTest.parseSlice();
|
Slice slice = SliceHandlerTest.parseSlice();
|
||||||
|
|
||||||
SliceToNodeMetadata parser = new SliceToNodeMetadata(sliceStateToNodeState, Suppliers
|
SliceToNodeMetadata parser = new SliceToNodeMetadata(sliceStateToNodeStatus, Suppliers
|
||||||
.<Set<? extends Image>> ofInstance(images), Suppliers.ofInstance(provider), Suppliers
|
.<Set<? extends Image>> ofInstance(images), Suppliers.ofInstance(provider), Suppliers
|
||||||
.<Set<? extends Hardware>> ofInstance(hardwares), namingConvention);
|
.<Set<? extends Hardware>> ofInstance(hardwares), namingConvention);
|
||||||
|
|
||||||
NodeMetadata metadata = parser.apply(slice);
|
NodeMetadata metadata = parser.apply(slice);
|
||||||
assertEquals(metadata, new NodeMetadataBuilder().state(NodeState.PENDING).publicAddresses(
|
assertEquals(metadata, new NodeMetadataBuilder().status(Status.PENDING).publicAddresses(
|
||||||
ImmutableSet.of("174.143.212.229")).privateAddresses(ImmutableSet.of("10.176.164.199")).group("jclouds")
|
ImmutableSet.of("174.143.212.229")).privateAddresses(ImmutableSet.of("10.176.164.199")).group("jclouds")
|
||||||
.imageId("2").hardware(
|
.imageId("2").hardware(
|
||||||
new HardwareBuilder().ids("1").name("256 slice").processors(
|
new HardwareBuilder().ids("1").name("256 slice").processors(
|
||||||
|
|
|
@ -32,7 +32,7 @@ import org.jclouds.compute.domain.Hardware;
|
||||||
import org.jclouds.compute.domain.Image;
|
import org.jclouds.compute.domain.Image;
|
||||||
import org.jclouds.compute.domain.NodeMetadata;
|
import org.jclouds.compute.domain.NodeMetadata;
|
||||||
import org.jclouds.compute.domain.NodeMetadataBuilder;
|
import org.jclouds.compute.domain.NodeMetadataBuilder;
|
||||||
import org.jclouds.compute.domain.NodeState;
|
import org.jclouds.compute.domain.NodeMetadata.Status;
|
||||||
import org.jclouds.compute.functions.GroupNamingConvention;
|
import org.jclouds.compute.functions.GroupNamingConvention;
|
||||||
import org.jclouds.domain.Location;
|
import org.jclouds.domain.Location;
|
||||||
import org.jclouds.softlayer.SoftLayerClient;
|
import org.jclouds.softlayer.SoftLayerClient;
|
||||||
|
@ -54,10 +54,10 @@ import com.google.common.collect.Iterables;
|
||||||
@Singleton
|
@Singleton
|
||||||
public class VirtualGuestToNodeMetadata implements Function<VirtualGuest, NodeMetadata> {
|
public class VirtualGuestToNodeMetadata implements Function<VirtualGuest, NodeMetadata> {
|
||||||
|
|
||||||
public static final Map<VirtualGuest.State, NodeState> serverStateToNodeState = ImmutableMap
|
public static final Map<VirtualGuest.State, Status> serverStateToNodeStatus = ImmutableMap
|
||||||
.<VirtualGuest.State, NodeState> builder().put(VirtualGuest.State.HALTED, NodeState.PENDING)
|
.<VirtualGuest.State, Status> builder().put(VirtualGuest.State.HALTED, Status.PENDING)
|
||||||
.put(VirtualGuest.State.PAUSED, NodeState.SUSPENDED).put(VirtualGuest.State.RUNNING, NodeState.RUNNING)
|
.put(VirtualGuest.State.PAUSED, Status.SUSPENDED).put(VirtualGuest.State.RUNNING, Status.RUNNING)
|
||||||
.put(VirtualGuest.State.UNRECOGNIZED, NodeState.UNRECOGNIZED).build();
|
.put(VirtualGuest.State.UNRECOGNIZED, Status.UNRECOGNIZED).build();
|
||||||
|
|
||||||
private final FindLocationForVirtualGuest findLocationForVirtualGuest;
|
private final FindLocationForVirtualGuest findLocationForVirtualGuest;
|
||||||
private final GetHardwareForVirtualGuest getHardwareForVirtualGuest;
|
private final GetHardwareForVirtualGuest getHardwareForVirtualGuest;
|
||||||
|
@ -94,7 +94,7 @@ public class VirtualGuestToNodeMetadata implements Function<VirtualGuest, NodeMe
|
||||||
if (hardware != null)
|
if (hardware != null)
|
||||||
builder.hardware(hardware);
|
builder.hardware(hardware);
|
||||||
|
|
||||||
builder.state(serverStateToNodeState.get(from.getPowerState().getKeyName()));
|
builder.status(serverStateToNodeStatus.get(from.getPowerState().getKeyName()));
|
||||||
|
|
||||||
// These are null for 'bad' guest orders in the HALTED state.
|
// These are null for 'bad' guest orders in the HALTED state.
|
||||||
if (from.getPrimaryIpAddress() != null)
|
if (from.getPrimaryIpAddress() != null)
|
||||||
|
|
|
@ -29,8 +29,8 @@ import org.jclouds.compute.domain.Image;
|
||||||
import org.jclouds.compute.domain.ImageBuilder;
|
import org.jclouds.compute.domain.ImageBuilder;
|
||||||
import org.jclouds.compute.domain.NodeMetadata;
|
import org.jclouds.compute.domain.NodeMetadata;
|
||||||
import org.jclouds.compute.domain.NodeMetadataBuilder;
|
import org.jclouds.compute.domain.NodeMetadataBuilder;
|
||||||
import org.jclouds.compute.domain.NodeState;
|
|
||||||
import org.jclouds.compute.domain.OperatingSystem;
|
import org.jclouds.compute.domain.OperatingSystem;
|
||||||
|
import org.jclouds.compute.domain.NodeMetadata.Status;
|
||||||
import org.jclouds.compute.functions.GroupNamingConvention;
|
import org.jclouds.compute.functions.GroupNamingConvention;
|
||||||
import org.jclouds.domain.Location;
|
import org.jclouds.domain.Location;
|
||||||
import org.jclouds.softlayer.SoftLayerClient;
|
import org.jclouds.softlayer.SoftLayerClient;
|
||||||
|
@ -75,7 +75,7 @@ public class VirtualGuestToNodeMetadataTest {
|
||||||
assertEquals(
|
assertEquals(
|
||||||
node,
|
node,
|
||||||
new NodeMetadataBuilder().ids("416788").name("node1000360500").hostname("node1000360500")
|
new NodeMetadataBuilder().ids("416788").name("node1000360500").hostname("node1000360500")
|
||||||
.location(expectedLocation).state(NodeState.PENDING)
|
.location(expectedLocation).status(Status.PENDING)
|
||||||
.publicAddresses(ImmutableSet.of("173.192.29.186"))
|
.publicAddresses(ImmutableSet.of("173.192.29.186"))
|
||||||
.privateAddresses(ImmutableSet.of("10.37.102.194"))
|
.privateAddresses(ImmutableSet.of("10.37.102.194"))
|
||||||
.hardware(new GetHardwareForVirtualGuestMock().getHardware(guest))
|
.hardware(new GetHardwareForVirtualGuestMock().getHardware(guest))
|
||||||
|
@ -102,7 +102,7 @@ public class VirtualGuestToNodeMetadataTest {
|
||||||
assertEquals(
|
assertEquals(
|
||||||
node,
|
node,
|
||||||
new NodeMetadataBuilder().ids("413348").name("foo-ef4").hostname("foo-ef4").group("foo")
|
new NodeMetadataBuilder().ids("413348").name("foo-ef4").hostname("foo-ef4").group("foo")
|
||||||
.state(NodeState.PENDING).hardware(new GetHardwareForVirtualGuestMock().getHardware(guest))
|
.status(Status.PENDING).hardware(new GetHardwareForVirtualGuestMock().getHardware(guest))
|
||||||
.imageId(new GetImageForVirtualGuestMock().getImage(guest).getId())
|
.imageId(new GetImageForVirtualGuestMock().getImage(guest).getId())
|
||||||
.operatingSystem(new GetImageForVirtualGuestMock().getImage(guest).getOperatingSystem()).build());
|
.operatingSystem(new GetImageForVirtualGuestMock().getImage(guest).getOperatingSystem()).build());
|
||||||
|
|
||||||
|
@ -127,7 +127,7 @@ public class VirtualGuestToNodeMetadataTest {
|
||||||
assertEquals(
|
assertEquals(
|
||||||
node,
|
node,
|
||||||
new NodeMetadataBuilder().ids("416700").name("node1703810489").hostname("node1703810489")
|
new NodeMetadataBuilder().ids("416700").name("node1703810489").hostname("node1703810489")
|
||||||
.location(expectedLocation).state(NodeState.PENDING)
|
.location(expectedLocation).status(Status.PENDING)
|
||||||
.publicAddresses(ImmutableSet.of("173.192.29.187"))
|
.publicAddresses(ImmutableSet.of("173.192.29.187"))
|
||||||
.privateAddresses(ImmutableSet.of("10.37.102.195"))
|
.privateAddresses(ImmutableSet.of("10.37.102.195"))
|
||||||
.hardware(new GetHardwareForVirtualGuestMock().getHardware(guest))
|
.hardware(new GetHardwareForVirtualGuestMock().getHardware(guest))
|
||||||
|
@ -155,7 +155,7 @@ public class VirtualGuestToNodeMetadataTest {
|
||||||
assertEquals(
|
assertEquals(
|
||||||
node,
|
node,
|
||||||
new NodeMetadataBuilder().ids("416700").name("node1703810489").hostname("node1703810489")
|
new NodeMetadataBuilder().ids("416700").name("node1703810489").hostname("node1703810489")
|
||||||
.location(expectedLocation).state(NodeState.SUSPENDED)
|
.location(expectedLocation).status(Status.SUSPENDED)
|
||||||
.publicAddresses(ImmutableSet.of("173.192.29.187"))
|
.publicAddresses(ImmutableSet.of("173.192.29.187"))
|
||||||
.privateAddresses(ImmutableSet.of("10.37.102.195"))
|
.privateAddresses(ImmutableSet.of("10.37.102.195"))
|
||||||
.hardware(new GetHardwareForVirtualGuestMock().getHardware(guest))
|
.hardware(new GetHardwareForVirtualGuestMock().getHardware(guest))
|
||||||
|
@ -183,7 +183,7 @@ public class VirtualGuestToNodeMetadataTest {
|
||||||
assertEquals(
|
assertEquals(
|
||||||
node,
|
node,
|
||||||
new NodeMetadataBuilder().ids("416700").name("node1703810489").hostname("node1703810489")
|
new NodeMetadataBuilder().ids("416700").name("node1703810489").hostname("node1703810489")
|
||||||
.location(expectedLocation).state(NodeState.RUNNING)
|
.location(expectedLocation).status(Status.RUNNING)
|
||||||
.publicAddresses(ImmutableSet.of("173.192.29.187"))
|
.publicAddresses(ImmutableSet.of("173.192.29.187"))
|
||||||
.privateAddresses(ImmutableSet.of("10.37.102.195"))
|
.privateAddresses(ImmutableSet.of("10.37.102.195"))
|
||||||
.hardware(new GetHardwareForVirtualGuestMock().getHardware(guest))
|
.hardware(new GetHardwareForVirtualGuestMock().getHardware(guest))
|
||||||
|
|
|
@ -32,7 +32,7 @@ import org.jclouds.compute.domain.Hardware;
|
||||||
import org.jclouds.compute.domain.Image;
|
import org.jclouds.compute.domain.Image;
|
||||||
import org.jclouds.compute.domain.NodeMetadata;
|
import org.jclouds.compute.domain.NodeMetadata;
|
||||||
import org.jclouds.compute.domain.NodeMetadataBuilder;
|
import org.jclouds.compute.domain.NodeMetadataBuilder;
|
||||||
import org.jclouds.compute.domain.NodeState;
|
import org.jclouds.compute.domain.NodeMetadata.Status;
|
||||||
import org.jclouds.compute.functions.GroupNamingConvention;
|
import org.jclouds.compute.functions.GroupNamingConvention;
|
||||||
import org.jclouds.domain.Credentials;
|
import org.jclouds.domain.Credentials;
|
||||||
import org.jclouds.domain.Location;
|
import org.jclouds.domain.Location;
|
||||||
|
@ -50,11 +50,11 @@ import com.google.common.collect.ImmutableSet;
|
||||||
@Singleton
|
@Singleton
|
||||||
public class ServerToNodeMetadata implements Function<Server, NodeMetadata> {
|
public class ServerToNodeMetadata implements Function<Server, NodeMetadata> {
|
||||||
|
|
||||||
public static final Map<Server.Status, NodeState> serverStatusToNodeState = ImmutableMap
|
public static final Map<Server.Status, Status> serverStatusToNodeStatus = ImmutableMap
|
||||||
.<Server.Status, NodeState> builder().put(Server.Status.ACTIVE, NodeState.RUNNING)//
|
.<Server.Status, Status> builder().put(Server.Status.ACTIVE, Status.RUNNING)//
|
||||||
.put(Server.Status.BUILD, NodeState.PENDING)//
|
.put(Server.Status.BUILD, Status.PENDING)//
|
||||||
.put(Server.Status.TERMINATED, NodeState.TERMINATED)//
|
.put(Server.Status.TERMINATED, Status.TERMINATED)//
|
||||||
.put(Server.Status.UNRECOGNIZED, NodeState.UNRECOGNIZED)//
|
.put(Server.Status.UNRECOGNIZED, Status.UNRECOGNIZED)//
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
private final FindHardwareForServer findHardwareForServer;
|
private final FindHardwareForServer findHardwareForServer;
|
||||||
|
@ -87,7 +87,7 @@ public class ServerToNodeMetadata implements Function<Server, NodeMetadata> {
|
||||||
if (image != null)
|
if (image != null)
|
||||||
builder.operatingSystem(image.getOperatingSystem());
|
builder.operatingSystem(image.getOperatingSystem());
|
||||||
builder.hardware(findHardwareForServer.apply(from));
|
builder.hardware(findHardwareForServer.apply(from));
|
||||||
builder.state(serverStatusToNodeState.get(from.status));
|
builder.status(serverStatusToNodeStatus.get(from.status));
|
||||||
builder.publicAddresses(ImmutableSet.<String> of(from.publicAddress));
|
builder.publicAddresses(ImmutableSet.<String> of(from.publicAddress));
|
||||||
builder.privateAddresses(ImmutableSet.<String> of(from.privateAddress));
|
builder.privateAddresses(ImmutableSet.<String> of(from.privateAddress));
|
||||||
builder.credentials(LoginCredentials.fromCredentials(credentialStore.get(from.id + "")));
|
builder.credentials(LoginCredentials.fromCredentials(credentialStore.get(from.id + "")));
|
||||||
|
|
Loading…
Reference in New Issue