diff --git a/apis/cloudloadbalancers/pom.xml b/apis/cloudloadbalancers/pom.xml
index 54b3ab291d..24d608e73d 100644
--- a/apis/cloudloadbalancers/pom.xml
+++ b/apis/cloudloadbalancers/pom.xml
@@ -34,9 +34,9 @@
bundle
- https://auth.api.rackspacecloud.com
- 1.0
-
+ https://identity.api.rackspacecloud.com/v2.0/
+ 1
+
${test.rackspace.identity}
${test.rackspace.credential}
@@ -50,8 +50,13 @@
${project.version}
- org.jclouds.common
- openstack-common
+ org.jclouds.api
+ openstack-keystone
+ ${project.version}
+
+
+ org.jclouds.api
+ rackspace-cloudidentity
${project.version}
@@ -69,18 +74,31 @@
test
- org.jclouds.common
- openstack-common
+ org.jclouds.api
+ openstack-keystone
+ ${project.version}
+ test-jar
+ test
+
+
+ org.jclouds.api
+ rackspace-cloudidentity
${project.version}
test-jar
test
org.jclouds.driver
- jclouds-log4j
+ jclouds-slf4j
${project.version}
test
+
+ ch.qos.logback
+ logback-classic
+ 1.0.7
+ test
+
@@ -104,6 +122,7 @@
${test.cloudloadbalancers.build-version}
${test.cloudloadbalancers.identity}
${test.cloudloadbalancers.credential}
+ ${test.jclouds.keystone.credential-type}
diff --git a/apis/cloudloadbalancers/src/main/java/org/jclouds/cloudloadbalancers/CloudLoadBalancersApiMetadata.java b/apis/cloudloadbalancers/src/main/java/org/jclouds/cloudloadbalancers/CloudLoadBalancersApiMetadata.java
index e59e3b9808..35a109f0f1 100644
--- a/apis/cloudloadbalancers/src/main/java/org/jclouds/cloudloadbalancers/CloudLoadBalancersApiMetadata.java
+++ b/apis/cloudloadbalancers/src/main/java/org/jclouds/cloudloadbalancers/CloudLoadBalancersApiMetadata.java
@@ -18,6 +18,9 @@
*/
package org.jclouds.cloudloadbalancers;
+import static org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties.CREDENTIAL_TYPE;
+import static org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties.SERVICE_TYPE;
+
import java.net.URI;
import java.util.Properties;
@@ -25,6 +28,10 @@ import org.jclouds.apis.ApiMetadata;
import org.jclouds.cloudloadbalancers.config.CloudLoadBalancersRestClientModule;
import org.jclouds.cloudloadbalancers.loadbalancer.config.CloudLoadBalancersLoadBalancerContextModule;
import org.jclouds.loadbalancer.LoadBalancerServiceContext;
+import org.jclouds.openstack.keystone.v2_0.config.KeystoneAuthenticationModule.ZoneModule;
+import org.jclouds.rackspace.cloudidentity.v2_0.ServiceType;
+import org.jclouds.rackspace.cloudidentity.v2_0.config.CloudIdentityAuthenticationModule;
+import org.jclouds.rackspace.cloudidentity.v2_0.config.CloudIdentityCredentialTypes;
import org.jclouds.rest.RestContext;
import org.jclouds.rest.internal.BaseRestApiMetadata;
@@ -37,14 +44,10 @@ import com.google.inject.Module;
*
* @author Adrian Cole
*/
-public class CloudLoadBalancersApiMetadata extends BaseRestApiMetadata {
-
- /** The serialVersionUID */
- private static final long serialVersionUID = 6725672099385580694L;
+public class CloudLoadBalancersApiMetadata extends BaseRestApiMetadata {
- public static final TypeToken> CONTEXT_TOKEN = new TypeToken>() {
- private static final long serialVersionUID = -5070937833892503232L;
- };
+ public static final TypeToken> CONTEXT_TOKEN =
+ new TypeToken>() {};
@Override
@@ -62,6 +65,10 @@ public class CloudLoadBalancersApiMetadata extends BaseRestApiMetadata {
public static Properties defaultProperties() {
Properties properties = BaseRestApiMetadata.defaultProperties();
+
+ properties.setProperty(SERVICE_TYPE, ServiceType.LOAD_BALANCERS);
+ properties.setProperty(CREDENTIAL_TYPE, CloudIdentityCredentialTypes.API_KEY_CREDENTIALS);
+
return properties;
}
@@ -70,15 +77,21 @@ public class CloudLoadBalancersApiMetadata extends BaseRestApiMetadata {
protected Builder() {
super(CloudLoadBalancersClient.class, CloudLoadBalancersAsyncClient.class);
id("cloudloadbalancers")
- .name("Rackspace Cloud Load Balancers API")
- .identityName("Username")
- .credentialName("API Key")
- .documentation(URI.create("http://docs.rackspacecloud.com/loadbalancers/api/v1.0/clb-devguide/content/ch01.html"))
- .version("1.0")
- .defaultEndpoint("https://auth.api.rackspacecloud.com")
- .defaultProperties(CloudLoadBalancersApiMetadata.defaultProperties())
- .view(TypeToken.of(LoadBalancerServiceContext.class))
- .defaultModules(ImmutableSet.>of(CloudLoadBalancersRestClientModule.class, CloudLoadBalancersLoadBalancerContextModule.class));
+ .name("Rackspace Cloud Load Balancers API")
+ .identityName("Username")
+ .credentialName("API Key")
+ .documentation(
+ URI.create("http://docs.rackspace.com/loadbalancers/api/clb-devguide-latest/index.html"))
+ .version("1.0")
+ .defaultEndpoint("https://identity.api.rackspacecloud.com/v2.0/")
+ .defaultProperties(CloudLoadBalancersApiMetadata.defaultProperties())
+ .view(TypeToken.of(LoadBalancerServiceContext.class))
+ .defaultModules(
+ ImmutableSet.> of(
+ CloudIdentityAuthenticationModule.class,
+ ZoneModule.class,
+ CloudLoadBalancersRestClientModule.class,
+ CloudLoadBalancersLoadBalancerContextModule.class));
}
@Override
@@ -94,4 +107,4 @@ public class CloudLoadBalancersApiMetadata extends BaseRestApiMetadata {
}
-}
\ No newline at end of file
+}
diff --git a/apis/cloudloadbalancers/src/main/java/org/jclouds/cloudloadbalancers/CloudLoadBalancersAsyncClient.java b/apis/cloudloadbalancers/src/main/java/org/jclouds/cloudloadbalancers/CloudLoadBalancersAsyncClient.java
index c2b8dfbceb..ee14b99377 100644
--- a/apis/cloudloadbalancers/src/main/java/org/jclouds/cloudloadbalancers/CloudLoadBalancersAsyncClient.java
+++ b/apis/cloudloadbalancers/src/main/java/org/jclouds/cloudloadbalancers/CloudLoadBalancersAsyncClient.java
@@ -22,8 +22,9 @@ import java.util.Set;
import org.jclouds.cloudloadbalancers.features.LoadBalancerAsyncClient;
import org.jclouds.cloudloadbalancers.features.NodeAsyncClient;
-import org.jclouds.location.Region;
-import org.jclouds.location.functions.RegionToEndpointOrProviderIfNull;
+import org.jclouds.javax.annotation.Nullable;
+import org.jclouds.location.Zone;
+import org.jclouds.location.functions.ZoneToEndpoint;
import org.jclouds.rest.annotations.Delegate;
import org.jclouds.rest.annotations.EndpointParam;
@@ -34,33 +35,28 @@ import com.google.inject.Provides;
*
*
* @see CloudLoadBalancersClient
- * @see
* @author Adrian Cole
*/
public interface CloudLoadBalancersAsyncClient {
-
/**
- *
- * @return the region codes configured
+ * @return the Zone codes configured
*/
@Provides
- @Region
- Set getConfiguredRegions();
+ @Zone
+ Set getConfiguredZones();
/**
* Provides asynchronous access to LoadBalancer features.
*/
@Delegate
LoadBalancerAsyncClient getLoadBalancerClient(
- @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) String region);
+ @EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
/**
* Provides asynchronous access to Node features.
*/
@Delegate
NodeAsyncClient getNodeClient(
- @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) String region);
+ @EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
}
diff --git a/apis/cloudloadbalancers/src/main/java/org/jclouds/cloudloadbalancers/CloudLoadBalancersClient.java b/apis/cloudloadbalancers/src/main/java/org/jclouds/cloudloadbalancers/CloudLoadBalancersClient.java
index 4d879a153b..c8f9f339f5 100644
--- a/apis/cloudloadbalancers/src/main/java/org/jclouds/cloudloadbalancers/CloudLoadBalancersClient.java
+++ b/apis/cloudloadbalancers/src/main/java/org/jclouds/cloudloadbalancers/CloudLoadBalancersClient.java
@@ -24,8 +24,9 @@ import java.util.concurrent.TimeUnit;
import org.jclouds.cloudloadbalancers.features.LoadBalancerClient;
import org.jclouds.cloudloadbalancers.features.NodeClient;
import org.jclouds.concurrent.Timeout;
-import org.jclouds.location.Region;
-import org.jclouds.location.functions.RegionToEndpointOrProviderIfNull;
+import org.jclouds.javax.annotation.Nullable;
+import org.jclouds.location.Zone;
+import org.jclouds.location.functions.ZoneToEndpoint;
import org.jclouds.rest.annotations.Delegate;
import org.jclouds.rest.annotations.EndpointParam;
@@ -36,33 +37,29 @@ import com.google.inject.Provides;
*
*
* @see CloudLoadBalancersAsyncClient
- * @see
* @author Adrian Cole
*/
@Timeout(duration = 60, timeUnit = TimeUnit.SECONDS)
public interface CloudLoadBalancersClient {
/**
- *
- * @return the region codes configured
+ * @return the Zone codes configured
*/
@Provides
- @Region
- Set getConfiguredRegions();
+ @Zone
+ Set getConfiguredZones();
/**
* Provides synchronous access to LoadBalancer features.
*/
@Delegate
LoadBalancerClient getLoadBalancerClient(
- @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) String region);
+ @EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
/**
* Provides synchronous access to Node features.
*/
@Delegate
NodeClient getNodeClient(
- @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) String region);
+ @EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
}
diff --git a/apis/cloudloadbalancers/src/main/java/org/jclouds/cloudloadbalancers/config/CloudLoadBalancersRestClientModule.java b/apis/cloudloadbalancers/src/main/java/org/jclouds/cloudloadbalancers/config/CloudLoadBalancersRestClientModule.java
index 5ccaf9af5e..37d83f7592 100644
--- a/apis/cloudloadbalancers/src/main/java/org/jclouds/cloudloadbalancers/config/CloudLoadBalancersRestClientModule.java
+++ b/apis/cloudloadbalancers/src/main/java/org/jclouds/cloudloadbalancers/config/CloudLoadBalancersRestClientModule.java
@@ -18,14 +18,8 @@
*/
package org.jclouds.cloudloadbalancers.config;
-import static org.jclouds.util.Suppliers2.getLastValueInMap;
-
-import java.net.URI;
import java.util.Map;
-import javax.inject.Named;
-import javax.inject.Singleton;
-
import org.jclouds.cloudloadbalancers.CloudLoadBalancersAsyncClient;
import org.jclouds.cloudloadbalancers.CloudLoadBalancersClient;
import org.jclouds.cloudloadbalancers.features.LoadBalancerAsyncClient;
@@ -34,28 +28,16 @@ import org.jclouds.cloudloadbalancers.features.NodeAsyncClient;
import org.jclouds.cloudloadbalancers.features.NodeClient;
import org.jclouds.cloudloadbalancers.functions.ConvertLB;
import org.jclouds.cloudloadbalancers.handlers.ParseCloudLoadBalancersErrorFromHttpResponse;
-import org.jclouds.cloudloadbalancers.location.RegionUrisFromPropertiesAndAccountIDPathSuffix;
-import org.jclouds.cloudloadbalancers.reference.RackspaceConstants;
import org.jclouds.http.HttpErrorHandler;
import org.jclouds.http.annotation.ClientError;
import org.jclouds.http.annotation.Redirection;
import org.jclouds.http.annotation.ServerError;
import org.jclouds.json.config.GsonModule.DateAdapter;
import org.jclouds.json.config.GsonModule.Iso8601DateAdapter;
-import org.jclouds.location.config.LocationModule;
-import org.jclouds.location.suppliers.RegionIdToURISupplier;
-import org.jclouds.openstack.keystone.v1_1.config.AuthenticationServiceModule;
import org.jclouds.rest.ConfiguresRestClient;
-import org.jclouds.rest.annotations.ApiVersion;
import org.jclouds.rest.config.RestClientModule;
-import org.jclouds.util.Suppliers2;
-import com.google.common.base.Function;
-import com.google.common.base.Supplier;
import com.google.common.collect.ImmutableMap;
-import com.google.inject.AbstractModule;
-import com.google.inject.Provides;
-import com.google.inject.Scopes;
import com.google.inject.assistedinject.FactoryModuleBuilder;
/**
@@ -67,49 +49,15 @@ import com.google.inject.assistedinject.FactoryModuleBuilder;
public class CloudLoadBalancersRestClientModule extends
RestClientModule {
- public static final Map, Class>> DELEGATE_MAP = ImmutableMap., Class>> builder()//
- .put(LoadBalancerClient.class, LoadBalancerAsyncClient.class)//
- .put(NodeClient.class, NodeAsyncClient.class)//
+ public static final Map, Class>> DELEGATE_MAP = ImmutableMap., Class>> builder()
+ .put(LoadBalancerClient.class, LoadBalancerAsyncClient.class)
+ .put(NodeClient.class, NodeAsyncClient.class)
.build();
public CloudLoadBalancersRestClientModule() {
super(DELEGATE_MAP);
}
- protected void installLocations() {
- install(new LocationModule());
- install(new URIWithAccountIDPathSuffixAuthenticationServiceModule());
- }
-
- public static class URIWithAccountIDPathSuffixAuthenticationServiceModule extends AbstractModule {
-
- @Override
- protected void configure() {
- install(new AuthenticationServiceModule());
- bind(RegionIdToURISupplier.class).to(RegionUrisFromPropertiesAndAccountIDPathSuffix.class)
- .in(Scopes.SINGLETON);
- }
-
- @Provides
- @Singleton
- @Named(RackspaceConstants.PROPERTY_ACCOUNT_ID)
- protected Supplier accountID(RegionIdToURISupplier.Factory factory, @ApiVersion String apiVersion) {
- return Suppliers2.compose(new Function() {
-
- @Override
- public String apply(URI arg0) {
- return arg0.getPath().substring(arg0.getPath().lastIndexOf('/') + 1);
- }
-
- @Override
- public String toString() {
- return "getAccountIdFromCloudServers()";
- }
- }, getLastValueInMap(factory.createForApiTypeAndVersion("cloudServers", apiVersion)));
-
- }
- }
-
@Override
protected void configure() {
bind(DateAdapter.class).to(Iso8601DateAdapter.class);
diff --git a/apis/cloudloadbalancers/src/main/java/org/jclouds/cloudloadbalancers/domain/LoadBalancer.java b/apis/cloudloadbalancers/src/main/java/org/jclouds/cloudloadbalancers/domain/LoadBalancer.java
index 6b045a85aa..bf320f6658 100644
--- a/apis/cloudloadbalancers/src/main/java/org/jclouds/cloudloadbalancers/domain/LoadBalancer.java
+++ b/apis/cloudloadbalancers/src/main/java/org/jclouds/cloudloadbalancers/domain/LoadBalancer.java
@@ -25,16 +25,16 @@ import java.util.Date;
import java.util.Set;
import org.jclouds.cloudloadbalancers.domain.internal.BaseLoadBalancer;
+import org.jclouds.cloudloadbalancers.features.LoadBalancerClient;
import org.jclouds.javax.annotation.Nullable;
+import com.google.common.base.Objects;
+import com.google.common.base.Objects.ToStringHelper;
import com.google.common.collect.ImmutableSet;
/**
*
* @author Adrian Cole
- * @see
*/
public class LoadBalancer extends BaseLoadBalancer {
@@ -61,6 +61,7 @@ public class LoadBalancer extends BaseLoadBalancer {
private Date created;
private Date updated;
private boolean connectionLoggingEnabled;
+ private int nodeCount = 0;
public Builder region(String region) {
this.region = region;
@@ -112,9 +113,17 @@ public class LoadBalancer extends BaseLoadBalancer {
return this;
}
+ /**
+ * @see LoadBalancer#getNodeCount()
+ */
+ public Builder nodeCount(int nodeCount) {
+ this.nodeCount = nodeCount;
+ return this;
+ }
+
public LoadBalancer build() {
return new LoadBalancer(region, id, name, protocol, port, algorithm, status, virtualIPs, nodes,
- sessionPersistenceType, clusterName, created, updated, connectionLoggingEnabled);
+ sessionPersistenceType, clusterName, created, updated, connectionLoggingEnabled, nodeCount);
}
@Override
@@ -138,7 +147,7 @@ public class LoadBalancer extends BaseLoadBalancer {
public Builder from(LoadBalancer in) {
return Builder.class.cast(super.from(in)).id(in.getId()).status(in.getStatus()).virtualIPs(in.getVirtualIPs())
.clusterName(in.getClusterName()).created(in.getCreated()).updated(in.getUpdated())
- .connectionLoggingEnabled(in.isConnectionLoggingEnabled());
+ .connectionLoggingEnabled(in.isConnectionLoggingEnabled()).nodeCount(in.getNodeCount());
}
@Override
@@ -268,10 +277,11 @@ public class LoadBalancer extends BaseLoadBalancer {
private final Date created;
private final Date updated;
private final boolean connectionLoggingEnabled;
+ private int nodeCount = 0;
public LoadBalancer(String region, int id, String name, String protocol, Integer port, @Nullable String algorithm,
Status status, Iterable virtualIPs, Iterable nodes, String sessionPersistenceType,
- String clusterName, Date created, Date updated, boolean connectionLoggingEnabled) {
+ String clusterName, Date created, Date updated, boolean connectionLoggingEnabled, Integer nodeCount) {
super(name, protocol, port, algorithm, nodes);
this.region = checkNotNull(region, "region");
checkArgument(id != -1, "id must be specified");
@@ -284,6 +294,7 @@ public class LoadBalancer extends BaseLoadBalancer {
this.created = checkNotNull(created, "created");
this.updated = checkNotNull(updated, "updated");
this.connectionLoggingEnabled = connectionLoggingEnabled;
+ this.nodeCount = nodeCount;
}
public String getRegion() {
@@ -331,41 +342,42 @@ public class LoadBalancer extends BaseLoadBalancer {
return connectionLoggingEnabled;
}
+ /**
+ * Broken out as a separate field because when LoadBalancers are returned from
+ * {@link LoadBalancerClient#listLoadBalancers()}, no Nodes are returned (so you can't rely on getNodes().size())
+ * but a nodeCount is returned. When {@link LoadBalancerClient#getLoadBalancer(int)} is called, nodes are
+ * returned by no nodeCount is returned.
+ *
+ * @return The number of Nodes in this LoadBalancer
+ */
+ public int getNodeCount() {
+ return nodes.size() > 0 ? nodes.size() : nodeCount;
+ }
+
+ protected ToStringHelper string() {
+ return Objects.toStringHelper(this)
+ .add("id", id).add("region", region).add("name", name).add("protocol", protocol).add("port", port)
+ .add("algorithm", algorithm).add("status", status).add("virtualIPs", virtualIPs).add("nodeCount", getNodeCount())
+ .add("nodes", nodes).add("sessionPersistenceType", sessionPersistenceType).add("created", created)
+ .add("updated", updated).add("clusterName", clusterName).add("connectionLoggingEnabled", connectionLoggingEnabled);
+ }
+
@Override
public String toString() {
- return String
- .format(
- "[region=%s, id=%s, name=%s, protocol=%s, port=%s, algorithm=%s, status=%s, virtualIPs=%s, nodes=%s, sessionPersistenceType=%s, created=%s, updated=%s, clusterName=%s, connectionLoggingEnabled=%s]",
- region, id, name, protocol, port, algorithm, status, virtualIPs, nodes, sessionPersistenceType,
- created, updated, clusterName, connectionLoggingEnabled);
+ return string().toString();
}
@Override
public int hashCode() {
- final int prime = 31;
- int result = super.hashCode();
- result = prime * result + id;
- result = prime * result + ((region == null) ? 0 : region.hashCode());
- return result;
+ return Objects.hashCode(id, region);
}
@Override
public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (!super.equals(obj))
- return false;
- if (getClass() != obj.getClass())
- return false;
- LoadBalancer other = (LoadBalancer) obj;
- if (id != other.id)
- return false;
- if (region == null) {
- if (other.region != null)
- return false;
- } else if (!region.equals(other.region))
- return false;
- return true;
- }
+ if (this == obj) return true;
+ if (obj == null || getClass() != obj.getClass()) return false;
+ LoadBalancer that = LoadBalancer.class.cast(obj);
+ return Objects.equal(this.id, that.id) && Objects.equal(this.region, that.region);
+ }
}
diff --git a/apis/cloudloadbalancers/src/main/java/org/jclouds/cloudloadbalancers/domain/LoadBalancerRequest.java b/apis/cloudloadbalancers/src/main/java/org/jclouds/cloudloadbalancers/domain/LoadBalancerRequest.java
index bd4672d94d..239de1a7d3 100644
--- a/apis/cloudloadbalancers/src/main/java/org/jclouds/cloudloadbalancers/domain/LoadBalancerRequest.java
+++ b/apis/cloudloadbalancers/src/main/java/org/jclouds/cloudloadbalancers/domain/LoadBalancerRequest.java
@@ -68,8 +68,9 @@ public class LoadBalancerRequest extends BaseLoadBalancer {
@Override
public LoadBalancer apply(LB lb) {
try {
- Builder builder = LoadBalancer.builder().region(region).name(lb.getName()).port(lb.getPort()).protocol(
- lb.getProtocol()).algorithm(lb.getAlgorithm()).nodes(lb.getNodes()).id(lb.id).status(lb.status)
- .virtualIPs(lb.virtualIps);
+ Builder builder = LoadBalancer.builder().region(region).name(lb.getName()).port(lb.getPort())
+ .protocol(lb.getProtocol()).algorithm(lb.getAlgorithm()).nodes(lb.getNodes()).id(lb.id)
+ .status(lb.status).virtualIPs(lb.virtualIps).nodeCount(lb.nodeCount);
if (lb.cluster.size() == 1)
builder.clusterName(Iterables.get(lb.cluster.values(), 0));
if (lb.sessionPersistence.size() == 1)
@@ -71,4 +71,4 @@ public class ConvertLB implements Function {
}
}
-}
\ No newline at end of file
+}
diff --git a/apis/cloudloadbalancers/src/main/java/org/jclouds/cloudloadbalancers/functions/LB.java b/apis/cloudloadbalancers/src/main/java/org/jclouds/cloudloadbalancers/functions/LB.java
index 658a2134e5..ef4d17e947 100644
--- a/apis/cloudloadbalancers/src/main/java/org/jclouds/cloudloadbalancers/functions/LB.java
+++ b/apis/cloudloadbalancers/src/main/java/org/jclouds/cloudloadbalancers/functions/LB.java
@@ -22,20 +22,21 @@ import java.util.Date;
import java.util.Map;
import java.util.Set;
+import org.jclouds.cloudloadbalancers.domain.LoadBalancer.Status;
import org.jclouds.cloudloadbalancers.domain.Node;
import org.jclouds.cloudloadbalancers.domain.VirtualIP;
-import org.jclouds.cloudloadbalancers.domain.LoadBalancer.Status;
import org.jclouds.cloudloadbalancers.domain.internal.BaseLoadBalancer;
+import com.google.common.base.Objects;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
/**
- * only here as the datatype for cloudloadbalancers is awkward.
- *
+ * Only here as the datatype for cloudloadbalancers is awkward.
**/
class LB extends BaseLoadBalancer {
int id;
+ int nodeCount;
Status status;
Set virtualIps = Sets.newLinkedHashSet();
Map sessionPersistence = Maps.newLinkedHashMap();
@@ -43,4 +44,18 @@ class LB extends BaseLoadBalancer {
Map created = Maps.newLinkedHashMap();
Map updated = Maps.newLinkedHashMap();
Map connectionLogging = Maps.newLinkedHashMap();
-}
\ No newline at end of file
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(id);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) return true;
+ if (obj == null || getClass() != obj.getClass()) return false;
+
+ LB that = LB.class.cast(obj);
+ return Objects.equal(this.id, that.id);
+ }
+}
diff --git a/apis/cloudloadbalancers/src/main/java/org/jclouds/cloudloadbalancers/loadbalancer/functions/LoadBalancerToLoadBalancerMetadata.java b/apis/cloudloadbalancers/src/main/java/org/jclouds/cloudloadbalancers/loadbalancer/functions/LoadBalancerToLoadBalancerMetadata.java
index a07e84a549..7576516519 100644
--- a/apis/cloudloadbalancers/src/main/java/org/jclouds/cloudloadbalancers/loadbalancer/functions/LoadBalancerToLoadBalancerMetadata.java
+++ b/apis/cloudloadbalancers/src/main/java/org/jclouds/cloudloadbalancers/loadbalancer/functions/LoadBalancerToLoadBalancerMetadata.java
@@ -60,7 +60,7 @@ public class LoadBalancerToLoadBalancerMetadata implements Function of(), Iterables.transform(input.getVirtualIPs(),
new Function() {
@@ -71,4 +71,4 @@ public class LoadBalancerToLoadBalancerMetadata implements Function converter;
private final ExecutorService executor;
- private final Supplier> regions;
+ private final Supplier> zones;
@Inject
protected CloudLoadBalancersListLoadBalancersStrategy(CloudLoadBalancersAsyncClient aclient,
Function converter,
- @Named(Constants.PROPERTY_USER_THREADS) ExecutorService executor, @Region Supplier> regions) {
+ @Named(Constants.PROPERTY_USER_THREADS) ExecutorService executor, @Zone Supplier> zones) {
this.aclient = checkNotNull(aclient, "aclient");
- this.regions = checkNotNull(regions, "regions");
+ this.zones = checkNotNull(zones, "zones");
this.converter = checkNotNull(converter, "converter");
this.executor = checkNotNull(executor, "executor");
}
@Override
public Iterable extends LoadBalancerMetadata> listLoadBalancers() {
- return transform(concat(transformParallel(regions.get(), new Function>>() {
+ return transform(concat(transformParallel(zones.get(), new Function>>() {
@Override
public ListenableFuture> apply(String from) {
diff --git a/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/CloudLoadBalancersAsyncClientTest.java b/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/CloudLoadBalancersAsyncClientTest.java
deleted file mode 100644
index e09d905434..0000000000
--- a/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/CloudLoadBalancersAsyncClientTest.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/**
- * Licensed to jclouds, Inc. (jclouds) under one or more
- * contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. jclouds 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.cloudloadbalancers;
-
-import java.io.IOException;
-import java.util.concurrent.ExecutionException;
-
-import org.jclouds.cloudloadbalancers.internal.BaseCloudLoadBalancersAsyncClientTest;
-import org.jclouds.http.HttpRequest;
-import org.jclouds.rest.internal.RestAnnotationProcessor;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-import com.google.inject.TypeLiteral;
-
-/**
- * Tests behavior of {@code CloudLoadBalancersAsyncClient}
- *
- * @author Adrian Cole
- */
-// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
-@Test(groups = "unit", testName = "CloudLoadBalancersAsyncClientTest")
-public class CloudLoadBalancersAsyncClientTest extends BaseCloudLoadBalancersAsyncClientTest {
-
- private CloudLoadBalancersAsyncClient asyncClient;
- private CloudLoadBalancersClient syncClient;
-
- public void testSync() throws SecurityException, NoSuchMethodException, InterruptedException, ExecutionException {
- assert syncClient.getLoadBalancerClient("LON") != null;
- }
-
- public void testAsync() throws SecurityException, NoSuchMethodException, InterruptedException, ExecutionException {
- assert asyncClient.getLoadBalancerClient("LON") != null;
- }
-
- @Override
- protected TypeLiteral> createTypeLiteral() {
- return new TypeLiteral>() {
- };
- }
-
- @BeforeClass
- @Override
- protected void setupFactory() throws IOException {
- super.setupFactory();
- asyncClient = injector.getInstance(CloudLoadBalancersAsyncClient.class);
- syncClient = injector.getInstance(CloudLoadBalancersClient.class);
- }
-
- @Override
- protected void checkFilters(HttpRequest request) {
-
- }
-
-}
diff --git a/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/features/LoadBalancerAsyncClientTest.java b/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/features/LoadBalancerAsyncClientTest.java
deleted file mode 100644
index 23c35038fd..0000000000
--- a/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/features/LoadBalancerAsyncClientTest.java
+++ /dev/null
@@ -1,168 +0,0 @@
-/**
- * Licensed to jclouds, Inc. (jclouds) under one or more
- * contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. jclouds 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.cloudloadbalancers.features;
-
-import java.io.IOException;
-import java.lang.reflect.Method;
-
-import org.jclouds.cloudloadbalancers.domain.LoadBalancerAttributes;
-import org.jclouds.cloudloadbalancers.domain.LoadBalancerRequest;
-import org.jclouds.cloudloadbalancers.domain.LoadBalancerAttributes.Builder;
-import org.jclouds.cloudloadbalancers.domain.VirtualIP.Type;
-import org.jclouds.cloudloadbalancers.functions.UnwrapLoadBalancer;
-import org.jclouds.cloudloadbalancers.functions.UnwrapLoadBalancers;
-import org.jclouds.cloudloadbalancers.internal.BaseCloudLoadBalancersAsyncClientTest;
-import org.jclouds.http.HttpRequest;
-import org.jclouds.http.functions.ReleasePayloadAndReturn;
-import org.jclouds.rest.functions.MapHttp4xxCodesToExceptions;
-import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404;
-import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
-import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404;
-import org.jclouds.rest.internal.RestAnnotationProcessor;
-import org.testng.annotations.Test;
-
-import com.google.inject.TypeLiteral;
-
-/**
- * Tests behavior of {@code LoadBalancerAsyncClient}
- *
- * @author Adrian Cole
- */
-// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
-@Test(groups = "unit", testName = "LoadBalancerAsyncClientTest")
-public class LoadBalancerAsyncClientTest extends BaseCloudLoadBalancersAsyncClientTest {
-
- public void testListLoadBalancers() throws SecurityException, NoSuchMethodException, IOException {
- Method method = LoadBalancerAsyncClient.class.getMethod("listLoadBalancers");
- HttpRequest httpRequest = processor.createRequest(method);
-
- assertRequestLineEquals(httpRequest,
- "GET https://lon.loadbalancers.api.rackspacecloud.com/v1.0/10001786/loadbalancers HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
- assertPayloadEquals(httpRequest, null, null, false);
-
- assertResponseParserClassEquals(method, httpRequest, UnwrapLoadBalancers.class);
- assertSaxResponseParserClassEquals(method, null);
- assertExceptionParserClassEquals(method, ReturnEmptySetOnNotFoundOr404.class);
-
- checkFilters(httpRequest);
-
- }
-
- public void testGetLoadBalancer() throws SecurityException, NoSuchMethodException, IOException {
- Method method = LoadBalancerAsyncClient.class.getMethod("getLoadBalancer", int.class);
- HttpRequest httpRequest = processor.createRequest(method, 5);
-
- assertRequestLineEquals(httpRequest,
- "GET https://lon.loadbalancers.api.rackspacecloud.com/v1.0/10001786/loadbalancers/5 HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
- assertPayloadEquals(httpRequest, null, null, false);
-
- assertResponseParserClassEquals(method, httpRequest, UnwrapLoadBalancer.class);
- assertSaxResponseParserClassEquals(method, null);
- assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class);
-
- checkFilters(httpRequest);
-
- }
-
- public void testCreateLoadBalancerWithType() throws SecurityException, NoSuchMethodException, IOException {
- Method method = LoadBalancerAsyncClient.class.getMethod("createLoadBalancer", LoadBalancerRequest.class);
- HttpRequest httpRequest = processor.createRequest(method, LoadBalancerRequest.builder().name("goo").protocol(
- "HTTP").port(80).virtualIPType(Type.PUBLIC).build());
-
- assertRequestLineEquals(httpRequest,
- "POST https://lon.loadbalancers.api.rackspacecloud.com/v1.0/10001786/loadbalancers HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
- assertPayloadEquals(
- httpRequest,
- "{\"loadBalancer\":{\"virtualIps\":[{\"type\":\"PUBLIC\"}],\"name\":\"goo\",\"protocol\":\"HTTP\",\"port\":80,\"nodes\":[]}}",
- "application/json", false);
-
- assertResponseParserClassEquals(method, httpRequest, UnwrapLoadBalancer.class);
- assertSaxResponseParserClassEquals(method, null);
- assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class);
-
- checkFilters(httpRequest);
-
- }
-
- public void testCreateLoadBalancerWithId() throws SecurityException, NoSuchMethodException, IOException {
- Method method = LoadBalancerAsyncClient.class.getMethod("createLoadBalancer", LoadBalancerRequest.class);
- HttpRequest httpRequest = processor.createRequest(method, LoadBalancerRequest.builder().name("goo").protocol(
- "HTTP").port(80).virtualIPId(4).build());
-
- assertRequestLineEquals(httpRequest,
- "POST https://lon.loadbalancers.api.rackspacecloud.com/v1.0/10001786/loadbalancers HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
- assertPayloadEquals(
- httpRequest,
- "{\"loadBalancer\":{\"virtualIps\":[{\"id\":\"4\"}],\"name\":\"goo\",\"protocol\":\"HTTP\",\"port\":80,\"nodes\":[]}}",
- "application/json", false);
-
- assertResponseParserClassEquals(method, httpRequest, UnwrapLoadBalancer.class);
- assertSaxResponseParserClassEquals(method, null);
- assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class);
-
- checkFilters(httpRequest);
-
- }
-
- public void testUpdateLoadBalancerAttributes() throws SecurityException, NoSuchMethodException, IOException {
- Method method = LoadBalancerAsyncClient.class.getMethod("updateLoadBalancerAttributes", int.class,
- LoadBalancerAttributes.class);
- HttpRequest httpRequest = processor.createRequest(method, 2, Builder.name("foo"));
-
- assertRequestLineEquals(httpRequest,
- "PUT https://lon.loadbalancers.api.rackspacecloud.com/v1.0/10001786/loadbalancers/2 HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
- assertPayloadEquals(httpRequest, "{\"loadBalancer\":{\"name\":\"foo\"}}", "application/json", false);
-
- assertResponseParserClassEquals(method, httpRequest, UnwrapLoadBalancer.class);
- assertSaxResponseParserClassEquals(method, null);
- assertExceptionParserClassEquals(method, MapHttp4xxCodesToExceptions.class);
-
- checkFilters(httpRequest);
-
- }
-
- public void testRemoveLoadBalancer() throws SecurityException, NoSuchMethodException, IOException {
- Method method = LoadBalancerAsyncClient.class.getMethod("removeLoadBalancer", int.class);
- HttpRequest httpRequest = processor.createRequest(method, 5);
-
- assertRequestLineEquals(httpRequest,
- "DELETE https://lon.loadbalancers.api.rackspacecloud.com/v1.0/10001786/loadbalancers/5 HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "Accept: */*\n");
- assertPayloadEquals(httpRequest, null, null, false);
-
- assertResponseParserClassEquals(method, httpRequest, ReleasePayloadAndReturn.class);
- assertSaxResponseParserClassEquals(method, null);
- assertExceptionParserClassEquals(method, ReturnVoidOnNotFoundOr404.class);
-
- checkFilters(httpRequest);
-
- }
-
- @Override
- protected TypeLiteral> createTypeLiteral() {
- return new TypeLiteral>() {
- };
- }
-
-}
diff --git a/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/features/LoadBalancerClientLiveTest.java b/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/features/LoadBalancerClientLiveTest.java
index 3cd80da8f8..397195613c 100644
--- a/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/features/LoadBalancerClientLiveTest.java
+++ b/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/features/LoadBalancerClientLiveTest.java
@@ -19,9 +19,9 @@
package org.jclouds.cloudloadbalancers.features;
import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertTrue;
-import java.util.Arrays;
import java.util.Set;
import java.util.logging.Logger;
@@ -31,6 +31,7 @@ import org.jclouds.cloudloadbalancers.domain.LoadBalancerRequest;
import org.jclouds.cloudloadbalancers.domain.NodeRequest;
import org.jclouds.cloudloadbalancers.domain.VirtualIP.Type;
import org.jclouds.cloudloadbalancers.internal.BaseCloudLoadBalancersClientLiveTest;
+import org.testng.annotations.AfterGroups;
import org.testng.annotations.Test;
import com.google.common.collect.Iterables;
@@ -46,15 +47,10 @@ public class LoadBalancerClientLiveTest extends BaseCloudLoadBalancersClientLive
private Set lbs = Sets.newLinkedHashSet();
@Override
- public void setupContext() {
- super.setupContext();
- assertEquals(client.getConfiguredRegions(), Arrays.asList(regions));
- Logger.getAnonymousLogger().info("running against regions " + client.getConfiguredRegions());
- }
-
- @Override
+ @AfterGroups(groups = "live")
protected void tearDownContext() {
- for (LoadBalancer lb : lbs) {
+ for (LoadBalancer lb: lbs) {
+ assert loadBalancerActive.apply(lb) : lb;
client.getLoadBalancerClient(lb.getRegion()).removeLoadBalancer(lb.getId());
assert loadBalancerDeleted.apply(lb) : lb;
}
@@ -62,43 +58,60 @@ public class LoadBalancerClientLiveTest extends BaseCloudLoadBalancersClientLive
}
public void testCreateLoadBalancer() throws Exception {
- for (String region : client.getConfiguredRegions()) {
- Logger.getAnonymousLogger().info("starting lb in region " + region);
- LoadBalancer lb = client.getLoadBalancerClient(region).createLoadBalancer(
- LoadBalancerRequest.builder().name(prefix + "-" + region).protocol("HTTP").port(80).virtualIPType(
- Type.PUBLIC).node(NodeRequest.builder().address("192.168.1.1").port(8080).build()).build());
- checkLBInRegion(region, lb, prefix + "-" + region);
+ for (String zone: client.getConfiguredZones()) {
+ Logger.getAnonymousLogger().info("starting lb in region " + zone);
+
+ LoadBalancer lb = client.getLoadBalancerClient(zone).createLoadBalancer(
+ LoadBalancerRequest.builder()
+ .name(prefix + "-" + zone)
+ .protocol("HTTP")
+ .port(80)
+ .virtualIPType(Type.PUBLIC)
+ .node(NodeRequest.builder()
+ .address("192.168.1.1")
+ .port(8080)
+ .build())
+ .build());
+ checkLBInRegion(zone, lb, prefix + "-" + zone);
+
assertEquals(lb.getStatus(), LoadBalancer.Status.BUILD);
+
lbs.add(lb);
- assert loadBalancerActive.apply(lb) : lb;
+
+ assertTrue(loadBalancerActive.apply(lb));
- LoadBalancer newLb = client.getLoadBalancerClient(region).getLoadBalancer(lb.getId());
- checkLBInRegion(region, newLb, prefix + "-" + region);
+ LoadBalancer newLb = client.getLoadBalancerClient(zone).getLoadBalancer(lb.getId());
+ checkLBInRegion(zone, newLb, prefix + "-" + zone);
+
assertEquals(newLb.getStatus(), LoadBalancer.Status.ACTIVE);
}
}
@Test(dependsOnMethods = "testCreateLoadBalancer")
public void testUpdateLoadBalancer() throws Exception {
- for (LoadBalancer lb : lbs) {
+ for (LoadBalancer lb: lbs) {
client.getLoadBalancerClient(lb.getRegion()).updateLoadBalancerAttributes(lb.getId(),
- LoadBalancerAttributes.Builder.name("foo" + "-" + lb.getRegion()));
- assert loadBalancerActive.apply(lb) : lb;
+ LoadBalancerAttributes.Builder.name("foo" + "-" + lb.getRegion()));
+
+ assertTrue(loadBalancerActive.apply(lb));
LoadBalancer newLb = client.getLoadBalancerClient(lb.getRegion()).getLoadBalancer(lb.getId());
checkLBInRegion(newLb.getRegion(), newLb, "foo" + "-" + lb.getRegion());
+
assertEquals(newLb.getStatus(), LoadBalancer.Status.ACTIVE);
}
}
@Test(dependsOnMethods = "testUpdateLoadBalancer")
public void testListLoadBalancers() throws Exception {
- for (String region : client.getConfiguredRegions()) {
- Set response = client.getLoadBalancerClient(region).listLoadBalancers();
- assert null != response;
+ for (String zone: client.getConfiguredZones()) {
+ Set response = client.getLoadBalancerClient(zone).listLoadBalancers();
+
+ assertNotNull(response);
assertTrue(response.size() >= 0);
- for (LoadBalancer lb : response) {
- if (lb.getStatus() == LoadBalancer.Status.DELETED)
+
+ for (LoadBalancer lb: response) {
+ if (!lbs.contains(lb))
continue;
assert lb.getRegion() != null : lb;
assert lb.getName() != null : lb;
@@ -112,7 +125,8 @@ public class LoadBalancerClientLiveTest extends BaseCloudLoadBalancersClientLive
// node info not available during list;
assert lb.getNodes().size() == 0 : lb;
- LoadBalancer getDetails = client.getLoadBalancerClient(region).getLoadBalancer(lb.getId());
+ LoadBalancer getDetails = client.getLoadBalancerClient(zone).getLoadBalancer(lb.getId());
+
try {
assertEquals(getDetails.getRegion(), lb.getRegion());
assertEquals(getDetails.getName(), lb.getName());
diff --git a/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/features/LoadBalancerExpectTest.java b/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/features/LoadBalancerExpectTest.java
new file mode 100644
index 0000000000..fe24a31381
--- /dev/null
+++ b/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/features/LoadBalancerExpectTest.java
@@ -0,0 +1,156 @@
+/**
+ * Licensed to jclouds, Inc. (jclouds) under one or more
+ * contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. jclouds 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.cloudloadbalancers.features;
+
+import static org.testng.Assert.assertEquals;
+
+import java.net.URI;
+import java.util.Set;
+
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.cloudloadbalancers.CloudLoadBalancersClient;
+import org.jclouds.cloudloadbalancers.domain.LoadBalancer;
+import org.jclouds.cloudloadbalancers.domain.LoadBalancerAttributes;
+import org.jclouds.cloudloadbalancers.domain.LoadBalancerRequest;
+import org.jclouds.cloudloadbalancers.domain.NodeRequest;
+import org.jclouds.cloudloadbalancers.domain.VirtualIP;
+import org.jclouds.cloudloadbalancers.functions.UnwrapLoadBalancerTest;
+import org.jclouds.cloudloadbalancers.functions.UnwrapLoadBalancersTest;
+import org.jclouds.cloudloadbalancers.internal.BaseCloudLoadBalancerExpectTest;
+import org.jclouds.http.HttpResponse;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.Sets;
+
+/**
+ * @author Everett Toews
+ */
+@Test(groups = "unit")
+public class LoadBalancerExpectTest extends BaseCloudLoadBalancerExpectTest {
+
+ public void testListLoadBalancers() {
+ URI endpoint = URI.create("https://dfw.loadbalancers.api.rackspacecloud.com/v1.0/123123/loadbalancers");
+ LoadBalancerClient api = requestsSendResponses(
+ rackspaceAuthWithUsernameAndApiKey,
+ responseWithAccess,
+ authenticatedGET().endpoint(endpoint).build(),
+ HttpResponse.builder().statusCode(200).payload(payloadFromResource("/loadbalancers-list.json")).build()
+ ).getLoadBalancerClient("DFW");
+
+ Set loadBalancers = api.listLoadBalancers();
+ assertEquals(loadBalancers, testLoadBalancers());
+ }
+
+ public void testGetLoadBalancer() {
+ URI endpoint = URI.create("https://dfw.loadbalancers.api.rackspacecloud.com/v1.0/123123/loadbalancers/2000");
+ LoadBalancerClient api = requestsSendResponses(
+ rackspaceAuthWithUsernameAndApiKey,
+ responseWithAccess,
+ authenticatedGET().endpoint(endpoint).build(),
+ HttpResponse.builder().statusCode(200).payload(payloadFromResource("/loadbalancer-get.json")).build()
+ ).getLoadBalancerClient("DFW");
+
+ LoadBalancer loadBalancer = api.getLoadBalancer(2000);
+ assertEquals(loadBalancer, testLoadBalancer());
+ }
+
+ public void testCreateLoadBalancer() {
+ URI endpoint = URI.create("https://dfw.loadbalancers.api.rackspacecloud.com/v1.0/123123/loadbalancers");
+ LoadBalancerClient api = requestsSendResponses(
+ rackspaceAuthWithUsernameAndApiKey,
+ responseWithAccess,
+ authenticatedGET()
+ .method("POST")
+ .payload(payloadFromResource("/loadbalancer-create.json"))
+ .endpoint(endpoint)
+ .build(),
+ HttpResponse.builder().statusCode(200).payload(payloadFromResource("/loadbalancer-get.json")).build()
+ ).getLoadBalancerClient("DFW");
+
+ NodeRequest nodeRequest1 = NodeRequest.builder()
+ .address("10.1.1.1")
+ .condition(NodeRequest.Condition.ENABLED)
+ .port(80)
+ .build();
+
+ NodeRequest nodeRequest2 = NodeRequest.builder()
+ .address("10.1.1.2")
+ .condition(NodeRequest.Condition.ENABLED)
+ .port(80)
+ .build();
+
+ Set nodeRequests = Sets.newHashSet(nodeRequest1, nodeRequest2);
+
+ LoadBalancerRequest lbRequest = LoadBalancerRequest.builder()
+ .name("sample-loadbalancer")
+ .protocol("HTTP")
+ .port(80)
+ .algorithm(LoadBalancer.Algorithm.RANDOM.name())
+ .virtualIPType(VirtualIP.Type.PUBLIC)
+ .nodes(nodeRequests)
+ .build();
+
+ LoadBalancer loadBalancer = api.createLoadBalancer(lbRequest);
+
+ assertEquals(loadBalancer, testLoadBalancer());
+ }
+
+ public void testUpdateLoadBalancerAttributes() {
+ URI endpoint = URI.create("https://dfw.loadbalancers.api.rackspacecloud.com/v1.0/123123/loadbalancers/2000");
+ LoadBalancerClient api = requestsSendResponses(
+ rackspaceAuthWithUsernameAndApiKey,
+ responseWithAccess,
+ authenticatedGET().method("PUT").payload(payloadFromResource("/loadbalancer-update.json")).endpoint(endpoint).build(),
+ HttpResponse.builder().statusCode(202).payload("").build()
+ ).getLoadBalancerClient("DFW");
+
+ LoadBalancerAttributes lbAttrs = LoadBalancerAttributes.Builder
+ .name("foo")
+ .protocol("HTTPS")
+ .port(443)
+ .algorithm(LoadBalancer.Algorithm.RANDOM.name());
+
+ api.updateLoadBalancerAttributes(2000, lbAttrs);
+ }
+
+ public void testRemoveLoadBalancer() {
+ URI endpoint = URI.create("https://dfw.loadbalancers.api.rackspacecloud.com/v1.0/123123/loadbalancers/2000");
+ LoadBalancerClient api = requestsSendResponses(
+ rackspaceAuthWithUsernameAndApiKey,
+ responseWithAccess,
+ authenticatedGET()
+ .method("DELETE")
+ .replaceHeader("Accept", MediaType.WILDCARD)
+ .endpoint(endpoint)
+ .build(),
+ HttpResponse.builder().statusCode(202).payload("").build()
+ ).getLoadBalancerClient("DFW");
+
+ api.removeLoadBalancer(2000);
+ }
+
+ private Object testLoadBalancer() {
+ return new UnwrapLoadBalancerTest().expected();
+ }
+
+ private Set testLoadBalancers() {
+ return new UnwrapLoadBalancersTest().expected();
+ }
+}
diff --git a/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/features/NodeAsyncClientTest.java b/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/features/NodeAsyncClientTest.java
deleted file mode 100644
index fb09722a1b..0000000000
--- a/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/features/NodeAsyncClientTest.java
+++ /dev/null
@@ -1,148 +0,0 @@
-/**
- * Licensed to jclouds, Inc. (jclouds) under one or more
- * contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. jclouds 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.cloudloadbalancers.features;
-
-import java.io.IOException;
-import java.lang.reflect.Method;
-import java.util.Collections;
-import java.util.Set;
-
-import org.jclouds.cloudloadbalancers.domain.NodeAttributes;
-import org.jclouds.cloudloadbalancers.domain.NodeRequest;
-import org.jclouds.cloudloadbalancers.domain.NodeAttributes.Builder;
-import org.jclouds.cloudloadbalancers.domain.internal.BaseNode.Condition;
-import org.jclouds.cloudloadbalancers.internal.BaseCloudLoadBalancersAsyncClientTest;
-import org.jclouds.http.HttpRequest;
-import org.jclouds.http.functions.ParseFirstJsonValueNamed;
-import org.jclouds.http.functions.ReleasePayloadAndReturn;
-import org.jclouds.rest.functions.MapHttp4xxCodesToExceptions;
-import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404;
-import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
-import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404;
-import org.jclouds.rest.internal.RestAnnotationProcessor;
-import org.testng.annotations.Test;
-
-import com.google.inject.TypeLiteral;
-
-/**
- * Tests behavior of {@code NodeAsyncClient}
- *
- * @author Dan Lo Bianco
- */
-// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
-@Test(groups = "unit", testName = "NodeAsyncClientTest")
-public class NodeAsyncClientTest extends BaseCloudLoadBalancersAsyncClientTest {
-
- public void testListNodes() throws SecurityException, NoSuchMethodException, IOException {
- Method method = NodeAsyncClient.class.getMethod("listNodes", int.class);
- HttpRequest httpRequest = processor.createRequest(method, 2);
-
- assertRequestLineEquals(httpRequest,
- "GET https://lon.loadbalancers.api.rackspacecloud.com/v1.0/10001786/loadbalancers/2/nodes HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
- assertPayloadEquals(httpRequest, null, null, false);
-
- assertResponseParserClassEquals(method, httpRequest, ParseFirstJsonValueNamed.class);
- assertSaxResponseParserClassEquals(method, null);
- assertExceptionParserClassEquals(method, ReturnEmptySetOnNotFoundOr404.class);
-
- checkFilters(httpRequest);
-
- }
-
- public void testGetNodeInLoadBalancer() throws SecurityException, NoSuchMethodException, IOException {
- Method method = NodeAsyncClient.class.getMethod("getNodeInLoadBalancer", int.class, int.class);
- HttpRequest httpRequest = processor.createRequest(method, 3, 2);
-
- assertRequestLineEquals(httpRequest,
- "GET https://lon.loadbalancers.api.rackspacecloud.com/v1.0/10001786/loadbalancers/2/nodes/3 HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
- assertPayloadEquals(httpRequest, null, null, false);
-
- assertResponseParserClassEquals(method, httpRequest, ParseFirstJsonValueNamed.class);
- assertSaxResponseParserClassEquals(method, null);
- assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class);
-
- checkFilters(httpRequest);
-
- }
-
- public void createNodesInLoadBalancerWithType() throws SecurityException, NoSuchMethodException, IOException {
- Method method = NodeAsyncClient.class.getMethod("createNodesInLoadBalancer", Set.class, int.class);
- HttpRequest httpRequest = processor.createRequest(method, Collections.singleton(NodeRequest.builder().
- address("192.168.1.1").port(8080).build()), 3);
-
- assertRequestLineEquals(httpRequest,
- "POST https://lon.loadbalancers.api.rackspacecloud.com/v1.0/10001786/loadbalancers/3/nodes HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
- assertPayloadEquals(
- httpRequest,
- "{\"nodes\":[{\"address\":\"192.168.1.1\",\"port\":8080,\"condition\":\"ENABLED\"}]}",
- "application/json", false);
-
- assertResponseParserClassEquals(method, httpRequest, ParseFirstJsonValueNamed.class);
- assertSaxResponseParserClassEquals(method, null);
- assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class);
-
- checkFilters(httpRequest);
-
- }
-
- public void testUpdateAttributesForNodeInLoadBalancer() throws SecurityException, NoSuchMethodException, IOException {
- Method method = NodeAsyncClient.class.getMethod("updateAttributesForNodeInLoadBalancer", NodeAttributes.class,
- int.class, int.class);
- HttpRequest httpRequest = processor.createRequest(method, Builder.condition(Condition.DISABLED).weight(13), 8, 7);
-
- assertRequestLineEquals(httpRequest,
- "PUT https://lon.loadbalancers.api.rackspacecloud.com/v1.0/10001786/loadbalancers/7/nodes/8 HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
- assertPayloadEquals(httpRequest, "{\"node\":{\"condition\":\"DISABLED\",\"weight\":13}}", "application/json", false);
-
- assertResponseParserClassEquals(method, httpRequest, ReleasePayloadAndReturn.class);
- assertSaxResponseParserClassEquals(method, null);
- assertExceptionParserClassEquals(method, MapHttp4xxCodesToExceptions.class);
-
- checkFilters(httpRequest);
-
- }
-
- public void testRemoveNodeFromLoadBalancer() throws SecurityException, NoSuchMethodException, IOException {
- Method method = NodeAsyncClient.class.getMethod("removeNodeFromLoadBalancer", int.class, int.class);
- HttpRequest httpRequest = processor.createRequest(method, 9, 4);
-
- assertRequestLineEquals(httpRequest,
- "DELETE https://lon.loadbalancers.api.rackspacecloud.com/v1.0/10001786/loadbalancers/4/nodes/9 HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "Accept: */*\n");
- assertPayloadEquals(httpRequest, null, null, false);
-
- assertResponseParserClassEquals(method, httpRequest, ReleasePayloadAndReturn.class);
- assertSaxResponseParserClassEquals(method, null);
- assertExceptionParserClassEquals(method, ReturnVoidOnNotFoundOr404.class);
-
- checkFilters(httpRequest);
-
- }
-
- @Override
- protected TypeLiteral> createTypeLiteral() {
- return new TypeLiteral>() {
- };
- }
-
-}
diff --git a/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/features/NodeClientLiveTest.java b/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/features/NodeClientLiveTest.java
index 64bfa9611e..75c86d8dd4 100644
--- a/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/features/NodeClientLiveTest.java
+++ b/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/features/NodeClientLiveTest.java
@@ -50,14 +50,13 @@ import org.testng.annotations.Test;
public class NodeClientLiveTest extends BaseCloudLoadBalancersClientLiveTest {
private Map> nodes = new HashMap>();
- @Test(groups = "live")
public void testCreateLoadBalancers() {
- assertTrue(client.getConfiguredRegions().size() > 0, "Need to have some regions!");
- Logger.getAnonymousLogger().info("running against regions " + client.getConfiguredRegions());
- for (String region : client.getConfiguredRegions()) {
- Logger.getAnonymousLogger().info("starting lb in region " + region);
- LoadBalancer lb = client.getLoadBalancerClient(region).createLoadBalancer(
- LoadBalancerRequest.builder().name(prefix + "-" + region).protocol("HTTP").port(80).virtualIPType(
+ assertTrue(client.getConfiguredZones().size() > 0, "Need to have some zones!");
+ Logger.getAnonymousLogger().info("running against zones " + client.getConfiguredZones());
+ for (String zone : client.getConfiguredZones()) {
+ Logger.getAnonymousLogger().info("starting lb in zone " + zone);
+ LoadBalancer lb = client.getLoadBalancerClient(zone).createLoadBalancer(
+ LoadBalancerRequest.builder().name(prefix + "-" + zone).protocol("HTTP").port(80).virtualIPType(
Type.PUBLIC).node(NodeRequest.builder().address("192.168.1.1").port(8080).build()).build());
nodes.put(lb, new HashSet());
@@ -65,7 +64,7 @@ public class NodeClientLiveTest extends BaseCloudLoadBalancersClientLiveTest {
}
}
- @Test(groups = "live", dependsOnMethods = "testCreateLoadBalancers")
+ @Test(dependsOnMethods = "testCreateLoadBalancers")
public void testAddNodes() throws Exception {
for (LoadBalancer lb : nodes.keySet()) {
String region = lb.getRegion();
@@ -85,7 +84,7 @@ public class NodeClientLiveTest extends BaseCloudLoadBalancersClientLiveTest {
}
}
- @Test(groups = "live", dependsOnMethods = "testAddNodes")
+ @Test(dependsOnMethods = "testAddNodes")
public void testModifyNode() throws Exception {
for (Entry> entry : nodes.entrySet()) {
for (Node n : entry.getValue()) {
@@ -102,7 +101,7 @@ public class NodeClientLiveTest extends BaseCloudLoadBalancersClientLiveTest {
}
}
- @Test(groups = "live", dependsOnMethods = "testModifyNode")
+ @Test(dependsOnMethods = "testModifyNode")
public void testListNodes() throws Exception {
for (LoadBalancer lb : nodes.keySet()) {
Set response = client.getNodeClient(lb.getRegion()).listNodes(lb.getId());
@@ -143,6 +142,7 @@ public class NodeClientLiveTest extends BaseCloudLoadBalancersClientLiveTest {
LoadBalancerClient lbClient = client.getLoadBalancerClient(lb.getRegion());
if (lbClient.getLoadBalancer(lb.getId()).getStatus() != Status.DELETED) {
+ assert loadBalancerActive.apply(lb) : lb;
lbClient.removeLoadBalancer(lb.getId());
}
assert loadBalancerDeleted.apply(lb) : lb;
diff --git a/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/features/NodeExpectTest.java b/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/features/NodeExpectTest.java
new file mode 100644
index 0000000000..aa9d080cfe
--- /dev/null
+++ b/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/features/NodeExpectTest.java
@@ -0,0 +1,194 @@
+/**
+ * Licensed to jclouds, Inc. (jclouds) under one or more
+ * contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. jclouds 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.cloudloadbalancers.features;
+
+import static org.testng.Assert.assertEquals;
+
+import java.net.URI;
+import java.util.Set;
+
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.cloudloadbalancers.CloudLoadBalancersClient;
+import org.jclouds.cloudloadbalancers.domain.Node;
+import org.jclouds.cloudloadbalancers.domain.NodeAttributes;
+import org.jclouds.cloudloadbalancers.domain.NodeRequest;
+import org.jclouds.cloudloadbalancers.internal.BaseCloudLoadBalancerExpectTest;
+import org.jclouds.http.HttpResponse;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.ImmutableSortedSet;
+
+/**
+ * @author Everett Toews
+ */
+@Test(groups = "unit")
+public class NodeExpectTest extends BaseCloudLoadBalancerExpectTest {
+
+ public void testListNodes() {
+ URI endpoint = URI.create("https://dfw.loadbalancers.api.rackspacecloud.com/v1.0/123123/loadbalancers/2000/nodes");
+ NodeClient api = requestsSendResponses(
+ rackspaceAuthWithUsernameAndApiKey,
+ responseWithAccess,
+ authenticatedGET().endpoint(endpoint).build(),
+ HttpResponse.builder().statusCode(200).payload(payloadFromResource("/nodes-list.json")).build()
+ ).getNodeClient("DFW");
+
+ Set nodes = api.listNodes(2000);
+ assertEquals(nodes, testNodes());
+ }
+
+ public void testGetNodeInLoadBalancer() {
+ URI endpoint = URI.create("https://dfw.loadbalancers.api.rackspacecloud.com/v1.0/123123/loadbalancers/2000/nodes/410");
+ NodeClient api = requestsSendResponses(
+ rackspaceAuthWithUsernameAndApiKey,
+ responseWithAccess,
+ authenticatedGET().endpoint(endpoint).build(),
+ HttpResponse.builder().statusCode(200).payload(payloadFromResource("/node-get.json")).build()
+ ).getNodeClient("DFW");
+
+ Node node = api.getNodeInLoadBalancer(410, 2000);
+ assertEquals(node, testNode());
+ }
+
+ public void testAddNodesInLoadBalancer() {
+ URI endpoint = URI.create("https://dfw.loadbalancers.api.rackspacecloud.com/v1.0/123123/loadbalancers/2000/nodes");
+ NodeClient api = requestsSendResponses(
+ rackspaceAuthWithUsernameAndApiKey,
+ responseWithAccess,
+ authenticatedGET()
+ .method("POST")
+ .payload(payloadFromResourceWithContentType("/nodes-add.json", MediaType.APPLICATION_JSON))
+ .endpoint(endpoint)
+ .build(),
+ HttpResponse.builder().statusCode(200).payload(payloadFromResource("/nodes-list.json")).build()
+ ).getNodeClient("DFW");
+
+ NodeRequest nodeRequest1 = NodeRequest.builder()
+ .address("10.1.1.1")
+ .condition(NodeRequest.Condition.ENABLED)
+ .port(80)
+ .weight(3)
+ .build();
+
+ NodeRequest nodeRequest2 = NodeRequest.builder()
+ .address("10.1.1.2")
+ .condition(NodeRequest.Condition.ENABLED)
+ .port(80)
+ .weight(8)
+ .build();
+
+ NodeRequest nodeRequest3 = NodeRequest.builder()
+ .address("10.1.1.3")
+ .condition(NodeRequest.Condition.DISABLED)
+ .port(80)
+ .weight(12)
+ .build();
+
+ Set nodeRequests = ImmutableSortedSet. of(nodeRequest1, nodeRequest2, nodeRequest3);
+
+ Set nodes = api.createNodesInLoadBalancer(nodeRequests, 2000);
+ assertEquals(nodes, testNodes());
+ }
+
+ public void testUpdateAttributesForNodeInLoadBalancer() {
+ URI endpoint = URI.create("https://dfw.loadbalancers.api.rackspacecloud.com/v1.0/123123/loadbalancers/2000/nodes/410");
+ NodeClient api = requestsSendResponses(
+ rackspaceAuthWithUsernameAndApiKey,
+ responseWithAccess,
+ authenticatedGET().method("PUT").payload(payloadFromResource("/node-update.json")).endpoint(endpoint).build(),
+ HttpResponse.builder().statusCode(200).build()
+ ).getNodeClient("DFW");
+
+ NodeAttributes nodeAttributes = NodeAttributes.Builder
+ .condition(NodeRequest.Condition.DISABLED)
+ .weight(20);
+
+ api.updateAttributesForNodeInLoadBalancer(nodeAttributes, 410, 2000);
+ }
+
+ public void testRemoveNodeFromLoadBalancer() {
+ URI endpoint = URI.create("https://dfw.loadbalancers.api.rackspacecloud.com/v1.0/123123/loadbalancers/2000/nodes/410");
+ NodeClient api = requestsSendResponses(
+ rackspaceAuthWithUsernameAndApiKey,
+ responseWithAccess,
+ authenticatedGET().method("DELETE").replaceHeader("Accept", MediaType.WILDCARD).endpoint(endpoint).build(),
+ HttpResponse.builder().statusCode(200).build()
+ ).getNodeClient("DFW");
+
+ api.removeNodeFromLoadBalancer(410, 2000);
+ }
+
+ public void testRemoveNodesFromLoadBalancer() {
+ URI endpoint = URI.create("https://dfw.loadbalancers.api.rackspacecloud.com/v1.0/123123/loadbalancers/2000/nodes?id=%5B410%2C%20411%5D");
+ NodeClient api = requestsSendResponses(
+ rackspaceAuthWithUsernameAndApiKey,
+ responseWithAccess,
+ authenticatedGET().method("DELETE").replaceHeader("Accept", MediaType.WILDCARD).endpoint(endpoint).build(),
+ HttpResponse.builder().statusCode(200).build()
+ ).getNodeClient("DFW");
+
+ Set nodeIds = ImmutableSortedSet. of(410, 411);
+
+ api.removeNodesFromLoadBalancer(nodeIds, 2000);
+ }
+
+ private Set testNodes() {
+ Node node1 = Node.builder()
+ .id(410)
+ .address("10.1.1.1")
+ .port(80)
+ .condition(Node.Condition.ENABLED)
+ .status(Node.Status.ONLINE)
+ .weight(3)
+ .build();
+
+ Node node2 = Node.builder()
+ .id(411)
+ .address("10.1.1.2")
+ .port(80)
+ .condition(Node.Condition.ENABLED)
+ .status(Node.Status.ONLINE)
+ .weight(8)
+ .build();
+
+ Node node3 = Node.builder()
+ .id(412)
+ .address("10.1.1.3")
+ .port(80)
+ .condition(Node.Condition.DISABLED)
+ .status(Node.Status.ONLINE)
+ .weight(12)
+ .build();
+
+ return ImmutableSet. of(node1, node2, node3);
+ }
+
+ private Node testNode() {
+ return Node.builder()
+ .id(410)
+ .address("10.1.1.1")
+ .port(80)
+ .condition(Node.Condition.ENABLED)
+ .status(Node.Status.ONLINE)
+ .weight(12)
+ .build();
+ }
+}
diff --git a/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/functions/UnwrapLoadBalancerTest.java b/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/functions/UnwrapLoadBalancerTest.java
index 521aa3a0ef..86c4f531ed 100644
--- a/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/functions/UnwrapLoadBalancerTest.java
+++ b/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/functions/UnwrapLoadBalancerTest.java
@@ -43,30 +43,31 @@ public class UnwrapLoadBalancerTest extends BaseItemParserTest {
@Override
public String resource() {
- return "/getloadbalancer.json";
+ return "/loadbalancer-get.json";
}
@Override
public LoadBalancer expected() {
- return LoadBalancer.builder().region("DFW").id(2000).name("sample-loadbalancer").protocol("HTTP").port(80)
- .algorithm("RANDOM").status(Status.ACTIVE).connectionLoggingEnabled(true).virtualIPs(
- ImmutableSet.of(VirtualIP.builder().id(1000).address("206.10.10.210").type(
- VirtualIP.Type.PUBLIC).ipVersion(IPVersion.IPV4).build()))
-
- .nodes(
- ImmutableSet.of(Node.builder().id(1041).address("10.1.1.1").port(80).condition(
- Node.Condition.ENABLED).status(Node.Status.ONLINE).build(), Node.builder().id(1411)
- .address("10.1.1.2").port(80).condition(Node.Condition.ENABLED).status(
- Node.Status.ONLINE).build())).sessionPersistenceType("HTTP_COOKIE")
- // connectionThrottle({
- // minConnections(10)
- // maxConnections(100)
- // maxConnectionRate(50)
- // rateInterval(60
- // })
- .clusterName("c1.dfw1").created(
- new SimpleDateFormatDateService().iso8601SecondsDateParse("2010-11-30T03:23:42Z")).updated(
- new SimpleDateFormatDateService().iso8601SecondsDateParse("2010-11-30T03:23:44Z")).build();
+ return LoadBalancer
+ .builder()
+ .region("DFW")
+ .id(2000)
+ .name("sample-loadbalancer")
+ .protocol("HTTP")
+ .port(80)
+ .algorithm("RANDOM")
+ .status(Status.ACTIVE)
+ .connectionLoggingEnabled(true)
+ .nodeCount(2)
+ .virtualIPs(ImmutableSet.of(
+ VirtualIP.builder().id(1000).address("206.10.10.210").type(VirtualIP.Type.PUBLIC).ipVersion(IPVersion.IPV4).build()))
+ .nodes(ImmutableSet.of(
+ Node.builder().id(1041).address("10.1.1.1").port(80).condition(Node.Condition.ENABLED).status(Node.Status.ONLINE).build(),
+ Node.builder().id(1411).address("10.1.1.2").port(80).condition(Node.Condition.ENABLED).status(Node.Status.ONLINE).build()))
+ .sessionPersistenceType("HTTP_COOKIE")
+ .clusterName("c1.dfw1")
+ .created(new SimpleDateFormatDateService().iso8601SecondsDateParse("2010-11-30T03:23:42Z"))
+ .updated(new SimpleDateFormatDateService().iso8601SecondsDateParse("2010-11-30T03:23:44Z")).build();
}
// add factory binding as this is not default
diff --git a/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/functions/UnwrapLoadBalancerWhenDeletedTest.java b/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/functions/UnwrapLoadBalancerWhenDeletedTest.java
index bd8501e40a..fd7e7a74fc 100644
--- a/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/functions/UnwrapLoadBalancerWhenDeletedTest.java
+++ b/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/functions/UnwrapLoadBalancerWhenDeletedTest.java
@@ -39,14 +39,14 @@ public class UnwrapLoadBalancerWhenDeletedTest extends BaseItemParserTest {
@Override
public String resource() {
- return "/listloadbalancers.json";
+ return "/loadbalancers-list.json";
}
@Override
@@ -51,18 +51,36 @@ public class UnwrapLoadBalancersTest extends BaseSetParserTest {
return ImmutableSet.of(
- LoadBalancer.builder().region("DFW").name("lb-site1").id(71).protocol("HTTP").port(80).algorithm("RANDOM")
- .status(Status.ACTIVE).virtualIPs(
- ImmutableSet.of(VirtualIP.builder().id(403).address("206.55.130.1").type(VirtualIP.Type.PUBLIC)
- .ipVersion(VirtualIP.IPVersion.IPV4).build())).created(
- new SimpleDateFormatDateService().iso8601SecondsDateParse("2010-11-30T03:23:42Z")).updated(
- new SimpleDateFormatDateService().iso8601SecondsDateParse("2010-11-30T03:23:44Z")).build(),
- LoadBalancer.builder().region("DFW").name("lb-site2").id(166).protocol("HTTP").port(80).algorithm(
- "RANDOM").status(Status.ACTIVE).virtualIPs(
- ImmutableSet.of(VirtualIP.builder().id(401).address("206.55.130.2").type(VirtualIP.Type.PUBLIC)
- .ipVersion(VirtualIP.IPVersion.IPV4).build())).created(
- new SimpleDateFormatDateService().iso8601SecondsDateParse("2010-11-30T03:23:42Z")).updated(
- new SimpleDateFormatDateService().iso8601SecondsDateParse("2010-11-30T03:23:44Z")).build());
+ LoadBalancer
+ .builder()
+ .region("DFW")
+ .name("lb-site1")
+ .id(71)
+ .protocol("HTTP")
+ .port(80)
+ .algorithm("RANDOM")
+ .status(Status.ACTIVE)
+ .nodeCount(1)
+ .virtualIPs(ImmutableSet.of(
+ VirtualIP.builder().id(403).address("206.55.130.1")
+ .type(VirtualIP.Type.PUBLIC).ipVersion(VirtualIP.IPVersion.IPV4).build()))
+ .created(new SimpleDateFormatDateService().iso8601SecondsDateParse("2010-11-30T03:23:42Z"))
+ .updated(new SimpleDateFormatDateService().iso8601SecondsDateParse("2010-11-30T03:23:44Z")).build(),
+ LoadBalancer
+ .builder()
+ .region("DFW")
+ .name("lb-site2")
+ .id(166)
+ .protocol("HTTP")
+ .port(80)
+ .algorithm("RANDOM")
+ .status(Status.ACTIVE)
+ .nodeCount(1)
+ .virtualIPs(ImmutableSet.of(
+ VirtualIP.builder().id(401).address("206.55.130.2")
+ .type(VirtualIP.Type.PUBLIC).ipVersion(VirtualIP.IPVersion.IPV4).build()))
+ .created(new SimpleDateFormatDateService().iso8601SecondsDateParse("2010-11-30T03:23:42Z"))
+ .updated(new SimpleDateFormatDateService().iso8601SecondsDateParse("2010-11-30T03:23:44Z")).build());
}
diff --git a/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/internal/BaseCloudLoadBalancerExpectTest.java b/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/internal/BaseCloudLoadBalancerExpectTest.java
new file mode 100644
index 0000000000..e674e446a7
--- /dev/null
+++ b/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/internal/BaseCloudLoadBalancerExpectTest.java
@@ -0,0 +1,60 @@
+/**
+ * Licensed to jclouds, Inc. (jclouds) under one or more
+ * contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. jclouds 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.cloudloadbalancers.internal;
+
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.http.HttpRequest;
+import org.jclouds.http.HttpResponse;
+import org.jclouds.rackspace.cloudidentity.v2_0.internal.RackspaceFixture;
+import org.jclouds.rest.internal.BaseRestApiExpectTest;
+
+/**
+ * Base class for writing Cloud Load Balancer Expect tests
+ *
+ * @author Everett Toews
+ */
+public class BaseCloudLoadBalancerExpectTest extends BaseRestApiExpectTest {
+ protected HttpRequest rackspaceAuthWithUsernameAndApiKey;
+
+ protected String authToken;
+ protected HttpResponse responseWithAccess;
+
+ public BaseCloudLoadBalancerExpectTest() {
+ provider = "cloudloadbalancers";
+
+ rackspaceAuthWithUsernameAndApiKey = RackspaceFixture.INSTANCE
+ .initialAuthWithUsernameAndApiKey(identity, credential);
+
+ authToken = RackspaceFixture.INSTANCE.getAuthToken();
+ responseWithAccess = RackspaceFixture.INSTANCE.responseWithAccess();
+ }
+
+ @Override
+ protected HttpRequestComparisonType compareHttpRequestAsType(HttpRequest input) {
+ return HttpRequestComparisonType.JSON;
+ }
+
+ protected HttpRequest.Builder> authenticatedGET() {
+ return HttpRequest.builder()
+ .method("GET")
+ .addHeader("Accept", MediaType.APPLICATION_JSON)
+ .addHeader("X-Auth-Token", authToken);
+ }
+}
diff --git a/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/internal/BaseCloudLoadBalancersAsyncClientTest.java b/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/internal/BaseCloudLoadBalancersAsyncClientTest.java
deleted file mode 100644
index d0ed3c0283..0000000000
--- a/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/internal/BaseCloudLoadBalancersAsyncClientTest.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/**
- * Licensed to jclouds, Inc. (jclouds) under one or more
- * contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. jclouds 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.cloudloadbalancers.internal;
-
-import static org.jclouds.Constants.PROPERTY_API_VERSION;
-import static org.jclouds.cloudloadbalancers.reference.Region.LON;
-import static org.jclouds.location.reference.LocationConstants.ENDPOINT;
-import static org.jclouds.location.reference.LocationConstants.ISO3166_CODES;
-import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGION;
-import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGIONS;
-import static org.testng.Assert.assertEquals;
-
-import java.io.IOException;
-import java.util.Properties;
-
-import javax.inject.Singleton;
-
-import org.jclouds.apis.ApiMetadata;
-import org.jclouds.cloudloadbalancers.CloudLoadBalancersApiMetadata;
-import org.jclouds.cloudloadbalancers.CloudLoadBalancersAsyncClient;
-import org.jclouds.cloudloadbalancers.config.CloudLoadBalancersRestClientModule;
-import org.jclouds.cloudloadbalancers.reference.Region;
-import org.jclouds.domain.Credentials;
-import org.jclouds.http.HttpRequest;
-import org.jclouds.internal.ClassMethodArgs;
-import org.jclouds.location.config.LocationModule;
-import org.jclouds.openstack.filters.AuthenticateRequest;
-import org.jclouds.openstack.keystone.v1_1.config.AuthenticationServiceModule.GetAuth;
-import org.jclouds.openstack.keystone.v1_1.domain.Auth;
-import org.jclouds.openstack.keystone.v1_1.parse.ParseAuthTest;
-import org.jclouds.rest.ConfiguresRestClient;
-import org.jclouds.rest.internal.BaseAsyncClientTest;
-import org.testng.annotations.BeforeClass;
-
-import com.google.common.base.Throwables;
-import com.google.inject.AbstractModule;
-import com.google.inject.Module;
-import com.google.inject.Provides;
-
-/**
- * @author Adrian Cole
- */
-public abstract class BaseCloudLoadBalancersAsyncClientTest extends BaseAsyncClientTest {
-
- protected String provider;
-
- public BaseCloudLoadBalancersAsyncClientTest() {
- this.provider = "cloudloadbalancers";
- }
-
- @Override
- protected Module createModule() {
- return new TestCloudLoadBalancersRestClientModule();
- }
-
- @ConfiguresRestClient
- protected static class TestCloudLoadBalancersRestClientModule extends CloudLoadBalancersRestClientModule {
- @Override
- protected void installLocations() {
- install(new AbstractModule() {
- protected void configure() {
- }
-
- @Provides
- @Singleton
- GetAuth provideGetAuth() {
- return new GetAuth(null) {
- @Override
- public Auth apply(Credentials in) {
- return new ParseAuthTest().expected();
- }
- };
- }
- });
- install(new LocationModule());
- install(new URIWithAccountIDPathSuffixAuthenticationServiceModule());
-
- }
- }
-
- @Override
- protected void checkFilters(HttpRequest request) {
- assertEquals(request.getFilters().size(), 1);
- assertEquals(request.getFilters().get(0).getClass(), AuthenticateRequest.class);
- }
-
- @BeforeClass
- @Override
- protected void setupFactory() throws IOException {
- super.setupFactory();
- try {
- processor.setCaller(new ClassMethodArgs(CloudLoadBalancersAsyncClient.class,
- CloudLoadBalancersAsyncClient.class.getMethod("getLoadBalancerClient", String.class),
- new Object[] { Region.LON }));
- } catch (Exception e) {
- Throwables.propagate(e);
- }
- }
-
- @Override
- protected Properties setupProperties() {
- Properties overrides = new Properties();
- overrides.setProperty(provider + ".endpoint", "https://auth");
- overrides.setProperty(PROPERTY_REGIONS, LON);
- overrides.setProperty(PROPERTY_REGION + "." + LON + "." + ISO3166_CODES, "GB-SLG");
- overrides.setProperty(PROPERTY_REGION + "." + LON + "." + ENDPOINT, String.format(
- "https://lon.loadbalancers.api.rackspacecloud.com/v${%s}", PROPERTY_API_VERSION));
- return overrides;
- }
-
- @Override
- protected ApiMetadata createApiMetadata() {
- return new CloudLoadBalancersApiMetadata();
- }
-
-}
\ No newline at end of file
diff --git a/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/internal/BaseCloudLoadBalancersClientLiveTest.java b/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/internal/BaseCloudLoadBalancersClientLiveTest.java
index 70e77f8aab..f76a40b562 100644
--- a/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/internal/BaseCloudLoadBalancersClientLiveTest.java
+++ b/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/internal/BaseCloudLoadBalancersClientLiveTest.java
@@ -18,16 +18,19 @@
*/
package org.jclouds.cloudloadbalancers.internal;
+import java.util.Properties;
import java.util.concurrent.TimeUnit;
+import java.util.logging.Logger;
-import org.jclouds.apis.BaseViewLiveTest;
+import org.jclouds.apis.BaseContextLiveTest;
+import org.jclouds.cloudloadbalancers.CloudLoadBalancersApiMetadata;
import org.jclouds.cloudloadbalancers.CloudLoadBalancersAsyncClient;
import org.jclouds.cloudloadbalancers.CloudLoadBalancersClient;
import org.jclouds.cloudloadbalancers.domain.LoadBalancer;
import org.jclouds.cloudloadbalancers.predicates.LoadBalancerActive;
import org.jclouds.cloudloadbalancers.predicates.LoadBalancerDeleted;
-import org.jclouds.loadbalancer.LoadBalancerServiceContext;
-import org.jclouds.logging.log4j.config.Log4JLoggingModule;
+import org.jclouds.logging.slf4j.config.SLF4JLoggingModule;
+import org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties;
import org.jclouds.predicates.RetryablePredicate;
import org.jclouds.rest.RestContext;
import org.testng.annotations.BeforeGroups;
@@ -42,15 +45,13 @@ import com.google.inject.Injector;
*
* @author Adrian Cole
*/
-public class BaseCloudLoadBalancersClientLiveTest extends BaseViewLiveTest {
+public class BaseCloudLoadBalancersClientLiveTest extends BaseContextLiveTest> {
public BaseCloudLoadBalancersClientLiveTest() {
provider = "cloudloadbalancers";
}
protected CloudLoadBalancersClient client;
- protected RestContext lbContext;
- protected String[] regions = {};
protected Predicate socketTester;
protected RetryablePredicate loadBalancerActive;
protected RetryablePredicate loadBalancerDeleted;
@@ -61,22 +62,30 @@ public class BaseCloudLoadBalancersClientLiveTest extends BaseViewLiveTest(new LoadBalancerActive(client), 300, 1, 1,
- TimeUnit.SECONDS);
+ client = context.getApi();
+ injector = Guice.createInjector(new SLF4JLoggingModule());
+
+ loadBalancerActive = new RetryablePredicate(
+ new LoadBalancerActive(client), 300, 1, 1, TimeUnit.SECONDS);
injector.injectMembers(loadBalancerActive);
- loadBalancerDeleted = new RetryablePredicate(new LoadBalancerDeleted(client), 300, 1, 1,
- TimeUnit.SECONDS);
+
+ loadBalancerDeleted = new RetryablePredicate(
+ new LoadBalancerDeleted(client), 300, 1, 1, TimeUnit.SECONDS);
injector.injectMembers(loadBalancerDeleted);
+
+ Logger.getAnonymousLogger().info("running against zones " + client.getConfiguredZones());
}
@Override
- protected TypeToken viewType() {
- return TypeToken.of(LoadBalancerServiceContext.class);
+ protected Properties setupProperties() {
+ Properties props = super.setupProperties();
+ setIfTestSystemPropertyPresent(props, KeystoneProperties.CREDENTIAL_TYPE);
+ return props;
+ }
+
+ @Override
+ protected TypeToken> contextType() {
+ return CloudLoadBalancersApiMetadata.CONTEXT_TOKEN;
}
-
}
diff --git a/apis/cloudloadbalancers/src/test/resources/loadbalancer-create.json b/apis/cloudloadbalancers/src/test/resources/loadbalancer-create.json
new file mode 100644
index 0000000000..700df7a81a
--- /dev/null
+++ b/apis/cloudloadbalancers/src/test/resources/loadbalancer-create.json
@@ -0,0 +1,25 @@
+{
+ "loadBalancer": {
+ "virtualIps": [
+ {
+ "type": "PUBLIC"
+ }
+ ],
+ "name": "sample-loadbalancer",
+ "protocol": "HTTP",
+ "port": 80,
+ "algorithm": "RANDOM",
+ "nodes": [
+ {
+ "address": "10.1.1.1",
+ "port": 80,
+ "condition": "ENABLED"
+ },
+ {
+ "address": "10.1.1.2",
+ "port": 80,
+ "condition": "ENABLED"
+ }
+ ]
+ }
+}
\ No newline at end of file
diff --git a/apis/cloudloadbalancers/src/test/resources/getloadbalancer-deleted.json b/apis/cloudloadbalancers/src/test/resources/loadbalancer-get-deleted.json
similarity index 75%
rename from apis/cloudloadbalancers/src/test/resources/getloadbalancer-deleted.json
rename to apis/cloudloadbalancers/src/test/resources/loadbalancer-get-deleted.json
index d4bdf18562..fb71a6a06a 100644
--- a/apis/cloudloadbalancers/src/test/resources/getloadbalancer-deleted.json
+++ b/apis/cloudloadbalancers/src/test/resources/loadbalancer-get-deleted.json
@@ -1 +1 @@
-{"loadBalancer":{"name":"adriancole-LON","id":4865,"status":"DELETED","created":{"time":"2011-12-05T18:03:23Z"},"updated":{"time":"2011-12-05T18:04:04Z"}}}
\ No newline at end of file
+{"loadBalancer":{"name":"adriancole-LON","id":4865,"status":"DELETED","created":{"time":"2011-12-05T18:03:23Z"},"updated":{"time":"2011-12-05T18:04:04Z"},"nodeCount":0}}
\ No newline at end of file
diff --git a/apis/cloudloadbalancers/src/test/resources/getloadbalancer.json b/apis/cloudloadbalancers/src/test/resources/loadbalancer-get.json
similarity index 100%
rename from apis/cloudloadbalancers/src/test/resources/getloadbalancer.json
rename to apis/cloudloadbalancers/src/test/resources/loadbalancer-get.json
diff --git a/apis/cloudloadbalancers/src/test/resources/loadbalancer-update.json b/apis/cloudloadbalancers/src/test/resources/loadbalancer-update.json
new file mode 100644
index 0000000000..2f6138b083
--- /dev/null
+++ b/apis/cloudloadbalancers/src/test/resources/loadbalancer-update.json
@@ -0,0 +1,8 @@
+{
+ "loadBalancer": {
+ "name": "foo",
+ "protocol": "HTTPS",
+ "port": 443,
+ "algorithm": "RANDOM"
+ }
+}
\ No newline at end of file
diff --git a/apis/cloudloadbalancers/src/test/resources/listloadbalancers.json b/apis/cloudloadbalancers/src/test/resources/loadbalancers-list.json
similarity index 93%
rename from apis/cloudloadbalancers/src/test/resources/listloadbalancers.json
rename to apis/cloudloadbalancers/src/test/resources/loadbalancers-list.json
index 7bc3f855f9..6559d56154 100644
--- a/apis/cloudloadbalancers/src/test/resources/listloadbalancers.json
+++ b/apis/cloudloadbalancers/src/test/resources/loadbalancers-list.json
@@ -20,7 +20,8 @@
},
"updated":{
"time":"2010-11-30T03:23:44Z"
- }
+ },
+ "nodeCount":1
},
{
"name":"lb-site2",
@@ -42,7 +43,8 @@
},
"updated":{
"time":"2010-11-30T03:23:44Z"
- }
+ },
+ "nodeCount":1
}
]
}
\ No newline at end of file
diff --git a/apis/cloudloadbalancers/src/test/resources/log4j.xml b/apis/cloudloadbalancers/src/test/resources/log4j.xml
deleted file mode 100644
index 9d2dd7db2f..0000000000
--- a/apis/cloudloadbalancers/src/test/resources/log4j.xml
+++ /dev/null
@@ -1,155 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/apis/cloudloadbalancers/src/test/resources/getnode.json b/apis/cloudloadbalancers/src/test/resources/node-get.json
similarity index 67%
rename from apis/cloudloadbalancers/src/test/resources/getnode.json
rename to apis/cloudloadbalancers/src/test/resources/node-get.json
index f78881ea75..84bd73a415 100644
--- a/apis/cloudloadbalancers/src/test/resources/getnode.json
+++ b/apis/cloudloadbalancers/src/test/resources/node-get.json
@@ -4,6 +4,8 @@
"port":80,
"condition":"ENABLED",
"status":"ONLINE",
- "weight":12
+ "weight":12,
+ "type":"PRIMARY",
+ "metadata":[]
}
}
\ No newline at end of file
diff --git a/apis/cloudloadbalancers/src/test/resources/node-update.json b/apis/cloudloadbalancers/src/test/resources/node-update.json
new file mode 100644
index 0000000000..4bd42bd715
--- /dev/null
+++ b/apis/cloudloadbalancers/src/test/resources/node-update.json
@@ -0,0 +1 @@
+{"node":{"condition":"DISABLED","weight":20}}
\ No newline at end of file
diff --git a/apis/cloudloadbalancers/src/test/resources/nodes-add.json b/apis/cloudloadbalancers/src/test/resources/nodes-add.json
new file mode 100644
index 0000000000..e8010ad6d8
--- /dev/null
+++ b/apis/cloudloadbalancers/src/test/resources/nodes-add.json
@@ -0,0 +1 @@
+{"nodes":[{"address":"10.1.1.1","port":80,"condition":"ENABLED","weight":3},{"address":"10.1.1.2","port":80,"condition":"ENABLED","weight":8},{"address":"10.1.1.3","port":80,"condition":"DISABLED","weight":12}]}
\ No newline at end of file
diff --git a/apis/cloudloadbalancers/src/test/resources/listnodes.json b/apis/cloudloadbalancers/src/test/resources/nodes-list.json
similarity index 100%
rename from apis/cloudloadbalancers/src/test/resources/listnodes.json
rename to apis/cloudloadbalancers/src/test/resources/nodes-list.json
diff --git a/apis/rackspace-cloudidentity/src/main/java/org/jclouds/rackspace/cloudidentity/v2_0/ServiceType.java b/apis/rackspace-cloudidentity/src/main/java/org/jclouds/rackspace/cloudidentity/v2_0/ServiceType.java
new file mode 100644
index 0000000000..b79d631bad
--- /dev/null
+++ b/apis/rackspace-cloudidentity/src/main/java/org/jclouds/rackspace/cloudidentity/v2_0/ServiceType.java
@@ -0,0 +1,33 @@
+/**
+ * Licensed to jclouds, Inc. (jclouds) under one or more
+ * contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. jclouds 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.rackspace.cloudidentity.v2_0;
+
+/**
+ * An Rackspace service, such as Cloud Load Balancers, DNS, etc.
+ * A service provides one or more endpoints through which users can access resources and perform operations.
+ *
+ * @author Everett Toews
+ */
+public interface ServiceType {
+ /**
+ * Cloud Load Balancers
+ */
+ public static final String LOAD_BALANCERS = "rax:load-balancer";
+}
diff --git a/apis/rackspace-cloudidentity/src/test/java/org/jclouds/rackspace/cloudidentity/v2_0/internal/RackspaceFixture.java b/apis/rackspace-cloudidentity/src/test/java/org/jclouds/rackspace/cloudidentity/v2_0/internal/RackspaceFixture.java
new file mode 100644
index 0000000000..c689af34f2
--- /dev/null
+++ b/apis/rackspace-cloudidentity/src/test/java/org/jclouds/rackspace/cloudidentity/v2_0/internal/RackspaceFixture.java
@@ -0,0 +1,81 @@
+/**
+ * Licensed to jclouds, Inc. (jclouds) under one or more
+ * contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. jclouds 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.rackspace.cloudidentity.v2_0.internal;
+
+import static java.lang.String.format;
+import static org.jclouds.rest.internal.BaseRestApiExpectTest.payloadFromStringWithContentType;
+
+import java.io.IOException;
+
+import org.jclouds.http.HttpRequest;
+import org.jclouds.http.HttpResponse;
+import org.jclouds.io.Payload;
+import org.jclouds.util.Strings2;
+
+import com.google.common.base.Throwables;
+import com.google.common.net.HttpHeaders;
+
+/**
+ * @author Everett Toews
+ */
+public enum RackspaceFixture {
+ INSTANCE;
+
+ public String getTenantId() {
+ return "123123";
+ }
+
+ public String getTenantName() {
+ return "123123";
+ }
+
+ public HttpRequest initialAuthWithUsernameAndApiKey(String username, String apiKey) {
+ return HttpRequest
+ .builder()
+ .method("POST")
+ .endpoint("https://identity.api.rackspacecloud.com/v2.0/tokens")
+ .addHeader(HttpHeaders.ACCEPT, "application/json")
+ .payload(payloadFromStringWithContentType(
+ format("{\"auth\":{\"RAX-KSKEY:apiKeyCredentials\":{\"username\":\"%s\",\"apiKey\":\"%s\"}}}",
+ username, apiKey), "application/json")).build();
+ }
+
+ public String getAuthToken() {
+ return "cd562fe2-1f0f-43a7-a898-98cb8ede3eb3";
+ }
+
+ public HttpResponse responseWithAccess() {
+ return HttpResponse.builder()
+ .statusCode(200)
+ .message("HTTP/1.1 200")
+ .payload(payloadFromResourceWithContentType("/rackspaceAuthResponse.json", "application/json"))
+ .build();
+ }
+
+ public Payload payloadFromResourceWithContentType(String resource, String contentType) {
+ try {
+ return payloadFromStringWithContentType(
+ Strings2.toStringAndClose(getClass().getResourceAsStream(resource)), contentType);
+ }
+ catch (IOException e) {
+ throw Throwables.propagate(e);
+ }
+
+ }
+}
diff --git a/apis/rackspace-cloudidentity/src/test/resources/rackspaceAuthResponse.json b/apis/rackspace-cloudidentity/src/test/resources/rackspaceAuthResponse.json
new file mode 100644
index 0000000000..1a3d01d378
--- /dev/null
+++ b/apis/rackspace-cloudidentity/src/test/resources/rackspaceAuthResponse.json
@@ -0,0 +1,163 @@
+{
+ "access": {
+ "user": {
+ "RAX-AUTH:defaultRegion": "DFW",
+ "name": "user4jclouds",
+ "roles": [
+ {
+ "name": "identity:user-admin",
+ "description": "User Admin Role.",
+ "id": "3"
+ }
+ ],
+ "id": "224085"
+ },
+ "serviceCatalog": [
+ {
+ "type": "object-store",
+ "name": "cloudFiles",
+ "endpoints": [
+ {
+ "internalURL": "https://snet-storage101.dfw1.clouddrive.com/v1/MossoCloudFS_5bcf386e-39dd-45ff-93a1-712b9aba90a9",
+ "publicURL": "https://storage101.dfw1.clouddrive.com/v1/MossoCloudFS_5bcf386e-39dd-45ff-93a1-712b9aba90a9",
+ "tenantId": "MossoCloudFS_5bcf386e-39dd-45ff-93a1-712b9aba90a9",
+ "region": "DFW"
+ },
+ {
+ "internalURL": "https://snet-storage101.ord1.clouddrive.com/v1/MossoCloudFS_5bcf386e-39dd-45ff-93a1-712b9aba90a9",
+ "publicURL": "https://storage101.ord1.clouddrive.com/v1/MossoCloudFS_5bcf386e-39dd-45ff-93a1-712b9aba90a9",
+ "tenantId": "MossoCloudFS_5bcf386e-39dd-45ff-93a1-712b9aba90a9",
+ "region": "ORD"
+ }
+ ]
+ },
+ {
+ "type": "rax:load-balancer",
+ "name": "cloudLoadBalancers",
+ "endpoints": [
+ {
+ "publicURL": "https://ord.loadbalancers.api.rackspacecloud.com/v1.0/123123",
+ "tenantId": "123123",
+ "region": "ORD"
+ },
+ {
+ "publicURL": "https://dfw.loadbalancers.api.rackspacecloud.com/v1.0/123123",
+ "tenantId": "123123",
+ "region": "DFW"
+ }
+ ]
+ },
+ {
+ "type": "rax:dns",
+ "name": "cloudDNS",
+ "endpoints": [
+ {
+ "publicURL": "https://dns.api.rackspacecloud.com/v1.0/123123",
+ "tenantId": "123123"
+ }
+ ]
+ },
+ {
+ "type": "rax:database",
+ "name": "cloudDatabases",
+ "endpoints": [
+ {
+ "publicURL": "https://dfw.databases.api.rackspacecloud.com/v1.0/123123",
+ "tenantId": "123123",
+ "region": "DFW"
+ },
+ {
+ "publicURL": "https://ord.databases.api.rackspacecloud.com/v1.0/123123",
+ "tenantId": "123123",
+ "region": "ORD"
+ }
+ ]
+ },
+ {
+ "type": "rax:object-cdn",
+ "name": "cloudFilesCDN",
+ "endpoints": [
+ {
+ "publicURL": "https://cdn1.clouddrive.com/v1/MossoCloudFS_5bcf386e-39dd-45ff-93a1-712b9aba90a9",
+ "tenantId": "MossoCloudFS_5bcf386e-39dd-45ff-93a1-712b9aba90a9",
+ "region": "DFW"
+ },
+ {
+ "publicURL": "https://cdn2.clouddrive.com/v1/MossoCloudFS_5bcf386e-39dd-45ff-93a1-712b9aba90a9",
+ "tenantId": "MossoCloudFS_5bcf386e-39dd-45ff-93a1-712b9aba90a9",
+ "region": "ORD"
+ }
+ ]
+ },
+ {
+ "type": "rax:monitor",
+ "name": "cloudMonitoring",
+ "endpoints": [
+ {
+ "publicURL": "https://monitoring.api.rackspacecloud.com/v1.0/123123",
+ "tenantId": "123123"
+ }
+ ]
+ },
+ {
+ "type": "compute",
+ "name": "cloudServers",
+ "endpoints": [
+ {
+ "versionId": "1.0",
+ "versionList": "https://servers.api.rackspacecloud.com/",
+ "versionInfo": "https://servers.api.rackspacecloud.com/v1.0",
+ "publicURL": "https://servers.api.rackspacecloud.com/v1.0/123123",
+ "tenantId": "123123"
+ }
+ ]
+ },
+ {
+ "type": "compute",
+ "name": "cloudServersOpenStack",
+ "endpoints": [
+ {
+ "versionId": "2",
+ "versionList": "https://dfw.servers.api.rackspacecloud.com/",
+ "versionInfo": "https://dfw.servers.api.rackspacecloud.com/v2",
+ "publicURL": "https://dfw.servers.api.rackspacecloud.com/v2/123123",
+ "tenantId": "123123",
+ "region": "DFW"
+ },
+ {
+ "versionId": "2",
+ "versionList": "https://ord.servers.api.rackspacecloud.com/",
+ "versionInfo": "https://ord.servers.api.rackspacecloud.com/v2",
+ "publicURL": "https://ord.servers.api.rackspacecloud.com/v2/123123",
+ "tenantId": "123123",
+ "region": "ORD"
+ }
+ ]
+ },
+ {
+ "type": "volume",
+ "name": "cloudBlockStorage",
+ "endpoints": [
+ {
+ "publicURL": "https://ord.blockstorage.api.rackspacecloud.com/v1/123123",
+ "tenantId": "123123",
+ "region": "ORD"
+ },
+ {
+ "publicURL": "https://dfw.blockstorage.api.rackspacecloud.com/v1/123123",
+ "tenantId": "123123",
+ "region": "DFW"
+ }
+ ]
+ }
+ ],
+ "token": {
+ "tenant": {
+ "name": "123123",
+ "id": "123123"
+ },
+ "expires": "2012-12-01T17:07:47.000-06:00",
+ "id": "cd562fe2-1f0f-43a7-a898-98cb8ede3eb3"
+ }
+ }
+}
diff --git a/providers/cloudloadbalancers-uk/pom.xml b/providers/cloudloadbalancers-uk/pom.xml
index dab906d528..a2723f4269 100644
--- a/providers/cloudloadbalancers-uk/pom.xml
+++ b/providers/cloudloadbalancers-uk/pom.xml
@@ -34,9 +34,9 @@
bundle
- https://lon.auth.api.rackspacecloud.com
- 1.0
-
+ https://lon.identity.api.rackspacecloud.com/v2.0/
+ 1
+
${test.rackspace-uk.identity}
${test.rackspace-uk.credential}
@@ -45,6 +45,11 @@
+
+ org.jclouds
+ jclouds-loadbalancer
+ ${project.version}
+
org.jclouds.api
cloudloadbalancers
@@ -52,20 +57,20 @@
org.jclouds.api
- cloudloadbalancers
+ openstack-keystone
+ ${project.version}
+
+
+ org.jclouds.api
+ rackspace-cloudidentity
${project.version}
- test-jar
- test
org.jclouds
jclouds-loadbalancer
${project.version}
-
-
- org.jclouds.common
- openstack-common
- ${project.version}
+ test-jar
+ test
org.jclouds
@@ -75,25 +80,31 @@
test
- org.jclouds
- jclouds-loadbalancer
+ org.jclouds.api
+ cloudloadbalancers
${project.version}
test-jar
test
- org.jclouds.common
- openstack-common
+ org.jclouds.api
+ openstack-keystone
${project.version}
test-jar
test
org.jclouds.driver
- jclouds-log4j
+ jclouds-slf4j
${project.version}
test
+
+ ch.qos.logback
+ logback-classic
+ 1.0.7
+ test
+
@@ -117,6 +128,7 @@
${test.cloudloadbalancers-uk.build-version}
${test.cloudloadbalancers-uk.identity}
${test.cloudloadbalancers-uk.credential}
+ ${test.jclouds.keystone.credential-type}
diff --git a/providers/cloudloadbalancers-uk/src/main/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersUKProviderMetadata.java b/providers/cloudloadbalancers-uk/src/main/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersUKProviderMetadata.java
index fddc0c4c22..3f0757ccb7 100644
--- a/providers/cloudloadbalancers-uk/src/main/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersUKProviderMetadata.java
+++ b/providers/cloudloadbalancers-uk/src/main/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersUKProviderMetadata.java
@@ -18,21 +18,24 @@
*/
package org.jclouds.rackspace.cloudloadbalancers;
-import static org.jclouds.Constants.PROPERTY_API_VERSION;
-import static org.jclouds.Constants.PROPERTY_ENDPOINT;
-import static org.jclouds.Constants.PROPERTY_ISO3166_CODES;
import static org.jclouds.cloudloadbalancers.reference.Region.LON;
-import static org.jclouds.location.reference.LocationConstants.ENDPOINT;
import static org.jclouds.location.reference.LocationConstants.ISO3166_CODES;
-import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGION;
-import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGIONS;
+import static org.jclouds.location.reference.LocationConstants.PROPERTY_ZONE;
+import static org.jclouds.location.reference.LocationConstants.PROPERTY_ZONES;
import java.net.URI;
import java.util.Properties;
import org.jclouds.cloudloadbalancers.CloudLoadBalancersApiMetadata;
+import org.jclouds.cloudloadbalancers.config.CloudLoadBalancersRestClientModule;
+import org.jclouds.cloudloadbalancers.loadbalancer.config.CloudLoadBalancersLoadBalancerContextModule;
+import org.jclouds.openstack.keystone.v2_0.config.KeystoneAuthenticationModule.ZoneModule;
import org.jclouds.providers.ProviderMetadata;
import org.jclouds.providers.internal.BaseProviderMetadata;
+import org.jclouds.rackspace.cloudidentity.v2_0.config.CloudIdentityAuthenticationModule;
+
+import com.google.common.collect.ImmutableSet;
+import com.google.inject.Module;
/**
* Implementation of {@link org.jclouds.types.ProviderMetadata} for Rackspace Cloud LoadBalancers UK.
@@ -63,12 +66,8 @@ public class CloudLoadBalancersUKProviderMetadata extends BaseProviderMetadata {
public static Properties defaultProperties() {
Properties properties = new Properties();
- properties.setProperty(PROPERTY_REGIONS, LON);
- properties.setProperty(PROPERTY_ENDPOINT, "https://lon.auth.api.rackspacecloud.com");
- properties.setProperty(PROPERTY_ISO3166_CODES, "GB-SLG");
- properties.setProperty(PROPERTY_REGION + "." + LON + "." + ISO3166_CODES, "GB-SLG");
- properties.setProperty(PROPERTY_REGION + "." + LON + "." + ENDPOINT,
- String.format("https://lon.loadbalancers.api.rackspacecloud.com/v${%s}", PROPERTY_API_VERSION));
+ properties.setProperty(PROPERTY_ZONES, LON);
+ properties.setProperty(PROPERTY_ZONE + ".LON." + ISO3166_CODES, "GB-SLG");
return properties;
}
public static class Builder extends BaseProviderMetadata.Builder {
@@ -76,12 +75,26 @@ public class CloudLoadBalancersUKProviderMetadata extends BaseProviderMetadata {
protected Builder(){
id("cloudloadbalancers-uk")
.name("Rackspace Cloud Load Balancers UK")
- .apiMetadata(new CloudLoadBalancersApiMetadata())
- .homepage(URI.create("http://www.rackspace.co.uk/cloud-hosting/cloud-products/cloud-load-balancers"))
- .console(URI.create("https://lon.manage.rackspacecloud.com"))
- .linkedServices("cloudloadbalancers-uk", "cloudservers-uk", "cloudfiles-uk")
+ .apiMetadata(new CloudLoadBalancersApiMetadata().toBuilder()
+ .identityName("${userName}")
+ .credentialName("${apiKey}")
+ .version("1.0")
+ .defaultEndpoint("https://lon.identity.api.rackspacecloud.com/v2.0/")
+ .endpointName("Identity service URL ending in /v2.0/")
+ .documentation(URI.create("http://docs.rackspace.com/loadbalancers/api/clb-devguide-latest/index.html"))
+ .defaultModules(ImmutableSet.>builder()
+ .add(CloudIdentityAuthenticationModule.class)
+ .add(ZoneModule.class)
+ .add(CloudLoadBalancersRestClientModule.class)
+ .add(CloudLoadBalancersLoadBalancerContextModule.class)
+ .build())
+ .build())
+ .homepage(URI.create("http://www.rackspace.co.uk/cloud-load-balancers/"))
+ .console(URI.create("https://mycloud.rackspace.co.uk"))
+ .linkedServices("rackspace-cloudservers-uk", "cloudfiles-uk", "rackspace-cloudblockstorage-uk")
.iso3166Codes("GB-SLG")
- .endpoint("https://lon.auth.api.rackspacecloud.com");
+ .endpoint("https://lon.identity.api.rackspacecloud.com/v2.0/")
+ .defaultProperties(CloudLoadBalancersApiMetadata.defaultProperties());
}
@Override
@@ -96,4 +109,4 @@ public class CloudLoadBalancersUKProviderMetadata extends BaseProviderMetadata {
return this;
}
}
-}
\ No newline at end of file
+}
diff --git a/providers/cloudloadbalancers-uk/src/test/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersUKLoadBalancerClientLiveTest.java b/providers/cloudloadbalancers-uk/src/test/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersUKLoadBalancerClientLiveTest.java
index 8f2f6d2892..ce9cdd6742 100644
--- a/providers/cloudloadbalancers-uk/src/test/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersUKLoadBalancerClientLiveTest.java
+++ b/providers/cloudloadbalancers-uk/src/test/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersUKLoadBalancerClientLiveTest.java
@@ -25,10 +25,9 @@ import org.testng.annotations.Test;
*
* @author Dan Lo Bianco
*/
-@Test(groups = "live", singleThreaded = true)
+@Test(groups = "live", singleThreaded = true, testName = "CloudLoadBalancersUKLoadBalancerClientLiveTest")
public class CloudLoadBalancersUKLoadBalancerClientLiveTest extends LoadBalancerClientLiveTest {
public CloudLoadBalancersUKLoadBalancerClientLiveTest() {
provider = "cloudloadbalancers-uk";
- regions = new String[] { "LON" };
}
}
diff --git a/providers/cloudloadbalancers-uk/src/test/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersUKNodeClientLiveTest.java b/providers/cloudloadbalancers-uk/src/test/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersUKNodeClientLiveTest.java
index 6de0b4ed92..7f17b39bf6 100644
--- a/providers/cloudloadbalancers-uk/src/test/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersUKNodeClientLiveTest.java
+++ b/providers/cloudloadbalancers-uk/src/test/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersUKNodeClientLiveTest.java
@@ -25,7 +25,7 @@ import org.testng.annotations.Test;
*
* @author Dan Lo Bianco
*/
-@Test(groups = "live", singleThreaded = true)
+@Test(groups = "live", singleThreaded = true, testName = "CloudLoadBalancersUKNodeClientLiveTest")
public class CloudLoadBalancersUKNodeClientLiveTest extends NodeClientLiveTest {
public CloudLoadBalancersUKNodeClientLiveTest() {
provider = "cloudloadbalancers-uk";
diff --git a/providers/cloudloadbalancers-us/pom.xml b/providers/cloudloadbalancers-us/pom.xml
index 96944ec65b..f35e51e0cc 100644
--- a/providers/cloudloadbalancers-us/pom.xml
+++ b/providers/cloudloadbalancers-us/pom.xml
@@ -34,9 +34,9 @@
bundle
- https://auth.api.rackspacecloud.com
- 1.0
-
+ https://identity.api.rackspacecloud.com/v2.0/
+ 1
+
${test.rackspace-us.identity}
${test.rackspace-us.credential}
@@ -45,6 +45,11 @@
+
+ org.jclouds
+ jclouds-loadbalancer
+ ${project.version}
+
org.jclouds.api
cloudloadbalancers
@@ -52,19 +57,12 @@
org.jclouds.api
- cloudloadbalancers
- ${project.version}
- test-jar
- test
-
-
- org.jclouds
- jclouds-loadbalancer
+ openstack-keystone
${project.version}
- org.jclouds.common
- openstack-common
+ org.jclouds.api
+ rackspace-cloudidentity
${project.version}
@@ -82,18 +80,31 @@
test
- org.jclouds.common
- openstack-common
+ org.jclouds.api
+ cloudloadbalancers
+ ${project.version}
+ test-jar
+ test
+
+
+ org.jclouds.api
+ openstack-keystone
${project.version}
test-jar
test
org.jclouds.driver
- jclouds-log4j
+ jclouds-slf4j
${project.version}
test
+
+ ch.qos.logback
+ logback-classic
+ 1.0.7
+ test
+
@@ -117,6 +128,7 @@
${test.cloudloadbalancers-us.build-version}
${test.cloudloadbalancers-us.identity}
${test.cloudloadbalancers-us.credential}
+ ${test.jclouds.keystone.credential-type}
diff --git a/providers/cloudloadbalancers-us/src/main/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersUSProviderMetadata.java b/providers/cloudloadbalancers-us/src/main/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersUSProviderMetadata.java
index 198e632a1b..9f1de88406 100644
--- a/providers/cloudloadbalancers-us/src/main/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersUSProviderMetadata.java
+++ b/providers/cloudloadbalancers-us/src/main/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersUSProviderMetadata.java
@@ -18,24 +18,23 @@
*/
package org.jclouds.rackspace.cloudloadbalancers;
-import static org.jclouds.Constants.PROPERTY_API_VERSION;
-import static org.jclouds.Constants.PROPERTY_ENDPOINT;
-import static org.jclouds.Constants.PROPERTY_ISO3166_CODES;
-import static org.jclouds.cloudloadbalancers.reference.Region.DFW;
-import static org.jclouds.cloudloadbalancers.reference.Region.ORD;
-import static org.jclouds.location.reference.LocationConstants.ENDPOINT;
import static org.jclouds.location.reference.LocationConstants.ISO3166_CODES;
-import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGION;
-import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGIONS;
+import static org.jclouds.location.reference.LocationConstants.PROPERTY_ZONE;
+import static org.jclouds.location.reference.LocationConstants.PROPERTY_ZONES;
import java.net.URI;
import java.util.Properties;
import org.jclouds.cloudloadbalancers.CloudLoadBalancersApiMetadata;
+import org.jclouds.cloudloadbalancers.config.CloudLoadBalancersRestClientModule;
+import org.jclouds.cloudloadbalancers.loadbalancer.config.CloudLoadBalancersLoadBalancerContextModule;
+import org.jclouds.openstack.keystone.v2_0.config.KeystoneAuthenticationModule.ZoneModule;
import org.jclouds.providers.ProviderMetadata;
import org.jclouds.providers.internal.BaseProviderMetadata;
+import org.jclouds.rackspace.cloudidentity.v2_0.config.CloudIdentityAuthenticationModule;
-import com.google.common.base.Joiner;
+import com.google.common.collect.ImmutableSet;
+import com.google.inject.Module;
/**
* Implementation of {@link org.jclouds.types.ProviderMetadata} for Rackspace Cloud LoadBalancers US.
@@ -63,21 +62,12 @@ public class CloudLoadBalancersUSProviderMetadata extends BaseProviderMetadata {
public CloudLoadBalancersUSProviderMetadata(Builder builder) {
super(builder);
}
- public static final String[] REGIONS = {ORD, DFW};
public static Properties defaultProperties() {
Properties properties = new Properties();
- properties.setProperty(PROPERTY_ENDPOINT, "https://auth.api.rackspacecloud.com");
- properties.setProperty(PROPERTY_REGIONS, Joiner.on(',').join(REGIONS));
- properties.setProperty(PROPERTY_ISO3166_CODES, "US-IL,US-TX");
-
- properties.setProperty(PROPERTY_REGION + "." + ORD + "." + ISO3166_CODES, "US-IL");
- properties.setProperty(PROPERTY_REGION + "." + ORD + "." + ENDPOINT, String
- .format("https://ord.loadbalancers.api.rackspacecloud.com/v${%s}", PROPERTY_API_VERSION));
-
- properties.setProperty(PROPERTY_REGION + "." + DFW + "." + ISO3166_CODES, "US-TX");
- properties.setProperty(PROPERTY_REGION + "." + DFW + "." + ENDPOINT, String
- .format("https://dfw.loadbalancers.api.rackspacecloud.com/v${%s}", PROPERTY_API_VERSION));
+ properties.setProperty(PROPERTY_ZONES, "ORD,DFW");
+ properties.setProperty(PROPERTY_ZONE + ".ORD." + ISO3166_CODES, "US-IL");
+ properties.setProperty(PROPERTY_ZONE + ".DFW." + ISO3166_CODES, "US-TX");
return properties;
}
@@ -86,12 +76,26 @@ public class CloudLoadBalancersUSProviderMetadata extends BaseProviderMetadata {
protected Builder(){
id("cloudloadbalancers-us")
.name("Rackspace Cloud Load Balancers US")
- .apiMetadata(new CloudLoadBalancersApiMetadata())
- .homepage(URI.create("http://www.rackspace.com/cloud/cloud_hosting_products/loadbalancers"))
- .console(URI.create("https://manage.rackspacecloud.com"))
- .linkedServices("cloudloadbalancers-us", "cloudservers-us", "cloudfiles-us")
- .iso3166Codes("US-IL","US-TX")
- .endpoint("https://auth.api.rackspacecloud.com");
+ .apiMetadata(new CloudLoadBalancersApiMetadata().toBuilder()
+ .identityName("${userName}")
+ .credentialName("${apiKey}")
+ .version("1.0")
+ .defaultEndpoint("https://identity.api.rackspacecloud.com/v2.0/")
+ .endpointName("Identity service URL ending in /v2.0/")
+ .documentation(URI.create("http://docs.rackspace.com/loadbalancers/api/clb-devguide-latest/index.html"))
+ .defaultModules(ImmutableSet.>builder()
+ .add(CloudIdentityAuthenticationModule.class)
+ .add(ZoneModule.class)
+ .add(CloudLoadBalancersRestClientModule.class)
+ .add(CloudLoadBalancersLoadBalancerContextModule.class)
+ .build())
+ .build())
+ .homepage(URI.create("http://www.rackspace.com/cloud/public/loadbalancers/"))
+ .console(URI.create("https://mycloud.rackspace.com"))
+ .linkedServices("rackspace-cloudservers-us", "cloudfiles-us", "rackspace-cloudblockstorage-us")
+ .iso3166Codes("US-IL", "US-TX")
+ .endpoint("https://identity.api.rackspacecloud.com/v2.0/")
+ .defaultProperties(CloudLoadBalancersApiMetadata.defaultProperties());
}
@Override
@@ -106,4 +110,4 @@ public class CloudLoadBalancersUSProviderMetadata extends BaseProviderMetadata {
return this;
}
}
-}
\ No newline at end of file
+}
diff --git a/providers/cloudloadbalancers-us/src/test/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersUSLoadBalancerClientLiveTest.java b/providers/cloudloadbalancers-us/src/test/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersUSLoadBalancerClientLiveTest.java
index 31c17ffd8a..9b85f31804 100644
--- a/providers/cloudloadbalancers-us/src/test/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersUSLoadBalancerClientLiveTest.java
+++ b/providers/cloudloadbalancers-us/src/test/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersUSLoadBalancerClientLiveTest.java
@@ -25,10 +25,9 @@ import org.testng.annotations.Test;
*
* @author Dan Lo Bianco
*/
-@Test(groups = "live", singleThreaded = true)
+@Test(groups = "live", singleThreaded = true, testName = "CloudLoadBalancersUSLoadBalancerClientLiveTest")
public class CloudLoadBalancersUSLoadBalancerClientLiveTest extends LoadBalancerClientLiveTest {
public CloudLoadBalancersUSLoadBalancerClientLiveTest() {
provider = "cloudloadbalancers-us";
- regions = CloudLoadBalancersUSProviderMetadata.REGIONS;
}
}
diff --git a/providers/cloudloadbalancers-us/src/test/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersUSNodeClientLiveTest.java b/providers/cloudloadbalancers-us/src/test/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersUSNodeClientLiveTest.java
index 7ca7f2d8be..f56a941a58 100644
--- a/providers/cloudloadbalancers-us/src/test/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersUSNodeClientLiveTest.java
+++ b/providers/cloudloadbalancers-us/src/test/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersUSNodeClientLiveTest.java
@@ -25,7 +25,7 @@ import org.testng.annotations.Test;
*
* @author Dan Lo Bianco
*/
-@Test(groups = "live", singleThreaded = true)
+@Test(groups = "live", singleThreaded = true, testName = "CloudLoadBalancersUSNodeClientLiveTest")
public class CloudLoadBalancersUSNodeClientLiveTest extends NodeClientLiveTest {
public CloudLoadBalancersUSNodeClientLiveTest() {
provider = "cloudloadbalancers-us";
diff --git a/providers/rackspace-cloudservers-us/src/main/java/org/jclouds/rackspace/cloudservers/us/CloudServersUSProviderMetadata.java b/providers/rackspace-cloudservers-us/src/main/java/org/jclouds/rackspace/cloudservers/us/CloudServersUSProviderMetadata.java
index 845b3d2650..9740a986ac 100644
--- a/providers/rackspace-cloudservers-us/src/main/java/org/jclouds/rackspace/cloudservers/us/CloudServersUSProviderMetadata.java
+++ b/providers/rackspace-cloudservers-us/src/main/java/org/jclouds/rackspace/cloudservers/us/CloudServersUSProviderMetadata.java
@@ -86,7 +86,7 @@ public class CloudServersUSProviderMetadata extends BaseProviderMetadata {
.version("2")
.defaultEndpoint("https://identity.api.rackspacecloud.com/v2.0/")
.endpointName("identity service url ending in /v2.0/")
- .documentation(URI.create("http://docs.rackspace.com/servers/api/v2/cs-devguide/content/ch_preface.html#webhelp-currentid"))
+ .documentation(URI.create("http://docs.rackspace.com/loadbalancers/api/v1.0/clb-devguide/content/index.html"))
.defaultModules(ImmutableSet.>builder()
.add(CloudIdentityAuthenticationModule.class)
.add(ZoneModule.class)