Skip to content
Permalink
Browse files
Support Rackspace Cloud Networks UK
  • Loading branch information
Jeremy Daggett committed Jan 14, 2015
1 parent 5f2af52 commit e934350ca68b1a99adbefdfeae9c31297d4852a8
Showing 9 changed files with 582 additions and 0 deletions.
@@ -68,6 +68,7 @@
<module>rackspace-cloudfiles</module>
<module>rackspace-cloudfiles-uk</module>
<module>rackspace-cloudfiles-us</module>
<module>rackspace-cloudnetworks-uk</module>
<module>rackspace-cloudnetworks-us</module>
</modules>

@@ -0,0 +1,4 @@
Rackspace Networks UK
========================

Beta
@@ -0,0 +1,125 @@
<?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>2.0.0-SNAPSHOT</version>
<relativePath />
</parent>

<!-- TODO: when out of labs, switch to org.jclouds.provider -->
<groupId>org.apache.jclouds.labs</groupId>
<artifactId>rackspace-cloudnetworks-uk</artifactId>
<version>2.0.0-SNAPSHOT</version>
<name>jclouds Rackspace Cloud Networks UK provider</name>
<description>OpenStack Neutron implementation targeted to Rackspace Cloud Networks UK</description>
<packaging>bundle</packaging>

<properties>
<!-- identity endpoint -->
<test.rackspace-cloudnetworks-uk.endpoint>https://lon.identity.api.rackspacecloud.com/v2.0/</test.rackspace-cloudnetworks-uk.endpoint>
<test.rackspace-cloudnetworks-uk.api-version>2.0</test.rackspace-cloudnetworks-uk.api-version>
<test.rackspace-cloudnetworks-uk.build-version />
<test.rackspace-cloudnetworks-uk.identity>${test.rackspace-uk.identity}</test.rackspace-cloudnetworks-uk.identity>
<test.rackspace-cloudnetworks-uk.credential>${test.rackspace-uk.credential}</test.rackspace-cloudnetworks-uk.credential>
<jclouds.osgi.export>org.jclouds.rackspace.cloudnetworks.uk*;version="${project.version}"</jclouds.osgi.export>
<jclouds.osgi.import>org.jclouds*;version="${project.version}",*</jclouds.osgi.import>
</properties>

<dependencies>
<dependency>
<groupId>org.apache.jclouds.labs</groupId>
<artifactId>openstack-neutron</artifactId>
<version>${project.parent.version}</version>
</dependency>
<dependency>
<groupId>org.apache.jclouds.api</groupId>
<artifactId>rackspace-cloudidentity</artifactId>
<version>${project.parent.version}</version>
</dependency>

<!-- Test Dependencies -->
<dependency>
<groupId>org.apache.jclouds.labs</groupId>
<artifactId>openstack-neutron</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>
<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>com.google.auto.service</groupId>
<artifactId>auto-service</artifactId>
<optional>true</optional>
</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>
<systemPropertyVariables>
<test.rackspace-cloudnetworks-uk.endpoint>${test.rackspace-cloudnetworks-uk.endpoint}</test.rackspace-cloudnetworks-uk.endpoint>
<test.rackspace-cloudnetworks-uk.api-version>${test.rackspace-cloudnetworks-uk.api-version}</test.rackspace-cloudnetworks-uk.api-version>
<test.rackspace-cloudnetworks-uk.build-version>${test.rackspace-cloudnetworks-uk.build-version}</test.rackspace-cloudnetworks-uk.build-version>
<test.rackspace-cloudnetworks-uk.identity>${test.rackspace-cloudnetworks-uk.identity}</test.rackspace-cloudnetworks-uk.identity>
<test.rackspace-cloudnetworks-uk.credential>${test.rackspace-cloudnetworks-uk.credential}</test.rackspace-cloudnetworks-uk.credential>
</systemPropertyVariables>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>

</project>
@@ -0,0 +1,118 @@
/*
* 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.cloudnetworks.uk;

import static org.jclouds.location.reference.LocationConstants.ISO3166_CODES;
import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGION;
import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGIONS;
import static org.jclouds.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.openstack.keystone.v2_0.config.KeystoneAuthenticationModule.RegionModule;
import org.jclouds.openstack.neutron.v2.NeutronApiMetadata;
import org.jclouds.openstack.neutron.v2.config.NeutronHttpApiModule;
import org.jclouds.openstack.v2_0.ServiceType;
import org.jclouds.providers.ProviderMetadata;
import org.jclouds.providers.internal.BaseProviderMetadata;
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.auto.service.AutoService;
import com.google.common.collect.ImmutableSet;
import com.google.inject.Module;

@AutoService(ProviderMetadata.class)
public class CloudNetworksUKProviderMetadata extends BaseProviderMetadata {

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

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

public CloudNetworksUKProviderMetadata() {
this(new Builder());
}

protected CloudNetworksUKProviderMetadata(Builder builder) {
super(builder);
}

/**
* @return a {@link Properties} object containing the default provider properties.
* This returns the credential type, service type, and configured regions.
*/
public static Properties defaultProperties() {
Properties properties = new Properties();
properties.setProperty(CREDENTIAL_TYPE, CloudIdentityCredentialTypes.API_KEY_CREDENTIALS);
properties.setProperty(SERVICE_TYPE, ServiceType.NETWORK);

properties.setProperty(PROPERTY_REGIONS, "LON");
properties.setProperty(PROPERTY_REGION + ".LON." + ISO3166_CODES, "GB-SLG");

return properties;
}

