diff --git a/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/domain/IpAddresses.java b/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/domain/IpAddresses.java index 2e5e8592f8..9055fc918c 100644 --- a/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/domain/IpAddresses.java +++ b/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/domain/IpAddresses.java @@ -45,4 +45,12 @@ public class IpAddresses { public void setPrimaryIp(String primaryIp) { this.primaryIp = primaryIp; } + + public SortedSet getSecondaryIps() { + return secondaryIps; + } + + public void setSecondaryIps(SortedSet secondaryIps) { + this.secondaryIps = secondaryIps; + } } diff --git a/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/domain/NewServerResponse.java b/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/domain/NewServerResponse.java index 81346bae80..fc7debcf2b 100644 --- a/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/domain/NewServerResponse.java +++ b/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/domain/NewServerResponse.java @@ -42,12 +42,12 @@ public class NewServerResponse implements Comparable { @SerializedName("running_vps_info") private ServerInfo serverInfo; - public Server getInstance() { + public Server getServer() { return server; } - public void setInstance(Server instaince) { - this.server = instaince; + public void setServer(Server server) { + this.server = server; } public NewServerData getNewInstanceRequest() { @@ -58,16 +58,16 @@ public class NewServerResponse implements Comparable { this.newServerDataRequest = newServerDataRequest; } - public ServerInfo getInstanceInfo() { + public ServerInfo getServerInfo() { return serverInfo; } - public void setInstanceInfo(ServerInfo serverInfo) { + public void setServerInfo(ServerInfo serverInfo) { this.serverInfo = serverInfo; } @Override public int compareTo(NewServerResponse server) { - return this.server.getId().compareTo(server.getInstance().getId()); + return this.server.getId().compareTo(server.getServer().getId()); } } diff --git a/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/servers/RimuHostingComputeService.java b/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/servers/RimuHostingComputeService.java index 3ffb1feecd..81dafd0a4f 100644 --- a/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/servers/RimuHostingComputeService.java +++ b/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/servers/RimuHostingComputeService.java @@ -49,9 +49,8 @@ public class RimuHostingComputeService implements ComputeService { @Override public CreateServerResponse createServer(String name, String profile, String image) { - NewServerResponse serverResp = rhClient.createInstance(name, image, profile); - // return new RimuHostingServer(serverResp.getInstance(), rhClient); - throw new UnsupportedOperationException(); + NewServerResponse serverResponse = rhClient.createInstance(name, image, profile); + return new RimuHostingCreateServerResponse(serverResponse); } public SortedSet listServers() { diff --git a/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/servers/RimuHostingCreateServerResponse.java b/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/servers/RimuHostingCreateServerResponse.java new file mode 100644 index 0000000000..ca1f47fa6b --- /dev/null +++ b/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/servers/RimuHostingCreateServerResponse.java @@ -0,0 +1,99 @@ +/** + * + * Copyright (C) 2009 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF 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.rimuhosting.miro.servers; + +import org.jclouds.compute.domain.CreateServerResponse; +import org.jclouds.compute.domain.LoginType; +import org.jclouds.domain.Credentials; +import org.jclouds.rimuhosting.miro.domain.Server; +import org.jclouds.rimuhosting.miro.domain.NewServerResponse; + +import java.net.InetAddress; +import java.net.UnknownHostException; +import java.util.SortedSet; +import java.util.TreeSet; + +/** + * @author Ivan Meredith + */ +public class RimuHostingCreateServerResponse implements CreateServerResponse { + private Server rhServer; + private NewServerResponse rhServerResponse; + + public RimuHostingCreateServerResponse(NewServerResponse rhServerResponse){ + this.rhServer = rhServerResponse.getServer(); + this.rhServerResponse = rhServerResponse; + } + public String getId() { + return rhServer.getId().toString(); + } + + public String getName() { + return rhServer.getName(); + } + + public SortedSet getPublicAddresses() { + SortedSet ipAddresses = new TreeSet(); + try { + InetAddress address = InetAddress.getByName(rhServer.getIpAddresses().getPrimaryIp()); + ipAddresses.add(address); + } catch (UnknownHostException e) { + //TODO: log the failure. + } + + for(String ip : rhServer.getIpAddresses().getSecondaryIps()){ + try { + InetAddress address = InetAddress.getByName(rhServer.getIpAddresses().getPrimaryIp()); + ipAddresses.add(address); + } catch (UnknownHostException e) { + //TODO: log the failure. + } + } + return null; + } + + /** + * Rimuhosting does not support private addressess at this time. + * @return null + */ + public SortedSet getPrivateAddresses() { + return null; + } + + /** + * Default port is always 22. + * @return 22 + */ + public int getLoginPort() { + return 22; + } + + public LoginType getLoginType() { + return LoginType.SSH; + } + + public Credentials getCredentials() { + return new Credentials("root",rhServerResponse.getNewInstanceRequest().getCreateOptions().getPassword()); + } +} diff --git a/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/servers/RimuHostingServer.java b/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/servers/RimuHostingServer.java index 8be3ac97bc..31493d1a31 100644 --- a/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/servers/RimuHostingServer.java +++ b/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/servers/RimuHostingServer.java @@ -48,7 +48,7 @@ public class RimuHostingServer implements Server { @Override public String getName() { - throw new UnsupportedOperationException(); + return rhServer.getName(); } @Override diff --git a/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/RimuHostingClientLiveTest.java b/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/RimuHostingClientLiveTest.java index 8c5245f47e..99966dbe0c 100644 --- a/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/RimuHostingClientLiveTest.java +++ b/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/RimuHostingClientLiveTest.java @@ -79,7 +79,7 @@ public class RimuHostingClientLiveTest { public void testLifeCycle() { //Get the first image, we dont really care what it is in this test. NewServerResponse serverResponse = connection.createInstance("test.jclouds.org", "lenny", "MIRO1B"); - Server server = serverResponse.getInstance(); + Server server = serverResponse.getServer(); //Now we have the server, lets restart it assertNotNull(server.getId()); ServerInfo serverInfo = connection.restartInstance(server.getId()); diff --git a/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/RimuHostingComputeClient.java b/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/RimuHostingComputeClient.java index e1efaa1a8a..57ca4dbc20 100644 --- a/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/RimuHostingComputeClient.java +++ b/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/RimuHostingComputeClient.java @@ -57,8 +57,8 @@ public class RimuHostingComputeClient { public Long start(String name, String planId, String imageId) { logger.debug(">> instantiating RimuHosting VPS name(%s) plan(%s) image(%s)", name, planId, imageId); NewServerResponse serverRespone = rhClient.createInstance(name, imageId, planId); - logger.debug(">> VPS id(%d) started and running.", serverRespone.getInstance().getId()); - return serverRespone.getInstance().getId(); + logger.debug(">> VPS id(%d) started and running.", serverRespone.getServer().getId()); + return serverRespone.getServer().getId(); }