Skip to content
Permalink
Browse files
Adds Otter (Rackspace Autoscale) to labs https://issues.apache.org/ji…
  • Loading branch information
zack-shoylev committed Aug 30, 2013
1 parent 9f440d6 commit 46f493ac869890fef4085af3de6c1801736a4c23
Showing 39 changed files with 4,497 additions and 0 deletions.
@@ -69,6 +69,8 @@
<module>openstack-swift</module>
<module>rackspace-clouddatabases-us</module>
<module>rackspace-clouddatabases-uk</module>
<module>rackspace-autoscale</module>
<module>rackspace-autoscale-us</module>
</modules>

<build>
@@ -0,0 +1,145 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.jclouds</groupId>
<artifactId>jclouds-project</artifactId>
<version>1.7.0-SNAPSHOT</version>
</parent>

<!-- TODO: when out of labs, switch to org.jclouds.api -->
<groupId>org.apache.jclouds.labs</groupId>
<artifactId>rackspace-autoscale-us</artifactId>
<version>1.7.0-SNAPSHOT</version>
<name>jclouds rackspace-autoscale api provider</name>
<description>jclouds components to access Rackspace Autoscale</description>
<packaging>bundle</packaging>

<properties>
<!-- keystone endpoint -->
<test.rackspace-autoscale.endpoint>http://localhost:5000/v2.0/</test.rackspace-autoscale.endpoint>
<!-- keystone version -->
<test.rackspace-autoscale.api-version>2.0</test.rackspace-autoscale.api-version>
<test.rackspace-autoscale.build-version />
<test.rackspace-autoscale.identity>FIXME_IDENTITY</test.rackspace-autoscale.identity>
<test.rackspace-autoscale.credential>FIXME_CREDENTIALS</test.rackspace-autoscale.credential>
<test.jclouds.keystone.credential-type>passwordCredentials</test.jclouds.keystone.credential-type>

<jclouds.osgi.export>org.jclouds.rackspace.autoscale.v1_0*;version="${project.version}"</jclouds.osgi.export>
<jclouds.osgi.import>
org.jclouds.rest.internal;version="${jclouds.version}",
org.jclouds.labs*;version="${project.version}",
org.jclouds*;version="${jclouds.version}",
*
</jclouds.osgi.import>
</properties>

<dependencies>
<dependency>
<groupId>org.apache.jclouds.labs</groupId>
<artifactId>rackspace-autoscale</artifactId>
<version>${project.parent.version}</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.jclouds.labs</groupId>
<artifactId>rackspace-autoscale</artifactId>
<version>${project.parent.version}</version>
</dependency>
<dependency>
<groupId>org.apache.jclouds.api</groupId>
<artifactId>openstack-keystone</artifactId>
<version>${project.parent.version}</version>
</dependency>
<dependency>
<groupId>org.apache.jclouds.api</groupId>
<artifactId>openstack-keystone</artifactId>
<version>${project.parent.version}</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.jclouds</groupId>
<artifactId>jclouds-core</artifactId>
<version>${project.parent.version}</version>
</dependency>
<dependency>
<groupId>org.apache.jclouds</groupId>
<artifactId>jclouds-core</artifactId>
<version>${project.parent.version}</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.jclouds.driver</groupId>
<artifactId>jclouds-slf4j</artifactId>
<version>${project.parent.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.jclouds.api</groupId>
<artifactId>rackspace-cloudidentity</artifactId>
<version>${project.parent.version}</version>
</dependency>
</dependencies>

<profiles>
<profile>
<id>live</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<executions>
<execution>
<id>integration</id>
<phase>integration-test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<forkCount>5</forkCount>
<reuseForks>true</reuseForks>
<parallel>classes</parallel>
<systemPropertyVariables>
<test.rackspace-autoscale.endpoint>${test.rackspace-autoscale-us.endpoint}</test.rackspace-autoscale.endpoint>
<test.rackspace-autoscale.api-version>${test.rackspace-autoscale-us.api-version}</test.rackspace-autoscale.api-version>
<test.rackspace-autoscale.build-version>${test.rackspace-autoscale-us.build-version}</test.rackspace-autoscale.build-version>
<test.rackspace-autoscale.identity>${test.rackspace-autoscale-us.identity}</test.rackspace-autoscale.identity>
<test.rackspace-autoscale.credential>${test.rackspace-autoscale-us.credential}</test.rackspace-autoscale.credential>
</systemPropertyVariables>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>

</project>
@@ -0,0 +1,114 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jclouds.rackspace.autoscale.us.v1;

import static org.jclouds.location.reference.LocationConstants.ISO3166_CODES;
import static org.jclouds.location.reference.LocationConstants.PROPERTY_ZONE;
import static org.jclouds.location.reference.LocationConstants.PROPERTY_ZONES;
import static org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties.CREDENTIAL_TYPE;
import static org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties.SERVICE_TYPE;

import java.net.URI;
import java.util.Properties;

import org.jclouds.apis.ApiMetadata;
import org.jclouds.openstack.keystone.v2_0.config.KeystoneAuthenticationModule.ZoneModule;
import org.jclouds.providers.ProviderMetadata;
import org.jclouds.providers.internal.BaseProviderMetadata;
import org.jclouds.rackspace.autoscale.v1.AutoscaleApiMetadata;
import org.jclouds.rackspace.autoscale.v1.config.AutoscaleHttpApiModule;
import org.jclouds.rackspace.autoscale.v1.config.AutoscaleParserModule;
import org.jclouds.rackspace.cloudidentity.v2_0.config.CloudIdentityAuthenticationApiModule;
import org.jclouds.rackspace.cloudidentity.v2_0.config.CloudIdentityAuthenticationModule;
import org.jclouds.rackspace.cloudidentity.v2_0.config.CloudIdentityCredentialTypes;

import com.google.common.collect.ImmutableSet;
import com.google.inject.Module;

/**
* Implementation of {@link ProviderMetadata} for Rackspace Autoscale API
*
* @author Zack Shoylev
*/
public class AutoscaleUSProviderMetadata extends BaseProviderMetadata {

public static Builder builder() {
return new Builder();
}

@Override
public Builder toBuilder() {
return builder().fromProviderMetadata(this);
}

public AutoscaleUSProviderMetadata() {
super(builder());
}

public AutoscaleUSProviderMetadata(Builder builder) {
super(builder);
}

public static Properties defaultProperties() {
Properties properties = new Properties();
properties.setProperty(CREDENTIAL_TYPE, CloudIdentityCredentialTypes.API_KEY_CREDENTIALS);
properties.setProperty(SERVICE_TYPE, "rax:autoscale");
properties.setProperty(PROPERTY_ZONES, "ORD,DFW,SYD");
properties.setProperty(PROPERTY_ZONE + ".ORD." + ISO3166_CODES, "US-IL");
properties.setProperty(PROPERTY_ZONE + ".DFW." + ISO3166_CODES, "US-TX");
properties.setProperty(PROPERTY_ZONE + ".SYD." + ISO3166_CODES, "AU-NSW");
return properties;
}

public static class Builder extends BaseProviderMetadata.Builder {

protected Builder(){
id("rackspace-autoscale-us")
.name("Rackspace autoscale US")
.apiMetadata(new AutoscaleApiMetadata().toBuilder()
.identityName("${userName}")
.credentialName("${apiKey}")
.defaultEndpoint("https://identity.api.rackspacecloud.com/v2.0/")
.endpointName("identity service url ending in /v2.0/")
.documentation(URI.create("http://docs.rackspace.com/cbs/api/v1.0/cbs-devguide/content/overview.html"))
.defaultModules(ImmutableSet.<Class<? extends Module>>builder()
.add(CloudIdentityAuthenticationApiModule.class)
.add(CloudIdentityAuthenticationModule.class)
.add(ZoneModule.class)
.add(AutoscaleParserModule.class)
.add(AutoscaleHttpApiModule.class).build())
.build())
.homepage(URI.create("http://www.rackspace.com/cloud/public/autoscale/"))
.console(URI.create("https://mycloud.rackspace.com"))
.linkedServices("rackspace-cloudservers-us", "cloudfiles-us")
.iso3166Codes("US-IL", "US-TX", "AU-NSW")
.endpoint("https://identity.api.rackspacecloud.com/v2.0/")
.defaultProperties(AutoscaleUSProviderMetadata.defaultProperties());
}

@Override
public AutoscaleUSProviderMetadata build() {
return new AutoscaleUSProviderMetadata(this);
}

@Override
public Builder fromProviderMetadata(ProviderMetadata in) {
super.fromProviderMetadata(in);
return this;
}
}
}
@@ -0,0 +1,18 @@
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

org.jclouds.rackspace.autoscale.us.v1.AutoscaleUSProviderMetadata
@@ -0,0 +1,64 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jclouds.rackspace.autoscale.us.v1;

import static org.testng.Assert.assertEquals;

import org.jclouds.http.HttpRequest;
import org.jclouds.http.HttpResponse;
import org.jclouds.rackspace.autoscale.v1.AutoscaleApi;
import org.jclouds.rackspace.autoscale.v1.internal.BaseAutoscaleApiExpectTest;
import org.testng.annotations.Test;

import com.google.common.collect.ImmutableSet;

/**
* This test ensures that the wiring in {@link AutoscaleUSProviderMetadata} is correct.
*
* @author Zack Shoylev
*/
@Test(groups = "unit", testName = "AutoscaleUSProviderMetadataExpectTest")
public class AutoscaleUSProviderMetadataExpectTest extends BaseAutoscaleApiExpectTest {

public AutoscaleUSProviderMetadataExpectTest() {
this.provider = "rackspace-autoscale-us";
this.identity = "myUsername";
this.credential = "myApiKey";
}

public void testCanGetConfiguredZones() {

HttpRequest authenticate = HttpRequest.builder().method("POST")
.endpoint("https://identity.api.rackspacecloud.com/v2.0/tokens")
.addHeader("Accept", "application/json")
.payload(payloadFromStringWithContentType(
"{\"auth\":{\"RAX-KSKEY:apiKeyCredentials\":{\"username\":\"myUsername\",\"apiKey\":\"myApiKey\"}}}"
, "application/json")).build();


HttpResponse authenticationResponse = HttpResponse.builder()
.statusCode(200)
.payload(payloadFromResourceWithContentType("/access_rax_us.json", "application/json"))
.build();

AutoscaleApi whenNovaRegionExists = requestSendsResponse(authenticate, authenticationResponse);

assertEquals(whenNovaRegionExists.getConfiguredZones(), ImmutableSet.of("ORD", "DFW"));

}

}
@@ -0,0 +1,32 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jclouds.rackspace.autoscale.us.v1;

import org.jclouds.providers.internal.BaseProviderMetadataTest;
import org.jclouds.rackspace.autoscale.v1.AutoscaleApiMetadata;
import org.testng.annotations.Test;

/**
* @author Zack Shoylev
*/
@Test(groups = "unit", testName = "AutoscaleUSProviderTest")
public class AutoscaleUSProviderTest extends BaseProviderMetadataTest {

public AutoscaleUSProviderTest() {
super(new AutoscaleUSProviderMetadata(), new AutoscaleApiMetadata());
}
}

0 comments on commit 46f493a

Please sign in to comment.