From 07c2c2472124c0c4d5747438b353665c124a5c51 Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Tue, 29 May 2012 20:41:10 -0700 Subject: [PATCH] Issue 949:Introduce: ComputeMetadataIncludingStatus; Deprecate NodeState -> NodeMetadata.Status --- .../byon/functions/NodeToNodeMetadata.java | 4 +- .../functions/NodeToNodeMetadataTest.java | 4 +- ...oudServersComputeServiceContextModule.java | 56 ++++++------ .../functions/ServerToNodeMetadata.java | 10 +-- ...erversComputeServiceContextModuleTest.java | 2 +- .../functions/ServerToNodeMetadataTest.java | 20 ++--- .../functions/ServerInfoToNodeMetadata.java | 18 ++-- .../VirtualMachineToNodeMetadata.java | 24 ++--- .../VirtualMachineToNodeMetadataTest.java | 8 +- .../functions/InstanceToNodeMetadata.java | 14 +-- .../EC2ComputeServiceDependenciesModule.java | 16 ++-- .../RunningInstanceToNodeMetadata.java | 14 +-- .../AddElasticIpsToNodemetadataTest.java | 4 +- .../RunningInstanceToNodeMetadataTest.java | 32 +++---- ...EC2CreateNodesInGroupThenAddToSetTest.java | 6 +- .../functions/ServerInfoToNodeMetadata.java | 18 ++-- .../NovaComputeServiceContextModule.java | 40 ++++----- .../functions/ServerToNodeMetadata.java | 10 +-- .../NovaComputeServiceContextModuleTest.java | 2 +- .../functions/ServerToNodeMetadataTest.java | 16 ++-- .../functions/ServerInZoneToNodeMetadata.java | 2 +- .../openstack/nova/v1_1/domain/Server.java | 22 ++--- ...ocateAndAddFloatingIpToNodeExpectTest.java | 4 +- .../functions/OrphanedGroupsByZoneIdTest.java | 1 - .../ServerInZoneToNodeMetadataTest.java | 3 +- .../v1_1/parse/ParseCreatedServerTest.java | 4 - ...CloudComputeServiceDependenciesModule.java | 17 ++-- .../compute/functions/VAppToNodeMetadata.java | 9 +- .../functions/VAppToNodeMetadataTest.java | 3 +- .../compute/TerremarkVCloudComputeClient.java | 10 +-- ...markVCloudComputeServiceContextModule.java | 14 +-- .../compute/functions/VAppToNodeMetadata.java | 9 +- .../TerremarkVCloudComputeClientTest.java | 10 +-- .../strategy/CleanupOrphanKeysTest.java | 6 +- .../src/main/clojure/org/jclouds/compute2.clj | 28 +++--- .../config/ComputeServiceTimeoutsModule.java | 4 +- .../ComputeMetadataIncludingStatus.java | 32 +++++++ .../jclouds/compute/domain/NodeMetadata.java | 37 +++++++- .../compute/domain/NodeMetadataBuilder.java | 52 ++++------- .../org/jclouds/compute/domain/NodeState.java | 51 ++++++++++- .../compute/domain/TemplateBuilderSpec.java | 8 +- .../domain/internal/NodeMetadataImpl.java | 51 ++++------- .../compute/internal/BaseComputeService.java | 10 +-- .../compute/options/TemplateOptions.java | 4 +- .../compute/predicates/AtomicNodeRunning.java | 9 +- .../predicates/AtomicNodeSuspended.java | 9 +- ...OnFalse.java => AtomicNodeTerminated.java} | 44 +++------ .../compute/predicates/NodePredicates.java | 8 +- ...ndDoubleCheckOnFailUnlessStateInvalid.java | 90 ------------------- ...dDoubleCheckOnFailUnlessStatusInvalid.java | 77 ++++++++++++++++ ...dDoubleCheckOnFailUnlessStatusInvalid.java | 65 ++++++++++++++ ...OrDeletedRefreshAndDoubleCheckOnFalse.java | 67 ++++++++++++++ ...dAddToGoodMapOrPutExceptionIntoBadMap.java | 12 +-- .../AdaptingComputeServiceStrategies.java | 4 +- ...sWithGroupEncodedIntoNameThenAddToSet.java | 8 +- .../config/StubComputeServiceAdapter.java | 44 ++++----- .../StubComputeServiceDependenciesModule.java | 4 +- ...riptUsingSshAndBlockUntilCompleteTest.java | 12 +-- ...nScriptOnNodeAsInitScriptUsingSshTest.java | 10 +-- .../config/PersistNodeCredentialsTest.java | 10 +-- .../internal/BaseComputeServiceLiveTest.java | 18 ++-- .../predicates/AtomicNodePredicatesTest.java | 20 ++--- ...ToGoodMapOrPutExceptionIntoBadMapTest.java | 16 ++-- .../ServerDetailsToNodeMetadata.java | 14 +-- .../ServerDetailsToNodeMetadataTest.java | 4 +- .../java/org/jclouds/nodepool/AppTest.java | 4 +- .../keystone/v2_0/AdminClientExpectTest.java | 1 + .../compute/functions/VMToNodeMetadata.java | 14 +-- .../compute/functions/VmToNodeMetadata.java | 11 ++- ...rdcodeLocalhostAsNodeMetadataSupplier.java | 5 +- ...VirtualBoxComputeServiceContextModule.java | 36 ++++---- .../functions/IMachineToNodeMetadata.java | 10 +-- .../virtualbox/functions/NodeCreator.java | 2 +- .../StartVBoxIfNotAlreadyRunningLiveTest.java | 6 +- .../AWSRunningInstanceToNodeMetadata.java | 6 +- .../AWSRunningInstanceToNodeMetadataTest.java | 14 +-- .../GoGridComputeServiceContextModule.java | 26 +++--- .../functions/ServerToNodeMetadata.java | 10 +-- ...GoGridComputeServiceContextModuleTest.java | 2 +- .../functions/ServerToNodeMetadataTest.java | 12 +-- .../miro/binder/RimuHostingJsonBinder.java | 1 - ...stingComputeServiceDependenciesModule.java | 18 ++-- .../functions/ServerToNodeMetadata.java | 14 +-- ...ostingComputeServiceContextModuleTest.java | 2 +- .../SlicehostComputeServiceContextModule.java | 20 ++--- .../functions/SliceToNodeMetadata.java | 10 +-- ...cehostComputeServiceContextModuleTest.java | 2 +- .../functions/SliceToNodeMetadataTest.java | 20 ++--- .../functions/VirtualGuestToNodeMetadata.java | 12 +-- .../VirtualGuestToNodeMetadataTest.java | 12 +-- .../functions/ServerToNodeMetadata.java | 14 +-- 91 files changed, 857 insertions(+), 681 deletions(-) create mode 100644 compute/src/main/java/org/jclouds/compute/domain/ComputeMetadataIncludingStatus.java rename compute/src/main/java/org/jclouds/compute/predicates/{TrueIfNullOrTerminatedRefreshAndDoubleCheckOnFalse.java => AtomicNodeTerminated.java} (51%) delete mode 100644 compute/src/main/java/org/jclouds/compute/predicates/RefreshAndDoubleCheckOnFailUnlessStateInvalid.java create mode 100644 compute/src/main/java/org/jclouds/compute/predicates/internal/RefreshAndDoubleCheckOnFailUnlessStatusInvalid.java create mode 100644 compute/src/main/java/org/jclouds/compute/predicates/internal/RefreshNodeAndDoubleCheckOnFailUnlessStatusInvalid.java create mode 100644 compute/src/main/java/org/jclouds/compute/predicates/internal/TrueIfNullOrDeletedRefreshAndDoubleCheckOnFalse.java diff --git a/apis/byon/src/main/java/org/jclouds/byon/functions/NodeToNodeMetadata.java b/apis/byon/src/main/java/org/jclouds/byon/functions/NodeToNodeMetadata.java index 878da381b3..8b9655fe5d 100644 --- a/apis/byon/src/main/java/org/jclouds/byon/functions/NodeToNodeMetadata.java +++ b/apis/byon/src/main/java/org/jclouds/byon/functions/NodeToNodeMetadata.java @@ -36,9 +36,9 @@ import org.jclouds.byon.Node; import org.jclouds.collect.Memoized; import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.domain.NodeMetadataBuilder; -import org.jclouds.compute.domain.NodeState; import org.jclouds.compute.domain.OperatingSystem; import org.jclouds.compute.domain.OsFamily; +import org.jclouds.compute.domain.NodeMetadata.Status; import org.jclouds.compute.reference.ComputeServiceConstants; import org.jclouds.domain.Credentials; import org.jclouds.domain.Location; @@ -90,7 +90,7 @@ public class NodeToNodeMetadata implements Function { builder.operatingSystem(OperatingSystem.builder().arch(from.getOsArch()).family( OsFamily.fromValue(from.getOsFamily())).description(from.getOsDescription()) .version(from.getOsVersion()).build()); - builder.state(NodeState.RUNNING); + builder.status(Status.RUNNING); builder.publicAddresses(ImmutableSet. of(from.getHostname())); if (from.getUsername() != null) { diff --git a/apis/byon/src/test/java/org/jclouds/byon/functions/NodeToNodeMetadataTest.java b/apis/byon/src/test/java/org/jclouds/byon/functions/NodeToNodeMetadataTest.java index f3bb421920..8a5034fa24 100644 --- a/apis/byon/src/test/java/org/jclouds/byon/functions/NodeToNodeMetadataTest.java +++ b/apis/byon/src/test/java/org/jclouds/byon/functions/NodeToNodeMetadataTest.java @@ -27,9 +27,9 @@ import java.util.Set; import org.jclouds.byon.suppliers.SupplyFromProviderURIOrNodesProperty; import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.domain.NodeMetadataBuilder; -import org.jclouds.compute.domain.NodeState; import org.jclouds.compute.domain.OperatingSystem; import org.jclouds.compute.domain.OsFamily; +import org.jclouds.compute.domain.NodeMetadata.Status; import org.jclouds.domain.Credentials; import org.jclouds.domain.Location; import org.jclouds.domain.LocationBuilder; @@ -88,7 +88,7 @@ public class NodeToNodeMetadataTest { .location(location) .userMetadata(ImmutableMap.of("Name", "foo")) .tags(ImmutableSet.of("vanilla")) - .state(NodeState.RUNNING) + .status(Status.RUNNING) .operatingSystem( OperatingSystem.builder().description("redhat").family(OsFamily.RHEL).arch("x86").version("5.3") .build()) diff --git a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/compute/config/CloudServersComputeServiceContextModule.java b/apis/cloudservers/src/main/java/org/jclouds/cloudservers/compute/config/CloudServersComputeServiceContextModule.java index 2810f6012a..8ab0b09680 100644 --- a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/compute/config/CloudServersComputeServiceContextModule.java +++ b/apis/cloudservers/src/main/java/org/jclouds/cloudservers/compute/config/CloudServersComputeServiceContextModule.java @@ -37,8 +37,8 @@ import org.jclouds.compute.config.ComputeServiceAdapterContextModule; import org.jclouds.compute.domain.Hardware; import org.jclouds.compute.domain.Image; import org.jclouds.compute.domain.NodeMetadata; -import org.jclouds.compute.domain.NodeState; import org.jclouds.compute.domain.OperatingSystem; +import org.jclouds.compute.domain.NodeMetadata.Status; import org.jclouds.compute.extensions.ImageExtension; import org.jclouds.compute.internal.BaseComputeService; import org.jclouds.domain.Location; @@ -93,36 +93,36 @@ public class CloudServersComputeServiceContextModule extends } @VisibleForTesting - public static final Map serverToNodeState = ImmutableMap - . builder().put(ServerStatus.ACTIVE, NodeState.RUNNING)// - .put(ServerStatus.SUSPENDED, NodeState.SUSPENDED)// - .put(ServerStatus.DELETED, NodeState.TERMINATED)// - .put(ServerStatus.QUEUE_RESIZE, NodeState.PENDING)// - .put(ServerStatus.PREP_RESIZE, NodeState.PENDING)// - .put(ServerStatus.RESIZE, NodeState.PENDING)// - .put(ServerStatus.VERIFY_RESIZE, NodeState.PENDING)// - .put(ServerStatus.QUEUE_MOVE, NodeState.PENDING)// - .put(ServerStatus.PREP_MOVE, NodeState.PENDING)// - .put(ServerStatus.MOVE, NodeState.PENDING)// - .put(ServerStatus.VERIFY_MOVE, NodeState.PENDING)// - .put(ServerStatus.RESCUE, NodeState.PENDING)// - .put(ServerStatus.ERROR, NodeState.ERROR)// - .put(ServerStatus.BUILD, NodeState.PENDING)// - .put(ServerStatus.RESTORING, NodeState.PENDING)// - .put(ServerStatus.PASSWORD, NodeState.PENDING)// - .put(ServerStatus.REBUILD, NodeState.PENDING)// - .put(ServerStatus.DELETE_IP, NodeState.PENDING)// - .put(ServerStatus.SHARE_IP_NO_CONFIG, NodeState.PENDING)// - .put(ServerStatus.SHARE_IP, NodeState.PENDING)// - .put(ServerStatus.REBOOT, NodeState.PENDING)// - .put(ServerStatus.HARD_REBOOT, NodeState.PENDING)// - .put(ServerStatus.UNKNOWN, NodeState.UNRECOGNIZED)// - .put(ServerStatus.UNRECOGNIZED, NodeState.UNRECOGNIZED).build(); + public static final Map serverToNodeStatus = ImmutableMap + . builder().put(ServerStatus.ACTIVE, Status.RUNNING)// + .put(ServerStatus.SUSPENDED, Status.SUSPENDED)// + .put(ServerStatus.DELETED, Status.TERMINATED)// + .put(ServerStatus.QUEUE_RESIZE, Status.PENDING)// + .put(ServerStatus.PREP_RESIZE, Status.PENDING)// + .put(ServerStatus.RESIZE, Status.PENDING)// + .put(ServerStatus.VERIFY_RESIZE, Status.PENDING)// + .put(ServerStatus.QUEUE_MOVE, Status.PENDING)// + .put(ServerStatus.PREP_MOVE, Status.PENDING)// + .put(ServerStatus.MOVE, Status.PENDING)// + .put(ServerStatus.VERIFY_MOVE, Status.PENDING)// + .put(ServerStatus.RESCUE, Status.PENDING)// + .put(ServerStatus.ERROR, Status.ERROR)// + .put(ServerStatus.BUILD, Status.PENDING)// + .put(ServerStatus.RESTORING, Status.PENDING)// + .put(ServerStatus.PASSWORD, Status.PENDING)// + .put(ServerStatus.REBUILD, Status.PENDING)// + .put(ServerStatus.DELETE_IP, Status.PENDING)// + .put(ServerStatus.SHARE_IP_NO_CONFIG, Status.PENDING)// + .put(ServerStatus.SHARE_IP, Status.PENDING)// + .put(ServerStatus.REBOOT, Status.PENDING)// + .put(ServerStatus.HARD_REBOOT, Status.PENDING)// + .put(ServerStatus.UNKNOWN, Status.UNRECOGNIZED)// + .put(ServerStatus.UNRECOGNIZED, Status.UNRECOGNIZED).build(); @Singleton @Provides - Map provideServerToNodeState() { - return serverToNodeState; + Map provideServerToNodeStatus() { + return serverToNodeStatus; } @Override diff --git a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/compute/functions/ServerToNodeMetadata.java b/apis/cloudservers/src/main/java/org/jclouds/cloudservers/compute/functions/ServerToNodeMetadata.java index a161ad4aa3..f28cb4e71e 100644 --- a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/compute/functions/ServerToNodeMetadata.java +++ b/apis/cloudservers/src/main/java/org/jclouds/cloudservers/compute/functions/ServerToNodeMetadata.java @@ -37,8 +37,8 @@ import org.jclouds.compute.domain.Hardware; import org.jclouds.compute.domain.Image; import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.domain.NodeMetadataBuilder; -import org.jclouds.compute.domain.NodeState; import org.jclouds.compute.domain.OperatingSystem; +import org.jclouds.compute.domain.NodeMetadata.Status; import org.jclouds.compute.functions.GroupNamingConvention; import org.jclouds.compute.reference.ComputeServiceConstants; import org.jclouds.domain.Location; @@ -61,7 +61,7 @@ public class ServerToNodeMetadata implements Function { protected Logger logger = Logger.NULL; protected final Supplier location; - protected final Map serverToNodeState; + protected final Map serverToNodeStatus; protected final Supplier> images; protected final Supplier> hardwares; protected final GroupNamingConvention nodeNamingConvention; @@ -93,12 +93,12 @@ public class ServerToNodeMetadata implements Function { } @Inject - ServerToNodeMetadata(Map serverStateToNodeState, + ServerToNodeMetadata(Map serverStateToNodeStatus, @Memoized Supplier> images, Supplier location, @Memoized Supplier> hardwares, GroupNamingConvention.Factory namingConvention) { this.nodeNamingConvention = checkNotNull(namingConvention, "namingConvention").createWithoutPrefix(); - this.serverToNodeState = checkNotNull(serverStateToNodeState, "serverStateToNodeState"); + this.serverToNodeStatus = checkNotNull(serverStateToNodeStatus, "serverStateToNodeStatus"); this.images = checkNotNull(images, "images"); this.location = checkNotNull(location, "location"); this.hardwares = checkNotNull(hardwares, "hardwares"); @@ -117,7 +117,7 @@ public class ServerToNodeMetadata implements Function { builder.imageId(from.getImageId() + ""); builder.operatingSystem(parseOperatingSystem(from)); builder.hardware(parseHardware(from)); - builder.state(serverToNodeState.get(from.getStatus())); + builder.status(serverToNodeStatus.get(from.getStatus())); builder.publicAddresses(from.getAddresses().getPublicAddresses()); builder.privateAddresses(from.getAddresses().getPrivateAddresses()); return builder.build(); diff --git a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/compute/config/CloudServersComputeServiceContextModuleTest.java b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/compute/config/CloudServersComputeServiceContextModuleTest.java index b39995a26b..74c69d381d 100644 --- a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/compute/config/CloudServersComputeServiceContextModuleTest.java +++ b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/compute/config/CloudServersComputeServiceContextModuleTest.java @@ -30,7 +30,7 @@ public class CloudServersComputeServiceContextModuleTest { public void testAllStatusCovered() { for (ServerStatus state : ServerStatus.values()) { - assert CloudServersComputeServiceContextModule.serverToNodeState.containsKey(state) : state; + assert CloudServersComputeServiceContextModule.serverToNodeStatus.containsKey(state) : state; } } diff --git a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/compute/functions/ServerToNodeMetadataTest.java b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/compute/functions/ServerToNodeMetadataTest.java index 855603afb8..e2665c1647 100644 --- a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/compute/functions/ServerToNodeMetadataTest.java +++ b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/compute/functions/ServerToNodeMetadataTest.java @@ -32,12 +32,12 @@ import org.jclouds.compute.domain.HardwareBuilder; import org.jclouds.compute.domain.Image; import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.domain.NodeMetadataBuilder; -import org.jclouds.compute.domain.NodeState; import org.jclouds.compute.domain.OperatingSystem; import org.jclouds.compute.domain.OsFamily; import org.jclouds.compute.domain.Processor; import org.jclouds.compute.domain.Volume; import org.jclouds.compute.domain.VolumeBuilder; +import org.jclouds.compute.domain.NodeMetadata.Status; import org.jclouds.compute.functions.GroupNamingConvention; import org.jclouds.domain.Location; import org.jclouds.domain.LocationBuilder; @@ -60,12 +60,12 @@ public class ServerToNodeMetadataTest { @Test public void testApplyWhereImageAndHardwareNotFound() { - Map serverStateToNodeState = CloudServersComputeServiceContextModule.serverToNodeState; + Map serverStateToNodeStatus = CloudServersComputeServiceContextModule.serverToNodeStatus; Set images = ImmutableSet.of(); Set hardwares = ImmutableSet.of(); Server server = ParseServerFromJsonResponseTest.parseServer(); - ServerToNodeMetadata parser = new ServerToNodeMetadata(serverStateToNodeState, Suppliers.> ofInstance(images), Suppliers + ServerToNodeMetadata parser = new ServerToNodeMetadata(serverStateToNodeStatus, Suppliers.> ofInstance(images), Suppliers .ofInstance(provider), Suppliers.> ofInstance(hardwares), namingConvention); NodeMetadata metadata = parser.apply(server); @@ -73,7 +73,7 @@ public class ServerToNodeMetadataTest { assertEquals( metadata, new NodeMetadataBuilder() - .state(NodeState.PENDING) + .status(Status.PENDING) .publicAddresses(ImmutableSet.of("67.23.10.132", "67.23.10.131")) .privateAddresses(ImmutableSet.of("10.176.42.16")) .imageId("2") @@ -91,13 +91,13 @@ public class ServerToNodeMetadataTest { @Test public void testApplyWhereImageFoundAndHardwareNotFound() { - Map serverStateToNodeState = CloudServersComputeServiceContextModule.serverToNodeState; + Map serverStateToNodeStatus = CloudServersComputeServiceContextModule.serverToNodeStatus; org.jclouds.compute.domain.Image jcImage = CloudServersImageToImageTest.convertImage(); Set images = ImmutableSet.of(jcImage); Set hardwares = ImmutableSet.of(); Server server = ParseServerFromJsonResponseTest.parseServer(); - ServerToNodeMetadata parser = new ServerToNodeMetadata(serverStateToNodeState, Suppliers.> ofInstance(images), Suppliers + ServerToNodeMetadata parser = new ServerToNodeMetadata(serverStateToNodeStatus, Suppliers.> ofInstance(images), Suppliers .ofInstance(provider), Suppliers.> ofInstance(hardwares), namingConvention); NodeMetadata metadata = parser.apply(server); @@ -105,7 +105,7 @@ public class ServerToNodeMetadataTest { assertEquals( metadata, new NodeMetadataBuilder() - .state(NodeState.PENDING) + .status(Status.PENDING) .publicAddresses(ImmutableSet.of("67.23.10.132", "67.23.10.131")) .privateAddresses(ImmutableSet.of("10.176.42.16")) .imageId("2") @@ -126,12 +126,12 @@ public class ServerToNodeMetadataTest { @Test public void testApplyWhereImageAndHardwareFound() { - Map serverStateToNodeState = CloudServersComputeServiceContextModule.serverToNodeState; + Map serverStateToNodeStatus = CloudServersComputeServiceContextModule.serverToNodeStatus; Set images = ImmutableSet.of(CloudServersImageToImageTest.convertImage()); Set hardwares = ImmutableSet.of(FlavorToHardwareTest.convertFlavor()); Server server = ParseServerFromJsonResponseTest.parseServer(); - ServerToNodeMetadata parser = new ServerToNodeMetadata(serverStateToNodeState, Suppliers.> ofInstance(images), Suppliers + ServerToNodeMetadata parser = new ServerToNodeMetadata(serverStateToNodeStatus, Suppliers.> ofInstance(images), Suppliers .ofInstance(provider), Suppliers.> ofInstance(hardwares), namingConvention); NodeMetadata metadata = parser.apply(server); @@ -139,7 +139,7 @@ public class ServerToNodeMetadataTest { assertEquals( metadata, new NodeMetadataBuilder() - .state(NodeState.PENDING) + .status(Status.PENDING) .publicAddresses(ImmutableSet.of("67.23.10.132", "67.23.10.131")) .privateAddresses(ImmutableSet.of("10.176.42.16")) .imageId("2") diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/compute/functions/ServerInfoToNodeMetadata.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/compute/functions/ServerInfoToNodeMetadata.java index d4f5dbd84f..5e131e6f30 100644 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/compute/functions/ServerInfoToNodeMetadata.java +++ b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/compute/functions/ServerInfoToNodeMetadata.java @@ -38,10 +38,10 @@ import org.jclouds.compute.domain.HardwareBuilder; import org.jclouds.compute.domain.Image; import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.domain.NodeMetadataBuilder; -import org.jclouds.compute.domain.NodeState; import org.jclouds.compute.domain.Processor; import org.jclouds.compute.domain.Volume; import org.jclouds.compute.domain.VolumeBuilder; +import org.jclouds.compute.domain.NodeMetadata.Status; import org.jclouds.compute.functions.GroupNamingConvention; import org.jclouds.domain.Location; import org.jclouds.logging.Logger; @@ -60,13 +60,13 @@ import com.google.common.util.concurrent.UncheckedExecutionException; */ @Singleton public class ServerInfoToNodeMetadata implements Function { - public static final Map serverStatusToNodeState = ImmutableMap - . builder().put(ServerStatus.ACTIVE, NodeState.RUNNING)// - .put(ServerStatus.STOPPED, NodeState.SUSPENDED)// - .put(ServerStatus.PAUSED, NodeState.SUSPENDED)// - .put(ServerStatus.DUMPED, NodeState.PENDING)// - .put(ServerStatus.DEAD, NodeState.TERMINATED)// - .put(ServerStatus.UNRECOGNIZED, NodeState.UNRECOGNIZED)// + public static final Map serverStatusToNodeStatus = ImmutableMap + . builder().put(ServerStatus.ACTIVE, Status.RUNNING)// + .put(ServerStatus.STOPPED, Status.SUSPENDED)// + .put(ServerStatus.PAUSED, Status.SUSPENDED)// + .put(ServerStatus.DUMPED, Status.PENDING)// + .put(ServerStatus.DEAD, Status.TERMINATED)// + .put(ServerStatus.UNRECOGNIZED, Status.UNRECOGNIZED)// .build(); private final Function getImageIdFromServer; @@ -104,7 +104,7 @@ public class ServerInfoToNodeMetadata implements Function of(from.getVnc().getIp())); builder.privateAddresses(ImmutableSet. of()); return builder.build(); diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/compute/functions/VirtualMachineToNodeMetadata.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/compute/functions/VirtualMachineToNodeMetadata.java index 8c551f66f7..193f3812bd 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/compute/functions/VirtualMachineToNodeMetadata.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/compute/functions/VirtualMachineToNodeMetadata.java @@ -41,8 +41,8 @@ import org.jclouds.compute.domain.HardwareBuilder; import org.jclouds.compute.domain.Image; import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.domain.NodeMetadataBuilder; -import org.jclouds.compute.domain.NodeState; import org.jclouds.compute.domain.Processor; +import org.jclouds.compute.domain.NodeMetadata.Status; import org.jclouds.compute.functions.GroupNamingConvention; import org.jclouds.domain.Location; import org.jclouds.rest.ResourceNotFoundException; @@ -64,17 +64,17 @@ import com.google.common.util.concurrent.UncheckedExecutionException; @Singleton public class VirtualMachineToNodeMetadata implements Function { - public static final Map vmStateToNodeState = ImmutableMap - . builder().put(VirtualMachine.State.STARTING, NodeState.PENDING) - .put(VirtualMachine.State.RUNNING, NodeState.RUNNING).put(VirtualMachine.State.STOPPING, NodeState.PENDING) - .put(VirtualMachine.State.STOPPED, NodeState.SUSPENDED) - .put(VirtualMachine.State.DESTROYED, NodeState.TERMINATED) - .put(VirtualMachine.State.EXPUNGING, NodeState.TERMINATED) - .put(VirtualMachine.State.MIGRATING, NodeState.PENDING).put(VirtualMachine.State.ERROR, NodeState.ERROR) - .put(VirtualMachine.State.UNKNOWN, NodeState.UNRECOGNIZED) + public static final Map vmStateToNodeStatus = ImmutableMap + . builder().put(VirtualMachine.State.STARTING, Status.PENDING) + .put(VirtualMachine.State.RUNNING, Status.RUNNING).put(VirtualMachine.State.STOPPING, Status.PENDING) + .put(VirtualMachine.State.STOPPED, Status.SUSPENDED) + .put(VirtualMachine.State.DESTROYED, Status.TERMINATED) + .put(VirtualMachine.State.EXPUNGING, Status.TERMINATED) + .put(VirtualMachine.State.MIGRATING, Status.PENDING).put(VirtualMachine.State.ERROR, Status.ERROR) + .put(VirtualMachine.State.UNKNOWN, Status.UNRECOGNIZED) // TODO: is this really a state? - .put(VirtualMachine.State.SHUTDOWNED, NodeState.PENDING) - .put(VirtualMachine.State.UNRECOGNIZED, NodeState.UNRECOGNIZED).build(); + .put(VirtualMachine.State.SHUTDOWNED, Status.PENDING) + .put(VirtualMachine.State.UNRECOGNIZED, Status.UNRECOGNIZED).build(); private final FindLocationForVirtualMachine findLocationForVirtualMachine; private final FindImageForVirtualMachine findImageForVirtualMachine; @@ -123,7 +123,7 @@ public class VirtualMachineToNodeMetadata implements Function publicAddresses = newHashSet(), privateAddresses = newHashSet(); if (from.getIPAddress() != null) { diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/compute/functions/VirtualMachineToNodeMetadataTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/compute/functions/VirtualMachineToNodeMetadataTest.java index d6597a3a83..ca89526200 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/compute/functions/VirtualMachineToNodeMetadataTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/compute/functions/VirtualMachineToNodeMetadataTest.java @@ -36,7 +36,7 @@ import org.jclouds.compute.domain.HardwareBuilder; import org.jclouds.compute.domain.Image; import org.jclouds.compute.domain.NodeMetadata; 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.date.internal.SimpleDateFormatDateService; import org.jclouds.domain.Location; @@ -87,7 +87,7 @@ public class VirtualMachineToNodeMetadataTest { assertEquals( node.toString(), 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")) .hardware(addHypervisor(ServiceOfferingToHardwareTest.one, "XenServer")) .imageId(TemplateToImageTest.one.getId()) @@ -150,7 +150,7 @@ public class VirtualMachineToNodeMetadataTest { assertEquals( node.toString(), 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()) .publicAddresses(ImmutableSet.of("1.1.1.5")) .hardware(addHypervisor(ServiceOfferingToHardwareTest.one, "XenServer")) @@ -186,7 +186,7 @@ public class VirtualMachineToNodeMetadataTest { assertEquals( node.toString(), 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")) .hardware(addHypervisor(ServiceOfferingToHardwareTest.one, "XenServer")) .imageId(TemplateToImageTest.one.getId()) diff --git a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/compute/functions/InstanceToNodeMetadata.java b/apis/deltacloud/src/main/java/org/jclouds/deltacloud/compute/functions/InstanceToNodeMetadata.java index 175d8e27bb..188ce1d2a2 100644 --- a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/compute/functions/InstanceToNodeMetadata.java +++ b/apis/deltacloud/src/main/java/org/jclouds/deltacloud/compute/functions/InstanceToNodeMetadata.java @@ -34,8 +34,8 @@ import org.jclouds.compute.domain.Hardware; import org.jclouds.compute.domain.Image; import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.domain.NodeMetadataBuilder; -import org.jclouds.compute.domain.NodeState; import org.jclouds.compute.domain.OperatingSystem; +import org.jclouds.compute.domain.NodeMetadata.Status; import org.jclouds.compute.functions.GroupNamingConvention; import org.jclouds.compute.reference.ComputeServiceConstants; import org.jclouds.deltacloud.domain.Instance; @@ -54,11 +54,11 @@ import com.google.common.collect.Iterables; @Singleton public class InstanceToNodeMetadata implements Function { - public static final Map instanceToNodeState = ImmutableMap - . builder().put(Instance.State.STOPPED, NodeState.SUSPENDED) - .put(Instance.State.RUNNING, NodeState.RUNNING).put(Instance.State.PENDING, NodeState.PENDING) - .put(Instance.State.UNRECOGNIZED, NodeState.UNRECOGNIZED).put(Instance.State.SHUTTING_DOWN, NodeState.PENDING) - .put(Instance.State.START, NodeState.PENDING).build(); + public static final Map instanceToNodeStatus = ImmutableMap + . builder().put(Instance.State.STOPPED, Status.SUSPENDED) + .put(Instance.State.RUNNING, Status.RUNNING).put(Instance.State.PENDING, Status.PENDING) + .put(Instance.State.UNRECOGNIZED, Status.UNRECOGNIZED).put(Instance.State.SHUTTING_DOWN, Status.PENDING) + .put(Instance.State.START, Status.PENDING).build(); @Resource @Named(ComputeServiceConstants.COMPUTE_LOGGER) @@ -155,7 +155,7 @@ public class InstanceToNodeMetadata implements Function builder.imageId(from.getImage().toASCIIString()); builder.operatingSystem(parseOperatingSystem(from)); builder.hardware(parseHardware(from)); - builder.state(instanceToNodeState.get(from.getState())); + builder.status(instanceToNodeStatus.get(from.getState())); builder.publicAddresses(from.getPublicAddresses()); builder.privateAddresses(from.getPrivateAddresses()); return builder.build(); diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/compute/config/EC2ComputeServiceDependenciesModule.java b/apis/ec2/src/main/java/org/jclouds/ec2/compute/config/EC2ComputeServiceDependenciesModule.java index b236189627..d1ed6b4835 100644 --- a/apis/ec2/src/main/java/org/jclouds/ec2/compute/config/EC2ComputeServiceDependenciesModule.java +++ b/apis/ec2/src/main/java/org/jclouds/ec2/compute/config/EC2ComputeServiceDependenciesModule.java @@ -31,8 +31,8 @@ import javax.inject.Singleton; import org.jclouds.compute.ComputeService; import org.jclouds.compute.domain.Image; import org.jclouds.compute.domain.NodeMetadata; -import org.jclouds.compute.domain.NodeState; import org.jclouds.compute.domain.TemplateBuilder; +import org.jclouds.compute.domain.NodeMetadata.Status; import org.jclouds.compute.extensions.ImageExtension; import org.jclouds.compute.options.TemplateOptions; import org.jclouds.domain.Credentials; @@ -79,17 +79,17 @@ import com.google.inject.name.Names; */ public class EC2ComputeServiceDependenciesModule extends AbstractModule { - public static final Map instanceToNodeState = ImmutableMap - . builder().put(InstanceState.PENDING, NodeState.PENDING).put( - InstanceState.RUNNING, NodeState.RUNNING).put(InstanceState.SHUTTING_DOWN, NodeState.PENDING).put( - InstanceState.TERMINATED, NodeState.TERMINATED).put(InstanceState.STOPPING, NodeState.PENDING) - .put(InstanceState.STOPPED, NodeState.SUSPENDED).put(InstanceState.UNRECOGNIZED, NodeState.UNRECOGNIZED) + public static final Map instanceToNodeStatus = ImmutableMap + . builder().put(InstanceState.PENDING, Status.PENDING).put( + InstanceState.RUNNING, Status.RUNNING).put(InstanceState.SHUTTING_DOWN, Status.PENDING).put( + InstanceState.TERMINATED, Status.TERMINATED).put(InstanceState.STOPPING, Status.PENDING) + .put(InstanceState.STOPPED, Status.SUSPENDED).put(InstanceState.UNRECOGNIZED, Status.UNRECOGNIZED) .build(); @Singleton @Provides - Map provideServerToNodeState() { - return instanceToNodeState; + Map provideServerToNodeStatus() { + return instanceToNodeStatus; } @Override diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/compute/functions/RunningInstanceToNodeMetadata.java b/apis/ec2/src/main/java/org/jclouds/ec2/compute/functions/RunningInstanceToNodeMetadata.java index fa66954a23..a037f31b98 100644 --- a/apis/ec2/src/main/java/org/jclouds/ec2/compute/functions/RunningInstanceToNodeMetadata.java +++ b/apis/ec2/src/main/java/org/jclouds/ec2/compute/functions/RunningInstanceToNodeMetadata.java @@ -24,9 +24,9 @@ import static com.google.common.collect.Iterables.filter; import java.util.List; import java.util.Map; -import java.util.Map.Entry; import java.util.NoSuchElementException; import java.util.Set; +import java.util.Map.Entry; import javax.annotation.Resource; 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.NodeMetadata; import org.jclouds.compute.domain.NodeMetadataBuilder; -import org.jclouds.compute.domain.NodeState; import org.jclouds.compute.domain.Volume; +import org.jclouds.compute.domain.NodeMetadata.Status; import org.jclouds.compute.domain.internal.VolumeImpl; import org.jclouds.compute.functions.GroupNamingConvention; 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.LoadingCache; import com.google.common.collect.ImmutableSet; -import com.google.common.collect.ImmutableSet.Builder; import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import com.google.common.collect.Sets; +import com.google.common.collect.ImmutableSet.Builder; import com.google.common.util.concurrent.UncheckedExecutionException; import com.google.inject.Inject; @@ -80,18 +80,18 @@ public class RunningInstanceToNodeMetadata implements Function> hardware; protected final Supplier> imageMap; protected final Map credentialStore; - protected final Map instanceToNodeState; + protected final Map instanceToNodeStatus; protected final GroupNamingConvention.Factory namingConvention; @Inject - protected RunningInstanceToNodeMetadata(Map instanceToNodeState, + protected RunningInstanceToNodeMetadata(Map instanceToNodeStatus, Map credentialStore, Supplier> imageMap, @Memoized Supplier> locations, @Memoized Supplier> hardware, GroupNamingConvention.Factory namingConvention) { this.locations = checkNotNull(locations, "locations"); this.hardware = checkNotNull(hardware, "hardware"); this.imageMap = checkNotNull(imageMap, "imageMap"); - this.instanceToNodeState = checkNotNull(instanceToNodeState, "instanceToNodeState"); + this.instanceToNodeStatus = checkNotNull(instanceToNodeStatus, "instanceToNodeStatus"); this.credentialStore = checkNotNull(credentialStore, "credentialStore"); this.namingConvention = checkNotNull(namingConvention, "namingConvention"); } @@ -114,7 +114,7 @@ public class RunningInstanceToNodeMetadata implements Function of(), ImmutableSet . of(), ImmutableSet. of(), ImmutableMap. of()); - assertEquals(parser.apply(instance), new NodeMetadataBuilder().state(NodeState.RUNNING).publicAddresses( + assertEquals(parser.apply(instance), new NodeMetadataBuilder().status(Status.RUNNING).publicAddresses( ImmutableSet. of()).privateAddresses(ImmutableSet.of("10.1.1.1")).id("us-east-1/id").imageId( "us-east-1/image").providerId("id").build()); } @@ -94,7 +94,7 @@ public class RunningInstanceToNodeMetadataTest { RunningInstanceToNodeMetadata parser = createNodeParser(ImmutableSet. of(), ImmutableSet . of(), ImmutableSet. of(), ImmutableMap. of()); - assertEquals(parser.apply(instance), new NodeMetadataBuilder().state(NodeState.RUNNING).privateAddresses( + assertEquals(parser.apply(instance), new NodeMetadataBuilder().status(Status.RUNNING).privateAddresses( ImmutableSet. of()).publicAddresses(ImmutableSet.of("1.1.1.1")).id("us-east-1/id").imageId( "us-east-1/image").providerId("id").build()); } @@ -115,7 +115,7 @@ public class RunningInstanceToNodeMetadataTest { assertEquals( 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. of()).privateAddresses(ImmutableSet.of("10.243.42.70")) .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()); @@ -129,7 +129,7 @@ public class RunningInstanceToNodeMetadataTest { RunningInstance server = firstInstanceFromResource("/describe_instances_running.xml"); 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. of()).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").build()); @@ -141,7 +141,7 @@ public class RunningInstanceToNodeMetadataTest { ImmutableSet. of(), ImmutableMap. of()); 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")) .imageId("us-east-1/ami-82e4b5c7").id("us-east-1/i-0799056f").providerId("i-0799056f") .location(provider).build(); @@ -159,7 +159,7 @@ public class RunningInstanceToNodeMetadataTest { assertEquals( parser.apply(server), new NodeMetadataBuilder() - .state(NodeState.RUNNING) + .status(Status.RUNNING) .hostname("ip-10-243-42-70") .privateAddresses(ImmutableSet.of("10.243.42.70")) .publicAddresses(ImmutableSet.of("174.129.81.68")) @@ -182,7 +182,7 @@ public class RunningInstanceToNodeMetadataTest { parser.apply(server), new NodeMetadataBuilder() .hostname("ip-10-243-42-70") - .state(NodeState.RUNNING) + .status(Status.RUNNING) .privateAddresses(ImmutableSet.of("10.243.42.70")) .publicAddresses(ImmutableSet.of("174.129.81.68")) .imageId("us-east-1/ami-82e4b5c7") @@ -210,13 +210,13 @@ public class RunningInstanceToNodeMetadataTest { RunningInstanceToNodeMetadata parser = createNodeParser(ImmutableSet.of(m1_small().build()), ImmutableSet .of(provider), ImmutableMap. of(), - EC2ComputeServiceDependenciesModule.instanceToNodeState, instanceToImage); + EC2ComputeServiceDependenciesModule.instanceToNodeStatus, instanceToImage); RunningInstance server = firstInstanceFromResource("/describe_instances_running.xml"); 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) .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") .hardware(m1_small().build()).location(provider).build()); @@ -245,7 +245,7 @@ public class RunningInstanceToNodeMetadataTest { protected RunningInstanceToNodeMetadata createNodeParser(final ImmutableSet hardware, final ImmutableSet locations, final Set images, Map credentialStore) { - Map instanceToNodeState = EC2ComputeServiceDependenciesModule.instanceToNodeState; + Map instanceToNodeStatus = EC2ComputeServiceDependenciesModule.instanceToNodeStatus; CacheLoader getRealImage = new CacheLoader() { @@ -255,7 +255,7 @@ public class RunningInstanceToNodeMetadataTest { } }; LoadingCache instanceToImage = CacheBuilder.newBuilder().build(getRealImage); - return createNodeParser(hardware, locations, credentialStore, instanceToNodeState, instanceToImage); + return createNodeParser(hardware, locations, credentialStore, instanceToNodeStatus, instanceToImage); } private void checkGroupName(RunningInstance instance) { @@ -266,7 +266,7 @@ public class RunningInstanceToNodeMetadataTest { private RunningInstanceToNodeMetadata createNodeParser(final ImmutableSet hardware, final ImmutableSet locations, Map credentialStore, - Map instanceToNodeState, LoadingCache instanceToImage) { + Map instanceToNodeStatus, LoadingCache instanceToImage) { Supplier> locationSupplier = new Supplier>() { @Override @@ -293,7 +293,7 @@ public class RunningInstanceToNodeMetadataTest { }).getInstance(GroupNamingConvention.Factory.class); - RunningInstanceToNodeMetadata parser = new RunningInstanceToNodeMetadata(instanceToNodeState, credentialStore, + RunningInstanceToNodeMetadata parser = new RunningInstanceToNodeMetadata(instanceToNodeStatus, credentialStore, Suppliers.> ofInstance(instanceToImage), locationSupplier, hardwareSupplier, namingConvention); return parser; diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/compute/strategy/EC2CreateNodesInGroupThenAddToSetTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/compute/strategy/EC2CreateNodesInGroupThenAddToSetTest.java index 400c954a57..0bf4fe3802 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/compute/strategy/EC2CreateNodesInGroupThenAddToSetTest.java +++ b/apis/ec2/src/test/java/org/jclouds/ec2/compute/strategy/EC2CreateNodesInGroupThenAddToSetTest.java @@ -34,9 +34,9 @@ import org.jclouds.compute.domain.Hardware; import org.jclouds.compute.domain.Image; import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.domain.NodeMetadataBuilder; -import org.jclouds.compute.domain.NodeState; import org.jclouds.compute.domain.Template; import org.jclouds.compute.domain.TemplateBuilder; +import org.jclouds.compute.domain.NodeMetadata.Status; import org.jclouds.compute.predicates.AtomicNodeRunning; import org.jclouds.compute.strategy.GetNodeMetadataStrategy; import org.jclouds.compute.util.ComputeUtils; @@ -78,7 +78,7 @@ public class EC2CreateNodesInGroupThenAddToSetTest { String imageId = "ami1"; String instanceCreatedId = "instance1"; NodeMetadata nodeMetadata = new NodeMetadataBuilder().id(region + "/" + instanceCreatedId) - .providerId(instanceCreatedId).state(NodeState.RUNNING).build(); + .providerId(instanceCreatedId).status(Status.RUNNING).build(); // setup mocks TemplateBuilder templateBuilder = createMock(TemplateBuilder.class); EC2CreateNodesInGroupThenAddToSet strategy = setupStrategy(templateBuilder, nodeMetadata); @@ -190,7 +190,7 @@ public class EC2CreateNodesInGroupThenAddToSetTest { String imageId = "ami1"; String instanceCreatedId = "instance1"; NodeMetadata nodeMetadata = new NodeMetadataBuilder().id(region + "/" + instanceCreatedId) - .providerId(instanceCreatedId).state(NodeState.RUNNING).build(); + .providerId(instanceCreatedId).status(Status.RUNNING).build(); // setup mocks TemplateBuilder templateBuilder = createMock(TemplateBuilder.class); diff --git a/apis/elasticstack/src/main/java/org/jclouds/elasticstack/compute/functions/ServerInfoToNodeMetadata.java b/apis/elasticstack/src/main/java/org/jclouds/elasticstack/compute/functions/ServerInfoToNodeMetadata.java index ceac0e90a9..59d2658660 100644 --- a/apis/elasticstack/src/main/java/org/jclouds/elasticstack/compute/functions/ServerInfoToNodeMetadata.java +++ b/apis/elasticstack/src/main/java/org/jclouds/elasticstack/compute/functions/ServerInfoToNodeMetadata.java @@ -34,10 +34,10 @@ import org.jclouds.compute.domain.HardwareBuilder; import org.jclouds.compute.domain.Image; import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.domain.NodeMetadataBuilder; -import org.jclouds.compute.domain.NodeState; import org.jclouds.compute.domain.Processor; import org.jclouds.compute.domain.Volume; import org.jclouds.compute.domain.VolumeBuilder; +import org.jclouds.compute.domain.NodeMetadata.Status; import org.jclouds.compute.functions.GroupNamingConvention; import org.jclouds.domain.Location; import org.jclouds.elasticstack.domain.Device; @@ -61,13 +61,13 @@ import com.google.common.util.concurrent.UncheckedExecutionException; */ @Singleton public class ServerInfoToNodeMetadata implements Function { - public static final Map serverStatusToNodeState = ImmutableMap - . builder().put(ServerStatus.ACTIVE, NodeState.RUNNING)// - .put(ServerStatus.STOPPED, NodeState.SUSPENDED)// - .put(ServerStatus.PAUSED, NodeState.SUSPENDED)// - .put(ServerStatus.DUMPED, NodeState.PENDING)// - .put(ServerStatus.DEAD, NodeState.TERMINATED)// - .put(ServerStatus.UNRECOGNIZED, NodeState.UNRECOGNIZED)// + public static final Map serverStatusToNodeStatus = ImmutableMap + . builder().put(ServerStatus.ACTIVE, Status.RUNNING)// + .put(ServerStatus.STOPPED, Status.SUSPENDED)// + .put(ServerStatus.PAUSED, Status.SUSPENDED)// + .put(ServerStatus.DUMPED, Status.PENDING)// + .put(ServerStatus.DEAD, Status.TERMINATED)// + .put(ServerStatus.UNRECOGNIZED, Status.UNRECOGNIZED)// .build(); private final Function getImageIdFromServer; @@ -106,7 +106,7 @@ public class ServerInfoToNodeMetadata implements Function of(from.getNics().get(0).getDhcp())); builder.privateAddresses(ImmutableSet. of()); return builder.build(); diff --git a/apis/nova/src/main/java/org/jclouds/openstack/nova/compute/config/NovaComputeServiceContextModule.java b/apis/nova/src/main/java/org/jclouds/openstack/nova/compute/config/NovaComputeServiceContextModule.java index 6ac995e84e..8d2d1c720d 100644 --- a/apis/nova/src/main/java/org/jclouds/openstack/nova/compute/config/NovaComputeServiceContextModule.java +++ b/apis/nova/src/main/java/org/jclouds/openstack/nova/compute/config/NovaComputeServiceContextModule.java @@ -27,8 +27,8 @@ import org.jclouds.compute.config.ComputeServiceAdapterContextModule; import org.jclouds.compute.domain.Hardware; import org.jclouds.compute.domain.Image; import org.jclouds.compute.domain.NodeMetadata; -import org.jclouds.compute.domain.NodeState; import org.jclouds.compute.domain.OperatingSystem; +import org.jclouds.compute.domain.NodeMetadata.Status; import org.jclouds.compute.internal.BaseComputeService; import org.jclouds.domain.Location; import org.jclouds.functions.IdentityFunction; @@ -80,28 +80,28 @@ public class NovaComputeServiceContextModule extends } @VisibleForTesting - public static final Map serverToNodeState = ImmutableMap - . builder().put(ServerStatus.ACTIVE, NodeState.RUNNING)// - .put(ServerStatus.SUSPENDED, NodeState.SUSPENDED)// - .put(ServerStatus.DELETED, NodeState.TERMINATED)// - .put(ServerStatus.QUEUE_RESIZE, NodeState.PENDING)// - .put(ServerStatus.PREP_RESIZE, NodeState.PENDING)// - .put(ServerStatus.RESIZE, NodeState.PENDING)// - .put(ServerStatus.VERIFY_RESIZE, NodeState.PENDING)// - .put(ServerStatus.RESCUE, NodeState.PENDING)// - .put(ServerStatus.BUILD, NodeState.PENDING)// - .put(ServerStatus.PASSWORD, NodeState.PENDING)// - .put(ServerStatus.REBUILD, NodeState.PENDING)// - .put(ServerStatus.DELETE_IP, NodeState.PENDING)// - .put(ServerStatus.REBOOT, NodeState.PENDING)// - .put(ServerStatus.HARD_REBOOT, NodeState.PENDING)// - .put(ServerStatus.UNKNOWN, NodeState.UNRECOGNIZED)// - .put(ServerStatus.UNRECOGNIZED, NodeState.UNRECOGNIZED).build(); + public static final Map serverToNodeStatus = ImmutableMap + . builder().put(ServerStatus.ACTIVE, Status.RUNNING)// + .put(ServerStatus.SUSPENDED, Status.SUSPENDED)// + .put(ServerStatus.DELETED, Status.TERMINATED)// + .put(ServerStatus.QUEUE_RESIZE, Status.PENDING)// + .put(ServerStatus.PREP_RESIZE, Status.PENDING)// + .put(ServerStatus.RESIZE, Status.PENDING)// + .put(ServerStatus.VERIFY_RESIZE, Status.PENDING)// + .put(ServerStatus.RESCUE, Status.PENDING)// + .put(ServerStatus.BUILD, Status.PENDING)// + .put(ServerStatus.PASSWORD, Status.PENDING)// + .put(ServerStatus.REBUILD, Status.PENDING)// + .put(ServerStatus.DELETE_IP, Status.PENDING)// + .put(ServerStatus.REBOOT, Status.PENDING)// + .put(ServerStatus.HARD_REBOOT, Status.PENDING)// + .put(ServerStatus.UNKNOWN, Status.UNRECOGNIZED)// + .put(ServerStatus.UNRECOGNIZED, Status.UNRECOGNIZED).build(); @Singleton @Provides - Map provideServerToNodeState() { - return serverToNodeState; + Map provideServerToNodeStatus() { + return serverToNodeStatus; } } diff --git a/apis/nova/src/main/java/org/jclouds/openstack/nova/compute/functions/ServerToNodeMetadata.java b/apis/nova/src/main/java/org/jclouds/openstack/nova/compute/functions/ServerToNodeMetadata.java index bc6b567f08..983c39dcc6 100644 --- a/apis/nova/src/main/java/org/jclouds/openstack/nova/compute/functions/ServerToNodeMetadata.java +++ b/apis/nova/src/main/java/org/jclouds/openstack/nova/compute/functions/ServerToNodeMetadata.java @@ -34,7 +34,7 @@ import org.jclouds.compute.domain.Hardware; import org.jclouds.compute.domain.Image; import org.jclouds.compute.domain.NodeMetadata; 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.reference.ComputeServiceConstants; import org.jclouds.domain.Location; @@ -60,7 +60,7 @@ public class ServerToNodeMetadata implements Function { protected Logger logger = Logger.NULL; protected final Supplier location; - protected final Map serverToNodeState; + protected final Map serverToNodeStatus; protected final Supplier> images; protected final Supplier> hardwares; protected final GroupNamingConvention nodeNamingConvention; @@ -92,12 +92,12 @@ public class ServerToNodeMetadata implements Function { } @Inject - ServerToNodeMetadata(Map serverStateToNodeState, + ServerToNodeMetadata(Map serverStateToNodeStatus, @Memoized Supplier> images, Supplier location, @Memoized Supplier> hardwares, GroupNamingConvention.Factory namingConvention) { this.nodeNamingConvention = checkNotNull(namingConvention, "namingConvention").createWithoutPrefix(); - this.serverToNodeState = checkNotNull(serverStateToNodeState, "serverStateToNodeState"); + this.serverToNodeStatus = checkNotNull(serverStateToNodeStatus, "serverStateToNodeStatus"); this.images = checkNotNull(images, "images"); this.location = checkNotNull(location, "location"); this.hardwares = checkNotNull(hardwares, "hardwares"); @@ -118,7 +118,7 @@ public class ServerToNodeMetadata implements Function { builder.operatingSystem(image.getOperatingSystem()); } 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.privateAddresses(Iterables.transform(from.getAddresses().getPrivateAddresses(), Address.newAddress2StringFunction())); builder.uri(from.getURI()); diff --git a/apis/nova/src/test/java/org/jclouds/openstack/nova/compute/config/NovaComputeServiceContextModuleTest.java b/apis/nova/src/test/java/org/jclouds/openstack/nova/compute/config/NovaComputeServiceContextModuleTest.java index fe9a759e23..a826c20695 100644 --- a/apis/nova/src/test/java/org/jclouds/openstack/nova/compute/config/NovaComputeServiceContextModuleTest.java +++ b/apis/nova/src/test/java/org/jclouds/openstack/nova/compute/config/NovaComputeServiceContextModuleTest.java @@ -30,7 +30,7 @@ public class NovaComputeServiceContextModuleTest { public void testAllStatusCovered() { for (ServerStatus state : ServerStatus.values()) { - assert NovaComputeServiceContextModule.serverToNodeState.containsKey(state) : state; + assert NovaComputeServiceContextModule.serverToNodeStatus.containsKey(state) : state; } } diff --git a/apis/nova/src/test/java/org/jclouds/openstack/nova/compute/functions/ServerToNodeMetadataTest.java b/apis/nova/src/test/java/org/jclouds/openstack/nova/compute/functions/ServerToNodeMetadataTest.java index c0d8909b7c..ffb57fa254 100644 --- a/apis/nova/src/test/java/org/jclouds/openstack/nova/compute/functions/ServerToNodeMetadataTest.java +++ b/apis/nova/src/test/java/org/jclouds/openstack/nova/compute/functions/ServerToNodeMetadataTest.java @@ -31,12 +31,12 @@ import org.jclouds.compute.domain.HardwareBuilder; import org.jclouds.compute.domain.Image; import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.domain.NodeMetadataBuilder; -import org.jclouds.compute.domain.NodeState; import org.jclouds.compute.domain.OperatingSystem; import org.jclouds.compute.domain.OsFamily; import org.jclouds.compute.domain.Processor; import org.jclouds.compute.domain.Volume; import org.jclouds.compute.domain.VolumeBuilder; +import org.jclouds.compute.domain.NodeMetadata.Status; import org.jclouds.compute.functions.GroupNamingConvention; import org.jclouds.domain.Location; import org.jclouds.domain.LocationBuilder; @@ -64,12 +64,12 @@ public class ServerToNodeMetadataTest { @Test public void testApplyWhereImageAndHardwareNotFound() throws UnknownHostException, NoSuchMethodException, ClassNotFoundException, URISyntaxException { - Map serverStateToNodeState = NovaComputeServiceContextModule.serverToNodeState; + Map serverStateToNodeStatus = NovaComputeServiceContextModule.serverToNodeStatus; Set images = ImmutableSet.of(); Set hardwares = ImmutableSet.of(); Server server = ParseServerFromJsonResponseTest.parseServer(); - ServerToNodeMetadata parser = new ServerToNodeMetadata(serverStateToNodeState, + ServerToNodeMetadata parser = new ServerToNodeMetadata(serverStateToNodeStatus, Suppliers.> ofInstance(images), Suppliers.ofInstance(provider), Suppliers.> ofInstance(hardwares), namingConvention); @@ -83,7 +83,7 @@ public class ServerToNodeMetadataTest { private NodeMetadataBuilder newNodeMetadataBuilder() throws URISyntaxException { 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")) .privateAddresses(ImmutableSet.of("10.176.42.16", "::babe:10.176.42.16")) .id("1234") @@ -100,13 +100,13 @@ public class ServerToNodeMetadataTest { @Test public void testApplyWhereImageFoundAndHardwareNotFound() throws UnknownHostException, NoSuchMethodException, ClassNotFoundException, URISyntaxException { - Map serverStateToNodeState = NovaComputeServiceContextModule.serverToNodeState; + Map serverStateToNodeStatus = NovaComputeServiceContextModule.serverToNodeStatus; org.jclouds.compute.domain.Image jcImage = NovaImageToImageTest.convertImage(); Set images = ImmutableSet.of(jcImage); Set hardwares = ImmutableSet.of(); Server server = ParseServerFromJsonResponseTest.parseServer(); - ServerToNodeMetadata parser = new ServerToNodeMetadata(serverStateToNodeState, + ServerToNodeMetadata parser = new ServerToNodeMetadata(serverStateToNodeStatus, Suppliers.> ofInstance(images), Suppliers.ofInstance(provider), Suppliers.> ofInstance(hardwares), namingConvention); @@ -125,12 +125,12 @@ public class ServerToNodeMetadataTest { @Test public void testApplyWhereImageAndHardwareFound() throws UnknownHostException, NoSuchMethodException, ClassNotFoundException, URISyntaxException { - Map serverStateToNodeState = NovaComputeServiceContextModule.serverToNodeState; + Map serverStateToNodeStatus = NovaComputeServiceContextModule.serverToNodeStatus; Set images = ImmutableSet.of(NovaImageToImageTest.convertImage()); Set hardwares = ImmutableSet.of(FlavorToHardwareTest.convertFlavor()); Server server = ParseServerFromJsonResponseTest.parseServer(); - ServerToNodeMetadata parser = new ServerToNodeMetadata(serverStateToNodeState, + ServerToNodeMetadata parser = new ServerToNodeMetadata(serverStateToNodeStatus, Suppliers.> ofInstance(images), Suppliers.ofInstance(provider), Suppliers.> ofInstance(hardwares), namingConvention); diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/compute/functions/ServerInZoneToNodeMetadata.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/compute/functions/ServerInZoneToNodeMetadata.java index 5cb74c3a09..0c8433be2b 100644 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/compute/functions/ServerInZoneToNodeMetadata.java +++ b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/compute/functions/ServerInZoneToNodeMetadata.java @@ -103,7 +103,7 @@ public class ServerInZoneToNodeMetadata implements Function VAPPSTATUS_TO_NODESTATE = ImmutableMap. builder().put( - Status.OFF, NodeState.SUSPENDED).put(Status.ON, NodeState.RUNNING).put(Status.RESOLVED, NodeState.PENDING) - .put(Status.ERROR, NodeState.ERROR).put(Status.UNRECOGNIZED, NodeState.UNRECOGNIZED).put(Status.DEPLOYED, - NodeState.PENDING).put(Status.INCONSISTENT, NodeState.PENDING).put(Status.UNKNOWN, - NodeState.UNRECOGNIZED).put(Status.MIXED, NodeState.PENDING).put(Status.WAITING_FOR_INPUT, - NodeState.PENDING).put(Status.SUSPENDED, NodeState.SUSPENDED).put(Status.UNRESOLVED, - NodeState.PENDING).build(); + public static final Map VAPPSTATUS_TO_NODESTATE = ImmutableMap. builder().put( + Status.OFF, NodeMetadata.Status.SUSPENDED).put(Status.ON, NodeMetadata.Status.RUNNING).put(Status.RESOLVED, NodeMetadata.Status.PENDING) + .put(Status.ERROR, NodeMetadata.Status.ERROR).put(Status.UNRECOGNIZED, NodeMetadata.Status.UNRECOGNIZED).put(Status.DEPLOYED, + NodeMetadata.Status.PENDING).put(Status.INCONSISTENT, NodeMetadata.Status.PENDING).put(Status.UNKNOWN, + NodeMetadata.Status.UNRECOGNIZED).put(Status.MIXED, NodeMetadata.Status.PENDING).put(Status.WAITING_FOR_INPUT, + NodeMetadata.Status.PENDING).put(Status.SUSPENDED, NodeMetadata.Status.SUSPENDED).put(Status.UNRESOLVED, + NodeMetadata.Status.PENDING).build(); @Singleton @Provides - protected Map provideVAppStatusToNodeState() { + protected Map provideVAppStatusToNodeStatus() { return VAPPSTATUS_TO_NODESTATE; } diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/functions/VAppToNodeMetadata.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/functions/VAppToNodeMetadata.java index 62bfc686d4..9e11ae4026 100644 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/functions/VAppToNodeMetadata.java +++ b/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/functions/VAppToNodeMetadata.java @@ -35,7 +35,6 @@ import javax.inject.Singleton; import org.jclouds.compute.domain.Hardware; import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.domain.NodeMetadataBuilder; -import org.jclouds.compute.domain.NodeState; import org.jclouds.compute.functions.GroupNamingConvention; import org.jclouds.domain.Credentials; import org.jclouds.logging.Logger; @@ -55,19 +54,19 @@ public class VAppToNodeMetadata implements Function { protected final FindLocationForResource findLocationForResourceInVDC; protected final Function hardwareForVApp; - protected final Map vAppStatusToNodeState; + protected final Map vAppStatusToNodeStatus; protected final Map credentialStore; protected final GroupNamingConvention nodeNamingConvention; @Inject - protected VAppToNodeMetadata(Map vAppStatusToNodeState, Map credentialStore, + protected VAppToNodeMetadata(Map vAppStatusToNodeStatus, Map credentialStore, FindLocationForResource findLocationForResourceInVDC, Function hardwareForVApp, GroupNamingConvention.Factory namingConvention) { this.nodeNamingConvention = checkNotNull(namingConvention, "namingConvention").createWithoutPrefix(); this.hardwareForVApp = checkNotNull(hardwareForVApp, "hardwareForVApp"); this.findLocationForResourceInVDC = checkNotNull(findLocationForResourceInVDC, "findLocationForResourceInVDC"); this.credentialStore = checkNotNull(credentialStore, "credentialStore"); - this.vAppStatusToNodeState = checkNotNull(vAppStatusToNodeState, "vAppStatusToNodeState"); + this.vAppStatusToNodeStatus = checkNotNull(vAppStatusToNodeStatus, "vAppStatusToNodeStatus"); } public NodeMetadata apply(VApp from) { @@ -80,7 +79,7 @@ public class VAppToNodeMetadata implements Function { builder.group(nodeNamingConvention.groupInUniqueNameOrNull(from.getName())); builder.operatingSystem(toComputeOs(from, null)); builder.hardware(hardwareForVApp.apply(from)); - builder.state(vAppStatusToNodeState.get(from.getStatus())); + builder.status(vAppStatusToNodeStatus.get(from.getStatus())); Set addresses = getIpsFromVApp(from); builder.publicAddresses(filter(addresses, not(IsPrivateIPAddress.INSTANCE))); builder.privateAddresses(filter(addresses, IsPrivateIPAddress.INSTANCE)); diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/compute/functions/VAppToNodeMetadataTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/compute/functions/VAppToNodeMetadataTest.java index f3d5df5188..6b335b26c2 100644 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/compute/functions/VAppToNodeMetadataTest.java +++ b/apis/vcloud/src/test/java/org/jclouds/vcloud/compute/functions/VAppToNodeMetadataTest.java @@ -31,7 +31,6 @@ import org.jclouds.cim.xml.ResourceAllocationSettingDataHandler; import org.jclouds.collect.Memoized; import org.jclouds.compute.domain.Hardware; import org.jclouds.compute.domain.NodeMetadata; -import org.jclouds.compute.domain.NodeState; import org.jclouds.domain.Credentials; import org.jclouds.domain.Location; import org.jclouds.domain.LocationBuilder; @@ -101,7 +100,7 @@ public class VAppToNodeMetadataTest { @SuppressWarnings("unused") @Singleton @Provides - protected Map provideVAppStatusToNodeState() { + protected Map provideVAppStatusToNodeStatus() { return VCloudComputeServiceDependenciesModule.VAPPSTATUS_TO_NODESTATE; } diff --git a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/compute/TerremarkVCloudComputeClient.java b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/compute/TerremarkVCloudComputeClient.java index 77f49a0f30..45060ad8c4 100644 --- a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/compute/TerremarkVCloudComputeClient.java +++ b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/compute/TerremarkVCloudComputeClient.java @@ -25,9 +25,9 @@ import static org.jclouds.trmk.vcloud_0_8.options.AddInternetServiceOptions.Buil import java.net.URI; import java.util.Map; -import java.util.Map.Entry; import java.util.NoSuchElementException; import java.util.Set; +import java.util.Map.Entry; import javax.annotation.Resource; import javax.inject.Inject; @@ -36,7 +36,7 @@ import javax.inject.Provider; import javax.inject.Singleton; 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.domain.Credentials; import org.jclouds.domain.LoginCredentials; @@ -72,18 +72,18 @@ public class TerremarkVCloudComputeClient { protected final TerremarkVCloudClient client; protected final Provider passwordGenerator; protected final InternetServiceAndPublicIpAddressSupplier internetServiceAndPublicIpAddressSupplier; - protected final Map vAppStatusToNodeState; + protected final Map vAppStatusToNodeStatus; protected final Predicate taskTester; @Inject protected TerremarkVCloudComputeClient(TerremarkVCloudClient client, @Named("PASSWORD") Provider passwordGenerator, Predicate successTester, - Map vAppStatusToNodeState, Map credentialStore, + Map vAppStatusToNodeStatus, Map credentialStore, InternetServiceAndPublicIpAddressSupplier internetServiceAndPublicIpAddressSupplier) { this.client = client; this.passwordGenerator = passwordGenerator; this.internetServiceAndPublicIpAddressSupplier = internetServiceAndPublicIpAddressSupplier; - this.vAppStatusToNodeState = vAppStatusToNodeState; + this.vAppStatusToNodeStatus = vAppStatusToNodeStatus; this.taskTester = successTester; } diff --git a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/compute/config/TerremarkVCloudComputeServiceContextModule.java b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/compute/config/TerremarkVCloudComputeServiceContextModule.java index 4788da82b6..b448da1041 100644 --- a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/compute/config/TerremarkVCloudComputeServiceContextModule.java +++ b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/compute/config/TerremarkVCloudComputeServiceContextModule.java @@ -28,7 +28,6 @@ import org.jclouds.compute.ComputeService; import org.jclouds.compute.config.BaseComputeServiceContextModule; import org.jclouds.compute.domain.Image; import org.jclouds.compute.domain.NodeMetadata; -import org.jclouds.compute.domain.NodeState; import org.jclouds.compute.domain.OperatingSystem; import org.jclouds.compute.options.TemplateOptions; import org.jclouds.compute.strategy.PopulateDefaultLoginCredentialsForImageStrategy; @@ -60,15 +59,16 @@ import com.google.inject.TypeLiteral; public class TerremarkVCloudComputeServiceContextModule extends BaseComputeServiceContextModule { @VisibleForTesting - public static final Map VAPPSTATUS_TO_NODESTATE = ImmutableMap. builder() - .put(Status.OFF, NodeState.SUSPENDED).put(Status.ON, NodeState.RUNNING) - .put(Status.RESOLVED, NodeState.PENDING).put(Status.UNRECOGNIZED, NodeState.UNRECOGNIZED) - .put(Status.DEPLOYED, NodeState.PENDING).put(Status.SUSPENDED, NodeState.SUSPENDED) - .put(Status.UNRESOLVED, NodeState.PENDING).build(); + public static final Map VAPPSTATUS_TO_NODESTATE = ImmutableMap + . builder().put(Status.OFF, NodeMetadata.Status.SUSPENDED).put(Status.ON, + NodeMetadata.Status.RUNNING).put(Status.RESOLVED, NodeMetadata.Status.PENDING).put( + Status.UNRECOGNIZED, NodeMetadata.Status.UNRECOGNIZED).put(Status.DEPLOYED, + NodeMetadata.Status.PENDING).put(Status.SUSPENDED, NodeMetadata.Status.SUSPENDED).put( + Status.UNRESOLVED, NodeMetadata.Status.PENDING).build(); @Singleton @Provides - protected Map provideVAppStatusToNodeState() { + protected Map provideVAppStatusToNodeStatus() { return VAPPSTATUS_TO_NODESTATE; } diff --git a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/compute/functions/VAppToNodeMetadata.java b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/compute/functions/VAppToNodeMetadata.java index 966f9e6b66..95299cb588 100644 --- a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/compute/functions/VAppToNodeMetadata.java +++ b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/compute/functions/VAppToNodeMetadata.java @@ -32,7 +32,6 @@ import org.jclouds.compute.domain.CIMOperatingSystem; import org.jclouds.compute.domain.Image; import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.domain.NodeMetadataBuilder; -import org.jclouds.compute.domain.NodeState; import org.jclouds.compute.domain.OperatingSystem; import org.jclouds.compute.functions.GroupNamingConvention; import org.jclouds.compute.util.ComputeServiceUtils; @@ -57,12 +56,12 @@ public class VAppToNodeMetadata implements Function { protected final Supplier> images; protected final FindLocationForResource findLocationForResourceInVDC; protected final HardwareForVCloudExpressVApp hardwareForVCloudExpressVApp; - protected final Map vAppStatusToNodeState; + protected final Map vAppStatusToNodeStatus; protected final GroupNamingConvention nodeNamingConvention; @Inject protected VAppToNodeMetadata(TerremarkVCloudComputeClient computeClient, Map credentialStore, - Map vAppStatusToNodeState, HardwareForVCloudExpressVApp hardwareForVCloudExpressVApp, + Map vAppStatusToNodeStatus, HardwareForVCloudExpressVApp hardwareForVCloudExpressVApp, FindLocationForResource findLocationForResourceInVDC, @Memoized Supplier> images, GroupNamingConvention.Factory namingConvention) { this.nodeNamingConvention = checkNotNull(namingConvention, "namingConvention").createWithoutPrefix(); @@ -71,7 +70,7 @@ public class VAppToNodeMetadata implements Function { this.findLocationForResourceInVDC = checkNotNull(findLocationForResourceInVDC, "findLocationForResourceInVDC"); this.credentialStore = checkNotNull(credentialStore, "credentialStore"); this.computeClient = checkNotNull(computeClient, "computeClient"); - this.vAppStatusToNodeState = checkNotNull(vAppStatusToNodeState, "vAppStatusToNodeState"); + this.vAppStatusToNodeStatus = checkNotNull(vAppStatusToNodeStatus, "vAppStatusToNodeStatus"); } @Override @@ -97,7 +96,7 @@ public class VAppToNodeMetadata implements Function { builder.operatingSystem(osBuilder.build()); } builder.hardware(hardwareForVCloudExpressVApp.apply(from)); - builder.state(vAppStatusToNodeState.get(from.getStatus())); + builder.status(vAppStatusToNodeStatus.get(from.getStatus())); builder.publicAddresses(computeClient.getPublicAddresses(from.getHref())); builder.privateAddresses(computeClient.getPrivateAddresses(from.getHref())); builder.group(nodeNamingConvention.groupInUniqueNameOrNull(from.getName())); diff --git a/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/compute/TerremarkVCloudComputeClientTest.java b/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/compute/TerremarkVCloudComputeClientTest.java index c8386fc85b..1ad5dc51f1 100644 --- a/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/compute/TerremarkVCloudComputeClientTest.java +++ b/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/compute/TerremarkVCloudComputeClientTest.java @@ -32,7 +32,7 @@ import java.util.Map; import javax.inject.Provider; 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.LoginCredentials; import org.jclouds.trmk.vcloud_0_8.TerremarkVCloudClient; @@ -86,7 +86,7 @@ public class TerremarkVCloudComputeClientTest { expect(client.powerOnVApp(vappLocation)).andReturn(task); Predicate notFoundTester = createMock(Predicate.class); - Map vAppStatusToNodeState = createMock(Map.class); + Map vAppStatusToNodeStatus = createMock(Map.class); TerremarkVCloudComputeClient computeClient = new TerremarkVCloudComputeClient(client, new Provider() { @@ -96,7 +96,7 @@ public class TerremarkVCloudComputeClientTest { return "password"; } - }, successTester, vAppStatusToNodeState, credentialStore, supplier); + }, successTester, vAppStatusToNodeStatus, credentialStore, supplier); replay(vdc); replay(template); @@ -105,7 +105,7 @@ public class TerremarkVCloudComputeClientTest { replay(client); replay(successTester); replay(notFoundTester); - replay(vAppStatusToNodeState); + replay(vAppStatusToNodeStatus); NodeAndInitialCredentials response = computeClient.startAndReturnCredentials(vdcURI, templateURI, "name", new InstantiateVAppTemplateOptions()); @@ -120,6 +120,6 @@ public class TerremarkVCloudComputeClientTest { verify(client); verify(successTester); verify(notFoundTester); - verify(vAppStatusToNodeState); + verify(vAppStatusToNodeStatus); } } diff --git a/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/compute/strategy/CleanupOrphanKeysTest.java b/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/compute/strategy/CleanupOrphanKeysTest.java index 07d742ad45..13b56f8374 100644 --- a/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/compute/strategy/CleanupOrphanKeysTest.java +++ b/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/compute/strategy/CleanupOrphanKeysTest.java @@ -28,7 +28,7 @@ import java.net.URI; import java.util.Map; 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.domain.Credentials; 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()))) .andReturn(ImmutableSet.of(nodeMetadata)); expect(nodeMetadata.getGroup()).andReturn(orgTag.getName()).atLeastOnce(); - expect(nodeMetadata.getState()).andReturn(NodeState.RUNNING).atLeastOnce(); + expect(nodeMetadata.getStatus()).andReturn(Status.RUNNING).atLeastOnce(); expectCleanupCredentialStore(strategy, nodeMetadata); // replay mocks @@ -121,7 +121,7 @@ public class CleanupOrphanKeysTest { expect((Object) strategy.listNodes.listDetailsOnNodesMatching(parentLocationId(orgTag.getOrg().toASCIIString()))) .andReturn(ImmutableSet.of(nodeMetadata)); 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); expectCleanupCredentialStore(strategy, nodeMetadata); diff --git a/compute/src/main/clojure/org/jclouds/compute2.clj b/compute/src/main/clojure/org/jclouds/compute2.clj index db3c4a6c89..8d9147ed8c 100644 --- a/compute/src/main/clojure/org/jclouds/compute2.clj +++ b/compute/src/main/clojure/org/jclouds/compute2.clj @@ -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] (.runScriptOnNodesMatching compute (to-predicate pred) command options))) -(defmacro state-predicate [node state] - `(= (.getState ~node) - (. org.jclouds.compute.domain.NodeState ~state))) +(defmacro status-predicate [node status] + `(= (.getStatus ~node) + (. org.jclouds.compute.domain.NodeMetadata$Status ~status))) (defn pending? "Predicate for the node being in transition" [#^NodeMetadata node] - (state-predicate node PENDING)) + (status-predicate node PENDING)) (defn running? "Predicate for the node being available for requests." [#^NodeMetadata node] - (state-predicate node RUNNING)) + (status-predicate node RUNNING)) (defn terminated? "Predicate for the node being halted." [#^NodeMetadata node] (or (= node nil) - (state-predicate node TERMINATED))) + (status-predicate node TERMINATED))) (defn suspended? "Predicate for the node being suspended." [#^NodeMetadata node] - (state-predicate node SUSPENDED)) + (status-predicate node SUSPENDED)) -(defn error-state? - "Predicate for the node being in an error state." +(defn error-status? + "Predicate for the node being in an error status." [#^NodeMetadata node] - (state-predicate node ERROR)) + (status-predicate node ERROR)) -(defn unrecognized-state? - "Predicate for the node being in an unrecognized state." +(defn unrecognized-status? + "Predicate for the node being in an unrecognized status." [#^NodeMetadata node] - (state-predicate node UNRECOGNIZED)) + (status-predicate node UNRECOGNIZED)) (defn in-group? "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 Image version os-family os-description architecture) (define-accessors Hardware processors ram volumes) -(define-accessors NodeMetadata "node" credentials hardware state group) +(define-accessors NodeMetadata "node" credentials hardware status group) (def ^{:doc "TemplateBuilder functions" :private true} diff --git a/compute/src/main/java/org/jclouds/compute/config/ComputeServiceTimeoutsModule.java b/compute/src/main/java/org/jclouds/compute/config/ComputeServiceTimeoutsModule.java index 311a651175..99dc468af4 100644 --- a/compute/src/main/java/org/jclouds/compute/config/ComputeServiceTimeoutsModule.java +++ b/compute/src/main/java/org/jclouds/compute/config/ComputeServiceTimeoutsModule.java @@ -29,7 +29,7 @@ import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.predicates.AtomicNodeRunning; import org.jclouds.compute.predicates.AtomicNodeSuspended; 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.reference.ComputeServiceConstants.Timeouts; import org.jclouds.predicates.RetryablePredicate; @@ -56,7 +56,7 @@ public class ComputeServiceTimeoutsModule extends AbstractModule { @Provides @Singleton @Named("NODE_TERMINATED") - protected Predicate> serverTerminated(TrueIfNullOrTerminatedRefreshAndDoubleCheckOnFalse stateTerminated, Timeouts timeouts) { + protected Predicate> serverTerminated(AtomicNodeTerminated stateTerminated, Timeouts timeouts) { return timeouts.nodeTerminated == 0 ? stateTerminated : new RetryablePredicate>(stateTerminated, timeouts.nodeTerminated); } diff --git a/compute/src/main/java/org/jclouds/compute/domain/ComputeMetadataIncludingStatus.java b/compute/src/main/java/org/jclouds/compute/domain/ComputeMetadataIncludingStatus.java new file mode 100644 index 0000000000..bce2067d90 --- /dev/null +++ b/compute/src/main/java/org/jclouds/compute/domain/ComputeMetadataIncludingStatus.java @@ -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> extends ComputeMetadata { + + /** + * status of the resource + * @since 1.5 + */ + public S getStatus(); + +} diff --git a/compute/src/main/java/org/jclouds/compute/domain/NodeMetadata.java b/compute/src/main/java/org/jclouds/compute/domain/NodeMetadata.java index 36343a7cbf..53f1dc1ab0 100644 --- a/compute/src/main/java/org/jclouds/compute/domain/NodeMetadata.java +++ b/compute/src/main/java/org/jclouds/compute/domain/NodeMetadata.java @@ -32,7 +32,36 @@ import com.google.inject.ImplementedBy; * @author Ivan Meredith */ @ImplementedBy(NodeMetadataImpl.class) -public interface NodeMetadata extends ComputeMetadata { +public interface NodeMetadata extends ComputeMetadataIncludingStatus { + + 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; + + } + /** *

note

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. @@ -75,8 +104,12 @@ public interface NodeMetadata extends ComputeMetadata { OperatingSystem getOperatingSystem(); /** - * Current State of the node + * Current State of the node; replaced by {@link #getStatus()} + *

Note

+ * will be removed in jclouds 1.6! + * @see #getStatus() */ + @Deprecated NodeState getState(); /** diff --git a/compute/src/main/java/org/jclouds/compute/domain/NodeMetadataBuilder.java b/compute/src/main/java/org/jclouds/compute/domain/NodeMetadataBuilder.java index ff6ebf06b2..e33018c0e7 100644 --- a/compute/src/main/java/org/jclouds/compute/domain/NodeMetadataBuilder.java +++ b/compute/src/main/java/org/jclouds/compute/domain/NodeMetadataBuilder.java @@ -24,11 +24,10 @@ import java.net.URI; import java.util.Map; import java.util.Set; +import org.jclouds.compute.domain.NodeMetadata.Status; import org.jclouds.compute.domain.internal.NodeMetadataImpl; -import org.jclouds.domain.Credentials; import org.jclouds.domain.Location; import org.jclouds.domain.LoginCredentials; -import org.jclouds.domain.LoginCredentials.Builder; import org.jclouds.javax.annotation.Nullable; import com.google.common.collect.ImmutableSet; @@ -38,7 +37,7 @@ import com.google.common.collect.Sets; * @author Adrian Cole */ public class NodeMetadataBuilder extends ComputeMetadataBuilder { - private NodeState state; + private Status status; private Set publicAddresses = Sets.newLinkedHashSet(); private Set privateAddresses = Sets.newLinkedHashSet(); @Nullable @@ -63,9 +62,20 @@ public class NodeMetadataBuilder extends ComputeMetadataBuilder { this.loginPort = loginPort; return this; } - + + public NodeMetadataBuilder status(Status status) { + this.status = checkNotNull(status, "status"); + return this; + } + + /** + *

Note

+ * will be removed in jclouds 1.6! + * @see #status + */ + @Deprecated public NodeMetadataBuilder state(NodeState state) { - this.state = checkNotNull(state, "state"); + this.status = checkNotNull(state, "state").toStatus(); return this; } @@ -79,39 +89,11 @@ public class NodeMetadataBuilder extends ComputeMetadataBuilder { return this; } - /** - *

will be removed in jclouds 1.4.0

- * - * @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; - } - - /** - *

will be removed in jclouds 1.4.0

- * - * @see #credentials(LoginCredentials) - */ - @Deprecated - public NodeMetadataBuilder credentials(@Nullable Credentials credentials) { - return credentials(LoginCredentials.fromCredentials(credentials)); - } - public NodeMetadataBuilder credentials(@Nullable LoginCredentials credentials) { this.credentials = credentials; return this; } - public NodeMetadataBuilder group(@Nullable String group) { this.group = group; return this; @@ -180,14 +162,14 @@ public class NodeMetadataBuilder extends ComputeMetadataBuilder { @Override public NodeMetadata build() { 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) { 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.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()); } diff --git a/compute/src/main/java/org/jclouds/compute/domain/NodeState.java b/compute/src/main/java/org/jclouds/compute/domain/NodeState.java index 07dddea847..e0bd5a698d 100644 --- a/compute/src/main/java/org/jclouds/compute/domain/NodeState.java +++ b/compute/src/main/java/org/jclouds/compute/domain/NodeState.java @@ -18,35 +18,84 @@ */ 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 + * @see NodeMetadata#getStatus() */ +@Deprecated public enum NodeState { /** * The node is in transition + * + * @see Status#PENDING */ PENDING, /** * The node is visible, and in the process of being deleted. + * + * @see Status#TERMINATED */ TERMINATED, /** * The node is deployed, but suspended or stopped. + * + * @see Status#SUSPENDED */ SUSPENDED, /** * The node is available for requests + * + * @see Status#RUNNING */ RUNNING, /** * There is an error on the node + * + * @see Status#ERROR */ ERROR, /** * The state of the node is unrecognized. + * + * @see Status#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; + } + } } \ No newline at end of file diff --git a/compute/src/main/java/org/jclouds/compute/domain/TemplateBuilderSpec.java b/compute/src/main/java/org/jclouds/compute/domain/TemplateBuilderSpec.java index 9f0cec5ab7..1192374482 100644 --- a/compute/src/main/java/org/jclouds/compute/domain/TemplateBuilderSpec.java +++ b/compute/src/main/java/org/jclouds/compute/domain/TemplateBuilderSpec.java @@ -184,7 +184,13 @@ public class TemplateBuilderSpec implements Serializable { /** Specification; used for toParseableString(). */ // 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) { this.specification = specification; diff --git a/compute/src/main/java/org/jclouds/compute/domain/internal/NodeMetadataImpl.java b/compute/src/main/java/org/jclouds/compute/domain/internal/NodeMetadataImpl.java index 79a329cd6a..1502de8cac 100644 --- a/compute/src/main/java/org/jclouds/compute/domain/internal/NodeMetadataImpl.java +++ b/compute/src/main/java/org/jclouds/compute/domain/internal/NodeMetadataImpl.java @@ -27,12 +27,9 @@ import java.util.Set; import org.jclouds.compute.domain.ComputeType; import org.jclouds.compute.domain.Hardware; import org.jclouds.compute.domain.NodeMetadata; -import org.jclouds.compute.domain.NodeState; import org.jclouds.compute.domain.OperatingSystem; -import org.jclouds.domain.Credentials; import org.jclouds.domain.Location; import org.jclouds.domain.LoginCredentials; -import org.jclouds.domain.LoginCredentials.Builder; import org.jclouds.javax.annotation.Nullable; import com.google.common.collect.ImmutableSet; @@ -46,7 +43,7 @@ public class NodeMetadataImpl extends ComputeMetadataImpl implements NodeMetadat /** The serialVersionUID */ private static final long serialVersionUID = 7924307572338157887L; - private final NodeState state; + private final Status status; private final int loginPort; private final Set publicAddresses; private final Set privateAddresses; @@ -63,36 +60,9 @@ public class NodeMetadataImpl extends ComputeMetadataImpl implements NodeMetadat @Nullable private final String hostname; - /** - *

will be removed in jclouds 1.4.0

- */ - @Deprecated public NodeMetadataImpl(String providerId, String name, String id, Location location, URI uri, Map userMetadata, Set tags, @Nullable String group, @Nullable Hardware hardware, - @Nullable String imageId, @Nullable OperatingSystem os, NodeState state, int loginPort, - Iterable publicAddresses, Iterable 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 userMetadata, Set 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 publicAddresses, Iterable privateAddresses, @Nullable LoginCredentials credentials, String hostname) { 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.imageId = imageId; this.os = os; - this.state = checkNotNull(state, "state"); + this.status = checkNotNull(status, "status"); this.loginPort = loginPort; this.publicAddresses = ImmutableSet.copyOf(checkNotNull(publicAddresses, "publicAddresses")); this.privateAddresses = ImmutableSet.copyOf(checkNotNull(privateAddresses, "privateAddresses")); @@ -161,8 +131,17 @@ public class NodeMetadataImpl extends ComputeMetadataImpl implements NodeMetadat * {@inheritDoc} */ @Override - public NodeState getState() { - return state; + @Deprecated + 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() { return "[id=" + getId() + ", providerId=" + getProviderId() + ", group=" + getGroup() + ", name=" + getName() + ", location=" + getLocation() + ", uri=" + getUri() + ", imageId=" + getImageId() + ", os=" - + getOperatingSystem() + ", state=" + getState() + ", loginPort=" + getLoginPort() + ", hostname=" + + getOperatingSystem() + ", status=" + getStatus() + ", loginPort=" + getLoginPort() + ", hostname=" + getHostname() + ", privateAddresses=" + privateAddresses + ", publicAddresses=" + publicAddresses + ", hardware=" + getHardware() + ", loginUser=" + ((credentials != null) ? credentials.identity : null) + ", userMetadata=" + getUserMetadata() + ", tags=" + tags + "]"; diff --git a/compute/src/main/java/org/jclouds/compute/internal/BaseComputeService.java b/compute/src/main/java/org/jclouds/compute/internal/BaseComputeService.java index 8c56f43fa2..42106ad924 100644 --- a/compute/src/main/java/org/jclouds/compute/internal/BaseComputeService.java +++ b/compute/src/main/java/org/jclouds/compute/internal/BaseComputeService.java @@ -61,9 +61,9 @@ import org.jclouds.compute.domain.Hardware; import org.jclouds.compute.domain.Image; import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.domain.NodeMetadataBuilder; -import org.jclouds.compute.domain.NodeState; import org.jclouds.compute.domain.Template; import org.jclouds.compute.domain.TemplateBuilder; +import org.jclouds.compute.domain.NodeMetadata.Status; import org.jclouds.compute.extensions.ImageExtension; import org.jclouds.compute.options.RunScriptOptions; import org.jclouds.compute.options.TemplateOptions; @@ -576,9 +576,9 @@ public class BaseComputeService implements ComputeService { NodeMetadata node = this.getNodeMetadata(id); if (node == null) throw new NoSuchElementException(id); - if (node.getState() != NodeState.RUNNING) + if (node.getStatus() != Status.RUNNING) 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); node = updateNodeWithCredentialsIfPresent(node, options); ExecResponse response = runScriptOnNodeFactory.create(node, runScript, options).init().call(); @@ -595,9 +595,9 @@ public class BaseComputeService implements ComputeService { NodeMetadata node = this.getNodeMetadata(id); if (node == null) throw new NoSuchElementException(id); - if (node.getState() != NodeState.RUNNING) + if (node.getStatus() != Status.RUNNING) 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); final NodeMetadata node1 = updateNodeWithCredentialsIfPresent(node, options); ListenableFuture response = runScriptOnNodeFactory.submit(node1, runScript, options); diff --git a/compute/src/main/java/org/jclouds/compute/options/TemplateOptions.java b/compute/src/main/java/org/jclouds/compute/options/TemplateOptions.java index 2ff19be5ca..e9066f8ae8 100644 --- a/compute/src/main/java/org/jclouds/compute/options/TemplateOptions.java +++ b/compute/src/main/java/org/jclouds/compute/options/TemplateOptions.java @@ -26,7 +26,7 @@ import java.util.Arrays; import java.util.Map; 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.io.Payload; import org.jclouds.scriptbuilder.domain.Statement; @@ -588,7 +588,7 @@ public class TemplateOptions extends RunScriptOptions implements Cloneable { * * @param blockUntilRunning * (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) { this.blockUntilRunning = blockUntilRunning; diff --git a/compute/src/main/java/org/jclouds/compute/predicates/AtomicNodeRunning.java b/compute/src/main/java/org/jclouds/compute/predicates/AtomicNodeRunning.java index ab66cb91c1..cb13ddee74 100644 --- a/compute/src/main/java/org/jclouds/compute/predicates/AtomicNodeRunning.java +++ b/compute/src/main/java/org/jclouds/compute/predicates/AtomicNodeRunning.java @@ -18,13 +18,14 @@ */ package org.jclouds.compute.predicates; +import javax.inject.Inject; 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 com.google.common.collect.ImmutableSet; -import com.google.inject.Inject; /** * @@ -33,10 +34,10 @@ import com.google.inject.Inject; * @author Adrian Cole */ @Singleton -public class AtomicNodeRunning extends RefreshAndDoubleCheckOnFailUnlessStateInvalid { +public class AtomicNodeRunning extends RefreshNodeAndDoubleCheckOnFailUnlessStatusInvalid { @Inject public AtomicNodeRunning(GetNodeMetadataStrategy client) { - super(NodeState.RUNNING, ImmutableSet.of(NodeState.ERROR, NodeState.TERMINATED), client); + super(Status.RUNNING, ImmutableSet.of(Status.ERROR, Status.TERMINATED), client); } } diff --git a/compute/src/main/java/org/jclouds/compute/predicates/AtomicNodeSuspended.java b/compute/src/main/java/org/jclouds/compute/predicates/AtomicNodeSuspended.java index 3e94459195..640488bc7e 100644 --- a/compute/src/main/java/org/jclouds/compute/predicates/AtomicNodeSuspended.java +++ b/compute/src/main/java/org/jclouds/compute/predicates/AtomicNodeSuspended.java @@ -18,13 +18,14 @@ */ package org.jclouds.compute.predicates; +import javax.inject.Inject; 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 com.google.common.collect.ImmutableSet; -import com.google.inject.Inject; /** * @@ -33,10 +34,10 @@ import com.google.inject.Inject; * @author Adrian Cole */ @Singleton -public class AtomicNodeSuspended extends RefreshAndDoubleCheckOnFailUnlessStateInvalid { +public class AtomicNodeSuspended extends RefreshNodeAndDoubleCheckOnFailUnlessStatusInvalid { @Inject public AtomicNodeSuspended(GetNodeMetadataStrategy client) { - super(NodeState.SUSPENDED, ImmutableSet.of(NodeState.ERROR, NodeState.TERMINATED), client); + super(Status.SUSPENDED, ImmutableSet.of(Status.ERROR, Status.TERMINATED), client); } } diff --git a/compute/src/main/java/org/jclouds/compute/predicates/TrueIfNullOrTerminatedRefreshAndDoubleCheckOnFalse.java b/compute/src/main/java/org/jclouds/compute/predicates/AtomicNodeTerminated.java similarity index 51% rename from compute/src/main/java/org/jclouds/compute/predicates/TrueIfNullOrTerminatedRefreshAndDoubleCheckOnFalse.java rename to compute/src/main/java/org/jclouds/compute/predicates/AtomicNodeTerminated.java index bf95727a30..fe12a99690 100644 --- a/compute/src/main/java/org/jclouds/compute/predicates/TrueIfNullOrTerminatedRefreshAndDoubleCheckOnFalse.java +++ b/compute/src/main/java/org/jclouds/compute/predicates/AtomicNodeTerminated.java @@ -18,16 +18,13 @@ */ package org.jclouds.compute.predicates; -import java.util.concurrent.atomic.AtomicReference; - -import javax.annotation.Resource; +import static com.google.common.base.Preconditions.checkNotNull; 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.logging.Logger; -import com.google.common.base.Predicate; import com.google.inject.Inject; /** @@ -35,35 +32,20 @@ import com.google.inject.Inject; * * @author Adrian Cole */ -public class TrueIfNullOrTerminatedRefreshAndDoubleCheckOnFalse implements Predicate> { +public class AtomicNodeTerminated extends TrueIfNullOrDeletedRefreshAndDoubleCheckOnFalse { private final GetNodeMetadataStrategy client; - @Resource - protected Logger logger = Logger.NULL; - @Inject - public TrueIfNullOrTerminatedRefreshAndDoubleCheckOnFalse(GetNodeMetadataStrategy client) { - this.client = client; + public AtomicNodeTerminated(GetNodeMetadataStrategy client) { + super(Status.TERMINATED); + this.client = checkNotNull(client, "client"); } - - public boolean apply(AtomicReference 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 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()); + + @Override + protected NodeMetadata refreshOrNull(NodeMetadata resource) { + if (resource == null || resource.getId() == null) + return null; + return client.getNode(resource.getId()); } } diff --git a/compute/src/main/java/org/jclouds/compute/predicates/NodePredicates.java b/compute/src/main/java/org/jclouds/compute/predicates/NodePredicates.java index 32cd732d0f..e14210b8b6 100644 --- a/compute/src/main/java/org/jclouds/compute/predicates/NodePredicates.java +++ b/compute/src/main/java/org/jclouds/compute/predicates/NodePredicates.java @@ -24,7 +24,7 @@ import java.util.Set; import org.jclouds.compute.domain.ComputeMetadata; 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 com.google.common.base.Predicate; @@ -235,7 +235,7 @@ public class NodePredicates { return new Predicate() { @Override public boolean apply(NodeMetadata nodeMetadata) { - return group.equals(nodeMetadata.getGroup()) && nodeMetadata.getState() == NodeState.RUNNING; + return group.equals(nodeMetadata.getGroup()) && nodeMetadata.getStatus() == Status.RUNNING; } @Override @@ -251,7 +251,7 @@ public class NodePredicates { public static final Predicate RUNNING = new Predicate() { @Override public boolean apply(NodeMetadata nodeMetadata) { - return nodeMetadata.getState() == NodeState.RUNNING; + return nodeMetadata.getStatus() == Status.RUNNING; } @Override @@ -266,7 +266,7 @@ public class NodePredicates { public static final Predicate TERMINATED = new Predicate() { @Override public boolean apply(NodeMetadata nodeMetadata) { - return nodeMetadata.getState() == NodeState.TERMINATED; + return nodeMetadata.getStatus() == Status.TERMINATED; } @Override diff --git a/compute/src/main/java/org/jclouds/compute/predicates/RefreshAndDoubleCheckOnFailUnlessStateInvalid.java b/compute/src/main/java/org/jclouds/compute/predicates/RefreshAndDoubleCheckOnFailUnlessStateInvalid.java deleted file mode 100644 index 32e9e2fea2..0000000000 --- a/compute/src/main/java/org/jclouds/compute/predicates/RefreshAndDoubleCheckOnFailUnlessStateInvalid.java +++ /dev/null @@ -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> { - - private final GetNodeMetadataStrategy client; - private final NodeState intended; - private final Set 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 invalids, - GetNodeMetadataStrategy client) { - this.intended = intended; - this.client = client; - this.invalids = invalids; - } - - public boolean apply(AtomicReference 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()); - } -} diff --git a/compute/src/main/java/org/jclouds/compute/predicates/internal/RefreshAndDoubleCheckOnFailUnlessStatusInvalid.java b/compute/src/main/java/org/jclouds/compute/predicates/internal/RefreshAndDoubleCheckOnFailUnlessStatusInvalid.java new file mode 100644 index 0000000000..9ad4cca997 --- /dev/null +++ b/compute/src/main/java/org/jclouds/compute/predicates/internal/RefreshAndDoubleCheckOnFailUnlessStatusInvalid.java @@ -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, C extends ComputeMetadataIncludingStatus> implements Predicate> { + + private final S intended; + private final Set invalids; + @Resource + protected Logger logger = Logger.NULL; + + public RefreshAndDoubleCheckOnFailUnlessStatusInvalid(S intended, Set invalids) { + this.intended = checkNotNull(intended, "intended"); + this.invalids = ImmutableSet.copyOf(checkNotNull(invalids, "invalids")); + } + + public boolean apply(AtomicReference 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); +} diff --git a/compute/src/main/java/org/jclouds/compute/predicates/internal/RefreshNodeAndDoubleCheckOnFailUnlessStatusInvalid.java b/compute/src/main/java/org/jclouds/compute/predicates/internal/RefreshNodeAndDoubleCheckOnFailUnlessStatusInvalid.java new file mode 100644 index 0000000000..89a4073923 --- /dev/null +++ b/compute/src/main/java/org/jclouds/compute/predicates/internal/RefreshNodeAndDoubleCheckOnFailUnlessStatusInvalid.java @@ -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 { + + private final GetNodeMetadataStrategy client; + + @Inject + public RefreshNodeAndDoubleCheckOnFailUnlessStatusInvalid(Status intended, GetNodeMetadataStrategy client) { + this(intended, ImmutableSet.of(Status.ERROR), client); + } + + public RefreshNodeAndDoubleCheckOnFailUnlessStatusInvalid(Status intended, Set 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()); + } +} diff --git a/compute/src/main/java/org/jclouds/compute/predicates/internal/TrueIfNullOrDeletedRefreshAndDoubleCheckOnFalse.java b/compute/src/main/java/org/jclouds/compute/predicates/internal/TrueIfNullOrDeletedRefreshAndDoubleCheckOnFalse.java new file mode 100644 index 0000000000..78bec8a60e --- /dev/null +++ b/compute/src/main/java/org/jclouds/compute/predicates/internal/TrueIfNullOrDeletedRefreshAndDoubleCheckOnFalse.java @@ -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, C extends ComputeMetadataIncludingStatus> + implements Predicate> { + protected final S deletedStatus; + + @Resource + protected Logger logger = Logger.NULL; + + protected TrueIfNullOrDeletedRefreshAndDoubleCheckOnFalse(S deletedStatus) { + this.deletedStatus = checkNotNull(deletedStatus, "deletedStatus"); + } + + public boolean apply(AtomicReference 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); + +} diff --git a/compute/src/main/java/org/jclouds/compute/strategy/CustomizeNodeAndAddToGoodMapOrPutExceptionIntoBadMap.java b/compute/src/main/java/org/jclouds/compute/strategy/CustomizeNodeAndAddToGoodMapOrPutExceptionIntoBadMap.java index 67f48befe1..2eefd0e25f 100644 --- a/compute/src/main/java/org/jclouds/compute/strategy/CustomizeNodeAndAddToGoodMapOrPutExceptionIntoBadMap.java +++ b/compute/src/main/java/org/jclouds/compute/strategy/CustomizeNodeAndAddToGoodMapOrPutExceptionIntoBadMap.java @@ -36,7 +36,7 @@ import org.jclouds.compute.callables.RunScriptOnNode; import org.jclouds.compute.config.CustomizationResponse; import org.jclouds.compute.domain.ExecResponse; 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.reference.ComputeServiceConstants; import org.jclouds.compute.reference.ComputeServiceConstants.Timeouts; @@ -140,17 +140,17 @@ public class CustomizeNodeAndAddToGoodMapOrPutExceptionIntoBadMap implements Cal } else if (timeWaited < (timeouts.nodeRunning - earlyReturnGrace)) { throw new IllegalStateException( format( - "node(%s) didn't achieve the state running, so we couldn't customize; aborting prematurely after %d seconds with final state: %s", - originalId, timeWaited / 1000, node.get().getState())); + "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().getStatus())); } else { throw new IllegalStateException( format( - "node(%s) didn't achieve the state running within %d seconds, so we couldn't customize; final state: %s", - originalId, timeouts.nodeRunning / 1000, node.get().getState())); + "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().getStatus())); } } } 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)); } else { throw e; diff --git a/compute/src/main/java/org/jclouds/compute/strategy/impl/AdaptingComputeServiceStrategies.java b/compute/src/main/java/org/jclouds/compute/strategy/impl/AdaptingComputeServiceStrategies.java index 2e232caf11..ccb52339c5 100644 --- a/compute/src/main/java/org/jclouds/compute/strategy/impl/AdaptingComputeServiceStrategies.java +++ b/compute/src/main/java/org/jclouds/compute/strategy/impl/AdaptingComputeServiceStrategies.java @@ -33,8 +33,8 @@ import org.jclouds.compute.ComputeServiceAdapter.NodeAndInitialCredentials; import org.jclouds.compute.domain.ComputeMetadata; import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.domain.NodeMetadataBuilder; -import org.jclouds.compute.domain.NodeState; import org.jclouds.compute.domain.Template; +import org.jclouds.compute.domain.NodeMetadata.Status; import org.jclouds.compute.predicates.NodePredicates; import org.jclouds.compute.reference.ComputeServiceConstants; import org.jclouds.compute.strategy.CreateNodeWithGroupEncodedIntoName; @@ -127,7 +127,7 @@ public class AdaptingComputeServiceStrategies implements CreateNodeW } 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 diff --git a/compute/src/main/java/org/jclouds/compute/strategy/impl/CreateNodesWithGroupEncodedIntoNameThenAddToSet.java b/compute/src/main/java/org/jclouds/compute/strategy/impl/CreateNodesWithGroupEncodedIntoNameThenAddToSet.java index b4e9e2ab66..04ff27860d 100644 --- a/compute/src/main/java/org/jclouds/compute/strategy/impl/CreateNodesWithGroupEncodedIntoNameThenAddToSet.java +++ b/compute/src/main/java/org/jclouds/compute/strategy/impl/CreateNodesWithGroupEncodedIntoNameThenAddToSet.java @@ -41,8 +41,8 @@ import org.jclouds.Constants; import org.jclouds.compute.config.CustomizationResponse; import org.jclouds.compute.domain.ComputeMetadata; import org.jclouds.compute.domain.NodeMetadata; -import org.jclouds.compute.domain.NodeState; import org.jclouds.compute.domain.Template; +import org.jclouds.compute.domain.NodeMetadata.Status; import org.jclouds.compute.functions.GroupNamingConvention; import org.jclouds.compute.reference.ComputeServiceConstants; 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(), name, template.getImage().getProviderId(), template.getHardware().getProviderId()); 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(node); } @@ -133,7 +133,7 @@ public class CreateNodesWithGroupEncodedIntoNameThenAddToSet implements CreateNo * to the jclouds {@link NodeMetadata} object. This call directly precedes customization, such as * executing scripts. * - *

The outcome of this operation does not imply the node is {@link NodeState#RUNNING + *

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 * 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 name generated name of the node * @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> createNodeInGroupWithNameAndTemplate(String group, String name, Template template) { diff --git a/compute/src/main/java/org/jclouds/compute/stub/config/StubComputeServiceAdapter.java b/compute/src/main/java/org/jclouds/compute/stub/config/StubComputeServiceAdapter.java index 0200b4474e..2a7c002dec 100644 --- a/compute/src/main/java/org/jclouds/compute/stub/config/StubComputeServiceAdapter.java +++ b/compute/src/main/java/org/jclouds/compute/stub/config/StubComputeServiceAdapter.java @@ -36,10 +36,10 @@ import org.jclouds.compute.domain.Image; import org.jclouds.compute.domain.ImageBuilder; import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.domain.NodeMetadataBuilder; -import org.jclouds.compute.domain.NodeState; import org.jclouds.compute.domain.OperatingSystem; import org.jclouds.compute.domain.OsFamily; import org.jclouds.compute.domain.Template; +import org.jclouds.compute.domain.NodeMetadata.Status; import org.jclouds.domain.Location; import org.jclouds.domain.LoginCredentials; import org.jclouds.location.suppliers.all.JustProvider; @@ -84,13 +84,13 @@ public class StubComputeServiceAdapter implements JCloudsNativeComputeServiceAda this.osToVersionMap = osToVersionMap; } - protected void setStateOnNode(NodeState state, NodeMetadata node) { - nodes.put(node.getId(), NodeMetadataBuilder.fromNodeMetadata(node).state(state).build()); + protected void setStateOnNode(Status status, NodeMetadata node) { + 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) - setStateOnNode(state, node); + setStateOnNode(status, node); else ioThreads.execute(new Runnable() { @@ -101,7 +101,7 @@ public class StubComputeServiceAdapter implements JCloudsNativeComputeServiceAda } catch (InterruptedException e) { Throwables.propagate(e); } - setStateOnNode(state, node); + setStateOnNode(status, node); } }); @@ -120,13 +120,13 @@ public class StubComputeServiceAdapter implements JCloudsNativeComputeServiceAda builder.location(location.get()); builder.imageId(template.getImage().getId()); builder.operatingSystem(template.getImage().getOperatingSystem()); - builder.state(NodeState.PENDING); + builder.status(Status.PENDING); builder.publicAddresses(ImmutableSet. of(publicIpPrefix + id)); builder.privateAddresses(ImmutableSet. of(privateIpPrefix + id)); builder.credentials(LoginCredentials.builder().user("root").password(passwordPrefix + id).build()); NodeMetadata node = builder.build(); nodes.put(node.getId(), node); - setStateOnNodeAfterDelay(NodeState.RUNNING, node, 100); + setStateOnNodeAfterDelay(Status.RUNNING, node, 100); return new NodeWithInitialCredentials(node); } @@ -176,8 +176,8 @@ public class StubComputeServiceAdapter implements JCloudsNativeComputeServiceAda NodeMetadata node = nodes.get(id); if (node == null) return; - setStateOnNodeAfterDelay(NodeState.PENDING, node, 0); - setStateOnNodeAfterDelay(NodeState.TERMINATED, node, 50); + setStateOnNodeAfterDelay(Status.PENDING, node, 0); + setStateOnNodeAfterDelay(Status.TERMINATED, node, 50); ioThreads.execute(new Runnable() { @Override @@ -199,8 +199,8 @@ public class StubComputeServiceAdapter implements JCloudsNativeComputeServiceAda NodeMetadata node = nodes.get(id); if (node == null) throw new ResourceNotFoundException("node not found: " + id); - setStateOnNode(NodeState.PENDING, node); - setStateOnNodeAfterDelay(NodeState.RUNNING, node, 50); + setStateOnNode(Status.PENDING, node); + setStateOnNodeAfterDelay(Status.RUNNING, node, 50); } @Override @@ -208,12 +208,12 @@ public class StubComputeServiceAdapter implements JCloudsNativeComputeServiceAda NodeMetadata node = nodes.get(id); if (node == null) throw new ResourceNotFoundException("node not found: " + id); - if (node.getState() == NodeState.RUNNING) + if (node.getStatus() == Status.RUNNING) return; - if (node.getState() != NodeState.SUSPENDED) - throw new IllegalStateException("to resume a node, it must be in suspended state, not: " + node.getState()); - setStateOnNode(NodeState.PENDING, node); - setStateOnNodeAfterDelay(NodeState.RUNNING, node, 50); + if (node.getStatus() != Status.SUSPENDED) + throw new IllegalStateException("to resume a node, it must be in suspended status, not: " + node.getStatus()); + setStateOnNode(Status.PENDING, node); + setStateOnNodeAfterDelay(Status.RUNNING, node, 50); } @Override @@ -221,11 +221,11 @@ public class StubComputeServiceAdapter implements JCloudsNativeComputeServiceAda NodeMetadata node = nodes.get(id); if (node == null) throw new ResourceNotFoundException("node not found: " + id); - if (node.getState() == NodeState.SUSPENDED) + if (node.getStatus() == Status.SUSPENDED) return; - if (node.getState() != NodeState.RUNNING) - throw new IllegalStateException("to suspend a node, it must be in running state, not: " + node.getState()); - setStateOnNode(NodeState.PENDING, node); - setStateOnNodeAfterDelay(NodeState.SUSPENDED, node, 50); + if (node.getStatus() != Status.RUNNING) + throw new IllegalStateException("to suspend a node, it must be in running status, not: " + node.getStatus()); + setStateOnNode(Status.PENDING, node); + setStateOnNodeAfterDelay(Status.SUSPENDED, node, 50); } } \ No newline at end of file diff --git a/compute/src/main/java/org/jclouds/compute/stub/config/StubComputeServiceDependenciesModule.java b/compute/src/main/java/org/jclouds/compute/stub/config/StubComputeServiceDependenciesModule.java index 4ec374c9d7..87360b08dd 100644 --- a/compute/src/main/java/org/jclouds/compute/stub/config/StubComputeServiceDependenciesModule.java +++ b/compute/src/main/java/org/jclouds/compute/stub/config/StubComputeServiceDependenciesModule.java @@ -29,9 +29,9 @@ import javax.inject.Singleton; import org.jclouds.compute.domain.Hardware; import org.jclouds.compute.domain.NodeMetadata; -import org.jclouds.compute.domain.NodeState; import org.jclouds.compute.domain.Processor; import org.jclouds.compute.domain.Volume; +import org.jclouds.compute.domain.NodeMetadata.Status; import org.jclouds.compute.domain.internal.VolumeImpl; import org.jclouds.predicates.SocketOpen; import org.jclouds.rest.annotations.Identity; @@ -133,7 +133,7 @@ public class StubComputeServiceDependenciesModule extends AbstractModule { return false; String id = input.getHostText().replace(publicIpPrefix, ""); NodeMetadata node = nodes.get(id); - return node != null && node.getState() == NodeState.RUNNING; + return node != null && node.getStatus() == Status.RUNNING; } } diff --git a/compute/src/test/java/org/jclouds/compute/callables/RunScriptOnNodeAsInitScriptUsingSshAndBlockUntilCompleteTest.java b/compute/src/test/java/org/jclouds/compute/callables/RunScriptOnNodeAsInitScriptUsingSshAndBlockUntilCompleteTest.java index 74e2c5827d..3648fef6b6 100644 --- a/compute/src/test/java/org/jclouds/compute/callables/RunScriptOnNodeAsInitScriptUsingSshAndBlockUntilCompleteTest.java +++ b/compute/src/test/java/org/jclouds/compute/callables/RunScriptOnNodeAsInitScriptUsingSshAndBlockUntilCompleteTest.java @@ -34,7 +34,7 @@ import org.jclouds.compute.config.ComputeServiceProperties; import org.jclouds.compute.domain.ExecResponse; import org.jclouds.compute.domain.NodeMetadata; 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.reference.ComputeServiceConstants.Timeouts; import org.jclouds.concurrent.MoreExecutors; @@ -91,7 +91,7 @@ public class RunScriptOnNodeAsInitScriptUsingSshAndBlockUntilCompleteTest { @Test(expectedExceptions = IllegalStateException.class) public void testWithoutInitThrowsIllegalStateException() { 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(); SshClient sshClient = createMock(SshClient.class); @@ -139,7 +139,7 @@ public class RunScriptOnNodeAsInitScriptUsingSshAndBlockUntilCompleteTest { */ private void runDefaults(IAnswer answerForScriptStatus, int timesForScriptStatus) { 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(); SshClient sshClient = createMock(SshClient.class); @@ -193,7 +193,7 @@ public class RunScriptOnNodeAsInitScriptUsingSshAndBlockUntilCompleteTest { public void testWithSudoPassword() { 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(); SshClient sshClient = createMock(SshClient.class); @@ -242,7 +242,7 @@ public class RunScriptOnNodeAsInitScriptUsingSshAndBlockUntilCompleteTest { public void testNotRoot() { 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(); SshClient sshClient = createMock(SshClient.class); @@ -292,7 +292,7 @@ public class RunScriptOnNodeAsInitScriptUsingSshAndBlockUntilCompleteTest { public void testBadReturnCode() { 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(); SshClient sshClient = createMock(SshClient.class); diff --git a/compute/src/test/java/org/jclouds/compute/callables/RunScriptOnNodeAsInitScriptUsingSshTest.java b/compute/src/test/java/org/jclouds/compute/callables/RunScriptOnNodeAsInitScriptUsingSshTest.java index 3716c746ba..42a0a54ec6 100644 --- a/compute/src/test/java/org/jclouds/compute/callables/RunScriptOnNodeAsInitScriptUsingSshTest.java +++ b/compute/src/test/java/org/jclouds/compute/callables/RunScriptOnNodeAsInitScriptUsingSshTest.java @@ -28,7 +28,7 @@ import static org.testng.Assert.assertEquals; import org.jclouds.compute.domain.ExecResponse; import org.jclouds.compute.domain.NodeMetadata; 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.domain.LoginCredentials; import org.jclouds.scriptbuilder.InitScript; @@ -51,7 +51,7 @@ public class RunScriptOnNodeAsInitScriptUsingSshTest { @Test(expectedExceptions = IllegalStateException.class) public void testWithoutInitThrowsIllegalStateException() { 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(); SshClient sshClient = createMock(SshClient.class); @@ -67,7 +67,7 @@ public class RunScriptOnNodeAsInitScriptUsingSshTest { public void testDefault() { 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(); SshClient sshClient = createMock(SshClient.class); @@ -108,7 +108,7 @@ public class RunScriptOnNodeAsInitScriptUsingSshTest { public void testWithSudoPassword() { 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(); SshClient sshClient = createMock(SshClient.class); @@ -150,7 +150,7 @@ public class RunScriptOnNodeAsInitScriptUsingSshTest { public void testNotRoot() { 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(); SshClient sshClient = createMock(SshClient.class); diff --git a/compute/src/test/java/org/jclouds/compute/config/PersistNodeCredentialsTest.java b/compute/src/test/java/org/jclouds/compute/config/PersistNodeCredentialsTest.java index 31fb4918b1..a12caf03b3 100644 --- a/compute/src/test/java/org/jclouds/compute/config/PersistNodeCredentialsTest.java +++ b/compute/src/test/java/org/jclouds/compute/config/PersistNodeCredentialsTest.java @@ -30,7 +30,7 @@ import org.jclouds.compute.config.PersistNodeCredentialsModule.RefreshCredential import org.jclouds.compute.config.PersistNodeCredentialsModule.RefreshCredentialsForNodeIfRanAdminAccess; import org.jclouds.compute.domain.NodeMetadata; 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.domain.Credentials; import org.jclouds.domain.LoginCredentials; @@ -72,7 +72,7 @@ public class PersistNodeCredentialsTest { 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( credstore, null); assertEquals(node, fn.apply(node)); @@ -90,7 +90,7 @@ public class PersistNodeCredentialsTest { 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); assertEquals(node, fn.apply(node)); @@ -111,7 +111,7 @@ public class PersistNodeCredentialsTest { replay(statement); 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( credstore, statement); assertEquals(fn.apply(node).getCredentials(), credentials); @@ -136,7 +136,7 @@ public class PersistNodeCredentialsTest { replay(statement); 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); assertEquals(fn.apply(node).getCredentials(), credentials); diff --git a/compute/src/test/java/org/jclouds/compute/internal/BaseComputeServiceLiveTest.java b/compute/src/test/java/org/jclouds/compute/internal/BaseComputeServiceLiveTest.java index d9f512ccfa..e24ff2cf35 100644 --- a/compute/src/test/java/org/jclouds/compute/internal/BaseComputeServiceLiveTest.java +++ b/compute/src/test/java/org/jclouds/compute/internal/BaseComputeServiceLiveTest.java @@ -52,10 +52,10 @@ import java.util.ArrayList; import java.util.Collection; import java.util.List; import java.util.Map; -import java.util.Map.Entry; import java.util.NoSuchElementException; import java.util.Set; import java.util.SortedSet; +import java.util.Map.Entry; import java.util.concurrent.Callable; import java.util.concurrent.CancellationException; 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.Image; import org.jclouds.compute.domain.NodeMetadata; -import org.jclouds.compute.domain.NodeState; import org.jclouds.compute.domain.OperatingSystem; import org.jclouds.compute.domain.Template; import org.jclouds.compute.domain.TemplateBuilder; +import org.jclouds.compute.domain.NodeMetadata.Status; import org.jclouds.compute.options.TemplateOptions; import org.jclouds.domain.Credentials; import org.jclouds.domain.Location; @@ -468,7 +468,7 @@ public abstract class BaseComputeServiceLiveTest extends BaseComputeServiceConte assertNotNull(node.getProviderId()); assertNotNull(node.getGroup()); assertEquals(node.getGroup(), group); - assertEquals(node.getState(), NodeState.RUNNING); + assertEquals(node.getStatus(), Status.RUNNING); Credentials fromStore = view.utils().credentialStore().get("node#" + node.getId()); assertEquals(fromStore, node.getCredentials()); 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()); checkImageIdMatchesTemplate(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. assertEquals(metadata.getPrivateAddresses().size(), node.getPrivateAddresses().size(), String.format( "[%s] didn't match: [%s]", metadata.getPrivateAddresses(), node.getPrivateAddresses().size())); @@ -537,9 +537,9 @@ public abstract class BaseComputeServiceLiveTest extends BaseComputeServiceConte @Override public boolean apply(NodeMetadata input) { - boolean returnVal = input.getState() == NodeState.SUSPENDED; + boolean returnVal = input.getStatus() == Status.SUSPENDED; 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; } @@ -571,7 +571,7 @@ public abstract class BaseComputeServiceLiveTest extends BaseComputeServiceConte // assert nodeMetadata.getImage() != null : node; // user specified name is not always supported // assert nodeMetadata.getName() != null : nodeMetadata; - if (nodeMetadata.getState() == NodeState.RUNNING) { + if (nodeMetadata.getStatus() == Status.RUNNING) { assert nodeMetadata.getPublicAddresses() != null : nodeMetadata; assert nodeMetadata.getPublicAddresses().size() > 0 || nodeMetadata.getPrivateAddresses().size() > 0 : nodeMetadata; assertNotNull(nodeMetadata.getPrivateAddresses()); @@ -585,7 +585,7 @@ public abstract class BaseComputeServiceLiveTest extends BaseComputeServiceConte Set destroyed = client.destroyNodesMatching(inGroup(group)); assertEquals(toDestroy, destroyed.size()); 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 " + "node#" + node.getId(); } @@ -794,7 +794,7 @@ public abstract class BaseComputeServiceLiveTest extends BaseComputeServiceConte long time = currentTimeMillis(); Set nodes = client.createNodesInGroup(group, 1, options); NodeMetadata node = getOnlyElement(nodes); - assert node.getState() != NodeState.RUNNING : node; + assert node.getStatus() != Status.RUNNING : node; long duration = (currentTimeMillis() - time) / 1000; assert duration < nonBlockDurationSeconds : format("duration(%d) longer than expected(%d) seconds! ", duration, nonBlockDurationSeconds); diff --git a/compute/src/test/java/org/jclouds/compute/predicates/AtomicNodePredicatesTest.java b/compute/src/test/java/org/jclouds/compute/predicates/AtomicNodePredicatesTest.java index a9eabe2ef3..b9c6aabfae 100644 --- a/compute/src/test/java/org/jclouds/compute/predicates/AtomicNodePredicatesTest.java +++ b/compute/src/test/java/org/jclouds/compute/predicates/AtomicNodePredicatesTest.java @@ -27,7 +27,7 @@ import java.util.concurrent.atomic.AtomicReference; import org.jclouds.compute.domain.NodeMetadata; 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.domain.LoginCredentials; import org.testng.Assert; @@ -47,7 +47,7 @@ public class AtomicNodePredicatesTest { @Test 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); replay(computeService); @@ -63,7 +63,7 @@ public class AtomicNodePredicatesTest { @Test 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); expect(computeService.getNode("myid")).andReturn(pending); @@ -82,11 +82,11 @@ public class AtomicNodePredicatesTest { @Test public void testRefreshUpdatesAtomicReferenceOnRecheckPendingAcceptsNewCredentials() { 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(); - 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); @@ -104,8 +104,8 @@ public class AtomicNodePredicatesTest { @Test public void testRefreshUpdatesAtomicReferenceOnRecheckRunning() { - NodeMetadata running = new NodeMetadataBuilder().id("myid").state(NodeState.RUNNING).build(); - NodeMetadata pending = new NodeMetadataBuilder().id("myid").state(NodeState.PENDING).build(); + NodeMetadata running = new NodeMetadataBuilder().id("myid").status(Status.RUNNING).build(); + NodeMetadata pending = new NodeMetadataBuilder().id("myid").status(Status.PENDING).build(); GetNodeMetadataStrategy computeService = createMock(GetNodeMetadataStrategy.class); expect(computeService.getNode("myid")).andReturn(running); @@ -133,7 +133,7 @@ public class AtomicNodePredicatesTest { @Test public void testNodeRunningReturnsTrueWhenRunning() { - expect(node.getState()).andReturn(NodeState.RUNNING).atLeastOnce(); + expect(node.getStatus()).andReturn(Status.RUNNING).atLeastOnce(); replay(node); replay(computeService); @@ -145,7 +145,7 @@ public class AtomicNodePredicatesTest { @Test(expectedExceptions = IllegalStateException.class) public void testNodeRunningFailsOnTerminated() { - expect(node.getState()).andReturn(NodeState.TERMINATED).atLeastOnce(); + expect(node.getStatus()).andReturn(Status.TERMINATED).atLeastOnce(); replay(node); replay(computeService); @@ -157,7 +157,7 @@ public class AtomicNodePredicatesTest { @Test(expectedExceptions = IllegalStateException.class) public void testNodeRunningFailsOnError() { - expect(node.getState()).andReturn(NodeState.ERROR).atLeastOnce(); + expect(node.getStatus()).andReturn(Status.ERROR).atLeastOnce(); replay(node); replay(computeService); diff --git a/compute/src/test/java/org/jclouds/compute/strategy/CustomizeNodeAndAddToGoodMapOrPutExceptionIntoBadMapTest.java b/compute/src/test/java/org/jclouds/compute/strategy/CustomizeNodeAndAddToGoodMapOrPutExceptionIntoBadMapTest.java index 9b36d3a382..bd8426cf36 100644 --- a/compute/src/test/java/org/jclouds/compute/strategy/CustomizeNodeAndAddToGoodMapOrPutExceptionIntoBadMapTest.java +++ b/compute/src/test/java/org/jclouds/compute/strategy/CustomizeNodeAndAddToGoodMapOrPutExceptionIntoBadMapTest.java @@ -34,7 +34,7 @@ import java.util.concurrent.atomic.AtomicReference; import org.jclouds.compute.config.CustomizationResponse; import org.jclouds.compute.domain.NodeMetadata; 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.options.TemplateOptions; import org.jclouds.compute.predicates.AtomicNodeRunning; @@ -54,7 +54,7 @@ import com.google.common.collect.Sets; /** * @author Adrian Cole */ -@Test(groups = "unit") +@Test(groups = "unit", testName = "CustomizeNodeAndAddToGoodMapOrPutExceptionIntoBadMapTest") public class CustomizeNodeAndAddToGoodMapOrPutExceptionIntoBadMapTest { public void testBreakWhenNodeStillPending() { @@ -69,7 +69,7 @@ public class CustomizeNodeAndAddToGoodMapOrPutExceptionIntoBadMapTest { Map badNodes = Maps.newLinkedHashMap(); Multimap 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 GetNodeMetadataStrategy nodeRunning = new GetNodeMetadataStrategy(){ @@ -93,7 +93,7 @@ public class CustomizeNodeAndAddToGoodMapOrPutExceptionIntoBadMapTest { assertEquals(goodNodes.size(), 0); assertEquals(badNodes.keySet(), ImmutableSet.of(node)); 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()); assertEquals(customizationResponses.size(), 0); @@ -113,8 +113,8 @@ public class CustomizeNodeAndAddToGoodMapOrPutExceptionIntoBadMapTest { Map badNodes = Maps.newLinkedHashMap(); Multimap customizationResponses = LinkedHashMultimap.create(); - final NodeMetadata node = new NodeMetadataBuilder().ids("id").state(NodeState.PENDING).build(); - final NodeMetadata deadNnode = new NodeMetadataBuilder().ids("id").state(NodeState.TERMINATED).build(); + final NodeMetadata node = new NodeMetadataBuilder().ids("id").status(Status.PENDING).build(); + final NodeMetadata deadNnode = new NodeMetadataBuilder().ids("id").status(Status.TERMINATED).build(); // node dies GetNodeMetadataStrategy nodeRunning = new GetNodeMetadataStrategy(){ @@ -156,8 +156,8 @@ public class CustomizeNodeAndAddToGoodMapOrPutExceptionIntoBadMapTest { Map badNodes = Maps.newLinkedHashMap(); Multimap customizationResponses = LinkedHashMultimap.create(); - final NodeMetadata pendingNode = new NodeMetadataBuilder().ids("id").state(NodeState.PENDING).build(); - final NodeMetadata runningNode = new NodeMetadataBuilder().ids("id").state(NodeState.RUNNING).build(); + final NodeMetadata pendingNode = new NodeMetadataBuilder().ids("id").status(Status.PENDING).build(); + final NodeMetadata runningNode = new NodeMetadataBuilder().ids("id").status(Status.RUNNING).build(); expect(openSocketFinder.findOpenSocketOnNode(runningNode, 22, portTimeoutSecs, TimeUnit.SECONDS)) .andThrow(new NoSuchElementException("could not connect to any ip address port")).once(); diff --git a/labs/glesys/src/main/java/org/jclouds/glesys/compute/functions/ServerDetailsToNodeMetadata.java b/labs/glesys/src/main/java/org/jclouds/glesys/compute/functions/ServerDetailsToNodeMetadata.java index 9ded7d6ee3..bef2a123b4 100644 --- a/labs/glesys/src/main/java/org/jclouds/glesys/compute/functions/ServerDetailsToNodeMetadata.java +++ b/labs/glesys/src/main/java/org/jclouds/glesys/compute/functions/ServerDetailsToNodeMetadata.java @@ -35,10 +35,10 @@ import org.jclouds.compute.domain.HardwareBuilder; import org.jclouds.compute.domain.Image; import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.domain.NodeMetadataBuilder; -import org.jclouds.compute.domain.NodeState; import org.jclouds.compute.domain.OperatingSystem; import org.jclouds.compute.domain.Processor; import org.jclouds.compute.domain.Volume; +import org.jclouds.compute.domain.NodeMetadata.Status; import org.jclouds.compute.domain.internal.VolumeImpl; import org.jclouds.compute.functions.GroupNamingConvention; import org.jclouds.compute.reference.ComputeServiceConstants; @@ -65,11 +65,11 @@ public class ServerDetailsToNodeMetadata implements Function serverStateToNodeState = ImmutableMap - . builder().put(ServerDetails.State.STOPPED, NodeState.SUSPENDED) - .put(ServerDetails.State.LOCKED, NodeState.PENDING) - .put(ServerDetails.State.RUNNING, NodeState.RUNNING) - .put(ServerDetails.State.UNRECOGNIZED, NodeState.UNRECOGNIZED).build(); + public static final Map serverStateToNodeStatus = ImmutableMap + . builder().put(ServerDetails.State.STOPPED, Status.SUSPENDED) + .put(ServerDetails.State.LOCKED, Status.PENDING) + .put(ServerDetails.State.RUNNING, Status.RUNNING) + .put(ServerDetails.State.UNRECOGNIZED, Status.UNRECOGNIZED).build(); protected final Supplier> images; protected final FindLocationForServerDetails findLocationForServerDetails; @@ -112,7 +112,7 @@ public class ServerDetailsToNodeMetadata implements Function of(new VolumeImpl((float) from.getDiskSizeGB(), true, true))) .hypervisor(from.getPlatform()).build()); - builder.state(serverStateToNodeState.get(from.getState())); + builder.status(serverStateToNodeStatus.get(from.getState())); Iterable addresses = Iterables.filter(Iterables.transform(from.getIps(), new Function() { @Override diff --git a/labs/glesys/src/test/java/org/jclouds/glesys/compute/functions/ServerDetailsToNodeMetadataTest.java b/labs/glesys/src/test/java/org/jclouds/glesys/compute/functions/ServerDetailsToNodeMetadataTest.java index c48ed8c28f..516283cf64 100644 --- a/labs/glesys/src/test/java/org/jclouds/glesys/compute/functions/ServerDetailsToNodeMetadataTest.java +++ b/labs/glesys/src/test/java/org/jclouds/glesys/compute/functions/ServerDetailsToNodeMetadataTest.java @@ -25,11 +25,11 @@ import java.net.URI; import org.jclouds.compute.domain.HardwareBuilder; import org.jclouds.compute.domain.NodeMetadataBuilder; -import org.jclouds.compute.domain.NodeState; import org.jclouds.compute.domain.OperatingSystem; import org.jclouds.compute.domain.OsFamily; import org.jclouds.compute.domain.Processor; import org.jclouds.compute.domain.Volume; +import org.jclouds.compute.domain.NodeMetadata.Status; import org.jclouds.compute.domain.internal.VolumeImpl; import org.jclouds.glesys.compute.internal.BaseGleSYSComputeServiceExpectTest; import org.jclouds.glesys.features.ServerClientExpectTest; @@ -89,6 +89,6 @@ public class ServerDetailsToNodeMetadataTest extends BaseGleSYSComputeServiceExp new HardwareBuilder().ids("xm3276891").ram(512) .processors(ImmutableList.of(new Processor(1, 1.0))) .volumes(ImmutableList. of(new VolumeImpl(5f, true, true))).hypervisor("Xen") - .build()).state(NodeState.RUNNING).build()); + .build()).status(Status.RUNNING).build()); } } diff --git a/labs/nodepool/src/test/java/org/jclouds/nodepool/AppTest.java b/labs/nodepool/src/test/java/org/jclouds/nodepool/AppTest.java index 7977cc8e58..d198d7dc5e 100644 --- a/labs/nodepool/src/test/java/org/jclouds/nodepool/AppTest.java +++ b/labs/nodepool/src/test/java/org/jclouds/nodepool/AppTest.java @@ -176,8 +176,8 @@ public class AppTest extends TestCase { if (NodeMetadata.class.isInstance(cm)) { String nodeGroup = ((NodeMetadata) cm).getGroup(); - if (!((NodeMetadata) cm).getState().equals(NodeState.SUSPENDED) - && !((NodeMetadata) cm).getState().equals(NodeState.TERMINATED)) { + if (!((NodeMetadata) cm).getState().equals(Status.SUSPENDED) + && !((NodeMetadata) cm).getState().equals(Status.TERMINATED)) { nodeCount++; } } diff --git a/labs/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/AdminClientExpectTest.java b/labs/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/AdminClientExpectTest.java index 87cd71cd47..16753c99a7 100644 --- a/labs/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/AdminClientExpectTest.java +++ b/labs/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/AdminClientExpectTest.java @@ -51,6 +51,7 @@ import com.google.common.collect.ImmutableSet; * * @author Adam Lowe */ +@Test(testName = "AdminClientExpectTest") public class AdminClientExpectTest extends BaseKeystoneRestClientExpectTest { private DateService dateService = new SimpleDateFormatDateService(); diff --git a/labs/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/compute/functions/VMToNodeMetadata.java b/labs/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/compute/functions/VMToNodeMetadata.java index d2a9df35c2..83bc5a5603 100644 --- a/labs/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/compute/functions/VMToNodeMetadata.java +++ b/labs/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/compute/functions/VMToNodeMetadata.java @@ -33,7 +33,7 @@ import org.jclouds.collect.Memoized; import org.jclouds.compute.domain.CIMOperatingSystem; import org.jclouds.compute.domain.NodeMetadata; 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.domain.Location; import org.jclouds.savvis.vpdc.domain.VM; @@ -51,11 +51,11 @@ import com.google.common.collect.Iterables; @Singleton public class VMToNodeMetadata implements Function { - public static final Map VAPPSTATUS_TO_NODESTATE = ImmutableMap - . builder().put(VM.Status.OFF, NodeState.SUSPENDED).put(VM.Status.ON, - NodeState.RUNNING).put(VM.Status.RESOLVED, NodeState.PENDING).put(VM.Status.UNRECOGNIZED, - NodeState.UNRECOGNIZED).put(VM.Status.UNKNOWN, NodeState.UNRECOGNIZED).put(VM.Status.SUSPENDED, - NodeState.SUSPENDED).put(VM.Status.UNRESOLVED, NodeState.PENDING).build(); + public static final Map VAPPSTATUS_TO_NODESTATE = ImmutableMap + . builder().put(VM.Status.OFF, Status.SUSPENDED).put(VM.Status.ON, + Status.RUNNING).put(VM.Status.RESOLVED, Status.PENDING).put(VM.Status.UNRECOGNIZED, + Status.UNRECOGNIZED).put(VM.Status.UNKNOWN, Status.UNRECOGNIZED).put(VM.Status.SUSPENDED, + Status.SUSPENDED).put(VM.Status.UNRESOLVED, Status.PENDING).build(); private final FindLocationForVM findLocationForVM; private final GroupNamingConvention nodeNamingConvention; @@ -81,7 +81,7 @@ public class VMToNodeMetadata implements Function { } // TODO build from resource allocation section // builder.hardware(findHardwareForVM.apply(from)); - builder.state(VAPPSTATUS_TO_NODESTATE.get(from.getStatus())); + builder.status(VAPPSTATUS_TO_NODESTATE.get(from.getStatus())); Set addresses = Utils.getIpsFromVM(from); builder.publicAddresses(filter(addresses, not(IsPrivateIPAddress.INSTANCE))); builder.privateAddresses(filter(addresses, IsPrivateIPAddress.INSTANCE)); diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/compute/functions/VmToNodeMetadata.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/compute/functions/VmToNodeMetadata.java index 9f18522498..e784d2ff32 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/compute/functions/VmToNodeMetadata.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/compute/functions/VmToNodeMetadata.java @@ -35,14 +35,13 @@ import javax.inject.Singleton; import org.jclouds.compute.domain.Hardware; import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.domain.NodeMetadataBuilder; -import org.jclouds.compute.domain.NodeState; import org.jclouds.compute.functions.GroupNamingConvention; import org.jclouds.domain.Credentials; import org.jclouds.logging.Logger; import org.jclouds.util.InetAddresses2.IsPrivateIPAddress; 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.ResourceEntity.Status; import org.jclouds.vcloud.director.v1_5.predicates.LinkPredicates; import com.google.common.base.Function; @@ -58,19 +57,19 @@ public class VmToNodeMetadata implements Function { protected final FindLocationForResource findLocationForResourceInVDC; protected final Function hardwareForVm; - protected final Map vAppStatusToNodeState; + protected final Map vAppStatusToNodeStatus; protected final Map credentialStore; protected final GroupNamingConvention nodeNamingConvention; @Inject - protected VmToNodeMetadata(Map vAppStatusToNodeState, Map credentialStore, + protected VmToNodeMetadata(Map vAppStatusToNodeStatus, Map credentialStore, FindLocationForResource findLocationForResourceInVDC, Function hardwareForVm, GroupNamingConvention.Factory namingConvention) { this.nodeNamingConvention = checkNotNull(namingConvention, "namingConvention").createWithoutPrefix(); this.hardwareForVm = checkNotNull(hardwareForVm, "hardwareForVm"); this.findLocationForResourceInVDC = checkNotNull(findLocationForResourceInVDC, "findLocationForResourceInVDC"); this.credentialStore = checkNotNull(credentialStore, "credentialStore"); - this.vAppStatusToNodeState = checkNotNull(vAppStatusToNodeState, "vAppStatusToNodeState"); + this.vAppStatusToNodeStatus = checkNotNull(vAppStatusToNodeStatus, "vAppStatusToNodeStatus"); } public NodeMetadata apply(Vm from) { @@ -84,7 +83,7 @@ public class VmToNodeMetadata implements Function { builder.group(nodeNamingConvention.groupInUniqueNameOrNull(from.getName())); builder.operatingSystem(toComputeOs(from)); builder.hardware(hardwareForVm.apply(from)); - builder.state(vAppStatusToNodeState.get(from.getStatus())); + builder.status(vAppStatusToNodeStatus.get(from.getStatus())); Set addresses = getIpsFromVm(from); builder.publicAddresses(filter(addresses, not(IsPrivateIPAddress.INSTANCE))); builder.privateAddresses(filter(addresses, IsPrivateIPAddress.INSTANCE)); diff --git a/labs/virtualbox/src/main/java/org/jclouds/virtualbox/config/HardcodeLocalhostAsNodeMetadataSupplier.java b/labs/virtualbox/src/main/java/org/jclouds/virtualbox/config/HardcodeLocalhostAsNodeMetadataSupplier.java index eb8bf949f3..196559ca20 100644 --- a/labs/virtualbox/src/main/java/org/jclouds/virtualbox/config/HardcodeLocalhostAsNodeMetadataSupplier.java +++ b/labs/virtualbox/src/main/java/org/jclouds/virtualbox/config/HardcodeLocalhostAsNodeMetadataSupplier.java @@ -20,15 +20,16 @@ package org.jclouds.virtualbox.config; import java.io.File; import java.io.IOException; +import java.util.concurrent.Future; import javax.inject.Singleton; import org.jclouds.compute.callables.RunScriptOnNode; import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.domain.NodeMetadataBuilder; -import org.jclouds.compute.domain.NodeState; import org.jclouds.compute.domain.OperatingSystem; import org.jclouds.compute.domain.OsFamily; +import org.jclouds.compute.domain.NodeMetadata.Status; import org.jclouds.domain.LocationBuilder; import org.jclouds.domain.LocationScope; import org.jclouds.domain.LoginCredentials; @@ -103,7 +104,7 @@ public class HardcodeLocalhostAsNodeMetadataSupplier extends AbstractModule { .arch(System.getProperty("os.arch")) .version(System.getProperty("os.version")) .build()) - .state(NodeState.RUNNING) + .status(Status.RUNNING) .location(new LocationBuilder().id(HOST_ID) .scope(LocationScope.HOST) .description(HOSTNAME) diff --git a/labs/virtualbox/src/main/java/org/jclouds/virtualbox/config/VirtualBoxComputeServiceContextModule.java b/labs/virtualbox/src/main/java/org/jclouds/virtualbox/config/VirtualBoxComputeServiceContextModule.java index 741cb9e950..fb55c3be7f 100644 --- a/labs/virtualbox/src/main/java/org/jclouds/virtualbox/config/VirtualBoxComputeServiceContextModule.java +++ b/labs/virtualbox/src/main/java/org/jclouds/virtualbox/config/VirtualBoxComputeServiceContextModule.java @@ -33,7 +33,7 @@ import org.jclouds.compute.config.ComputeServiceAdapterContextModule; import org.jclouds.compute.domain.Hardware; import org.jclouds.compute.domain.Image; 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.reference.ComputeServiceConstants.Timeouts; import org.jclouds.domain.Location; @@ -174,23 +174,23 @@ public class VirtualBoxComputeServiceContextModule extends } @VisibleForTesting - public static final Map machineToNodeState = ImmutableMap - . builder().put(MachineState.Running, NodeState.RUNNING) - .put(MachineState.PoweredOff, NodeState.SUSPENDED) - .put(MachineState.DeletingSnapshot, NodeState.PENDING) - .put(MachineState.DeletingSnapshotOnline, NodeState.PENDING) - .put(MachineState.DeletingSnapshotPaused, NodeState.PENDING) - .put(MachineState.FaultTolerantSyncing, NodeState.PENDING) - .put(MachineState.LiveSnapshotting, NodeState.PENDING) - .put(MachineState.SettingUp, NodeState.PENDING) - .put(MachineState.Starting, NodeState.PENDING) - .put(MachineState.Stopping, NodeState.PENDING) - .put(MachineState.Restoring, NodeState.PENDING) + public static final Map machineToNodeStatus = ImmutableMap + . builder().put(MachineState.Running, Status.RUNNING) + .put(MachineState.PoweredOff, Status.SUSPENDED) + .put(MachineState.DeletingSnapshot, Status.PENDING) + .put(MachineState.DeletingSnapshotOnline, Status.PENDING) + .put(MachineState.DeletingSnapshotPaused, Status.PENDING) + .put(MachineState.FaultTolerantSyncing, Status.PENDING) + .put(MachineState.LiveSnapshotting, Status.PENDING) + .put(MachineState.SettingUp, Status.PENDING) + .put(MachineState.Starting, Status.PENDING) + .put(MachineState.Stopping, Status.PENDING) + .put(MachineState.Restoring, Status.PENDING) // TODO What to map these states to? - .put(MachineState.FirstOnline, NodeState.PENDING).put(MachineState.FirstTransient, NodeState.PENDING) - .put(MachineState.LastOnline, NodeState.PENDING).put(MachineState.LastTransient, NodeState.PENDING) - .put(MachineState.Teleported, NodeState.PENDING).put(MachineState.TeleportingIn, NodeState.PENDING) - .put(MachineState.TeleportingPausedVM, NodeState.PENDING).put(MachineState.Aborted, NodeState.ERROR) - .put(MachineState.Stuck, NodeState.ERROR).put(MachineState.Null, NodeState.UNRECOGNIZED).build(); + .put(MachineState.FirstOnline, Status.PENDING).put(MachineState.FirstTransient, Status.PENDING) + .put(MachineState.LastOnline, Status.PENDING).put(MachineState.LastTransient, Status.PENDING) + .put(MachineState.Teleported, Status.PENDING).put(MachineState.TeleportingIn, Status.PENDING) + .put(MachineState.TeleportingPausedVM, Status.PENDING).put(MachineState.Aborted, Status.ERROR) + .put(MachineState.Stuck, Status.ERROR).put(MachineState.Null, Status.UNRECOGNIZED).build(); } diff --git a/labs/virtualbox/src/main/java/org/jclouds/virtualbox/functions/IMachineToNodeMetadata.java b/labs/virtualbox/src/main/java/org/jclouds/virtualbox/functions/IMachineToNodeMetadata.java index 5379d38cba..2258236dbe 100644 --- a/labs/virtualbox/src/main/java/org/jclouds/virtualbox/functions/IMachineToNodeMetadata.java +++ b/labs/virtualbox/src/main/java/org/jclouds/virtualbox/functions/IMachineToNodeMetadata.java @@ -19,7 +19,7 @@ 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_PREFIX; @@ -30,7 +30,7 @@ import javax.inject.Named; import org.jclouds.compute.domain.NodeMetadata; 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.domain.LocationBuilder; import org.jclouds.domain.LocationScope; @@ -90,10 +90,10 @@ public class IMachineToNodeMetadata implements Function nodeMetadataBuilder.hostname(vm.getName()); MachineState vmState = vm.getState(); - NodeState nodeState = machineToNodeState.get(vmState); + NodeMetadata.Status nodeState = machineToNodeStatus.get(vmState); if (nodeState == null) - nodeState = NodeState.UNRECOGNIZED; - nodeMetadataBuilder.state(nodeState); + nodeState = Status.UNRECOGNIZED; + nodeMetadataBuilder.status(nodeState); /* // nat adapter diff --git a/labs/virtualbox/src/main/java/org/jclouds/virtualbox/functions/NodeCreator.java b/labs/virtualbox/src/main/java/org/jclouds/virtualbox/functions/NodeCreator.java index a70f4ef2c4..df5c301552 100644 --- a/labs/virtualbox/src/main/java/org/jclouds/virtualbox/functions/NodeCreator.java +++ b/labs/virtualbox/src/main/java/org/jclouds/virtualbox/functions/NodeCreator.java @@ -177,7 +177,7 @@ public class NodeCreator implements Function instanceToNodeState, + protected AWSRunningInstanceToNodeMetadata(Map instanceToNodeStatus, Map credentialStore, Supplier> imageMap, @Memoized Supplier> locations, @Memoized Supplier> hardware, GroupNamingConvention.Factory namingConvention) { - super(instanceToNodeState, credentialStore, imageMap, locations, hardware, namingConvention); + super(instanceToNodeStatus, credentialStore, imageMap, locations, hardware, namingConvention); } @Override diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/functions/AWSRunningInstanceToNodeMetadataTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/functions/AWSRunningInstanceToNodeMetadataTest.java index 1f7e7d58fd..c820dc1094 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/functions/AWSRunningInstanceToNodeMetadataTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/functions/AWSRunningInstanceToNodeMetadataTest.java @@ -29,7 +29,7 @@ import org.jclouds.aws.ec2.domain.MonitoringState; import org.jclouds.compute.domain.Hardware; import org.jclouds.compute.domain.Image; 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.date.DateService; import org.jclouds.domain.Credentials; @@ -135,7 +135,7 @@ public class AWSRunningInstanceToNodeMetadataTest { assertEquals( parser.apply(Iterables.get(contents, 0)).toString(), new NodeMetadataBuilder() - .state(NodeState.RUNNING) + .status(Status.RUNNING) .group("zkclustertest") .name("foo") .hostname("ip-10-212-81-7") @@ -149,7 +149,7 @@ public class AWSRunningInstanceToNodeMetadataTest { assertEquals( parser.apply(Iterables.get(contents, 1)), new NodeMetadataBuilder() - .state(NodeState.RUNNING) + .status(Status.RUNNING) .group("zkclustertest") .hostname("ip-10-212-185-8") .privateAddresses(ImmutableSet.of("10.212.185.8")) @@ -163,7 +163,7 @@ public class AWSRunningInstanceToNodeMetadataTest { protected AWSRunningInstanceToNodeMetadata createNodeParser(final ImmutableSet hardware, final ImmutableSet locations, Set images, Map credentialStore) { - Map instanceToNodeState = EC2ComputeServiceDependenciesModule.instanceToNodeState; + Map instanceToNodeStatus = EC2ComputeServiceDependenciesModule.instanceToNodeStatus; final Map 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, final ImmutableSet locations, Map credentialStore, - Map instanceToNodeState, LoadingCache instanceToImage) { + Map instanceToNodeStatus, LoadingCache instanceToImage) { Supplier> locationSupplier = new Supplier>() { @Override @@ -209,7 +209,7 @@ public class AWSRunningInstanceToNodeMetadataTest { }).getInstance(GroupNamingConvention.Factory.class); - AWSRunningInstanceToNodeMetadata parser = new AWSRunningInstanceToNodeMetadata(instanceToNodeState, + AWSRunningInstanceToNodeMetadata parser = new AWSRunningInstanceToNodeMetadata(instanceToNodeStatus, credentialStore, Suppliers.> ofInstance(instanceToImage), locationSupplier, hardwareSupplier, namingConvention); return parser; diff --git a/providers/gogrid/src/main/java/org/jclouds/gogrid/compute/config/GoGridComputeServiceContextModule.java b/providers/gogrid/src/main/java/org/jclouds/gogrid/compute/config/GoGridComputeServiceContextModule.java index d4b1163cca..e3e258a5a5 100644 --- a/providers/gogrid/src/main/java/org/jclouds/gogrid/compute/config/GoGridComputeServiceContextModule.java +++ b/providers/gogrid/src/main/java/org/jclouds/gogrid/compute/config/GoGridComputeServiceContextModule.java @@ -30,7 +30,7 @@ import org.jclouds.compute.config.ComputeServiceAdapterContextModule; import org.jclouds.compute.domain.Hardware; import org.jclouds.compute.domain.Image; 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.domain.Location; import org.jclouds.functions.IdentityFunction; @@ -85,21 +85,21 @@ public class GoGridComputeServiceContextModule extends } @VisibleForTesting - static final Map serverStateToNodeState = ImmutableMap. builder() - .put(ServerState.ON, NodeState.RUNNING)// - .put(ServerState.STARTING, NodeState.PENDING)// - .put(ServerState.OFF, NodeState.SUSPENDED)// - .put(ServerState.STOPPING, NodeState.PENDING)// - .put(ServerState.RESTARTING, NodeState.PENDING)// - .put(ServerState.SAVING, NodeState.PENDING)// - .put(ServerState.UNRECOGNIZED, NodeState.UNRECOGNIZED)// - .put(ServerState.RESTORING, NodeState.PENDING)// - .put(ServerState.UPDATING, NodeState.PENDING).build(); + static final Map serverStateToNodeStatus = ImmutableMap. builder() + .put(ServerState.ON, Status.RUNNING)// + .put(ServerState.STARTING, Status.PENDING)// + .put(ServerState.OFF, Status.SUSPENDED)// + .put(ServerState.STOPPING, Status.PENDING)// + .put(ServerState.RESTARTING, Status.PENDING)// + .put(ServerState.SAVING, Status.PENDING)// + .put(ServerState.UNRECOGNIZED, Status.UNRECOGNIZED)// + .put(ServerState.RESTORING, Status.PENDING)// + .put(ServerState.UPDATING, Status.PENDING).build(); @Singleton @Provides - Map provideServerToNodeState() { - return serverStateToNodeState; + Map provideServerToNodeStatus() { + return serverStateToNodeStatus; } /** diff --git a/providers/gogrid/src/main/java/org/jclouds/gogrid/compute/functions/ServerToNodeMetadata.java b/providers/gogrid/src/main/java/org/jclouds/gogrid/compute/functions/ServerToNodeMetadata.java index 9cea0a2159..91080f347d 100644 --- a/providers/gogrid/src/main/java/org/jclouds/gogrid/compute/functions/ServerToNodeMetadata.java +++ b/providers/gogrid/src/main/java/org/jclouds/gogrid/compute/functions/ServerToNodeMetadata.java @@ -32,7 +32,7 @@ import org.jclouds.compute.domain.Hardware; import org.jclouds.compute.domain.Image; import org.jclouds.compute.domain.NodeMetadata; 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.domain.Location; import org.jclouds.gogrid.domain.Server; @@ -54,7 +54,7 @@ public class ServerToNodeMetadata implements Function { @Resource protected Logger logger = Logger.NULL; - private final Map serverStateToNodeState; + private final Map serverStateToNodeStatus; private final Supplier> images; private final Supplier> hardwares; private final Supplier> locations; @@ -91,12 +91,12 @@ public class ServerToNodeMetadata implements Function { } @Inject - ServerToNodeMetadata(Map serverStateToNodeState, + ServerToNodeMetadata(Map serverStateToNodeStatus, @Memoized Supplier> images, @Memoized Supplier> hardwares, @Memoized Supplier> locations, GroupNamingConvention.Factory namingConvention) { this.nodeNamingConvention = checkNotNull(namingConvention, "namingConvention").createWithoutPrefix(); - this.serverStateToNodeState = checkNotNull(serverStateToNodeState, "serverStateToNodeState"); + this.serverStateToNodeStatus = checkNotNull(serverStateToNodeStatus, "serverStateToNodeStatus"); this.images = checkNotNull(images, "images"); this.hardwares = checkNotNull(hardwares, "hardwares"); this.locations = checkNotNull(locations, "locations"); @@ -117,7 +117,7 @@ public class ServerToNodeMetadata implements Function { if (image != null) builder.operatingSystem(image.getOperatingSystem()); - builder.state(serverStateToNodeState.get(from.getState())); + builder.status(serverStateToNodeStatus.get(from.getState())); builder.publicAddresses(ImmutableSet.of(from.getIp().getIp())); return builder.build(); } diff --git a/providers/gogrid/src/test/java/org/jclouds/gogrid/compute/config/GoGridComputeServiceContextModuleTest.java b/providers/gogrid/src/test/java/org/jclouds/gogrid/compute/config/GoGridComputeServiceContextModuleTest.java index f5ec5c8fea..0ef1b33939 100644 --- a/providers/gogrid/src/test/java/org/jclouds/gogrid/compute/config/GoGridComputeServiceContextModuleTest.java +++ b/providers/gogrid/src/test/java/org/jclouds/gogrid/compute/config/GoGridComputeServiceContextModuleTest.java @@ -31,7 +31,7 @@ public class GoGridComputeServiceContextModuleTest { public void testAllStatusCovered() { for (ServerState state : ServerState.values()) { - assert GoGridComputeServiceContextModule.serverStateToNodeState.containsKey(state) : state; + assert GoGridComputeServiceContextModule.serverStateToNodeStatus.containsKey(state) : state; } } diff --git a/providers/gogrid/src/test/java/org/jclouds/gogrid/compute/functions/ServerToNodeMetadataTest.java b/providers/gogrid/src/test/java/org/jclouds/gogrid/compute/functions/ServerToNodeMetadataTest.java index 117d11e795..31c9f68d33 100644 --- a/providers/gogrid/src/test/java/org/jclouds/gogrid/compute/functions/ServerToNodeMetadataTest.java +++ b/providers/gogrid/src/test/java/org/jclouds/gogrid/compute/functions/ServerToNodeMetadataTest.java @@ -30,8 +30,8 @@ import java.util.Set; import org.jclouds.compute.domain.Hardware; import org.jclouds.compute.domain.Image; import org.jclouds.compute.domain.NodeMetadata; -import org.jclouds.compute.domain.NodeState; import org.jclouds.compute.domain.OperatingSystem; +import org.jclouds.compute.domain.NodeMetadata.Status; import org.jclouds.compute.functions.GroupNamingConvention; import org.jclouds.domain.Location; import org.jclouds.domain.LocationBuilder; @@ -60,7 +60,7 @@ public class ServerToNodeMetadataTest { @Test public void testApplySetsTagFromNameAndCredentialsFromName() { - Map serverStateToNodeState = createMock(Map.class); + Map serverStateToNodeStatus = createMock(Map.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 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.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(); Set< ? extends Location> locations = ImmutableSet.< Location> of( location); @@ -88,12 +88,12 @@ public class ServerToNodeMetadataTest { expect(jcImage.getLocation()).andReturn(location).atLeastOnce(); expect(jcImage.getOperatingSystem()).andReturn(createMock(OperatingSystem.class)).atLeastOnce(); - replay(serverStateToNodeState); + replay(serverStateToNodeStatus); replay(server); replay(image); replay(jcImage); - ServerToNodeMetadata parser = new ServerToNodeMetadata(serverStateToNodeState, Suppliers + ServerToNodeMetadata parser = new ServerToNodeMetadata(serverStateToNodeStatus, Suppliers .> ofInstance(images), Suppliers .> ofInstance(GoGridHardwareSupplier.H_ALL), Suppliers .> ofInstance(locations), namingConvention); @@ -103,7 +103,7 @@ public class ServerToNodeMetadataTest { assertEquals(metadata.getImageId(), "2000"); assertEquals(metadata.getGroup(), "group"); - verify(serverStateToNodeState); + verify(serverStateToNodeStatus); verify(image); verify(server); verify(jcImage); diff --git a/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/binder/RimuHostingJsonBinder.java b/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/binder/RimuHostingJsonBinder.java index 011861169b..f015dc4e5d 100644 --- a/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/binder/RimuHostingJsonBinder.java +++ b/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/binder/RimuHostingJsonBinder.java @@ -18,7 +18,6 @@ */ package org.jclouds.rimuhosting.miro.binder; -import java.util.HashMap; import java.util.Map; import javax.inject.Inject; diff --git a/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/compute/config/RimuHostingComputeServiceDependenciesModule.java b/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/compute/config/RimuHostingComputeServiceDependenciesModule.java index c1669347f9..5e47072577 100644 --- a/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/compute/config/RimuHostingComputeServiceDependenciesModule.java +++ b/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/compute/config/RimuHostingComputeServiceDependenciesModule.java @@ -23,7 +23,7 @@ import java.util.Map; import javax.inject.Singleton; 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.domain.Server; import org.jclouds.rimuhosting.miro.domain.internal.RunningState; @@ -55,18 +55,18 @@ public class RimuHostingComputeServiceDependenciesModule extends AbstractModule } @VisibleForTesting - static final Map runningStateToNodeState = ImmutableMap. builder() - .put(RunningState.RUNNING, NodeState.RUNNING)// - .put(RunningState.NOTRUNNING, NodeState.SUSPENDED)// - .put(RunningState.POWERCYCLING, NodeState.PENDING)// - .put(RunningState.RESTARTING, NodeState.PENDING)// - .put(RunningState.UNRECOGNIZED, NodeState.UNRECOGNIZED)// + static final Map runningStateToNodeStatus = ImmutableMap. builder() + .put(RunningState.RUNNING, Status.RUNNING)// + .put(RunningState.NOTRUNNING, Status.SUSPENDED)// + .put(RunningState.POWERCYCLING, Status.PENDING)// + .put(RunningState.RESTARTING, Status.PENDING)// + .put(RunningState.UNRECOGNIZED, Status.UNRECOGNIZED)// .build(); @Singleton @Provides - Map provideServerToNodeState() { - return runningStateToNodeState; + Map provideServerToNodeStatus() { + return runningStateToNodeStatus; } @Singleton diff --git a/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/compute/functions/ServerToNodeMetadata.java b/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/compute/functions/ServerToNodeMetadata.java index e11c47d3d7..3d5a4f8536 100644 --- a/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/compute/functions/ServerToNodeMetadata.java +++ b/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/compute/functions/ServerToNodeMetadata.java @@ -32,8 +32,8 @@ import org.jclouds.collect.Memoized; import org.jclouds.compute.domain.Image; import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.domain.NodeMetadataBuilder; -import org.jclouds.compute.domain.NodeState; import org.jclouds.compute.domain.OperatingSystem; +import org.jclouds.compute.domain.NodeMetadata.Status; import org.jclouds.compute.functions.GroupNamingConvention; import org.jclouds.domain.Location; import org.jclouds.logging.Logger; @@ -57,7 +57,7 @@ public class ServerToNodeMetadata implements Function { protected final Supplier> locations; protected final Function> getPublicAddresses; - protected final Map runningStateToNodeState; + protected final Map runningStateToNodeStatus; protected final Supplier> images; protected final GroupNamingConvention nodeNamingConvention; @@ -80,13 +80,13 @@ public class ServerToNodeMetadata implements Function { @Inject ServerToNodeMetadata(Function> getPublicAddresses, - @Memoized Supplier> locations, Map runningStateToNodeState, + @Memoized Supplier> locations, Map runningStateToNodeStatus, @Memoized Supplier> images, GroupNamingConvention.Factory namingConvention) { this.nodeNamingConvention = checkNotNull(namingConvention, "namingConvention").createWithoutPrefix(); - this.getPublicAddresses = checkNotNull(getPublicAddresses, "serverStateToNodeState"); + this.getPublicAddresses = checkNotNull(getPublicAddresses, "serverStateToNodeStatus"); this.locations = checkNotNull(locations, "locations"); - this.runningStateToNodeState = checkNotNull(runningStateToNodeState, "serverStateToNodeState"); + this.runningStateToNodeStatus = checkNotNull(runningStateToNodeStatus, "serverStateToNodeStatus"); this.images = checkNotNull(images, "images"); } @@ -104,9 +104,9 @@ public class ServerToNodeMetadata implements Function { builder.hardware(null);// TODO if (from.getBillingData() != null && from.getBillingData().getDateCancelled() != null && RunningState.NOTRUNNING == from.getState()) - builder.state(NodeState.TERMINATED); + builder.status(Status.TERMINATED); else - builder.state(runningStateToNodeState.get(from.getState())); + builder.status(runningStateToNodeStatus.get(from.getState())); builder.publicAddresses(getPublicAddresses.apply(from)); return builder.build(); } diff --git a/providers/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/compute/config/RimuHostingComputeServiceContextModuleTest.java b/providers/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/compute/config/RimuHostingComputeServiceContextModuleTest.java index 23d743f76b..0d80742c2d 100644 --- a/providers/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/compute/config/RimuHostingComputeServiceContextModuleTest.java +++ b/providers/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/compute/config/RimuHostingComputeServiceContextModuleTest.java @@ -30,7 +30,7 @@ public class RimuHostingComputeServiceContextModuleTest { public void testAllStatusCovered() { for (RunningState state : RunningState.values()) { - assert RimuHostingComputeServiceDependenciesModule.runningStateToNodeState.containsKey(state) : state; + assert RimuHostingComputeServiceDependenciesModule.runningStateToNodeStatus.containsKey(state) : state; } } diff --git a/providers/slicehost/src/main/java/org/jclouds/slicehost/compute/config/SlicehostComputeServiceContextModule.java b/providers/slicehost/src/main/java/org/jclouds/slicehost/compute/config/SlicehostComputeServiceContextModule.java index ecf26037d4..aabf941470 100644 --- a/providers/slicehost/src/main/java/org/jclouds/slicehost/compute/config/SlicehostComputeServiceContextModule.java +++ b/providers/slicehost/src/main/java/org/jclouds/slicehost/compute/config/SlicehostComputeServiceContextModule.java @@ -27,8 +27,8 @@ import org.jclouds.compute.config.ComputeServiceAdapterContextModule; import org.jclouds.compute.domain.Hardware; import org.jclouds.compute.domain.Image; import org.jclouds.compute.domain.NodeMetadata; -import org.jclouds.compute.domain.NodeState; import org.jclouds.compute.domain.OperatingSystem; +import org.jclouds.compute.domain.NodeMetadata.Status; import org.jclouds.compute.internal.BaseComputeService; import org.jclouds.domain.Location; import org.jclouds.functions.IdentityFunction; @@ -79,18 +79,18 @@ public class SlicehostComputeServiceContextModule extends } @VisibleForTesting - public static final Map sliceStatusToNodeState = ImmutableMap - . builder().put(Slice.Status.ACTIVE, NodeState.RUNNING)// - .put(Slice.Status.BUILD, NodeState.PENDING)// - .put(Slice.Status.REBOOT, NodeState.PENDING)// - .put(Slice.Status.HARD_REBOOT, NodeState.PENDING)// - .put(Slice.Status.TERMINATED, NodeState.TERMINATED)// - .put(Slice.Status.UNRECOGNIZED, NodeState.UNRECOGNIZED)// + public static final Map sliceStatusToNodeStatus = ImmutableMap + . builder().put(Slice.Status.ACTIVE, Status.RUNNING)// + .put(Slice.Status.BUILD, Status.PENDING)// + .put(Slice.Status.REBOOT, Status.PENDING)// + .put(Slice.Status.HARD_REBOOT, Status.PENDING)// + .put(Slice.Status.TERMINATED, Status.TERMINATED)// + .put(Slice.Status.UNRECOGNIZED, Status.UNRECOGNIZED)// .build(); @Singleton @Provides - Map provideSliceToNodeState() { - return sliceStatusToNodeState; + Map provideSliceToNodeStatus() { + return sliceStatusToNodeStatus; } } diff --git a/providers/slicehost/src/main/java/org/jclouds/slicehost/compute/functions/SliceToNodeMetadata.java b/providers/slicehost/src/main/java/org/jclouds/slicehost/compute/functions/SliceToNodeMetadata.java index 9bc4171242..2c106e2cc5 100644 --- a/providers/slicehost/src/main/java/org/jclouds/slicehost/compute/functions/SliceToNodeMetadata.java +++ b/providers/slicehost/src/main/java/org/jclouds/slicehost/compute/functions/SliceToNodeMetadata.java @@ -33,8 +33,8 @@ import org.jclouds.compute.domain.Hardware; import org.jclouds.compute.domain.Image; import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.domain.NodeMetadataBuilder; -import org.jclouds.compute.domain.NodeState; import org.jclouds.compute.domain.OperatingSystem; +import org.jclouds.compute.domain.NodeMetadata.Status; import org.jclouds.compute.functions.GroupNamingConvention; import org.jclouds.domain.Location; import org.jclouds.logging.Logger; @@ -51,7 +51,7 @@ import com.google.common.collect.Iterables; @Singleton public class SliceToNodeMetadata implements Function { protected final Supplier location; - protected final Map sliceToNodeState; + protected final Map sliceToNodeStatus; protected final Supplier> images; protected final Supplier> hardwares; protected final GroupNamingConvention nodeNamingConvention; @@ -86,12 +86,12 @@ public class SliceToNodeMetadata implements Function { } @Inject - SliceToNodeMetadata(Map sliceStateToNodeState, + SliceToNodeMetadata(Map sliceStateToNodeStatus, @Memoized Supplier> images, Supplier location, @Memoized Supplier> hardwares, GroupNamingConvention.Factory namingConvention) { this.nodeNamingConvention = checkNotNull(namingConvention, "namingConvention").createWithoutPrefix(); - this.sliceToNodeState = checkNotNull(sliceStateToNodeState, "sliceStateToNodeState"); + this.sliceToNodeStatus = checkNotNull(sliceStateToNodeStatus, "sliceStateToNodeStatus"); this.images = checkNotNull(images, "images"); this.location = checkNotNull(location, "location"); this.hardwares = checkNotNull(hardwares, "hardwares"); @@ -108,7 +108,7 @@ public class SliceToNodeMetadata implements Function { builder.imageId(from.getImageId() + ""); builder.operatingSystem(parseOperatingSystem(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() { @Override diff --git a/providers/slicehost/src/test/java/org/jclouds/slicehost/compute/config/SlicehostComputeServiceContextModuleTest.java b/providers/slicehost/src/test/java/org/jclouds/slicehost/compute/config/SlicehostComputeServiceContextModuleTest.java index ad258a7ed9..b6e9872596 100644 --- a/providers/slicehost/src/test/java/org/jclouds/slicehost/compute/config/SlicehostComputeServiceContextModuleTest.java +++ b/providers/slicehost/src/test/java/org/jclouds/slicehost/compute/config/SlicehostComputeServiceContextModuleTest.java @@ -30,7 +30,7 @@ public class SlicehostComputeServiceContextModuleTest { public void testAllStatusCovered() { for (Slice.Status state : Slice.Status.values()) { - assert SlicehostComputeServiceContextModule.sliceStatusToNodeState.containsKey(state) : state; + assert SlicehostComputeServiceContextModule.sliceStatusToNodeStatus.containsKey(state) : state; } } diff --git a/providers/slicehost/src/test/java/org/jclouds/slicehost/compute/functions/SliceToNodeMetadataTest.java b/providers/slicehost/src/test/java/org/jclouds/slicehost/compute/functions/SliceToNodeMetadataTest.java index c07a782dbd..8bba87443b 100644 --- a/providers/slicehost/src/test/java/org/jclouds/slicehost/compute/functions/SliceToNodeMetadataTest.java +++ b/providers/slicehost/src/test/java/org/jclouds/slicehost/compute/functions/SliceToNodeMetadataTest.java @@ -28,12 +28,12 @@ import org.jclouds.compute.domain.HardwareBuilder; import org.jclouds.compute.domain.Image; import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.domain.NodeMetadataBuilder; -import org.jclouds.compute.domain.NodeState; import org.jclouds.compute.domain.OperatingSystem; import org.jclouds.compute.domain.OsFamily; import org.jclouds.compute.domain.Processor; import org.jclouds.compute.domain.Volume; import org.jclouds.compute.domain.VolumeBuilder; +import org.jclouds.compute.domain.NodeMetadata.Status; import org.jclouds.compute.functions.GroupNamingConvention; import org.jclouds.domain.Location; import org.jclouds.domain.LocationBuilder; @@ -59,18 +59,18 @@ public class SliceToNodeMetadataTest { @Test public void testApplyWhereImageAndHardwareNotFound() { - Map sliceStateToNodeState = SlicehostComputeServiceContextModule.sliceStatusToNodeState; + Map sliceStateToNodeStatus = SlicehostComputeServiceContextModule.sliceStatusToNodeStatus; Set images = ImmutableSet.of(); Set hardwares = ImmutableSet.of(); Slice slice = SliceHandlerTest.parseSlice(); - SliceToNodeMetadata parser = new SliceToNodeMetadata(sliceStateToNodeState, Suppliers + SliceToNodeMetadata parser = new SliceToNodeMetadata(sliceStateToNodeStatus, Suppliers .> ofInstance(images), Suppliers.ofInstance(provider), Suppliers .> ofInstance(hardwares), namingConvention); 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") .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()); @@ -78,18 +78,18 @@ public class SliceToNodeMetadataTest { @Test public void testApplyWhereImageFoundAndHardwareNotFound() { - Map sliceStateToNodeState = SlicehostComputeServiceContextModule.sliceStatusToNodeState; + Map sliceStateToNodeStatus = SlicehostComputeServiceContextModule.sliceStatusToNodeStatus; org.jclouds.compute.domain.Image jcImage = SlicehostImageToImageTest.convertImage(); Set images = ImmutableSet.of(jcImage); Set hardwares = ImmutableSet.of(); Slice slice = SliceHandlerTest.parseSlice(); - SliceToNodeMetadata parser = new SliceToNodeMetadata(sliceStateToNodeState, Suppliers + SliceToNodeMetadata parser = new SliceToNodeMetadata(sliceStateToNodeStatus, Suppliers .> ofInstance(images), Suppliers.ofInstance(provider), Suppliers .> ofInstance(hardwares), namingConvention); 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") .imageId("2").operatingSystem( new OperatingSystem.Builder().family(OsFamily.CENTOS).description("CentOS 5.2").version("5.2") @@ -100,17 +100,17 @@ public class SliceToNodeMetadataTest { @Test public void testApplyWhereImageAndHardwareFound() { - Map sliceStateToNodeState = SlicehostComputeServiceContextModule.sliceStatusToNodeState; + Map sliceStateToNodeStatus = SlicehostComputeServiceContextModule.sliceStatusToNodeStatus; Set images = ImmutableSet.of(SlicehostImageToImageTest.convertImage()); Set hardwares = ImmutableSet.of(FlavorToHardwareTest.convertFlavor()); Slice slice = SliceHandlerTest.parseSlice(); - SliceToNodeMetadata parser = new SliceToNodeMetadata(sliceStateToNodeState, Suppliers + SliceToNodeMetadata parser = new SliceToNodeMetadata(sliceStateToNodeStatus, Suppliers .> ofInstance(images), Suppliers.ofInstance(provider), Suppliers .> ofInstance(hardwares), namingConvention); 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") .imageId("2").hardware( new HardwareBuilder().ids("1").name("256 slice").processors( diff --git a/providers/softlayer/src/main/java/org/jclouds/softlayer/compute/functions/VirtualGuestToNodeMetadata.java b/providers/softlayer/src/main/java/org/jclouds/softlayer/compute/functions/VirtualGuestToNodeMetadata.java index bd1ee96cfe..b5a6bd8ee5 100644 --- a/providers/softlayer/src/main/java/org/jclouds/softlayer/compute/functions/VirtualGuestToNodeMetadata.java +++ b/providers/softlayer/src/main/java/org/jclouds/softlayer/compute/functions/VirtualGuestToNodeMetadata.java @@ -32,7 +32,7 @@ import org.jclouds.compute.domain.Hardware; import org.jclouds.compute.domain.Image; import org.jclouds.compute.domain.NodeMetadata; 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.domain.Location; import org.jclouds.softlayer.SoftLayerClient; @@ -54,10 +54,10 @@ import com.google.common.collect.Iterables; @Singleton public class VirtualGuestToNodeMetadata implements Function { - public static final Map serverStateToNodeState = ImmutableMap - . builder().put(VirtualGuest.State.HALTED, NodeState.PENDING) - .put(VirtualGuest.State.PAUSED, NodeState.SUSPENDED).put(VirtualGuest.State.RUNNING, NodeState.RUNNING) - .put(VirtualGuest.State.UNRECOGNIZED, NodeState.UNRECOGNIZED).build(); + public static final Map serverStateToNodeStatus = ImmutableMap + . builder().put(VirtualGuest.State.HALTED, Status.PENDING) + .put(VirtualGuest.State.PAUSED, Status.SUSPENDED).put(VirtualGuest.State.RUNNING, Status.RUNNING) + .put(VirtualGuest.State.UNRECOGNIZED, Status.UNRECOGNIZED).build(); private final FindLocationForVirtualGuest findLocationForVirtualGuest; private final GetHardwareForVirtualGuest getHardwareForVirtualGuest; @@ -94,7 +94,7 @@ public class VirtualGuestToNodeMetadata implements Function { - public static final Map serverStatusToNodeState = ImmutableMap - . builder().put(Server.Status.ACTIVE, NodeState.RUNNING)// - .put(Server.Status.BUILD, NodeState.PENDING)// - .put(Server.Status.TERMINATED, NodeState.TERMINATED)// - .put(Server.Status.UNRECOGNIZED, NodeState.UNRECOGNIZED)// + public static final Map serverStatusToNodeStatus = ImmutableMap + . builder().put(Server.Status.ACTIVE, Status.RUNNING)// + .put(Server.Status.BUILD, Status.PENDING)// + .put(Server.Status.TERMINATED, Status.TERMINATED)// + .put(Server.Status.UNRECOGNIZED, Status.UNRECOGNIZED)// .build(); private final FindHardwareForServer findHardwareForServer; @@ -87,7 +87,7 @@ public class ServerToNodeMetadata implements Function { if (image != null) builder.operatingSystem(image.getOperatingSystem()); builder.hardware(findHardwareForServer.apply(from)); - builder.state(serverStatusToNodeState.get(from.status)); + builder.status(serverStatusToNodeStatus.get(from.status)); builder.publicAddresses(ImmutableSet. of(from.publicAddress)); builder.privateAddresses(ImmutableSet. of(from.privateAddress)); builder.credentials(LoginCredentials.fromCredentials(credentialStore.get(from.id + "")));