mirror of https://github.com/apache/jclouds.git
Bringing Rackspace Cloud Load Balancers back to working condition. Fixed auth, zones, tests, bugs, logging, and dependencies.
This commit is contained in:
parent
d9aaf94bd7
commit
1f1050777c
|
@ -34,8 +34,8 @@
|
||||||
<packaging>bundle</packaging>
|
<packaging>bundle</packaging>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<test.cloudloadbalancers.endpoint>https://auth.api.rackspacecloud.com</test.cloudloadbalancers.endpoint>
|
<test.cloudloadbalancers.endpoint>https://identity.api.rackspacecloud.com/v2.0/</test.cloudloadbalancers.endpoint>
|
||||||
<test.cloudloadbalancers.api-version>1.0</test.cloudloadbalancers.api-version>
|
<test.cloudloadbalancers.api-version>1</test.cloudloadbalancers.api-version>
|
||||||
<test.cloudloadbalancers.build-version></test.cloudloadbalancers.build-version>
|
<test.cloudloadbalancers.build-version></test.cloudloadbalancers.build-version>
|
||||||
<test.cloudloadbalancers.identity>${test.rackspace.identity}</test.cloudloadbalancers.identity>
|
<test.cloudloadbalancers.identity>${test.rackspace.identity}</test.cloudloadbalancers.identity>
|
||||||
<test.cloudloadbalancers.credential>${test.rackspace.credential}</test.cloudloadbalancers.credential>
|
<test.cloudloadbalancers.credential>${test.rackspace.credential}</test.cloudloadbalancers.credential>
|
||||||
|
@ -50,8 +50,13 @@
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.jclouds.common</groupId>
|
<groupId>org.jclouds.api</groupId>
|
||||||
<artifactId>openstack-common</artifactId>
|
<artifactId>openstack-keystone</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jclouds.api</groupId>
|
||||||
|
<artifactId>rackspace-cloudidentity</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -69,18 +74,30 @@
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.jclouds.common</groupId>
|
<groupId>org.jclouds.api</groupId>
|
||||||
<artifactId>openstack-common</artifactId>
|
<artifactId>openstack-keystone</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
<type>test-jar</type>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jclouds.api</groupId>
|
||||||
|
<artifactId>rackspace-cloudidentity</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
<type>test-jar</type>
|
<type>test-jar</type>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.jclouds.driver</groupId>
|
<groupId>org.jclouds.driver</groupId>
|
||||||
<artifactId>jclouds-log4j</artifactId>
|
<artifactId>jclouds-slf4j</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>ch.qos.logback</groupId>
|
||||||
|
<artifactId>logback-classic</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<profiles>
|
<profiles>
|
||||||
<profile>
|
<profile>
|
||||||
|
@ -104,6 +121,7 @@
|
||||||
<test.cloudloadbalancers.build-version>${test.cloudloadbalancers.build-version}</test.cloudloadbalancers.build-version>
|
<test.cloudloadbalancers.build-version>${test.cloudloadbalancers.build-version}</test.cloudloadbalancers.build-version>
|
||||||
<test.cloudloadbalancers.identity>${test.cloudloadbalancers.identity}</test.cloudloadbalancers.identity>
|
<test.cloudloadbalancers.identity>${test.cloudloadbalancers.identity}</test.cloudloadbalancers.identity>
|
||||||
<test.cloudloadbalancers.credential>${test.cloudloadbalancers.credential}</test.cloudloadbalancers.credential>
|
<test.cloudloadbalancers.credential>${test.cloudloadbalancers.credential}</test.cloudloadbalancers.credential>
|
||||||
|
<test.jclouds.keystone.credential-type>${test.jclouds.keystone.credential-type}</test.jclouds.keystone.credential-type>
|
||||||
</systemPropertyVariables>
|
</systemPropertyVariables>
|
||||||
</configuration>
|
</configuration>
|
||||||
</execution>
|
</execution>
|
||||||
|
|
|
@ -18,6 +18,9 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.cloudloadbalancers;
|
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.net.URI;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
|
@ -25,6 +28,10 @@ import org.jclouds.apis.ApiMetadata;
|
||||||
import org.jclouds.cloudloadbalancers.config.CloudLoadBalancersRestClientModule;
|
import org.jclouds.cloudloadbalancers.config.CloudLoadBalancersRestClientModule;
|
||||||
import org.jclouds.cloudloadbalancers.loadbalancer.config.CloudLoadBalancersLoadBalancerContextModule;
|
import org.jclouds.cloudloadbalancers.loadbalancer.config.CloudLoadBalancersLoadBalancerContextModule;
|
||||||
import org.jclouds.loadbalancer.LoadBalancerServiceContext;
|
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.RestContext;
|
||||||
import org.jclouds.rest.internal.BaseRestApiMetadata;
|
import org.jclouds.rest.internal.BaseRestApiMetadata;
|
||||||
|
|
||||||
|
@ -37,10 +44,10 @@ import com.google.inject.Module;
|
||||||
*
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
public class CloudLoadBalancersApiMetadata extends BaseRestApiMetadata {
|
public class CloudLoadBalancersApiMetadata extends BaseRestApiMetadata {
|
||||||
|
|
||||||
public static final TypeToken<RestContext<CloudLoadBalancersClient, CloudLoadBalancersAsyncClient>> CONTEXT_TOKEN = new TypeToken<RestContext<CloudLoadBalancersClient, CloudLoadBalancersAsyncClient>>() {
|
public static final TypeToken<RestContext<CloudLoadBalancersClient, CloudLoadBalancersAsyncClient>> CONTEXT_TOKEN =
|
||||||
};
|
new TypeToken<RestContext<CloudLoadBalancersClient, CloudLoadBalancersAsyncClient>>() {};
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Builder toBuilder() {
|
public Builder toBuilder() {
|
||||||
|
@ -57,6 +64,10 @@ public class CloudLoadBalancersApiMetadata extends BaseRestApiMetadata {
|
||||||
|
|
||||||
public static Properties defaultProperties() {
|
public static Properties defaultProperties() {
|
||||||
Properties properties = BaseRestApiMetadata.defaultProperties();
|
Properties properties = BaseRestApiMetadata.defaultProperties();
|
||||||
|
|
||||||
|
properties.setProperty(SERVICE_TYPE, ServiceType.LOAD_BALANCERS);
|
||||||
|
properties.setProperty(CREDENTIAL_TYPE, CloudIdentityCredentialTypes.API_KEY_CREDENTIALS);
|
||||||
|
|
||||||
return properties;
|
return properties;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,15 +76,21 @@ public class CloudLoadBalancersApiMetadata extends BaseRestApiMetadata {
|
||||||
protected Builder() {
|
protected Builder() {
|
||||||
super(CloudLoadBalancersClient.class, CloudLoadBalancersAsyncClient.class);
|
super(CloudLoadBalancersClient.class, CloudLoadBalancersAsyncClient.class);
|
||||||
id("cloudloadbalancers")
|
id("cloudloadbalancers")
|
||||||
.name("Rackspace Cloud Load Balancers API")
|
.name("Rackspace Cloud Load Balancers API")
|
||||||
.identityName("Username")
|
.identityName("Username")
|
||||||
.credentialName("API Key")
|
.credentialName("API Key")
|
||||||
.documentation(URI.create("http://docs.rackspacecloud.com/loadbalancers/api/v1.0/clb-devguide/content/ch01.html"))
|
.documentation(
|
||||||
.version("1.0")
|
URI.create("http://docs.rackspace.com/loadbalancers/api/clb-devguide-latest/index.html"))
|
||||||
.defaultEndpoint("https://auth.api.rackspacecloud.com")
|
.version("1.0")
|
||||||
.defaultProperties(CloudLoadBalancersApiMetadata.defaultProperties())
|
.defaultEndpoint("https://identity.api.rackspacecloud.com/v2.0/")
|
||||||
.view(TypeToken.of(LoadBalancerServiceContext.class))
|
.defaultProperties(CloudLoadBalancersApiMetadata.defaultProperties())
|
||||||
.defaultModules(ImmutableSet.<Class<? extends Module>>of(CloudLoadBalancersRestClientModule.class, CloudLoadBalancersLoadBalancerContextModule.class));
|
.view(TypeToken.of(LoadBalancerServiceContext.class))
|
||||||
|
.defaultModules(
|
||||||
|
ImmutableSet.<Class<? extends Module>> of(
|
||||||
|
CloudIdentityAuthenticationModule.class,
|
||||||
|
ZoneModule.class,
|
||||||
|
CloudLoadBalancersRestClientModule.class,
|
||||||
|
CloudLoadBalancersLoadBalancerContextModule.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -22,8 +22,9 @@ import java.util.Set;
|
||||||
|
|
||||||
import org.jclouds.cloudloadbalancers.features.LoadBalancerAsyncClient;
|
import org.jclouds.cloudloadbalancers.features.LoadBalancerAsyncClient;
|
||||||
import org.jclouds.cloudloadbalancers.features.NodeAsyncClient;
|
import org.jclouds.cloudloadbalancers.features.NodeAsyncClient;
|
||||||
import org.jclouds.location.Region;
|
import org.jclouds.javax.annotation.Nullable;
|
||||||
import org.jclouds.location.functions.RegionToEndpointOrProviderIfNull;
|
import org.jclouds.location.Zone;
|
||||||
|
import org.jclouds.location.functions.ZoneToEndpoint;
|
||||||
import org.jclouds.rest.annotations.Delegate;
|
import org.jclouds.rest.annotations.Delegate;
|
||||||
import org.jclouds.rest.annotations.EndpointParam;
|
import org.jclouds.rest.annotations.EndpointParam;
|
||||||
|
|
||||||
|
@ -34,33 +35,28 @@ import com.google.inject.Provides;
|
||||||
* <p/>
|
* <p/>
|
||||||
*
|
*
|
||||||
* @see CloudLoadBalancersClient
|
* @see CloudLoadBalancersClient
|
||||||
* @see <a
|
|
||||||
* href="http://docs.rackspacecloud.com/loadbalancers/api/v1.0/clb-devguide/content/ch04s01.html"
|
|
||||||
* />
|
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
public interface CloudLoadBalancersAsyncClient {
|
public interface CloudLoadBalancersAsyncClient {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* @return the Zone codes configured
|
||||||
* @return the region codes configured
|
|
||||||
*/
|
*/
|
||||||
@Provides
|
@Provides
|
||||||
@Region
|
@Zone
|
||||||
Set<String> getConfiguredRegions();
|
Set<String> getConfiguredZones();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides asynchronous access to LoadBalancer features.
|
* Provides asynchronous access to LoadBalancer features.
|
||||||
*/
|
*/
|
||||||
@Delegate
|
@Delegate
|
||||||
LoadBalancerAsyncClient getLoadBalancerClient(
|
LoadBalancerAsyncClient getLoadBalancerClient(
|
||||||
@EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) String region);
|
@EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides asynchronous access to Node features.
|
* Provides asynchronous access to Node features.
|
||||||
*/
|
*/
|
||||||
@Delegate
|
@Delegate
|
||||||
NodeAsyncClient getNodeClient(
|
NodeAsyncClient getNodeClient(
|
||||||
@EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) String region);
|
@EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,8 +24,9 @@ import java.util.concurrent.TimeUnit;
|
||||||
import org.jclouds.cloudloadbalancers.features.LoadBalancerClient;
|
import org.jclouds.cloudloadbalancers.features.LoadBalancerClient;
|
||||||
import org.jclouds.cloudloadbalancers.features.NodeClient;
|
import org.jclouds.cloudloadbalancers.features.NodeClient;
|
||||||
import org.jclouds.concurrent.Timeout;
|
import org.jclouds.concurrent.Timeout;
|
||||||
import org.jclouds.location.Region;
|
import org.jclouds.javax.annotation.Nullable;
|
||||||
import org.jclouds.location.functions.RegionToEndpointOrProviderIfNull;
|
import org.jclouds.location.Zone;
|
||||||
|
import org.jclouds.location.functions.ZoneToEndpoint;
|
||||||
import org.jclouds.rest.annotations.Delegate;
|
import org.jclouds.rest.annotations.Delegate;
|
||||||
import org.jclouds.rest.annotations.EndpointParam;
|
import org.jclouds.rest.annotations.EndpointParam;
|
||||||
|
|
||||||
|
@ -36,33 +37,29 @@ import com.google.inject.Provides;
|
||||||
* <p/>
|
* <p/>
|
||||||
*
|
*
|
||||||
* @see CloudLoadBalancersAsyncClient
|
* @see CloudLoadBalancersAsyncClient
|
||||||
* @see <a
|
|
||||||
* href="http://docs.rackspacecloud.com/loadbalancers/api/v1.0/clb-devguide/content/ch04s01.html"
|
|
||||||
* />
|
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Timeout(duration = 60, timeUnit = TimeUnit.SECONDS)
|
@Timeout(duration = 60, timeUnit = TimeUnit.SECONDS)
|
||||||
public interface CloudLoadBalancersClient {
|
public interface CloudLoadBalancersClient {
|
||||||
/**
|
/**
|
||||||
*
|
* @return the Zone codes configured
|
||||||
* @return the region codes configured
|
|
||||||
*/
|
*/
|
||||||
@Provides
|
@Provides
|
||||||
@Region
|
@Zone
|
||||||
Set<String> getConfiguredRegions();
|
Set<String> getConfiguredZones();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides synchronous access to LoadBalancer features.
|
* Provides synchronous access to LoadBalancer features.
|
||||||
*/
|
*/
|
||||||
@Delegate
|
@Delegate
|
||||||
LoadBalancerClient getLoadBalancerClient(
|
LoadBalancerClient getLoadBalancerClient(
|
||||||
@EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) String region);
|
@EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides synchronous access to Node features.
|
* Provides synchronous access to Node features.
|
||||||
*/
|
*/
|
||||||
@Delegate
|
@Delegate
|
||||||
NodeClient getNodeClient(
|
NodeClient getNodeClient(
|
||||||
@EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) String region);
|
@EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,14 +18,8 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.cloudloadbalancers.config;
|
package org.jclouds.cloudloadbalancers.config;
|
||||||
|
|
||||||
import static org.jclouds.util.Suppliers2.getLastValueInMap;
|
|
||||||
|
|
||||||
import java.net.URI;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import javax.inject.Named;
|
|
||||||
import javax.inject.Singleton;
|
|
||||||
|
|
||||||
import org.jclouds.cloudloadbalancers.CloudLoadBalancersAsyncClient;
|
import org.jclouds.cloudloadbalancers.CloudLoadBalancersAsyncClient;
|
||||||
import org.jclouds.cloudloadbalancers.CloudLoadBalancersClient;
|
import org.jclouds.cloudloadbalancers.CloudLoadBalancersClient;
|
||||||
import org.jclouds.cloudloadbalancers.features.LoadBalancerAsyncClient;
|
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.features.NodeClient;
|
||||||
import org.jclouds.cloudloadbalancers.functions.ConvertLB;
|
import org.jclouds.cloudloadbalancers.functions.ConvertLB;
|
||||||
import org.jclouds.cloudloadbalancers.handlers.ParseCloudLoadBalancersErrorFromHttpResponse;
|
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.HttpErrorHandler;
|
||||||
import org.jclouds.http.annotation.ClientError;
|
import org.jclouds.http.annotation.ClientError;
|
||||||
import org.jclouds.http.annotation.Redirection;
|
import org.jclouds.http.annotation.Redirection;
|
||||||
import org.jclouds.http.annotation.ServerError;
|
import org.jclouds.http.annotation.ServerError;
|
||||||
import org.jclouds.json.config.GsonModule.DateAdapter;
|
import org.jclouds.json.config.GsonModule.DateAdapter;
|
||||||
import org.jclouds.json.config.GsonModule.Iso8601DateAdapter;
|
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.ConfiguresRestClient;
|
||||||
import org.jclouds.rest.annotations.ApiVersion;
|
|
||||||
import org.jclouds.rest.config.RestClientModule;
|
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.common.collect.ImmutableMap;
|
||||||
import com.google.inject.AbstractModule;
|
|
||||||
import com.google.inject.Provides;
|
|
||||||
import com.google.inject.Scopes;
|
|
||||||
import com.google.inject.assistedinject.FactoryModuleBuilder;
|
import com.google.inject.assistedinject.FactoryModuleBuilder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -67,49 +49,15 @@ import com.google.inject.assistedinject.FactoryModuleBuilder;
|
||||||
public class CloudLoadBalancersRestClientModule extends
|
public class CloudLoadBalancersRestClientModule extends
|
||||||
RestClientModule<CloudLoadBalancersClient, CloudLoadBalancersAsyncClient> {
|
RestClientModule<CloudLoadBalancersClient, CloudLoadBalancersAsyncClient> {
|
||||||
|
|
||||||
public static final Map<Class<?>, Class<?>> DELEGATE_MAP = ImmutableMap.<Class<?>, Class<?>> builder()//
|
public static final Map<Class<?>, Class<?>> DELEGATE_MAP = ImmutableMap.<Class<?>, Class<?>> builder()
|
||||||
.put(LoadBalancerClient.class, LoadBalancerAsyncClient.class)//
|
.put(LoadBalancerClient.class, LoadBalancerAsyncClient.class)
|
||||||
.put(NodeClient.class, NodeAsyncClient.class)//
|
.put(NodeClient.class, NodeAsyncClient.class)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
public CloudLoadBalancersRestClientModule() {
|
public CloudLoadBalancersRestClientModule() {
|
||||||
super(DELEGATE_MAP);
|
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<String> accountID(RegionIdToURISupplier.Factory factory, @ApiVersion String apiVersion) {
|
|
||||||
return Suppliers2.compose(new Function<URI, String>() {
|
|
||||||
|
|
||||||
@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
|
@Override
|
||||||
protected void configure() {
|
protected void configure() {
|
||||||
bind(DateAdapter.class).to(Iso8601DateAdapter.class);
|
bind(DateAdapter.class).to(Iso8601DateAdapter.class);
|
||||||
|
|
|
@ -25,16 +25,16 @@ import java.util.Date;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.jclouds.cloudloadbalancers.domain.internal.BaseLoadBalancer;
|
import org.jclouds.cloudloadbalancers.domain.internal.BaseLoadBalancer;
|
||||||
|
import org.jclouds.cloudloadbalancers.features.LoadBalancerClient;
|
||||||
import org.jclouds.javax.annotation.Nullable;
|
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;
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
* @see <a href=
|
|
||||||
* "http://docs.rackspacecloud.com/loadbalancers/api/v1.0/clb-devguide/content/ch04s01s02.html"
|
|
||||||
* />
|
|
||||||
*/
|
*/
|
||||||
public class LoadBalancer extends BaseLoadBalancer<Node, LoadBalancer> {
|
public class LoadBalancer extends BaseLoadBalancer<Node, LoadBalancer> {
|
||||||
|
|
||||||
|
@ -61,6 +61,7 @@ public class LoadBalancer extends BaseLoadBalancer<Node, LoadBalancer> {
|
||||||
private Date created;
|
private Date created;
|
||||||
private Date updated;
|
private Date updated;
|
||||||
private boolean connectionLoggingEnabled;
|
private boolean connectionLoggingEnabled;
|
||||||
|
private int nodeCount = 0;
|
||||||
|
|
||||||
public Builder region(String region) {
|
public Builder region(String region) {
|
||||||
this.region = region;
|
this.region = region;
|
||||||
|
@ -112,9 +113,17 @@ public class LoadBalancer extends BaseLoadBalancer<Node, LoadBalancer> {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see LoadBalancer#getNodeCount()
|
||||||
|
*/
|
||||||
|
public Builder nodeCount(int nodeCount) {
|
||||||
|
this.nodeCount = nodeCount;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public LoadBalancer build() {
|
public LoadBalancer build() {
|
||||||
return new LoadBalancer(region, id, name, protocol, port, algorithm, status, virtualIPs, nodes,
|
return new LoadBalancer(region, id, name, protocol, port, algorithm, status, virtualIPs, nodes,
|
||||||
sessionPersistenceType, clusterName, created, updated, connectionLoggingEnabled);
|
sessionPersistenceType, clusterName, created, updated, connectionLoggingEnabled, nodeCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -138,7 +147,7 @@ public class LoadBalancer extends BaseLoadBalancer<Node, LoadBalancer> {
|
||||||
public Builder from(LoadBalancer in) {
|
public Builder from(LoadBalancer in) {
|
||||||
return Builder.class.cast(super.from(in)).id(in.getId()).status(in.getStatus()).virtualIPs(in.getVirtualIPs())
|
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())
|
.clusterName(in.getClusterName()).created(in.getCreated()).updated(in.getUpdated())
|
||||||
.connectionLoggingEnabled(in.isConnectionLoggingEnabled());
|
.connectionLoggingEnabled(in.isConnectionLoggingEnabled()).nodeCount(in.getNodeCount());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -268,10 +277,11 @@ public class LoadBalancer extends BaseLoadBalancer<Node, LoadBalancer> {
|
||||||
private final Date created;
|
private final Date created;
|
||||||
private final Date updated;
|
private final Date updated;
|
||||||
private final boolean connectionLoggingEnabled;
|
private final boolean connectionLoggingEnabled;
|
||||||
|
private int nodeCount = 0;
|
||||||
|
|
||||||
public LoadBalancer(String region, int id, String name, String protocol, Integer port, @Nullable String algorithm,
|
public LoadBalancer(String region, int id, String name, String protocol, Integer port, @Nullable String algorithm,
|
||||||
Status status, Iterable<VirtualIP> virtualIPs, Iterable<Node> nodes, String sessionPersistenceType,
|
Status status, Iterable<VirtualIP> virtualIPs, Iterable<Node> 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);
|
super(name, protocol, port, algorithm, nodes);
|
||||||
this.region = checkNotNull(region, "region");
|
this.region = checkNotNull(region, "region");
|
||||||
checkArgument(id != -1, "id must be specified");
|
checkArgument(id != -1, "id must be specified");
|
||||||
|
@ -284,6 +294,7 @@ public class LoadBalancer extends BaseLoadBalancer<Node, LoadBalancer> {
|
||||||
this.created = checkNotNull(created, "created");
|
this.created = checkNotNull(created, "created");
|
||||||
this.updated = checkNotNull(updated, "updated");
|
this.updated = checkNotNull(updated, "updated");
|
||||||
this.connectionLoggingEnabled = connectionLoggingEnabled;
|
this.connectionLoggingEnabled = connectionLoggingEnabled;
|
||||||
|
this.nodeCount = nodeCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getRegion() {
|
public String getRegion() {
|
||||||
|
@ -331,41 +342,42 @@ public class LoadBalancer extends BaseLoadBalancer<Node, LoadBalancer> {
|
||||||
return connectionLoggingEnabled;
|
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
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return String
|
return string().toString();
|
||||||
.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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
final int prime = 31;
|
return Objects.hashCode(id, region);
|
||||||
int result = super.hashCode();
|
|
||||||
result = prime * result + id;
|
|
||||||
result = prime * result + ((region == null) ? 0 : region.hashCode());
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object obj) {
|
||||||
if (this == obj)
|
if (this == obj) return true;
|
||||||
return true;
|
if (obj == null || getClass() != obj.getClass()) return false;
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
LoadBalancer that = LoadBalancer.class.cast(obj);
|
||||||
|
return Objects.equal(this.id, that.id) && Objects.equal(this.region, that.region);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,8 +68,9 @@ public class LoadBalancerRequest extends BaseLoadBalancer<NodeRequest, LoadBalan
|
||||||
}
|
}
|
||||||
|
|
||||||
public LoadBalancerRequest build() {
|
public LoadBalancerRequest build() {
|
||||||
return virtualIps == null ? new LoadBalancerRequest(name, protocol, port, algorithm, nodes, virtualIPType,
|
return virtualIps == null
|
||||||
virtualIPId) : new LoadBalancerRequest(name, protocol, port, algorithm, nodes, virtualIps);
|
? new LoadBalancerRequest(name, protocol, port, algorithm, nodes, virtualIPType, virtualIPId)
|
||||||
|
: new LoadBalancerRequest(name, protocol, port, algorithm, nodes, virtualIps);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -34,7 +34,7 @@ import org.jclouds.cloudloadbalancers.domain.LoadBalancerAttributes;
|
||||||
import org.jclouds.cloudloadbalancers.domain.LoadBalancerRequest;
|
import org.jclouds.cloudloadbalancers.domain.LoadBalancerRequest;
|
||||||
import org.jclouds.cloudloadbalancers.functions.UnwrapLoadBalancer;
|
import org.jclouds.cloudloadbalancers.functions.UnwrapLoadBalancer;
|
||||||
import org.jclouds.cloudloadbalancers.functions.UnwrapLoadBalancers;
|
import org.jclouds.cloudloadbalancers.functions.UnwrapLoadBalancers;
|
||||||
import org.jclouds.openstack.filters.AuthenticateRequest;
|
import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest;
|
||||||
import org.jclouds.rest.annotations.ExceptionParser;
|
import org.jclouds.rest.annotations.ExceptionParser;
|
||||||
import org.jclouds.rest.annotations.RequestFilters;
|
import org.jclouds.rest.annotations.RequestFilters;
|
||||||
import org.jclouds.rest.annotations.ResponseParser;
|
import org.jclouds.rest.annotations.ResponseParser;
|
||||||
|
|
|
@ -33,7 +33,7 @@ import javax.ws.rs.core.MediaType;
|
||||||
import org.jclouds.cloudloadbalancers.domain.Node;
|
import org.jclouds.cloudloadbalancers.domain.Node;
|
||||||
import org.jclouds.cloudloadbalancers.domain.NodeAttributes;
|
import org.jclouds.cloudloadbalancers.domain.NodeAttributes;
|
||||||
import org.jclouds.cloudloadbalancers.domain.NodeRequest;
|
import org.jclouds.cloudloadbalancers.domain.NodeRequest;
|
||||||
import org.jclouds.openstack.filters.AuthenticateRequest;
|
import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest;
|
||||||
import org.jclouds.rest.annotations.ExceptionParser;
|
import org.jclouds.rest.annotations.ExceptionParser;
|
||||||
import org.jclouds.rest.annotations.RequestFilters;
|
import org.jclouds.rest.annotations.RequestFilters;
|
||||||
import org.jclouds.rest.annotations.SelectJson;
|
import org.jclouds.rest.annotations.SelectJson;
|
||||||
|
|
|
@ -51,9 +51,9 @@ public class ConvertLB implements Function<LB, LoadBalancer> {
|
||||||
@Override
|
@Override
|
||||||
public LoadBalancer apply(LB lb) {
|
public LoadBalancer apply(LB lb) {
|
||||||
try {
|
try {
|
||||||
Builder builder = LoadBalancer.builder().region(region).name(lb.getName()).port(lb.getPort()).protocol(
|
Builder builder = LoadBalancer.builder().region(region).name(lb.getName()).port(lb.getPort())
|
||||||
lb.getProtocol()).algorithm(lb.getAlgorithm()).nodes(lb.getNodes()).id(lb.id).status(lb.status)
|
.protocol(lb.getProtocol()).algorithm(lb.getAlgorithm()).nodes(lb.getNodes()).id(lb.id)
|
||||||
.virtualIPs(lb.virtualIps);
|
.status(lb.status).virtualIPs(lb.virtualIps).nodeCount(lb.nodeCount);
|
||||||
if (lb.cluster.size() == 1)
|
if (lb.cluster.size() == 1)
|
||||||
builder.clusterName(Iterables.get(lb.cluster.values(), 0));
|
builder.clusterName(Iterables.get(lb.cluster.values(), 0));
|
||||||
if (lb.sessionPersistence.size() == 1)
|
if (lb.sessionPersistence.size() == 1)
|
||||||
|
|
|
@ -22,20 +22,21 @@ import java.util.Date;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.jclouds.cloudloadbalancers.domain.LoadBalancer.Status;
|
||||||
import org.jclouds.cloudloadbalancers.domain.Node;
|
import org.jclouds.cloudloadbalancers.domain.Node;
|
||||||
import org.jclouds.cloudloadbalancers.domain.VirtualIP;
|
import org.jclouds.cloudloadbalancers.domain.VirtualIP;
|
||||||
import org.jclouds.cloudloadbalancers.domain.LoadBalancer.Status;
|
|
||||||
import org.jclouds.cloudloadbalancers.domain.internal.BaseLoadBalancer;
|
import org.jclouds.cloudloadbalancers.domain.internal.BaseLoadBalancer;
|
||||||
|
|
||||||
|
import com.google.common.base.Objects;
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
import com.google.common.collect.Sets;
|
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<Node, LB> {
|
class LB extends BaseLoadBalancer<Node, LB> {
|
||||||
int id;
|
int id;
|
||||||
|
int nodeCount;
|
||||||
Status status;
|
Status status;
|
||||||
Set<VirtualIP> virtualIps = Sets.newLinkedHashSet();
|
Set<VirtualIP> virtualIps = Sets.newLinkedHashSet();
|
||||||
Map<String, String> sessionPersistence = Maps.newLinkedHashMap();
|
Map<String, String> sessionPersistence = Maps.newLinkedHashMap();
|
||||||
|
@ -43,4 +44,18 @@ class LB extends BaseLoadBalancer<Node, LB> {
|
||||||
Map<String, Date> created = Maps.newLinkedHashMap();
|
Map<String, Date> created = Maps.newLinkedHashMap();
|
||||||
Map<String, Date> updated = Maps.newLinkedHashMap();
|
Map<String, Date> updated = Maps.newLinkedHashMap();
|
||||||
Map<String, Boolean> connectionLogging = Maps.newLinkedHashMap();
|
Map<String, Boolean> connectionLogging = Maps.newLinkedHashMap();
|
||||||
|
|
||||||
|
@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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,7 +60,7 @@ public class LoadBalancerToLoadBalancerMetadata implements Function<LoadBalancer
|
||||||
|
|
||||||
String id = input.getRegion() + "/" + input.getId();
|
String id = input.getRegion() + "/" + input.getId();
|
||||||
// TODO Builder
|
// TODO Builder
|
||||||
return new LoadBalancerMetadataImpl(LoadBalancerType.LB, input.getName(), input.getName(), id, location, null,
|
return new LoadBalancerMetadataImpl(LoadBalancerType.LB, String.valueOf(input.getId()), input.getName(), id, location, null,
|
||||||
ImmutableMap.<String, String> of(), Iterables.transform(input.getVirtualIPs(),
|
ImmutableMap.<String, String> of(), Iterables.transform(input.getVirtualIPs(),
|
||||||
new Function<VirtualIP, String>() {
|
new Function<VirtualIP, String>() {
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,7 @@ import org.jclouds.cloudloadbalancers.domain.LoadBalancer;
|
||||||
import org.jclouds.loadbalancer.domain.LoadBalancerMetadata;
|
import org.jclouds.loadbalancer.domain.LoadBalancerMetadata;
|
||||||
import org.jclouds.loadbalancer.reference.LoadBalancerConstants;
|
import org.jclouds.loadbalancer.reference.LoadBalancerConstants;
|
||||||
import org.jclouds.loadbalancer.strategy.ListLoadBalancersStrategy;
|
import org.jclouds.loadbalancer.strategy.ListLoadBalancersStrategy;
|
||||||
import org.jclouds.location.Region;
|
import org.jclouds.location.Zone;
|
||||||
import org.jclouds.logging.Logger;
|
import org.jclouds.logging.Logger;
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
|
@ -58,21 +58,21 @@ public class CloudLoadBalancersListLoadBalancersStrategy implements ListLoadBala
|
||||||
private final CloudLoadBalancersAsyncClient aclient;
|
private final CloudLoadBalancersAsyncClient aclient;
|
||||||
private final Function<LoadBalancer, LoadBalancerMetadata> converter;
|
private final Function<LoadBalancer, LoadBalancerMetadata> converter;
|
||||||
private final ExecutorService executor;
|
private final ExecutorService executor;
|
||||||
private final Supplier<Set<String>> regions;
|
private final Supplier<Set<String>> zones;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
protected CloudLoadBalancersListLoadBalancersStrategy(CloudLoadBalancersAsyncClient aclient,
|
protected CloudLoadBalancersListLoadBalancersStrategy(CloudLoadBalancersAsyncClient aclient,
|
||||||
Function<LoadBalancer, LoadBalancerMetadata> converter,
|
Function<LoadBalancer, LoadBalancerMetadata> converter,
|
||||||
@Named(Constants.PROPERTY_USER_THREADS) ExecutorService executor, @Region Supplier<Set<String>> regions) {
|
@Named(Constants.PROPERTY_USER_THREADS) ExecutorService executor, @Zone Supplier<Set<String>> zones) {
|
||||||
this.aclient = checkNotNull(aclient, "aclient");
|
this.aclient = checkNotNull(aclient, "aclient");
|
||||||
this.regions = checkNotNull(regions, "regions");
|
this.zones = checkNotNull(zones, "zones");
|
||||||
this.converter = checkNotNull(converter, "converter");
|
this.converter = checkNotNull(converter, "converter");
|
||||||
this.executor = checkNotNull(executor, "executor");
|
this.executor = checkNotNull(executor, "executor");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Iterable<? extends LoadBalancerMetadata> listLoadBalancers() {
|
public Iterable<? extends LoadBalancerMetadata> listLoadBalancers() {
|
||||||
return transform(concat(transformParallel(regions.get(), new Function<String, Future<? extends Set<LoadBalancer>>>() {
|
return transform(concat(transformParallel(zones.get(), new Function<String, Future<? extends Set<LoadBalancer>>>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ListenableFuture<Set<LoadBalancer>> apply(String from) {
|
public ListenableFuture<Set<LoadBalancer>> apply(String from) {
|
||||||
|
|
|
@ -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<CloudLoadBalancersAsyncClient> {
|
|
||||||
|
|
||||||
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<RestAnnotationProcessor<CloudLoadBalancersAsyncClient>> createTypeLiteral() {
|
|
||||||
return new TypeLiteral<RestAnnotationProcessor<CloudLoadBalancersAsyncClient>>() {
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
@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) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -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<LoadBalancerAsyncClient> {
|
|
||||||
|
|
||||||
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<RestAnnotationProcessor<LoadBalancerAsyncClient>> createTypeLiteral() {
|
|
||||||
return new TypeLiteral<RestAnnotationProcessor<LoadBalancerAsyncClient>>() {
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -19,9 +19,9 @@
|
||||||
package org.jclouds.cloudloadbalancers.features;
|
package org.jclouds.cloudloadbalancers.features;
|
||||||
|
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
|
import static org.testng.Assert.assertNotNull;
|
||||||
import static org.testng.Assert.assertTrue;
|
import static org.testng.Assert.assertTrue;
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.logging.Logger;
|
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.NodeRequest;
|
||||||
import org.jclouds.cloudloadbalancers.domain.VirtualIP.Type;
|
import org.jclouds.cloudloadbalancers.domain.VirtualIP.Type;
|
||||||
import org.jclouds.cloudloadbalancers.internal.BaseCloudLoadBalancersClientLiveTest;
|
import org.jclouds.cloudloadbalancers.internal.BaseCloudLoadBalancersClientLiveTest;
|
||||||
|
import org.testng.annotations.AfterGroups;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
|
@ -46,15 +47,10 @@ public class LoadBalancerClientLiveTest extends BaseCloudLoadBalancersClientLive
|
||||||
private Set<LoadBalancer> lbs = Sets.newLinkedHashSet();
|
private Set<LoadBalancer> lbs = Sets.newLinkedHashSet();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setupContext() {
|
@AfterGroups(groups = "live")
|
||||||
super.setupContext();
|
|
||||||
assertEquals(client.getConfiguredRegions(), Arrays.asList(regions));
|
|
||||||
Logger.getAnonymousLogger().info("running against regions " + client.getConfiguredRegions());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void tearDownContext() {
|
protected void tearDownContext() {
|
||||||
for (LoadBalancer lb : lbs) {
|
for (LoadBalancer lb: lbs) {
|
||||||
|
assert loadBalancerActive.apply(lb) : lb;
|
||||||
client.getLoadBalancerClient(lb.getRegion()).removeLoadBalancer(lb.getId());
|
client.getLoadBalancerClient(lb.getRegion()).removeLoadBalancer(lb.getId());
|
||||||
assert loadBalancerDeleted.apply(lb) : lb;
|
assert loadBalancerDeleted.apply(lb) : lb;
|
||||||
}
|
}
|
||||||
|
@ -62,43 +58,60 @@ public class LoadBalancerClientLiveTest extends BaseCloudLoadBalancersClientLive
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testCreateLoadBalancer() throws Exception {
|
public void testCreateLoadBalancer() throws Exception {
|
||||||
for (String region : client.getConfiguredRegions()) {
|
for (String zone: client.getConfiguredZones()) {
|
||||||
Logger.getAnonymousLogger().info("starting lb in region " + region);
|
Logger.getAnonymousLogger().info("starting lb in region " + zone);
|
||||||
LoadBalancer lb = client.getLoadBalancerClient(region).createLoadBalancer(
|
|
||||||
LoadBalancerRequest.builder().name(prefix + "-" + region).protocol("HTTP").port(80).virtualIPType(
|
LoadBalancer lb = client.getLoadBalancerClient(zone).createLoadBalancer(
|
||||||
Type.PUBLIC).node(NodeRequest.builder().address("192.168.1.1").port(8080).build()).build());
|
LoadBalancerRequest.builder()
|
||||||
checkLBInRegion(region, lb, prefix + "-" + region);
|
.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);
|
assertEquals(lb.getStatus(), LoadBalancer.Status.BUILD);
|
||||||
|
|
||||||
lbs.add(lb);
|
lbs.add(lb);
|
||||||
assert loadBalancerActive.apply(lb) : lb;
|
|
||||||
|
assertTrue(loadBalancerActive.apply(lb));
|
||||||
|
|
||||||
LoadBalancer newLb = client.getLoadBalancerClient(region).getLoadBalancer(lb.getId());
|
LoadBalancer newLb = client.getLoadBalancerClient(zone).getLoadBalancer(lb.getId());
|
||||||
checkLBInRegion(region, newLb, prefix + "-" + region);
|
checkLBInRegion(zone, newLb, prefix + "-" + zone);
|
||||||
|
|
||||||
assertEquals(newLb.getStatus(), LoadBalancer.Status.ACTIVE);
|
assertEquals(newLb.getStatus(), LoadBalancer.Status.ACTIVE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(dependsOnMethods = "testCreateLoadBalancer")
|
@Test(dependsOnMethods = "testCreateLoadBalancer")
|
||||||
public void testUpdateLoadBalancer() throws Exception {
|
public void testUpdateLoadBalancer() throws Exception {
|
||||||
for (LoadBalancer lb : lbs) {
|
for (LoadBalancer lb: lbs) {
|
||||||
client.getLoadBalancerClient(lb.getRegion()).updateLoadBalancerAttributes(lb.getId(),
|
client.getLoadBalancerClient(lb.getRegion()).updateLoadBalancerAttributes(lb.getId(),
|
||||||
LoadBalancerAttributes.Builder.name("foo" + "-" + lb.getRegion()));
|
LoadBalancerAttributes.Builder.name("foo" + "-" + lb.getRegion()));
|
||||||
assert loadBalancerActive.apply(lb) : lb;
|
|
||||||
|
assertTrue(loadBalancerActive.apply(lb));
|
||||||
|
|
||||||
LoadBalancer newLb = client.getLoadBalancerClient(lb.getRegion()).getLoadBalancer(lb.getId());
|
LoadBalancer newLb = client.getLoadBalancerClient(lb.getRegion()).getLoadBalancer(lb.getId());
|
||||||
checkLBInRegion(newLb.getRegion(), newLb, "foo" + "-" + lb.getRegion());
|
checkLBInRegion(newLb.getRegion(), newLb, "foo" + "-" + lb.getRegion());
|
||||||
|
|
||||||
assertEquals(newLb.getStatus(), LoadBalancer.Status.ACTIVE);
|
assertEquals(newLb.getStatus(), LoadBalancer.Status.ACTIVE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(dependsOnMethods = "testUpdateLoadBalancer")
|
@Test(dependsOnMethods = "testUpdateLoadBalancer")
|
||||||
public void testListLoadBalancers() throws Exception {
|
public void testListLoadBalancers() throws Exception {
|
||||||
for (String region : client.getConfiguredRegions()) {
|
for (String zone: client.getConfiguredZones()) {
|
||||||
Set<LoadBalancer> response = client.getLoadBalancerClient(region).listLoadBalancers();
|
Set<LoadBalancer> response = client.getLoadBalancerClient(zone).listLoadBalancers();
|
||||||
assert null != response;
|
|
||||||
|
assertNotNull(response);
|
||||||
assertTrue(response.size() >= 0);
|
assertTrue(response.size() >= 0);
|
||||||
for (LoadBalancer lb : response) {
|
|
||||||
if (lb.getStatus() == LoadBalancer.Status.DELETED)
|
for (LoadBalancer lb: response) {
|
||||||
|
if (!lbs.contains(lb))
|
||||||
continue;
|
continue;
|
||||||
assert lb.getRegion() != null : lb;
|
assert lb.getRegion() != null : lb;
|
||||||
assert lb.getName() != null : lb;
|
assert lb.getName() != null : lb;
|
||||||
|
@ -112,7 +125,8 @@ public class LoadBalancerClientLiveTest extends BaseCloudLoadBalancersClientLive
|
||||||
// node info not available during list;
|
// node info not available during list;
|
||||||
assert lb.getNodes().size() == 0 : lb;
|
assert lb.getNodes().size() == 0 : lb;
|
||||||
|
|
||||||
LoadBalancer getDetails = client.getLoadBalancerClient(region).getLoadBalancer(lb.getId());
|
LoadBalancer getDetails = client.getLoadBalancerClient(zone).getLoadBalancer(lb.getId());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
assertEquals(getDetails.getRegion(), lb.getRegion());
|
assertEquals(getDetails.getRegion(), lb.getRegion());
|
||||||
assertEquals(getDetails.getName(), lb.getName());
|
assertEquals(getDetails.getName(), lb.getName());
|
||||||
|
|
|
@ -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<CloudLoadBalancersClient> {
|
||||||
|
|
||||||
|
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<LoadBalancer> 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<NodeRequest> 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<LoadBalancer> testLoadBalancers() {
|
||||||
|
return new UnwrapLoadBalancersTest().expected();
|
||||||
|
}
|
||||||
|
}
|
|
@ -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.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.common.collect.ImmutableList;
|
|
||||||
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<NodeAsyncClient> {
|
|
||||||
|
|
||||||
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, ImmutableList.<NodeRequest>of(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<RestAnnotationProcessor<NodeAsyncClient>> createTypeLiteral() {
|
|
||||||
return new TypeLiteral<RestAnnotationProcessor<NodeAsyncClient>>() {
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -51,14 +51,13 @@ import org.testng.annotations.Test;
|
||||||
public class NodeClientLiveTest extends BaseCloudLoadBalancersClientLiveTest {
|
public class NodeClientLiveTest extends BaseCloudLoadBalancersClientLiveTest {
|
||||||
private Map<LoadBalancer, Set<Node>> nodes = Maps.newHashMap();
|
private Map<LoadBalancer, Set<Node>> nodes = Maps.newHashMap();
|
||||||
|
|
||||||
@Test(groups = "live")
|
|
||||||
public void testCreateLoadBalancers() {
|
public void testCreateLoadBalancers() {
|
||||||
assertTrue(client.getConfiguredRegions().size() > 0, "Need to have some regions!");
|
assertTrue(client.getConfiguredZones().size() > 0, "Need to have some zones!");
|
||||||
Logger.getAnonymousLogger().info("running against regions " + client.getConfiguredRegions());
|
Logger.getAnonymousLogger().info("running against zones " + client.getConfiguredZones());
|
||||||
for (String region : client.getConfiguredRegions()) {
|
for (String zone : client.getConfiguredZones()) {
|
||||||
Logger.getAnonymousLogger().info("starting lb in region " + region);
|
Logger.getAnonymousLogger().info("starting lb in zone " + zone);
|
||||||
LoadBalancer lb = client.getLoadBalancerClient(region).createLoadBalancer(
|
LoadBalancer lb = client.getLoadBalancerClient(zone).createLoadBalancer(
|
||||||
LoadBalancerRequest.builder().name(prefix + "-" + region).protocol("HTTP").port(80).virtualIPType(
|
LoadBalancerRequest.builder().name(prefix + "-" + zone).protocol("HTTP").port(80).virtualIPType(
|
||||||
Type.PUBLIC).node(NodeRequest.builder().address("192.168.1.1").port(8080).build()).build());
|
Type.PUBLIC).node(NodeRequest.builder().address("192.168.1.1").port(8080).build()).build());
|
||||||
nodes.put(lb, new HashSet<Node>());
|
nodes.put(lb, new HashSet<Node>());
|
||||||
|
|
||||||
|
@ -66,7 +65,7 @@ public class NodeClientLiveTest extends BaseCloudLoadBalancersClientLiveTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(groups = "live", dependsOnMethods = "testCreateLoadBalancers")
|
@Test(dependsOnMethods = "testCreateLoadBalancers")
|
||||||
public void testAddNodes() throws Exception {
|
public void testAddNodes() throws Exception {
|
||||||
for (LoadBalancer lb : nodes.keySet()) {
|
for (LoadBalancer lb : nodes.keySet()) {
|
||||||
String region = lb.getRegion();
|
String region = lb.getRegion();
|
||||||
|
@ -86,7 +85,7 @@ public class NodeClientLiveTest extends BaseCloudLoadBalancersClientLiveTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(groups = "live", dependsOnMethods = "testAddNodes")
|
@Test(dependsOnMethods = "testAddNodes")
|
||||||
public void testModifyNode() throws Exception {
|
public void testModifyNode() throws Exception {
|
||||||
for (Entry<LoadBalancer, Set<Node>> entry : nodes.entrySet()) {
|
for (Entry<LoadBalancer, Set<Node>> entry : nodes.entrySet()) {
|
||||||
for (Node n : entry.getValue()) {
|
for (Node n : entry.getValue()) {
|
||||||
|
@ -103,7 +102,7 @@ public class NodeClientLiveTest extends BaseCloudLoadBalancersClientLiveTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(groups = "live", dependsOnMethods = "testModifyNode")
|
@Test(dependsOnMethods = "testModifyNode")
|
||||||
public void testListNodes() throws Exception {
|
public void testListNodes() throws Exception {
|
||||||
for (LoadBalancer lb : nodes.keySet()) {
|
for (LoadBalancer lb : nodes.keySet()) {
|
||||||
Set<Node> response = client.getNodeClient(lb.getRegion()).listNodes(lb.getId());
|
Set<Node> response = client.getNodeClient(lb.getRegion()).listNodes(lb.getId());
|
||||||
|
@ -144,6 +143,7 @@ public class NodeClientLiveTest extends BaseCloudLoadBalancersClientLiveTest {
|
||||||
LoadBalancerClient lbClient = client.getLoadBalancerClient(lb.getRegion());
|
LoadBalancerClient lbClient = client.getLoadBalancerClient(lb.getRegion());
|
||||||
|
|
||||||
if (lbClient.getLoadBalancer(lb.getId()).getStatus() != Status.DELETED) {
|
if (lbClient.getLoadBalancer(lb.getId()).getStatus() != Status.DELETED) {
|
||||||
|
assert loadBalancerActive.apply(lb) : lb;
|
||||||
lbClient.removeLoadBalancer(lb.getId());
|
lbClient.removeLoadBalancer(lb.getId());
|
||||||
}
|
}
|
||||||
assert loadBalancerDeleted.apply(lb) : lb;
|
assert loadBalancerDeleted.apply(lb) : lb;
|
||||||
|
|
|
@ -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<CloudLoadBalancersClient> {
|
||||||
|
|
||||||
|
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<Node> 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<NodeRequest> nodeRequests = ImmutableSortedSet.<NodeRequest> of(nodeRequest1, nodeRequest2, nodeRequest3);
|
||||||
|
|
||||||
|
Set<Node> 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<Integer> nodeIds = ImmutableSortedSet.<Integer> of(410, 411);
|
||||||
|
|
||||||
|
api.removeNodesFromLoadBalancer(nodeIds, 2000);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Set<Node> 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.<Node> 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();
|
||||||
|
}
|
||||||
|
}
|
|
@ -43,30 +43,31 @@ public class UnwrapLoadBalancerTest extends BaseItemParserTest<LoadBalancer> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String resource() {
|
public String resource() {
|
||||||
return "/getloadbalancer.json";
|
return "/loadbalancer-get.json";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LoadBalancer expected() {
|
public LoadBalancer expected() {
|
||||||
return LoadBalancer.builder().region("DFW").id(2000).name("sample-loadbalancer").protocol("HTTP").port(80)
|
return LoadBalancer
|
||||||
.algorithm("RANDOM").status(Status.ACTIVE).connectionLoggingEnabled(true).virtualIPs(
|
.builder()
|
||||||
ImmutableSet.of(VirtualIP.builder().id(1000).address("206.10.10.210").type(
|
.region("DFW")
|
||||||
VirtualIP.Type.PUBLIC).ipVersion(IPVersion.IPV4).build()))
|
.id(2000)
|
||||||
|
.name("sample-loadbalancer")
|
||||||
.nodes(
|
.protocol("HTTP")
|
||||||
ImmutableSet.of(Node.builder().id(1041).address("10.1.1.1").port(80).condition(
|
.port(80)
|
||||||
Node.Condition.ENABLED).status(Node.Status.ONLINE).build(), Node.builder().id(1411)
|
.algorithm("RANDOM")
|
||||||
.address("10.1.1.2").port(80).condition(Node.Condition.ENABLED).status(
|
.status(Status.ACTIVE)
|
||||||
Node.Status.ONLINE).build())).sessionPersistenceType("HTTP_COOKIE")
|
.connectionLoggingEnabled(true)
|
||||||
// connectionThrottle({
|
.nodeCount(2)
|
||||||
// minConnections(10)
|
.virtualIPs(ImmutableSet.of(
|
||||||
// maxConnections(100)
|
VirtualIP.builder().id(1000).address("206.10.10.210").type(VirtualIP.Type.PUBLIC).ipVersion(IPVersion.IPV4).build()))
|
||||||
// maxConnectionRate(50)
|
.nodes(ImmutableSet.of(
|
||||||
// rateInterval(60
|
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()))
|
||||||
.clusterName("c1.dfw1").created(
|
.sessionPersistenceType("HTTP_COOKIE")
|
||||||
new SimpleDateFormatDateService().iso8601SecondsDateParse("2010-11-30T03:23:42Z")).updated(
|
.clusterName("c1.dfw1")
|
||||||
new SimpleDateFormatDateService().iso8601SecondsDateParse("2010-11-30T03:23:44Z")).build();
|
.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
|
// add factory binding as this is not default
|
||||||
|
|
|
@ -39,14 +39,14 @@ public class UnwrapLoadBalancerWhenDeletedTest extends BaseItemParserTest<LoadBa
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String resource() {
|
public String resource() {
|
||||||
return "/getloadbalancer-deleted.json";
|
return "/loadbalancer-get-deleted.json";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LoadBalancer expected() {
|
public LoadBalancer expected() {
|
||||||
return LoadBalancer.builder().region("LON").id(4865).name("adriancole-LON").status(Status.DELETED).created(
|
return LoadBalancer.builder().region("LON").id(4865).name("adriancole-LON").status(Status.DELETED).nodeCount(0)
|
||||||
new SimpleDateFormatDateService().iso8601SecondsDateParse("2011-12-05T18:03:23Z")).updated(
|
.created(new SimpleDateFormatDateService().iso8601SecondsDateParse("2011-12-05T18:03:23Z"))
|
||||||
new SimpleDateFormatDateService().iso8601SecondsDateParse("2011-12-05T18:04:04Z")).build();
|
.updated(new SimpleDateFormatDateService().iso8601SecondsDateParse("2011-12-05T18:04:04Z")).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
// add factory binding as this is not default
|
// add factory binding as this is not default
|
||||||
|
|
|
@ -43,7 +43,7 @@ public class UnwrapLoadBalancersTest extends BaseSetParserTest<LoadBalancer> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String resource() {
|
public String resource() {
|
||||||
return "/listloadbalancers.json";
|
return "/loadbalancers-list.json";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -51,18 +51,36 @@ public class UnwrapLoadBalancersTest extends BaseSetParserTest<LoadBalancer> {
|
||||||
|
|
||||||
return ImmutableSet.of(
|
return ImmutableSet.of(
|
||||||
|
|
||||||
LoadBalancer.builder().region("DFW").name("lb-site1").id(71).protocol("HTTP").port(80).algorithm("RANDOM")
|
LoadBalancer
|
||||||
.status(Status.ACTIVE).virtualIPs(
|
.builder()
|
||||||
ImmutableSet.of(VirtualIP.builder().id(403).address("206.55.130.1").type(VirtualIP.Type.PUBLIC)
|
.region("DFW")
|
||||||
.ipVersion(VirtualIP.IPVersion.IPV4).build())).created(
|
.name("lb-site1")
|
||||||
new SimpleDateFormatDateService().iso8601SecondsDateParse("2010-11-30T03:23:42Z")).updated(
|
.id(71)
|
||||||
new SimpleDateFormatDateService().iso8601SecondsDateParse("2010-11-30T03:23:44Z")).build(),
|
.protocol("HTTP")
|
||||||
LoadBalancer.builder().region("DFW").name("lb-site2").id(166).protocol("HTTP").port(80).algorithm(
|
.port(80)
|
||||||
"RANDOM").status(Status.ACTIVE).virtualIPs(
|
.algorithm("RANDOM")
|
||||||
ImmutableSet.of(VirtualIP.builder().id(401).address("206.55.130.2").type(VirtualIP.Type.PUBLIC)
|
.status(Status.ACTIVE)
|
||||||
.ipVersion(VirtualIP.IPVersion.IPV4).build())).created(
|
.nodeCount(1)
|
||||||
new SimpleDateFormatDateService().iso8601SecondsDateParse("2010-11-30T03:23:42Z")).updated(
|
.virtualIPs(ImmutableSet.of(
|
||||||
new SimpleDateFormatDateService().iso8601SecondsDateParse("2010-11-30T03:23:44Z")).build());
|
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());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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<T> extends BaseRestApiExpectTest<T> {
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
|
@ -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<T> extends BaseAsyncClientTest<T> {
|
|
||||||
|
|
||||||
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();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -18,16 +18,19 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.cloudloadbalancers.internal;
|
package org.jclouds.cloudloadbalancers.internal;
|
||||||
|
|
||||||
|
import java.util.Properties;
|
||||||
import java.util.concurrent.TimeUnit;
|
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.CloudLoadBalancersAsyncClient;
|
||||||
import org.jclouds.cloudloadbalancers.CloudLoadBalancersClient;
|
import org.jclouds.cloudloadbalancers.CloudLoadBalancersClient;
|
||||||
import org.jclouds.cloudloadbalancers.domain.LoadBalancer;
|
import org.jclouds.cloudloadbalancers.domain.LoadBalancer;
|
||||||
import org.jclouds.cloudloadbalancers.predicates.LoadBalancerActive;
|
import org.jclouds.cloudloadbalancers.predicates.LoadBalancerActive;
|
||||||
import org.jclouds.cloudloadbalancers.predicates.LoadBalancerDeleted;
|
import org.jclouds.cloudloadbalancers.predicates.LoadBalancerDeleted;
|
||||||
import org.jclouds.loadbalancer.LoadBalancerServiceContext;
|
import org.jclouds.logging.slf4j.config.SLF4JLoggingModule;
|
||||||
import org.jclouds.logging.log4j.config.Log4JLoggingModule;
|
import org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties;
|
||||||
import org.jclouds.predicates.RetryablePredicate;
|
import org.jclouds.predicates.RetryablePredicate;
|
||||||
import org.jclouds.rest.RestContext;
|
import org.jclouds.rest.RestContext;
|
||||||
import org.testng.annotations.BeforeGroups;
|
import org.testng.annotations.BeforeGroups;
|
||||||
|
@ -42,15 +45,13 @@ import com.google.inject.Injector;
|
||||||
*
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
public class BaseCloudLoadBalancersClientLiveTest extends BaseViewLiveTest<LoadBalancerServiceContext> {
|
public class BaseCloudLoadBalancersClientLiveTest extends BaseContextLiveTest<RestContext<CloudLoadBalancersClient, CloudLoadBalancersAsyncClient>> {
|
||||||
|
|
||||||
public BaseCloudLoadBalancersClientLiveTest() {
|
public BaseCloudLoadBalancersClientLiveTest() {
|
||||||
provider = "cloudloadbalancers";
|
provider = "cloudloadbalancers";
|
||||||
}
|
}
|
||||||
|
|
||||||
protected CloudLoadBalancersClient client;
|
protected CloudLoadBalancersClient client;
|
||||||
protected RestContext<CloudLoadBalancersClient, CloudLoadBalancersAsyncClient> lbContext;
|
|
||||||
protected String[] regions = {};
|
|
||||||
protected Predicate<HostAndPort> socketTester;
|
protected Predicate<HostAndPort> socketTester;
|
||||||
protected RetryablePredicate<LoadBalancer> loadBalancerActive;
|
protected RetryablePredicate<LoadBalancer> loadBalancerActive;
|
||||||
protected RetryablePredicate<LoadBalancer> loadBalancerDeleted;
|
protected RetryablePredicate<LoadBalancer> loadBalancerDeleted;
|
||||||
|
@ -61,22 +62,30 @@ public class BaseCloudLoadBalancersClientLiveTest extends BaseViewLiveTest<LoadB
|
||||||
@Override
|
@Override
|
||||||
public void setupContext() {
|
public void setupContext() {
|
||||||
super.setupContext();
|
super.setupContext();
|
||||||
lbContext = view.unwrap();
|
|
||||||
|
|
||||||
client = lbContext.getApi();
|
client = context.getApi();
|
||||||
|
injector = Guice.createInjector(new SLF4JLoggingModule());
|
||||||
injector = Guice.createInjector(new Log4JLoggingModule());
|
|
||||||
loadBalancerActive = new RetryablePredicate<LoadBalancer>(new LoadBalancerActive(client), 300, 1, 1,
|
loadBalancerActive = new RetryablePredicate<LoadBalancer>(
|
||||||
TimeUnit.SECONDS);
|
new LoadBalancerActive(client), 300, 1, 1, TimeUnit.SECONDS);
|
||||||
injector.injectMembers(loadBalancerActive);
|
injector.injectMembers(loadBalancerActive);
|
||||||
loadBalancerDeleted = new RetryablePredicate<LoadBalancer>(new LoadBalancerDeleted(client), 300, 1, 1,
|
|
||||||
TimeUnit.SECONDS);
|
loadBalancerDeleted = new RetryablePredicate<LoadBalancer>(
|
||||||
|
new LoadBalancerDeleted(client), 300, 1, 1, TimeUnit.SECONDS);
|
||||||
injector.injectMembers(loadBalancerDeleted);
|
injector.injectMembers(loadBalancerDeleted);
|
||||||
|
|
||||||
|
Logger.getAnonymousLogger().info("running against zones " + client.getConfiguredZones());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected TypeToken<LoadBalancerServiceContext> viewType() {
|
protected Properties setupProperties() {
|
||||||
return TypeToken.of(LoadBalancerServiceContext.class);
|
Properties props = super.setupProperties();
|
||||||
|
setIfTestSystemPropertyPresent(props, KeystoneProperties.CREDENTIAL_TYPE);
|
||||||
|
return props;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected TypeToken<RestContext<CloudLoadBalancersClient, CloudLoadBalancersAsyncClient>> contextType() {
|
||||||
|
return CloudLoadBalancersApiMetadata.CONTEXT_TOKEN;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
|
@ -1 +1 @@
|
||||||
{"loadBalancer":{"name":"adriancole-LON","id":4865,"status":"DELETED","created":{"time":"2011-12-05T18:03:23Z"},"updated":{"time":"2011-12-05T18:04:04Z"}}}
|
{"loadBalancer":{"name":"adriancole-LON","id":4865,"status":"DELETED","created":{"time":"2011-12-05T18:03:23Z"},"updated":{"time":"2011-12-05T18:04:04Z"},"nodeCount":0}}
|
|
@ -0,0 +1,8 @@
|
||||||
|
{
|
||||||
|
"loadBalancer": {
|
||||||
|
"name": "foo",
|
||||||
|
"protocol": "HTTPS",
|
||||||
|
"port": 443,
|
||||||
|
"algorithm": "RANDOM"
|
||||||
|
}
|
||||||
|
}
|
|
@ -20,7 +20,8 @@
|
||||||
},
|
},
|
||||||
"updated":{
|
"updated":{
|
||||||
"time":"2010-11-30T03:23:44Z"
|
"time":"2010-11-30T03:23:44Z"
|
||||||
}
|
},
|
||||||
|
"nodeCount":1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name":"lb-site2",
|
"name":"lb-site2",
|
||||||
|
@ -42,7 +43,8 @@
|
||||||
},
|
},
|
||||||
"updated":{
|
"updated":{
|
||||||
"time":"2010-11-30T03:23:44Z"
|
"time":"2010-11-30T03:23:44Z"
|
||||||
}
|
},
|
||||||
|
"nodeCount":1
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
|
@ -1,155 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
|
|
||||||
|
|
||||||
<!--
|
|
||||||
For more configuration infromation and examples see the Apache
|
|
||||||
Log4j website: http://logging.apache.org/log4j/
|
|
||||||
-->
|
|
||||||
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"
|
|
||||||
debug="false">
|
|
||||||
|
|
||||||
<!-- A time/date based rolling appender -->
|
|
||||||
<appender name="WIREFILE" class="org.apache.log4j.DailyRollingFileAppender">
|
|
||||||
<param name="File" value="target/test-data/jclouds-wire.log" />
|
|
||||||
<param name="Append" value="true" />
|
|
||||||
|
|
||||||
<!-- Rollover at midnight each day -->
|
|
||||||
<param name="DatePattern" value="'.'yyyy-MM-dd" />
|
|
||||||
|
|
||||||
<param name="Threshold" value="TRACE" />
|
|
||||||
|
|
||||||
<layout class="org.apache.log4j.PatternLayout">
|
|
||||||
<!-- The default pattern: Date Priority [Category] Message\n -->
|
|
||||||
<param name="ConversionPattern" value="%d %-5p [%c] (%t) %m%n" />
|
|
||||||
|
|
||||||
<!--
|
|
||||||
The full pattern: Date MS Priority [Category]
|
|
||||||
(Thread:NDC) Message\n <param name="ConversionPattern"
|
|
||||||
value="%d %-5r %-5p [%c] (%t:%x) %m%n"/>
|
|
||||||
-->
|
|
||||||
</layout>
|
|
||||||
</appender>
|
|
||||||
|
|
||||||
<!-- A time/date based rolling appender -->
|
|
||||||
<appender name="FILE" class="org.apache.log4j.DailyRollingFileAppender">
|
|
||||||
<param name="File" value="target/test-data/jclouds.log" />
|
|
||||||
<param name="Append" value="true" />
|
|
||||||
|
|
||||||
<!-- Rollover at midnight each day -->
|
|
||||||
<param name="DatePattern" value="'.'yyyy-MM-dd" />
|
|
||||||
|
|
||||||
<param name="Threshold" value="TRACE" />
|
|
||||||
|
|
||||||
<layout class="org.apache.log4j.PatternLayout">
|
|
||||||
<!-- The default pattern: Date Priority [Category] Message\n -->
|
|
||||||
<param name="ConversionPattern" value="%d %-5p [%c] (%t) %m%n" />
|
|
||||||
|
|
||||||
<!--
|
|
||||||
The full pattern: Date MS Priority [Category]
|
|
||||||
(Thread:NDC) Message\n <param name="ConversionPattern"
|
|
||||||
value="%d %-5r %-5p [%c] (%t:%x) %m%n"/>
|
|
||||||
-->
|
|
||||||
</layout>
|
|
||||||
</appender>
|
|
||||||
|
|
||||||
<!-- A time/date based rolling appender -->
|
|
||||||
<appender name="COMPUTEFILE" class="org.apache.log4j.DailyRollingFileAppender">
|
|
||||||
<param name="File" value="target/test-data/jclouds-compute.log" />
|
|
||||||
<param name="Append" value="true" />
|
|
||||||
|
|
||||||
<!-- Rollover at midnight each day -->
|
|
||||||
<param name="DatePattern" value="'.'yyyy-MM-dd" />
|
|
||||||
|
|
||||||
<param name="Threshold" value="TRACE" />
|
|
||||||
|
|
||||||
<layout class="org.apache.log4j.PatternLayout">
|
|
||||||
<!-- The default pattern: Date Priority [Category] Message\n -->
|
|
||||||
<param name="ConversionPattern" value="%d %-5p [%c] (%t) %m%n" />
|
|
||||||
|
|
||||||
<!--
|
|
||||||
The full pattern: Date MS Priority [Category]
|
|
||||||
(Thread:NDC) Message\n <param name="ConversionPattern"
|
|
||||||
value="%d %-5r %-5p [%c] (%t:%x) %m%n"/>
|
|
||||||
-->
|
|
||||||
</layout>
|
|
||||||
</appender>
|
|
||||||
|
|
||||||
<!-- A time/date based rolling appender -->
|
|
||||||
<appender name="SSHFILE" class="org.apache.log4j.DailyRollingFileAppender">
|
|
||||||
<param name="File" value="target/test-data/jclouds-ssh.log" />
|
|
||||||
<param name="Append" value="true" />
|
|
||||||
|
|
||||||
<!-- Rollover at midnight each day -->
|
|
||||||
<param name="DatePattern" value="'.'yyyy-MM-dd" />
|
|
||||||
|
|
||||||
<param name="Threshold" value="TRACE" />
|
|
||||||
|
|
||||||
<layout class="org.apache.log4j.PatternLayout">
|
|
||||||
<!-- The default pattern: Date Priority [Category] Message\n -->
|
|
||||||
<param name="ConversionPattern" value="%d %-5p [%c] (%t) %m%n" />
|
|
||||||
|
|
||||||
<!--
|
|
||||||
The full pattern: Date MS Priority [Category]
|
|
||||||
(Thread:NDC) Message\n <param name="ConversionPattern"
|
|
||||||
value="%d %-5r %-5p [%c] (%t:%x) %m%n"/>
|
|
||||||
-->
|
|
||||||
</layout>
|
|
||||||
</appender>
|
|
||||||
|
|
||||||
<appender name="ASYNCCOMPUTE" class="org.apache.log4j.AsyncAppender">
|
|
||||||
<appender-ref ref="COMPUTEFILE" />
|
|
||||||
</appender>
|
|
||||||
|
|
||||||
<appender name="ASYNCSSH" class="org.apache.log4j.AsyncAppender">
|
|
||||||
<appender-ref ref="SSHFILE" />
|
|
||||||
</appender>
|
|
||||||
|
|
||||||
<appender name="ASYNC" class="org.apache.log4j.AsyncAppender">
|
|
||||||
<appender-ref ref="FILE" />
|
|
||||||
</appender>
|
|
||||||
|
|
||||||
<appender name="ASYNCWIRE" class="org.apache.log4j.AsyncAppender">
|
|
||||||
<appender-ref ref="WIREFILE" />
|
|
||||||
</appender>
|
|
||||||
|
|
||||||
<!-- ================ -->
|
|
||||||
<!-- Limit categories -->
|
|
||||||
<!-- ================ -->
|
|
||||||
|
|
||||||
<category name="org.jclouds">
|
|
||||||
<priority value="DEBUG" />
|
|
||||||
<appender-ref ref="ASYNC" />
|
|
||||||
</category>
|
|
||||||
|
|
||||||
<category name="jclouds.headers">
|
|
||||||
<priority value="DEBUG" />
|
|
||||||
<appender-ref ref="ASYNCWIRE" />
|
|
||||||
</category>
|
|
||||||
|
|
||||||
<category name="jclouds.ssh">
|
|
||||||
<priority value="TRACE" />
|
|
||||||
<appender-ref ref="ASYNCSSH" />
|
|
||||||
</category><!--
|
|
||||||
<category name="jclouds.signature">
|
|
||||||
<priority value="DEBUG" />
|
|
||||||
<appender-ref ref="ASYNCWIRE" />
|
|
||||||
</category>
|
|
||||||
|
|
||||||
--><category name="jclouds.wire">
|
|
||||||
<priority value="DEBUG" />
|
|
||||||
<appender-ref ref="ASYNCWIRE" />
|
|
||||||
</category>
|
|
||||||
|
|
||||||
<category name="jclouds.compute">
|
|
||||||
<priority value="TRACE" />
|
|
||||||
<appender-ref ref="ASYNCCOMPUTE" />
|
|
||||||
</category>
|
|
||||||
<!-- ======================= -->
|
|
||||||
<!-- Setup the Root category -->
|
|
||||||
<!-- ======================= -->
|
|
||||||
|
|
||||||
<root>
|
|
||||||
<priority value="WARN" />
|
|
||||||
</root>
|
|
||||||
|
|
||||||
</log4j:configuration>
|
|
|
@ -4,6 +4,8 @@
|
||||||
"port":80,
|
"port":80,
|
||||||
"condition":"ENABLED",
|
"condition":"ENABLED",
|
||||||
"status":"ONLINE",
|
"status":"ONLINE",
|
||||||
"weight":12
|
"weight":12,
|
||||||
|
"type":"PRIMARY",
|
||||||
|
"metadata":[]
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -0,0 +1 @@
|
||||||
|
{"node":{"condition":"DISABLED","weight":20}}
|
|
@ -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}]}
|
|
@ -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";
|
||||||
|
}
|
|
@ -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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -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"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -34,8 +34,8 @@
|
||||||
<packaging>bundle</packaging>
|
<packaging>bundle</packaging>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<test.cloudloadbalancers-uk.endpoint>https://lon.auth.api.rackspacecloud.com</test.cloudloadbalancers-uk.endpoint>
|
<test.cloudloadbalancers-uk.endpoint>https://lon.identity.api.rackspacecloud.com/v2.0/</test.cloudloadbalancers-uk.endpoint>
|
||||||
<test.cloudloadbalancers-uk.api-version>1.0</test.cloudloadbalancers-uk.api-version>
|
<test.cloudloadbalancers-uk.api-version>1</test.cloudloadbalancers-uk.api-version>
|
||||||
<test.cloudloadbalancers-uk.build-version></test.cloudloadbalancers-uk.build-version>
|
<test.cloudloadbalancers-uk.build-version></test.cloudloadbalancers-uk.build-version>
|
||||||
<test.cloudloadbalancers-uk.identity>${test.rackspace-uk.identity}</test.cloudloadbalancers-uk.identity>
|
<test.cloudloadbalancers-uk.identity>${test.rackspace-uk.identity}</test.cloudloadbalancers-uk.identity>
|
||||||
<test.cloudloadbalancers-uk.credential>${test.rackspace-uk.credential}</test.cloudloadbalancers-uk.credential>
|
<test.cloudloadbalancers-uk.credential>${test.rackspace-uk.credential}</test.cloudloadbalancers-uk.credential>
|
||||||
|
@ -45,6 +45,11 @@
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jclouds</groupId>
|
||||||
|
<artifactId>jclouds-loadbalancer</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.jclouds.api</groupId>
|
<groupId>org.jclouds.api</groupId>
|
||||||
<artifactId>cloudloadbalancers</artifactId>
|
<artifactId>cloudloadbalancers</artifactId>
|
||||||
|
@ -52,20 +57,20 @@
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.jclouds.api</groupId>
|
<groupId>org.jclouds.api</groupId>
|
||||||
<artifactId>cloudloadbalancers</artifactId>
|
<artifactId>openstack-keystone</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jclouds.api</groupId>
|
||||||
|
<artifactId>rackspace-cloudidentity</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
<type>test-jar</type>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.jclouds</groupId>
|
<groupId>org.jclouds</groupId>
|
||||||
<artifactId>jclouds-loadbalancer</artifactId>
|
<artifactId>jclouds-loadbalancer</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
</dependency>
|
<type>test-jar</type>
|
||||||
<dependency>
|
<scope>test</scope>
|
||||||
<groupId>org.jclouds.common</groupId>
|
|
||||||
<artifactId>openstack-common</artifactId>
|
|
||||||
<version>${project.version}</version>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.jclouds</groupId>
|
<groupId>org.jclouds</groupId>
|
||||||
|
@ -75,25 +80,30 @@
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.jclouds</groupId>
|
<groupId>org.jclouds.api</groupId>
|
||||||
<artifactId>jclouds-loadbalancer</artifactId>
|
<artifactId>cloudloadbalancers</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
<type>test-jar</type>
|
<type>test-jar</type>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.jclouds.common</groupId>
|
<groupId>org.jclouds.api</groupId>
|
||||||
<artifactId>openstack-common</artifactId>
|
<artifactId>openstack-keystone</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
<type>test-jar</type>
|
<type>test-jar</type>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.jclouds.driver</groupId>
|
<groupId>org.jclouds.driver</groupId>
|
||||||
<artifactId>jclouds-log4j</artifactId>
|
<artifactId>jclouds-slf4j</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>ch.qos.logback</groupId>
|
||||||
|
<artifactId>logback-classic</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<profiles>
|
<profiles>
|
||||||
<profile>
|
<profile>
|
||||||
|
@ -117,6 +127,7 @@
|
||||||
<test.cloudloadbalancers-uk.build-version>${test.cloudloadbalancers-uk.build-version}</test.cloudloadbalancers-uk.build-version>
|
<test.cloudloadbalancers-uk.build-version>${test.cloudloadbalancers-uk.build-version}</test.cloudloadbalancers-uk.build-version>
|
||||||
<test.cloudloadbalancers-uk.identity>${test.cloudloadbalancers-uk.identity}</test.cloudloadbalancers-uk.identity>
|
<test.cloudloadbalancers-uk.identity>${test.cloudloadbalancers-uk.identity}</test.cloudloadbalancers-uk.identity>
|
||||||
<test.cloudloadbalancers-uk.credential>${test.cloudloadbalancers-uk.credential}</test.cloudloadbalancers-uk.credential>
|
<test.cloudloadbalancers-uk.credential>${test.cloudloadbalancers-uk.credential}</test.cloudloadbalancers-uk.credential>
|
||||||
|
<test.jclouds.keystone.credential-type>${test.jclouds.keystone.credential-type}</test.jclouds.keystone.credential-type>
|
||||||
</systemPropertyVariables>
|
</systemPropertyVariables>
|
||||||
</configuration>
|
</configuration>
|
||||||
</execution>
|
</execution>
|
||||||
|
|
|
@ -18,21 +18,24 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.rackspace.cloudloadbalancers;
|
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.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.ISO3166_CODES;
|
||||||
import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGION;
|
import static org.jclouds.location.reference.LocationConstants.PROPERTY_ZONE;
|
||||||
import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGIONS;
|
import static org.jclouds.location.reference.LocationConstants.PROPERTY_ZONES;
|
||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
import org.jclouds.cloudloadbalancers.CloudLoadBalancersApiMetadata;
|
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.ProviderMetadata;
|
||||||
import org.jclouds.providers.internal.BaseProviderMetadata;
|
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.
|
* Implementation of {@link org.jclouds.types.ProviderMetadata} for Rackspace Cloud LoadBalancers UK.
|
||||||
|
@ -60,12 +63,8 @@ public class CloudLoadBalancersUKProviderMetadata extends BaseProviderMetadata {
|
||||||
|
|
||||||
public static Properties defaultProperties() {
|
public static Properties defaultProperties() {
|
||||||
Properties properties = new Properties();
|
Properties properties = new Properties();
|
||||||
properties.setProperty(PROPERTY_REGIONS, LON);
|
properties.setProperty(PROPERTY_ZONES, LON);
|
||||||
properties.setProperty(PROPERTY_ENDPOINT, "https://lon.auth.api.rackspacecloud.com");
|
properties.setProperty(PROPERTY_ZONE + ".LON." + ISO3166_CODES, "GB-SLG");
|
||||||
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));
|
|
||||||
return properties;
|
return properties;
|
||||||
}
|
}
|
||||||
public static class Builder extends BaseProviderMetadata.Builder {
|
public static class Builder extends BaseProviderMetadata.Builder {
|
||||||
|
@ -73,12 +72,26 @@ public class CloudLoadBalancersUKProviderMetadata extends BaseProviderMetadata {
|
||||||
protected Builder(){
|
protected Builder(){
|
||||||
id("cloudloadbalancers-uk")
|
id("cloudloadbalancers-uk")
|
||||||
.name("Rackspace Cloud Load Balancers UK")
|
.name("Rackspace Cloud Load Balancers UK")
|
||||||
.apiMetadata(new CloudLoadBalancersApiMetadata())
|
.apiMetadata(new CloudLoadBalancersApiMetadata().toBuilder()
|
||||||
.homepage(URI.create("http://www.rackspace.co.uk/cloud-hosting/cloud-products/cloud-load-balancers"))
|
.identityName("${userName}")
|
||||||
.console(URI.create("https://lon.manage.rackspacecloud.com"))
|
.credentialName("${apiKey}")
|
||||||
.linkedServices("cloudloadbalancers-uk", "cloudservers-uk", "cloudfiles-uk")
|
.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.<Class<? extends Module>>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")
|
.iso3166Codes("GB-SLG")
|
||||||
.endpoint("https://lon.auth.api.rackspacecloud.com");
|
.endpoint("https://lon.identity.api.rackspacecloud.com/v2.0/")
|
||||||
|
.defaultProperties(CloudLoadBalancersApiMetadata.defaultProperties());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -25,10 +25,9 @@ import org.testng.annotations.Test;
|
||||||
*
|
*
|
||||||
* @author Dan Lo Bianco
|
* @author Dan Lo Bianco
|
||||||
*/
|
*/
|
||||||
@Test(groups = "live", singleThreaded = true)
|
@Test(groups = "live", singleThreaded = true, testName = "CloudLoadBalancersUKLoadBalancerClientLiveTest")
|
||||||
public class CloudLoadBalancersUKLoadBalancerClientLiveTest extends LoadBalancerClientLiveTest {
|
public class CloudLoadBalancersUKLoadBalancerClientLiveTest extends LoadBalancerClientLiveTest {
|
||||||
public CloudLoadBalancersUKLoadBalancerClientLiveTest() {
|
public CloudLoadBalancersUKLoadBalancerClientLiveTest() {
|
||||||
provider = "cloudloadbalancers-uk";
|
provider = "cloudloadbalancers-uk";
|
||||||
regions = new String[] { "LON" };
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ import org.testng.annotations.Test;
|
||||||
*
|
*
|
||||||
* @author Dan Lo Bianco
|
* @author Dan Lo Bianco
|
||||||
*/
|
*/
|
||||||
@Test(groups = "live", singleThreaded = true)
|
@Test(groups = "live", singleThreaded = true, testName = "CloudLoadBalancersUKNodeClientLiveTest")
|
||||||
public class CloudLoadBalancersUKNodeClientLiveTest extends NodeClientLiveTest {
|
public class CloudLoadBalancersUKNodeClientLiveTest extends NodeClientLiveTest {
|
||||||
public CloudLoadBalancersUKNodeClientLiveTest() {
|
public CloudLoadBalancersUKNodeClientLiveTest() {
|
||||||
provider = "cloudloadbalancers-uk";
|
provider = "cloudloadbalancers-uk";
|
||||||
|
|
|
@ -34,8 +34,8 @@
|
||||||
<packaging>bundle</packaging>
|
<packaging>bundle</packaging>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<test.cloudloadbalancers-us.endpoint>https://auth.api.rackspacecloud.com</test.cloudloadbalancers-us.endpoint>
|
<test.cloudloadbalancers-us.endpoint>https://identity.api.rackspacecloud.com/v2.0/</test.cloudloadbalancers-us.endpoint>
|
||||||
<test.cloudloadbalancers-us.api-version>1.0</test.cloudloadbalancers-us.api-version>
|
<test.cloudloadbalancers-us.api-version>1</test.cloudloadbalancers-us.api-version>
|
||||||
<test.cloudloadbalancers-us.build-version></test.cloudloadbalancers-us.build-version>
|
<test.cloudloadbalancers-us.build-version></test.cloudloadbalancers-us.build-version>
|
||||||
<test.cloudloadbalancers-us.identity>${test.rackspace-us.identity}</test.cloudloadbalancers-us.identity>
|
<test.cloudloadbalancers-us.identity>${test.rackspace-us.identity}</test.cloudloadbalancers-us.identity>
|
||||||
<test.cloudloadbalancers-us.credential>${test.rackspace-us.credential}</test.cloudloadbalancers-us.credential>
|
<test.cloudloadbalancers-us.credential>${test.rackspace-us.credential}</test.cloudloadbalancers-us.credential>
|
||||||
|
@ -45,6 +45,11 @@
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jclouds</groupId>
|
||||||
|
<artifactId>jclouds-loadbalancer</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.jclouds.api</groupId>
|
<groupId>org.jclouds.api</groupId>
|
||||||
<artifactId>cloudloadbalancers</artifactId>
|
<artifactId>cloudloadbalancers</artifactId>
|
||||||
|
@ -52,19 +57,12 @@
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.jclouds.api</groupId>
|
<groupId>org.jclouds.api</groupId>
|
||||||
<artifactId>cloudloadbalancers</artifactId>
|
<artifactId>openstack-keystone</artifactId>
|
||||||
<version>${project.version}</version>
|
|
||||||
<type>test-jar</type>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.jclouds</groupId>
|
|
||||||
<artifactId>jclouds-loadbalancer</artifactId>
|
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.jclouds.common</groupId>
|
<groupId>org.jclouds.api</groupId>
|
||||||
<artifactId>openstack-common</artifactId>
|
<artifactId>rackspace-cloudidentity</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -82,18 +80,30 @@
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.jclouds.common</groupId>
|
<groupId>org.jclouds.api</groupId>
|
||||||
<artifactId>openstack-common</artifactId>
|
<artifactId>cloudloadbalancers</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
<type>test-jar</type>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jclouds.api</groupId>
|
||||||
|
<artifactId>openstack-keystone</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
<type>test-jar</type>
|
<type>test-jar</type>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.jclouds.driver</groupId>
|
<groupId>org.jclouds.driver</groupId>
|
||||||
<artifactId>jclouds-log4j</artifactId>
|
<artifactId>jclouds-slf4j</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>ch.qos.logback</groupId>
|
||||||
|
<artifactId>logback-classic</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<profiles>
|
<profiles>
|
||||||
<profile>
|
<profile>
|
||||||
|
@ -117,6 +127,7 @@
|
||||||
<test.cloudloadbalancers-us.build-version>${test.cloudloadbalancers-us.build-version}</test.cloudloadbalancers-us.build-version>
|
<test.cloudloadbalancers-us.build-version>${test.cloudloadbalancers-us.build-version}</test.cloudloadbalancers-us.build-version>
|
||||||
<test.cloudloadbalancers-us.identity>${test.cloudloadbalancers-us.identity}</test.cloudloadbalancers-us.identity>
|
<test.cloudloadbalancers-us.identity>${test.cloudloadbalancers-us.identity}</test.cloudloadbalancers-us.identity>
|
||||||
<test.cloudloadbalancers-us.credential>${test.cloudloadbalancers-us.credential}</test.cloudloadbalancers-us.credential>
|
<test.cloudloadbalancers-us.credential>${test.cloudloadbalancers-us.credential}</test.cloudloadbalancers-us.credential>
|
||||||
|
<test.jclouds.keystone.credential-type>${test.jclouds.keystone.credential-type}</test.jclouds.keystone.credential-type>
|
||||||
</systemPropertyVariables>
|
</systemPropertyVariables>
|
||||||
</configuration>
|
</configuration>
|
||||||
</execution>
|
</execution>
|
||||||
|
|
|
@ -18,24 +18,23 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.rackspace.cloudloadbalancers;
|
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.ISO3166_CODES;
|
||||||
import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGION;
|
import static org.jclouds.location.reference.LocationConstants.PROPERTY_ZONE;
|
||||||
import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGIONS;
|
import static org.jclouds.location.reference.LocationConstants.PROPERTY_ZONES;
|
||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
import org.jclouds.cloudloadbalancers.CloudLoadBalancersApiMetadata;
|
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.ProviderMetadata;
|
||||||
import org.jclouds.providers.internal.BaseProviderMetadata;
|
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.
|
* Implementation of {@link org.jclouds.types.ProviderMetadata} for Rackspace Cloud LoadBalancers US.
|
||||||
|
@ -60,21 +59,12 @@ public class CloudLoadBalancersUSProviderMetadata extends BaseProviderMetadata {
|
||||||
public CloudLoadBalancersUSProviderMetadata(Builder builder) {
|
public CloudLoadBalancersUSProviderMetadata(Builder builder) {
|
||||||
super(builder);
|
super(builder);
|
||||||
}
|
}
|
||||||
public static final String[] REGIONS = {ORD, DFW};
|
|
||||||
|
|
||||||
public static Properties defaultProperties() {
|
public static Properties defaultProperties() {
|
||||||
Properties properties = new Properties();
|
Properties properties = new Properties();
|
||||||
properties.setProperty(PROPERTY_ENDPOINT, "https://auth.api.rackspacecloud.com");
|
properties.setProperty(PROPERTY_ZONES, "ORD,DFW");
|
||||||
properties.setProperty(PROPERTY_REGIONS, Joiner.on(',').join(REGIONS));
|
properties.setProperty(PROPERTY_ZONE + ".ORD." + ISO3166_CODES, "US-IL");
|
||||||
properties.setProperty(PROPERTY_ISO3166_CODES, "US-IL,US-TX");
|
properties.setProperty(PROPERTY_ZONE + ".DFW." + ISO3166_CODES, "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));
|
|
||||||
return properties;
|
return properties;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,12 +73,26 @@ public class CloudLoadBalancersUSProviderMetadata extends BaseProviderMetadata {
|
||||||
protected Builder(){
|
protected Builder(){
|
||||||
id("cloudloadbalancers-us")
|
id("cloudloadbalancers-us")
|
||||||
.name("Rackspace Cloud Load Balancers US")
|
.name("Rackspace Cloud Load Balancers US")
|
||||||
.apiMetadata(new CloudLoadBalancersApiMetadata())
|
.apiMetadata(new CloudLoadBalancersApiMetadata().toBuilder()
|
||||||
.homepage(URI.create("http://www.rackspace.com/cloud/cloud_hosting_products/loadbalancers"))
|
.identityName("${userName}")
|
||||||
.console(URI.create("https://manage.rackspacecloud.com"))
|
.credentialName("${apiKey}")
|
||||||
.linkedServices("cloudloadbalancers-us", "cloudservers-us", "cloudfiles-us")
|
.version("1.0")
|
||||||
.iso3166Codes("US-IL","US-TX")
|
.defaultEndpoint("https://identity.api.rackspacecloud.com/v2.0/")
|
||||||
.endpoint("https://auth.api.rackspacecloud.com");
|
.endpointName("Identity service URL ending in /v2.0/")
|
||||||
|
.documentation(URI.create("http://docs.rackspace.com/loadbalancers/api/clb-devguide-latest/index.html"))
|
||||||
|
.defaultModules(ImmutableSet.<Class<? extends Module>>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
|
@Override
|
||||||
|
|
|
@ -25,10 +25,9 @@ import org.testng.annotations.Test;
|
||||||
*
|
*
|
||||||
* @author Dan Lo Bianco
|
* @author Dan Lo Bianco
|
||||||
*/
|
*/
|
||||||
@Test(groups = "live", singleThreaded = true)
|
@Test(groups = "live", singleThreaded = true, testName = "CloudLoadBalancersUSLoadBalancerClientLiveTest")
|
||||||
public class CloudLoadBalancersUSLoadBalancerClientLiveTest extends LoadBalancerClientLiveTest {
|
public class CloudLoadBalancersUSLoadBalancerClientLiveTest extends LoadBalancerClientLiveTest {
|
||||||
public CloudLoadBalancersUSLoadBalancerClientLiveTest() {
|
public CloudLoadBalancersUSLoadBalancerClientLiveTest() {
|
||||||
provider = "cloudloadbalancers-us";
|
provider = "cloudloadbalancers-us";
|
||||||
regions = CloudLoadBalancersUSProviderMetadata.REGIONS;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ import org.testng.annotations.Test;
|
||||||
*
|
*
|
||||||
* @author Dan Lo Bianco
|
* @author Dan Lo Bianco
|
||||||
*/
|
*/
|
||||||
@Test(groups = "live", singleThreaded = true)
|
@Test(groups = "live", singleThreaded = true, testName = "CloudLoadBalancersUSNodeClientLiveTest")
|
||||||
public class CloudLoadBalancersUSNodeClientLiveTest extends NodeClientLiveTest {
|
public class CloudLoadBalancersUSNodeClientLiveTest extends NodeClientLiveTest {
|
||||||
public CloudLoadBalancersUSNodeClientLiveTest() {
|
public CloudLoadBalancersUSNodeClientLiveTest() {
|
||||||
provider = "cloudloadbalancers-us";
|
provider = "cloudloadbalancers-us";
|
||||||
|
|
|
@ -83,7 +83,7 @@ public class CloudServersUSProviderMetadata extends BaseProviderMetadata {
|
||||||
.version("2")
|
.version("2")
|
||||||
.defaultEndpoint("https://identity.api.rackspacecloud.com/v2.0/")
|
.defaultEndpoint("https://identity.api.rackspacecloud.com/v2.0/")
|
||||||
.endpointName("identity service url ending in /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.<Class<? extends Module>>builder()
|
.defaultModules(ImmutableSet.<Class<? extends Module>>builder()
|
||||||
.add(CloudIdentityAuthenticationModule.class)
|
.add(CloudIdentityAuthenticationModule.class)
|
||||||
.add(ZoneModule.class)
|
.add(ZoneModule.class)
|
||||||
|
|
Loading…
Reference in New Issue