Issue 276: revise gogrid api

This commit is contained in:
Adrian Cole 2010-06-09 12:46:01 -07:00
parent 9b9f9c4e9c
commit d06e8d2678
9 changed files with 282 additions and 150 deletions

View File

@ -28,6 +28,7 @@ import java.util.Map.Entry;
import org.jclouds.util.InputStreamChain;
import org.jclouds.util.Utils;
import com.google.common.collect.Lists;
import com.google.common.collect.Multimap;
/**
@ -42,6 +43,10 @@ public class MultipartForm {
private long size;
public MultipartForm(String boundary, Part... parts) {
this(boundary, Lists.newArrayList(parts));
}
public MultipartForm(String boundary, Iterable<? extends Part> parts) {
String boundaryrn = boundary + rn;
chain = new InputStreamChain();
for (Part part : parts) {

View File

@ -39,6 +39,7 @@ import java.util.Set;
import java.util.SortedSet;
import java.util.Map.Entry;
import javax.annotation.Nullable;
import javax.annotation.Resource;
import javax.inject.Named;
import javax.inject.Provider;
@ -60,6 +61,8 @@ import org.jclouds.http.HttpRequest;
import org.jclouds.http.HttpRequestFilter;
import org.jclouds.http.HttpResponse;
import org.jclouds.http.HttpUtils;
import org.jclouds.http.MultipartForm;
import org.jclouds.http.MultipartForm.Part;
import org.jclouds.http.functions.CloseContentAndReturn;
import org.jclouds.http.functions.ParseSax;
import org.jclouds.http.functions.ParseURIFromListOrLocationHeaderIf20x;
@ -86,6 +89,7 @@ import org.jclouds.rest.annotations.MapPayloadParam;
import org.jclouds.rest.annotations.MatrixParams;
import org.jclouds.rest.annotations.OverrideRequestFilters;
import org.jclouds.rest.annotations.ParamParser;
import org.jclouds.rest.annotations.PartParam;
import org.jclouds.rest.annotations.QueryParams;
import org.jclouds.rest.annotations.RequestFilters;
import org.jclouds.rest.annotations.ResponseParser;
@ -98,6 +102,8 @@ import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Function;
import com.google.common.base.Predicate;
import com.google.common.collect.Collections2;
import com.google.common.collect.ImmutableMultimap;
import com.google.common.collect.Iterables;
import com.google.common.collect.LinkedHashMultimap;
import com.google.common.collect.LinkedListMultimap;
import com.google.common.collect.Lists;
@ -110,7 +116,6 @@ import com.google.inject.Inject;
import com.google.inject.Injector;
import com.google.inject.Key;
import com.google.inject.TypeLiteral;
import com.google.inject.internal.Nullable;
/**
* Creates http methods based on annotations on a class or interface.
@ -142,6 +147,7 @@ public class RestAnnotationProcessor<T> {
private final Map<Method, Map<Integer, Set<Annotation>>> methodToIndexOfParamToQueryParamAnnotations = createMethodToIndexOfParamToAnnotation(QueryParam.class);
private final Map<Method, Map<Integer, Set<Annotation>>> methodToIndexOfParamToPathParamAnnotations = createMethodToIndexOfParamToAnnotation(PathParam.class);
private final Map<Method, Map<Integer, Set<Annotation>>> methodToIndexOfParamToPostParamAnnotations = createMethodToIndexOfParamToAnnotation(MapPayloadParam.class);
private final Map<Method, Map<Integer, Set<Annotation>>> methodToIndexOfParamToPartParamAnnotations = createMethodToIndexOfParamToAnnotation(PartParam.class);
private final Map<Method, Map<Integer, Set<Annotation>>> methodToIndexOfParamToParamParserAnnotations = createMethodToIndexOfParamToAnnotation(ParamParser.class);
private final Map<MethodKey, Method> delegationMap = Maps.newHashMap();
@ -185,6 +191,16 @@ public class RestAnnotationProcessor<T> {
private static final Class<? extends HttpRequestOptions[]> optionsVarArgsClass = new HttpRequestOptions[] {}
.getClass();
private static final Function<? super Entry<String, String>, ? extends Part> ENTRY_TO_PART = new Function<Entry<String, String>, Part>() {
@Override
public Part apply(Entry<String, String> from) {
return new Part(ImmutableMultimap.of("Content-Disposition", String.format(
"form-data; name=\"%s\"", from.getKey())), from.getValue());
}
};
private final Map<Method, Set<Integer>> methodToIndexesOfOptions = new MapMaker()
.makeComputingMap(new Function<Method, Set<Integer>>() {
public Set<Integer> apply(final Method method) {
@ -270,6 +286,7 @@ public class RestAnnotationProcessor<T> {
methodToIndexOfParamToPathParamAnnotations.get(method).get(index);
methodToIndexOfParamToPostParamAnnotations.get(method).get(index);
methodToIndexOfParamToParamParserAnnotations.get(method).get(index);
methodToIndexOfParamToPartParamAnnotations.get(method).get(index);
methodToIndexesOfOptions.get(method);
}
delegationMap.put(new MethodKey(method), method);
@ -401,7 +418,22 @@ public class RestAnnotationProcessor<T> {
addHostHeaderIfAnnotatedWithVirtualHost(headers, request.getEndpoint().getHost(), method);
addFiltersIfAnnotated(method, request);
if (formParams.size() > 0) {
List<? extends Part> parts = getParts(method, args);
if (parts.size() > 0) {
if (formParams.size() > 0) {
parts = Lists.newLinkedList(Iterables.concat(Iterables
.<Entry<String, String>, Part> transform(formParams.entries(), ENTRY_TO_PART),
parts));
}
MultipartForm form = new MultipartForm(BOUNDARY, parts);
request.setPayload(form.getData());
request.getHeaders().put(HttpHeaders.CONTENT_TYPE,
"multipart/form-data; boundary=" + BOUNDARY);
request.getHeaders().put(HttpHeaders.CONTENT_LENGTH, form.getSize() + "");
} else if (formParams.size() > 0) {
if (headers.get(HttpHeaders.CONTENT_TYPE) != null)
headers.put(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_FORM_URLENCODED);
request.setPayload(makeQueryLine(formParams, null, skips));
@ -419,6 +451,8 @@ public class RestAnnotationProcessor<T> {
return request;
}
public static final String BOUNDARY = "--JCLOUDS--";
private String getPath(Class<?> clazz, Method method, Object[] args) {
UriBuilder builder = uriBuilderProvider.get();
if (clazz.isAnnotationPresent(Path.class))
@ -972,6 +1006,20 @@ public class RestAnnotationProcessor<T> {
return out;
}
List<? extends Part> getParts(Method method, Object... args) {
List<Part> parts = Lists.newLinkedList();
Map<Integer, Set<Annotation>> indexToPartParam = methodToIndexOfParamToPartParamAnnotations
.get(method);
for (Entry<Integer, Set<Annotation>> entry : indexToPartParam.entrySet()) {
for (Annotation key : entry.getValue()) {
PartParam extractor = (PartParam) key;
Part part = injector.getInstance(extractor.value()).apply(args[entry.getKey()]);
parts.add(part);
}
}
return parts;
}
private Multimap<String, String> getPathParamKeyValues(Method method, Object... args) {
Multimap<String, String> pathParamValues = LinkedHashMultimap.create();
pathParamValues.putAll(constants);

View File

@ -18,7 +18,17 @@
*/
package org.jclouds.gogrid.services;
import com.google.common.util.concurrent.ListenableFuture;
import static org.jclouds.gogrid.reference.GoGridHeaders.VERSION;
import static org.jclouds.gogrid.reference.GoGridQueryParams.ID_KEY;
import static org.jclouds.gogrid.reference.GoGridQueryParams.NAME_KEY;
import java.util.List;
import java.util.Set;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.QueryParam;
import org.jclouds.gogrid.GoGrid;
import org.jclouds.gogrid.binders.BindIdsToQueryParams;
import org.jclouds.gogrid.binders.BindNamesToQueryParams;
@ -30,19 +40,13 @@ import org.jclouds.gogrid.filters.SharedKeyLiteAuthentication;
import org.jclouds.gogrid.functions.ParseLoadBalancerFromJsonResponse;
import org.jclouds.gogrid.functions.ParseLoadBalancerListFromJsonResponse;
import org.jclouds.gogrid.options.AddLoadBalancerOptions;
import org.jclouds.rest.annotations.*;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.QueryParam;
import java.util.List;
import java.util.Set;
import static org.jclouds.gogrid.reference.GoGridHeaders.VERSION;
import static org.jclouds.gogrid.reference.GoGridQueryParams.ID_KEY;
import static org.jclouds.gogrid.reference.GoGridQueryParams.NAME_KEY;
import static org.jclouds.gogrid.reference.GoGridQueryParams.LOAD_BALANCER_KEY;
import org.jclouds.rest.annotations.BinderParam;
import org.jclouds.rest.annotations.Endpoint;
import org.jclouds.rest.annotations.QueryParams;
import org.jclouds.rest.annotations.RequestFilters;
import org.jclouds.rest.annotations.ResponseParser;
import com.google.common.util.concurrent.ListenableFuture;
/**
* @author Oleksiy Yarmula
@ -52,63 +56,74 @@ import static org.jclouds.gogrid.reference.GoGridQueryParams.LOAD_BALANCER_KEY;
@QueryParams(keys = VERSION, values = "1.4")
public interface GridLoadBalancerAsyncClient {
/**
* @see GridJobClient#getJobList(org.jclouds.gogrid.options.GetJobListOptions...)
*/
@GET
@ResponseParser(ParseLoadBalancerListFromJsonResponse.class)
@Path("/grid/loadbalancer/list")
ListenableFuture<Set<LoadBalancer>> getLoadBalancerList();
/**
* @see GridJobClient#getJobList(org.jclouds.gogrid.options.GetJobListOptions...)
*/
@GET
@ResponseParser(ParseLoadBalancerListFromJsonResponse.class)
@Path("/grid/loadbalancer/list")
ListenableFuture<Set<LoadBalancer>> getLoadBalancerList();
/**
/**
* @see GridLoadBalancerClient#getLoadBalancersByName
*/
@GET
@ResponseParser(ParseLoadBalancerListFromJsonResponse.class)
@Path("/grid/loadbalancer/get")
ListenableFuture<Set<LoadBalancer>> getLoadBalancersByName(@BinderParam(BindNamesToQueryParams.class) String... names);
@GET
@ResponseParser(ParseLoadBalancerListFromJsonResponse.class)
@Path("/grid/loadbalancer/get")
ListenableFuture<Set<LoadBalancer>> getLoadBalancersByName(
@BinderParam(BindNamesToQueryParams.class) String... names);
/**
/**
* @see GridLoadBalancerClient#getLoadBalancersById
*/
@GET
@ResponseParser(ParseLoadBalancerListFromJsonResponse.class)
@Path("/grid/loadbalancer/get")
ListenableFuture<Set<LoadBalancer>> getLoadBalancersById(@BinderParam(BindIdsToQueryParams.class) Long... ids);
@GET
@ResponseParser(ParseLoadBalancerListFromJsonResponse.class)
@Path("/grid/loadbalancer/get")
ListenableFuture<Set<LoadBalancer>> getLoadBalancersById(
@BinderParam(BindIdsToQueryParams.class) Long... ids);
/**
* @see GridLoadBalancerClient#addLoadBalancer
*/
@GET
@ResponseParser(ParseLoadBalancerFromJsonResponse.class)
@Path("/grid/loadbalancer/add")
ListenableFuture<LoadBalancer> addLoadBalancer(@QueryParam(NAME_KEY) String name,
@BinderParam(BindVirtualIpPortPairToQueryParams.class) IpPortPair virtualIp,
@BinderParam(BindRealIpPortPairsToQueryParams.class) List<IpPortPair> realIps,
AddLoadBalancerOptions... options);
/**
* @see GridLoadBalancerClient#addLoadBalancer
*/
@GET
@ResponseParser(ParseLoadBalancerFromJsonResponse.class)
@Path("/grid/loadbalancer/add")
ListenableFuture<LoadBalancer> addLoadBalancer(@QueryParam(NAME_KEY) String name,
@BinderParam(BindVirtualIpPortPairToQueryParams.class) IpPortPair virtualIp,
@BinderParam(BindRealIpPortPairsToQueryParams.class) List<IpPortPair> realIps,
AddLoadBalancerOptions... options);
/**
* @see GridLoadBalancerClient#editLoadBalancer
*/
@GET
@ResponseParser(ParseLoadBalancerFromJsonResponse.class)
@Path("/grid/loadbalancer/edit")
ListenableFuture<LoadBalancer> editLoadBalancer(@QueryParam(LOAD_BALANCER_KEY) String idOrName,
@BinderParam(BindRealIpPortPairsToQueryParams.class) List<IpPortPair> realIps);
/**
* @see GridLoadBalancerClient#editLoadBalancerNamed
*/
@GET
@ResponseParser(ParseLoadBalancerFromJsonResponse.class)
@Path("/grid/loadbalancer/edit")
ListenableFuture<LoadBalancer> editLoadBalancerNamed(@QueryParam(NAME_KEY) String name,
@BinderParam(BindRealIpPortPairsToQueryParams.class) List<IpPortPair> realIps);
/**
/**
* @see GridLoadBalancerClient#editLoadBalancer
*/
@GET
@ResponseParser(ParseLoadBalancerFromJsonResponse.class)
@Path("/grid/loadbalancer/edit")
ListenableFuture<LoadBalancer> editLoadBalancer(@QueryParam(ID_KEY) long id,
@BinderParam(BindRealIpPortPairsToQueryParams.class) List<IpPortPair> realIps);
/**
* @see GridLoadBalancerClient#
*/
@GET
@ResponseParser(ParseLoadBalancerFromJsonResponse.class)
@Path("/grid/loadbalancer/delete")
ListenableFuture<LoadBalancer> deleteById(@QueryParam(ID_KEY) Long id);
@GET
@ResponseParser(ParseLoadBalancerFromJsonResponse.class)
@Path("/grid/loadbalancer/delete")
ListenableFuture<LoadBalancer> deleteById(@QueryParam(ID_KEY) Long id);
/**
/**
* @see GridLoadBalancerClient#
*/
@GET
@ResponseParser(ParseLoadBalancerFromJsonResponse.class)
@Path("/grid/loadbalancer/delete")
ListenableFuture<LoadBalancer> deleteByName(@QueryParam(NAME_KEY) String name);
@GET
@ResponseParser(ParseLoadBalancerFromJsonResponse.class)
@Path("/grid/loadbalancer/delete")
ListenableFuture<LoadBalancer> deleteByName(@QueryParam(NAME_KEY) String name);
}

View File

@ -18,101 +18,112 @@
*/
package org.jclouds.gogrid.services;
import java.util.List;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import org.jclouds.concurrent.Timeout;
import org.jclouds.gogrid.domain.IpPortPair;
import org.jclouds.gogrid.domain.LoadBalancer;
import org.jclouds.gogrid.options.AddLoadBalancerOptions;
import java.util.List;
import java.util.Set;
import java.util.concurrent.TimeUnit;
/**
* @author Oleksiy Yarmula
*/
@Timeout(duration = 30, timeUnit = TimeUnit.SECONDS)
public interface GridLoadBalancerClient {
/**
* Returns all load balancers found for the current user.
* @return load balancers found
*/
Set<LoadBalancer> getLoadBalancerList();
/**
* Returns all load balancers found for the current user.
*
* @return load balancers found
*/
Set<LoadBalancer> getLoadBalancerList();
/**
* Returns the load balancer(s) by unique name(s).
*
* Given a name or a set of names, finds one or
* multiple load balancers.
* @param names to get the load balancers
* @return load balancer(s) matching the name(s)
*/
Set<LoadBalancer> getLoadBalancersByName(String... names);
/**
* Returns the load balancer(s) by unique name(s).
*
* Given a name or a set of names, finds one or multiple load balancers.
*
* @param names
* to get the load balancers
* @return load balancer(s) matching the name(s)
*/
Set<LoadBalancer> getLoadBalancersByName(String... names);
/**
* Returns the load balancer(s) by unique id(s).
*
* Given an id or a set of ids, finds one or
* multiple load balancers.
* @param ids to get the load balancers
* @return load balancer(s) matching the ids
*/
Set<LoadBalancer> getLoadBalancersById(Long... ids);
/**
* Returns the load balancer(s) by unique id(s).
*
* Given an id or a set of ids, finds one or multiple load balancers.
*
* @param ids
* to get the load balancers
* @return load balancer(s) matching the ids
*/
Set<LoadBalancer> getLoadBalancersById(Long... ids);
/**
* Creates a load balancer with given properties.
*
* @param name name of the load balancer
* @param virtualIp virtual IP with IP address set in
* {@link org.jclouds.gogrid.domain.Ip#ip} and
* port set in {@link IpPortPair#port}
* @param realIps real IPs to bind the virtual IP to, with
* IP address set in
* {@link org.jclouds.gogrid.domain.Ip#ip} and
* port set in {@link IpPortPair#port}
* @param options options that specify load balancer's type (round robin,
* least load), persistence strategy, or description.
* @return created load balancer object
*/
LoadBalancer addLoadBalancer(String name,
IpPortPair virtualIp,
List<IpPortPair> realIps,
AddLoadBalancerOptions... options);
/**
* Creates a load balancer with given properties.
*
* @param name
* name of the load balancer
* @param virtualIp
* virtual IP with IP address set in {@link org.jclouds.gogrid.domain.Ip#ip} and port
* set in {@link IpPortPair#port}
* @param realIps
* real IPs to bind the virtual IP to, with IP address set in
* {@link org.jclouds.gogrid.domain.Ip#ip} and port set in {@link IpPortPair#port}
* @param options
* options that specify load balancer's type (round robin, least load), persistence
* strategy, or description.
* @return created load balancer object
*/
LoadBalancer addLoadBalancer(String name, IpPortPair virtualIp, List<IpPortPair> realIps,
AddLoadBalancerOptions... options);
/**
* Edits the existing load balancer to change the real
* IP mapping.
*
* @param idOrName id or name of the existing load balancer
* @param realIps real IPs to bind the virtual IP to, with
* IP address set in
* {@link org.jclouds.gogrid.domain.Ip#ip} and
* port set in {@link IpPortPair#port}
* @return edited object
*/
LoadBalancer editLoadBalancer(String idOrName,
List<IpPortPair> realIps);
/**
* Edits the existing load balancer to change the real IP mapping.
*
* @param id
* id of the existing load balancer
* @param realIps
* real IPs to bind the virtual IP to, with IP address set in
* {@link org.jclouds.gogrid.domain.Ip#ip} and port set in {@link IpPortPair#port}
* @return edited object
*/
LoadBalancer editLoadBalancer(long id, List<IpPortPair> realIps);
/**
* Deletes the load balancer by Id
*
* @param id
* id of the load balancer to delete
* @return load balancer before the command is executed
*/
LoadBalancer deleteById(Long id);
/**
* Edits the existing load balancer to change the real IP mapping.
*
* @param name
* name of the existing load balancer
* @param realIps
* real IPs to bind the virtual IP to, with IP address set in
* {@link org.jclouds.gogrid.domain.Ip#ip} and port set in {@link IpPortPair#port}
* @return edited object
*/
LoadBalancer editLoadBalancerNamed(String name, List<IpPortPair> realIps);
/**
* Deletes the load balancer by name;
*
* NOTE: Using this parameter may generate an
* error if one or more load balancers share a
* non-unique name.
*
* @param name
* name of the load balancer to be deleted
*
* @return load balancer before the command is executed
*/
LoadBalancer deleteByName(String name);
/**
* Deletes the load balancer by Id
*
* @param id
* id of the load balancer to delete
* @return load balancer before the command is executed
*/
LoadBalancer deleteById(Long id);
/**
* Deletes the load balancer by name;
*
* NOTE: Using this parameter may generate an error if one or more load balancers share a
* non-unique name.
*
* @param name
* name of the load balancer to be deleted
*
* @return load balancer before the command is executed
*/
LoadBalancer deleteByName(String name);
}

View File

@ -265,7 +265,7 @@ public class GoGridLiveTest {
assertNotNull(createdLoadBalancer.getVirtualIp());
assertEquals(createdLoadBalancer.getVirtualIp().getIp().getIp(), vip.getIp());
LoadBalancer editedLoadBalancer = client.getLoadBalancerServices().editLoadBalancer(
LoadBalancer editedLoadBalancer = client.getLoadBalancerServices().editLoadBalancerNamed(
nameOfLoadBalancer, Arrays.asList(new IpPortPair(realIp3, 8181)));
assert loadBalancerLatestJobCompleted.apply(editedLoadBalancer);
assertNotNull(editedLoadBalancer.getRealIpList());

View File

@ -46,7 +46,6 @@ import org.jclouds.logging.Logger;
import org.jclouds.rest.RestClientTest;
import org.jclouds.rest.internal.GeneratedHttpRequest;
import org.jclouds.rest.internal.RestAnnotationProcessor;
import com.google.inject.name.Names;
import org.testng.annotations.Test;
import com.google.common.collect.Iterables;
@ -54,6 +53,7 @@ import com.google.inject.AbstractModule;
import com.google.inject.Module;
import com.google.inject.Provides;
import com.google.inject.TypeLiteral;
import com.google.inject.name.Names;
/**
* @author Oleksiy Yarmula
@ -123,14 +123,42 @@ public class GridLoadBalancerAsyncClientTest extends RestClientTest<GridLoadBala
@Test
public void testEditLoadBalancer() throws NoSuchMethodException, IOException {
Method method = GridLoadBalancerAsyncClient.class.getMethod("editLoadBalancer", String.class,
Method method = GridLoadBalancerAsyncClient.class.getMethod("editLoadBalancer", long.class,
List.class);
GeneratedHttpRequest<GridLoadBalancerAsyncClient> httpRequest = processor.createRequest(
method, 1l, Arrays.asList(new IpPortPair(new Ip("127.0.0.1"), 8080), new IpPortPair(
new Ip("127.0.0.1"), 9090)));
assertRequestLineEquals(
httpRequest,
"GET https://api.gogrid.com/api/grid/loadbalancer/edit?v=1.4&id=1&realiplist.0.ip=127.0.0.1&realiplist.0.port=8080&realiplist.1.ip=127.0.0.1&realiplist.1.port=9090 HTTP/1.1");
assertHeadersEqual(httpRequest, "");
assertPayloadEquals(httpRequest, null);
assertResponseParserClassEquals(method, httpRequest, ParseLoadBalancerFromJsonResponse.class);
assertSaxResponseParserClassEquals(method, null);
assertExceptionParserClassEquals(method, null);
checkFilters(httpRequest);
Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
assertRequestLineEquals(
httpRequest,
"GET https://api.gogrid.com/api/grid/loadbalancer/edit?v=1.4&id=1&realiplist.0.ip=127.0.0.1&realiplist.0.port=8080&realiplist.1.ip=127.0.0.1&realiplist.1.port=9090&sig=3f446f171455fbb5574aecff4997b273&api_key=foo HTTP/1.1");
assertHeadersEqual(httpRequest, "");
assertPayloadEquals(httpRequest, null);
}
@Test
public void testEditLoadBalancerNamed() throws NoSuchMethodException, IOException {
Method method = GridLoadBalancerAsyncClient.class.getMethod("editLoadBalancerNamed",
String.class, List.class);
GeneratedHttpRequest<GridLoadBalancerAsyncClient> httpRequest = processor.createRequest(
method, "BalanceIt", Arrays.asList(new IpPortPair(new Ip("127.0.0.1"), 8080),
new IpPortPair(new Ip("127.0.0.1"), 9090)));
assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/loadbalancer/"
+ "edit?v=1.4&loadbalancer=BalanceIt&realiplist.0.ip=127.0.0.1&"
+ "edit?v=1.4&name=BalanceIt&realiplist.0.ip=127.0.0.1&"
+ "realiplist.0.port=8080&realiplist.1.ip=127.0.0.1&realiplist.1.port=9090 HTTP/1.1");
assertHeadersEqual(httpRequest, "");
assertPayloadEquals(httpRequest, null);
@ -142,10 +170,9 @@ public class GridLoadBalancerAsyncClientTest extends RestClientTest<GridLoadBala
checkFilters(httpRequest);
Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/loadbalancer/"
+ "edit?v=1.4&loadbalancer=BalanceIt&realiplist.0.ip=127.0.0.1&"
+ "realiplist.0.port=8080&realiplist.1.ip=127.0.0.1&realiplist.1.port=9090&"
+ "sig=3f446f171455fbb5574aecff4997b273&api_key=foo " + "HTTP/1.1");
assertRequestLineEquals(
httpRequest,
"GET https://api.gogrid.com/api/grid/loadbalancer/edit?v=1.4&name=BalanceIt&realiplist.0.ip=127.0.0.1&realiplist.0.port=8080&realiplist.1.ip=127.0.0.1&realiplist.1.port=9090&sig=3f446f171455fbb5574aecff4997b273&api_key=foo HTTP/1.1");
assertHeadersEqual(httpRequest, "");
assertPayloadEquals(httpRequest, null);
}

View File

@ -446,10 +446,25 @@ public class IBMDeveloperCloudComputeServiceContextModule extends IBMDeveloperCl
(in.getPlatform().indexOf("Redhat") != -1) ? OsFamily.RHEL : OsFamily.SUSE, in
.getPlatform(),
(in.getPlatform().indexOf("32") != -1) ? Architecture.X86_32
: Architecture.X86_64, new Credentials("root", null));
: Architecture.X86_64, new Credentials("idcuser", null));
this.rawImage = in;
}
@Override
public boolean equals(Object obj) {
return rawImage.equals(obj);
}
@Override
public int hashCode() {
return rawImage.hashCode();
}
@Override
public String toString() {
return rawImage.toString();
}
}
@Singleton

View File

@ -100,7 +100,7 @@ public class IBMDeveloperCloudRestClientModule extends
@Singleton
@Named("ACTIVE")
protected Predicate<Instance> instanceActive(InstanceActive instanceActive) {
return new RetryablePredicate<Instance>(instanceActive, 600, 1, TimeUnit.SECONDS);
return new RetryablePredicate<Instance>(instanceActive, 1200, 3, TimeUnit.SECONDS);
}
@Provides

View File

@ -25,6 +25,8 @@ import org.jclouds.ibmdev.IBMDeveloperCloudClient;
import org.jclouds.compute.BaseComputeServiceLiveTest;
import org.jclouds.compute.ComputeServiceContextFactory;
import org.jclouds.compute.domain.Architecture;
import org.jclouds.compute.domain.ComputeMetadata;
import org.jclouds.compute.domain.ComputeType;
import org.jclouds.compute.domain.OsFamily;
import org.jclouds.compute.domain.Template;
import org.jclouds.rest.RestContext;
@ -52,6 +54,15 @@ public class IBMDeveloperCloudComputeServiceLiveTest extends BaseComputeServiceL
assertEquals(defaultTemplate.getLocation().getId(), "1");
assertEquals(defaultTemplate.getSize().getCores(), 2.0d);
}
@Override
public void testListNodes() throws Exception {
for (ComputeMetadata node : client.listNodes()) {
assert node.getProviderId() != null;
// assert node.getLocation() != null;
assertEquals(node.getType(), ComputeType.NODE);
}
}
@Override
protected JschSshClientModule getSshModule() {