Implemented the CreateServerResponse for RimuHosting

git-svn-id: http://jclouds.googlecode.com/svn/trunk@2393 3d8758e0-26b5-11de-8745-db77d3ebf521
This commit is contained in:
ivan@ivan.net.nz 2009-12-10 08:52:25 +00:00
parent 3c41116782
commit 3e00559d78
7 changed files with 119 additions and 13 deletions

View File

@ -45,4 +45,12 @@ public class IpAddresses {
public void setPrimaryIp(String primaryIp) {
this.primaryIp = primaryIp;
}
public SortedSet<String> getSecondaryIps() {
return secondaryIps;
}
public void setSecondaryIps(SortedSet<String> secondaryIps) {
this.secondaryIps = secondaryIps;
}
}

View File

@ -42,12 +42,12 @@ public class NewServerResponse implements Comparable<NewServerResponse> {
@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<NewServerResponse> {
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());
}
}

View File

@ -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<org.jclouds.compute.Server> listServers() {

View File

@ -0,0 +1,99 @@
/**
*
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
*
* ====================================================================
* 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<InetAddress> getPublicAddresses() {
SortedSet<InetAddress> ipAddresses = new TreeSet<InetAddress>();
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<InetAddress> 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());
}
}

View File

@ -48,7 +48,7 @@ public class RimuHostingServer implements Server {
@Override
public String getName() {
throw new UnsupportedOperationException();
return rhServer.getName();
}
@Override

View File

@ -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());

View File

@ -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();
}