diff --git a/providers/rackspace-cloudnetworks-uk/README.md b/providers/rackspace-cloudnetworks-uk/README.md new file mode 100644 index 0000000000..dc52a0f488 --- /dev/null +++ b/providers/rackspace-cloudnetworks-uk/README.md @@ -0,0 +1,4 @@ +Rackspace Networks UK +======================== + +Beta diff --git a/providers/rackspace-cloudnetworks-uk/pom.xml b/providers/rackspace-cloudnetworks-uk/pom.xml new file mode 100644 index 0000000000..1cf16fc961 --- /dev/null +++ b/providers/rackspace-cloudnetworks-uk/pom.xml @@ -0,0 +1,125 @@ + + + + 4.0.0 + + org.apache.jclouds + jclouds-project + 2.0.0-SNAPSHOT + + + + + org.apache.jclouds.labs + rackspace-cloudnetworks-uk + 2.0.0-SNAPSHOT + jclouds Rackspace Cloud Networks UK provider + OpenStack Neutron implementation targeted to Rackspace Cloud Networks UK + bundle + + + + https://lon.identity.api.rackspacecloud.com/v2.0/ + 2.0 + + ${test.rackspace-uk.identity} + ${test.rackspace-uk.credential} + org.jclouds.rackspace.cloudnetworks.uk*;version="${project.version}" + org.jclouds*;version="${project.version}",* + + + + + org.apache.jclouds.labs + openstack-neutron + ${project.parent.version} + + + org.apache.jclouds.api + rackspace-cloudidentity + ${project.parent.version} + + + + + org.apache.jclouds.labs + openstack-neutron + ${project.parent.version} + test-jar + test + + + org.apache.jclouds + jclouds-core + ${project.parent.version} + test-jar + test + + + org.apache.jclouds.driver + jclouds-slf4j + ${project.parent.version} + test + + + ch.qos.logback + logback-classic + test + + + com.google.auto.service + auto-service + true + + + + + + live + + + + org.apache.maven.plugins + maven-surefire-plugin + + + integration + integration-test + + test + + + + ${test.rackspace-cloudnetworks-uk.endpoint} + ${test.rackspace-cloudnetworks-uk.api-version} + ${test.rackspace-cloudnetworks-uk.build-version} + ${test.rackspace-cloudnetworks-uk.identity} + ${test.rackspace-cloudnetworks-uk.credential} + + + + + + + + + + + diff --git a/providers/rackspace-cloudnetworks-uk/src/main/java/org/jclouds/rackspace/cloudnetworks/uk/CloudNetworksUKProviderMetadata.java b/providers/rackspace-cloudnetworks-uk/src/main/java/org/jclouds/rackspace/cloudnetworks/uk/CloudNetworksUKProviderMetadata.java new file mode 100644 index 0000000000..4cc4c16270 --- /dev/null +++ b/providers/rackspace-cloudnetworks-uk/src/main/java/org/jclouds/rackspace/cloudnetworks/uk/CloudNetworksUKProviderMetadata.java @@ -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.>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; + } + } +} diff --git a/providers/rackspace-cloudnetworks-uk/src/test/java/org/jclouds/rackspace/cloudnetworks/uk/CloudNetworksUKNetworkApiLiveTest.java b/providers/rackspace-cloudnetworks-uk/src/test/java/org/jclouds/rackspace/cloudnetworks/uk/CloudNetworksUKNetworkApiLiveTest.java new file mode 100644 index 0000000000..e6fd5c76ac --- /dev/null +++ b/providers/rackspace-cloudnetworks-uk/src/test/java/org/jclouds/rackspace/cloudnetworks/uk/CloudNetworksUKNetworkApiLiveTest.java @@ -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"); + } +} diff --git a/providers/rackspace-cloudnetworks-uk/src/test/java/org/jclouds/rackspace/cloudnetworks/uk/CloudNetworksUKPortApiLiveTest.java b/providers/rackspace-cloudnetworks-uk/src/test/java/org/jclouds/rackspace/cloudnetworks/uk/CloudNetworksUKPortApiLiveTest.java new file mode 100644 index 0000000000..1685766b2c --- /dev/null +++ b/providers/rackspace-cloudnetworks-uk/src/test/java/org/jclouds/rackspace/cloudnetworks/uk/CloudNetworksUKPortApiLiveTest.java @@ -0,0 +1,85 @@ +/* + * 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.domain.Port; +import org.jclouds.openstack.neutron.v2.domain.Subnet; +import org.jclouds.openstack.neutron.v2.features.NetworkApi; +import org.jclouds.openstack.neutron.v2.features.PortApi; +import org.jclouds.openstack.neutron.v2.features.PortApiLiveTest; +import org.jclouds.openstack.neutron.v2.features.SubnetApi; +import org.testng.SkipException; +import org.testng.annotations.Test; + +import com.google.common.collect.ImmutableSet; + +@Test(groups = "live", testName = "CloudNetworksUKPortApiLiveTest", singleThreaded = true) +public class CloudNetworksUKPortApiLiveTest extends PortApiLiveTest { + public CloudNetworksUKPortApiLiveTest() { + provider = "rackspace-cloudnetworks-uk"; + } + + public void testCreateUpdateAndDeletePort() { + for (String region : api.getConfiguredRegions()) { + NetworkApi networkApi = api.getNetworkApi(region); + SubnetApi subnetApi = api.getSubnetApi(region); + PortApi portApi = api.getPortApi(region); + String networkId = networkApi.create( + Network.createBuilder("JClouds-Live-Network").build()).getId(); + String ipv4SubnetId = subnetApi.create(Subnet.createBuilder(networkId, "192.168.0.0/30").ipVersion(4) + .name("JClouds-Live-IPv4-Subnet").build()).getId(); + + assertNotNull(networkId); + assertNotNull(ipv4SubnetId); + + String ipv4PortId = portApi.create(Port.createBuilder(networkId).name("JClouds-Live-IPv4-Port") + .fixedIps(ImmutableSet.copyOf(getFixedAddresses(ipv4SubnetId))).build()).getId(); + + /* List and get test */ + Port portList = api.getPortApi(region).list().concat().toSet().iterator().next(); + assertNotNull(portList); + Port portGet = api.getPortApi(region).get(portList.getId()); + assertEquals(portList, portGet); + /****/ + + assertNotNull(ipv4PortId); + + Port ipv4Port = portApi.get(ipv4PortId); + assertNotNull(ipv4Port); + assertEquals(ipv4Port.getId(), ipv4PortId); + assertEquals(ipv4Port.getName(), "JClouds-Live-IPv4-Port"); + + assertNotNull(portApi.update(ipv4PortId, Port.updateBuilder().name("Updated").build())); + Port updatedIpv4Port = portApi.get(ipv4PortId); + assertEquals(updatedIpv4Port.getName(), "Updated"); + + assertTrue(portApi.delete(ipv4PortId)); + assertTrue(subnetApi.delete(ipv4SubnetId)); + assertTrue(networkApi.delete(networkId)); + } + } + + @Override + public void testBulkCreatePort() { + throw new SkipException("unsupported functionality"); + } +} diff --git a/providers/rackspace-cloudnetworks-uk/src/test/java/org/jclouds/rackspace/cloudnetworks/uk/CloudNetworksUKProviderTest.java b/providers/rackspace-cloudnetworks-uk/src/test/java/org/jclouds/rackspace/cloudnetworks/uk/CloudNetworksUKProviderTest.java new file mode 100644 index 0000000000..2b2a01ca7b --- /dev/null +++ b/providers/rackspace-cloudnetworks-uk/src/test/java/org/jclouds/rackspace/cloudnetworks/uk/CloudNetworksUKProviderTest.java @@ -0,0 +1,28 @@ +/* + * 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 org.jclouds.openstack.neutron.v2.NeutronApiMetadata; +import org.jclouds.providers.internal.BaseProviderMetadataTest; +import org.testng.annotations.Test; + +@Test(groups = "unit", testName = "CloudNetworksUKProviderTest", singleThreaded = true) +public class CloudNetworksUKProviderTest extends BaseProviderMetadataTest { + public CloudNetworksUKProviderTest() { + super(new CloudNetworksUKProviderMetadata(), new NeutronApiMetadata()); + } +} diff --git a/providers/rackspace-cloudnetworks-uk/src/test/java/org/jclouds/rackspace/cloudnetworks/uk/CloudNetworksUKSubnetApiLiveTest.java b/providers/rackspace-cloudnetworks-uk/src/test/java/org/jclouds/rackspace/cloudnetworks/uk/CloudNetworksUKSubnetApiLiveTest.java new file mode 100644 index 0000000000..54df5e0569 --- /dev/null +++ b/providers/rackspace-cloudnetworks-uk/src/test/java/org/jclouds/rackspace/cloudnetworks/uk/CloudNetworksUKSubnetApiLiveTest.java @@ -0,0 +1,89 @@ +/* + * 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.AllocationPool; +import org.jclouds.openstack.neutron.v2.domain.HostRoute; +import org.jclouds.openstack.neutron.v2.domain.Network; +import org.jclouds.openstack.neutron.v2.domain.Subnet; +import org.jclouds.openstack.neutron.v2.features.NetworkApi; +import org.jclouds.openstack.neutron.v2.features.SubnetApi; +import org.jclouds.openstack.neutron.v2.features.SubnetApiLiveTest; +import org.testng.SkipException; +import org.testng.annotations.Test; + +import com.google.common.collect.ImmutableSet; + +@Test(groups = "live", testName = "CloudNetworksUKSubnetApiLiveTest", singleThreaded = true) +public class CloudNetworksUKSubnetApiLiveTest extends SubnetApiLiveTest { + public CloudNetworksUKSubnetApiLiveTest() { + provider = "rackspace-cloudnetworks-uk"; + } + + @Override + public void testCreateUpdateAndDeleteSubnet() { + for (String region : api.getConfiguredRegions()) { + NetworkApi networkApi = api.getNetworkApi(region); + String networkId = networkApi.create( + Network.createBuilder("jclouds-live-test").build()).getId(); + + SubnetApi subnetApi = api.getSubnetApi(region); + ImmutableSet allocationPools = ImmutableSet.of( + AllocationPool.builder().start("192.168.100.0").end("192.168.100.2").build() + ); + ImmutableSet hostRoutes = ImmutableSet.of( + HostRoute.builder().destinationCidr("192.168.100.0/30").nextHop("192.168.100.4").build() + ); + Subnet subnet = subnetApi.create(Subnet.createBuilder(networkId, "192.168.100.0/30").ipVersion(4).allocationPools(allocationPools).hostRoutes(hostRoutes).build()); + assertNotNull(subnet); + + /* Test list and get */ + Subnet subnetList = api.getSubnetApi(region).list().concat().toSet().iterator().next(); + assertNotNull(subnetList); + Subnet subnetGet = api.getSubnetApi(region).get(subnetList.getId()); + assertEquals(subnetList, subnetGet); + /***/ + + Subnet retrievedSubnet = subnetApi.get(subnet.getId()); + + assertEquals(retrievedSubnet.getId(), subnet.getId()); + assertEquals(retrievedSubnet.getCidr(), "192.168.100.0/30"); + assertTrue(retrievedSubnet.getDnsNameservers().isEmpty()); + assertEquals(retrievedSubnet.getAllocationPools().size(), 1); + assertEquals(retrievedSubnet.getHostRoutes().size(), 1); + assertNotNull(subnetApi.update(retrievedSubnet.getId(), Subnet.updateBuilder().name("jclouds-live-test-update").build())); + + retrievedSubnet = subnetApi.get(retrievedSubnet.getId()); + + assertEquals(retrievedSubnet.getId(), subnet.getId()); + assertEquals(retrievedSubnet.getName(), "jclouds-live-test-update"); + assertTrue(retrievedSubnet.getDnsNameservers().isEmpty()); + + assertTrue(subnetApi.delete(subnet.getId())); + assertTrue(networkApi.delete(networkId)); + } + } + + @Override + public void testBulkCreateSubnet() { + throw new SkipException("unsupported functionality"); + } +} diff --git a/providers/rackspace-cloudnetworks-uk/src/test/resources/logback.xml b/providers/rackspace-cloudnetworks-uk/src/test/resources/logback.xml new file mode 100644 index 0000000000..d7c463a01a --- /dev/null +++ b/providers/rackspace-cloudnetworks-uk/src/test/resources/logback.xml @@ -0,0 +1,56 @@ + + + + + target/test-data/jclouds.log + + + %d %-5p [%c] [%thread] %m%n + + + + + target/test-data/jclouds-wire.log + + + %d %-5p [%c] [%thread] %m%n + + + + + + + + + + + + + + + + + + + + + + +