public static class Builder extends BaseProviderMetadata.Builder {

protected Builder() {
id("rackspace-cloudnetworks-uk")
.name("Rackspace Cloud Networks UK")
.apiMetadata(new NeutronApiMetadata().toBuilder()
.identityName("${userName}")
.credentialName("${apiKey}")
.defaultEndpoint("https://lon.identity.api.rackspacecloud.com/v2.0/")
.documentation(URI.create("http://docs.rackspace.com/networks/api/v1/cf-devguide/content/index.html"))
.endpointName("Rackspace Cloud Identity service URL ending in /v2.0/")
.version("2.0")
.defaultModules(ImmutableSet.<Class<? extends Module>>builder()
.add(CloudIdentityAuthenticationApiModule.class)
.add(CloudIdentityAuthenticationModule.class)
.add(RegionModule.class)
.add(NeutronHttpApiModule.class)
.build())
.build())
.homepage(URI.create("http://www.rackspace.com/cloud/networks"))
.console(URI.create("https://mycloud.rackspace.co.uk"))
.linkedServices("rackspace-autoscale-uk", "rackspace-cloudblockstorage-uk",
"rackspace-clouddatabases-uk", "rackspace-clouddns-uk", "rackspace-cloudidentity",
"rackspace-cloudloadbalancers-uk", "rackspace-cloudqueues-uk",
"rackspace-cloudservers-uk")
.iso3166Codes("GB-SLG")
.defaultProperties(CloudNetworksUKProviderMetadata.defaultProperties());

}

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

@Override
public Builder fromProviderMetadata(ProviderMetadata in) {
super.fromProviderMetadata(in);
return this;
}
}
}
@@ -0,0 +1,76 @@
/*
* 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.cloudnetworks.uk;

import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertTrue;

import org.jclouds.openstack.neutron.v2.domain.Network;
import org.jclouds.openstack.neutron.v2.features.NetworkApi;
import org.jclouds.openstack.neutron.v2.features.NetworkApiLiveTest;
import org.testng.SkipException;
import org.testng.annotations.Test;

@Test(groups = "live", testName = "CloudNetworksUKNetworkApiLiveTest", singleThreaded = true)
public class CloudNetworksUKNetworkApiLiveTest extends NetworkApiLiveTest {
public CloudNetworksUKNetworkApiLiveTest() {
provider = "rackspace-cloudnetworks-uk";
}

@Override
public void testCreateUpdateAndDeleteNetwork() {
for (String region : api.getConfiguredRegions()) {
NetworkApi networkApi = api.getNetworkApi(region);
Network net = networkApi.create(Network.createBuilder("jclouds-test").build());
Network test = networkApi.create(Network.createBuilder("jclouds-test").build());
assertNotNull(net);

/* List and get tests */
Network networkList = api.getNetworkApi(region).list().concat().toSet().iterator().next();
assertNotNull(networkList);
Network networkGet = api.getNetworkApi(region).get(networkList.getId());
assertEquals(networkList, networkGet);
/****/

Network network = networkApi.get(net.getId());

assertEquals(network.getId(), net.getId());
assertEquals(network.getName(), "jclouds-test");
assertTrue(network.getSubnets().isEmpty());
assertNotNull(networkApi.update(net.getId(), Network.updateBuilder().name("jclouds-live-test").build()));

network = networkApi.get(net.getId());

assertEquals(network.getId(), net.getId());
assertEquals(network.getName(), "jclouds-live-test");
assertTrue(network.getSubnets().isEmpty());

Network net2 = networkApi.create(Network.createBuilder("jclouds-test2").build());
assertNotNull(net2);

assertTrue(networkApi.delete(net.getId()));
assertTrue(networkApi.delete(net2.getId()));
assertTrue(networkApi.delete(test.getId()));
}
}

@Override
public void testBulkCreateNetwork() {
throw new SkipException("unsupported functionality");
}
}

0 comments on commit e934350

Please sign in to comment.