mirror of https://github.com/apache/jclouds.git
RimuHosting Impl of Server and ServerService
git-svn-id: http://jclouds.googlecode.com/svn/trunk@2342 3d8758e0-26b5-11de-8745-db77d3ebf521
This commit is contained in:
parent
44ec84c8aa
commit
13dd0a3f67
|
@ -8,15 +8,9 @@ import java.util.concurrent.Future;
|
||||||
/**
|
/**
|
||||||
* @author Ivan Meredith
|
* @author Ivan Meredith
|
||||||
*/
|
*/
|
||||||
public interface Server extends Service {
|
public interface Server {
|
||||||
public String getId();
|
public String getId();
|
||||||
|
|
||||||
public State rebootAndWait();
|
|
||||||
|
|
||||||
public Future<State> reboot();
|
|
||||||
|
|
||||||
public Boolean supportsPlatforms();
|
|
||||||
|
|
||||||
public Platform createPlatform(String id/*, Archive archive , mount? */);
|
public Platform createPlatform(String id/*, Archive archive , mount? */);
|
||||||
|
|
||||||
public Platform getPlatform(String id);
|
public Platform getPlatform(String id);
|
||||||
|
@ -24,4 +18,6 @@ public interface Server extends Service {
|
||||||
public SortedSet<Platform> listPlatforms();
|
public SortedSet<Platform> listPlatforms();
|
||||||
|
|
||||||
public SortedSet<Instance> listInstances(/* platform("mybilling-1.0.1").tags("production" */);
|
public SortedSet<Instance> listInstances(/* platform("mybilling-1.0.1").tags("production" */);
|
||||||
|
|
||||||
|
public Boolean destroyServer();
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,4 +16,5 @@ public interface ServerService {
|
||||||
public SortedSet<Server> listServers();
|
public SortedSet<Server> listServers();
|
||||||
|
|
||||||
public Server getServer(String id);
|
public Server getServer(String id);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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<Platform> listPlatforms() {
|
||||||
|
return null; //To change body of implemented methods use File | Settings | File Templates.
|
||||||
|
}
|
||||||
|
|
||||||
|
public SortedSet<Instance> listInstances() {
|
||||||
|
return null; //To change body of implemented methods use File | Settings | File Templates.
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean destroyServer() {
|
||||||
|
rhClient.destroyInstance(rhInstance.getId());
|
||||||
|
return Boolean.TRUE;
|
||||||
|
}
|
||||||
|
}
|
|
@ -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<Server> createServer(String name, String profile, String image) {
|
||||||
|
return null; //To change body of implemented methods use File | Settings | File Templates.
|
||||||
|
}
|
||||||
|
|
||||||
|
public SortedSet<Server> listServers() {
|
||||||
|
SortedSet<Server> servers = new TreeSet<Server>();
|
||||||
|
SortedSet<Instance> 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);
|
||||||
|
}
|
||||||
|
}
|
|
@ -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();
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue