mirror of https://github.com/apache/jclouds.git
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:
parent
3c41116782
commit
3e00559d78
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
}
|
|
@ -48,7 +48,7 @@ public class RimuHostingServer implements Server {
|
|||
|
||||
@Override
|
||||
public String getName() {
|
||||
throw new UnsupportedOperationException();
|
||||
return rhServer.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue