Issue 815: repackaged keystone classes into their own api

This commit is contained in:
Adrian Cole 2012-06-06 14:57:50 -07:00
parent c18c97552f
commit b58060599b
200 changed files with 1532 additions and 319 deletions

View File

@ -28,7 +28,6 @@ import org.jclouds.apis.ApiMetadata;
import org.jclouds.blobstore.BlobStoreContext;
import org.jclouds.cloudfiles.blobstore.config.CloudFilesBlobStoreContextModule;
import org.jclouds.cloudfiles.config.CloudFilesRestClientModule;
import org.jclouds.openstack.OpenStackAuthAsyncClient;
import org.jclouds.rest.RestContext;
import org.jclouds.rest.internal.BaseRestApiMetadata;
@ -81,7 +80,7 @@ public class CloudFilesApiMetadata extends BaseRestApiMetadata {
.identityName("Username")
.credentialName("API Key")
.documentation(URI.create("http://docs.rackspacecloud.com/files/api/v1/cfdevguide_d5/content/ch01.html"))
.version(OpenStackAuthAsyncClient.VERSION)
.version("1.0")
.defaultProperties(CloudFilesApiMetadata.defaultProperties())
.view(TypeToken.of(BlobStoreContext.class))
.defaultModules(ImmutableSet.<Class<? extends Module>>of(CloudFilesRestClientModule.class, CloudFilesBlobStoreContextModule.class));

View File

@ -25,7 +25,6 @@ import org.jclouds.apis.ApiMetadata;
import org.jclouds.cloudloadbalancers.config.CloudLoadBalancersRestClientModule;
import org.jclouds.cloudloadbalancers.loadbalancer.config.CloudLoadBalancersLoadBalancerContextModule;
import org.jclouds.loadbalancer.LoadBalancerServiceContext;
import org.jclouds.openstack.OpenStackAuthAsyncClient;
import org.jclouds.rest.RestContext;
import org.jclouds.rest.internal.BaseRestApiMetadata;
@ -75,7 +74,7 @@ public class CloudLoadBalancersApiMetadata extends BaseRestApiMetadata {
.identityName("Username")
.credentialName("API Key")
.documentation(URI.create("http://docs.rackspacecloud.com/loadbalancers/api/v1.0/clb-devguide/content/ch01.html"))
.version(OpenStackAuthAsyncClient.VERSION)
.version("1.0")
.defaultEndpoint("https://auth.api.rackspacecloud.com")
.defaultProperties(CloudLoadBalancersApiMetadata.defaultProperties())
.view(TypeToken.of(LoadBalancerServiceContext.class))

View File

@ -25,7 +25,6 @@ import org.jclouds.apis.ApiMetadata;
import org.jclouds.cloudservers.compute.config.CloudServersComputeServiceContextModule;
import org.jclouds.cloudservers.config.CloudServersRestClientModule;
import org.jclouds.compute.ComputeServiceContext;
import org.jclouds.openstack.OpenStackAuthAsyncClient;
import org.jclouds.rest.RestContext;
import org.jclouds.rest.internal.BaseRestApiMetadata;
@ -74,7 +73,7 @@ public class CloudServersApiMetadata extends BaseRestApiMetadata {
.identityName("Username")
.credentialName("API Key")
.documentation(URI.create("http://docs.rackspacecloud.com/servers/api/v1.0/cs-devguide/content/ch01.html"))
.version(OpenStackAuthAsyncClient.VERSION)
.version("1.0")
.defaultEndpoint("https://auth.api.rackspacecloud.com")
.defaultProperties(CloudServersApiMetadata.defaultProperties())
.view(TypeToken.of(ComputeServiceContext.class))

View File

@ -35,9 +35,9 @@ import org.jclouds.http.HttpRequest;
import org.jclouds.http.functions.ReleasePayloadAndReturn;
import org.jclouds.http.functions.ReturnTrueIf2xx;
import org.jclouds.http.functions.UnwrapOnlyJsonValue;
import org.jclouds.openstack.TestOpenStackAuthenticationModule;
import org.jclouds.openstack.filters.AddTimestampQuery;
import org.jclouds.openstack.filters.AuthenticateRequest;
import org.jclouds.openstack.internal.TestOpenStackAuthenticationModule;
import org.jclouds.openstack.nova.config.NovaRestClientModule;
import org.jclouds.openstack.nova.domain.RebootType;
import org.jclouds.openstack.nova.options.CreateServerOptions;

Binary file not shown.

View File

@ -27,7 +27,7 @@
<version>1.5.0-SNAPSHOT</version>
<relativePath>../../project/pom.xml</relativePath>
</parent>
<groupId>org.jclouds.labs</groupId>
<groupId>org.jclouds.api</groupId>
<artifactId>openstack-keystone</artifactId>
<name>jcloud openstack-keystone api</name>
<description>jclouds components to access an implementation of OpenStack Keystone</description>
@ -43,7 +43,9 @@
<test.openstack-keystone.credential>FIXME_CREDENTIALS</test.openstack-keystone.credential>
<test.jclouds.keystone.credential-type>passwordCredentials</test.jclouds.keystone.credential-type>
<jclouds.osgi.export>org.jclouds.openstack.keystone.v2_0*;version="${project.version}"</jclouds.osgi.export>
<jclouds.osgi.export>org.jclouds.openstack.v2_0*;version="${project.version}",
org.jclouds.openstack.keystone.v2_0*;version="${project.version}"
</jclouds.osgi.export>
<jclouds.osgi.import>
org.jclouds.rest.internal;version="${project.version}",
org.jclouds*;version="${project.version}",
@ -53,8 +55,8 @@
<dependencies>
<dependency>
<groupId>org.jclouds.common</groupId>
<artifactId>openstack-common</artifactId>
<groupId>org.jclouds</groupId>
<artifactId>jclouds-core</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
@ -64,13 +66,6 @@
<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.driver</groupId>
<artifactId>jclouds-slf4j</artifactId>

View File

@ -26,7 +26,7 @@ import java.util.Properties;
import org.jclouds.apis.ApiMetadata;
import org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties;
import org.jclouds.openstack.keystone.v2_0.config.KeystoneRestClientModule;
import org.jclouds.openstack.services.ServiceType;
import org.jclouds.openstack.v2_0.ServiceType;
import org.jclouds.rest.RestContext;
import org.jclouds.rest.internal.BaseRestApiMetadata;
@ -45,6 +45,9 @@ public class KeystoneApiMetadata extends BaseRestApiMetadata {
private static final long serialVersionUID = 6725672099385580694L;
public static final TypeToken<RestContext<KeystoneClient, KeystoneAsyncClient>> CONTEXT_TOKEN = new TypeToken<RestContext<KeystoneClient, KeystoneAsyncClient>>() {
/** The serialVersionUID */
private static final long serialVersionUID = 3030344682235783904L;
};
@Override
@ -62,9 +65,6 @@ public class KeystoneApiMetadata extends BaseRestApiMetadata {
public static Properties defaultProperties() {
Properties properties = BaseRestApiMetadata.defaultProperties();
// auth fail can happen while cloud-init applies keypair updates
properties.setProperty("jclouds.ssh.max-retries", "7");
properties.setProperty("jclouds.ssh.retry-auth", "true");
// TODO: this doesn't actually do anything yet.
properties.setProperty(KeystoneProperties.VERSION, "2.0");
properties.put(SERVICE_TYPE, ServiceType.IDENTITY);

View File

@ -26,6 +26,8 @@ import org.jclouds.Constants;
import org.jclouds.javax.annotation.Nullable;
import org.jclouds.location.Region;
import org.jclouds.location.functions.RegionToEndpoint;
import org.jclouds.openstack.keystone.v2_0.features.AdminAsyncClient;
import org.jclouds.openstack.keystone.v2_0.features.ServiceAsyncClient;
import org.jclouds.openstack.keystone.v2_0.functions.RegionToAdminEndpointURI;
import org.jclouds.rest.annotations.Delegate;
import org.jclouds.rest.annotations.EndpointParam;

View File

@ -25,6 +25,8 @@ 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.keystone.v2_0.features.AdminClient;
import org.jclouds.openstack.keystone.v2_0.features.ServiceClient;
import org.jclouds.openstack.keystone.v2_0.functions.RegionToAdminEndpointURI;
import org.jclouds.rest.annotations.Delegate;
import org.jclouds.rest.annotations.EndpointParam;

View File

@ -0,0 +1,38 @@
/**
* 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.keystone.v2_0.config;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import javax.inject.Qualifier;
/**
*
* @author Adrian Cole
*
*/
@Retention(value = RetentionPolicy.RUNTIME)
@Target(value = { ElementType.TYPE, ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD })
@Qualifier
public @interface Authentication {
}

View File

@ -39,7 +39,6 @@ import org.jclouds.location.suppliers.ZoneIdToURISupplier;
import org.jclouds.location.suppliers.ZoneIdsSupplier;
import org.jclouds.location.suppliers.derived.RegionIdsFromRegionIdToURIKeySet;
import org.jclouds.location.suppliers.derived.ZoneIdsFromZoneIdToURIKeySet;
import org.jclouds.openstack.Authentication;
import org.jclouds.openstack.keystone.v2_0.AuthenticationAsyncClient;
import org.jclouds.openstack.keystone.v2_0.AuthenticationClient;
import org.jclouds.openstack.keystone.v2_0.domain.Access;

View File

@ -18,7 +18,7 @@
*/
package org.jclouds.openstack.keystone.v2_0.config;
import org.jclouds.openstack.services.ServiceType;
import org.jclouds.openstack.v2_0.ServiceType;
/**
* Configuration properties and constants used in Keystone connections.

View File

@ -24,12 +24,12 @@ import org.jclouds.http.HttpErrorHandler;
import org.jclouds.http.annotation.ClientError;
import org.jclouds.http.annotation.Redirection;
import org.jclouds.http.annotation.ServerError;
import org.jclouds.openstack.keystone.v2_0.AdminAsyncClient;
import org.jclouds.openstack.keystone.v2_0.AdminClient;
import org.jclouds.openstack.keystone.v2_0.KeystoneAsyncClient;
import org.jclouds.openstack.keystone.v2_0.KeystoneClient;
import org.jclouds.openstack.keystone.v2_0.ServiceAsyncClient;
import org.jclouds.openstack.keystone.v2_0.ServiceClient;
import org.jclouds.openstack.keystone.v2_0.features.AdminAsyncClient;
import org.jclouds.openstack.keystone.v2_0.features.AdminClient;
import org.jclouds.openstack.keystone.v2_0.features.ServiceAsyncClient;
import org.jclouds.openstack.keystone.v2_0.features.ServiceClient;
import org.jclouds.openstack.keystone.v2_0.handlers.KeystoneErrorHandler;
import org.jclouds.rest.ConfiguresRestClient;
import org.jclouds.rest.config.RestClientModule;
@ -45,7 +45,8 @@ import com.google.common.collect.ImmutableMap;
public class KeystoneRestClientModule extends RestClientModule<KeystoneClient, KeystoneAsyncClient> {
public static final Map<Class<?>, Class<?>> DELEGATE_MAP = ImmutableMap.<Class<?>, Class<?>> builder()
.put(ServiceClient.class, ServiceAsyncClient.class).put(AdminClient.class, AdminAsyncClient.class)
.put(ServiceClient.class, ServiceAsyncClient.class)
.put(AdminClient.class, AdminAsyncClient.class)
.build();
public KeystoneRestClientModule() {

View File

@ -25,7 +25,7 @@ import java.util.Date;
import java.util.Set;
import org.jclouds.javax.annotation.Nullable;
import org.jclouds.openstack.domain.Resource;
import org.jclouds.openstack.v2_0.domain.Resource;
import com.google.common.base.Objects;
import com.google.common.base.Objects.ToStringHelper;

View File

@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.openstack.keystone.v2_0;
package org.jclouds.openstack.keystone.v2_0.features;
import java.util.Set;
@ -28,13 +28,13 @@ import javax.ws.rs.PathParam;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import org.jclouds.openstack.filters.AuthenticateRequest;
import org.jclouds.openstack.keystone.v2_0.domain.ApiMetadata;
import org.jclouds.openstack.keystone.v2_0.domain.Endpoint;
import org.jclouds.openstack.keystone.v2_0.domain.Role;
import org.jclouds.openstack.keystone.v2_0.domain.Tenant;
import org.jclouds.openstack.keystone.v2_0.domain.Token;
import org.jclouds.openstack.keystone.v2_0.domain.User;
import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest;
import org.jclouds.rest.annotations.ExceptionParser;
import org.jclouds.rest.annotations.RequestFilters;
import org.jclouds.rest.annotations.SelectJson;

View File

@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.openstack.keystone.v2_0;
package org.jclouds.openstack.keystone.v2_0.features;
import java.util.Set;
import java.util.concurrent.TimeUnit;

View File

@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.openstack.keystone.v2_0;
package org.jclouds.openstack.keystone.v2_0.features;
import java.util.Set;
@ -25,9 +25,9 @@ import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.core.MediaType;
import org.jclouds.openstack.filters.AuthenticateRequest;
import org.jclouds.openstack.keystone.v2_0.domain.ApiMetadata;
import org.jclouds.openstack.keystone.v2_0.domain.Tenant;
import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest;
import org.jclouds.rest.annotations.ExceptionParser;
import org.jclouds.rest.annotations.RequestFilters;
import org.jclouds.rest.annotations.SelectJson;

View File

@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.openstack.keystone.v2_0;
package org.jclouds.openstack.keystone.v2_0.features;
import java.util.Set;
import java.util.concurrent.TimeUnit;

View File

@ -0,0 +1,54 @@
/**
* 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.keystone.v2_0.filters;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.jclouds.http.HttpException;
import org.jclouds.http.HttpRequest;
import org.jclouds.http.HttpRequestFilter;
import org.jclouds.http.utils.ModifyRequest;
import org.jclouds.openstack.keystone.v2_0.config.Authentication;
import org.jclouds.openstack.v2_0.reference.AuthHeaders;
import com.google.common.base.Supplier;
/**
* Signs the Keystone-based request. This will update the Authentication Token before 24 hours is up.
*
* @author Adrian Cole
*
*/
@Singleton
public class AuthenticateRequest implements HttpRequestFilter {
private final Supplier<String> authTokenProvider;
@Inject
public AuthenticateRequest(@Authentication Supplier<String> authTokenProvider) {
this.authTokenProvider = authTokenProvider;
}
@Override
public HttpRequest filter(HttpRequest request) throws HttpException {
return ModifyRequest.replaceHeader(request, AuthHeaders.AUTH_TOKEN, authTokenProvider.get());
}
}

View File

@ -29,7 +29,6 @@ import org.jclouds.http.HttpResponse;
import org.jclouds.http.HttpRetryHandler;
import org.jclouds.logging.Logger;
import org.jclouds.openstack.keystone.v2_0.domain.Access;
import org.jclouds.openstack.reference.AuthHeaders;
import com.google.common.cache.LoadingCache;
import com.google.common.collect.Multimap;
@ -62,8 +61,8 @@ public class RetryOnRenew implements HttpRetryHandler {
case 401:
// Do not retry on 401 from authentication request
Multimap<String, String> headers = command.getCurrentRequest().getHeaders();
if (headers != null && headers.containsKey(AuthHeaders.AUTH_USER)
&& headers.containsKey(AuthHeaders.AUTH_KEY) && !headers.containsKey(AuthHeaders.AUTH_TOKEN)) {
if (headers != null && headers.containsKey("X-Auth-User")
&& headers.containsKey("X-Auth-Key") && !headers.containsKey("X-Auth-Token")) {
retry = false;
} else {
byte[] content = closeClientButKeepContentStream(response);

View File

@ -0,0 +1,52 @@
/**
* 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, Name 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.v2_0;
/**
* An OpenStack service, such as Compute (Nova), Object Storage (Swift), or Image Service (Glance).
* A service provides one or more endpoints through which users can access resources and perform
* (presumably useful) operations.
*
* @author Adrian Cole
* @see <a href="http://docs.openstack.org/api/openstack-typeentity-service/2.0/content/Identity-Service-Concepts-e1362.html"
* />
*/
public interface ServiceType {
/**
* Object Storage (Swift)
*/
public static final String OBJECT_STORE = "object-store";
/**
* Compute (Nova)
*/
public static final String COMPUTE = "compute";
/**
* Image Service (Glance)
*/
public static final String IMAGE = "image";
/**
* Identity Service (Keystone)
*/
public static final String IDENTITY = "identity";
/**
* Network Service (Quantum)
*/
public static final String NETWORK = "network";
}

View File

@ -0,0 +1,207 @@
/**
* 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, Href 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.v2_0.domain;
import static com.google.common.base.Objects.equal;
import static com.google.common.base.Objects.toStringHelper;
import static com.google.common.base.Preconditions.checkNotNull;
import java.net.URI;
import org.jclouds.javax.annotation.Nullable;
import com.google.common.base.Objects;
import com.google.gson.annotations.SerializedName;
/**
* For convenience, resources contain links to themselves. This allows a client to easily obtain a
* resource URIs rather than to construct them.
*
* @author AdrianCole
* @see <a href= "http://docs.openstack.org/api/openstack-compute/1.1/content/LinksReferences.html"
* />
*/
public class Link {
/**
* Relations associated with resources.
*/
public static enum Relation {
/**
* a versioned link to the resource. These links should be used in cases where the link will
* be followed immediately.
*/
SELF,
/**
* a permanent link to a resource that is appropriate for long term storage.
*/
BOOKMARK,
/**
*
*/
DESCRIBEDBY,
/**
* an alternate representation of the resource. For example, an OpenStack Compute image may
* have an alternate representation in the OpenStack Image service.
*/
ALTERNATE,
/**
* the value returned by the OpenStack service was not recognized.
*/
UNRECOGNIZED;
public String value() {
return name().toLowerCase();
}
public static Relation fromValue(String v) {
try {
return valueOf(v.toUpperCase());
} catch (IllegalArgumentException e) {
return UNRECOGNIZED;
}
}
}
public static Link create(Relation relation, URI href) {
return new Link(relation, null, href);
}
public static Link create(Relation relation,String type, URI href) {
return new Link(relation, type, href);
}
public static Builder builder() {
return new Builder();
}
public Builder toBuilder() {
return builder().fromLink(this);
}
public static class Builder {
protected Relation relation;
protected String type;
protected URI href;
/**
* @see Link#getRelation()
*/
public Builder relation(Relation relation) {
this.relation = checkNotNull(relation, "relation");
return this;
}
/**
* @see Link#getType()
*/
public Builder type(String type) {
this.type = type;
return this;
}
/**
* @see Link#getHref()
*/
public Builder href(URI href) {
this.href = checkNotNull(href, "href");
return this;
}
public Link build(){
return new Link(relation, type, href);
}
public Builder fromLink(Link from) {
return relation(from.getRelation()).type(from.getType()).href(from.getHref());
}
}
protected Link() {
// we want serializers like Gson to work w/o using sun.misc.Unsafe,
// prohibited in GAE. This also implies fields are not final.
// see http://code.google.com/p/jclouds/issues/detail?id=925
}
@SerializedName("rel")
protected Relation relation;
protected String type;
protected URI href;
protected Link(Relation relation, @Nullable String type, URI href) {
this.relation = checkNotNull(relation, "relation");
this.type = type;
this.href = checkNotNull(href, "href");
}
/**
* There are three kinds of link relations associated with resources. A self link contains a
* versioned link to the resource. These links should be used in cases where the link will be
* followed immediately. A bookmark link provides a permanent link to a resource that is
* appropriate for long term storage. An alternate link can contain an alternate representation
* of the resource. For example, an OpenStack Compute image may have an alternate representation
* in the OpenStack Image service. Note that the type attribute here is used to provide a hint as
* to the type of representation to expect when following the link.
*
* @return the relation of the resource in the current OpenStack deployment
*/
public Relation getRelation() {
return relation;
}
/**
* @return the type of the resource or null if not specified
*/
@Nullable
public String getType() {
return type;
}
/**
* @return the href of the resource
*/
public URI getHref() {
return href;
}
@Override
public boolean equals(Object object) {
if (this == object) {
return true;
}
if (object instanceof Link) {
final Link other = Link.class.cast(object);
return equal(relation, other.relation) && equal(type, other.type) && equal(href, other.href);
} else {
return false;
}
}
@Override
public int hashCode() {
return Objects.hashCode(relation, type, href);
}
@Override
public String toString() {
return toStringHelper("").add("relation", relation).add("type", type).add("href", href).toString();
}
}

View File

@ -0,0 +1,185 @@
/**
* 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, Name 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.v2_0.domain;
import static com.google.common.base.Preconditions.checkNotNull;
import java.util.Collections;
import java.util.Set;
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;
/**
* Resource found in a paginated collection
*
* @author AdrianCole
* @see <a href=
* "http://docs.openstack.org/api/openstack-compute/1.1/content/Paginated_Collections-d1e664.html"
* />
*/
public class Resource implements Comparable<Resource> {
public static Builder<?> builder() {
return new ConcreteBuilder();
}
public Builder<?> toBuilder() {
return new ConcreteBuilder().fromResource(this);
}
public static abstract class Builder<T extends Builder<T>> {
protected abstract T self();
private String id;
private String name;
private Set<Link> links = ImmutableSet.of();
/**
* @see Resource#getId()
*/
public T id(String id) {
this.id = id;
return self();
}
/**
* @see Resource#getName()
*/
public T name(String name) {
this.name = name;
return self();
}
/**
* @see Resource#getLinks()
*/
public T links(Link... links) {
return links(ImmutableSet.copyOf(checkNotNull(links, "links")));
}
/**
* @see Resource#getLinks()
*/
public T links(Set<Link> links) {
this.links = links;
return self();
}
public Resource build() {
return new Resource(this);
}
public T fromResource(Resource in) {
return this
.id(in.getId())
.name(in.getName())
.links(in.getLinks())
;
}
}
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
@Override
protected ConcreteBuilder self() {
return this;
}
}
protected Resource() {
// we want serializers like Gson to work w/o using sun.misc.Unsafe,
// prohibited in GAE. This also implies fields are not final.
// see http://code.google.com/p/jclouds/issues/detail?id=925
}
private String id;
private String name;
private Set<Link> links = ImmutableSet.of();
protected Resource(Builder<?> builder) {
this.id = checkNotNull(builder.id, "id");
this.name = builder.name;
this.links = ImmutableSet.copyOf(checkNotNull(builder.links, "links"));
}
/**
* When providing an ID, it is assumed that the resource exists in the current OpenStack
* deployment
*
* @return the id of the resource in the current OpenStack deployment
*/
public String getId() {
return id;
}
/**
* @return the name of the resource
*/
@Nullable
public String getName() {
return name;
}
/**
* @return the links of the id address allocated to the new server
*/
public Set<Link> getLinks() {
return Collections.unmodifiableSet(this.links);
}
@Override
public int hashCode() {
return Objects.hashCode(id, name, links);
}
@Override
public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null || getClass() != obj.getClass()) return false;
Resource that = Resource.class.cast(obj);
return Objects.equal(this.getId(), that.getId())
&& Objects.equal(this.name, that.name)
&& Objects.equal(this.links, that.links);
}
protected ToStringHelper string() {
return Objects.toStringHelper("")
.add("id", getId())
.add("name", name)
.add("links", links);
}
@Override
public String toString() {
return string().toString();
}
@Override
public int compareTo(Resource that) {
if (that == null)
return 1;
if (this == that)
return 0;
return this.getId().compareTo(that.getId());
}
}

View File

@ -0,0 +1,100 @@
/**
* 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.v2_0.options;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Preconditions.checkState;
import java.util.Date;
import org.jclouds.http.options.BaseHttpRequestOptions;
/**
* Options used to control paginated results (aka list commands).
*
* @see <a href="http://docs.rackspacecloud.com/servers/api/cs-devguide-latest.pdf" />
* @author Adrian Cole
*/
public class BaseListOptions extends BaseHttpRequestOptions {
public static final BaseListOptions NONE = new BaseListOptions();
/**
* Only return objects changed since this time.
*/
public BaseListOptions changesSince(Date ifModifiedSince) {
this.queryParameters.put("changes-since", checkNotNull(ifModifiedSince, "ifModifiedSince")
.getTime()
/ 1000 + "");
return this;
}
/**
* Indicates where to begin listing. The list will only include objects that occur after the
* offset. This is convenient for pagination: To get the next page of results use the last result
* number of the current page + current page offset as the offset.
*/
public BaseListOptions startAt(long offset) {
checkState(offset >= 0, "offset must be >= 0");
queryParameters.put("offset", Long.toString(checkNotNull(offset, "offset")));
return this;
}
/**
* To reduce load on the service, list operations will return a maximum of 1,000 items at a time.
* To navigate the collection, the parameters limit and offset can be set in the URI
* (e.g.?limit=0&offset=0). If an offset is given beyond the end of a list an empty list will be
* returned.
* <p/>
* Note that list operations never return itemNotFound (404) faults.
*/
public BaseListOptions maxResults(int limit) {
checkState(limit >= 0, "limit must be >= 0");
checkState(limit <= 10000, "limit must be <= 10000");
queryParameters.put("limit", Integer.toString(limit));
return this;
}
public static class Builder {
/**
* @see BaseListOptions#startAt(long)
*/
public static BaseListOptions startAt(long prefix) {
BaseListOptions options = new BaseListOptions();
return options.startAt(prefix);
}
/**
* @see BaseListOptions#maxResults
*/
public static BaseListOptions maxResults(int maxKeys) {
BaseListOptions options = new BaseListOptions();
return options.maxResults(maxKeys);
}
/**
* @see BaseListOptions#changesSince(Date)
*/
public static BaseListOptions changesSince(Date since) {
BaseListOptions options = new BaseListOptions();
return options.changesSince(since);
}
}
}

View File

@ -0,0 +1,103 @@
/*
* 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.v2_0.predicates;
import static com.google.common.base.Preconditions.checkNotNull;
import java.net.URI;
import org.jclouds.openstack.v2_0.domain.Link;
import org.jclouds.openstack.v2_0.domain.Link.Relation;
import com.google.common.base.Predicate;
/**
* Predicates handy when working with Link Types
*
* @author Adrian Cole
*/
public class LinkPredicates {
/**
* matches links of the given relation
*
* @param rel relation of the link
* @return predicate that will match links of the given rel
*/
public static Predicate<Link> relationEquals(final Relation rel) {
checkNotNull(rel, "rel must be defined");
return new Predicate<Link>() {
@Override
public boolean apply(Link link) {
return rel.equals(link.getRelation());
}
@Override
public String toString() {
return "relEquals(" + rel + ")";
}
};
}
/**
* matches links of the given href
*
* @param href
* @return predicate that will match links of the given href
*/
public static Predicate<Link> hrefEquals(final URI href) {
checkNotNull(href, "href must be defined");
return new Predicate<Link>() {
@Override
public boolean apply(Link link) {
return href.equals(link.getHref());
}
@Override
public String toString() {
return "hrefEquals(" + href + ")";
}
};
}
/**
* matches links of the given type
*
* @param type
* ex. application/pdf
* @return predicate that will match links of the given type
*/
public static Predicate<Link> typeEquals(final String type) {
checkNotNull(type, "type must be defined");
return new Predicate<Link>() {
@Override
public boolean apply(Link link) {
return type.equals(link.getType());
}
@Override
public String toString() {
return "typeEquals(" + type + ")";
}
};
}
}

View File

@ -0,0 +1,31 @@
/**
* 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.v2_0.reference;
/**
* @author Adrian Cole
*
*/
public interface AuthHeaders {
public static final String AUTH_USER = "X-Auth-User";
public static final String AUTH_KEY = "X-Auth-Key";
public static final String AUTH_TOKEN = "X-Auth-Token";
}

View File

@ -0,0 +1,43 @@
/**
* 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.v2_0.services;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import javax.inject.Qualifier;
import org.jclouds.openstack.v2_0.ServiceType;
/**
* Compute (Nova)
*
* @author Adrian Cole
* @see <a href="http://docs.openstack.org/api/openstack-typeentity-service/2.0/content/Identity-Service-Concepts-e1362.html"
* />
* @see ServiceType#COMPUTE
*/
@Retention(value = RetentionPolicy.RUNTIME)
@Target(value = { ElementType.TYPE, ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD })
@Qualifier
public @interface Compute {
}

View File

@ -0,0 +1,79 @@
/**
* 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.v2_0.services;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import javax.inject.Qualifier;
import org.jclouds.openstack.v2_0.ServiceType;
/**
* An extension of a {@link ServiceType service}. In order for us to understand
* the context of the extension, we must consider the <a href=
* "http://docs.openstack.org/api/openstack-compute/2/content/Extensions-d1e1444.html"
* >extensions call</a>.
*
* <br/>
* For our purposes, the minimal context of an extension is the type of the
* service it extends ex. {@link ServiceType#COMPUTE}, and its namespace ex. <a
* href
* ="http://docs.openstack.org/ext/keypairs/api/v1.1">http://docs.openstack.org
* /ext/keypairs/api/v1.1</a>.
*
* @author Adrian Cole
*
* @see ServiceType
* @see <a href=
* "http://docs.openstack.org/api/openstack-compute/2/content/Extensions-d1e1444.html"
* />
* @see <a href="http://nova.openstack.org/api_ext" />
* @see <a href="http://nova.openstack.org/api_ext/ext_keypairs.html" />
*/
@Retention(value = RetentionPolicy.RUNTIME)
@Target(value = { ElementType.TYPE, ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD })
@Qualifier
public @interface Extension {
/**
* the service type this is an extension of.
*
* <h3>note</h3>
*
* This isn't necessarily one of the built-in {@link ServiceType services},
* it could be an extension of a custom service.
*
* @return the service type this is an extension of.
*
*/
String of();
/**
* namespace ex. <a href
* ="http://docs.openstack.org/ext/keypairs/api/v1.1">http
* ://docs.openstack.org /ext/keypairs/api/v1.1</a>.
*
* @return the namespace of the extension
*/
String namespace();
}

View File

@ -0,0 +1,43 @@
/**
* 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.v2_0.services;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import javax.inject.Qualifier;
import org.jclouds.openstack.v2_0.ServiceType;
/**
* Image Service (Glance)
*
* @author Adrian Cole
* @see <a href="http://docs.openstack.org/api/openstack-typeentity-service/2.0/content/Identity-Service-Concepts-e1362.html"
* />
* @see ServiceType#IMAGE
*/
@Retention(value = RetentionPolicy.RUNTIME)
@Target(value = { ElementType.TYPE, ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD })
@Qualifier
public @interface Image {
}

View File

@ -0,0 +1,43 @@
/**
* 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.v2_0.services;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import javax.inject.Qualifier;
import org.jclouds.openstack.v2_0.ServiceType;
/**
* Object Storage (Swift)
*
* @author Adrian Cole
* @see <a href="http://docs.openstack.org/api/openstack-typeentity-service/2.0/content/Identity-Service-Concepts-e1362.html"
* />
* @see ServiceType#OBJECT_STORE
*/
@Retention(value = RetentionPolicy.RUNTIME)
@Target(value = { ElementType.TYPE, ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD })
@Qualifier
public @interface ObjectStore {
}

View File

@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.openstack.keystone.v2_0;
package org.jclouds.openstack.keystone.v2_0.features;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
import static org.testng.Assert.assertEquals;
@ -31,7 +31,7 @@ import java.util.Set;
import org.jclouds.date.DateService;
import org.jclouds.date.internal.SimpleDateFormatDateService;
import org.jclouds.http.HttpResponseException;
import org.jclouds.openstack.domain.Link;
import org.jclouds.openstack.keystone.v2_0.KeystoneClient;
import org.jclouds.openstack.keystone.v2_0.domain.ApiMetadata;
import org.jclouds.openstack.keystone.v2_0.domain.Endpoint;
import org.jclouds.openstack.keystone.v2_0.domain.MediaType;
@ -40,6 +40,7 @@ import org.jclouds.openstack.keystone.v2_0.domain.Tenant;
import org.jclouds.openstack.keystone.v2_0.domain.Token;
import org.jclouds.openstack.keystone.v2_0.domain.User;
import org.jclouds.openstack.keystone.v2_0.internal.BaseKeystoneRestClientExpectTest;
import org.jclouds.openstack.v2_0.domain.Link;
import org.jclouds.rest.AuthorizationException;
import org.testng.annotations.Test;

View File

@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.openstack.keystone.v2_0;
package org.jclouds.openstack.keystone.v2_0.features;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
@ -28,15 +28,14 @@ import java.net.URI;
import java.util.Set;
import org.jclouds.http.HttpRequest;
import org.jclouds.openstack.filters.AuthenticateRequest;
import org.jclouds.openstack.keystone.v2_0.domain.ApiMetadata;
import org.jclouds.openstack.keystone.v2_0.domain.Endpoint;
import org.jclouds.openstack.keystone.v2_0.domain.Role;
import org.jclouds.openstack.keystone.v2_0.domain.Tenant;
import org.jclouds.openstack.keystone.v2_0.domain.Token;
import org.jclouds.openstack.keystone.v2_0.domain.User;
import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest;
import org.jclouds.openstack.keystone.v2_0.internal.BaseKeystoneClientLiveTest;
import org.jclouds.openstack.reference.AuthHeaders;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
@ -57,7 +56,7 @@ public class AdminClientLiveTest extends BaseKeystoneClientLiveTest {
public void grabToken() {
AuthenticateRequest ar = keystoneContext.getUtils().getInjector().getInstance(AuthenticateRequest.class);
HttpRequest test = ar.filter(HttpRequest.builder().method("GET").endpoint(URI.create(endpoint)).build());
token = Iterables.getOnlyElement(test.getHeaders().get(AuthHeaders.AUTH_TOKEN));
token = Iterables.getOnlyElement(test.getHeaders().get("X-Auth-Token"));
}
public void testGetApiMetaData() {

View File

@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.openstack.keystone.v2_0;
package org.jclouds.openstack.keystone.v2_0.features;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
import static org.testng.Assert.assertEquals;
@ -29,11 +29,12 @@ import java.util.Set;
import org.jclouds.date.internal.SimpleDateFormatDateService;
import org.jclouds.http.HttpRequest;
import org.jclouds.http.HttpResponse;
import org.jclouds.openstack.domain.Link;
import org.jclouds.openstack.keystone.v2_0.KeystoneClient;
import org.jclouds.openstack.keystone.v2_0.domain.ApiMetadata;
import org.jclouds.openstack.keystone.v2_0.domain.MediaType;
import org.jclouds.openstack.keystone.v2_0.domain.Tenant;
import org.jclouds.openstack.keystone.v2_0.internal.BaseKeystoneRestClientExpectTest;
import org.jclouds.openstack.v2_0.domain.Link;
import com.google.common.collect.ImmutableMultimap;
import com.google.common.collect.ImmutableSet;

View File

@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.openstack.keystone.v2_0;
package org.jclouds.openstack.keystone.v2_0.features;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertNotNull;

View File

@ -27,7 +27,7 @@ import javax.ws.rs.core.MediaType;
import org.jclouds.http.HttpRequest;
import org.jclouds.http.HttpResponse;
import org.jclouds.openstack.services.ServiceType;
import org.jclouds.openstack.v2_0.ServiceType;
import org.jclouds.rest.internal.BaseRestClientExpectTest;
import com.google.common.base.Objects;

View File

@ -25,8 +25,8 @@ import javax.ws.rs.core.MediaType;
import org.jclouds.date.internal.SimpleDateFormatDateService;
import org.jclouds.json.BaseItemParserTest;
import org.jclouds.openstack.domain.Link;
import org.jclouds.openstack.keystone.v2_0.domain.ApiMetadata;
import org.jclouds.openstack.v2_0.domain.Link;
import org.jclouds.rest.annotations.SelectJson;
import org.testng.annotations.Test;

View File

@ -0,0 +1,77 @@
/**
* 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.v2_0.options;
import static org.jclouds.openstack.v2_0.options.BaseListOptions.Builder.changesSince;
import static org.jclouds.openstack.v2_0.options.BaseListOptions.Builder.maxResults;
import static org.jclouds.openstack.v2_0.options.BaseListOptions.Builder.startAt;
import static org.testng.Assert.assertEquals;
import java.util.Date;
import org.testng.annotations.Test;
import com.google.common.collect.ImmutableList;
/**
* Tests behavior of {@code ListOptions}
*
* @author Adrian Cole
*/
@Test(groups = "unit")
public class BaseListOptionsTest {
public void testChangesSince() {
Date ifModifiedSince = new Date();
BaseListOptions options = new BaseListOptions().changesSince(ifModifiedSince);
assertEquals(ImmutableList.of(ifModifiedSince.getTime() / 1000 + ""), options
.buildQueryParameters().get("changes-since"));
}
public void testStartAt() {
long offset = 1;
BaseListOptions options = new BaseListOptions().startAt(offset);
assertEquals(ImmutableList.of("1"), options.buildQueryParameters().get("offset"));
}
public void testMaxResults() {
int limit = 1;
BaseListOptions options = new BaseListOptions().maxResults(limit);
assertEquals(ImmutableList.of("1"), options.buildQueryParameters().get("limit"));
}
public void testChangesSinceStatic() {
Date ifModifiedSince = new Date();
BaseListOptions options = changesSince(ifModifiedSince);
assertEquals(ImmutableList.of(ifModifiedSince.getTime() / 1000 + ""), options
.buildQueryParameters().get("changes-since"));
}
public void testStartAtStatic() {
long offset = 1;
BaseListOptions options = startAt(offset);
assertEquals(ImmutableList.of("1"), options.buildQueryParameters().get("offset"));
}
public void testMaxResultsStatic() {
int limit = 1;
BaseListOptions options = maxResults(limit);
assertEquals(ImmutableList.of("1"), options.buildQueryParameters().get("limit"));
}
}

View File

@ -0,0 +1,51 @@
package org.jclouds.openstack.v2_0.predicates;
import static org.jclouds.openstack.v2_0.predicates.LinkPredicates.hrefEquals;
import static org.jclouds.openstack.v2_0.predicates.LinkPredicates.relationEquals;
import static org.jclouds.openstack.v2_0.predicates.LinkPredicates.typeEquals;
import java.net.URI;
import org.jclouds.openstack.v2_0.domain.Link;
import org.jclouds.openstack.v2_0.domain.Link.Relation;
import org.testng.annotations.Test;
/**
*
* @author Adrian Cole
*/
@Test(groups = "unit", testName = "LinkPredicatesTest")
public class LinkPredicatesTest {
Link ref = Link.builder().type("application/pdf").relation(Relation.DESCRIBEDBY).href(
URI.create("http://docs.openstack.org/ext/keypairs/api/v1.1")).build();
@Test
public void testRelationEqualsWhenEqual() {
assert relationEquals(Relation.DESCRIBEDBY).apply(ref);
}
@Test
public void testRelationEqualsWhenNotEqual() {
assert !relationEquals(Relation.UNRECOGNIZED).apply(ref);
}
@Test
public void testTypeEqualsWhenEqual() {
assert typeEquals("application/pdf").apply(ref);
}
@Test
public void testTypeEqualsWhenNotEqual() {
assert !typeEquals("foo").apply(ref);
}
@Test
public void testHrefEqualsWhenEqual() {
assert hrefEquals(URI.create("http://docs.openstack.org/ext/keypairs/api/v1.1")).apply(ref);
}
@Test
public void testHrefEqualsWhenNotEqual() {
assert !hrefEquals(URI.create("foo")).apply(ref);
}
}

View File

@ -1,51 +1,64 @@
<?xml version="1.0"?>
<configuration scan="false">
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
<file>target/test-data/jclouds.log</file>
<encoder>
<Pattern>%d %-5p [%c] [%thread] %m%n</Pattern>
</encoder>
</appender>
<appender name="WIREFILE" class="ch.qos.logback.core.FileAppender">
<file>target/test-data/jclouds-wire.log</file>
<encoder>
<Pattern>%d %-5p [%c] [%thread] %m%n</Pattern>
</encoder>
</appender>
<appender name="BLOBSTOREFILE" class="ch.qos.logback.core.FileAppender">
<file>target/test-data/jclouds-blobstore.log</file>
<encoder>
<Pattern>%d %-5p [%c] [%thread] %m%n</Pattern>
</encoder>
</appender>
<root>
<level value="warn" />
</root>
<logger name="org.jclouds">
<level value="DEBUG" />
<appender-ref ref="FILE" />
</logger>
<logger name="jclouds.wire">
<level value="DEBUG" />
<appender-ref ref="WIREFILE" />
</logger>
<logger name="jclouds.headers">
<level value="DEBUG" />
<appender-ref ref="WIREFILE" />
</logger>
<logger name="jclouds.blobstore">
<level value="DEBUG" />
<appender-ref ref="BLOBSTOREFILE" />
</logger>
</configuration>
<?xml version="1.0"?>
<configuration scan="false">
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
<file>target/test-data/jclouds.log</file>
<encoder>
<Pattern>%d %-5p [%c] [%thread] %m%n</Pattern>
</encoder>
</appender>
<appender name="WIREFILE" class="ch.qos.logback.core.FileAppender">
<file>target/test-data/jclouds-wire.log</file>
<encoder>
<Pattern>%d %-5p [%c] [%thread] %m%n</Pattern>
</encoder>
</appender>
<appender name="COMPUTEFILE" class="ch.qos.logback.core.FileAppender">
<file>target/test-data/jclouds-compute.log</file>
<encoder>
<Pattern>%d %-5p [%c] [%thread] %m%n</Pattern>
</encoder>
</appender>
<appender name="SSHFILE" class="ch.qos.logback.core.FileAppender">
<file>target/test-data/jclouds-ssh.log</file>
<encoder>
<Pattern>%d %-5p [%c] [%thread] %m%n</Pattern>
</encoder>
</appender>
<root>
<level value="warn" />
</root>
<logger name="org.jclouds">
<level value="DEBUG" />
<appender-ref ref="FILE" />
</logger>
<logger name="jclouds.wire">
<level value="DEBUG" />
<appender-ref ref="WIREFILE" />
</logger>
<logger name="jclouds.headers">
<level value="DEBUG" />
<appender-ref ref="WIREFILE" />
</logger>
<logger name="jclouds.compute">
<level value="DEBUG" />
<appender-ref ref="COMPUTEFILE" />
</logger>
<logger name="jclouds.ssh">
<level value="DEBUG" />
<appender-ref ref="SSHFILE" />
</logger>
</configuration>

View File

@ -58,8 +58,8 @@
<dependencies>
<dependency>
<groupId>org.jclouds.common</groupId>
<artifactId>openstack-common</artifactId>
<groupId>org.jclouds.api</groupId>
<artifactId>openstack-keystone</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
@ -75,8 +75,8 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jclouds.common</groupId>
<artifactId>openstack-common</artifactId>
<groupId>org.jclouds.api</groupId>
<artifactId>openstack-keystone</artifactId>
<version>${project.version}</version>
<type>test-jar</type>
<scope>test</scope>

View File

@ -19,6 +19,7 @@
package org.jclouds.openstack.nova.v1_1;
import static org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties.SERVICE_TYPE;
import static org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties.VERSION;
import static org.jclouds.openstack.nova.v1_1.config.NovaProperties.AUTO_ALLOCATE_FLOATING_IPS;
import static org.jclouds.openstack.nova.v1_1.config.NovaProperties.AUTO_GENERATE_KEYPAIRS;
import static org.jclouds.openstack.nova.v1_1.config.NovaProperties.TIMEOUT_SECURITYGROUP_PRESENT;
@ -28,10 +29,9 @@ import java.util.Properties;
import org.jclouds.apis.ApiMetadata;
import org.jclouds.compute.ComputeServiceContext;
import org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties;
import org.jclouds.openstack.nova.v1_1.compute.config.NovaComputeServiceContextModule;
import org.jclouds.openstack.nova.v1_1.config.NovaRestClientModule;
import org.jclouds.openstack.services.ServiceType;
import org.jclouds.openstack.v2_0.ServiceType;
import org.jclouds.rest.RestContext;
import org.jclouds.rest.internal.BaseRestApiMetadata;
@ -74,7 +74,7 @@ public class NovaApiMetadata extends BaseRestApiMetadata {
properties.setProperty(SERVICE_TYPE, ServiceType.COMPUTE);
// TODO: this doesn't actually do anything yet.
properties.setProperty(KeystoneProperties.VERSION, "2.0");
properties.setProperty(VERSION, "2.0");
properties.setProperty(AUTO_ALLOCATE_FLOATING_IPS, "false");
properties.setProperty(AUTO_GENERATE_KEYPAIRS, "false");

View File

@ -23,7 +23,20 @@ import java.util.Set;
import org.jclouds.javax.annotation.Nullable;
import org.jclouds.location.Zone;
import org.jclouds.location.functions.ZoneToEndpoint;
import org.jclouds.openstack.nova.v1_1.extensions.*;
import org.jclouds.openstack.nova.v1_1.extensions.AdminActionsAsyncClient;
import org.jclouds.openstack.nova.v1_1.extensions.FlavorExtraSpecsAsyncClient;
import org.jclouds.openstack.nova.v1_1.extensions.FloatingIPAsyncClient;
import org.jclouds.openstack.nova.v1_1.extensions.HostAdministrationAsyncClient;
import org.jclouds.openstack.nova.v1_1.extensions.HostAggregateAsyncClient;
import org.jclouds.openstack.nova.v1_1.extensions.KeyPairAsyncClient;
import org.jclouds.openstack.nova.v1_1.extensions.QuotaAsyncClient;
import org.jclouds.openstack.nova.v1_1.extensions.QuotaClassAsyncClient;
import org.jclouds.openstack.nova.v1_1.extensions.SecurityGroupAsyncClient;
import org.jclouds.openstack.nova.v1_1.extensions.ServerWithSecurityGroupsAsyncClient;
import org.jclouds.openstack.nova.v1_1.extensions.SimpleTenantUsageAsyncClient;
import org.jclouds.openstack.nova.v1_1.extensions.VirtualInterfaceAsyncClient;
import org.jclouds.openstack.nova.v1_1.extensions.VolumeAsyncClient;
import org.jclouds.openstack.nova.v1_1.extensions.VolumeTypeAsyncClient;
import org.jclouds.openstack.nova.v1_1.features.ExtensionAsyncClient;
import org.jclouds.openstack.nova.v1_1.features.FlavorAsyncClient;
import org.jclouds.openstack.nova.v1_1.features.ImageAsyncClient;

View File

@ -25,7 +25,20 @@ import org.jclouds.concurrent.Timeout;
import org.jclouds.javax.annotation.Nullable;
import org.jclouds.location.Zone;
import org.jclouds.location.functions.ZoneToEndpoint;
import org.jclouds.openstack.nova.v1_1.extensions.*;
import org.jclouds.openstack.nova.v1_1.extensions.AdminActionsClient;
import org.jclouds.openstack.nova.v1_1.extensions.FlavorExtraSpecsClient;
import org.jclouds.openstack.nova.v1_1.extensions.FloatingIPClient;
import org.jclouds.openstack.nova.v1_1.extensions.HostAdministrationClient;
import org.jclouds.openstack.nova.v1_1.extensions.HostAggregateClient;
import org.jclouds.openstack.nova.v1_1.extensions.KeyPairClient;
import org.jclouds.openstack.nova.v1_1.extensions.QuotaClassClient;
import org.jclouds.openstack.nova.v1_1.extensions.QuotaClient;
import org.jclouds.openstack.nova.v1_1.extensions.SecurityGroupClient;
import org.jclouds.openstack.nova.v1_1.extensions.ServerWithSecurityGroupsClient;
import org.jclouds.openstack.nova.v1_1.extensions.SimpleTenantUsageClient;
import org.jclouds.openstack.nova.v1_1.extensions.VirtualInterfaceClient;
import org.jclouds.openstack.nova.v1_1.extensions.VolumeClient;
import org.jclouds.openstack.nova.v1_1.extensions.VolumeTypeClient;
import org.jclouds.openstack.nova.v1_1.features.ExtensionClient;
import org.jclouds.openstack.nova.v1_1.features.FlavorClient;
import org.jclouds.openstack.nova.v1_1.features.ImageClient;

View File

@ -35,7 +35,34 @@ import org.jclouds.openstack.keystone.v2_0.config.KeystoneAuthenticationModule;
import org.jclouds.openstack.nova.v1_1.NovaAsyncClient;
import org.jclouds.openstack.nova.v1_1.NovaClient;
import org.jclouds.openstack.nova.v1_1.domain.Extension;
import org.jclouds.openstack.nova.v1_1.extensions.*;
import org.jclouds.openstack.nova.v1_1.extensions.AdminActionsAsyncClient;
import org.jclouds.openstack.nova.v1_1.extensions.AdminActionsClient;
import org.jclouds.openstack.nova.v1_1.extensions.FlavorExtraSpecsAsyncClient;
import org.jclouds.openstack.nova.v1_1.extensions.FlavorExtraSpecsClient;
import org.jclouds.openstack.nova.v1_1.extensions.FloatingIPAsyncClient;
import org.jclouds.openstack.nova.v1_1.extensions.FloatingIPClient;
import org.jclouds.openstack.nova.v1_1.extensions.HostAdministrationAsyncClient;
import org.jclouds.openstack.nova.v1_1.extensions.HostAdministrationClient;
import org.jclouds.openstack.nova.v1_1.extensions.HostAggregateAsyncClient;
import org.jclouds.openstack.nova.v1_1.extensions.HostAggregateClient;
import org.jclouds.openstack.nova.v1_1.extensions.KeyPairAsyncClient;
import org.jclouds.openstack.nova.v1_1.extensions.KeyPairClient;
import org.jclouds.openstack.nova.v1_1.extensions.QuotaAsyncClient;
import org.jclouds.openstack.nova.v1_1.extensions.QuotaClassAsyncClient;
import org.jclouds.openstack.nova.v1_1.extensions.QuotaClassClient;
import org.jclouds.openstack.nova.v1_1.extensions.QuotaClient;
import org.jclouds.openstack.nova.v1_1.extensions.SecurityGroupAsyncClient;
import org.jclouds.openstack.nova.v1_1.extensions.SecurityGroupClient;
import org.jclouds.openstack.nova.v1_1.extensions.ServerWithSecurityGroupsAsyncClient;
import org.jclouds.openstack.nova.v1_1.extensions.ServerWithSecurityGroupsClient;
import org.jclouds.openstack.nova.v1_1.extensions.SimpleTenantUsageAsyncClient;
import org.jclouds.openstack.nova.v1_1.extensions.SimpleTenantUsageClient;
import org.jclouds.openstack.nova.v1_1.extensions.VirtualInterfaceAsyncClient;
import org.jclouds.openstack.nova.v1_1.extensions.VirtualInterfaceClient;
import org.jclouds.openstack.nova.v1_1.extensions.VolumeAsyncClient;
import org.jclouds.openstack.nova.v1_1.extensions.VolumeClient;
import org.jclouds.openstack.nova.v1_1.extensions.VolumeTypeAsyncClient;
import org.jclouds.openstack.nova.v1_1.extensions.VolumeTypeClient;
import org.jclouds.openstack.nova.v1_1.features.ExtensionAsyncClient;
import org.jclouds.openstack.nova.v1_1.features.ExtensionClient;
import org.jclouds.openstack.nova.v1_1.features.FlavorAsyncClient;

View File

@ -21,7 +21,7 @@ package org.jclouds.openstack.nova.v1_1.domain;
import java.net.URI;
import java.util.Date;
import org.jclouds.openstack.domain.Resource;
import org.jclouds.openstack.v2_0.domain.Resource;
import com.google.common.base.Objects;

View File

@ -18,7 +18,7 @@
*/
package org.jclouds.openstack.nova.v1_1.domain;
import org.jclouds.openstack.domain.Resource;
import org.jclouds.openstack.v2_0.domain.Resource;
import com.google.common.base.Objects;
import com.google.common.base.Optional;

View File

@ -26,8 +26,8 @@ import java.util.Map;
import java.util.Set;
import com.google.common.base.Objects;
import com.google.common.base.Objects.ToStringHelper;
import com.google.common.base.Optional;
import com.google.common.base.Objects.ToStringHelper;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.gson.annotations.SerializedName;

Some files were not shown because too many files have changed in this diff Show More