diff --git a/core/src/test/java/org/jclouds/servers/Server.java b/core/src/test/java/org/jclouds/servers/Server.java index 6c519af38a..26f5d4a6a6 100644 --- a/core/src/test/java/org/jclouds/servers/Server.java +++ b/core/src/test/java/org/jclouds/servers/Server.java @@ -8,15 +8,9 @@ import java.util.concurrent.Future; /** * @author Ivan Meredith */ -public interface Server extends Service { +public interface Server { public String getId(); - public State rebootAndWait(); - - public Future reboot(); - - public Boolean supportsPlatforms(); - public Platform createPlatform(String id/*, Archive archive , mount? */); public Platform getPlatform(String id); @@ -24,4 +18,6 @@ public interface Server extends Service { public SortedSet listPlatforms(); public SortedSet listInstances(/* platform("mybilling-1.0.1").tags("production" */); + + public Boolean destroyServer(); } diff --git a/core/src/test/java/org/jclouds/servers/ServerService.java b/core/src/test/java/org/jclouds/servers/ServerService.java index c62f10a8db..874d17f912 100644 --- a/core/src/test/java/org/jclouds/servers/ServerService.java +++ b/core/src/test/java/org/jclouds/servers/ServerService.java @@ -16,4 +16,5 @@ public interface ServerService { public SortedSet listServers(); public Server getServer(String id); + } diff --git a/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/servers/RimuHostingServer.java b/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/servers/RimuHostingServer.java new file mode 100644 index 0000000000..0c206e7003 --- /dev/null +++ b/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/servers/RimuHostingServer.java @@ -0,0 +1,46 @@ +package org.jclouds.rimuhosting.miro.servers; + +import org.jclouds.servers.Server; +import org.jclouds.servers.Platform; +import org.jclouds.servers.Instance; +import org.jclouds.rimuhosting.miro.RimuHostingClient; +import com.google.common.base.Service; + +import java.util.concurrent.Future; +import java.util.SortedSet; + +public class RimuHostingServer implements Server { + org.jclouds.rimuhosting.miro.domain.Instance rhInstance; + + RimuHostingClient rhClient; + + public RimuHostingServer(org.jclouds.rimuhosting.miro.domain.Instance rhInstance, RimuHostingClient rhClient){ + this.rhInstance = rhInstance; + this.rhClient = rhClient; + } + + public String getId() { + return rhInstance.toString(); + } + + public Platform createPlatform(String id) { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public Platform getPlatform(String id) { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public SortedSet listPlatforms() { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public SortedSet listInstances() { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public Boolean destroyServer() { + rhClient.destroyInstance(rhInstance.getId()); + return Boolean.TRUE; + } +} diff --git a/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/servers/RimuHostingServerService.java b/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/servers/RimuHostingServerService.java new file mode 100644 index 0000000000..930c9135c8 --- /dev/null +++ b/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/servers/RimuHostingServerService.java @@ -0,0 +1,48 @@ +package org.jclouds.rimuhosting.miro.servers; + +import org.jclouds.servers.ServerService; +import org.jclouds.servers.Server; +import org.jclouds.rimuhosting.miro.RimuHostingClient; +import org.jclouds.rimuhosting.miro.domain.Instance; +import org.jclouds.rimuhosting.miro.domain.NewInstanceResponse; + +import javax.inject.Singleton; +import javax.inject.Inject; +import java.util.concurrent.Future; +import java.util.SortedSet; +import java.util.TreeSet; + +/** + * @author Ivan Meredith + */ +@Singleton +public class RimuHostingServerService implements ServerService { + RimuHostingClient rhClient; + + @Inject + public RimuHostingServerService(RimuHostingClient rhClient){ + this.rhClient = rhClient; + } + + public Server createServerAndWait(String name, String profile, String image) { + NewInstanceResponse instanceResp = rhClient.createInstance(name, image, profile); + return new RimuHostingServer(instanceResp.getInstance(), rhClient); + } + + public Future createServer(String name, String profile, String image) { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public SortedSet listServers() { + SortedSet servers = new TreeSet(); + SortedSet rhServers = rhClient.getInstanceList(); + for(Instance rhServer : rhServers) { + servers.add(new RimuHostingServer(rhServer,rhClient)); + } + return servers; + } + + public Server getServer(String id) { + return new RimuHostingServer(rhClient.getInstance(Long.valueOf(id)), rhClient); + } +} \ No newline at end of file diff --git a/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/servers/RimuHostingServerServiceLiveTest.java b/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/servers/RimuHostingServerServiceLiveTest.java new file mode 100644 index 0000000000..a77c6241ed --- /dev/null +++ b/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/servers/RimuHostingServerServiceLiveTest.java @@ -0,0 +1,48 @@ +package org.jclouds.rimuhosting.miro.servers; + +import org.testng.annotations.Test; +import org.testng.annotations.BeforeGroups; +import org.jclouds.rimuhosting.miro.*; +import org.jclouds.rimuhosting.miro.config.RimuHostingRestClientModule; +import org.jclouds.logging.log4j.config.Log4JLoggingModule; +import org.jclouds.ssh.jsch.config.JschSshClientModule; +import org.jclouds.predicates.SocketOpen; +import org.jclouds.predicates.RetryablePredicate; +import org.jclouds.predicates.AddressReachable; +import org.jclouds.servers.Server; +import com.google.inject.*; +import static com.google.common.base.Preconditions.checkNotNull; +import static org.testng.Assert.assertNotNull; + +import com.google.common.base.Predicate; + +import java.net.InetSocketAddress; +import java.net.InetAddress; +import java.util.concurrent.TimeUnit; + +/** + * @author Ivan Meredith + */ +@Test(groups = "live", sequential = true, testName = "rimuhosting.RimuHostingServerServiceLiveTest") +public class RimuHostingServerServiceLiveTest { + RimuHostingClient rhClient; + RimuHostingServerService rhServerService; + + @BeforeGroups(groups = { "live" }) + public void setupClient() { + String account = "ddd"; + String key = checkNotNull(System.getProperty("jclouds.test.key"), "jclouds.test.key"); + Injector injector = new RimuHostingContextBuilder(new RimuHostingPropertiesBuilder( + account, key).relaxSSLHostname().build()).withModules(new Log4JLoggingModule()).buildInjector(); + + rhClient = injector.getInstance(RimuHostingClient.class); + rhServerService = injector.getInstance(RimuHostingServerService.class); + } + + @Test + public void testServerCreate(){ + Server server = rhServerService.createServerAndWait("test.com", "MIRO1B", "lenny"); + assertNotNull(rhClient.getInstance(Long.valueOf(server.getId()))); + server.destroyServer(); + } +}