Skip to content

Commit

Permalink
openstack-quantum: adding network service for openstack
Browse files Browse the repository at this point in the history
  • Loading branch information
aplowe committed Jun 1, 2012
1 parent df919fb commit e5c7afa
Show file tree
Hide file tree
Showing 40 changed files with 2,853 additions and 0 deletions.
151 changes: 151 additions & 0 deletions labs/openstack-quantum/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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.
-->
<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.jclouds</groupId>
<artifactId>jclouds-project</artifactId>
<version>1.5.0-SNAPSHOT</version>
<relativePath>../../project/pom.xml</relativePath>
</parent>
<groupId>org.jclouds.labs</groupId>
<artifactId>openstack-quantum</artifactId>
<name>jcloud openstack-quantum api</name>
<description>jclouds components to access an implementation of OpenStack Quantum</description>
<packaging>bundle</packaging>

<properties>
<!-- keystone endpoint -->
<test.openstack-quantum.endpoint>http://localhost:5000</test.openstack-quantum.endpoint>
<!-- keystone version -->
<test.openstack-quantum.api-version>1.0</test.openstack-quantum.api-version>
<test.openstack-quantum.build-version></test.openstack-quantum.build-version>
<test.openstack-quantum.identity>FIXME_IDENTITY</test.openstack-quantum.identity>
<test.openstack-quantum.credential>FIXME_CREDENTIALS</test.openstack-quantum.credential>
<test.jclouds.keystone.credential-type>passwordCredentials</test.jclouds.keystone.credential-type>
<jclouds.blobstore.httpstream.url>FIXME_HTTPURL</jclouds.blobstore.httpstream.url>
<jclouds.blobstore.httpstream.md5>FIXME_HTTPMD5</jclouds.blobstore.httpstream.md5>
</properties>

<dependencies>
<dependency>
<groupId>org.jclouds.common</groupId>
<artifactId>openstack-common</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.jclouds</groupId>
<artifactId>jclouds-blobstore</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.jclouds</groupId>
<artifactId>jclouds-core</artifactId>
<version>${project.version}</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jclouds.common</groupId>
<artifactId>openstack-common</artifactId>
<version>${project.version}</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jclouds</groupId>
<artifactId>jclouds-blobstore</artifactId>
<version>${project.version}</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jclouds.driver</groupId>
<artifactId>jclouds-slf4j</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.0.0</version>
<scope>test</scope>
</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.openstack-quantum.endpoint>${test.openstack-quantum.endpoint}</test.openstack-quantum.endpoint>
<test.openstack-quantum.api-version>${test.openstack-quantum.api-version}</test.openstack-quantum.api-version>
<test.openstack-quantum.build-version>${test.openstack-quantum.build-version}</test.openstack-quantum.build-version>
<test.openstack-quantum.identity>${test.openstack-quantum.identity}</test.openstack-quantum.identity>
<test.openstack-quantum.credential>${test.openstack-quantum.credential}</test.openstack-quantum.credential>
<test.jclouds.keystone.credential-type>${test.jclouds.keystone.credential-type}</test.jclouds.keystone.credential-type>
<jclouds.blobstore.httpstream.url>${jclouds.blobstore.httpstream.url}</jclouds.blobstore.httpstream.url>
<jclouds.blobstore.httpstream.md5>${jclouds.blobstore.httpstream.md5}</jclouds.blobstore.httpstream.md5>
</systemPropertyVariables>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>

<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<configuration>
<instructions>
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
<Export-Package>org.jclouds.openstack.quantum.v1*;version="${project.version}"</Export-Package>
<Import-Package>
org.jclouds.blobstore.internal;version="${project.version}",
org.jclouds.rest.internal;version="${project.version}",
org.jclouds*;version="${project.version}",
*
</Import-Package>
</instructions>
</configuration>
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
/**
* 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.openstack.quantum.v1_0;

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.KeystoneProperties;
import org.jclouds.openstack.quantum.v1_0.config.QuantumRestClientModule;
import org.jclouds.openstack.services.ServiceType;
import org.jclouds.rest.RestContext;
import org.jclouds.rest.internal.BaseRestApiMetadata;

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

/**
* Implementation of {@link ApiMetadata} for Quantum 1.0 API
*
* @author Adam Lowe
*/
public class QuantumApiMetadata extends BaseRestApiMetadata {
/** The serialVersionUID */
private static final long serialVersionUID = -7273686435105663195L;

public static final TypeToken<RestContext<QuantumClient, QuantumAsyncClient>> CONTEXT_TOKEN = new TypeToken<RestContext<QuantumClient, QuantumAsyncClient>>() {
private static final long serialVersionUID = -3493117927790861884L;
};

@Override
public Builder toBuilder() {
return new Builder().fromApiMetadata(this);
}

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

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

public static Properties defaultProperties() {
Properties properties = BaseRestApiMetadata.defaultProperties();
properties.setProperty(SERVICE_TYPE, ServiceType.NETWORK);
// TODO: this doesn't actually do anything yet.
properties.setProperty(KeystoneProperties.VERSION, "2.0");
return properties;
}

public static class Builder extends BaseRestApiMetadata.Builder {

protected Builder() {
super(QuantumClient.class, QuantumAsyncClient.class);
id("openstack-quantum")
.name("OpenStack Quantum API")
.identityName("tenantId:user")
.credentialName("password")
.documentation(URI.create("http://docs.openstack.org/api/openstack-network/1.0/content/"))
.version("1.0")
.defaultEndpoint("http://localhost:5000")
.defaultProperties(QuantumApiMetadata.defaultProperties())
.defaultModules(ImmutableSet.<Class<? extends Module>>of(QuantumRestClientModule.class));
}

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

@Override
public Builder fromApiMetadata(ApiMetadata in) {
super.fromApiMetadata(in);
return this;
}

}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/**
* 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.openstack.quantum.v1_0;

import java.util.Set;

import org.jclouds.javax.annotation.Nullable;
import org.jclouds.location.Region;
import org.jclouds.location.functions.RegionToEndpoint;
import org.jclouds.openstack.quantum.v1_0.features.NetworkAsyncClient;
import org.jclouds.openstack.quantum.v1_0.features.PortAsyncClient;
import org.jclouds.rest.annotations.Delegate;
import org.jclouds.rest.annotations.EndpointParam;

import com.google.inject.Provides;

/**
* Provides asynchronous access to Quantum via their REST API.
* <p/>
*
* @see QuantumClient
* @see <a href="http://docs.openstack.org/api/openstack-network/1.0/content">api doc</a>
* @author Adam Lowe
*/
public interface QuantumAsyncClient {
/**
*
* @return the Region codes configured
*/
@Provides
@Region
Set<String> getConfiguredRegions();

/**
* Provides asynchronous access to Network features.
*/
@Delegate
NetworkAsyncClient getNetworkClientForRegion(@EndpointParam(parser = RegionToEndpoint.class) @Nullable String region);

/**
* Provides asynchronous access to Port features.
*/
@Delegate
PortAsyncClient getPortClientForRegion(@EndpointParam(parser = RegionToEndpoint.class) @Nullable String region);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/**
* 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.openstack.quantum.v1_0;

import java.util.Set;
import java.util.concurrent.TimeUnit;

import org.jclouds.concurrent.Timeout;
import org.jclouds.javax.annotation.Nullable;
import org.jclouds.location.Region;
import org.jclouds.location.functions.RegionToEndpoint;
import org.jclouds.openstack.quantum.v1_0.features.NetworkClient;
import org.jclouds.openstack.quantum.v1_0.features.PortClient;
import org.jclouds.rest.annotations.Delegate;
import org.jclouds.rest.annotations.EndpointParam;

import com.google.inject.Provides;

/**
* Provides synchronous access to Quantum.
* <p/>
*
* @author Adam Lowe
* @see QuantumAsyncClient
* @see <a href="http://docs.openstack.org/api/openstack-network/1.0/content">api doc</a>
*/
@Timeout(duration = 60, timeUnit = TimeUnit.SECONDS)
public interface QuantumClient {
/**
* @return the Region codes configured
*/
@Provides
@Region
Set<String> getConfiguredRegions();

/**
* Provides synchronous access to Network features.
*/
@Delegate
NetworkClient getNetworkClientForRegion(@EndpointParam(parser = RegionToEndpoint.class) @Nullable String region);

/**
* Provides synchronous access to Port features.
*/
@Delegate
PortClient getPortClientForRegion(@EndpointParam(parser = RegionToEndpoint.class) @Nullable String region);
}
Loading

0 comments on commit e5c7afa

Please sign in to comment.