Guest User

Untitled

a guest
Jul 19th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.24 KB | None | 0 0
  1. @Singleton
  2. public class RimuHostingServerService implements ServerService {
  3. RimuHostingClient rhClient;
  4.  
  5. @Inject
  6. public RimuHostingServerService(RimuHostingClient rhClient){
  7. this.rhClient = rhClient;
  8. }
  9.  
  10. public Server createServerAndWait(String name, String profile, String image) {
  11. NewInstanceResponse instanceResp = rhClient.createInstance(name, profile, image);
  12. return new RimuHostingServer(instanceResp.getInstance(), rhClient);
  13. }
  14.  
  15. public Future<Server> createServer(String name, String profile, String image) {
  16. return null; //To change body of implemented methods use File | Settings | File Templates.
  17. }
  18.  
  19. public SortedSet<Server> listServers() {
  20. SortedSet<Server> servers = new TreeSet<Server>();
  21. SortedSet<Instance> rhServers = rhClient.getInstanceList();
  22. for(Instance rhServer : rhServers) {
  23. servers.add(new RimuHostingServer(rhServer,rhClient));
  24. }
  25. return servers;
  26. }
  27.  
  28. public Server getServer(String id) {
  29. return new RimuHostingServer(rhClient.getInstance(Long.valueOf(id)), rhClient);
  30. }
  31. }
  32.  
  33. public class RimuHostingServer implements Server {
  34. org.jclouds.rimuhosting.miro.domain.Instance rhInstance;
  35.  
  36. RimuHostingClient rhClient;
  37.  
  38. public RimuHostingServer(org.jclouds.rimuhosting.miro.domain.Instance rhInstance, RimuHostingClient rhClient){
  39. this.rhInstance = rhInstance;
  40. this.rhClient = rhClient;
  41. }
  42.  
  43. public String getId() {
  44. return rhInstance.toString();
  45. }
  46.  
  47. public Platform createPlatform(String id) {
  48. return null; //To change body of implemented methods use File | Settings | File Templates.
  49. }
  50.  
  51. public Platform getPlatform(String id) {
  52. return null; //To change body of implemented methods use File | Settings | File Templates.
  53. }
  54.  
  55. public SortedSet<Platform> listPlatforms() {
  56. return null; //To change body of implemented methods use File | Settings | File Templates.
  57. }
  58.  
  59. public SortedSet<Instance> listInstances() {
  60. return null; //To change body of implemented methods use File | Settings | File Templates.
  61. }
  62.  
  63. public Boolean destroyServer() {
  64. rhClient.destroyInstance(rhInstance.getId());
  65. return Boolean.TRUE;
  66. }
  67. }
Add Comment
Please, Sign In to add comment