mirror of https://github.com/apache/jclouds.git
openstack: adjusting beans in openstack-nova and openstack-keystone to use ConstructorProperties/Named annotations
This commit is contained in:
parent
3fd65f25ce
commit
294e405593
|
@ -1,9 +1,9 @@
|
|||
/**
|
||||
/*
|
||||
* 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, User 2.0 (the
|
||||
* 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
|
||||
*
|
||||
|
@ -18,13 +18,13 @@
|
|||
*/
|
||||
package org.jclouds.openstack.keystone.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.beans.ConstructorProperties;
|
||||
import java.util.Set;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
/**
|
||||
|
@ -32,19 +32,21 @@ import com.google.common.collect.ImmutableSet;
|
|||
*
|
||||
* @author Adrian Cole
|
||||
* @see <a href="http://docs.openstack.org/api/openstack-identity-service/2.0/content/Service_API_Client_Operations.html"
|
||||
* />
|
||||
/>
|
||||
*/
|
||||
public class Access implements Comparable<Access> {
|
||||
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
public static Builder<?> builder() {
|
||||
return new ConcreteBuilder();
|
||||
}
|
||||
|
||||
public Builder toBuilder() {
|
||||
return builder().fromAccess(this);
|
||||
public Builder<?> toBuilder() {
|
||||
return new ConcreteBuilder().fromAccess(this);
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
public static abstract class Builder<T extends Builder<T>> {
|
||||
protected abstract T self();
|
||||
|
||||
protected Token token;
|
||||
protected User user;
|
||||
protected Set<Service> serviceCatalog = ImmutableSet.of();
|
||||
|
@ -52,55 +54,58 @@ public class Access implements Comparable<Access> {
|
|||
/**
|
||||
* @see Access#getToken()
|
||||
*/
|
||||
public Builder token(Token token) {
|
||||
this.token = checkNotNull(token, "token");
|
||||
return this;
|
||||
public T token(Token token) {
|
||||
this.token = token;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Access#getUser()
|
||||
*/
|
||||
public Builder user(User user) {
|
||||
this.user = checkNotNull(user, "user");
|
||||
return this;
|
||||
public T user(User user) {
|
||||
this.user = user;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Access#getServiceCatalog()
|
||||
*/
|
||||
public Builder serviceCatalog(Service... serviceCatalog) {
|
||||
return serviceCatalog(ImmutableSet.copyOf(checkNotNull(serviceCatalog, "serviceCatalog")));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Access#getServiceCatalog()
|
||||
*/
|
||||
public Builder serviceCatalog(Set<Service> serviceCatalog) {
|
||||
public T serviceCatalog(Set<Service> serviceCatalog) {
|
||||
this.serviceCatalog = ImmutableSet.copyOf(checkNotNull(serviceCatalog, "serviceCatalog"));
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public T serviceCatalog(Service... in) {
|
||||
return serviceCatalog(ImmutableSet.copyOf(in));
|
||||
}
|
||||
|
||||
public Access build() {
|
||||
return new Access(token, user, serviceCatalog);
|
||||
}
|
||||
|
||||
public Builder fromAccess(Access from) {
|
||||
return token(from.getToken()).user(from.getUser()).serviceCatalog(from.getServiceCatalog());
|
||||
public T fromAccess(Access in) {
|
||||
return this
|
||||
.token(in.getToken())
|
||||
.user(in.getUser())
|
||||
.serviceCatalog(in.getServiceCatalog());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected Access() {
|
||||
// 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 static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
@Override
|
||||
protected ConcreteBuilder self() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
protected Token token;
|
||||
protected User user;
|
||||
protected Set<Service> serviceCatalog = ImmutableSet.of();
|
||||
private final Token token;
|
||||
private final User user;
|
||||
private final Set<Service> serviceCatalog;
|
||||
|
||||
public Access(Token token, User user, Set<Service> serviceCatalog) {
|
||||
@ConstructorProperties({
|
||||
"token", "user", "serviceCatalog"
|
||||
})
|
||||
protected Access(Token token, User user, Set<Service> serviceCatalog) {
|
||||
this.token = checkNotNull(token, "token");
|
||||
this.user = checkNotNull(user, "user");
|
||||
this.serviceCatalog = ImmutableSet.copyOf(checkNotNull(serviceCatalog, "serviceCatalog"));
|
||||
|
@ -110,34 +115,21 @@ public class Access implements Comparable<Access> {
|
|||
* TODO
|
||||
*/
|
||||
public Token getToken() {
|
||||
return token;
|
||||
return this.token;
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO
|
||||
*/
|
||||
public User getUser() {
|
||||
return user;
|
||||
return this.user;
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO
|
||||
*/
|
||||
public Set<Service> getServiceCatalog() {
|
||||
return serviceCatalog;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object object) {
|
||||
if (this == object) {
|
||||
return true;
|
||||
}
|
||||
if (object instanceof Access) {
|
||||
final Access other = Access.class.cast(object);
|
||||
return equal(token, other.token) && equal(user, other.user) && equal(serviceCatalog, other.serviceCatalog);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return this.serviceCatalog;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -145,9 +137,24 @@ public class Access implements Comparable<Access> {
|
|||
return Objects.hashCode(token, user, serviceCatalog);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
Access that = Access.class.cast(obj);
|
||||
return Objects.equal(this.token, that.token)
|
||||
&& Objects.equal(this.user, that.user)
|
||||
&& Objects.equal(this.serviceCatalog, that.serviceCatalog);
|
||||
}
|
||||
|
||||
protected ToStringHelper string() {
|
||||
return Objects.toStringHelper(this)
|
||||
.add("token", token).add("user", user).add("serviceCatalog", serviceCatalog);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return toStringHelper("").add("token", token).add("user", user).add("serviceCatalog", serviceCatalog).toString();
|
||||
return string().toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
/*
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
|
@ -16,71 +16,86 @@
|
|||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.jclouds.openstack.keystone.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.beans.ConstructorProperties;
|
||||
|
||||
import org.jclouds.openstack.keystone.v2_0.config.CredentialType;
|
||||
import org.jclouds.openstack.keystone.v2_0.config.CredentialTypes;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
|
||||
/**
|
||||
* Api AccessKey Credentials
|
||||
*
|
||||
* @see <a href="http://docs.openstack.org/api/openstack-identity-service/2.0/content/POST_authenticate_v2.0_tokens_Service_API_Client_Operations.html#d662e583"
|
||||
* />
|
||||
/>
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@CredentialType(CredentialTypes.API_ACCESS_KEY_CREDENTIALS)
|
||||
public class ApiAccessKeyCredentials {
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
|
||||
public static Builder<?> builder() {
|
||||
return new ConcreteBuilder();
|
||||
}
|
||||
|
||||
public Builder toBuilder() {
|
||||
return builder().fromSecretKeyCredentials(this);
|
||||
public Builder<?> toBuilder() {
|
||||
return new ConcreteBuilder().fromApiAccessKeyCredentials(this);
|
||||
}
|
||||
|
||||
public static ApiAccessKeyCredentials createWithAccessKeyAndSecretKey(String accessKey, String secretKey) {
|
||||
return builder().secretKey(secretKey).accessKey(accessKey).build();
|
||||
return new ApiAccessKeyCredentials(accessKey, secretKey);
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
public static abstract class Builder<T extends Builder<T>> {
|
||||
protected abstract T self();
|
||||
|
||||
protected String accessKey;
|
||||
protected String secretKey;
|
||||
|
||||
/**
|
||||
* @see ApiAccessKeyCredentials#getAccessKey()
|
||||
*/
|
||||
protected Builder secretKey(String secretKey) {
|
||||
this.secretKey = secretKey;
|
||||
return this;
|
||||
public T accessKey(String accessKey) {
|
||||
this.accessKey = accessKey;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ApiAccessKeyCredentials#getSecretKey()
|
||||
*/
|
||||
public Builder accessKey(String accessKey) {
|
||||
this.accessKey = accessKey;
|
||||
return this;
|
||||
public T secretKey(String secretKey) {
|
||||
this.secretKey = secretKey;
|
||||
return self();
|
||||
}
|
||||
|
||||
public ApiAccessKeyCredentials build() {
|
||||
return new ApiAccessKeyCredentials(accessKey, secretKey);
|
||||
}
|
||||
|
||||
public Builder fromSecretKeyCredentials(ApiAccessKeyCredentials from) {
|
||||
return accessKey(from.getAccessKey()).secretKey(from.getSecretKey());
|
||||
public T fromApiAccessKeyCredentials(ApiAccessKeyCredentials in) {
|
||||
return this
|
||||
.accessKey(in.getAccessKey())
|
||||
.secretKey(in.getSecretKey());
|
||||
}
|
||||
}
|
||||
|
||||
protected final String accessKey;
|
||||
protected final String secretKey;
|
||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
@Override
|
||||
protected ConcreteBuilder self() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
private final String accessKey;
|
||||
private final String secretKey;
|
||||
|
||||
@ConstructorProperties({
|
||||
"accessKey", "secretKey"
|
||||
})
|
||||
protected ApiAccessKeyCredentials(String accessKey, String secretKey) {
|
||||
this.accessKey = checkNotNull(accessKey, "accessKey");
|
||||
this.secretKey = checkNotNull(secretKey, "secretKey");
|
||||
|
@ -90,27 +105,14 @@ public class ApiAccessKeyCredentials {
|
|||
* @return the accessKey
|
||||
*/
|
||||
public String getAccessKey() {
|
||||
return accessKey;
|
||||
return this.accessKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the secretKey
|
||||
*/
|
||||
public String getSecretKey() {
|
||||
return secretKey;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object object) {
|
||||
if (this == object) {
|
||||
return true;
|
||||
}
|
||||
if (object instanceof ApiAccessKeyCredentials) {
|
||||
final ApiAccessKeyCredentials other = ApiAccessKeyCredentials.class.cast(object);
|
||||
return equal(accessKey, other.accessKey) && equal(secretKey, other.secretKey);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return this.secretKey;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -118,9 +120,23 @@ public class ApiAccessKeyCredentials {
|
|||
return Objects.hashCode(accessKey, secretKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
ApiAccessKeyCredentials that = ApiAccessKeyCredentials.class.cast(obj);
|
||||
return Objects.equal(this.accessKey, that.accessKey)
|
||||
&& Objects.equal(this.secretKey, that.secretKey);
|
||||
}
|
||||
|
||||
protected ToStringHelper string() {
|
||||
return Objects.toStringHelper(this)
|
||||
.add("accessKey", accessKey).add("secretKey", secretKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return toStringHelper("").add("accessKey", accessKey).add("secretKey", secretKey).toString();
|
||||
return string().toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
/*
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
|
@ -20,20 +20,23 @@ package org.jclouds.openstack.keystone.v2_0.domain;
|
|||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.beans.ConstructorProperties;
|
||||
import java.util.Date;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.inject.Named;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
import org.jclouds.openstack.v2_0.domain.Link;
|
||||
import org.jclouds.openstack.v2_0.domain.Resource;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
/**
|
||||
* Class ApiMetadata
|
||||
*
|
||||
* @author Adam Lowe
|
||||
*/
|
||||
public class ApiMetadata extends Resource {
|
||||
|
@ -47,9 +50,9 @@ public class ApiMetadata extends Resource {
|
|||
}
|
||||
|
||||
public static abstract class Builder<T extends Builder<T>> extends Resource.Builder<T> {
|
||||
private String status;
|
||||
private Date updated;
|
||||
private Set<MediaType> mediaTypes = Sets.newLinkedHashSet();
|
||||
protected String status;
|
||||
protected Date updated;
|
||||
protected Set<MediaType> mediaTypes = ImmutableSet.of();
|
||||
|
||||
/**
|
||||
* @see ApiMetadata#getStatus()
|
||||
|
@ -71,12 +74,16 @@ public class ApiMetadata extends Resource {
|
|||
* @see ApiMetadata#getMediaTypes()
|
||||
*/
|
||||
public T mediaTypes(Set<MediaType> mediaTypes) {
|
||||
this.mediaTypes = mediaTypes;
|
||||
this.mediaTypes = ImmutableSet.copyOf(checkNotNull(mediaTypes, "mediaTypes"));
|
||||
return self();
|
||||
}
|
||||
|
||||
public T mediaTypes(MediaType... in) {
|
||||
return mediaTypes(ImmutableSet.copyOf(in));
|
||||
}
|
||||
|
||||
public ApiMetadata build() {
|
||||
return new ApiMetadata(this);
|
||||
return new ApiMetadata(id, name, links, status, updated, mediaTypes);
|
||||
}
|
||||
|
||||
public T fromApiMetadata(ApiMetadata in) {
|
||||
|
@ -85,7 +92,6 @@ public class ApiMetadata extends Resource {
|
|||
.updated(in.getUpdated())
|
||||
.mediaTypes(in.getMediaTypes());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
|
@ -95,43 +101,33 @@ public class ApiMetadata extends Resource {
|
|||
}
|
||||
}
|
||||
|
||||
protected ApiMetadata() {
|
||||
// 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 final String status;
|
||||
private final Date updated;
|
||||
@Named("media-types")
|
||||
private final Set<MediaType> mediaTypes;
|
||||
|
||||
@ConstructorProperties({
|
||||
"id", "name", "links", "status", "updated", "media-types"
|
||||
})
|
||||
protected ApiMetadata(String id, @Nullable String name, java.util.Set<Link> links, @Nullable String status, @Nullable Date updated, Set<MediaType> mediaTypes) {
|
||||
super(id, name, links);
|
||||
this.status = status;
|
||||
this.updated = updated;
|
||||
this.mediaTypes = ImmutableSet.copyOf(checkNotNull(mediaTypes, "mediaTypes"));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private String status;
|
||||
@Nullable
|
||||
private Date updated;
|
||||
|
||||
@SerializedName(value="media-types")
|
||||
private Set<MediaType> mediaTypes = Sets.newLinkedHashSet();
|
||||
|
||||
protected ApiMetadata(Builder<?> builder) {
|
||||
super(builder);
|
||||
this.status = checkNotNull(builder.status, "status");
|
||||
this.updated = checkNotNull(builder.updated, "updated");
|
||||
this.mediaTypes = ImmutableSet.copyOf(builder.mediaTypes);
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public String getStatus() {
|
||||
return this.status;
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
@Nullable
|
||||
public Date getUpdated() {
|
||||
return this.updated;
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public Set<MediaType> getMediaTypes() {
|
||||
return Collections.unmodifiableSet(this.mediaTypes);
|
||||
return this.mediaTypes;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -151,9 +147,7 @@ public class ApiMetadata extends Resource {
|
|||
|
||||
protected ToStringHelper string() {
|
||||
return super.string()
|
||||
.add("status", status)
|
||||
.add("updated", updated)
|
||||
.add("mediaTypes", mediaTypes);
|
||||
.add("status", status).add("updated", updated).add("mediaTypes", mediaTypes);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,9 +1,9 @@
|
|||
/**
|
||||
/*
|
||||
* 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
|
||||
* 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
|
||||
*
|
||||
|
@ -16,19 +16,17 @@
|
|||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.jclouds.openstack.keystone.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.beans.ConstructorProperties;
|
||||
import java.net.URI;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.collect.ComparisonChain;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
|
||||
/**
|
||||
* An network-accessible address, usually described by URL, where a service may be accessed. If
|
||||
|
@ -37,19 +35,20 @@ import com.google.common.collect.ComparisonChain;
|
|||
*
|
||||
* @author AdrianCole
|
||||
* @see <a href="http://docs.openstack.org/api/openstack-identity-service/2.0/content/Identity-Endpoint-Concepts-e1362.html"
|
||||
* />
|
||||
/>
|
||||
*/
|
||||
public class Endpoint implements Comparable<Endpoint> {
|
||||
public class Endpoint {
|
||||
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
public static Builder<?> builder() {
|
||||
return new ConcreteBuilder();
|
||||
}
|
||||
|
||||
public Builder toBuilder() {
|
||||
return builder().fromEndpoint(this);
|
||||
public Builder<?> toBuilder() {
|
||||
return new ConcreteBuilder().fromEndpoint(this);
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
public static abstract class Builder<T extends Builder<T>> {
|
||||
protected abstract T self();
|
||||
|
||||
protected String versionId;
|
||||
protected String region;
|
||||
|
@ -63,108 +62,112 @@ public class Endpoint implements Comparable<Endpoint> {
|
|||
/**
|
||||
* @see Endpoint#getVersionId()
|
||||
*/
|
||||
public Builder versionId(String versionId) {
|
||||
this.versionId = checkNotNull(versionId, "versionId");
|
||||
return this;
|
||||
public T versionId(String versionId) {
|
||||
this.versionId = versionId;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Endpoint#getRegion()
|
||||
*/
|
||||
public Builder region(String region) {
|
||||
this.region = checkNotNull(region, "region");
|
||||
return this;
|
||||
public T region(String region) {
|
||||
this.region = region;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Endpoint#getPublicURL()
|
||||
*/
|
||||
public Builder publicURL(URI publicURL) {
|
||||
this.publicURL = checkNotNull(publicURL, "publicURL");
|
||||
return this;
|
||||
public T publicURL(URI publicURL) {
|
||||
this.publicURL = publicURL;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Endpoint#getInternalURL()
|
||||
*/
|
||||
public Builder internalURL(URI internalURL) {
|
||||
this.internalURL = checkNotNull(internalURL, "internalURL");
|
||||
return this;
|
||||
public T internalURL(URI internalURL) {
|
||||
this.internalURL = internalURL;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Endpoint#getInternalURL()
|
||||
* @see Endpoint#getAdminURL()
|
||||
*/
|
||||
public Builder adminURL(URI adminURL) {
|
||||
this.adminURL = checkNotNull(adminURL, "adminURL");
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Endpoint#getTenantId()
|
||||
*/
|
||||
public Builder tenantId(@Nullable String tenantId) {
|
||||
this.tenantId = tenantId;
|
||||
return this;
|
||||
public T adminURL(URI adminURL) {
|
||||
this.adminURL = adminURL;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Endpoint#getVersionInfo()
|
||||
*/
|
||||
public Builder versionInfo(URI versionInfo) {
|
||||
this.versionInfo = checkNotNull(versionInfo, "versionInfo");
|
||||
return this;
|
||||
public T versionInfo(URI versionInfo) {
|
||||
this.versionInfo = versionInfo;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Endpoint#getVersionList()
|
||||
*/
|
||||
public Builder versionList(URI versionList) {
|
||||
this.versionList = checkNotNull(versionList, "versionList");
|
||||
return this;
|
||||
public T versionList(URI versionList) {
|
||||
this.versionList = versionList;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Endpoint#getTenantId()
|
||||
*/
|
||||
public T tenantId(String tenantId) {
|
||||
this.tenantId = tenantId;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Endpoint build() {
|
||||
return new Endpoint(versionId, region, publicURL, internalURL, adminURL, tenantId, versionInfo, versionList);
|
||||
return new Endpoint(null, versionId, region, publicURL, internalURL, adminURL, versionInfo, versionList, null, tenantId);
|
||||
}
|
||||
|
||||
public Builder fromEndpoint(Endpoint from) {
|
||||
return versionId(from.getVersionId()).region(from.getRegion()).publicURL(from.getPublicURL()).internalURL(
|
||||
from.getInternalURL()).tenantId(from.getTenantId()).versionInfo(from.getVersionInfo()).versionList(
|
||||
from.getVersionList());
|
||||
public T fromEndpoint(Endpoint in) {
|
||||
return this
|
||||
.versionId(in.getVersionId())
|
||||
.region(in.getRegion())
|
||||
.publicURL(in.getPublicURL())
|
||||
.internalURL(in.getInternalURL())
|
||||
.adminURL(in.getAdminURL())
|
||||
.versionInfo(in.getVersionInfo())
|
||||
.versionList(in.getVersionList())
|
||||
.tenantId(in.getTenantId());
|
||||
}
|
||||
}
|
||||
|
||||
protected Endpoint() {
|
||||
// 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 static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
@Override
|
||||
protected ConcreteBuilder self() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
// renamed half-way through
|
||||
@Deprecated
|
||||
protected String id;
|
||||
protected String versionId;
|
||||
protected String region;
|
||||
protected URI publicURL;
|
||||
protected URI internalURL;
|
||||
protected URI adminURL;
|
||||
protected URI versionInfo;
|
||||
protected URI versionList;
|
||||
private final String versionId;
|
||||
private final String region;
|
||||
private final URI publicURL;
|
||||
private final URI internalURL;
|
||||
private final URI adminURL;
|
||||
private final URI versionInfo;
|
||||
private final URI versionList;
|
||||
private final String tenantId;
|
||||
|
||||
// renamed half-way through
|
||||
@Deprecated
|
||||
protected String tenantName;
|
||||
protected String tenantId;
|
||||
|
||||
protected Endpoint(@Nullable String versionId, @Nullable String region, @Nullable URI publicURL, @Nullable URI internalURL,
|
||||
@Nullable URI adminURL, @Nullable String tenantId, @Nullable URI versionInfo, @Nullable URI versionList) {
|
||||
this.versionId = versionId;
|
||||
@ConstructorProperties({
|
||||
"id", "versionId", "region", "publicURL", "internalURL", "adminURL", "versionInfo", "versionList", "tenantName", "tenantId"
|
||||
})
|
||||
protected Endpoint(@Nullable String id, @Nullable String versionId, @Nullable String region, @Nullable URI publicURL,
|
||||
@Nullable URI internalURL, @Nullable URI adminURL, @Nullable URI versionInfo, @Nullable URI versionList,
|
||||
@Nullable String tenantName, @Nullable String tenantId) {
|
||||
this.versionId = versionId != null ? versionId : id;
|
||||
this.tenantId = tenantId != null ? tenantId : tenantName;
|
||||
this.region = region;
|
||||
this.publicURL = publicURL;
|
||||
this.internalURL = internalURL;
|
||||
this.adminURL = adminURL;
|
||||
this.tenantId = tenantId;
|
||||
this.versionInfo = versionInfo;
|
||||
this.versionList = versionList;
|
||||
}
|
||||
|
@ -177,7 +180,7 @@ public class Endpoint implements Comparable<Endpoint> {
|
|||
*/
|
||||
@Nullable
|
||||
public String getVersionId() {
|
||||
return versionId != null ? versionId : id;
|
||||
return this.versionId;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -185,7 +188,7 @@ public class Endpoint implements Comparable<Endpoint> {
|
|||
*/
|
||||
@Nullable
|
||||
public String getRegion() {
|
||||
return region;
|
||||
return this.region;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -193,7 +196,7 @@ public class Endpoint implements Comparable<Endpoint> {
|
|||
*/
|
||||
@Nullable
|
||||
public URI getPublicURL() {
|
||||
return publicURL;
|
||||
return this.publicURL;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -201,7 +204,7 @@ public class Endpoint implements Comparable<Endpoint> {
|
|||
*/
|
||||
@Nullable
|
||||
public URI getInternalURL() {
|
||||
return internalURL;
|
||||
return this.internalURL;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -209,7 +212,17 @@ public class Endpoint implements Comparable<Endpoint> {
|
|||
*/
|
||||
@Nullable
|
||||
public URI getAdminURL() {
|
||||
return adminURL;
|
||||
return this.adminURL;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public URI getVersionInfo() {
|
||||
return this.versionInfo;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public URI getVersionList() {
|
||||
return this.versionList;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -217,53 +230,38 @@ public class Endpoint implements Comparable<Endpoint> {
|
|||
*/
|
||||
@Nullable
|
||||
public String getTenantId() {
|
||||
return tenantId != null ? tenantId : tenantName;
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
@Nullable
|
||||
public URI getVersionInfo() {
|
||||
return versionInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
@Nullable
|
||||
public URI getVersionList() {
|
||||
return versionList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object object) {
|
||||
if (this == object) {
|
||||
return true;
|
||||
}
|
||||
if (object instanceof Endpoint) {
|
||||
final Endpoint other = Endpoint.class.cast(object);
|
||||
return equal(getVersionId(), other.getVersionId()) && equal(region, other.region) && equal(publicURL, other.publicURL)
|
||||
&& equal(internalURL, other.internalURL) && equal(adminURL, other.adminURL) && equal(getTenantId(), other.getTenantId());
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return this.tenantId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(getVersionId(), region, publicURL, internalURL, adminURL, getTenantId());
|
||||
return Objects.hashCode(versionId, region, publicURL, internalURL, adminURL, versionInfo, versionList, tenantId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
Endpoint that = Endpoint.class.cast(obj);
|
||||
return Objects.equal(this.versionId, that.versionId)
|
||||
&& Objects.equal(this.region, that.region)
|
||||
&& Objects.equal(this.publicURL, that.publicURL)
|
||||
&& Objects.equal(this.internalURL, that.internalURL)
|
||||
&& Objects.equal(this.adminURL, that.adminURL)
|
||||
&& Objects.equal(this.versionInfo, that.versionInfo)
|
||||
&& Objects.equal(this.versionList, that.versionList)
|
||||
&& Objects.equal(this.tenantId, that.tenantId);
|
||||
}
|
||||
|
||||
protected ToStringHelper string() {
|
||||
return Objects.toStringHelper(this)
|
||||
.add("versionId", versionId).add("region", region).add("publicURL", publicURL).add("internalURL", internalURL)
|
||||
.add("adminURL", adminURL).add("versionInfo", versionInfo).add("versionList", versionList).add("tenantId", tenantId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return toStringHelper("").add("versionId", getVersionId()).add("region", region).add("publicURL", publicURL).add(
|
||||
"internalURL", internalURL).add("adminURL", adminURL).add("tenantId", getTenantId()).add("versionInfo",
|
||||
versionInfo).add("versionList", versionList).toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(Endpoint that) {
|
||||
return ComparisonChain.start().compare(this.getTenantId(), that.getTenantId()).compare(this.getVersionId(), that.getVersionId())
|
||||
.compare(this.region, that.region).result();
|
||||
return string().toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
/*
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
|
@ -18,6 +18,8 @@
|
|||
*/
|
||||
package org.jclouds.openstack.keystone.v2_0.domain;
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
|
@ -28,61 +30,70 @@ import com.google.common.base.Objects.ToStringHelper;
|
|||
*/
|
||||
public class MediaType {
|
||||
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
public static Builder<?> builder() {
|
||||
return new ConcreteBuilder();
|
||||
}
|
||||
|
||||
public Builder toBuilder() {
|
||||
return builder().fromMediaType(this);
|
||||
public Builder<?> toBuilder() {
|
||||
return new ConcreteBuilder().fromMediaType(this);
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
public static abstract class Builder<T extends Builder<T>> {
|
||||
protected abstract T self();
|
||||
|
||||
private String base;
|
||||
private String type;
|
||||
protected String base;
|
||||
protected String type;
|
||||
|
||||
public Builder base(String base) {
|
||||
/**
|
||||
* @see MediaType#getBase()
|
||||
*/
|
||||
public T base(String base) {
|
||||
this.base = base;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder type(String type) {
|
||||
/**
|
||||
* @see MediaType#getType()
|
||||
*/
|
||||
public T type(String type) {
|
||||
this.type = type;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public MediaType build() {
|
||||
return new MediaType(this);
|
||||
return new MediaType(base, type);
|
||||
}
|
||||
|
||||
public Builder fromMediaType(MediaType in) {
|
||||
return this.base(in.getBase()).type(in.getType());
|
||||
public T fromMediaType(MediaType in) {
|
||||
return this
|
||||
.base(in.getBase())
|
||||
.type(in.getType());
|
||||
}
|
||||
}
|
||||
|
||||
protected MediaType() {
|
||||
// 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 static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
@Override
|
||||
protected ConcreteBuilder self() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
private String base;
|
||||
private String type;
|
||||
private final String base;
|
||||
private final String type;
|
||||
|
||||
protected MediaType(Builder builder) {
|
||||
this.base = builder.base;
|
||||
this.type = builder.type;
|
||||
@ConstructorProperties({
|
||||
"base", "type"
|
||||
})
|
||||
protected MediaType(@Nullable String base, @Nullable String type) {
|
||||
this.base = base;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
@Nullable
|
||||
public String getBase() {
|
||||
return this.base;
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
@Nullable
|
||||
public String getType() {
|
||||
return this.type;
|
||||
|
@ -99,14 +110,12 @@ public class MediaType {
|
|||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
MediaType that = MediaType.class.cast(obj);
|
||||
return Objects.equal(this.base, that.base)
|
||||
&& Objects.equal(this.type, that.type)
|
||||
;
|
||||
&& Objects.equal(this.type, that.type);
|
||||
}
|
||||
|
||||
protected ToStringHelper string() {
|
||||
return Objects.toStringHelper("")
|
||||
.add("base", base)
|
||||
.add("type", type);
|
||||
return Objects.toStringHelper(this)
|
||||
.add("base", base).add("type", type);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
/*
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
|
@ -16,71 +16,85 @@
|
|||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.jclouds.openstack.keystone.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.beans.ConstructorProperties;
|
||||
|
||||
import org.jclouds.openstack.keystone.v2_0.config.CredentialType;
|
||||
import org.jclouds.openstack.keystone.v2_0.config.CredentialTypes;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
|
||||
/**
|
||||
* Password Credentials
|
||||
*
|
||||
* @see <a href="http://docs.openstack.org/api/openstack-identity-service/2.0/content/POST_authenticate_v2.0_tokens_Service_API_Client_Operations.html#d662e583"
|
||||
* />
|
||||
/>
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@CredentialType(CredentialTypes.PASSWORD_CREDENTIALS)
|
||||
@CredentialType("passwordCredentials")
|
||||
public class PasswordCredentials {
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
|
||||
public static Builder<?> builder() {
|
||||
return new ConcreteBuilder();
|
||||
}
|
||||
|
||||
public Builder toBuilder() {
|
||||
return builder().fromPasswordCredentials(this);
|
||||
public Builder<?> toBuilder() {
|
||||
return new ConcreteBuilder().fromPasswordCredentials(this);
|
||||
}
|
||||
|
||||
public static PasswordCredentials createWithUsernameAndPassword(String username, String password) {
|
||||
return builder().password(password).username(username).build();
|
||||
return new PasswordCredentials(username, password);
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
public static abstract class Builder<T extends Builder<T>> {
|
||||
protected abstract T self();
|
||||
|
||||
protected String username;
|
||||
protected String password;
|
||||
|
||||
/**
|
||||
* @see PasswordCredentials#getUsername()
|
||||
*/
|
||||
protected Builder password(String password) {
|
||||
this.password = password;
|
||||
return this;
|
||||
public T username(String username) {
|
||||
this.username = username;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see PasswordCredentials#getPassword()
|
||||
*/
|
||||
public Builder username(String username) {
|
||||
this.username = username;
|
||||
return this;
|
||||
public T password(String password) {
|
||||
this.password = password;
|
||||
return self();
|
||||
}
|
||||
|
||||
public PasswordCredentials build() {
|
||||
return new PasswordCredentials(username, password);
|
||||
}
|
||||
|
||||
public Builder fromPasswordCredentials(PasswordCredentials from) {
|
||||
return username(from.getUsername()).password(from.getPassword());
|
||||
public T fromPasswordCredentials(PasswordCredentials in) {
|
||||
return this
|
||||
.username(in.getUsername())
|
||||
.password(in.getPassword());
|
||||
}
|
||||
}
|
||||
|
||||
protected final String username;
|
||||
protected final String password;
|
||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
@Override
|
||||
protected ConcreteBuilder self() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
private final String username;
|
||||
private final String password;
|
||||
|
||||
@ConstructorProperties({
|
||||
"username", "password"
|
||||
})
|
||||
protected PasswordCredentials(String username, String password) {
|
||||
this.username = checkNotNull(username, "username");
|
||||
this.password = checkNotNull(password, "password");
|
||||
|
@ -90,27 +104,14 @@ public class PasswordCredentials {
|
|||
* @return the username
|
||||
*/
|
||||
public String getUsername() {
|
||||
return username;
|
||||
return this.username;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the password
|
||||
*/
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object object) {
|
||||
if (this == object) {
|
||||
return true;
|
||||
}
|
||||
if (object instanceof PasswordCredentials) {
|
||||
final PasswordCredentials other = PasswordCredentials.class.cast(object);
|
||||
return equal(username, other.username) && equal(password, other.password);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return this.password;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -118,9 +119,23 @@ public class PasswordCredentials {
|
|||
return Objects.hashCode(username, password);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
PasswordCredentials that = PasswordCredentials.class.cast(obj);
|
||||
return Objects.equal(this.username, that.username)
|
||||
&& Objects.equal(this.password, that.password);
|
||||
}
|
||||
|
||||
protected ToStringHelper string() {
|
||||
return Objects.toStringHelper(this)
|
||||
.add("username", username).add("password", password);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return toStringHelper("").add("username", username).add("password", password).toString();
|
||||
return string().toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/**
|
||||
/*
|
||||
* 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
|
||||
* 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
|
||||
*
|
||||
|
@ -16,17 +16,16 @@
|
|||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.jclouds.openstack.keystone.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.beans.ConstructorProperties;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.collect.ComparisonChain;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
|
||||
/**
|
||||
* A personality that a user assumes when performing a specific set of operations. A role includes a
|
||||
|
@ -38,19 +37,20 @@ import com.google.common.collect.ComparisonChain;
|
|||
*
|
||||
* @author AdrianCole
|
||||
* @see <a href="http://docs.openstack.org/api/openstack-identity-service/2.0/content/Identity-Service-Concepts-e1362.html"
|
||||
* />
|
||||
/>
|
||||
*/
|
||||
public class Role implements Comparable<Role> {
|
||||
public class Role {
|
||||
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
public static Builder<?> builder() {
|
||||
return new ConcreteBuilder();
|
||||
}
|
||||
|
||||
public Builder toBuilder() {
|
||||
return builder().fromRole(this);
|
||||
public Builder<?> toBuilder() {
|
||||
return new ConcreteBuilder().fromRole(this);
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
public static abstract class Builder<T extends Builder<T>> {
|
||||
protected abstract T self();
|
||||
protected String id;
|
||||
protected String name;
|
||||
protected String description;
|
||||
|
@ -60,73 +60,80 @@ public class Role implements Comparable<Role> {
|
|||
/**
|
||||
* @see Role#getId()
|
||||
*/
|
||||
public Builder id(String id) {
|
||||
this.id = checkNotNull(id, "id");
|
||||
return this;
|
||||
public T id(String id) {
|
||||
this.id = id;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Role#getName()
|
||||
*/
|
||||
public Builder name(String name) {
|
||||
this.name = checkNotNull(name, "name");
|
||||
return this;
|
||||
public T name(String name) {
|
||||
this.name = name;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Role#getDescription()
|
||||
*/
|
||||
public Builder description(String description) {
|
||||
this.description = checkNotNull(description, "description");
|
||||
return this;
|
||||
public T description(String description) {
|
||||
this.description = description;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Role#getServiceId()
|
||||
*/
|
||||
public Builder serviceId(@Nullable String serviceId) {
|
||||
public T serviceId(String serviceId) {
|
||||
this.serviceId = serviceId;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Role#getTenantId()
|
||||
*/
|
||||
public Builder tenantId(@Nullable String tenantId) {
|
||||
public T tenantId(String tenantId) {
|
||||
this.tenantId = tenantId;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Role build() {
|
||||
return new Role(id, name, description, serviceId, tenantId);
|
||||
return new Role(id, name, description, serviceId, tenantId, null);
|
||||
}
|
||||
|
||||
public Builder fromRole(Role from) {
|
||||
return id(from.getId()).name(from.getName()).description(from.getName()).serviceId(from.getServiceId()).tenantId(from.getTenantId());
|
||||
public T fromRole(Role in) {
|
||||
return this
|
||||
.id(in.getId())
|
||||
.name(in.getName())
|
||||
.description(in.getDescription())
|
||||
.serviceId(in.getServiceId())
|
||||
.tenantId(in.getTenantId());
|
||||
}
|
||||
}
|
||||
|
||||
protected Role() {
|
||||
// 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 static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
@Override
|
||||
protected ConcreteBuilder self() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
protected String id;
|
||||
protected String name;
|
||||
protected String description;
|
||||
protected String serviceId;
|
||||
// renamed half-way through
|
||||
@Deprecated
|
||||
protected String tenantName;
|
||||
protected String tenantId;
|
||||
private final String id;
|
||||
private final String name;
|
||||
private final String description;
|
||||
private final String serviceId;
|
||||
private final String tenantId;
|
||||
|
||||
protected Role(String id, String name, @Nullable String description, @Nullable String serviceId, @Nullable String tenantId) {
|
||||
@ConstructorProperties({
|
||||
"id", "name", "description", "serviceId", "tenantId", "tenantName"
|
||||
})
|
||||
protected Role(String id, String name, @Nullable String description, @Nullable String serviceId, @Nullable String tenantId,
|
||||
@Nullable String tenantName) {
|
||||
this.id = checkNotNull(id, "id");
|
||||
this.name = checkNotNull(name, "name");
|
||||
this.description = description;
|
||||
this.serviceId = serviceId;
|
||||
this.tenantId = tenantId;
|
||||
this.tenantId = tenantId != null ? tenantId : tenantName;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -135,14 +142,14 @@ public class Role implements Comparable<Role> {
|
|||
* @return the id of the role in the current OpenStack deployment
|
||||
*/
|
||||
public String getId() {
|
||||
return id;
|
||||
return this.id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the name of the role
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
return this.name;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -150,7 +157,7 @@ public class Role implements Comparable<Role> {
|
|||
*/
|
||||
@Nullable
|
||||
public String getDescription() {
|
||||
return description;
|
||||
return this.description;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -158,7 +165,7 @@ public class Role implements Comparable<Role> {
|
|||
*/
|
||||
@Nullable
|
||||
public String getServiceId() {
|
||||
return serviceId;
|
||||
return this.serviceId;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -166,37 +173,34 @@ public class Role implements Comparable<Role> {
|
|||
*/
|
||||
@Nullable
|
||||
public String getTenantId() {
|
||||
return tenantId != null ? tenantId : tenantName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object object) {
|
||||
if (this == object) {
|
||||
return true;
|
||||
}
|
||||
if (object instanceof Role) {
|
||||
final Role other = Role.class.cast(object);
|
||||
return equal(id, other.id) && equal(name, other.name) && equal(serviceId, other.serviceId)
|
||||
&& equal(getTenantId(), other.getTenantId());
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return this.tenantId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(id, name, serviceId, getTenantId());
|
||||
return Objects.hashCode(id, name, description, serviceId, tenantId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
Role that = Role.class.cast(obj);
|
||||
return Objects.equal(this.id, that.id)
|
||||
&& Objects.equal(this.name, that.name)
|
||||
&& Objects.equal(this.description, that.description)
|
||||
&& Objects.equal(this.serviceId, that.serviceId)
|
||||
&& Objects.equal(this.tenantId, that.tenantId);
|
||||
}
|
||||
|
||||
protected ToStringHelper string() {
|
||||
return Objects.toStringHelper(this)
|
||||
.add("id", id).add("name", name).add("description", description).add("serviceId", serviceId).add("tenantId", tenantId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return toStringHelper("").add("id", id).add("name", name).add("description", description).add("serviceId", serviceId).add("tenantId", getTenantId())
|
||||
.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(Role that) {
|
||||
return ComparisonChain.start().compare(this.id, that.id).result();
|
||||
return string().toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/**
|
||||
/*
|
||||
* 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
|
||||
* 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
|
||||
*
|
||||
|
@ -18,14 +18,13 @@
|
|||
*/
|
||||
package org.jclouds.openstack.keystone.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.beans.ConstructorProperties;
|
||||
import java.util.Set;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
import com.google.common.collect.ComparisonChain;
|
||||
import com.google.common.collect.ForwardingSet;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
@ -37,19 +36,21 @@ import com.google.common.collect.ImmutableSet;
|
|||
*
|
||||
* @author Adrian Cole
|
||||
* @see <a href="http://docs.openstack.org/api/openstack-typeentity-service/2.0/content/Identity-Service-Concepts-e1362.html"
|
||||
* />
|
||||
/>
|
||||
*/
|
||||
public class Service extends ForwardingSet<Endpoint> implements Comparable<Service> {
|
||||
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
public static Builder<?> builder() {
|
||||
return new ConcreteBuilder();
|
||||
}
|
||||
|
||||
public Builder toBuilder() {
|
||||
return builder().fromService(this);
|
||||
public Builder<?> toBuilder() {
|
||||
return new ConcreteBuilder().fromService(this);
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
public static abstract class Builder<T extends Builder<T>> {
|
||||
protected abstract T self();
|
||||
|
||||
protected String type;
|
||||
protected String name;
|
||||
protected Set<Endpoint> endpoints = ImmutableSet.of();
|
||||
|
@ -57,49 +58,57 @@ public class Service extends ForwardingSet<Endpoint> implements Comparable<Servi
|
|||
/**
|
||||
* @see Service#getType()
|
||||
*/
|
||||
public Builder type(String type) {
|
||||
this.type = checkNotNull(type, "type");
|
||||
return this;
|
||||
public T type(String type) {
|
||||
this.type = type;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Service#getName()
|
||||
*/
|
||||
public Builder name(String name) {
|
||||
this.name = checkNotNull(name, "name");
|
||||
return this;
|
||||
public T name(String name) {
|
||||
this.name = name;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Service#getEndpoints()
|
||||
*/
|
||||
public Builder endpoints(Endpoint... endpoints) {
|
||||
return endpoints(ImmutableSet.copyOf(checkNotNull(endpoints, "endpoints")));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Service#getEndpoints()
|
||||
*/
|
||||
public Builder endpoints(Set<Endpoint> endpoints) {
|
||||
public T endpoints(Set<Endpoint> endpoints) {
|
||||
this.endpoints = ImmutableSet.copyOf(checkNotNull(endpoints, "endpoints"));
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public T endpoints(Endpoint... in) {
|
||||
return endpoints(ImmutableSet.copyOf(in));
|
||||
}
|
||||
|
||||
public Service build() {
|
||||
return new Service(type, name, endpoints);
|
||||
}
|
||||
|
||||
public Builder fromService(Service from) {
|
||||
return type(from.getType()).name(from.getName()).endpoints(from.getEndpoints());
|
||||
public T fromService(Service in) {
|
||||
return this
|
||||
.type(in.getType())
|
||||
.name(in.getName())
|
||||
.endpoints(in.getEndpoints());
|
||||
}
|
||||
}
|
||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
@Override
|
||||
protected ConcreteBuilder self() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
protected final String type;
|
||||
protected final String name;
|
||||
protected final Set<Endpoint> endpoints;
|
||||
private final String type;
|
||||
private final String name;
|
||||
private final Set<Endpoint> endpoints;
|
||||
|
||||
@ConstructorProperties({ "type", "name", "endpoints" })
|
||||
public Service(String type, String name, Set<Endpoint> endpoints) {
|
||||
@ConstructorProperties({
|
||||
"type", "name", "endpoints"
|
||||
})
|
||||
protected Service(String type, String name, Set<Endpoint> endpoints) {
|
||||
this.type = checkNotNull(type, "type");
|
||||
this.name = checkNotNull(name, "name");
|
||||
this.endpoints = ImmutableSet.copyOf(checkNotNull(endpoints, "endpoints"));
|
||||
|
@ -111,34 +120,21 @@ public class Service extends ForwardingSet<Endpoint> implements Comparable<Servi
|
|||
* @return the type of the service in the current OpenStack deployment
|
||||
*/
|
||||
public String getType() {
|
||||
return type;
|
||||
return this.type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the name of the service
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
return this.name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the endpoints assigned to the service
|
||||
*/
|
||||
public Set<Endpoint> getEndpoints() {
|
||||
return endpoints;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object object) {
|
||||
if (this == object) {
|
||||
return true;
|
||||
}
|
||||
if (object instanceof Service) {
|
||||
final Service other = Service.class.cast(object);
|
||||
return equal(type, other.type) && equal(name, other.name) && equal(endpoints, other.endpoints);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return this.endpoints;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -146,9 +142,24 @@ public class Service extends ForwardingSet<Endpoint> implements Comparable<Servi
|
|||
return Objects.hashCode(type, name, endpoints);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
Service that = Service.class.cast(obj);
|
||||
return Objects.equal(this.type, that.type)
|
||||
&& Objects.equal(this.name, that.name)
|
||||
&& Objects.equal(this.endpoints, that.endpoints);
|
||||
}
|
||||
|
||||
protected ToStringHelper string() {
|
||||
return Objects.toStringHelper(this)
|
||||
.add("type", type).add("name", name).add("endpoints", endpoints);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return toStringHelper("").add("type", type).add("name", name).add("endpoints", endpoints).toString();
|
||||
return string().toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -163,5 +174,4 @@ public class Service extends ForwardingSet<Endpoint> implements Comparable<Servi
|
|||
protected Set<Endpoint> delegate() {
|
||||
return endpoints;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
/*
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
|
@ -16,16 +16,16 @@
|
|||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.jclouds.openstack.keystone.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.beans.ConstructorProperties;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
|
||||
/**
|
||||
* A container used to group or isolate resources and/or identity objects. Depending on the service
|
||||
|
@ -33,19 +33,21 @@ import com.google.common.base.Objects;
|
|||
*
|
||||
* @author Adrian Cole
|
||||
* @see <a href="http://docs.openstack.org/api/openstack-identity-service/2.0/content/Identity-Service-Concepts-e1362.html"
|
||||
* />
|
||||
/>
|
||||
*/
|
||||
public class Tenant implements Comparable<Tenant> {
|
||||
public class Tenant {
|
||||
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
public static Builder<?> builder() {
|
||||
return new ConcreteBuilder();
|
||||
}
|
||||
|
||||
public Builder toBuilder() {
|
||||
return builder().fromTenant(this);
|
||||
public Builder<?> toBuilder() {
|
||||
return new ConcreteBuilder().fromTenant(this);
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
public static abstract class Builder<T extends Builder<T>> {
|
||||
protected abstract T self();
|
||||
|
||||
protected String id;
|
||||
protected String name;
|
||||
protected String description;
|
||||
|
@ -53,47 +55,54 @@ public class Tenant implements Comparable<Tenant> {
|
|||
/**
|
||||
* @see Tenant#getId()
|
||||
*/
|
||||
public Builder id(String id) {
|
||||
this.id = checkNotNull(id, "id");
|
||||
return this;
|
||||
public T id(String id) {
|
||||
this.id = id;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Tenant#getName()
|
||||
*/
|
||||
public Builder name(String name) {
|
||||
this.name = checkNotNull(name, "name");
|
||||
return this;
|
||||
public T name(String name) {
|
||||
this.name = name;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Tenant#getDescription()
|
||||
*/
|
||||
public Builder description(String description) {
|
||||
public T description(String description) {
|
||||
this.description = description;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Tenant build() {
|
||||
return new Tenant(id, name, description);
|
||||
}
|
||||
|
||||
public Builder fromTenant(Tenant from) {
|
||||
return id(from.getId()).name(from.getName());
|
||||
public T fromTenant(Tenant in) {
|
||||
return this
|
||||
.id(in.getId())
|
||||
.name(in.getName())
|
||||
.description(in.getDescription());
|
||||
}
|
||||
}
|
||||
|
||||
protected Tenant() {
|
||||
// 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 static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
@Override
|
||||
protected ConcreteBuilder self() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
protected String id;
|
||||
protected String name;
|
||||
protected String description;
|
||||
private final String id;
|
||||
private final String name;
|
||||
private final String description;
|
||||
|
||||
protected Tenant(String id, String name, String description) {
|
||||
@ConstructorProperties({
|
||||
"id", "name", "description"
|
||||
})
|
||||
protected Tenant(String id, String name, @Nullable String description) {
|
||||
this.id = checkNotNull(id, "id");
|
||||
this.name = checkNotNull(name, "name");
|
||||
this.description = description;
|
||||
|
@ -105,14 +114,14 @@ public class Tenant implements Comparable<Tenant> {
|
|||
* @return the id of the tenant in the current OpenStack deployment
|
||||
*/
|
||||
public String getId() {
|
||||
return id;
|
||||
return this.id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the name of the tenant
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
return this.name;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -120,21 +129,7 @@ public class Tenant implements Comparable<Tenant> {
|
|||
*/
|
||||
@Nullable
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object object) {
|
||||
if (this == object) {
|
||||
return true;
|
||||
}
|
||||
if (object instanceof Tenant) {
|
||||
final Tenant other = Tenant.class.cast(object);
|
||||
return equal(id, other.id) && equal(name, other.name)
|
||||
&& equal(description, other.description);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return this.description;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -143,17 +138,23 @@ public class Tenant implements Comparable<Tenant> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return toStringHelper("").add("id", id).add("name", name).add("description", description).toString();
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
Tenant that = Tenant.class.cast(obj);
|
||||
return Objects.equal(this.id, that.id)
|
||||
&& Objects.equal(this.name, that.name)
|
||||
&& Objects.equal(this.description, that.description);
|
||||
}
|
||||
|
||||
protected ToStringHelper string() {
|
||||
return Objects.toStringHelper(this)
|
||||
.add("id", id).add("name", name).add("description", description);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(Tenant that) {
|
||||
if (that == null)
|
||||
return 1;
|
||||
if (this == that)
|
||||
return 0;
|
||||
return this.id.compareTo(that.id);
|
||||
public String toString() {
|
||||
return string().toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/**
|
||||
/*
|
||||
* 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, Expires 2.0 (the
|
||||
* 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
|
||||
*
|
||||
|
@ -16,16 +16,15 @@
|
|||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.jclouds.openstack.keystone.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.beans.ConstructorProperties;
|
||||
import java.util.Date;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
|
||||
/**
|
||||
* A token is an arbitrary bit of text that is used to access resources. Each token has a scope
|
||||
|
@ -38,19 +37,21 @@ import com.google.common.base.Objects;
|
|||
*
|
||||
* @author Adrian Cole
|
||||
* @see <a href="http://docs.openstack.org/api/openstack-identity-service/2.0/content/Identity-Service-Concepts-e1362.html"
|
||||
* />
|
||||
/>
|
||||
*/
|
||||
public class Token implements Comparable<Token> {
|
||||
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
public static Builder<?> builder() {
|
||||
return new ConcreteBuilder();
|
||||
}
|
||||
|
||||
public Builder toBuilder() {
|
||||
return builder().fromToken(this);
|
||||
public Builder<?> toBuilder() {
|
||||
return new ConcreteBuilder().fromToken(this);
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
public static abstract class Builder<T extends Builder<T>> {
|
||||
protected abstract T self();
|
||||
|
||||
protected String id;
|
||||
protected Date expires;
|
||||
protected Tenant tenant;
|
||||
|
@ -58,47 +59,54 @@ public class Token implements Comparable<Token> {
|
|||
/**
|
||||
* @see Token#getId()
|
||||
*/
|
||||
public Builder id(String id) {
|
||||
this.id = checkNotNull(id, "id");
|
||||
return this;
|
||||
public T id(String id) {
|
||||
this.id = id;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Token#getExpires()
|
||||
*/
|
||||
public Builder expires(Date expires) {
|
||||
this.expires = checkNotNull(expires, "expires");
|
||||
return this;
|
||||
public T expires(Date expires) {
|
||||
this.expires = expires;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Token#getTenant()
|
||||
*/
|
||||
public Builder tenant(Tenant tenant) {
|
||||
this.tenant = checkNotNull(tenant, "tenant");
|
||||
return this;
|
||||
public T tenant(Tenant tenant) {
|
||||
this.tenant = tenant;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Token build() {
|
||||
return new Token(id, expires, tenant);
|
||||
}
|
||||
|
||||
public Builder fromToken(Token from) {
|
||||
return id(from.getId()).expires(from.getExpires()).tenant(from.getTenant());
|
||||
public T fromToken(Token in) {
|
||||
return this
|
||||
.id(in.getId())
|
||||
.expires(in.getExpires())
|
||||
.tenant(in.getTenant());
|
||||
}
|
||||
}
|
||||
|
||||
protected Token() {
|
||||
// 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 static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
@Override
|
||||
protected ConcreteBuilder self() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
protected String id;
|
||||
protected Date expires;
|
||||
protected Tenant tenant;
|
||||
private final String id;
|
||||
private final Date expires;
|
||||
private final Tenant tenant;
|
||||
|
||||
public Token(String id, Date expires, Tenant tenant) {
|
||||
@ConstructorProperties({
|
||||
"id", "expires", "tenant"
|
||||
})
|
||||
protected Token(String id, Date expires, Tenant tenant) {
|
||||
this.id = checkNotNull(id, "id");
|
||||
this.expires = checkNotNull(expires, "expires");
|
||||
this.tenant = checkNotNull(tenant, "tenant");
|
||||
|
@ -110,34 +118,21 @@ public class Token implements Comparable<Token> {
|
|||
* @return the id of the token in the current OpenStack deployment
|
||||
*/
|
||||
public String getId() {
|
||||
return id;
|
||||
return this.id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the expires of the token
|
||||
*/
|
||||
public Date getExpires() {
|
||||
return expires;
|
||||
return this.expires;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the tenant assigned to the token
|
||||
*/
|
||||
public Tenant getTenant() {
|
||||
return tenant;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object object) {
|
||||
if (this == object) {
|
||||
return true;
|
||||
}
|
||||
if (object instanceof Token) {
|
||||
final Token other = Token.class.cast(object);
|
||||
return equal(id, other.id) && equal(expires, other.expires) && equal(tenant, other.tenant);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return this.tenant;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -145,9 +140,24 @@ public class Token implements Comparable<Token> {
|
|||
return Objects.hashCode(id, expires, tenant);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
Token that = Token.class.cast(obj);
|
||||
return Objects.equal(this.id, that.id)
|
||||
&& Objects.equal(this.expires, that.expires)
|
||||
&& Objects.equal(this.tenant, that.tenant);
|
||||
}
|
||||
|
||||
protected ToStringHelper string() {
|
||||
return Objects.toStringHelper(this)
|
||||
.add("id", id).add("expires", expires).add("tenant", tenant);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return toStringHelper("").add("id", id).add("expires", expires).add("tenant", tenant).toString();
|
||||
return string().toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -158,5 +168,4 @@ public class Token implements Comparable<Token> {
|
|||
return 0;
|
||||
return this.id.compareTo(that.id);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/**
|
||||
/*
|
||||
* 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
|
||||
* 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
|
||||
*
|
||||
|
@ -16,16 +16,17 @@
|
|||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.jclouds.openstack.keystone.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.beans.ConstructorProperties;
|
||||
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;
|
||||
|
||||
/**
|
||||
|
@ -39,17 +40,19 @@ import com.google.common.collect.ImmutableSet;
|
|||
* @see <a href="http://docs.openstack.org/api/openstack-identity-service/2.0/content/Identity-Service-Concepts-e1362.html"
|
||||
* />
|
||||
*/
|
||||
public class User implements Comparable<User> {
|
||||
public class User {
|
||||
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
public static Builder<?> builder() {
|
||||
return new ConcreteBuilder();
|
||||
}
|
||||
|
||||
public Builder toBuilder() {
|
||||
return builder().fromUser(this);
|
||||
public Builder<?> toBuilder() {
|
||||
return new ConcreteBuilder().fromUser(this);
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
public static abstract class Builder<T extends Builder<T>> {
|
||||
protected abstract T self();
|
||||
|
||||
protected String id;
|
||||
protected String name;
|
||||
protected Set<Role> roles = ImmutableSet.of();
|
||||
|
@ -57,57 +60,61 @@ public class User implements Comparable<User> {
|
|||
/**
|
||||
* @see User#getId()
|
||||
*/
|
||||
public Builder id(String id) {
|
||||
this.id = checkNotNull(id, "id");
|
||||
return this;
|
||||
public T id(String id) {
|
||||
this.id = id;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see User#getName()
|
||||
*/
|
||||
public Builder name(String name) {
|
||||
this.name = checkNotNull(name, "name");
|
||||
return this;
|
||||
public T name(String name) {
|
||||
this.name = name;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see User#getRoles()
|
||||
*/
|
||||
public Builder roles(Role... roles) {
|
||||
return roles(ImmutableSet.copyOf(checkNotNull(roles, "roles")));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see User#getRoles()
|
||||
*/
|
||||
public Builder roles(Set<Role> roles) {
|
||||
public T roles(Set<Role> roles) {
|
||||
this.roles = ImmutableSet.copyOf(checkNotNull(roles, "roles"));
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public T roles(Role... in) {
|
||||
return roles(ImmutableSet.copyOf(in));
|
||||
}
|
||||
|
||||
public User build() {
|
||||
return new User(id, name, roles);
|
||||
}
|
||||
|
||||
public Builder fromUser(User from) {
|
||||
return id(from.getId()).name(from.getName()).roles(from.getRoles());
|
||||
public T fromUser(User in) {
|
||||
return this
|
||||
.id(in.getId())
|
||||
.name(in.getName())
|
||||
.roles(in.getRoles());
|
||||
}
|
||||
}
|
||||
|
||||
protected User() {
|
||||
// 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 static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
@Override
|
||||
protected ConcreteBuilder self() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
protected String id;
|
||||
protected String name;
|
||||
protected Set<Role> roles = ImmutableSet.of();
|
||||
private final String id;
|
||||
private final String name;
|
||||
private final Set<Role> roles;
|
||||
|
||||
protected User(String id, String name, Set<Role> roles) {
|
||||
@ConstructorProperties({
|
||||
"id", "name", "roles"
|
||||
})
|
||||
protected User(String id, String name, @Nullable Set<Role> roles) {
|
||||
this.id = checkNotNull(id, "id");
|
||||
this.name = checkNotNull(name, "name");
|
||||
this.roles = ImmutableSet.copyOf(checkNotNull(roles, "roles"));
|
||||
this.roles = roles == null ? ImmutableSet.<Role>of() : ImmutableSet.copyOf(checkNotNull(roles, "roles"));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -116,34 +123,21 @@ public class User implements Comparable<User> {
|
|||
* @return the id of the user in the current OpenStack deployment
|
||||
*/
|
||||
public String getId() {
|
||||
return id;
|
||||
return this.id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the name of the user
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
return this.name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the roles assigned to the user
|
||||
*/
|
||||
public Set<Role> getRoles() {
|
||||
return roles;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object object) {
|
||||
if (this == object) {
|
||||
return true;
|
||||
}
|
||||
if (object instanceof User) {
|
||||
final User other = User.class.cast(object);
|
||||
return equal(id, other.id) && equal(name, other.name) && equal(roles, other.roles);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return this.roles;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -152,17 +146,23 @@ public class User implements Comparable<User> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return toStringHelper("").add("id", id).add("name", name).add("roles", roles).toString();
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
User that = User.class.cast(obj);
|
||||
return Objects.equal(this.id, that.id)
|
||||
&& Objects.equal(this.name, that.name)
|
||||
&& Objects.equal(this.roles, that.roles);
|
||||
}
|
||||
|
||||
protected ToStringHelper string() {
|
||||
return Objects.toStringHelper(this)
|
||||
.add("id", id).add("name", name).add("roles", roles);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(User that) {
|
||||
if (that == null)
|
||||
return 1;
|
||||
if (this == that)
|
||||
return 0;
|
||||
return this.id.compareTo(that.id);
|
||||
public String toString() {
|
||||
return string().toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/**
|
||||
/*
|
||||
* 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
|
||||
* 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
|
||||
*
|
||||
|
@ -16,19 +16,19 @@
|
|||
* 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.beans.ConstructorProperties;
|
||||
import java.net.URI;
|
||||
|
||||
import javax.inject.Named;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
|
||||
/**
|
||||
* For convenience, resources contain links to themselves. This allows a client to easily obtain a
|
||||
|
@ -36,7 +36,7 @@ import com.google.gson.annotations.SerializedName;
|
|||
*
|
||||
* @author AdrianCole
|
||||
* @see <a href= "http://docs.openstack.org/api/openstack-compute/1.1/content/LinksReferences.html"
|
||||
* />
|
||||
/>
|
||||
*/
|
||||
public class Link {
|
||||
/**
|
||||
|
@ -77,7 +77,6 @@ public class Link {
|
|||
return UNRECOGNIZED;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static Link create(Relation relation, URI href) {
|
||||
|
@ -88,64 +87,73 @@ public class Link {
|
|||
return new Link(relation, type, href);
|
||||
}
|
||||
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
public static Builder<?> builder() {
|
||||
return new ConcreteBuilder();
|
||||
}
|
||||
|
||||
public Builder toBuilder() {
|
||||
return builder().fromLink(this);
|
||||
public Builder<?> toBuilder() {
|
||||
return new ConcreteBuilder().fromLink(this);
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
protected Relation relation;
|
||||
public static abstract class Builder<T extends Builder<T>> {
|
||||
protected abstract T self();
|
||||
|
||||
protected Link.Relation relation;
|
||||
protected String type;
|
||||
protected URI href;
|
||||
|
||||
/**
|
||||
* @see Link#getRelation()
|
||||
*/
|
||||
public Builder relation(Relation relation) {
|
||||
this.relation = checkNotNull(relation, "relation");
|
||||
return this;
|
||||
public T relation(Link.Relation relation) {
|
||||
this.relation = relation;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Link#getType()
|
||||
*/
|
||||
public Builder type(String type) {
|
||||
public T type(String type) {
|
||||
this.type = type;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Link#getHref()
|
||||
*/
|
||||
public Builder href(URI href) {
|
||||
this.href = checkNotNull(href, "href");
|
||||
return this;
|
||||
public T href(URI href) {
|
||||
this.href = href;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Link build(){
|
||||
public Link build() {
|
||||
return new Link(relation, type, href);
|
||||
}
|
||||
|
||||
public Builder fromLink(Link from) {
|
||||
return relation(from.getRelation()).type(from.getType()).href(from.getHref());
|
||||
public T fromLink(Link in) {
|
||||
return this
|
||||
.relation(in.getRelation())
|
||||
.type(in.getType())
|
||||
.href(in.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
|
||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
@Override
|
||||
protected ConcreteBuilder self() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@SerializedName("rel")
|
||||
protected Relation relation;
|
||||
protected String type;
|
||||
protected URI href;
|
||||
@Named("rel")
|
||||
private final Link.Relation relation;
|
||||
private final String type;
|
||||
private final URI href;
|
||||
|
||||
protected Link(Relation relation, @Nullable String type, URI href) {
|
||||
@ConstructorProperties({
|
||||
"rel", "type", "href"
|
||||
})
|
||||
protected Link(Link.Relation relation, @Nullable String type, URI href) {
|
||||
this.relation = checkNotNull(relation, "relation");
|
||||
this.type = type;
|
||||
this.href = checkNotNull(href, "href");
|
||||
|
@ -162,8 +170,8 @@ public class Link {
|
|||
*
|
||||
* @return the relation of the resource in the current OpenStack deployment
|
||||
*/
|
||||
public Relation getRelation() {
|
||||
return relation;
|
||||
public Link.Relation getRelation() {
|
||||
return this.relation;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -171,27 +179,14 @@ public class Link {
|
|||
*/
|
||||
@Nullable
|
||||
public String getType() {
|
||||
return type;
|
||||
return this.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;
|
||||
}
|
||||
return this.href;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -199,9 +194,24 @@ public class Link {
|
|||
return Objects.hashCode(relation, type, href);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
Link that = Link.class.cast(obj);
|
||||
return Objects.equal(this.relation, that.relation)
|
||||
&& Objects.equal(this.type, that.type)
|
||||
&& Objects.equal(this.href, that.href);
|
||||
}
|
||||
|
||||
protected ToStringHelper string() {
|
||||
return Objects.toStringHelper(this)
|
||||
.add("relation", relation).add("type", type).add("href", href);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return toStringHelper("").add("relation", relation).add("type", type).add("href", href).toString();
|
||||
return string().toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/**
|
||||
/*
|
||||
* 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
|
||||
* 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
|
||||
*
|
||||
|
@ -16,12 +16,11 @@
|
|||
* 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.beans.ConstructorProperties;
|
||||
import java.util.Set;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
|
@ -35,8 +34,8 @@ import com.google.common.collect.ImmutableSet;
|
|||
*
|
||||
* @author AdrianCole
|
||||
* @see <a href=
|
||||
* "http://docs.openstack.org/api/openstack-compute/1.1/content/Paginated_Collections-d1e664.html"
|
||||
* />
|
||||
"http://docs.openstack.org/api/openstack-compute/1.1/content/Paginated_Collections-d1e664.html"
|
||||
/>
|
||||
*/
|
||||
public class Resource implements Comparable<Resource> {
|
||||
|
||||
|
@ -51,9 +50,9 @@ public class Resource implements Comparable<Resource> {
|
|||
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();
|
||||
protected String id;
|
||||
protected String name;
|
||||
protected Set<Link> links = ImmutableSet.of();
|
||||
|
||||
/**
|
||||
* @see Resource#getId()
|
||||
|
@ -71,31 +70,27 @@ public class Resource implements Comparable<Resource> {
|
|||
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;
|
||||
this.links = ImmutableSet.copyOf(checkNotNull(links, "links"));
|
||||
return self();
|
||||
}
|
||||
|
||||
public T links(Link... in) {
|
||||
return links(ImmutableSet.copyOf(in));
|
||||
}
|
||||
|
||||
public Resource build() {
|
||||
return new Resource(this);
|
||||
return new Resource(id, name, links);
|
||||
}
|
||||
|
||||
public T fromResource(Resource in) {
|
||||
return this
|
||||
.id(in.getId())
|
||||
.name(in.getName())
|
||||
.links(in.getLinks())
|
||||
;
|
||||
.links(in.getLinks());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -106,20 +101,28 @@ public class Resource implements Comparable<Resource> {
|
|||
}
|
||||
}
|
||||
|
||||
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 final String id;
|
||||
private final String name;
|
||||
private final Set<Link> links;
|
||||
|
||||
@ConstructorProperties({
|
||||
"id", "name", "links"
|
||||
})
|
||||
protected Resource(String id, @Nullable String name, Set<Link> links) {
|
||||
this.id = checkNotNull(id, "id");
|
||||
this.name = name;
|
||||
this.links = ImmutableSet.copyOf(checkNotNull(links, "links"));
|
||||
}
|
||||
|
||||
private String id;
|
||||
private String name;
|
||||
private Set<Link> links = ImmutableSet.of();
|
||||
|
||||
// leaving till beans in other openstack projects are updated
|
||||
@Deprecated
|
||||
protected Resource(Builder<?> builder) {
|
||||
this.id = checkNotNull(builder.id, "id");
|
||||
this.name = builder.name;
|
||||
this.links = ImmutableSet.copyOf(checkNotNull(builder.links, "links"));
|
||||
this(builder.id, builder.name, builder.links);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
protected Resource() {
|
||||
id = null; name = null; links = ImmutableSet.of();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -129,7 +132,7 @@ public class Resource implements Comparable<Resource> {
|
|||
* @return the id of the resource in the current OpenStack deployment
|
||||
*/
|
||||
public String getId() {
|
||||
return id;
|
||||
return this.id;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -137,14 +140,14 @@ public class Resource implements Comparable<Resource> {
|
|||
*/
|
||||
@Nullable
|
||||
public String getName() {
|
||||
return name;
|
||||
return this.name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the links of the id address allocated to the new server
|
||||
*/
|
||||
public Set<Link> getLinks() {
|
||||
return Collections.unmodifiableSet(this.links);
|
||||
return this.links;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -157,22 +160,21 @@ public class Resource implements Comparable<Resource> {
|
|||
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())
|
||||
return Objects.equal(this.id, that.id)
|
||||
&& 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);
|
||||
return Objects.toStringHelper(this)
|
||||
.add("id", id).add("name", name).add("links", links);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return string().toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(Resource that) {
|
||||
if (that == null)
|
||||
|
|
|
@ -18,19 +18,20 @@
|
|||
*/
|
||||
package org.jclouds.openstack.nova.v2_0.config;
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
import org.jclouds.json.config.GsonModule;
|
||||
import org.jclouds.json.config.GsonModule.DateAdapter;
|
||||
import org.jclouds.openstack.nova.v2_0.domain.HostResourceUsage;
|
||||
import org.jclouds.openstack.nova.v2_0.domain.Server;
|
||||
import org.jclouds.openstack.nova.v2_0.domain.ServerExtendedAttributes;
|
||||
import org.jclouds.openstack.nova.v2_0.domain.ServerExtendedStatus;
|
||||
import org.jclouds.openstack.nova.v2_0.domain.ServerWithSecurityGroups;
|
||||
import org.jclouds.openstack.nova.v2_0.domain.*;
|
||||
import org.jclouds.openstack.v2_0.domain.Link;
|
||||
import org.jclouds.openstack.v2_0.domain.Resource;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
@ -57,7 +58,8 @@ public class NovaParserModule extends AbstractModule {
|
|||
return ImmutableMap.<Type, Object>of(
|
||||
HostResourceUsage.class, new HostResourceUsageAdapter(),
|
||||
ServerWithSecurityGroups.class, new ServerWithSecurityGroupsAdapter(),
|
||||
Server.class, new ServerAdapter()
|
||||
Server.class, new ServerAdapter(),
|
||||
SecurityGroupRule.class, new SecurityGroupRuleAdapter()
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -85,9 +87,14 @@ public class NovaParserModule extends AbstractModule {
|
|||
private static class HostResourceUsageView {
|
||||
protected HostResourceUsageInternal resource;
|
||||
}
|
||||
|
||||
private static class HostResourceUsageInternal extends HostResourceUsage {
|
||||
protected HostResourceUsageInternal(Builder<?> builder) {
|
||||
super(builder);
|
||||
|
||||
@ConstructorProperties({
|
||||
"host", "project", "memory_mb", "cpu", "disk_gb"
|
||||
})
|
||||
protected HostResourceUsageInternal(String host, @Nullable String project, int memoryMb, int cpu, int diskGb) {
|
||||
super(host, project, memoryMb, cpu, diskGb);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -124,7 +131,7 @@ public class NovaParserModule extends AbstractModule {
|
|||
}
|
||||
ServerExtendedAttributes extraAttributes = context.deserialize(jsonElement, ServerExtendedAttributes.class);
|
||||
if (!Objects.equal(extraAttributes, ServerExtendedAttributes.builder().build())) {
|
||||
result.extraAttributes(extraAttributes);
|
||||
result.extendedAttributes(extraAttributes);
|
||||
}
|
||||
return result.build();
|
||||
}
|
||||
|
@ -134,9 +141,47 @@ public class NovaParserModule extends AbstractModule {
|
|||
}
|
||||
|
||||
private static class ServerInternal extends Server {
|
||||
protected ServerInternal() {
|
||||
@ConstructorProperties({
|
||||
"id", "name", "links", "uuid", "tenant_id", "user_id", "updated", "created", "hostId", "accessIPv4", "accessIPv6", "status", "image", "flavor", "key_name", "config_drive", "addresses", "metadata", "extendedStatus", "extendedAttributes", "OS-DCF:diskConfig"
|
||||
})
|
||||
protected ServerInternal(String id, @Nullable String name, java.util.Set<Link> links, @Nullable String uuid, String tenantId,
|
||||
String userId, Date updated, Date created, @Nullable String hostId, @Nullable String accessIPv4,
|
||||
@Nullable String accessIPv6, Server.Status status, Resource image, Resource flavor, @Nullable String keyName,
|
||||
@Nullable String configDrive, Map<String, Set<Address>> addresses, Map<String, String> metadata,
|
||||
@Nullable ServerExtendedStatus extendedStatus, @Nullable ServerExtendedAttributes extendedAttributes, @Nullable String diskConfig) {
|
||||
super(id, name, links, uuid, tenantId, userId, updated, created, hostId, accessIPv4, accessIPv6, status, image, flavor, keyName, configDrive, addresses, metadata, extendedStatus, extendedAttributes, diskConfig);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* trying to cope with group { } to signify no group! */
|
||||
@Singleton
|
||||
public static class SecurityGroupRuleAdapter implements JsonDeserializer<SecurityGroupRule> {
|
||||
@Override
|
||||
public SecurityGroupRule deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext context)
|
||||
throws JsonParseException {
|
||||
SecurityGroupRule ruleBase = apply((SecurityGroupRuleInternal) context.deserialize(jsonElement, SecurityGroupRuleInternal.class));
|
||||
if (jsonElement.getAsJsonObject().has("group")) {
|
||||
try {
|
||||
TenantIdAndName group = context.deserialize(jsonElement.getAsJsonObject().getAsJsonObject("group"), TenantIdAndName.class);
|
||||
ruleBase = ruleBase.toBuilder().group(group).build();
|
||||
} catch (NullPointerException ex) {
|
||||
}
|
||||
}
|
||||
return ruleBase;
|
||||
}
|
||||
|
||||
public SecurityGroupRule apply(SecurityGroupRuleInternal in) {
|
||||
return in.toBuilder().build();
|
||||
}
|
||||
|
||||
private static class SecurityGroupRuleInternal extends SecurityGroupRule {
|
||||
@ConstructorProperties({
|
||||
"ip_protocol", "from_port", "to_port", "id", "parent_group_id", "ip_range"
|
||||
})
|
||||
protected SecurityGroupRuleInternal(IpProtocol ipProtocol, int fromPort, int toPort, String id, String parentGroupId, @Nullable Cidr ipRange) {
|
||||
super(ipProtocol, fromPort, toPort, id, null, parentGroupId, ipRange);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
/*
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
|
@ -16,27 +16,28 @@
|
|||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.jclouds.openstack.nova.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.beans.ConstructorProperties;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
|
||||
/**
|
||||
* IP address
|
||||
*
|
||||
* @author AdrianCole
|
||||
*/
|
||||
*/
|
||||
public class Address {
|
||||
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
public static Builder<?> builder() {
|
||||
return new ConcreteBuilder();
|
||||
}
|
||||
|
||||
public Builder toBuilder() {
|
||||
return builder().fromAddress(this);
|
||||
public Builder<?> toBuilder() {
|
||||
return new ConcreteBuilder().fromAddress(this);
|
||||
}
|
||||
|
||||
public static Address createV4(String addr) {
|
||||
|
@ -47,46 +48,54 @@ public class Address {
|
|||
return builder().version(6).addr(addr).build();
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
public static abstract class Builder<T extends Builder<T>> {
|
||||
protected abstract T self();
|
||||
|
||||
protected String addr;
|
||||
protected int version;
|
||||
|
||||
/**
|
||||
* @see Address#getVersion()
|
||||
* @see Address#getAddr()
|
||||
*/
|
||||
protected Builder version(int version) {
|
||||
this.version = version;
|
||||
return this;
|
||||
public T addr(String addr) {
|
||||
this.addr = addr;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Address#getAddr()
|
||||
* @see Address#getVersion()
|
||||
*/
|
||||
public Builder addr(String addr) {
|
||||
this.addr = addr;
|
||||
return this;
|
||||
public T version(int version) {
|
||||
this.version = version;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Address build() {
|
||||
return new Address(addr, version);
|
||||
}
|
||||
|
||||
public Builder fromAddress(Address from) {
|
||||
return addr(from.getAddr()).version(from.getVersion());
|
||||
public T fromAddress(Address in) {
|
||||
return this
|
||||
.addr(in.getAddr())
|
||||
.version(in.getVersion());
|
||||
}
|
||||
}
|
||||
|
||||
protected Address() {
|
||||
// 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 static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
@Override
|
||||
protected ConcreteBuilder self() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
protected String addr;
|
||||
protected int version;
|
||||
private final String addr;
|
||||
private final int version;
|
||||
|
||||
public Address(String addr, int version) {
|
||||
this.addr = addr;
|
||||
@ConstructorProperties({
|
||||
"addr", "version"
|
||||
})
|
||||
protected Address(String addr, int version) {
|
||||
this.addr = checkNotNull(addr, "addr");
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
|
@ -94,27 +103,14 @@ public class Address {
|
|||
* @return the ip address
|
||||
*/
|
||||
public String getAddr() {
|
||||
return addr;
|
||||
return this.addr;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the IP version, ex. 4
|
||||
*/
|
||||
public int getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object object) {
|
||||
if (this == object) {
|
||||
return true;
|
||||
}
|
||||
if (object instanceof Address) {
|
||||
final Address other = Address.class.cast(object);
|
||||
return equal(addr, other.addr) && equal(version, other.version);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return this.version;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -122,9 +118,23 @@ public class Address {
|
|||
return Objects.hashCode(addr, version);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
Address that = Address.class.cast(obj);
|
||||
return Objects.equal(this.addr, that.addr)
|
||||
&& Objects.equal(this.version, that.version);
|
||||
}
|
||||
|
||||
protected ToStringHelper string() {
|
||||
return Objects.toStringHelper(this)
|
||||
.add("addr", addr).add("version", version);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return toStringHelper("").add("addr", addr).add("version", version).toString();
|
||||
return string().toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/**
|
||||
/*
|
||||
* 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
|
||||
* 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
|
||||
*
|
||||
|
@ -18,12 +18,19 @@
|
|||
*/
|
||||
package org.jclouds.openstack.nova.v2_0.domain;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
import java.net.URI;
|
||||
import java.util.Date;
|
||||
import java.util.Set;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
import org.jclouds.openstack.v2_0.domain.Link;
|
||||
import org.jclouds.openstack.v2_0.domain.Resource;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
|
||||
/**
|
||||
* The OpenStack Compute API is extensible. Extensions serve two purposes: They
|
||||
|
@ -33,10 +40,11 @@ import com.google.common.base.Objects;
|
|||
*
|
||||
* @author Adrian Cole
|
||||
* @see <a href=
|
||||
* "http://docs.openstack.org/api/openstack-compute/2/content/Extensions-d1e1444.html"
|
||||
* />
|
||||
*/
|
||||
"http://docs.openstack.org/api/openstack-compute/2/content/Extensions-d1e1444.html"
|
||||
/>
|
||||
*/
|
||||
public class Extension extends Resource {
|
||||
|
||||
public static Builder<?> builder() {
|
||||
return new ConcreteBuilder();
|
||||
}
|
||||
|
@ -46,10 +54,10 @@ public class Extension extends Resource {
|
|||
}
|
||||
|
||||
public static abstract class Builder<T extends Builder<T>> extends Resource.Builder<T> {
|
||||
private URI namespace;
|
||||
private String alias;
|
||||
private Date updated;
|
||||
private String description;
|
||||
protected URI namespace;
|
||||
protected String alias;
|
||||
protected Date updated;
|
||||
protected String description;
|
||||
|
||||
/**
|
||||
* @see Extension#getNamespace()
|
||||
|
@ -63,11 +71,18 @@ public class Extension extends Resource {
|
|||
* @see Extension#getAlias()
|
||||
*/
|
||||
public T alias(String alias) {
|
||||
id(alias);
|
||||
this.alias = alias;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Extension#getAlias()
|
||||
*/
|
||||
@Override
|
||||
public T id(String id) {
|
||||
return alias(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Extension#getUpdated()
|
||||
*/
|
||||
|
@ -85,18 +100,16 @@ public class Extension extends Resource {
|
|||
}
|
||||
|
||||
public Extension build() {
|
||||
return new Extension(this);
|
||||
return new Extension(name, links, namespace, alias, updated, description);
|
||||
}
|
||||
|
||||
public T fromExtension(Extension in) {
|
||||
return super.fromResource(in)
|
||||
.namespace(in.getNamespace())
|
||||
.alias(in.getAlias())
|
||||
.updated(in.getUpdated())
|
||||
.description(in.getDescription())
|
||||
;
|
||||
.namespace(in.getNamespace())
|
||||
.alias(in.getAlias())
|
||||
.updated(in.getUpdated())
|
||||
.description(in.getDescription());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
|
@ -106,38 +119,31 @@ public class Extension extends Resource {
|
|||
}
|
||||
}
|
||||
|
||||
protected Extension() {
|
||||
// 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 final URI namespace;
|
||||
private final String alias;
|
||||
private final Date updated;
|
||||
private final String description;
|
||||
|
||||
private URI namespace;
|
||||
private String alias;
|
||||
private Date updated;
|
||||
private String description;
|
||||
|
||||
protected Extension(Builder<?> builder) {
|
||||
super(builder);
|
||||
this.namespace = builder.namespace;
|
||||
this.alias = builder.alias;
|
||||
this.updated = builder.updated;
|
||||
this.description = builder.description;
|
||||
@ConstructorProperties({
|
||||
"name", "links", "namespace", "alias", "updated", "description"
|
||||
})
|
||||
protected Extension(@Nullable String name, Set<Link> links, URI namespace, String alias, @Nullable Date updated, String description) {
|
||||
super(alias, name, links);
|
||||
this.namespace = checkNotNull(namespace, "namespace");
|
||||
this.alias = checkNotNull(alias, "alias");
|
||||
this.updated = updated;
|
||||
this.description = checkNotNull(description, "description");
|
||||
}
|
||||
|
||||
public URI getNamespace() {
|
||||
return this.namespace;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getId() {
|
||||
return this.alias;
|
||||
}
|
||||
|
||||
public String getAlias() {
|
||||
return this.alias;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Date getUpdated() {
|
||||
return this.updated;
|
||||
}
|
||||
|
@ -147,11 +153,24 @@ public class Extension extends Resource {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Objects.ToStringHelper string() {
|
||||
return super.string()
|
||||
.add("namespace", namespace)
|
||||
.add("alias", alias)
|
||||
.add("updated", updated)
|
||||
.add("description", description);
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(namespace, alias, updated, description);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
Extension that = Extension.class.cast(obj);
|
||||
return super.equals(that) && Objects.equal(this.namespace, that.namespace)
|
||||
&& Objects.equal(this.alias, that.alias)
|
||||
&& Objects.equal(this.updated, that.updated)
|
||||
&& Objects.equal(this.description, that.description);
|
||||
}
|
||||
|
||||
protected ToStringHelper string() {
|
||||
return super.string()
|
||||
.add("namespace", namespace).add("alias", alias).add("updated", updated).add("description", description);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
/*
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
|
@ -18,11 +18,17 @@
|
|||
*/
|
||||
package org.jclouds.openstack.nova.v2_0.domain;
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
|
||||
import javax.inject.Named;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
import org.jclouds.openstack.v2_0.domain.Link;
|
||||
import org.jclouds.openstack.v2_0.domain.Resource;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
import com.google.common.base.Optional;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
/**
|
||||
* A flavor is an available hardware configuration for a server. Each flavor has
|
||||
|
@ -30,10 +36,11 @@ import com.google.gson.annotations.SerializedName;
|
|||
*
|
||||
* @author Jeremy Daggett
|
||||
* @see <a href=
|
||||
* "http://docs.openstack.org/api/openstack-compute/1.1/content/Flavors-d1e4180.html"
|
||||
* />
|
||||
*/
|
||||
"http://docs.openstack.org/api/openstack-compute/1.1/content/Flavors-d1e4180.html"
|
||||
/>
|
||||
*/
|
||||
public class Flavor extends Resource {
|
||||
|
||||
public static Builder<?> builder() {
|
||||
return new ConcreteBuilder();
|
||||
}
|
||||
|
@ -43,13 +50,12 @@ public class Flavor extends Resource {
|
|||
}
|
||||
|
||||
public static abstract class Builder<T extends Builder<T>> extends Resource.Builder<T> {
|
||||
private int ram;
|
||||
private int disk;
|
||||
private int vcpus;
|
||||
private String swap;
|
||||
private Double rxtxFactor;
|
||||
private Integer ephemeral;
|
||||
|
||||
protected int ram;
|
||||
protected int disk;
|
||||
protected int vcpus;
|
||||
protected String swap;
|
||||
protected Double rxtxFactor;
|
||||
protected Integer ephemeral;
|
||||
|
||||
/**
|
||||
* @see Flavor#getRam()
|
||||
|
@ -76,7 +82,7 @@ public class Flavor extends Resource {
|
|||
}
|
||||
|
||||
/**
|
||||
* @see Flavor#getVcpus()
|
||||
* @see Flavor#getSwap()
|
||||
*/
|
||||
public T swap(String swap) {
|
||||
this.swap = swap;
|
||||
|
@ -84,7 +90,7 @@ public class Flavor extends Resource {
|
|||
}
|
||||
|
||||
/**
|
||||
* @see Flavor#getVcpus()
|
||||
* @see Flavor#getRxtxFactor()
|
||||
*/
|
||||
public T rxtxFactor(Double rxtxFactor) {
|
||||
this.rxtxFactor = rxtxFactor;
|
||||
|
@ -92,28 +98,26 @@ public class Flavor extends Resource {
|
|||
}
|
||||
|
||||
/**
|
||||
* @see Flavor#getVcpus()
|
||||
* @see Flavor#getEphemeral()
|
||||
*/
|
||||
public T ephemeral(Integer ephemeral) {
|
||||
this.ephemeral = ephemeral;
|
||||
return self();
|
||||
}
|
||||
|
||||
|
||||
public Flavor build() {
|
||||
return new Flavor(this);
|
||||
return new Flavor(id, name, links, ram, disk, vcpus, swap, rxtxFactor, ephemeral);
|
||||
}
|
||||
|
||||
public T fromFlavor(Flavor in) {
|
||||
return super.fromResource(in)
|
||||
.ram(in.getRam())
|
||||
.disk(in.getDisk())
|
||||
.vcpus(in.getVcpus())
|
||||
.swap(in.getSwap().orNull())
|
||||
.rxtxFactor(in.getRxtxFactor().orNull())
|
||||
.ephemeral(in.getEphemeral().orNull());
|
||||
.ram(in.getRam())
|
||||
.disk(in.getDisk())
|
||||
.vcpus(in.getVcpus())
|
||||
.swap(in.getSwap().orNull())
|
||||
.rxtxFactor(in.getRxtxFactor().orNull())
|
||||
.ephemeral(in.getEphemeral().orNull());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
|
@ -123,29 +127,27 @@ public class Flavor extends Resource {
|
|||
}
|
||||
}
|
||||
|
||||
protected Flavor() {
|
||||
// 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 final int ram;
|
||||
private final int disk;
|
||||
private final int vcpus;
|
||||
private final Optional<String> swap;
|
||||
@Named("rxtx_factor")
|
||||
private final Optional<Double> rxtxFactor;
|
||||
@Named("OS-FLV-EXT-DATA:ephemeral")
|
||||
private final Optional<Integer> ephemeral;
|
||||
|
||||
private int ram;
|
||||
private int disk;
|
||||
private int vcpus;
|
||||
private Optional<String> swap = Optional.absent();
|
||||
@SerializedName("rxtx_factor")
|
||||
private Optional<Double> rxtxFactor = Optional.absent();
|
||||
@SerializedName("OS-FLV-EXT-DATA:ephemeral")
|
||||
private Optional<Integer> ephemeral = Optional.absent();
|
||||
|
||||
protected Flavor(Builder<?> builder) {
|
||||
super(builder);
|
||||
this.ram = builder.ram;
|
||||
this.disk = builder.disk;
|
||||
this.vcpus = builder.vcpus;
|
||||
this.swap = Optional.fromNullable(builder.swap);
|
||||
this.rxtxFactor = Optional.fromNullable(builder.rxtxFactor);
|
||||
this.ephemeral = Optional.fromNullable(builder.ephemeral);
|
||||
@ConstructorProperties({
|
||||
"id", "name", "links", "ram", "disk", "vcpus", "swap", "rxtx_factor", "OS-FLV-EXT-DATA:ephemeral"
|
||||
})
|
||||
protected Flavor(String id, @Nullable String name, java.util.Set<Link> links, int ram, int disk, int vcpus,
|
||||
@Nullable String swap, @Nullable Double rxtxFactor, @Nullable Integer ephemeral) {
|
||||
super(id, name, links);
|
||||
this.ram = ram;
|
||||
this.disk = disk;
|
||||
this.vcpus = vcpus;
|
||||
this.swap = Optional.fromNullable(swap);
|
||||
this.rxtxFactor = Optional.fromNullable(rxtxFactor);
|
||||
this.ephemeral = Optional.fromNullable(ephemeral);
|
||||
}
|
||||
|
||||
public int getRam() {
|
||||
|
@ -161,11 +163,11 @@ public class Flavor extends Resource {
|
|||
}
|
||||
|
||||
public Optional<String> getSwap() {
|
||||
return swap;
|
||||
return this.swap;
|
||||
}
|
||||
|
||||
public Optional<Double> getRxtxFactor() {
|
||||
return rxtxFactor;
|
||||
return this.rxtxFactor;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -177,17 +179,30 @@ public class Flavor extends Resource {
|
|||
* @see org.jclouds.openstack.nova.v2_0.extensions.ExtensionNamespaces#FLAVOR_EXTRA_DATA
|
||||
*/
|
||||
public Optional<Integer> getEphemeral() {
|
||||
return ephemeral;
|
||||
return this.ephemeral;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Objects.ToStringHelper string() {
|
||||
return super.string()
|
||||
.add("ram", ram)
|
||||
.add("disk", disk)
|
||||
.add("vcpus", vcpus)
|
||||
.add("swap", swap)
|
||||
.add("rxtxFactor", rxtxFactor)
|
||||
.add("ephemeral", ephemeral);
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(ram, disk, vcpus, swap, rxtxFactor, ephemeral);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
Flavor that = Flavor.class.cast(obj);
|
||||
return super.equals(that) && Objects.equal(this.ram, that.ram)
|
||||
&& Objects.equal(this.disk, that.disk)
|
||||
&& Objects.equal(this.vcpus, that.vcpus)
|
||||
&& Objects.equal(this.swap, that.swap)
|
||||
&& Objects.equal(this.rxtxFactor, that.rxtxFactor)
|
||||
&& Objects.equal(this.ephemeral, that.ephemeral);
|
||||
}
|
||||
|
||||
protected ToStringHelper string() {
|
||||
return super.string()
|
||||
.add("ram", ram).add("disk", disk).add("vcpus", vcpus).add("swap", swap).add("rxtxFactor", rxtxFactor).add("ephemeral", ephemeral);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
/*
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
|
@ -18,11 +18,16 @@
|
|||
*/
|
||||
package org.jclouds.openstack.nova.v2_0.domain;
|
||||
|
||||
import static com.google.common.base.Objects.toStringHelper;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
|
||||
import javax.inject.Named;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
|
||||
/**
|
||||
* A Floating IP is an IP address that can be created and associated with a
|
||||
|
@ -31,68 +36,90 @@ import com.google.gson.annotations.SerializedName;
|
|||
*
|
||||
* @author Jeremy Daggett
|
||||
* @author chamerling
|
||||
*/
|
||||
*/
|
||||
public class FloatingIP implements Comparable<FloatingIP> {
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
|
||||
public static Builder<?> builder() {
|
||||
return new ConcreteBuilder();
|
||||
}
|
||||
|
||||
public Builder toBuilder() {
|
||||
return builder().fromFloatingIp(this);
|
||||
public Builder<?> toBuilder() {
|
||||
return new ConcreteBuilder().fromFloatingIP(this);
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
private String id;
|
||||
private String ip;
|
||||
private String fixedIp;
|
||||
private String instanceId;
|
||||
public static abstract class Builder<T extends Builder<T>> {
|
||||
protected abstract T self();
|
||||
|
||||
public Builder id(String id) {
|
||||
protected String id;
|
||||
protected String ip;
|
||||
protected String fixedIp;
|
||||
protected String instanceId;
|
||||
|
||||
/**
|
||||
* @see FloatingIP#getId()
|
||||
*/
|
||||
public T id(String id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder ip(String ip) {
|
||||
/**
|
||||
* @see FloatingIP#getIp()
|
||||
*/
|
||||
public T ip(String ip) {
|
||||
this.ip = ip;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder fixedIp(String fixedIp) {
|
||||
/**
|
||||
* @see FloatingIP#getFixedIp()
|
||||
*/
|
||||
public T fixedIp(String fixedIp) {
|
||||
this.fixedIp = fixedIp;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder instanceId(String instanceId) {
|
||||
/**
|
||||
* @see FloatingIP#getInstanceId()
|
||||
*/
|
||||
public T instanceId(String instanceId) {
|
||||
this.instanceId = instanceId;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public FloatingIP build() {
|
||||
return new FloatingIP(id, ip, fixedIp, instanceId);
|
||||
}
|
||||
|
||||
public Builder fromFloatingIp(FloatingIP in) {
|
||||
return id(in.getId()).ip(in.getIp()).fixedIp(in.getFixedIp()).instanceId(in.getInstanceId());
|
||||
public T fromFloatingIP(FloatingIP in) {
|
||||
return this
|
||||
.id(in.getId())
|
||||
.ip(in.getIp())
|
||||
.fixedIp(in.getFixedIp())
|
||||
.instanceId(in.getInstanceId());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected FloatingIP() {
|
||||
// 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 static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
@Override
|
||||
protected ConcreteBuilder self() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
private String id;
|
||||
private String ip;
|
||||
@SerializedName("fixed_ip")
|
||||
private String fixedIp;
|
||||
@SerializedName("instance_id")
|
||||
private String instanceId;
|
||||
private final String id;
|
||||
private final String ip;
|
||||
@Named("fixed_ip")
|
||||
private final String fixedIp;
|
||||
@Named("instance_id")
|
||||
private final String instanceId;
|
||||
|
||||
@ConstructorProperties({
|
||||
"id", "ip", "fixed_ip", "instance_id"
|
||||
})
|
||||
protected FloatingIP(String id, String ip, @Nullable String fixedIp, @Nullable String instanceId) {
|
||||
this.id = id;
|
||||
this.ip = ip;
|
||||
this.id = checkNotNull(id, "id");
|
||||
this.ip = checkNotNull(ip, "ip");
|
||||
this.fixedIp = fixedIp;
|
||||
this.instanceId = instanceId;
|
||||
}
|
||||
|
@ -105,66 +132,44 @@ public class FloatingIP implements Comparable<FloatingIP> {
|
|||
return this.ip;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getFixedIp() {
|
||||
return this.fixedIp;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getInstanceId() {
|
||||
return this.instanceId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(id, ip, fixedIp, instanceId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
FloatingIP that = FloatingIP.class.cast(obj);
|
||||
return Objects.equal(this.id, that.id)
|
||||
&& Objects.equal(this.ip, that.ip)
|
||||
&& Objects.equal(this.fixedIp, that.fixedIp)
|
||||
&& Objects.equal(this.instanceId, that.instanceId);
|
||||
}
|
||||
|
||||
protected ToStringHelper string() {
|
||||
return Objects.toStringHelper(this)
|
||||
.add("id", id).add("ip", ip).add("fixedIp", fixedIp).add("instanceId", instanceId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return string().toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(FloatingIP o) {
|
||||
return this.id.compareTo(o.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((fixedIp == null) ? 0 : fixedIp.hashCode());
|
||||
result = prime * result + ((id == null) ? 0 : id.hashCode());
|
||||
result = prime * result + ((instanceId == null) ? 0 : instanceId.hashCode());
|
||||
result = prime * result + ((ip == null) ? 0 : ip.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
FloatingIP other = (FloatingIP) obj;
|
||||
if (fixedIp == null) {
|
||||
if (other.fixedIp != null)
|
||||
return false;
|
||||
} else if (!fixedIp.equals(other.fixedIp))
|
||||
return false;
|
||||
if (id == null) {
|
||||
if (other.id != null)
|
||||
return false;
|
||||
} else if (!id.equals(other.id))
|
||||
return false;
|
||||
if (instanceId == null) {
|
||||
if (other.instanceId != null)
|
||||
return false;
|
||||
} else if (!instanceId.equals(other.instanceId))
|
||||
return false;
|
||||
if (ip == null) {
|
||||
if (other.ip != null)
|
||||
return false;
|
||||
} else if (!ip.equals(other.ip))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return toStringHelper("").add("id", id).add("ip", ip).add("fixedIp", fixedIp).add("instanceId", instanceId)
|
||||
.toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
/*
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
|
@ -18,15 +18,18 @@
|
|||
*/
|
||||
package org.jclouds.openstack.nova.v2_0.domain;
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
|
||||
import javax.inject.Named;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
/**
|
||||
* Class Host
|
||||
*/
|
||||
*/
|
||||
public class Host {
|
||||
|
||||
public static Builder<?> builder() {
|
||||
|
@ -40,30 +43,34 @@ public class Host {
|
|||
public static abstract class Builder<T extends Builder<T>> {
|
||||
protected abstract T self();
|
||||
|
||||
private String name;
|
||||
private String service;
|
||||
protected String name;
|
||||
protected String service;
|
||||
|
||||
/**
|
||||
* @see Host#getName()
|
||||
*/
|
||||
public T name(String name) {
|
||||
this.name = name;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Host#getService()
|
||||
*/
|
||||
public T service(String service) {
|
||||
this.service = service;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Host build() {
|
||||
return new Host(this);
|
||||
return new Host(name, service);
|
||||
}
|
||||
|
||||
public T fromHost(Host in) {
|
||||
return this
|
||||
.name(in.getName())
|
||||
.service(in.getService())
|
||||
;
|
||||
.name(in.getName())
|
||||
.service(in.getService());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
|
@ -73,30 +80,23 @@ public class Host {
|
|||
}
|
||||
}
|
||||
|
||||
protected Host() {
|
||||
// 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
|
||||
@Named("host_name")
|
||||
private final String name;
|
||||
private final String service;
|
||||
|
||||
@ConstructorProperties({
|
||||
"host_name", "service"
|
||||
})
|
||||
protected Host(@Nullable String name, @Nullable String service) {
|
||||
this.name = name;
|
||||
this.service = service;
|
||||
}
|
||||
|
||||
@SerializedName(value="host_name")
|
||||
private String name;
|
||||
private String service;
|
||||
|
||||
protected Host(Builder<?> builder) {
|
||||
this.name = builder.name;
|
||||
this.service = builder.service;
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
@Nullable
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
@Nullable
|
||||
public String getService() {
|
||||
return this.service;
|
||||
|
@ -113,15 +113,12 @@ public class Host {
|
|||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
Host that = Host.class.cast(obj);
|
||||
return Objects.equal(this.name, that.name)
|
||||
&& Objects.equal(this.service, that.service)
|
||||
;
|
||||
&& Objects.equal(this.service, that.service);
|
||||
}
|
||||
|
||||
protected ToStringHelper string() {
|
||||
return Objects.toStringHelper("")
|
||||
.add("name", name)
|
||||
.add("service", service)
|
||||
;
|
||||
return Objects.toStringHelper(this)
|
||||
.add("name", name).add("service", service);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
/*
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
|
@ -20,23 +20,26 @@ package org.jclouds.openstack.nova.v2_0.domain;
|
|||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.beans.ConstructorProperties;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.inject.Named;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.base.Optional;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
import com.google.common.base.Optional;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
/**
|
||||
* Aggregates can be manipulated using the Aggregate Extension to Nova (alias "OS-AGGREGATES")
|
||||
*
|
||||
* @see org.jclouds.openstack.nova.v2_0.extensions.HostAggregateClient
|
||||
*/
|
||||
*/
|
||||
public class HostAggregate {
|
||||
|
||||
public static Builder<?> builder() {
|
||||
|
@ -44,20 +47,20 @@ public class HostAggregate {
|
|||
}
|
||||
|
||||
public Builder<?> toBuilder() {
|
||||
return new ConcreteBuilder().fromAggregate(this);
|
||||
return new ConcreteBuilder().fromHostAggregate(this);
|
||||
}
|
||||
|
||||
public static abstract class Builder<T extends Builder<T>> {
|
||||
public static abstract class Builder<T extends Builder<T>> {
|
||||
protected abstract T self();
|
||||
|
||||
private String id;
|
||||
private String name;
|
||||
private String availabilityZone;
|
||||
private Set<String> hosts = ImmutableSet.of();
|
||||
private String state;
|
||||
private Date created = new Date();
|
||||
private Date updated;
|
||||
private Map<String, String> metadata = ImmutableMap.of();
|
||||
protected String id;
|
||||
protected String name;
|
||||
protected String availabilityZone;
|
||||
protected Set<String> hosts = ImmutableSet.of();
|
||||
protected String state;
|
||||
protected Date created;
|
||||
protected Date updated;
|
||||
protected Map<String, String> metadata = ImmutableMap.of();
|
||||
|
||||
/**
|
||||
* @see HostAggregate#getId()
|
||||
|
@ -86,16 +89,13 @@ public class HostAggregate {
|
|||
/**
|
||||
* @see HostAggregate#getHosts()
|
||||
*/
|
||||
public T hosts(String... hosts) {
|
||||
return hosts(ImmutableSet.copyOf(hosts));
|
||||
public T hosts(Set<String> hosts) {
|
||||
this.hosts = ImmutableSet.copyOf(checkNotNull(hosts, "hosts"));
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see HostAggregate#getHosts()
|
||||
*/
|
||||
public T hosts(Set<String> hosts) {
|
||||
this.hosts = hosts;
|
||||
return self();
|
||||
public T hosts(String... in) {
|
||||
return hosts(ImmutableSet.copyOf(in));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -126,26 +126,25 @@ public class HostAggregate {
|
|||
* @see HostAggregate#getMetadata()
|
||||
*/
|
||||
public T metadata(Map<String, String> metadata) {
|
||||
this.metadata = metadata;
|
||||
this.metadata = ImmutableMap.copyOf(checkNotNull(metadata, "metadata"));
|
||||
return self();
|
||||
}
|
||||
|
||||
public HostAggregate build() {
|
||||
return new HostAggregate(this);
|
||||
return new HostAggregate(id, name, availabilityZone, hosts, state, created, updated, metadata);
|
||||
}
|
||||
|
||||
public T fromAggregate(HostAggregate in) {
|
||||
public T fromHostAggregate(HostAggregate in) {
|
||||
return this
|
||||
.id(in.getId())
|
||||
.name(in.getName())
|
||||
.availabilityZone(in.getAvailabilityZone())
|
||||
.hosts(in.getHosts())
|
||||
.state(in.getState())
|
||||
.created(in.getCreated())
|
||||
.updated(in.getUpdated().orNull())
|
||||
.metadata(in.getMetadata());
|
||||
.id(in.getId())
|
||||
.name(in.getName())
|
||||
.availabilityZone(in.getAvailabilityZone())
|
||||
.hosts(in.getHosts())
|
||||
.state(in.getState())
|
||||
.created(in.getCreated())
|
||||
.updated(in.getUpdated().get())
|
||||
.metadata(in.getMetadata());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
|
@ -155,34 +154,32 @@ public class HostAggregate {
|
|||
}
|
||||
}
|
||||
|
||||
protected HostAggregate() {
|
||||
// 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 final String id;
|
||||
private final String name;
|
||||
@Named("availability_zone")
|
||||
private final String availabilityZone;
|
||||
private final Set<String> hosts;
|
||||
@Named("operational_state")
|
||||
private final String state;
|
||||
@Named("created_at")
|
||||
private final Date created;
|
||||
@Named("updated_at")
|
||||
private final Optional<Date> updated;
|
||||
private final Map<String, String> metadata;
|
||||
|
||||
private String id;
|
||||
private String name;
|
||||
@SerializedName(value = "availability_zone")
|
||||
private String availabilityZone;
|
||||
private Set<String> hosts = ImmutableSet.of();
|
||||
@SerializedName(value = "operational_state")
|
||||
private String state;
|
||||
@SerializedName(value = "created_at")
|
||||
private Date created;
|
||||
@SerializedName(value = "updated_at")
|
||||
private Optional<Date> updated = Optional.absent();
|
||||
private Map<String, String> metadata = ImmutableMap.of();
|
||||
|
||||
protected HostAggregate(Builder<?> builder) {
|
||||
this.id = checkNotNull(builder.id, "id");
|
||||
this.name = checkNotNull(builder.name, "name");
|
||||
this.availabilityZone = checkNotNull(builder.availabilityZone, "availabilityZone");
|
||||
this.hosts = ImmutableSet.copyOf(checkNotNull(builder.hosts, "hosts"));
|
||||
this.state = checkNotNull(builder.state, "state");
|
||||
this.created = checkNotNull(builder.created, "created");
|
||||
this.updated = Optional.fromNullable(builder.updated);
|
||||
this.metadata = ImmutableMap.copyOf(checkNotNull(builder.metadata, "metadata"));
|
||||
@ConstructorProperties({
|
||||
"id", "name", "availability_zone", "hosts", "operational_state", "created_at", "updated_at", "metadata"
|
||||
})
|
||||
protected HostAggregate(String id, String name, String availabilityZone, Set<String> hosts, String state, Date created,
|
||||
@Nullable Date updated, Map<String, String> metadata) {
|
||||
this.id = checkNotNull(id, "id");
|
||||
this.name = checkNotNull(name, "name");
|
||||
this.availabilityZone = checkNotNull(availabilityZone, "availabilityZone");
|
||||
this.hosts = ImmutableSet.copyOf(checkNotNull(hosts, "hosts"));
|
||||
this.state = checkNotNull(state, "state");
|
||||
this.created = checkNotNull(created, "created");
|
||||
this.updated = Optional.fromNullable(updated);
|
||||
this.metadata = ImmutableMap.copyOf(checkNotNull(metadata, "metadata"));
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
|
@ -203,7 +200,7 @@ public class HostAggregate {
|
|||
}
|
||||
|
||||
public Set<String> getHosts() {
|
||||
return Collections.unmodifiableSet(this.hosts);
|
||||
return this.hosts;
|
||||
}
|
||||
|
||||
public String getState() {
|
||||
|
@ -233,26 +230,18 @@ public class HostAggregate {
|
|||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
HostAggregate that = HostAggregate.class.cast(obj);
|
||||
return Objects.equal(this.id, that.id)
|
||||
&& Objects.equal(this.name, that.name)
|
||||
&& Objects.equal(this.availabilityZone, that.availabilityZone)
|
||||
&& Objects.equal(this.hosts, that.hosts)
|
||||
&& Objects.equal(this.state, that.state)
|
||||
&& Objects.equal(this.created, that.created)
|
||||
&& Objects.equal(this.updated, that.updated)
|
||||
&& Objects.equal(this.metadata, that.metadata)
|
||||
;
|
||||
&& Objects.equal(this.name, that.name)
|
||||
&& Objects.equal(this.availabilityZone, that.availabilityZone)
|
||||
&& Objects.equal(this.hosts, that.hosts)
|
||||
&& Objects.equal(this.state, that.state)
|
||||
&& Objects.equal(this.created, that.created)
|
||||
&& Objects.equal(this.updated, that.updated)
|
||||
&& Objects.equal(this.metadata, that.metadata);
|
||||
}
|
||||
|
||||
protected ToStringHelper string() {
|
||||
return Objects.toStringHelper("")
|
||||
.add("id", id)
|
||||
.add("name", name)
|
||||
.add("availabilityZone", availabilityZone)
|
||||
.add("hosts", hosts)
|
||||
.add("state", state)
|
||||
.add("created", created)
|
||||
.add("updated", updated)
|
||||
.add("metadata", metadata);
|
||||
return Objects.toStringHelper(this)
|
||||
.add("id", id).add("name", name).add("availabilityZone", availabilityZone).add("hosts", hosts).add("state", state).add("created", created).add("updated", updated).add("metadata", metadata);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
/*
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
|
@ -20,15 +20,18 @@ package org.jclouds.openstack.nova.v2_0.domain;
|
|||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
|
||||
import javax.inject.Named;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
/**
|
||||
* Class HostResourceUsage
|
||||
*/
|
||||
*/
|
||||
public class HostResourceUsage {
|
||||
|
||||
public static Builder<?> builder() {
|
||||
|
@ -42,51 +45,64 @@ public class HostResourceUsage {
|
|||
public static abstract class Builder<T extends Builder<T>> {
|
||||
protected abstract T self();
|
||||
|
||||
private String host;
|
||||
private String project;
|
||||
private int memoryMb;
|
||||
private int cpu;
|
||||
private int diskGb;
|
||||
protected String host;
|
||||
protected String project;
|
||||
protected int memoryMb;
|
||||
protected int cpu;
|
||||
protected int diskGb;
|
||||
|
||||
/**
|
||||
* @see HostResourceUsage#getHost()
|
||||
*/
|
||||
public T host(String host) {
|
||||
this.host = host;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see HostResourceUsage#getProject()
|
||||
*/
|
||||
public T project(String project) {
|
||||
this.project = project;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see HostResourceUsage#getMemoryMb()
|
||||
*/
|
||||
public T memoryMb(int memoryMb) {
|
||||
this.memoryMb = memoryMb;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see HostResourceUsage#getCpu()
|
||||
*/
|
||||
public T cpu(int cpu) {
|
||||
this.cpu = cpu;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see HostResourceUsage#getDiskGb()
|
||||
*/
|
||||
public T diskGb(int diskGb) {
|
||||
this.diskGb = diskGb;
|
||||
return self();
|
||||
}
|
||||
|
||||
public HostResourceUsage build() {
|
||||
return new HostResourceUsage(this);
|
||||
return new HostResourceUsage(host, project, memoryMb, cpu, diskGb);
|
||||
}
|
||||
|
||||
public T fromHostResourceUsage(HostResourceUsage in) {
|
||||
return this
|
||||
.host(in.getHost())
|
||||
.project(in.getProject())
|
||||
.memoryMb(in.getMemoryMb())
|
||||
.cpu(in.getCpu())
|
||||
.diskGb(in.getDiskGb())
|
||||
;
|
||||
.host(in.getHost())
|
||||
.project(in.getProject())
|
||||
.memoryMb(in.getMemoryMb())
|
||||
.cpu(in.getCpu())
|
||||
.diskGb(in.getDiskGb());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
|
@ -96,55 +112,42 @@ public class HostResourceUsage {
|
|||
}
|
||||
}
|
||||
|
||||
protected HostResourceUsage() {
|
||||
// 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 final String host;
|
||||
private final String project;
|
||||
@Named("memory_mb")
|
||||
private final int memoryMb;
|
||||
private final int cpu;
|
||||
@Named("disk_gb")
|
||||
private final int diskGb;
|
||||
|
||||
@ConstructorProperties({
|
||||
"host", "project", "memory_mb", "cpu", "disk_gb"
|
||||
})
|
||||
protected HostResourceUsage(String host, @Nullable String project, int memoryMb, int cpu, int diskGb) {
|
||||
this.host = checkNotNull(host, "host");
|
||||
this.project = project;
|
||||
this.memoryMb = memoryMb;
|
||||
this.cpu = cpu;
|
||||
this.diskGb = diskGb;
|
||||
}
|
||||
|
||||
private String host;
|
||||
private String project;
|
||||
@SerializedName(value="memory_mb")
|
||||
private int memoryMb;
|
||||
private int cpu;
|
||||
@SerializedName(value="disk_gb")
|
||||
private int diskGb;
|
||||
|
||||
protected HostResourceUsage(Builder<?> builder) {
|
||||
this.host = checkNotNull(builder.host, "host");
|
||||
this.project = builder.project;
|
||||
this.memoryMb = checkNotNull(builder.memoryMb, "memoryMb");
|
||||
this.cpu = checkNotNull(builder.cpu, "cpu");
|
||||
this.diskGb = checkNotNull(builder.diskGb, "diskGb");
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public String getHost() {
|
||||
return this.host;
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
@Nullable
|
||||
public String getProject() {
|
||||
return this.project;
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public int getMemoryMb() {
|
||||
return this.memoryMb;
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public int getCpu() {
|
||||
return this.cpu;
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public int getDiskGb() {
|
||||
return this.diskGb;
|
||||
}
|
||||
|
@ -160,19 +163,15 @@ public class HostResourceUsage {
|
|||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
HostResourceUsage that = HostResourceUsage.class.cast(obj);
|
||||
return Objects.equal(this.host, that.host)
|
||||
&& Objects.equal(this.project, that.project)
|
||||
&& Objects.equal(this.memoryMb, that.memoryMb)
|
||||
&& Objects.equal(this.cpu, that.cpu)
|
||||
&& Objects.equal(this.diskGb, that.diskGb);
|
||||
&& Objects.equal(this.project, that.project)
|
||||
&& Objects.equal(this.memoryMb, that.memoryMb)
|
||||
&& Objects.equal(this.cpu, that.cpu)
|
||||
&& Objects.equal(this.diskGb, that.diskGb);
|
||||
}
|
||||
|
||||
protected ToStringHelper string() {
|
||||
return Objects.toStringHelper("")
|
||||
.add("host", host)
|
||||
.add("project", project)
|
||||
.add("memoryMb", memoryMb)
|
||||
.add("cpu", cpu)
|
||||
.add("diskGb", diskGb);
|
||||
return Objects.toStringHelper(this)
|
||||
.add("host", host).add("project", project).add("memoryMb", memoryMb).add("cpu", cpu).add("diskGb", diskGb);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
/*
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
|
@ -18,16 +18,23 @@
|
|||
*/
|
||||
package org.jclouds.openstack.nova.v2_0.domain;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.inject.Named;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
import org.jclouds.openstack.v2_0.domain.Link;
|
||||
import org.jclouds.openstack.v2_0.domain.Resource;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
import com.google.common.base.Predicates;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
/**
|
||||
* An image is a collection of files you use to create or rebuild a server. Operators provide
|
||||
|
@ -35,9 +42,10 @@ import com.google.gson.annotations.SerializedName;
|
|||
*
|
||||
* @author Jeremy Daggett
|
||||
* @see <a href= "http://docs.openstack.org/api/openstack-compute/1.1/content/Images-d1e4427.html"
|
||||
* />
|
||||
*/
|
||||
/>
|
||||
*/
|
||||
public class Image extends Resource {
|
||||
|
||||
/**
|
||||
* In-flight images will have the status attribute set to SAVING and the conditional progress
|
||||
* element (0-100% completion) will also be returned. Other possible values for the status
|
||||
|
@ -52,15 +60,15 @@ public class Image extends Resource {
|
|||
UNRECOGNIZED, UNKNOWN, ACTIVE, SAVING, ERROR, DELETED;
|
||||
|
||||
public String value() {
|
||||
return name();
|
||||
return name();
|
||||
}
|
||||
|
||||
public static Status fromValue(String v) {
|
||||
try {
|
||||
return valueOf(v);
|
||||
} catch (IllegalArgumentException e) {
|
||||
return UNRECOGNIZED;
|
||||
}
|
||||
try {
|
||||
return valueOf(v);
|
||||
} catch (IllegalArgumentException e) {
|
||||
return UNRECOGNIZED;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -74,16 +82,16 @@ public class Image extends Resource {
|
|||
}
|
||||
|
||||
public static abstract class Builder<T extends Builder<T>> extends Resource.Builder<T> {
|
||||
private Date updated;
|
||||
private Date created;
|
||||
private String tenantId;
|
||||
private String userId;
|
||||
private Image.Status status;
|
||||
private int progress;
|
||||
private int minDisk;
|
||||
private int minRam;
|
||||
private Resource server;
|
||||
private Map<String, String> metadata = ImmutableMap.of();
|
||||
protected Date updated;
|
||||
protected Date created;
|
||||
protected String tenantId;
|
||||
protected String userId;
|
||||
protected Image.Status status;
|
||||
protected int progress;
|
||||
protected int minDisk;
|
||||
protected int minRam;
|
||||
protected Resource server;
|
||||
protected Map<String, String> metadata = ImmutableMap.of();
|
||||
|
||||
/**
|
||||
* @see Image#getUpdated()
|
||||
|
@ -161,28 +169,27 @@ public class Image extends Resource {
|
|||
* @see Image#getMetadata()
|
||||
*/
|
||||
public T metadata(Map<String, String> metadata) {
|
||||
this.metadata = metadata;
|
||||
this.metadata = ImmutableMap.copyOf(checkNotNull(metadata, "metadata"));
|
||||
return self();
|
||||
}
|
||||
|
||||
public Image build() {
|
||||
return new Image(this);
|
||||
return new Image(id, name, links, updated, created, tenantId, userId, status, progress, minDisk, minRam, server, metadata);
|
||||
}
|
||||
|
||||
public T fromImage(Image in) {
|
||||
return super.fromResource(in)
|
||||
.updated(in.getUpdated())
|
||||
.created(in.getCreated())
|
||||
.tenantId(in.getTenantId())
|
||||
.userId(in.getUserId())
|
||||
.status(in.getStatus())
|
||||
.progress(in.getProgress())
|
||||
.minDisk(in.getMinDisk())
|
||||
.minRam(in.getMinRam())
|
||||
.server(in.getServer())
|
||||
.metadata(in.getMetadata());
|
||||
.updated(in.getUpdated())
|
||||
.created(in.getCreated())
|
||||
.tenantId(in.getTenantId())
|
||||
.userId(in.getUserId())
|
||||
.status(in.getStatus())
|
||||
.progress(in.getProgress())
|
||||
.minDisk(in.getMinDisk())
|
||||
.minRam(in.getMinRam())
|
||||
.server(in.getServer())
|
||||
.metadata(in.getMetadata());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
|
@ -192,55 +199,59 @@ public class Image extends Resource {
|
|||
}
|
||||
}
|
||||
|
||||
protected Image() {
|
||||
// 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 Date updated;
|
||||
private Date created;
|
||||
@SerializedName("tenant_id")
|
||||
private String tenantId;
|
||||
@SerializedName("user_id")
|
||||
private String userId;
|
||||
private Status status;
|
||||
private int progress;
|
||||
private int minDisk;
|
||||
private int minRam;
|
||||
private Resource server;
|
||||
private Map<String, String> metadata = ImmutableMap.of();
|
||||
|
||||
protected Image(Builder<?> builder) {
|
||||
super(builder);
|
||||
this.updated = builder.updated;
|
||||
this.created = builder.created;
|
||||
this.tenantId = builder.tenantId;
|
||||
this.userId = builder.userId;
|
||||
this.status = builder.status;
|
||||
this.progress = builder.progress;
|
||||
this.minDisk = builder.minDisk;
|
||||
this.minRam = builder.minRam;
|
||||
this.server = builder.server;
|
||||
this.metadata = ImmutableMap.copyOf(builder.metadata);
|
||||
private final Date updated;
|
||||
private final Date created;
|
||||
@Named("tenant_id")
|
||||
private final String tenantId;
|
||||
@Named("user_id")
|
||||
private final String userId;
|
||||
private final Image.Status status;
|
||||
private final int progress;
|
||||
private final int minDisk;
|
||||
private final int minRam;
|
||||
private final Resource server;
|
||||
private final Map<String, String> metadata;
|
||||
|
||||
@ConstructorProperties({
|
||||
"id", "name", "links", "updated", "created", "tenant_id", "user_id", "status", "progress", "minDisk", "minRam", "server", "metadata"
|
||||
})
|
||||
protected Image(String id, @Nullable String name, java.util.Set<Link> links, @Nullable Date updated, @Nullable Date created,
|
||||
String tenantId, @Nullable String userId, @Nullable Status status, int progress, int minDisk, int minRam,
|
||||
@Nullable Resource server, @Nullable Map<String, String> metadata) {
|
||||
super(id, name, links);
|
||||
this.updated = updated;
|
||||
this.created = created;
|
||||
this.tenantId = tenantId;
|
||||
this.userId = userId;
|
||||
this.status = status;
|
||||
this.progress = progress;
|
||||
this.minDisk = minDisk;
|
||||
this.minRam = minRam;
|
||||
this.server = server;
|
||||
this.metadata = metadata == null ? ImmutableMap.<String, String>of() : ImmutableMap.copyOf(Maps.filterValues(metadata, Predicates.notNull()));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Date getUpdated() {
|
||||
return this.updated;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Date getCreated() {
|
||||
return this.created;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getTenantId() {
|
||||
return this.tenantId;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getUserId() {
|
||||
return this.userId;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Status getStatus() {
|
||||
return this.status;
|
||||
}
|
||||
|
@ -257,28 +268,40 @@ public class Image extends Resource {
|
|||
return this.minRam;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Resource getServer() {
|
||||
return this.server;
|
||||
}
|
||||
|
||||
public Map<String, String> getMetadata() {
|
||||
// in case this was assigned in gson
|
||||
return ImmutableMap.copyOf(Maps.filterValues(this.metadata, Predicates.notNull()));
|
||||
return this.metadata;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Objects.ToStringHelper string() {
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(updated, created, tenantId, userId, status, progress, minDisk, minRam, server, metadata);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
Image that = Image.class.cast(obj);
|
||||
return super.equals(that) && Objects.equal(this.updated, that.updated)
|
||||
&& Objects.equal(this.created, that.created)
|
||||
&& Objects.equal(this.tenantId, that.tenantId)
|
||||
&& Objects.equal(this.userId, that.userId)
|
||||
&& Objects.equal(this.status, that.status)
|
||||
&& Objects.equal(this.progress, that.progress)
|
||||
&& Objects.equal(this.minDisk, that.minDisk)
|
||||
&& Objects.equal(this.minRam, that.minRam)
|
||||
&& Objects.equal(this.server, that.server)
|
||||
&& Objects.equal(this.metadata, that.metadata);
|
||||
}
|
||||
|
||||
protected ToStringHelper string() {
|
||||
return super.string()
|
||||
.add("updated", updated)
|
||||
.add("created", created)
|
||||
.add("tenantId", tenantId)
|
||||
.add("userId", userId)
|
||||
.add("status", status)
|
||||
.add("progress", progress)
|
||||
.add("minDisk", minDisk)
|
||||
.add("minRam", minRam)
|
||||
.add("server", server)
|
||||
.add("metadata", metadata);
|
||||
.add("updated", updated).add("created", created).add("tenantId", tenantId).add("userId", userId).add("status", status).add("progress", progress).add("minDisk", minDisk).add("minRam", minRam).add("server", server).add("metadata", metadata);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
/*
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
|
@ -18,86 +18,103 @@
|
|||
*/
|
||||
package org.jclouds.openstack.nova.v2_0.domain;
|
||||
|
||||
import static com.google.common.base.Objects.equal;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
|
||||
import javax.inject.Named;
|
||||
|
||||
import com.google.common.annotations.Beta;
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
/**
|
||||
* Ingress access to a destination protocol on particular ports
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
*/
|
||||
@Beta
|
||||
public class Ingress {
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
|
||||
public static Builder<?> builder() {
|
||||
return new ConcreteBuilder();
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
public Builder<?> toBuilder() {
|
||||
return new ConcreteBuilder().fromIngress(this);
|
||||
}
|
||||
|
||||
public static abstract class Builder<T extends Builder<T>> {
|
||||
protected abstract T self();
|
||||
|
||||
protected IpProtocol ipProtocol;
|
||||
protected int fromPort;
|
||||
protected int toPort;
|
||||
|
||||
/**
|
||||
*
|
||||
* @see Ingress#getIpProtocol()
|
||||
*/
|
||||
public Builder ipProtocol(IpProtocol ipProtocol) {
|
||||
public T ipProtocol(IpProtocol ipProtocol) {
|
||||
this.ipProtocol = ipProtocol;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @see Ingress#getFromPort()
|
||||
*/
|
||||
public Builder fromPort(int fromPort) {
|
||||
public T fromPort(int fromPort) {
|
||||
this.fromPort = fromPort;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @see Ingress#getToPort()
|
||||
*/
|
||||
public Builder toPort(int toPort) {
|
||||
public T toPort(int toPort) {
|
||||
this.toPort = toPort;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Ingress build() {
|
||||
return new Ingress(ipProtocol, fromPort, toPort);
|
||||
}
|
||||
|
||||
public T fromIngress(Ingress in) {
|
||||
return this
|
||||
.ipProtocol(in.getIpProtocol())
|
||||
.fromPort(in.getFromPort())
|
||||
.toPort(in.getToPort());
|
||||
}
|
||||
}
|
||||
|
||||
protected Ingress() {
|
||||
// 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 static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
@Override
|
||||
protected ConcreteBuilder self() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@SerializedName(value = "ip_protocol")
|
||||
protected IpProtocol ipProtocol;
|
||||
@SerializedName(value = "from_port")
|
||||
protected int fromPort;
|
||||
@SerializedName(value = "to_port")
|
||||
protected int toPort;
|
||||
@Named("ip_protocol")
|
||||
private final IpProtocol ipProtocol;
|
||||
@Named("from_port")
|
||||
private final int fromPort;
|
||||
@Named("to_port")
|
||||
private final int toPort;
|
||||
|
||||
@ConstructorProperties({
|
||||
"ip_protocol", "from_port", "to_port"
|
||||
})
|
||||
protected Ingress(IpProtocol ipProtocol, int fromPort, int toPort) {
|
||||
this.ipProtocol = checkNotNull(ipProtocol, "ipProtocol");
|
||||
this.fromPort = fromPort;
|
||||
this.toPort = toPort;
|
||||
this.ipProtocol = checkNotNull(ipProtocol, "ipProtocol");
|
||||
}
|
||||
|
||||
/**
|
||||
* destination IP protocol
|
||||
*/
|
||||
public IpProtocol getIpProtocol() {
|
||||
return ipProtocol;
|
||||
return this.ipProtocol;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -105,7 +122,7 @@ public class Ingress {
|
|||
* type number of -1 indicates a wildcard (i.e., any ICMP type number).
|
||||
*/
|
||||
public int getFromPort() {
|
||||
return fromPort;
|
||||
return this.fromPort;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -113,19 +130,7 @@ public class Ingress {
|
|||
* -1 indicates a wildcard (i.e., any ICMP code).
|
||||
*/
|
||||
public int getToPort() {
|
||||
return toPort;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o)
|
||||
return true;
|
||||
// allow subtypes
|
||||
if (o == null || !(o instanceof Ingress))
|
||||
return false;
|
||||
Ingress that = Ingress.class.cast(o);
|
||||
return equal(this.ipProtocol, that.ipProtocol) && equal(this.fromPort, that.fromPort)
|
||||
&& equal(this.toPort, that.toPort);
|
||||
return this.toPort;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -133,13 +138,24 @@ public class Ingress {
|
|||
return Objects.hashCode(ipProtocol, fromPort, toPort);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
Ingress that = Ingress.class.cast(obj);
|
||||
return Objects.equal(this.ipProtocol, that.ipProtocol)
|
||||
&& Objects.equal(this.fromPort, that.fromPort)
|
||||
&& Objects.equal(this.toPort, that.toPort);
|
||||
}
|
||||
|
||||
protected ToStringHelper string() {
|
||||
return Objects.toStringHelper(this)
|
||||
.add("ipProtocol", ipProtocol).add("fromPort", fromPort).add("toPort", toPort);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return string().toString();
|
||||
}
|
||||
|
||||
protected ToStringHelper string() {
|
||||
return Objects.toStringHelper("").add("ipProtocol", ipProtocol).add("fromPort", fromPort).add("toPort", toPort);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
/*
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
|
@ -18,158 +18,169 @@
|
|||
*/
|
||||
package org.jclouds.openstack.nova.v2_0.domain;
|
||||
|
||||
import static com.google.common.base.Objects.toStringHelper;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
|
||||
import javax.inject.Named;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
|
||||
public class KeyPair implements Comparable<KeyPair> {
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
/**
|
||||
* Class KeyPair
|
||||
*/
|
||||
public class KeyPair {
|
||||
|
||||
public static Builder<?> builder() {
|
||||
return new ConcreteBuilder();
|
||||
}
|
||||
|
||||
public Builder toBuilder() {
|
||||
return builder().fromKeyPair(this);
|
||||
public Builder<?> toBuilder() {
|
||||
return new ConcreteBuilder().fromKeyPair(this);
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
public static abstract class Builder<T extends Builder<T>> {
|
||||
protected abstract T self();
|
||||
|
||||
private String publicKey;
|
||||
private String privateKey;
|
||||
private String userId;
|
||||
private String name;
|
||||
private String fingerprint;
|
||||
protected String publicKey;
|
||||
protected String privateKey;
|
||||
protected String userId;
|
||||
protected String name;
|
||||
protected String fingerprint;
|
||||
|
||||
public Builder publicKey(String publicKey) {
|
||||
/**
|
||||
* @see KeyPair#getPublicKey()
|
||||
*/
|
||||
public T publicKey(String publicKey) {
|
||||
this.publicKey = publicKey;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder privateKey(String privateKey) {
|
||||
/**
|
||||
* @see KeyPair#getPrivateKey()
|
||||
*/
|
||||
public T privateKey(String privateKey) {
|
||||
this.privateKey = privateKey;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder userId(String userId) {
|
||||
/**
|
||||
* @see KeyPair#getUserId()
|
||||
*/
|
||||
public T userId(String userId) {
|
||||
this.userId = userId;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder name(String name) {
|
||||
/**
|
||||
* @see KeyPair#getName()
|
||||
*/
|
||||
public T name(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder fingerprint(String fingerprint) {
|
||||
/**
|
||||
* @see KeyPair#getFingerprint()
|
||||
*/
|
||||
public T fingerprint(String fingerprint) {
|
||||
this.fingerprint = fingerprint;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public KeyPair build() {
|
||||
return new KeyPair(publicKey, privateKey, userId, name, fingerprint);
|
||||
}
|
||||
|
||||
public Builder fromKeyPair(KeyPair in) {
|
||||
return publicKey(in.getPublicKey()).privateKey(in.getPrivateKey()).userId(in.getUserId()).name(in.getName())
|
||||
.fingerprint(in.getFingerprint());
|
||||
public T fromKeyPair(KeyPair in) {
|
||||
return this
|
||||
.publicKey(in.getPublicKey())
|
||||
.privateKey(in.getPrivateKey())
|
||||
.userId(in.getUserId())
|
||||
.name(in.getName())
|
||||
.fingerprint(in.getFingerprint());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected KeyPair() {
|
||||
// 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 static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
@Override
|
||||
protected ConcreteBuilder self() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@SerializedName("public_key")
|
||||
private String publicKey;
|
||||
@SerializedName("private_key")
|
||||
private String privateKey;
|
||||
@SerializedName("user_id")
|
||||
private String userId;
|
||||
private String name;
|
||||
private String fingerprint;
|
||||
@Named("public_key")
|
||||
private final String publicKey;
|
||||
@Named("private_key")
|
||||
private final String privateKey;
|
||||
@Named("user_id")
|
||||
private final String userId;
|
||||
private final String name;
|
||||
private final String fingerprint;
|
||||
|
||||
protected KeyPair(String publicKey, String privateKey, @Nullable String userId, String name, String fingerprint) {
|
||||
@ConstructorProperties({
|
||||
"public_key", "private_key", "user_id", "name", "fingerprint"
|
||||
})
|
||||
protected KeyPair(@Nullable String publicKey, @Nullable String privateKey, @Nullable String userId, String name, @Nullable String fingerprint) {
|
||||
this.publicKey = publicKey;
|
||||
this.privateKey = privateKey;
|
||||
this.userId = userId;
|
||||
this.name = name;
|
||||
this.name = checkNotNull(name, "name");
|
||||
this.fingerprint = fingerprint;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getPublicKey() {
|
||||
return this.publicKey;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getPrivateKey() {
|
||||
return this.privateKey;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getUserId() {
|
||||
return this.privateKey;
|
||||
return this.userId;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getFingerprint() {
|
||||
return this.fingerprint;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(KeyPair o) {
|
||||
return this.fingerprint.compareTo(o.getFingerprint());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((publicKey == null) ? 0 : publicKey.hashCode());
|
||||
result = prime * result + ((privateKey == null) ? 0 : privateKey.hashCode());
|
||||
result = prime * result + ((name == null) ? 0 : name.hashCode());
|
||||
result = prime * result + ((fingerprint == null) ? 0 : fingerprint.hashCode());
|
||||
return result;
|
||||
return Objects.hashCode(publicKey, privateKey, userId, name, fingerprint);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
KeyPair other = (KeyPair) obj;
|
||||
if (publicKey == null) {
|
||||
if (other.publicKey != null)
|
||||
return false;
|
||||
} else if (!publicKey.equals(other.publicKey))
|
||||
return false;
|
||||
if (privateKey == null) {
|
||||
if (other.privateKey != null)
|
||||
return false;
|
||||
} else if (!privateKey.equals(other.privateKey))
|
||||
return false;
|
||||
if (name == null) {
|
||||
if (other.name != null)
|
||||
return false;
|
||||
} else if (!name.equals(other.name))
|
||||
return false;
|
||||
if (fingerprint == null) {
|
||||
if (other.fingerprint != null)
|
||||
return false;
|
||||
} else if (!fingerprint.equals(other.fingerprint))
|
||||
return false;
|
||||
return true;
|
||||
if (this == obj) return true;
|
||||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
KeyPair that = KeyPair.class.cast(obj);
|
||||
return Objects.equal(this.publicKey, that.publicKey)
|
||||
&& Objects.equal(this.privateKey, that.privateKey)
|
||||
&& Objects.equal(this.userId, that.userId)
|
||||
&& Objects.equal(this.name, that.name)
|
||||
&& Objects.equal(this.fingerprint, that.fingerprint);
|
||||
}
|
||||
|
||||
protected ToStringHelper string() {
|
||||
return Objects.toStringHelper(this)
|
||||
.add("publicKey", publicKey).add("privateKey", privateKey).add("userId", userId).add("name", name).add("fingerprint", fingerprint);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return toStringHelper("").add("userId", userId).add("name", name).add("fingerprint", fingerprint).toString();
|
||||
return string().toString();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
/*
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
|
@ -18,11 +18,13 @@
|
|||
*/
|
||||
package org.jclouds.openstack.nova.v2_0.domain;
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
|
||||
/**
|
||||
* Represents the set of limits (quota class) returned by the Quota Class Extension
|
||||
*
|
||||
* @see org.jclouds.openstack.nova.v2_0.extensions.QuotaClassClient
|
||||
*/
|
||||
*/
|
||||
public class QuotaClass extends Quotas {
|
||||
|
||||
public static Builder<?> builder() {
|
||||
|
@ -30,21 +32,18 @@ public class QuotaClass extends Quotas {
|
|||
}
|
||||
|
||||
public Builder<?> toBuilder() {
|
||||
return new ConcreteBuilder().fromQuotas(this);
|
||||
return new ConcreteBuilder().fromQuotaClass(this);
|
||||
}
|
||||
|
||||
public static abstract class Builder<T extends Builder<T>> extends Quotas.Builder<T> {
|
||||
/**
|
||||
* @see QuotaClass#getId()
|
||||
*/
|
||||
@Override
|
||||
public T id(String id) {
|
||||
return super.id(id);
|
||||
}
|
||||
public static abstract class Builder<T extends Builder<T>> extends Quotas.Builder<T> {
|
||||
|
||||
public QuotaClass build() {
|
||||
return new QuotaClass(this);
|
||||
return new QuotaClass(id, metadataItems, injectedFileContentBytes, volumes, gigabytes, ram, floatingIps, instances, injectedFiles, cores, securityGroups, securityGroupRules, keyPairs);
|
||||
}
|
||||
|
||||
public T fromQuotaClass(QuotaClass in) {
|
||||
return super.fromQuotas(in);
|
||||
}
|
||||
}
|
||||
|
||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
|
@ -54,15 +53,12 @@ public class QuotaClass extends Quotas {
|
|||
}
|
||||
}
|
||||
|
||||
protected QuotaClass(Builder<?> builder) {
|
||||
super(builder);
|
||||
|
||||
@ConstructorProperties({
|
||||
"id", "metadata_items", "injected_file_content_bytes", "volumes", "gigabytes", "ram", "floating_ips", "instances", "injected_files", "cores", "security_groups", "security_group_rules", "key_pairs"
|
||||
})
|
||||
protected QuotaClass(String id, int metadataItems, int injectedFileContentBytes, int volumes, int gigabytes, int ram, int floatingIps, int instances, int injectedFiles, int cores, int securityGroups, int securityGroupRules, int keyPairs) {
|
||||
super(id, metadataItems, injectedFileContentBytes, volumes, gigabytes, ram, floatingIps, instances, injectedFiles, cores, securityGroups, securityGroupRules, keyPairs);
|
||||
}
|
||||
|
||||
/**
|
||||
* The id of this Quota Class.
|
||||
*/
|
||||
@Override
|
||||
public String getId() {
|
||||
return super.getId();
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
/*
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
|
@ -20,15 +20,18 @@ package org.jclouds.openstack.nova.v2_0.domain;
|
|||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
|
||||
import javax.inject.Named;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
/**
|
||||
* Represents the set of limits (quotas) returned by the Quota Extension
|
||||
*
|
||||
* @see org.jclouds.openstack.nova.v2_0.extensions.QuotaClient
|
||||
*/
|
||||
*/
|
||||
public class Quotas {
|
||||
|
||||
public static Builder<?> builder() {
|
||||
|
@ -42,19 +45,19 @@ public class Quotas {
|
|||
public static abstract class Builder<T extends Builder<T>> {
|
||||
protected abstract T self();
|
||||
|
||||
private String id;
|
||||
private int metadataItems;
|
||||
private int injectedFileContentBytes;
|
||||
private int volumes;
|
||||
private int gigabytes;
|
||||
private int ram;
|
||||
private int floatingIps;
|
||||
private int instances;
|
||||
private int injectedFiles;
|
||||
private int cores;
|
||||
private int securityGroups;
|
||||
private int securityGroupRules;
|
||||
private int keyPairs;
|
||||
protected String id;
|
||||
protected int metadataItems;
|
||||
protected int injectedFileContentBytes;
|
||||
protected int volumes;
|
||||
protected int gigabytes;
|
||||
protected int ram;
|
||||
protected int floatingIps;
|
||||
protected int instances;
|
||||
protected int injectedFiles;
|
||||
protected int cores;
|
||||
protected int securityGroups;
|
||||
protected int securityGroupRules;
|
||||
protected int keyPairs;
|
||||
|
||||
/**
|
||||
* @see Quotas#getId()
|
||||
|
@ -161,23 +164,24 @@ public class Quotas {
|
|||
}
|
||||
|
||||
public Quotas build() {
|
||||
return new Quotas(this);
|
||||
return new Quotas(id, metadataItems, injectedFileContentBytes, volumes, gigabytes, ram, floatingIps, instances, injectedFiles, cores, securityGroups, securityGroupRules, keyPairs);
|
||||
}
|
||||
|
||||
public T fromQuotas(Quotas in) {
|
||||
return this.id(in.getId())
|
||||
.metadataItems(in.getMetadataItems())
|
||||
.injectedFileContentBytes(in.getInjectedFileContentBytes())
|
||||
.volumes(in.getVolumes())
|
||||
.gigabytes(in.getGigabytes())
|
||||
.ram(in.getRam())
|
||||
.floatingIps(in.getFloatingIps())
|
||||
.instances(in.getInstances())
|
||||
.injectedFiles(in.getInjectedFiles())
|
||||
.cores(in.getCores())
|
||||
.securityGroups(in.getSecurityGroups())
|
||||
.securityGroupRules(in.getSecurityGroupRules())
|
||||
.keyPairs(in.getKeyPairs());
|
||||
return this
|
||||
.id(in.getId())
|
||||
.metadataItems(in.getMetadataItems())
|
||||
.injectedFileContentBytes(in.getInjectedFileContentBytes())
|
||||
.volumes(in.getVolumes())
|
||||
.gigabytes(in.getGigabytes())
|
||||
.ram(in.getRam())
|
||||
.floatingIps(in.getFloatingIps())
|
||||
.instances(in.getInstances())
|
||||
.injectedFiles(in.getInjectedFiles())
|
||||
.cores(in.getCores())
|
||||
.securityGroups(in.getSecurityGroups())
|
||||
.securityGroupRules(in.getSecurityGroupRules())
|
||||
.keyPairs(in.getKeyPairs());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -188,48 +192,44 @@ public class Quotas {
|
|||
}
|
||||
}
|
||||
|
||||
protected Quotas() {
|
||||
// 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 final String id;
|
||||
@Named("metadata_items")
|
||||
private final int metadataItems;
|
||||
@Named("injected_file_content_bytes")
|
||||
private final int injectedFileContentBytes;
|
||||
private final int volumes;
|
||||
private final int gigabytes;
|
||||
private final int ram;
|
||||
@Named("floating_ips")
|
||||
private final int floatingIps;
|
||||
private final int instances;
|
||||
@Named("injected_files")
|
||||
private final int injectedFiles;
|
||||
private final int cores;
|
||||
@Named("security_groups")
|
||||
private final int securityGroups;
|
||||
@Named("security_group_rules")
|
||||
private final int securityGroupRules;
|
||||
@Named("key_pairs")
|
||||
private final int keyPairs;
|
||||
|
||||
@SerializedName("id")
|
||||
private String id;
|
||||
@SerializedName("metadata_items")
|
||||
private int metadataItems;
|
||||
@SerializedName("injected_file_content_bytes")
|
||||
private int injectedFileContentBytes;
|
||||
private int volumes;
|
||||
private int gigabytes;
|
||||
private int ram;
|
||||
@SerializedName("floating_ips")
|
||||
private int floatingIps;
|
||||
private int instances;
|
||||
@SerializedName("injected_files")
|
||||
private int injectedFiles;
|
||||
private int cores;
|
||||
@SerializedName("security_groups")
|
||||
private int securityGroups;
|
||||
@SerializedName("security_group_rules")
|
||||
private int securityGroupRules;
|
||||
@SerializedName("key_pairs")
|
||||
private int keyPairs;
|
||||
|
||||
protected Quotas(Builder<?> builder) {
|
||||
this.id = checkNotNull(builder.id, "id");
|
||||
this.metadataItems = checkNotNull(builder.metadataItems, "metadataItems");
|
||||
this.injectedFileContentBytes = checkNotNull(builder.injectedFileContentBytes, "injectedFileContentBytes");
|
||||
this.volumes = checkNotNull(builder.volumes, "volumes");
|
||||
this.gigabytes = checkNotNull(builder.gigabytes, "gigabytes");
|
||||
this.ram = checkNotNull(builder.ram, "ram");
|
||||
this.floatingIps = checkNotNull(builder.floatingIps, "floatingIps");
|
||||
this.instances = checkNotNull(builder.instances, "instances");
|
||||
this.injectedFiles = checkNotNull(builder.injectedFiles, "injectedFiles");
|
||||
this.cores = checkNotNull(builder.cores, "cores");
|
||||
this.securityGroups = checkNotNull(builder.securityGroups, "securityGroups");
|
||||
this.securityGroupRules = checkNotNull(builder.securityGroupRules, "securityGroupRules");
|
||||
this.keyPairs = checkNotNull(builder.keyPairs, "keyPairs");
|
||||
@ConstructorProperties({
|
||||
"id", "metadata_items", "injected_file_content_bytes", "volumes", "gigabytes", "ram", "floating_ips", "instances", "injected_files", "cores", "security_groups", "security_group_rules", "key_pairs"
|
||||
})
|
||||
protected Quotas(String id, int metadataItems, int injectedFileContentBytes, int volumes, int gigabytes, int ram, int floatingIps, int instances, int injectedFiles, int cores, int securityGroups, int securityGroupRules, int keyPairs) {
|
||||
this.id = checkNotNull(id, "id");
|
||||
this.metadataItems = metadataItems;
|
||||
this.injectedFileContentBytes = injectedFileContentBytes;
|
||||
this.volumes = volumes;
|
||||
this.gigabytes = gigabytes;
|
||||
this.ram = ram;
|
||||
this.floatingIps = floatingIps;
|
||||
this.instances = instances;
|
||||
this.injectedFiles = injectedFiles;
|
||||
this.cores = cores;
|
||||
this.securityGroups = securityGroups;
|
||||
this.securityGroupRules = securityGroupRules;
|
||||
this.keyPairs = keyPairs;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -298,7 +298,6 @@ public class Quotas {
|
|||
|
||||
/**
|
||||
* @return the limit of the number of security groups that can be created for the tenant
|
||||
*
|
||||
* @see org.jclouds.openstack.nova.v2_0.extensions.SecurityGroupClient
|
||||
*/
|
||||
public int getSecurityGroups() {
|
||||
|
@ -307,7 +306,6 @@ public class Quotas {
|
|||
|
||||
/**
|
||||
* @return the limit of the number of security group rules that can be created for the tenant
|
||||
*
|
||||
* @see org.jclouds.openstack.nova.v2_0.extensions.SecurityGroupClient
|
||||
*/
|
||||
public int getSecurityGroupRules() {
|
||||
|
@ -316,7 +314,6 @@ public class Quotas {
|
|||
|
||||
/**
|
||||
* @return the limit of the number of key pairs that can be created for the tenant
|
||||
*
|
||||
* @see org.jclouds.openstack.nova.v2_0.extensions.KeyPairClient
|
||||
*/
|
||||
public int getKeyPairs() {
|
||||
|
@ -334,35 +331,23 @@ public class Quotas {
|
|||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
Quotas that = Quotas.class.cast(obj);
|
||||
return Objects.equal(this.id, that.id)
|
||||
&& Objects.equal(this.metadataItems, that.metadataItems)
|
||||
&& Objects.equal(this.injectedFileContentBytes, that.injectedFileContentBytes)
|
||||
&& Objects.equal(this.volumes, that.volumes)
|
||||
&& Objects.equal(this.gigabytes, that.gigabytes)
|
||||
&& Objects.equal(this.ram, that.ram)
|
||||
&& Objects.equal(this.floatingIps, that.floatingIps)
|
||||
&& Objects.equal(this.instances, that.instances)
|
||||
&& Objects.equal(this.injectedFiles, that.injectedFiles)
|
||||
&& Objects.equal(this.cores, that.cores)
|
||||
&& Objects.equal(this.securityGroups, that.securityGroups)
|
||||
&& Objects.equal(this.securityGroupRules, that.securityGroupRules)
|
||||
&& Objects.equal(this.keyPairs, that.keyPairs);
|
||||
&& Objects.equal(this.metadataItems, that.metadataItems)
|
||||
&& Objects.equal(this.injectedFileContentBytes, that.injectedFileContentBytes)
|
||||
&& Objects.equal(this.volumes, that.volumes)
|
||||
&& Objects.equal(this.gigabytes, that.gigabytes)
|
||||
&& Objects.equal(this.ram, that.ram)
|
||||
&& Objects.equal(this.floatingIps, that.floatingIps)
|
||||
&& Objects.equal(this.instances, that.instances)
|
||||
&& Objects.equal(this.injectedFiles, that.injectedFiles)
|
||||
&& Objects.equal(this.cores, that.cores)
|
||||
&& Objects.equal(this.securityGroups, that.securityGroups)
|
||||
&& Objects.equal(this.securityGroupRules, that.securityGroupRules)
|
||||
&& Objects.equal(this.keyPairs, that.keyPairs);
|
||||
}
|
||||
|
||||
protected ToStringHelper string() {
|
||||
return Objects.toStringHelper("")
|
||||
.add("id", id)
|
||||
.add("metadataItems", metadataItems)
|
||||
.add("injectedFileContentBytes", injectedFileContentBytes)
|
||||
.add("volumes", volumes)
|
||||
.add("gigabytes", gigabytes)
|
||||
.add("ram", ram)
|
||||
.add("floatingIps", floatingIps)
|
||||
.add("instances", instances)
|
||||
.add("injectedFiles", injectedFiles)
|
||||
.add("cores", cores)
|
||||
.add("securityGroups", securityGroups)
|
||||
.add("securityGroupRules", securityGroupRules)
|
||||
.add("keyPairs", keyPairs);
|
||||
return Objects.toStringHelper(this)
|
||||
.add("id", id).add("metadataItems", metadataItems).add("injectedFileContentBytes", injectedFileContentBytes).add("volumes", volumes).add("gigabytes", gigabytes).add("ram", ram).add("floatingIps", floatingIps).add("instances", instances).add("injectedFiles", injectedFiles).add("cores", cores).add("securityGroups", securityGroups).add("securityGroupRules", securityGroupRules).add("keyPairs", keyPairs);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
/*
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
|
@ -18,107 +18,118 @@
|
|||
*/
|
||||
package org.jclouds.openstack.nova.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.beans.ConstructorProperties;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.inject.Named;
|
||||
|
||||
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;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
/**
|
||||
* Defines a security group
|
||||
*
|
||||
*/
|
||||
*/
|
||||
public class SecurityGroup {
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
|
||||
public static Builder<?> builder() {
|
||||
return new ConcreteBuilder();
|
||||
}
|
||||
|
||||
public Builder toBuilder() {
|
||||
return builder().fromSecurityGroup(this);
|
||||
public Builder<?> toBuilder() {
|
||||
return new ConcreteBuilder().fromSecurityGroup(this);
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
public static abstract class Builder<T extends Builder<T>> {
|
||||
protected abstract T self();
|
||||
|
||||
private String id;
|
||||
private String tenantId;
|
||||
private String name;
|
||||
private String description;
|
||||
private Set<SecurityGroupRule> rules = ImmutableSet.<SecurityGroupRule> of();
|
||||
protected String id;
|
||||
protected String tenantId;
|
||||
protected String name;
|
||||
protected String description;
|
||||
protected Set<SecurityGroupRule> rules = ImmutableSet.of();
|
||||
|
||||
public Builder id(String id) {
|
||||
/**
|
||||
* @see SecurityGroup#getId()
|
||||
*/
|
||||
public T id(String id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder tenantId(String tenantId) {
|
||||
/**
|
||||
* @see SecurityGroup#getTenantId()
|
||||
*/
|
||||
public T tenantId(String tenantId) {
|
||||
this.tenantId = tenantId;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder name(String name) {
|
||||
/**
|
||||
* @see SecurityGroup#getName()
|
||||
*/
|
||||
public T name(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder description(String description) {
|
||||
/**
|
||||
* @see SecurityGroup#getDescription()
|
||||
*/
|
||||
public T description(String description) {
|
||||
this.description = description;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @see #getSecurityGroupNames
|
||||
* @see SecurityGroup#getRules()
|
||||
*/
|
||||
public Builder rules(SecurityGroupRule... rules) {
|
||||
return rules(ImmutableSet.copyOf(checkNotNull(rules, "rules")));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see #getSecurityGroupNames
|
||||
*/
|
||||
public Builder rules(Iterable<SecurityGroupRule> rules) {
|
||||
public T rules(Set<SecurityGroupRule> rules) {
|
||||
this.rules = ImmutableSet.copyOf(checkNotNull(rules, "rules"));
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder rules(Set<SecurityGroupRule> rules) {
|
||||
this.rules = rules;
|
||||
return this;
|
||||
public T rules(SecurityGroupRule... in) {
|
||||
return rules(ImmutableSet.copyOf(in));
|
||||
}
|
||||
|
||||
public SecurityGroup build() {
|
||||
return new SecurityGroup(id, tenantId, name, description, rules);
|
||||
}
|
||||
|
||||
public Builder fromSecurityGroup(SecurityGroup in) {
|
||||
return id(in.getId()).tenantId(in.getTenantId()).name(in.getName()).description(in.getDescription()).rules(
|
||||
in.getRules());
|
||||
public T fromSecurityGroup(SecurityGroup in) {
|
||||
return this
|
||||
.id(in.getId())
|
||||
.tenantId(in.getTenantId())
|
||||
.name(in.getName())
|
||||
.description(in.getDescription())
|
||||
.rules(in.getRules());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected SecurityGroup() {
|
||||
// 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 static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
@Override
|
||||
protected ConcreteBuilder self() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
protected String id;
|
||||
@SerializedName("tenant_id")
|
||||
protected String tenantId;
|
||||
protected String name;
|
||||
protected String description;
|
||||
protected Set<SecurityGroupRule> rules = ImmutableSet.of();
|
||||
private final String id;
|
||||
@Named("tenant_id")
|
||||
private final String tenantId;
|
||||
private final String name;
|
||||
private final String description;
|
||||
private final Set<SecurityGroupRule> rules;
|
||||
|
||||
protected SecurityGroup(String id, String tenantId, @Nullable String name, @Nullable String description,
|
||||
Set<SecurityGroupRule> rules) {
|
||||
this.id = id;
|
||||
@ConstructorProperties({
|
||||
"id", "tenant_id", "name", "description", "rules"
|
||||
})
|
||||
protected SecurityGroup(String id, @Nullable String tenantId, @Nullable String name, @Nullable String description, Set<SecurityGroupRule> rules) {
|
||||
this.id = checkNotNull(id, "id");
|
||||
this.tenantId = tenantId;
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
|
@ -130,44 +141,50 @@ public class SecurityGroup {
|
|||
return this.id;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getTenantId() {
|
||||
return this.tenantId;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getDescription() {
|
||||
return this.description;
|
||||
}
|
||||
|
||||
public Set<SecurityGroupRule> getRules() {
|
||||
return this.rules == null ? ImmutableSet.<SecurityGroupRule> of() : rules;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object object) {
|
||||
if (this == object) {
|
||||
return true;
|
||||
}
|
||||
if (object instanceof SecurityGroup) {
|
||||
final SecurityGroup other = SecurityGroup.class.cast(object);
|
||||
return equal(tenantId, other.tenantId) && equal(id, other.id) && equal(name, other.name);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return this.rules;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(tenantId, id, name);
|
||||
return Objects.hashCode(id, tenantId, name, description, rules);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
SecurityGroup that = SecurityGroup.class.cast(obj);
|
||||
return Objects.equal(this.id, that.id)
|
||||
&& Objects.equal(this.tenantId, that.tenantId)
|
||||
&& Objects.equal(this.name, that.name)
|
||||
&& Objects.equal(this.description, that.description)
|
||||
&& Objects.equal(this.rules, that.rules);
|
||||
}
|
||||
|
||||
protected ToStringHelper string() {
|
||||
return Objects.toStringHelper(this)
|
||||
.add("id", id).add("tenantId", tenantId).add("name", name).add("description", description).add("rules", rules);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return toStringHelper("").add("tenantId", getTenantId()).add("id", getId()).add("name", getName()).add(
|
||||
"description", description).add("rules", getRules()).toString();
|
||||
return string().toString();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
/*
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
|
@ -18,99 +18,24 @@
|
|||
*/
|
||||
package org.jclouds.openstack.nova.v2_0.domain;
|
||||
|
||||
import static com.google.common.base.Objects.toStringHelper;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
|
||||
import javax.inject.Named;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
import com.google.common.collect.ForwardingObject;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
/**
|
||||
* Defines a security group rule
|
||||
*
|
||||
*/
|
||||
public class SecurityGroupRule extends Ingress {
|
||||
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
public Builder toBuilder() {
|
||||
return builder().fromSecurityGroupRule(this);
|
||||
}
|
||||
|
||||
public static class Builder extends Ingress.Builder {
|
||||
private String id;
|
||||
private String parentGroupId;
|
||||
private TenantIdAndName group;
|
||||
private String ipRange;
|
||||
|
||||
public Builder id(String id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder group(TenantIdAndName group) {
|
||||
this.group = group;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder parentGroupId(String parentGroupId) {
|
||||
this.parentGroupId = parentGroupId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder ipRange(String ipRange) {
|
||||
this.ipRange = ipRange;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SecurityGroupRule build() {
|
||||
return new SecurityGroupRule(ipProtocol, fromPort, toPort, id, parentGroupId, group, ipRange);
|
||||
}
|
||||
|
||||
public Builder fromSecurityGroupRule(SecurityGroupRule in) {
|
||||
return id(in.getId()).fromPort(in.getFromPort()).group(in.getGroup()).ipProtocol(in.getIpProtocol()).toPort(
|
||||
in.getToPort()).parentGroupId(in.getParentGroupId()).ipRange(in.getIpRange());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Builder ipProtocol(IpProtocol ipProtocol) {
|
||||
super.ipProtocol(ipProtocol);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Builder fromPort(int fromPort) {
|
||||
super.fromPort(fromPort);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Builder toPort(int toPort) {
|
||||
super.toPort(toPort);
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected SecurityGroupRule() {
|
||||
// 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
|
||||
}
|
||||
|
||||
protected String id;
|
||||
protected TenantIdAndName group;
|
||||
@SerializedName(value = "parent_group_id")
|
||||
protected String parentGroupId;
|
||||
@SerializedName(value = "ip_range")
|
||||
protected Cidr ipRange;
|
||||
|
||||
// type to get around unnecessary structure
|
||||
private static class Cidr extends ForwardingObject {
|
||||
public static class Cidr extends ForwardingObject {
|
||||
private String cidr;
|
||||
|
||||
private Cidr(String cidr) {
|
||||
|
@ -123,18 +48,88 @@ public class SecurityGroupRule extends Ingress {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
protected SecurityGroupRule(IpProtocol ipProtocol, int fromPort, int toPort, String id, String parentGroupId,
|
||||
@Nullable TenantIdAndName group, @Nullable String ipRange) {
|
||||
super(ipProtocol, fromPort, toPort);
|
||||
this.parentGroupId = checkNotNull(parentGroupId, "parentGroupId");
|
||||
this.id = checkNotNull(id, "id");
|
||||
this.group = group;
|
||||
this.ipRange = ipRange != null ? new Cidr(ipRange) : null;
|
||||
public static Builder<?> builder() {
|
||||
return new ConcreteBuilder();
|
||||
}
|
||||
|
||||
public String getParentGroupId() {
|
||||
return this.parentGroupId;
|
||||
public Builder<?> toBuilder() {
|
||||
return new ConcreteBuilder().fromSecurityGroupRule(this);
|
||||
}
|
||||
|
||||
public static abstract class Builder<T extends Builder<T>> extends Ingress.Builder<T> {
|
||||
protected String id;
|
||||
protected TenantIdAndName group;
|
||||
protected String parentGroupId;
|
||||
protected String ipRange;
|
||||
|
||||
/**
|
||||
* @see SecurityGroupRule#getId()
|
||||
*/
|
||||
public T id(String id) {
|
||||
this.id = id;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see SecurityGroupRule#getGroup()
|
||||
*/
|
||||
public T group(TenantIdAndName group) {
|
||||
this.group = group;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see SecurityGroupRule#getParentGroupId()
|
||||
*/
|
||||
public T parentGroupId(String parentGroupId) {
|
||||
this.parentGroupId = parentGroupId;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see SecurityGroupRule#getIpRange()
|
||||
*/
|
||||
public T ipRange(String ipRange) {
|
||||
this.ipRange = ipRange;
|
||||
return self();
|
||||
}
|
||||
|
||||
public SecurityGroupRule build() {
|
||||
return new SecurityGroupRule(ipProtocol, fromPort, toPort, id, group, parentGroupId, ipRange == null ? null : new Cidr(ipRange));
|
||||
}
|
||||
|
||||
public T fromSecurityGroupRule(SecurityGroupRule in) {
|
||||
return super.fromIngress(in)
|
||||
.id(in.getId())
|
||||
.group(in.getGroup())
|
||||
.parentGroupId(in.getParentGroupId())
|
||||
.ipRange(in.getIpRange());
|
||||
}
|
||||
}
|
||||
|
||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
@Override
|
||||
protected ConcreteBuilder self() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
private final String id;
|
||||
private final TenantIdAndName group;
|
||||
@Named("parent_group_id")
|
||||
private final String parentGroupId;
|
||||
@Named("ip_range")
|
||||
private final SecurityGroupRule.Cidr ipRange;
|
||||
|
||||
@ConstructorProperties({
|
||||
"ip_protocol", "from_port", "to_port", "id", "group", "parent_group_id", "ip_range"
|
||||
})
|
||||
protected SecurityGroupRule(IpProtocol ipProtocol, int fromPort, int toPort, String id, @Nullable TenantIdAndName group, String parentGroupId, @Nullable Cidr ipRange) {
|
||||
super(ipProtocol, fromPort, toPort);
|
||||
this.id = checkNotNull(id, "id");
|
||||
this.group = group;
|
||||
this.parentGroupId = checkNotNull(parentGroupId, "parentGroupId");
|
||||
this.ipRange = ipRange;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
|
@ -143,73 +138,37 @@ public class SecurityGroupRule extends Ingress {
|
|||
|
||||
@Nullable
|
||||
public TenantIdAndName getGroup() {
|
||||
if (this.group == null || this.group.getName() == null)
|
||||
return null;
|
||||
return this.group;
|
||||
}
|
||||
|
||||
public String getParentGroupId() {
|
||||
return this.parentGroupId;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getIpRange() {
|
||||
return this.ipRange == null ? null : ipRange.cidr;
|
||||
return ipRange == null ? null : ipRange.cidr;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + fromPort;
|
||||
result = prime * result + ((group == null) ? 0 : group.hashCode());
|
||||
result = prime * result + ((id == null) ? 0 : id.hashCode());
|
||||
result = prime * result + ((ipProtocol == null) ? 0 : ipProtocol.hashCode());
|
||||
result = prime * result + ((ipRange == null) ? 0 : ipRange.hashCode());
|
||||
result = prime * result + ((parentGroupId == null) ? 0 : parentGroupId.hashCode());
|
||||
result = prime * result + toPort;
|
||||
return result;
|
||||
return Objects.hashCode(id, group, parentGroupId, ipRange);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
SecurityGroupRule other = (SecurityGroupRule) obj;
|
||||
if (fromPort != other.fromPort)
|
||||
return false;
|
||||
if (group == null) {
|
||||
if (other.group != null)
|
||||
return false;
|
||||
} else if (!group.equals(other.group))
|
||||
return false;
|
||||
if (id == null) {
|
||||
if (other.id != null)
|
||||
return false;
|
||||
} else if (!id.equals(other.id))
|
||||
return false;
|
||||
if (ipProtocol != other.ipProtocol)
|
||||
return false;
|
||||
if (ipRange == null) {
|
||||
if (other.ipRange != null)
|
||||
return false;
|
||||
} else if (!ipRange.equals(other.ipRange))
|
||||
return false;
|
||||
if (parentGroupId == null) {
|
||||
if (other.parentGroupId != null)
|
||||
return false;
|
||||
} else if (!parentGroupId.equals(other.parentGroupId))
|
||||
return false;
|
||||
if (toPort != other.toPort)
|
||||
return false;
|
||||
return true;
|
||||
if (this == obj) return true;
|
||||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
SecurityGroupRule that = SecurityGroupRule.class.cast(obj);
|
||||
return super.equals(that) && Objects.equal(this.id, that.id)
|
||||
&& Objects.equal(this.group, that.group)
|
||||
&& Objects.equal(this.parentGroupId, that.parentGroupId)
|
||||
&& Objects.equal(this.ipRange, that.ipRange);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return toStringHelper("").add("id", id).add("fromPort", fromPort).add("group", getGroup()).add("ipProtocol",
|
||||
ipProtocol).add("toPort", toPort).add("parentGroupId", parentGroupId).add("ipRange", getIpRange())
|
||||
.toString();
|
||||
protected ToStringHelper string() {
|
||||
return super.string()
|
||||
.add("id", id).add("group", group).add("parentGroupId", parentGroupId).add("ipRange", ipRange);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
/*
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
|
@ -20,24 +20,28 @@ package org.jclouds.openstack.nova.v2_0.domain;
|
|||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.inject.Named;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
import org.jclouds.openstack.nova.v2_0.extensions.KeyPairClient;
|
||||
import org.jclouds.openstack.v2_0.domain.Link;
|
||||
import org.jclouds.openstack.v2_0.domain.Resource;
|
||||
import org.jclouds.util.Multimaps2;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
import com.google.common.base.Optional;
|
||||
import com.google.common.base.Predicates;
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableMultimap;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Multimap;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
/**
|
||||
* A server is a virtual machine instance in the compute system. Flavor and image are requisite
|
||||
|
@ -53,7 +57,7 @@ public class Server extends Resource {
|
|||
/**
|
||||
* Servers contain a status attribute that can be used as an indication of the current server
|
||||
* state. Servers with an ACTIVE status are available for use.
|
||||
*
|
||||
* <p/>
|
||||
* Other possible values for the status attribute include: BUILD, REBUILD, SUSPENDED, RESIZE,
|
||||
* VERIFY_RESIZE, REVERT_RESIZE, PASSWORD, REBOOT, HARD_REBOOT, DELETED, UNKNOWN, and ERROR.
|
||||
*
|
||||
|
@ -76,7 +80,6 @@ public class Server extends Resource {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
public static Builder<?> builder() {
|
||||
return new ConcreteBuilder();
|
||||
}
|
||||
|
@ -85,28 +88,25 @@ public class Server extends Resource {
|
|||
return new ConcreteBuilder().fromServer(this);
|
||||
}
|
||||
|
||||
public static abstract class Builder<T extends Builder<T>> extends Resource.Builder<T> {
|
||||
private String uuid;
|
||||
private String tenantId;
|
||||
private String userId;
|
||||
private Date updated;
|
||||
private Date created;
|
||||
private String hostId;
|
||||
private String accessIPv4;
|
||||
private String accessIPv6;
|
||||
private Server.Status status;
|
||||
private Resource image;
|
||||
private Resource flavor;
|
||||
private String keyName;
|
||||
private String configDrive;
|
||||
private Multimap<String, Address> addresses = ImmutableMultimap.of();
|
||||
private Map<String, String> metadata = ImmutableMap.of();
|
||||
// Extended status extension
|
||||
private ServerExtendedStatus extendedStatus;
|
||||
// Extended server attributes extension
|
||||
private ServerExtendedAttributes extendedAttributes;
|
||||
// Disk Config extension
|
||||
private String diskConfig;
|
||||
public static abstract class Builder<T extends Builder<T>> extends Resource.Builder<T> {
|
||||
protected String uuid;
|
||||
protected String tenantId;
|
||||
protected String userId;
|
||||
protected Date updated;
|
||||
protected Date created;
|
||||
protected String hostId;
|
||||
protected String accessIPv4;
|
||||
protected String accessIPv6;
|
||||
protected Server.Status status;
|
||||
protected Resource image;
|
||||
protected Resource flavor;
|
||||
protected String keyName;
|
||||
protected String configDrive;
|
||||
protected Multimap<String, Address> addresses = ImmutableMultimap.of();
|
||||
protected Map<String, String> metadata = ImmutableMap.of();
|
||||
protected ServerExtendedStatus extendedStatus;
|
||||
protected ServerExtendedAttributes extendedAttributes;
|
||||
protected String diskConfig;
|
||||
|
||||
/**
|
||||
* @see Server#getUuid()
|
||||
|
@ -224,7 +224,7 @@ public class Server extends Resource {
|
|||
* @see Server#getMetadata()
|
||||
*/
|
||||
public T metadata(Map<String, String> metadata) {
|
||||
this.metadata = metadata;
|
||||
this.metadata = ImmutableMap.copyOf(checkNotNull(metadata, "metadata"));
|
||||
return self();
|
||||
}
|
||||
|
||||
|
@ -239,7 +239,7 @@ public class Server extends Resource {
|
|||
/**
|
||||
* @see Server#getExtendedAttributes()
|
||||
*/
|
||||
public T extraAttributes(ServerExtendedAttributes extendedAttributes) {
|
||||
public T extendedAttributes(ServerExtendedAttributes extendedAttributes) {
|
||||
this.extendedAttributes = extendedAttributes;
|
||||
return self();
|
||||
}
|
||||
|
@ -253,7 +253,9 @@ public class Server extends Resource {
|
|||
}
|
||||
|
||||
public Server build() {
|
||||
return new Server(this);
|
||||
return new Server(id, name, links, uuid, tenantId, userId, updated, created, hostId, accessIPv4, accessIPv6,
|
||||
status, image, flavor, keyName, configDrive, Multimaps2.toOldSchool(addresses), metadata, extendedStatus,
|
||||
extendedAttributes, diskConfig);
|
||||
}
|
||||
|
||||
public T fromServer(Server in) {
|
||||
|
@ -274,7 +276,7 @@ public class Server extends Resource {
|
|||
.addresses(in.getAddresses())
|
||||
.metadata(in.getMetadata())
|
||||
.extendedStatus(in.getExtendedStatus().orNull())
|
||||
.extraAttributes(in.getExtendedAttributes().orNull())
|
||||
.extendedAttributes(in.getExtendedAttributes().orNull())
|
||||
.diskConfig(in.getDiskConfig().orNull());
|
||||
}
|
||||
}
|
||||
|
@ -286,62 +288,58 @@ public class Server extends Resource {
|
|||
}
|
||||
}
|
||||
|
||||
protected Server() {
|
||||
// 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 final String uuid;
|
||||
@Named("tenant_id")
|
||||
private final String tenantId;
|
||||
@Named("user_id")
|
||||
private final String userId;
|
||||
private final Date updated;
|
||||
private final Date created;
|
||||
private final String hostId;
|
||||
private final String accessIPv4;
|
||||
private final String accessIPv6;
|
||||
private final Server.Status status;
|
||||
private final Resource image;
|
||||
private final Resource flavor;
|
||||
@Named("key_name")
|
||||
private final String keyName;
|
||||
@Named("config_drive")
|
||||
private final String configDrive;
|
||||
private final Map<String, Set<Address>> addresses;
|
||||
private final Map<String, String> metadata;
|
||||
private final Optional<ServerExtendedStatus> extendedStatus;
|
||||
private final Optional<ServerExtendedAttributes> extendedAttributes;
|
||||
@Named("OS-DCF:diskConfig")
|
||||
private final Optional<String> diskConfig;
|
||||
|
||||
private String uuid;
|
||||
@SerializedName("tenant_id")
|
||||
private String tenantId;
|
||||
@SerializedName("user_id")
|
||||
private String userId;
|
||||
private Date updated;
|
||||
private Date created;
|
||||
private String hostId;
|
||||
private String accessIPv4;
|
||||
private String accessIPv6;
|
||||
private Status status;
|
||||
private Resource image;
|
||||
private Resource flavor;
|
||||
@SerializedName("key_name")
|
||||
private String keyName;
|
||||
@SerializedName("config_drive")
|
||||
private String configDrive;
|
||||
// TODO: get gson multimap adapter!
|
||||
private Map<String, Set<Address>> addresses = ImmutableMap.of();
|
||||
private Map<String, String> metadata = ImmutableMap.of();
|
||||
// Extended status extension
|
||||
// @Prefixed("OS-EXT-STS:")
|
||||
private Optional<ServerExtendedStatus> extendedStatus = Optional.absent();
|
||||
// Extended server attributes extension
|
||||
// @Prefixed("OS-EXT-SRV-ATTR:")
|
||||
private Optional<ServerExtendedAttributes> extendedAttributes = Optional.absent();
|
||||
// Disk Config extension
|
||||
@SerializedName("OS-DCF:diskConfig")
|
||||
private Optional<String> diskConfig = Optional.absent();
|
||||
|
||||
protected Server(Builder<?> builder) {
|
||||
super(builder);
|
||||
this.uuid = builder.uuid; // TODO: see what version this came up in
|
||||
this.tenantId = checkNotNull(builder.tenantId, "tenantId");
|
||||
this.userId = checkNotNull(builder.userId, "userId");
|
||||
this.updated = checkNotNull(builder.updated, "updated");
|
||||
this.created = checkNotNull(builder.created, "created");
|
||||
this.hostId = builder.hostId;
|
||||
this.accessIPv4 = builder.accessIPv4;
|
||||
this.accessIPv6 = builder.accessIPv6;
|
||||
this.status = checkNotNull(builder.status, "status");
|
||||
this.configDrive = builder.configDrive;
|
||||
this.image = checkNotNull(builder.image, "image");
|
||||
this.flavor = checkNotNull(builder.flavor, "flavor");
|
||||
this.metadata = Maps.newHashMap(builder.metadata);
|
||||
this.addresses = Multimaps2.toOldSchool(ImmutableMultimap.copyOf(checkNotNull(builder.addresses, "addresses")));
|
||||
this.keyName = builder.keyName;
|
||||
this.extendedStatus = Optional.fromNullable(builder.extendedStatus);
|
||||
this.extendedAttributes = Optional.fromNullable(builder.extendedAttributes);
|
||||
this.diskConfig = builder.diskConfig == null ? Optional.<String>absent() : Optional.of(builder.diskConfig);
|
||||
@ConstructorProperties({
|
||||
"id", "name", "links", "uuid", "tenant_id", "user_id", "updated", "created", "hostId", "accessIPv4", "accessIPv6", "status", "image", "flavor", "key_name", "config_drive", "addresses", "metadata", "extendedStatus", "extendedAttributes", "OS-DCF:diskConfig"
|
||||
})
|
||||
protected Server(String id, @Nullable String name, java.util.Set<Link> links, @Nullable String uuid, String tenantId,
|
||||
String userId, @Nullable Date updated, Date created, @Nullable String hostId, @Nullable String accessIPv4,
|
||||
@Nullable String accessIPv6, Server.Status status, Resource image, Resource flavor, @Nullable String keyName,
|
||||
@Nullable String configDrive, Map<String, Set<Address>> addresses, Map<String, String> metadata,
|
||||
@Nullable ServerExtendedStatus extendedStatus, @Nullable ServerExtendedAttributes extendedAttributes,
|
||||
@Nullable String diskConfig) {
|
||||
super(id, name, links);
|
||||
this.uuid = uuid;
|
||||
this.tenantId = checkNotNull(tenantId, "tenantId");
|
||||
this.userId = checkNotNull(userId, "userId");
|
||||
this.updated = updated;
|
||||
this.created = checkNotNull(created, "created");
|
||||
this.hostId = Strings.emptyToNull(hostId);
|
||||
this.accessIPv4 = Strings.emptyToNull(accessIPv4);
|
||||
this.accessIPv6 = Strings.emptyToNull(accessIPv6);
|
||||
this.status = checkNotNull(status, "status");
|
||||
this.image = checkNotNull(image, "image");
|
||||
this.flavor = checkNotNull(flavor, "flavor");
|
||||
this.keyName = Strings.emptyToNull(keyName);
|
||||
this.configDrive = Strings.emptyToNull(configDrive);
|
||||
this.addresses = ImmutableMap.copyOf(checkNotNull(addresses, "addresses"));
|
||||
this.metadata = ImmutableMap.copyOf(checkNotNull(metadata, "metadata"));
|
||||
this.extendedStatus = Optional.fromNullable(extendedStatus);
|
||||
this.extendedAttributes = Optional.fromNullable(extendedAttributes);
|
||||
this.diskConfig = Optional.fromNullable(diskConfig);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -362,6 +360,7 @@ public class Server extends Resource {
|
|||
return this.userId;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Date getUpdated() {
|
||||
return this.updated;
|
||||
}
|
||||
|
@ -375,17 +374,17 @@ public class Server extends Resource {
|
|||
*/
|
||||
@Nullable
|
||||
public String getHostId() {
|
||||
return Strings.emptyToNull(this.hostId);
|
||||
return this.hostId;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getAccessIPv4() {
|
||||
return Strings.emptyToNull(this.accessIPv4);
|
||||
return this.accessIPv4;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getAccessIPv6() {
|
||||
return Strings.emptyToNull(this.accessIPv6);
|
||||
return this.accessIPv6;
|
||||
}
|
||||
|
||||
public Status getStatus() {
|
||||
|
@ -394,7 +393,7 @@ public class Server extends Resource {
|
|||
|
||||
@Nullable
|
||||
public String getConfigDrive() {
|
||||
return Strings.emptyToNull(this.configDrive);
|
||||
return this.configDrive;
|
||||
}
|
||||
|
||||
public Resource getImage() {
|
||||
|
@ -426,7 +425,6 @@ public class Server extends Resource {
|
|||
return keyName;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Retrieves the extended server status fields (alias "OS-EXT-STS")
|
||||
* <p/>
|
||||
|
@ -468,11 +466,12 @@ public class Server extends Resource {
|
|||
|
||||
@Override
|
||||
protected ToStringHelper string() {
|
||||
return super.string().add("uuid", uuid).add("tenantId", tenantId).add(
|
||||
"userId", userId).add("hostId", getHostId()).add("updated", updated).add("created", created).add(
|
||||
"accessIPv4", getAccessIPv4()).add("accessIPv6", getAccessIPv6()).add("status", status).add(
|
||||
"configDrive", getConfigDrive()).add("image", image).add("flavor", flavor).add("metadata", metadata)
|
||||
.add("addresses", getAddresses()).add("diskConfig", diskConfig)
|
||||
.add("extendedStatus", extendedStatus).add("extendedAttributes", extendedAttributes);
|
||||
return super.string()
|
||||
.add("uuid", uuid).add("tenantId", tenantId).add("userId", userId).add("updated", updated).add("created", created)
|
||||
.add("hostId", hostId).add("accessIPv4", accessIPv4).add("accessIPv6", accessIPv6).add("status", status).add("image", image)
|
||||
.add("flavor", flavor).add("keyName", keyName).add("configDrive", configDrive).add("addresses", addresses)
|
||||
.add("metadata", metadata).add("extendedStatus", extendedStatus).add("extendedAttributes", extendedAttributes)
|
||||
.add("diskConfig", diskConfig);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
/*
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
|
@ -18,8 +18,16 @@
|
|||
*/
|
||||
package org.jclouds.openstack.nova.v2_0.domain;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
import java.util.Set;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
import org.jclouds.openstack.v2_0.domain.Link;
|
||||
import org.jclouds.openstack.v2_0.domain.Resource;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
|
||||
/**
|
||||
|
@ -27,9 +35,9 @@ import com.google.common.base.Objects.ToStringHelper;
|
|||
*
|
||||
* @author Adam Lowe
|
||||
* @see <a href=
|
||||
* "http://docs.openstack.org/api/openstack-compute/1.1/content/Get_Server_Details-d1e2623.html"
|
||||
* />
|
||||
*/
|
||||
"http://docs.openstack.org/api/openstack-compute/1.1/content/Get_Server_Details-d1e2623.html"
|
||||
/>
|
||||
*/
|
||||
public class ServerCreated extends Resource {
|
||||
|
||||
public static Builder<?> builder() {
|
||||
|
@ -41,7 +49,7 @@ public class ServerCreated extends Resource {
|
|||
}
|
||||
|
||||
public static abstract class Builder<T extends Builder<T>> extends Resource.Builder<T> {
|
||||
private String adminPass;
|
||||
protected String adminPass;
|
||||
|
||||
/**
|
||||
* @see ServerCreated#getAdminPass()
|
||||
|
@ -51,12 +59,13 @@ public class ServerCreated extends Resource {
|
|||
return self();
|
||||
}
|
||||
|
||||
public T fromServerCreated(ServerCreated in) {
|
||||
return super.fromResource(in).adminPass(in.getAdminPass());
|
||||
public ServerCreated build() {
|
||||
return new ServerCreated(id, name, links, adminPass);
|
||||
}
|
||||
|
||||
public ServerCreated build() {
|
||||
return new ServerCreated(this);
|
||||
public T fromServerCreated(ServerCreated in) {
|
||||
return super.fromResource(in)
|
||||
.adminPass(in.getAdminPass());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -67,30 +76,39 @@ public class ServerCreated extends Resource {
|
|||
}
|
||||
}
|
||||
|
||||
protected ServerCreated() {
|
||||
// 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 final String adminPass;
|
||||
|
||||
private String adminPass;
|
||||
|
||||
protected ServerCreated(Builder<?> builder) {
|
||||
super(builder);
|
||||
this.adminPass = builder.adminPass;
|
||||
@ConstructorProperties({
|
||||
"id", "name", "links", "adminPass"
|
||||
})
|
||||
protected ServerCreated(String id, @Nullable String name, Set<Link> links, String adminPass) {
|
||||
super(id, name, links);
|
||||
this.adminPass = checkNotNull(adminPass, "adminPass");
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the administrative password for this server. Note: this is not available in Server responses.
|
||||
*/
|
||||
public String getAdminPass() {
|
||||
return adminPass;
|
||||
return this.adminPass;
|
||||
}
|
||||
|
||||
// hashCode/equals from super is ok
|
||||
|
||||
@Override
|
||||
protected ToStringHelper string() {
|
||||
return super.string().add("adminPass", adminPass);
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(adminPass);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
ServerCreated that = ServerCreated.class.cast(obj);
|
||||
return super.equals(that) && Objects.equal(this.adminPass, that.adminPass);
|
||||
}
|
||||
|
||||
protected ToStringHelper string() {
|
||||
return super.string()
|
||||
.add("adminPass", adminPass);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
/*
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
|
@ -18,37 +18,43 @@
|
|||
*/
|
||||
package org.jclouds.openstack.nova.v2_0.domain;
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
|
||||
import javax.inject.Named;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
/**
|
||||
* Additional attributes delivered by Extended Server Attributes extension (alias "OS-EXT-SRV-ATTR")
|
||||
*
|
||||
* @author Adam Lowe
|
||||
* @see <a href=
|
||||
* "http://nova.openstack.org/api/nova.api.openstack.compute.contrib.extended_server_attributes.html"
|
||||
* />
|
||||
"http://nova.openstack.org/api/nova.api.openstack.compute.contrib.extended_server_attributes.html"
|
||||
/>
|
||||
* @see org.jclouds.openstack.nova.v2_0.features.ExtensionClient#getExtensionByAlias
|
||||
* @see org.jclouds.openstack.nova.v1_1.extensions.ExtensionNamespaces#EXTENDED_STATUS (extended status?)
|
||||
*/
|
||||
* @see org.jclouds.openstack.nova.v2_0.extensions.ExtensionNamespaces#EXTENDED_STATUS
|
||||
*/
|
||||
public class ServerExtendedAttributes {
|
||||
public static final String PREFIX = "OS-EXT-SRV-ATTR:";
|
||||
|
||||
public static String PREFIX;
|
||||
|
||||
public static Builder<?> builder() {
|
||||
return new ConcreteBuilder();
|
||||
}
|
||||
|
||||
public Builder<?> toBuilder() {
|
||||
return new ConcreteBuilder().fromServerExtraAttributes(this);
|
||||
return new ConcreteBuilder().fromServerExtendedAttributes(this);
|
||||
}
|
||||
|
||||
public static abstract class Builder<T extends Builder<T>> {
|
||||
protected abstract T self();
|
||||
|
||||
private String instanceName;
|
||||
private String hostName;
|
||||
private String hypervisorHostName;
|
||||
protected String instanceName;
|
||||
protected String hostName;
|
||||
protected String hypervisorHostName;
|
||||
|
||||
/**
|
||||
* @see ServerExtendedAttributes#getInstanceName()
|
||||
|
@ -69,20 +75,20 @@ public class ServerExtendedAttributes {
|
|||
/**
|
||||
* @see ServerExtendedAttributes#getHypervisorHostName()
|
||||
*/
|
||||
public T hypervisorHostame(String hypervisorHostName) {
|
||||
public T hypervisorHostName(String hypervisorHostName) {
|
||||
this.hypervisorHostName = hypervisorHostName;
|
||||
return self();
|
||||
}
|
||||
|
||||
public ServerExtendedAttributes build() {
|
||||
return new ServerExtendedAttributes(this);
|
||||
return new ServerExtendedAttributes(instanceName, hostName, hypervisorHostName);
|
||||
}
|
||||
|
||||
public T fromServerExtraAttributes(ServerExtendedAttributes in) {
|
||||
public T fromServerExtendedAttributes(ServerExtendedAttributes in) {
|
||||
return this
|
||||
.instanceName(in.getInstanceName())
|
||||
.hostName(in.getHostName())
|
||||
.hypervisorHostame(in.getHypervisorHostName());
|
||||
.instanceName(in.getInstanceName())
|
||||
.hostName(in.getHostName())
|
||||
.hypervisorHostName(in.getHypervisorHostName());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -93,33 +99,33 @@ public class ServerExtendedAttributes {
|
|||
}
|
||||
}
|
||||
|
||||
protected ServerExtendedAttributes() {
|
||||
// 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(value=PREFIX + "instance_name")
|
||||
private String instanceName;
|
||||
@SerializedName(value=PREFIX + "host")
|
||||
private String hostName;
|
||||
@SerializedName(value=PREFIX + "hypervisor_hostname")
|
||||
private String hypervisorHostName;
|
||||
|
||||
protected ServerExtendedAttributes(Builder<?> builder) {
|
||||
this.instanceName = builder.instanceName;
|
||||
this.hostName = builder.hostName;
|
||||
this.hypervisorHostName = builder.hypervisorHostName;
|
||||
@Named("OS-EXT-SRV-ATTR:instance_name")
|
||||
private final String instanceName;
|
||||
@Named("OS-EXT-SRV-ATTR:host")
|
||||
private final String hostName;
|
||||
@Named("OS-EXT-SRV-ATTR:hypervisor_hostname")
|
||||
private final String hypervisorHostName;
|
||||
|
||||
@ConstructorProperties({
|
||||
"OS-EXT-SRV-ATTR:instance_name", "OS-EXT-SRV-ATTR:host", "OS-EXT-SRV-ATTR:hypervisor_hostname"
|
||||
})
|
||||
protected ServerExtendedAttributes(@Nullable String instanceName, @Nullable String hostName, @Nullable String hypervisorHostName) {
|
||||
this.instanceName = instanceName;
|
||||
this.hostName = hostName;
|
||||
this.hypervisorHostName = hypervisorHostName;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getInstanceName() {
|
||||
return this.instanceName;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getHostName() {
|
||||
return this.hostName;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getHypervisorHostName() {
|
||||
return this.hypervisorHostName;
|
||||
}
|
||||
|
@ -135,15 +141,13 @@ public class ServerExtendedAttributes {
|
|||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
ServerExtendedAttributes that = ServerExtendedAttributes.class.cast(obj);
|
||||
return Objects.equal(this.instanceName, that.instanceName)
|
||||
&& Objects.equal(this.hostName, that.hostName)
|
||||
&& Objects.equal(this.hypervisorHostName, that.hypervisorHostName);
|
||||
&& Objects.equal(this.hostName, that.hostName)
|
||||
&& Objects.equal(this.hypervisorHostName, that.hypervisorHostName);
|
||||
}
|
||||
|
||||
protected ToStringHelper string() {
|
||||
return Objects.toStringHelper("")
|
||||
.add("instanceName", instanceName)
|
||||
.add("hostName", hostName)
|
||||
.add("hypervisorHostName", hypervisorHostName);
|
||||
return Objects.toStringHelper(this)
|
||||
.add("instanceName", instanceName).add("hostName", hostName).add("hypervisorHostName", hypervisorHostName);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
/*
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
|
@ -18,24 +18,28 @@
|
|||
*/
|
||||
package org.jclouds.openstack.nova.v2_0.domain;
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
|
||||
import javax.inject.Named;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
/**
|
||||
* Additional attributes delivered by Extended Server Status extension (alias "OS-EXT-STS")
|
||||
*
|
||||
* @author Adam Lowe
|
||||
* @see <a href=
|
||||
* "http://nova.openstack.org/api/nova.api.openstack.compute.contrib.extended_status.html"
|
||||
* />
|
||||
"http://nova.openstack.org/api/nova.api.openstack.compute.contrib.extended_status.html"
|
||||
/>
|
||||
* @see org.jclouds.openstack.nova.v2_0.features.ExtensionClient#getExtensionByAlias
|
||||
* @see org.jclouds.openstack.nova.v1_1.extensions.ExtensionNamespaces#EXTENDED_STATUS (extended status?)
|
||||
*/
|
||||
*/
|
||||
public class ServerExtendedStatus {
|
||||
public static final String PREFIX = "OS-EXT-STS:";
|
||||
|
||||
public static String PREFIX;
|
||||
|
||||
public static Builder<?> builder() {
|
||||
return new ConcreteBuilder();
|
||||
|
@ -48,9 +52,9 @@ public class ServerExtendedStatus {
|
|||
public static abstract class Builder<T extends Builder<T>> {
|
||||
protected abstract T self();
|
||||
|
||||
private String taskState;
|
||||
private String vmState;
|
||||
private int powerState = Integer.MIN_VALUE;
|
||||
protected String taskState;
|
||||
protected String vmState;
|
||||
protected int powerState;
|
||||
|
||||
/**
|
||||
* @see ServerExtendedStatus#getTaskState()
|
||||
|
@ -77,14 +81,14 @@ public class ServerExtendedStatus {
|
|||
}
|
||||
|
||||
public ServerExtendedStatus build() {
|
||||
return new ServerExtendedStatus(this);
|
||||
return new ServerExtendedStatus(taskState, vmState, powerState);
|
||||
}
|
||||
|
||||
public T fromServerExtendedStatus(ServerExtendedStatus in) {
|
||||
return this
|
||||
.taskState(in.getTaskState())
|
||||
.vmState(in.getVmState())
|
||||
.powerState(in.getPowerState());
|
||||
.taskState(in.getTaskState())
|
||||
.vmState(in.getVmState())
|
||||
.powerState(in.getPowerState());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -95,23 +99,20 @@ public class ServerExtendedStatus {
|
|||
}
|
||||
}
|
||||
|
||||
protected ServerExtendedStatus() {
|
||||
// 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
|
||||
}
|
||||
@Named("OS-EXT-STS:task_state")
|
||||
private final String taskState;
|
||||
@Named("OS-EXT-STS:vm_state")
|
||||
private final String vmState;
|
||||
@Named("OS-EXT-STS:power_state")
|
||||
private final int powerState;
|
||||
|
||||
@SerializedName(value=PREFIX + "task_state")
|
||||
private String taskState;
|
||||
@SerializedName(value=PREFIX + "vm_state")
|
||||
private String vmState;
|
||||
@SerializedName(value=PREFIX + "power_state")
|
||||
private int powerState = Integer.MIN_VALUE;
|
||||
|
||||
protected ServerExtendedStatus(Builder<?> builder) {
|
||||
this.taskState = builder.taskState;
|
||||
this.vmState = builder.vmState;
|
||||
this.powerState = builder.powerState;
|
||||
@ConstructorProperties({
|
||||
"OS-EXT-STS:task_state", "OS-EXT-STS:vm_state", "OS-EXT-STS:power_state"
|
||||
})
|
||||
protected ServerExtendedStatus(@Nullable String taskState, @Nullable String vmState, int powerState) {
|
||||
this.taskState = taskState;
|
||||
this.vmState = vmState;
|
||||
this.powerState = powerState;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
@ -139,17 +140,13 @@ public class ServerExtendedStatus {
|
|||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
ServerExtendedStatus that = ServerExtendedStatus.class.cast(obj);
|
||||
return Objects.equal(this.taskState, that.taskState)
|
||||
&& Objects.equal(this.vmState, that.vmState)
|
||||
&& Objects.equal(this.powerState, that.powerState)
|
||||
;
|
||||
&& Objects.equal(this.vmState, that.vmState)
|
||||
&& Objects.equal(this.powerState, that.powerState);
|
||||
}
|
||||
|
||||
protected ToStringHelper string() {
|
||||
return Objects.toStringHelper("")
|
||||
.add("taskState", taskState)
|
||||
.add("vmState", vmState)
|
||||
.add("powerState", powerState)
|
||||
;
|
||||
return Objects.toStringHelper(this)
|
||||
.add("taskState", taskState).add("vmState", vmState).add("powerState", powerState);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
/*
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
|
@ -20,13 +20,21 @@ package org.jclouds.openstack.nova.v2_0.domain;
|
|||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.beans.ConstructorProperties;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.inject.Named;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
import org.jclouds.openstack.v2_0.domain.Link;
|
||||
import org.jclouds.openstack.v2_0.domain.Resource;
|
||||
import org.jclouds.util.Multimaps2;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
/**
|
||||
* Extended server returned by ServerWithSecurityGroupsClient
|
||||
|
@ -35,7 +43,7 @@ import com.google.gson.annotations.SerializedName;
|
|||
* @see <a href=
|
||||
"http://docs.openstack.org/api/openstack-compute/1.1/content/Get_Server_Details-d1e2623.html"
|
||||
/>
|
||||
*/
|
||||
*/
|
||||
public class ServerWithSecurityGroups extends Server {
|
||||
|
||||
public static Builder<?> builder() {
|
||||
|
@ -47,24 +55,30 @@ public class ServerWithSecurityGroups extends Server {
|
|||
}
|
||||
|
||||
public static abstract class Builder<T extends Builder<T>> extends Server.Builder<T> {
|
||||
private Set<String> securityGroupNames = ImmutableSet.of();
|
||||
protected Set<String> securityGroupNames = ImmutableSet.of();
|
||||
|
||||
/**
|
||||
* @see ServerWithSecurityGroups#getSecurityGroupNames()
|
||||
*/
|
||||
public T securityGroupNames(Set<String> securityGroupNames) {
|
||||
this.securityGroupNames = securityGroupNames;
|
||||
this.securityGroupNames = ImmutableSet.copyOf(checkNotNull(securityGroupNames, "securityGroupNames"));
|
||||
return self();
|
||||
}
|
||||
|
||||
public T securityGroupNames(String... in) {
|
||||
return securityGroupNames(ImmutableSet.copyOf(in));
|
||||
}
|
||||
|
||||
public ServerWithSecurityGroups build() {
|
||||
return new ServerWithSecurityGroups(this);
|
||||
return new ServerWithSecurityGroups(id, name, links, uuid, tenantId, userId, updated, created, hostId,
|
||||
accessIPv4, accessIPv6, status, image, flavor, keyName, configDrive, Multimaps2.toOldSchool(addresses),
|
||||
metadata, extendedStatus, extendedAttributes, diskConfig, securityGroupNames);
|
||||
}
|
||||
|
||||
public T fromServerWithSecurityGroups(ServerWithSecurityGroups in) {
|
||||
return super.fromServer(in).securityGroupNames(in.getSecurityGroupNames());
|
||||
return super.fromServer(in)
|
||||
.securityGroupNames(in.getSecurityGroupNames());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
|
@ -74,24 +88,25 @@ public class ServerWithSecurityGroups extends Server {
|
|||
}
|
||||
}
|
||||
|
||||
protected ServerWithSecurityGroups() {
|
||||
// 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
|
||||
@Named("security_groups")
|
||||
private final Set<String> securityGroupNames;
|
||||
|
||||
@ConstructorProperties({
|
||||
"id", "name", "links", "uuid", "tenant_id", "user_id", "updated", "created", "hostId", "accessIPv4", "accessIPv6", "status", "image", "flavor", "key_name", "config_drive", "addresses", "metadata", "extendedStatus", "extendedAttributes", "OS-DCF:diskConfig", "security_groups"
|
||||
})
|
||||
protected ServerWithSecurityGroups(String id, @Nullable String name, Set<Link> links, @Nullable String uuid,
|
||||
String tenantId, String userId, Date updated, Date created, @Nullable String hostId,
|
||||
@Nullable String accessIPv4, @Nullable String accessIPv6, Server.Status status, Resource image,
|
||||
Resource flavor, @Nullable String keyName, @Nullable String configDrive,
|
||||
Map<String, Set<Address>> addresses, Map<String, String> metadata,
|
||||
@Nullable ServerExtendedStatus extendedStatus, @Nullable ServerExtendedAttributes extendedAttributes,
|
||||
@Nullable String diskConfig, Set<String> securityGroupNames) {
|
||||
super(id, name, links, uuid, tenantId, userId, updated, created, hostId, accessIPv4, accessIPv6, status, image, flavor, keyName, configDrive, addresses, metadata, extendedStatus, extendedAttributes, diskConfig);
|
||||
this.securityGroupNames = ImmutableSet.copyOf(checkNotNull(securityGroupNames, "securityGroupNames"));
|
||||
}
|
||||
|
||||
@SerializedName(value="security_groups")
|
||||
private Set<String> securityGroupNames = ImmutableSet.of();
|
||||
|
||||
protected ServerWithSecurityGroups(Builder<?> builder) {
|
||||
super(builder);
|
||||
this.securityGroupNames = ImmutableSet.copyOf(checkNotNull(builder.securityGroupNames, "securityGroupNames"));
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public Set<String> getSecurityGroupNames() {
|
||||
return Collections.unmodifiableSet(this.securityGroupNames);
|
||||
return this.securityGroupNames;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
/*
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
|
@ -20,35 +20,39 @@ package org.jclouds.openstack.nova.v2_0.domain;
|
|||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
import java.util.Date;
|
||||
|
||||
import javax.inject.Named;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
/**
|
||||
* Information the SimpleTenantUsage extension return data about each Server
|
||||
*
|
||||
* @author Adam Lowe
|
||||
*/
|
||||
*/
|
||||
public class SimpleServerUsage {
|
||||
|
||||
/**
|
||||
*/
|
||||
public static enum Status {
|
||||
|
||||
UNRECOGNIZED, ACTIVE;
|
||||
|
||||
public String value() {
|
||||
return name();
|
||||
return name();
|
||||
}
|
||||
|
||||
public static Status fromValue(String v) {
|
||||
try {
|
||||
return valueOf(v.toUpperCase());
|
||||
} catch (IllegalArgumentException e) {
|
||||
return UNRECOGNIZED;
|
||||
}
|
||||
try {
|
||||
return valueOf(v.toUpperCase());
|
||||
} catch (IllegalArgumentException e) {
|
||||
return UNRECOGNIZED;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -62,95 +66,126 @@ public class SimpleServerUsage {
|
|||
}
|
||||
|
||||
public static abstract class Builder<T extends Builder<T>> {
|
||||
private String instanceName;
|
||||
private double hours;
|
||||
private double flavorMemoryMb;
|
||||
private double flavorLocalGb;
|
||||
private double flavorVcpus;
|
||||
private String tenantId;
|
||||
private String flavorName;
|
||||
private Date instanceCreated;
|
||||
private Date instanceTerminiated;
|
||||
private Status instanceStatus;
|
||||
private long uptime;
|
||||
|
||||
protected abstract T self();
|
||||
|
||||
protected String instanceName;
|
||||
protected double hours;
|
||||
protected double flavorMemoryMb;
|
||||
protected double flavorLocalGb;
|
||||
protected double flavorVcpus;
|
||||
protected String tenantId;
|
||||
protected String flavorName;
|
||||
protected Date instanceCreated;
|
||||
protected Date instanceTerminiated;
|
||||
protected SimpleServerUsage.Status instanceStatus;
|
||||
protected long uptime;
|
||||
|
||||
/**
|
||||
* @see SimpleServerUsage#getInstanceName()
|
||||
*/
|
||||
public T instanceName(String instanceName) {
|
||||
this.instanceName = instanceName;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see SimpleServerUsage#getHours()
|
||||
*/
|
||||
public T hours(double hours) {
|
||||
this.hours = hours;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see SimpleServerUsage#getFlavorMemoryMb()
|
||||
*/
|
||||
public T flavorMemoryMb(double flavorMemoryMb) {
|
||||
this.flavorMemoryMb = flavorMemoryMb;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see SimpleServerUsage#getFlavorLocalGb()
|
||||
*/
|
||||
public T flavorLocalGb(double flavorLocalGb) {
|
||||
this.flavorLocalGb = flavorLocalGb;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see SimpleServerUsage#getFlavorVcpus()
|
||||
*/
|
||||
public T flavorVcpus(double flavorVcpus) {
|
||||
this.flavorVcpus = flavorVcpus;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see SimpleServerUsage#getTenantId()
|
||||
*/
|
||||
public T tenantId(String tenantId) {
|
||||
this.tenantId = tenantId;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see SimpleServerUsage#getFlavorName()
|
||||
*/
|
||||
public T flavorName(String flavorName) {
|
||||
this.flavorName = flavorName;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see SimpleServerUsage#getInstanceCreated()
|
||||
*/
|
||||
public T instanceCreated(Date instanceCreated) {
|
||||
this.instanceCreated = instanceCreated;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see SimpleServerUsage#getInstanceTerminiated()
|
||||
*/
|
||||
public T instanceTerminiated(Date instanceTerminiated) {
|
||||
this.instanceTerminiated = instanceTerminiated;
|
||||
return self();
|
||||
}
|
||||
|
||||
public T instanceStatus(Status instanceStatus) {
|
||||
/**
|
||||
* @see SimpleServerUsage#getInstanceStatus()
|
||||
*/
|
||||
public T instanceStatus(SimpleServerUsage.Status instanceStatus) {
|
||||
this.instanceStatus = instanceStatus;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see SimpleServerUsage#getUptime()
|
||||
*/
|
||||
public T uptime(long uptime) {
|
||||
this.uptime = uptime;
|
||||
return self();
|
||||
}
|
||||
|
||||
public SimpleServerUsage build() {
|
||||
return new SimpleServerUsage(this);
|
||||
return new SimpleServerUsage(instanceName, hours, flavorMemoryMb, flavorLocalGb, flavorVcpus, tenantId, flavorName, instanceCreated, instanceTerminiated, instanceStatus, uptime);
|
||||
}
|
||||
|
||||
|
||||
public T fromSimpleServerUsage(SimpleServerUsage in) {
|
||||
return this
|
||||
.instanceName(in.getInstanceName())
|
||||
.flavorMemoryMb(in.getFlavorMemoryMb())
|
||||
.flavorLocalGb(in.getFlavorLocalGb())
|
||||
.flavorVcpus(in.getFlavorVcpus())
|
||||
.tenantId(in.getTenantId())
|
||||
.flavorName(in.getFlavorName())
|
||||
.instanceCreated(in.getInstanceCreated())
|
||||
.instanceTerminiated(in.getInstanceTerminiated())
|
||||
.instanceStatus(in.getInstanceStatus())
|
||||
.uptime(in.getUptime())
|
||||
;
|
||||
.instanceName(in.getInstanceName())
|
||||
.hours(in.getHours())
|
||||
.flavorMemoryMb(in.getFlavorMemoryMb())
|
||||
.flavorLocalGb(in.getFlavorLocalGb())
|
||||
.flavorVcpus(in.getFlavorVcpus())
|
||||
.tenantId(in.getTenantId())
|
||||
.flavorName(in.getFlavorName())
|
||||
.instanceCreated(in.getInstanceCreated())
|
||||
.instanceTerminiated(in.getInstanceTerminiated())
|
||||
.instanceStatus(in.getInstanceStatus())
|
||||
.uptime(in.getUptime());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
|
@ -160,111 +195,92 @@ public class SimpleServerUsage {
|
|||
}
|
||||
}
|
||||
|
||||
protected SimpleServerUsage() {
|
||||
// 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
|
||||
@Named("name")
|
||||
private final String instanceName;
|
||||
private final double hours;
|
||||
@Named("memory_mb")
|
||||
private final double flavorMemoryMb;
|
||||
@Named("local_gb")
|
||||
private final double flavorLocalGb;
|
||||
@Named("vcpus")
|
||||
private final double flavorVcpus;
|
||||
@Named("tenant_id")
|
||||
private final String tenantId;
|
||||
@Named("flavor")
|
||||
private final String flavorName;
|
||||
@Named("started_at")
|
||||
private final Date instanceCreated;
|
||||
@Named("ended_at")
|
||||
private final Date instanceTerminiated;
|
||||
@Named("state")
|
||||
private final SimpleServerUsage.Status instanceStatus;
|
||||
private final long uptime;
|
||||
|
||||
@ConstructorProperties({
|
||||
"name", "hours", "memory_mb", "local_gb", "vcpus", "tenant_id", "flavor", "started_at", "ended_at", "state", "uptime"
|
||||
})
|
||||
protected SimpleServerUsage(String instanceName, double hours, double flavorMemoryMb, double flavorLocalGb, double flavorVcpus, String tenantId, String flavorName, Date instanceCreated, @Nullable Date instanceTerminiated, SimpleServerUsage.Status instanceStatus, long uptime) {
|
||||
this.instanceName = checkNotNull(instanceName, "instanceName");
|
||||
this.hours = hours;
|
||||
this.flavorMemoryMb = flavorMemoryMb;
|
||||
this.flavorLocalGb = flavorLocalGb;
|
||||
this.flavorVcpus = flavorVcpus;
|
||||
this.tenantId = checkNotNull(tenantId, "tenantId");
|
||||
this.flavorName = checkNotNull(flavorName, "flavorName");
|
||||
this.instanceCreated = checkNotNull(instanceCreated, "instanceCreated");
|
||||
this.instanceTerminiated = instanceTerminiated;
|
||||
this.instanceStatus = checkNotNull(instanceStatus, "instanceStatus");
|
||||
this.uptime = uptime;
|
||||
}
|
||||
|
||||
@SerializedName("name")
|
||||
private String instanceName;
|
||||
private double hours;
|
||||
@SerializedName("memory_mb")
|
||||
private double flavorMemoryMb;
|
||||
@SerializedName("local_gb")
|
||||
private double flavorLocalGb;
|
||||
@SerializedName("vcpus")
|
||||
private double flavorVcpus;
|
||||
@SerializedName("tenant_id")
|
||||
private String tenantId;
|
||||
@SerializedName("flavor")
|
||||
private String flavorName;
|
||||
@SerializedName("started_at")
|
||||
private Date instanceCreated;
|
||||
@SerializedName("ended_at")
|
||||
private Date instanceTerminiated;
|
||||
@SerializedName("state")
|
||||
private Status instanceStatus;
|
||||
private long uptime;
|
||||
|
||||
private SimpleServerUsage(Builder<?> builder) {
|
||||
this.instanceName = checkNotNull(builder.instanceName, "instanceName");
|
||||
this.hours = builder.hours;
|
||||
this.flavorMemoryMb = builder.flavorMemoryMb;
|
||||
this.flavorLocalGb = builder.flavorLocalGb;
|
||||
this.flavorVcpus = builder.flavorVcpus;
|
||||
this.tenantId = checkNotNull(builder.tenantId, "tenantId");
|
||||
this.flavorName = checkNotNull(builder.flavorName, "flavorName");
|
||||
this.instanceCreated = builder.instanceCreated; //checkNotNull(builder.instanceCreated, "instanceCreated");
|
||||
this.instanceTerminiated = builder.instanceTerminiated;
|
||||
this.instanceStatus = checkNotNull(builder.instanceStatus, "instanceStatus");
|
||||
this.uptime = checkNotNull(builder.uptime, "uptime");
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public String getInstanceName() {
|
||||
return this.instanceName;
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public double getHours() {
|
||||
return this.hours;
|
||||
}
|
||||
|
||||
public double getFlavorMemoryMb() {
|
||||
return this.flavorMemoryMb;
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public double getFlavorLocalGb() {
|
||||
return this.flavorLocalGb;
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public double getFlavorVcpus() {
|
||||
return this.flavorVcpus;
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public String getTenantId() {
|
||||
return this.tenantId;
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public String getFlavorName() {
|
||||
return this.flavorName;
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public Date getInstanceCreated() {
|
||||
return this.instanceCreated;
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
@Nullable
|
||||
public Date getInstanceTerminiated() {
|
||||
return this.instanceTerminiated;
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public Status getInstanceStatus() {
|
||||
public SimpleServerUsage.Status getInstanceStatus() {
|
||||
return this.instanceStatus;
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public long getUptime() {
|
||||
return this.uptime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(instanceName, flavorMemoryMb, flavorLocalGb, flavorVcpus, tenantId, flavorName, instanceCreated, instanceTerminiated, instanceStatus, uptime);
|
||||
return Objects.hashCode(instanceName, hours, flavorMemoryMb, flavorLocalGb, flavorVcpus, tenantId, flavorName, instanceCreated, instanceTerminiated, instanceStatus, uptime);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -273,31 +289,21 @@ public class SimpleServerUsage {
|
|||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
SimpleServerUsage that = SimpleServerUsage.class.cast(obj);
|
||||
return Objects.equal(this.instanceName, that.instanceName)
|
||||
&& Objects.equal(this.flavorMemoryMb, that.flavorMemoryMb)
|
||||
&& Objects.equal(this.flavorLocalGb, that.flavorLocalGb)
|
||||
&& Objects.equal(this.flavorVcpus, that.flavorVcpus)
|
||||
&& Objects.equal(this.tenantId, that.tenantId)
|
||||
&& Objects.equal(this.flavorName, that.flavorName)
|
||||
&& Objects.equal(this.instanceCreated, that.instanceCreated)
|
||||
&& Objects.equal(this.instanceTerminiated, that.instanceTerminiated)
|
||||
&& Objects.equal(this.instanceStatus, that.instanceStatus)
|
||||
&& Objects.equal(this.uptime, that.uptime)
|
||||
;
|
||||
&& Objects.equal(this.hours, that.hours)
|
||||
&& Objects.equal(this.flavorMemoryMb, that.flavorMemoryMb)
|
||||
&& Objects.equal(this.flavorLocalGb, that.flavorLocalGb)
|
||||
&& Objects.equal(this.flavorVcpus, that.flavorVcpus)
|
||||
&& Objects.equal(this.tenantId, that.tenantId)
|
||||
&& Objects.equal(this.flavorName, that.flavorName)
|
||||
&& Objects.equal(this.instanceCreated, that.instanceCreated)
|
||||
&& Objects.equal(this.instanceTerminiated, that.instanceTerminiated)
|
||||
&& Objects.equal(this.instanceStatus, that.instanceStatus)
|
||||
&& Objects.equal(this.uptime, that.uptime);
|
||||
}
|
||||
|
||||
protected ToStringHelper string() {
|
||||
return Objects.toStringHelper("")
|
||||
.add("instanceName", instanceName)
|
||||
.add("flavorMemoryMb", flavorMemoryMb)
|
||||
.add("flavorLocalGb", flavorLocalGb)
|
||||
.add("flavorVcpus", flavorVcpus)
|
||||
.add("tenantId", tenantId)
|
||||
.add("flavorName", flavorName)
|
||||
.add("instanceCreated", instanceCreated)
|
||||
.add("instanceTerminiated", instanceTerminiated)
|
||||
.add("instanceStatus", instanceStatus)
|
||||
.add("uptime", uptime)
|
||||
;
|
||||
return Objects.toStringHelper(this)
|
||||
.add("instanceName", instanceName).add("hours", hours).add("flavorMemoryMb", flavorMemoryMb).add("flavorLocalGb", flavorLocalGb).add("flavorVcpus", flavorVcpus).add("tenantId", tenantId).add("flavorName", flavorName).add("instanceCreated", instanceCreated).add("instanceTerminiated", instanceTerminiated).add("instanceStatus", instanceStatus).add("uptime", uptime);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
/*
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
|
@ -20,24 +20,25 @@ package org.jclouds.openstack.nova.v2_0.domain;
|
|||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.beans.ConstructorProperties;
|
||||
import java.util.Date;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.inject.Named;
|
||||
|
||||
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;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
/**
|
||||
* Information the SimpleTenantUsage extension returns data about each tenant
|
||||
*
|
||||
* @author Adam Lowe
|
||||
*/
|
||||
*/
|
||||
public class SimpleTenantUsage {
|
||||
|
||||
public static Builder<?> builder() {
|
||||
return new ConcreteBuilder();
|
||||
}
|
||||
|
@ -46,75 +47,101 @@ public class SimpleTenantUsage {
|
|||
return new ConcreteBuilder().fromSimpleTenantUsage(this);
|
||||
}
|
||||
|
||||
public static abstract class Builder<T extends Builder<T>> {
|
||||
private String tenantId;
|
||||
private double totalLocalGbUsage;
|
||||
private double totalVcpusUsage;
|
||||
private double totalMemoryMbUsage;
|
||||
private double totalHours;
|
||||
private Date start;
|
||||
private Date stop;
|
||||
private Set<SimpleServerUsage> serverUsages = Sets.newLinkedHashSet();
|
||||
|
||||
public static abstract class Builder<T extends Builder<T>> {
|
||||
protected abstract T self();
|
||||
|
||||
protected String tenantId;
|
||||
protected double totalLocalGbUsage;
|
||||
protected double totalVcpusUsage;
|
||||
protected double totalMemoryMbUsage;
|
||||
protected double totalHours;
|
||||
protected Date start;
|
||||
protected Date stop;
|
||||
protected Set<SimpleServerUsage> serverUsages = ImmutableSet.of();
|
||||
|
||||
/**
|
||||
* @see SimpleTenantUsage#getTenantId()
|
||||
*/
|
||||
public T tenantId(String tenantId) {
|
||||
this.tenantId = tenantId;
|
||||
return self();
|
||||
}
|
||||
|
||||
public T totalLocalGbUsage(double total_local_gb_usage) {
|
||||
this.totalLocalGbUsage = total_local_gb_usage;
|
||||
/**
|
||||
* @see SimpleTenantUsage#getTotalLocalGbUsage()
|
||||
*/
|
||||
public T totalLocalGbUsage(double totalLocalGbUsage) {
|
||||
this.totalLocalGbUsage = totalLocalGbUsage;
|
||||
return self();
|
||||
}
|
||||
|
||||
public T totalVcpusUsage(double total_vcpus_usage) {
|
||||
this.totalVcpusUsage = total_vcpus_usage;
|
||||
/**
|
||||
* @see SimpleTenantUsage#getTotalVcpusUsage()
|
||||
*/
|
||||
public T totalVcpusUsage(double totalVcpusUsage) {
|
||||
this.totalVcpusUsage = totalVcpusUsage;
|
||||
return self();
|
||||
}
|
||||
|
||||
public T totalMemoryMbUsage(double total_memory_mb_usage) {
|
||||
this.totalMemoryMbUsage = total_memory_mb_usage;
|
||||
/**
|
||||
* @see SimpleTenantUsage#getTotalMemoryMbUsage()
|
||||
*/
|
||||
public T totalMemoryMbUsage(double totalMemoryMbUsage) {
|
||||
this.totalMemoryMbUsage = totalMemoryMbUsage;
|
||||
return self();
|
||||
}
|
||||
|
||||
public T totalHours(double total_hours) {
|
||||
this.totalHours = total_hours;
|
||||
/**
|
||||
* @see SimpleTenantUsage#getTotalHours()
|
||||
*/
|
||||
public T totalHours(double totalHours) {
|
||||
this.totalHours = totalHours;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see SimpleTenantUsage#getStart()
|
||||
*/
|
||||
public T start(Date start) {
|
||||
this.start = start;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see SimpleTenantUsage#getStop()
|
||||
*/
|
||||
public T stop(Date stop) {
|
||||
this.stop = stop;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see SimpleTenantUsage#getServerUsages()
|
||||
*/
|
||||
public T serverUsages(Set<SimpleServerUsage> serverUsages) {
|
||||
this.serverUsages = serverUsages;
|
||||
this.serverUsages = ImmutableSet.copyOf(checkNotNull(serverUsages, "serverUsages"));
|
||||
return self();
|
||||
}
|
||||
|
||||
public SimpleTenantUsage build() {
|
||||
return new SimpleTenantUsage(this);
|
||||
public T serverUsages(SimpleServerUsage... in) {
|
||||
return serverUsages(ImmutableSet.copyOf(in));
|
||||
}
|
||||
|
||||
public SimpleTenantUsage build() {
|
||||
return new SimpleTenantUsage(tenantId, totalLocalGbUsage, totalVcpusUsage, totalMemoryMbUsage, totalHours, start, stop, serverUsages);
|
||||
}
|
||||
|
||||
public T fromSimpleTenantUsage(SimpleTenantUsage in) {
|
||||
return this
|
||||
.totalLocalGbUsage(in.getTotalLocalGbUsage())
|
||||
.totalVcpusUsage(in.getTotalVcpusUsage())
|
||||
.totalMemoryMbUsage(in.getTotalMemoryMbUsage())
|
||||
.totalHours(in.getTotalHours())
|
||||
.start(in.getStart())
|
||||
.stop(in.getStop())
|
||||
.serverUsages(in.getServerUsages())
|
||||
;
|
||||
.tenantId(in.getTenantId())
|
||||
.totalLocalGbUsage(in.getTotalLocalGbUsage())
|
||||
.totalVcpusUsage(in.getTotalVcpusUsage())
|
||||
.totalMemoryMbUsage(in.getTotalMemoryMbUsage())
|
||||
.totalHours(in.getTotalHours())
|
||||
.start(in.getStart())
|
||||
.stop(in.getStop())
|
||||
.serverUsages(in.getServerUsages());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
|
@ -124,90 +151,72 @@ public class SimpleTenantUsage {
|
|||
}
|
||||
}
|
||||
|
||||
protected SimpleTenantUsage() {
|
||||
// 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
|
||||
}
|
||||
@Named("tenant_id")
|
||||
private final String tenantId;
|
||||
@Named("total_local_gb_usage")
|
||||
private final double totalLocalGbUsage;
|
||||
@Named("total_vcpus_usage")
|
||||
private final double totalVcpusUsage;
|
||||
@Named("total_memory_mb_usage")
|
||||
private final double totalMemoryMbUsage;
|
||||
@Named("total_hours")
|
||||
private final double totalHours;
|
||||
private final Date start;
|
||||
private final Date stop;
|
||||
@Named("server_usages")
|
||||
private final Set<SimpleServerUsage> serverUsages;
|
||||
|
||||
@SerializedName("tenant_id")
|
||||
private String tenantId;
|
||||
@SerializedName("total_local_gb_usage")
|
||||
private double totalLocalGbUsage;
|
||||
@SerializedName("total_vcpus_usage")
|
||||
private double totalVcpusUsage;
|
||||
@SerializedName("total_memory_mb_usage")
|
||||
private double totalMemoryMbUsage;
|
||||
@SerializedName("total_hours")
|
||||
private double totalHours;
|
||||
private Date start;
|
||||
private Date stop;
|
||||
@SerializedName("server_usages")
|
||||
private Set<SimpleServerUsage> serverUsages = ImmutableSet.of();
|
||||
|
||||
private SimpleTenantUsage(Builder<?> builder) {
|
||||
this.tenantId = builder.tenantId;
|
||||
this.totalLocalGbUsage = builder.totalLocalGbUsage;
|
||||
this.totalVcpusUsage = builder.totalVcpusUsage;
|
||||
this.totalMemoryMbUsage = builder.totalMemoryMbUsage;
|
||||
this.totalHours = builder.totalHours;
|
||||
this.start = builder.start;
|
||||
this.stop = builder.stop;
|
||||
this.serverUsages = ImmutableSet.copyOf(checkNotNull(builder.serverUsages, "serverUsages"));
|
||||
@ConstructorProperties({
|
||||
"tenant_id", "total_local_gb_usage", "total_vcpus_usage", "total_memory_mb_usage", "total_hours", "start", "stop", "server_usages"
|
||||
})
|
||||
protected SimpleTenantUsage(String tenantId, double totalLocalGbUsage, double totalVcpusUsage, double totalMemoryMbUsage, double totalHours, @Nullable Date start, @Nullable Date stop, @Nullable Set<SimpleServerUsage> serverUsages) {
|
||||
this.tenantId = checkNotNull(tenantId, "tenantId");
|
||||
this.totalLocalGbUsage = totalLocalGbUsage;
|
||||
this.totalVcpusUsage = totalVcpusUsage;
|
||||
this.totalMemoryMbUsage = totalMemoryMbUsage;
|
||||
this.totalHours = totalHours;
|
||||
this.start = start;
|
||||
this.stop = stop;
|
||||
this.serverUsages = serverUsages == null ? ImmutableSet.<SimpleServerUsage>of() : ImmutableSet.copyOf(serverUsages);
|
||||
}
|
||||
|
||||
public String getTenantId() {
|
||||
return tenantId;
|
||||
return this.tenantId;
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public double getTotalLocalGbUsage() {
|
||||
return this.totalLocalGbUsage;
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public double getTotalVcpusUsage() {
|
||||
return this.totalVcpusUsage;
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public double getTotalMemoryMbUsage() {
|
||||
return this.totalMemoryMbUsage;
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public double getTotalHours() {
|
||||
return this.totalHours;
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
@Nullable
|
||||
public Date getStart() {
|
||||
return this.start;
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
@Nullable
|
||||
public Date getStop() {
|
||||
return this.stop;
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
@Nullable
|
||||
public Set<SimpleServerUsage> getServerUsages() {
|
||||
return serverUsages == null ? ImmutableSet.<SimpleServerUsage>of() : Collections.unmodifiableSet(this.serverUsages);
|
||||
return this.serverUsages;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(totalLocalGbUsage, totalVcpusUsage, totalMemoryMbUsage, totalHours, start, stop, serverUsages);
|
||||
return Objects.hashCode(tenantId, totalLocalGbUsage, totalVcpusUsage, totalMemoryMbUsage, totalHours, start, stop, serverUsages);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -215,26 +224,19 @@ public class SimpleTenantUsage {
|
|||
if (this == obj) return true;
|
||||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
SimpleTenantUsage that = SimpleTenantUsage.class.cast(obj);
|
||||
return Objects.equal(this.totalLocalGbUsage, that.totalLocalGbUsage)
|
||||
&& Objects.equal(this.totalVcpusUsage, that.totalVcpusUsage)
|
||||
&& Objects.equal(this.totalMemoryMbUsage, that.totalMemoryMbUsage)
|
||||
&& Objects.equal(this.totalHours, that.totalHours)
|
||||
&& Objects.equal(this.start, that.start)
|
||||
&& Objects.equal(this.stop, that.stop)
|
||||
&& Objects.equal(this.serverUsages, that.serverUsages)
|
||||
;
|
||||
return Objects.equal(this.tenantId, that.tenantId)
|
||||
&& Objects.equal(this.totalLocalGbUsage, that.totalLocalGbUsage)
|
||||
&& Objects.equal(this.totalVcpusUsage, that.totalVcpusUsage)
|
||||
&& Objects.equal(this.totalMemoryMbUsage, that.totalMemoryMbUsage)
|
||||
&& Objects.equal(this.totalHours, that.totalHours)
|
||||
&& Objects.equal(this.start, that.start)
|
||||
&& Objects.equal(this.stop, that.stop)
|
||||
&& Objects.equal(this.serverUsages, that.serverUsages);
|
||||
}
|
||||
|
||||
protected ToStringHelper string() {
|
||||
return Objects.toStringHelper("")
|
||||
.add("totalLocalGbUsage", totalLocalGbUsage)
|
||||
.add("totalVcpusUsage", totalVcpusUsage)
|
||||
.add("totalMemoryMbUsage", totalMemoryMbUsage)
|
||||
.add("totalHours", totalHours)
|
||||
.add("start", start)
|
||||
.add("stop", stop)
|
||||
.add("serverUsages", serverUsages)
|
||||
;
|
||||
return Objects.toStringHelper(this)
|
||||
.add("tenantId", tenantId).add("totalLocalGbUsage", totalLocalGbUsage).add("totalVcpusUsage", totalVcpusUsage).add("totalMemoryMbUsage", totalMemoryMbUsage).add("totalHours", totalHours).add("start", start).add("stop", stop).add("serverUsages", serverUsages);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
/*
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
|
@ -18,50 +18,88 @@
|
|||
*/
|
||||
package org.jclouds.openstack.nova.v2_0.domain;
|
||||
|
||||
import static com.google.common.base.Objects.equal;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
|
||||
import javax.inject.Named;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
/**
|
||||
* Class TenantIdAndName
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
*/
|
||||
public class TenantIdAndName {
|
||||
|
||||
protected TenantIdAndName() {
|
||||
// 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
|
||||
public static Builder<?> builder() {
|
||||
return new ConcreteBuilder();
|
||||
}
|
||||
|
||||
@SerializedName("tenant_id")
|
||||
protected String tenantId;
|
||||
protected String name;
|
||||
public Builder<?> toBuilder() {
|
||||
return new ConcreteBuilder().fromTenantIdAndName(this);
|
||||
}
|
||||
|
||||
public TenantIdAndName(String tenantId, String name) {
|
||||
public static abstract class Builder<T extends Builder<T>> {
|
||||
protected abstract T self();
|
||||
|
||||
protected String tenantId;
|
||||
protected String name;
|
||||
|
||||
/**
|
||||
* @see TenantIdAndName#getTenantId()
|
||||
*/
|
||||
public T tenantId(String tenantId) {
|
||||
this.tenantId = tenantId;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see TenantIdAndName#getName()
|
||||
*/
|
||||
public T name(String name) {
|
||||
this.name = name;
|
||||
return self();
|
||||
}
|
||||
|
||||
public TenantIdAndName build() {
|
||||
return new TenantIdAndName(tenantId, name);
|
||||
}
|
||||
|
||||
public T fromTenantIdAndName(TenantIdAndName in) {
|
||||
return this
|
||||
.tenantId(in.getTenantId())
|
||||
.name(in.getName());
|
||||
}
|
||||
}
|
||||
|
||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
@Override
|
||||
protected ConcreteBuilder self() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@Named("tenant_id")
|
||||
private final String tenantId;
|
||||
private final String name;
|
||||
|
||||
@ConstructorProperties({
|
||||
"tenant_id", "name"
|
||||
})
|
||||
protected TenantIdAndName(String tenantId, String name) {
|
||||
this.tenantId = checkNotNull(tenantId, "tenantId");
|
||||
this.name = checkNotNull(name, "name");
|
||||
}
|
||||
|
||||
public String getTenantId() {
|
||||
return tenantId;
|
||||
return this.tenantId;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o)
|
||||
return true;
|
||||
if (o == null || getClass() != o.getClass())
|
||||
return false;
|
||||
TenantIdAndName that = TenantIdAndName.class.cast(o);
|
||||
return equal(this.tenantId, that.tenantId) && equal(this.name, that.name);
|
||||
return this.name;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -69,12 +107,23 @@ public class TenantIdAndName {
|
|||
return Objects.hashCode(tenantId, name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
TenantIdAndName that = TenantIdAndName.class.cast(obj);
|
||||
return Objects.equal(this.tenantId, that.tenantId)
|
||||
&& Objects.equal(this.name, that.name);
|
||||
}
|
||||
|
||||
protected ToStringHelper string() {
|
||||
return Objects.toStringHelper(this)
|
||||
.add("tenantId", tenantId).add("name", name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return string().toString();
|
||||
}
|
||||
|
||||
protected ToStringHelper string() {
|
||||
return Objects.toStringHelper("").add("tenantId", tenantId).add("name", name);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
/*
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
|
@ -20,16 +20,19 @@ package org.jclouds.openstack.nova.v2_0.domain;
|
|||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
|
||||
import javax.inject.Named;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
/**
|
||||
* Represents a Virtual Interface (VIF)
|
||||
*
|
||||
* @author Adam Lowe
|
||||
* @see org.jclouds.openstack.nova.v2_0.extensions.VirtualInterfaceClient
|
||||
*/
|
||||
*/
|
||||
public class VirtualInterface {
|
||||
|
||||
public static Builder<?> builder() {
|
||||
|
@ -43,8 +46,8 @@ public class VirtualInterface {
|
|||
public static abstract class Builder<T extends Builder<T>> {
|
||||
protected abstract T self();
|
||||
|
||||
private String id;
|
||||
private String macAddress;
|
||||
protected String id;
|
||||
protected String macAddress;
|
||||
|
||||
/**
|
||||
* @see VirtualInterface#getId()
|
||||
|
@ -63,16 +66,14 @@ public class VirtualInterface {
|
|||
}
|
||||
|
||||
public VirtualInterface build() {
|
||||
return new VirtualInterface(this);
|
||||
return new VirtualInterface(id, macAddress);
|
||||
}
|
||||
|
||||
public T fromVirtualInterface(VirtualInterface in) {
|
||||
return this
|
||||
.id(in.getId())
|
||||
.macAddress(in.getMacAddress())
|
||||
;
|
||||
.id(in.getId())
|
||||
.macAddress(in.getMacAddress());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
|
@ -82,19 +83,16 @@ public class VirtualInterface {
|
|||
}
|
||||
}
|
||||
|
||||
protected VirtualInterface() {
|
||||
// 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 final String id;
|
||||
@Named("mac_address")
|
||||
private final String macAddress;
|
||||
|
||||
private String id;
|
||||
@SerializedName(value="mac_address")
|
||||
private String macAddress;
|
||||
|
||||
protected VirtualInterface(Builder<?> builder) {
|
||||
this.id = checkNotNull(builder.id, "id");
|
||||
this.macAddress = checkNotNull(builder.macAddress, "macAddress");
|
||||
@ConstructorProperties({
|
||||
"id", "mac_address"
|
||||
})
|
||||
protected VirtualInterface(String id, String macAddress) {
|
||||
this.id = checkNotNull(id, "id");
|
||||
this.macAddress = checkNotNull(macAddress, "macAddress");
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
|
@ -116,15 +114,12 @@ public class VirtualInterface {
|
|||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
VirtualInterface that = VirtualInterface.class.cast(obj);
|
||||
return Objects.equal(this.id, that.id)
|
||||
&& Objects.equal(this.macAddress, that.macAddress)
|
||||
;
|
||||
&& Objects.equal(this.macAddress, that.macAddress);
|
||||
}
|
||||
|
||||
protected ToStringHelper string() {
|
||||
return Objects.toStringHelper("")
|
||||
.add("id", id)
|
||||
.add("macAddress", macAddress)
|
||||
;
|
||||
return Objects.toStringHelper(this)
|
||||
.add("id", id).add("macAddress", macAddress);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
/*
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
|
@ -20,11 +20,13 @@ package org.jclouds.openstack.nova.v2_0.domain;
|
|||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.beans.ConstructorProperties;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.inject.Named;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.CaseFormat;
|
||||
|
@ -32,32 +34,31 @@ import com.google.common.base.Objects;
|
|||
import com.google.common.base.Objects.ToStringHelper;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
/**
|
||||
* An Openstack Nova Volume
|
||||
*/
|
||||
*/
|
||||
public class Volume {
|
||||
|
||||
/**
|
||||
*/
|
||||
public static enum Status {
|
||||
CREATING, AVAILABLE, IN_USE, DELETING, ERROR, UNRECOGNIZED;
|
||||
public String value() {
|
||||
return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_HYPHEN, name());
|
||||
return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_HYPHEN, name());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return value();
|
||||
return value();
|
||||
}
|
||||
|
||||
public static Status fromValue(String status) {
|
||||
try {
|
||||
return valueOf(CaseFormat.LOWER_HYPHEN.to(CaseFormat.UPPER_UNDERSCORE, checkNotNull(status, "status")));
|
||||
} catch (IllegalArgumentException e) {
|
||||
return UNRECOGNIZED;
|
||||
}
|
||||
try {
|
||||
return valueOf(CaseFormat.LOWER_HYPHEN.to(CaseFormat.UPPER_UNDERSCORE, checkNotNull(status, "status")));
|
||||
} catch (IllegalArgumentException e) {
|
||||
return UNRECOGNIZED;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -72,102 +73,128 @@ public class Volume {
|
|||
public static abstract class Builder<T extends Builder<T>> {
|
||||
protected abstract T self();
|
||||
|
||||
private String id;
|
||||
private Status status;
|
||||
private int size;
|
||||
private String zone;
|
||||
private Date created;
|
||||
private Set<VolumeAttachment> attachments = Sets.newLinkedHashSet();
|
||||
private String volumeType;
|
||||
private String snapshotId;
|
||||
private String name;
|
||||
private String description;
|
||||
private Map<String, String> metadata = Maps.newHashMap();
|
||||
protected String id;
|
||||
protected Volume.Status status;
|
||||
protected int size;
|
||||
protected String zone;
|
||||
protected Date created;
|
||||
protected Set<VolumeAttachment> attachments = ImmutableSet.of();
|
||||
protected String volumeType;
|
||||
protected String snapshotId;
|
||||
protected String name;
|
||||
protected String description;
|
||||
protected Map<String, String> metadata = ImmutableMap.of();
|
||||
|
||||
/** @see Volume#getId() */
|
||||
/**
|
||||
* @see Volume#getId()
|
||||
*/
|
||||
public T id(String id) {
|
||||
this.id = id;
|
||||
return self();
|
||||
}
|
||||
|
||||
/** @see Volume#getStatus() */
|
||||
public T status(Status status) {
|
||||
/**
|
||||
* @see Volume#getStatus()
|
||||
*/
|
||||
public T status(Volume.Status status) {
|
||||
this.status = status;
|
||||
return self();
|
||||
}
|
||||
|
||||
/** @see Volume#getSize() */
|
||||
/**
|
||||
* @see Volume#getSize()
|
||||
*/
|
||||
public T size(int size) {
|
||||
this.size = size;
|
||||
return self();
|
||||
}
|
||||
|
||||
/** @see Volume#getZone() */
|
||||
/**
|
||||
* @see Volume#getZone()
|
||||
*/
|
||||
public T zone(String zone) {
|
||||
this.zone = zone;
|
||||
return self();
|
||||
}
|
||||
|
||||
/** @see Volume#getCreated() */
|
||||
/**
|
||||
* @see Volume#getCreated()
|
||||
*/
|
||||
public T created(Date created) {
|
||||
this.created = created;
|
||||
return self();
|
||||
}
|
||||
|
||||
/** @see Volume#getAttachments() */
|
||||
/**
|
||||
* @see Volume#getAttachments()
|
||||
*/
|
||||
public T attachments(Set<VolumeAttachment> attachments) {
|
||||
this.attachments = attachments;
|
||||
this.attachments = ImmutableSet.copyOf(checkNotNull(attachments, "attachments"));
|
||||
return self();
|
||||
}
|
||||
|
||||
/** @see Volume#getVolumeType() */
|
||||
public T attachments(VolumeAttachment... in) {
|
||||
return attachments(ImmutableSet.copyOf(in));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Volume#getVolumeType()
|
||||
*/
|
||||
public T volumeType(String volumeType) {
|
||||
this.volumeType = volumeType;
|
||||
return self();
|
||||
}
|
||||
|
||||
/** @see Volume#getSnapshotId() */
|
||||
/**
|
||||
* @see Volume#getSnapshotId()
|
||||
*/
|
||||
public T snapshotId(String snapshotId) {
|
||||
this.snapshotId = snapshotId;
|
||||
return self();
|
||||
}
|
||||
|
||||
/** @see Volume#getMetadata() */
|
||||
public T metadata(Map<String, String> metadata) {
|
||||
this.metadata = metadata;
|
||||
return self();
|
||||
}
|
||||
|
||||
/** @see Volume#getName() */
|
||||
/**
|
||||
* @see Volume#getName()
|
||||
*/
|
||||
public T name(String name) {
|
||||
this.name = name;
|
||||
return self();
|
||||
}
|
||||
|
||||
/** @see Volume#getDescription() */
|
||||
/**
|
||||
* @see Volume#getDescription()
|
||||
*/
|
||||
public T description(String description) {
|
||||
this.description = description;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Volume#getMetadata()
|
||||
*/
|
||||
public T metadata(Map<String, String> metadata) {
|
||||
this.metadata = ImmutableMap.copyOf(checkNotNull(metadata, "metadata"));
|
||||
return self();
|
||||
}
|
||||
|
||||
public Volume build() {
|
||||
return new Volume(this);
|
||||
return new Volume(id, status, size, zone, created, attachments, volumeType, snapshotId, name, description, metadata);
|
||||
}
|
||||
|
||||
public T fromVolume(Volume in) {
|
||||
return this
|
||||
.id(in.getId())
|
||||
.status(in.getStatus())
|
||||
.size(in.getSize())
|
||||
.zone(in.getZone())
|
||||
.created(in.getCreated())
|
||||
.attachments(in.getAttachments())
|
||||
.volumeType(in.getVolumeType())
|
||||
.snapshotId(in.getSnapshotId())
|
||||
.metadata(in.getMetadata())
|
||||
;
|
||||
.id(in.getId())
|
||||
.status(in.getStatus())
|
||||
.size(in.getSize())
|
||||
.zone(in.getZone())
|
||||
.created(in.getCreated())
|
||||
.attachments(in.getAttachments())
|
||||
.volumeType(in.getVolumeType())
|
||||
.snapshotId(in.getSnapshotId())
|
||||
.name(in.getName())
|
||||
.description(in.getDescription())
|
||||
.metadata(in.getMetadata());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
|
@ -177,40 +204,37 @@ public class Volume {
|
|||
}
|
||||
}
|
||||
|
||||
protected Volume() {
|
||||
// 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 final String id;
|
||||
private final Volume.Status status;
|
||||
private final int size;
|
||||
@Named("availabilityZone")
|
||||
private final String zone;
|
||||
@Named("createdAt")
|
||||
private final Date created;
|
||||
private final Set<VolumeAttachment> attachments;
|
||||
private final String volumeType;
|
||||
private final String snapshotId;
|
||||
@Named("displayName")
|
||||
private final String name;
|
||||
@Named("displayDescription")
|
||||
private final String description;
|
||||
private final Map<String, String> metadata;
|
||||
|
||||
private String id;
|
||||
private Status status;
|
||||
private int size;
|
||||
@SerializedName(value="availabilityZone")
|
||||
private String zone;
|
||||
@SerializedName(value="createdAt")
|
||||
private Date created;
|
||||
private Set<VolumeAttachment> attachments = ImmutableSet.of();
|
||||
private String volumeType;
|
||||
private String snapshotId;
|
||||
@SerializedName(value="displayName")
|
||||
private String name;
|
||||
@SerializedName(value="displayDescription")
|
||||
private String description;
|
||||
private Map<String, String> metadata = ImmutableMap.of();
|
||||
|
||||
protected Volume(Builder<?> builder) {
|
||||
this.id = builder.id;
|
||||
this.status = builder.status;
|
||||
this.size = builder.size;
|
||||
this.zone = builder.zone;
|
||||
this.created = builder.created;
|
||||
this.attachments = ImmutableSet.copyOf(checkNotNull(builder.attachments, "attachments"));
|
||||
this.volumeType = builder.volumeType;
|
||||
this.snapshotId = builder.snapshotId;
|
||||
this.name = builder.name;
|
||||
this.description = builder.description;
|
||||
this.metadata = ImmutableMap.copyOf(checkNotNull(builder.metadata, "metadata"));
|
||||
@ConstructorProperties({
|
||||
"id", "status", "size", "availabilityZone", "createdAt", "attachments", "volumeType", "snapshotId", "displayName", "displayDescription", "metadata"
|
||||
})
|
||||
protected Volume(String id, Volume.Status status, int size, String zone, Date created, @Nullable Set<VolumeAttachment> attachments, @Nullable String volumeType, @Nullable String snapshotId, @Nullable String name, @Nullable String description, @Nullable Map<String, String> metadata) {
|
||||
this.id = checkNotNull(id, "id");
|
||||
this.status = checkNotNull(status, "status");
|
||||
this.size = size;
|
||||
this.zone = checkNotNull(zone, "zone");
|
||||
this.created = checkNotNull(created, "created");
|
||||
this.attachments = attachments == null ? ImmutableSet.<VolumeAttachment>of() : ImmutableSet.copyOf(attachments);
|
||||
this.volumeType = volumeType;
|
||||
this.snapshotId = snapshotId;
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
this.metadata = metadata == null ? ImmutableMap.<String, String>of() : ImmutableMap.copyOf(metadata);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -223,7 +247,7 @@ public class Volume {
|
|||
/**
|
||||
* @return the status of this volume
|
||||
*/
|
||||
public Status getStatus() {
|
||||
public Volume.Status getStatus() {
|
||||
return this.status;
|
||||
}
|
||||
|
||||
|
@ -251,9 +275,8 @@ public class Volume {
|
|||
/**
|
||||
* @return the set of attachments (to Servers)
|
||||
*/
|
||||
@Nullable
|
||||
public Set<VolumeAttachment> getAttachments() {
|
||||
return Collections.unmodifiableSet(this.attachments);
|
||||
return this.attachments;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -285,41 +308,36 @@ public class Volume {
|
|||
return this.description;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Map<String, String> getMetadata() {
|
||||
return Collections.unmodifiableMap(this.metadata);
|
||||
return this.metadata;
|
||||
}
|
||||
|
||||
// keeping fields short in eq/hashCode so that minor state differences don't affect collection membership
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(id, zone);
|
||||
return Objects.hashCode(id, status, size, zone, created, attachments, volumeType, snapshotId, name, description, metadata);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null || getClass() != obj.getClass())
|
||||
return false;
|
||||
if (this == obj) return true;
|
||||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
Volume that = Volume.class.cast(obj);
|
||||
return Objects.equal(this.id, that.id) && Objects.equal(this.zone, that.zone);
|
||||
return Objects.equal(this.id, that.id)
|
||||
&& Objects.equal(this.status, that.status)
|
||||
&& Objects.equal(this.size, that.size)
|
||||
&& Objects.equal(this.zone, that.zone)
|
||||
&& Objects.equal(this.created, that.created)
|
||||
&& Objects.equal(this.attachments, that.attachments)
|
||||
&& Objects.equal(this.volumeType, that.volumeType)
|
||||
&& Objects.equal(this.snapshotId, that.snapshotId)
|
||||
&& Objects.equal(this.name, that.name)
|
||||
&& Objects.equal(this.description, that.description)
|
||||
&& Objects.equal(this.metadata, that.metadata);
|
||||
}
|
||||
|
||||
protected ToStringHelper string() {
|
||||
return Objects.toStringHelper("")
|
||||
.add("id", id)
|
||||
.add("status", status)
|
||||
.add("size", size)
|
||||
.add("zone", zone)
|
||||
.add("created", created)
|
||||
.add("attachments", attachments)
|
||||
.add("volumeType", volumeType)
|
||||
.add("snapshotId", snapshotId)
|
||||
.add("name", name)
|
||||
.add("description", description)
|
||||
.add("metadata", metadata)
|
||||
;
|
||||
return Objects.toStringHelper(this)
|
||||
.add("id", id).add("status", status).add("size", size).add("zone", zone).add("created", created).add("attachments", attachments).add("volumeType", volumeType).add("snapshotId", snapshotId).add("name", name).add("description", description).add("metadata", metadata);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
/*
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
|
@ -20,6 +20,8 @@ package org.jclouds.openstack.nova.v2_0.domain;
|
|||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
|
@ -27,7 +29,7 @@ import com.google.common.base.Objects.ToStringHelper;
|
|||
|
||||
/**
|
||||
* An Openstack Nova Volume Attachment (describes how Volumes are attached to Servers)
|
||||
*/
|
||||
*/
|
||||
public class VolumeAttachment {
|
||||
|
||||
public static Builder<?> builder() {
|
||||
|
@ -35,54 +37,60 @@ public class VolumeAttachment {
|
|||
}
|
||||
|
||||
public Builder<?> toBuilder() {
|
||||
return new ConcreteBuilder().fromAttachment(this);
|
||||
return new ConcreteBuilder().fromVolumeAttachment(this);
|
||||
}
|
||||
|
||||
public static abstract class Builder<T extends Builder<T>> {
|
||||
protected abstract T self();
|
||||
|
||||
private String id;
|
||||
private String volumeId;
|
||||
private String serverId;
|
||||
private String device;
|
||||
protected String id;
|
||||
protected String volumeId;
|
||||
protected String serverId;
|
||||
protected String device;
|
||||
|
||||
/** @see VolumeAttachment#getId() */
|
||||
/**
|
||||
* @see VolumeAttachment#getId()
|
||||
*/
|
||||
public T id(String id) {
|
||||
this.id = id;
|
||||
return self();
|
||||
}
|
||||
|
||||
/** @see VolumeAttachment#getVolumeId() */
|
||||
/**
|
||||
* @see VolumeAttachment#getVolumeId()
|
||||
*/
|
||||
public T volumeId(String volumeId) {
|
||||
this.volumeId = volumeId;
|
||||
return self();
|
||||
}
|
||||
|
||||
/** @see VolumeAttachment#getServerId() */
|
||||
/**
|
||||
* @see VolumeAttachment#getServerId()
|
||||
*/
|
||||
public T serverId(String serverId) {
|
||||
this.serverId = serverId;
|
||||
return self();
|
||||
}
|
||||
|
||||
/** @see VolumeAttachment#getDevice() */
|
||||
/**
|
||||
* @see VolumeAttachment#getDevice()
|
||||
*/
|
||||
public T device(String device) {
|
||||
this.device = device;
|
||||
return self();
|
||||
}
|
||||
|
||||
public VolumeAttachment build() {
|
||||
return new VolumeAttachment(this);
|
||||
return new VolumeAttachment(id, volumeId, serverId, device);
|
||||
}
|
||||
|
||||
public T fromAttachment(VolumeAttachment in) {
|
||||
public T fromVolumeAttachment(VolumeAttachment in) {
|
||||
return this
|
||||
.id(in.getId())
|
||||
.volumeId(in.getVolumeId())
|
||||
.serverId(in.getServerId())
|
||||
.device(in.getDevice())
|
||||
;
|
||||
.id(in.getId())
|
||||
.volumeId(in.getVolumeId())
|
||||
.serverId(in.getServerId())
|
||||
.device(in.getDevice());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
|
@ -92,22 +100,19 @@ public class VolumeAttachment {
|
|||
}
|
||||
}
|
||||
|
||||
protected VolumeAttachment() {
|
||||
// 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 final String id;
|
||||
private final String volumeId;
|
||||
private final String serverId;
|
||||
private final String device;
|
||||
|
||||
private String id;
|
||||
private String volumeId;
|
||||
private String serverId;
|
||||
private String device;
|
||||
|
||||
protected VolumeAttachment(Builder<?> builder) {
|
||||
this.id = checkNotNull(builder.id, "id");
|
||||
this.volumeId = checkNotNull(builder.volumeId, "volumeId");
|
||||
this.serverId = builder.serverId;
|
||||
this.device = builder.device;
|
||||
@ConstructorProperties({
|
||||
"id", "volumeId", "serverId", "device"
|
||||
})
|
||||
protected VolumeAttachment(String id, String volumeId, @Nullable String serverId, @Nullable String device) {
|
||||
this.id = checkNotNull(id, "id");
|
||||
this.volumeId = checkNotNull(volumeId, "volumeId");
|
||||
this.serverId = serverId;
|
||||
this.device = device;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -151,19 +156,14 @@ public class VolumeAttachment {
|
|||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
VolumeAttachment that = VolumeAttachment.class.cast(obj);
|
||||
return Objects.equal(this.id, that.id)
|
||||
&& Objects.equal(this.volumeId, that.volumeId)
|
||||
&& Objects.equal(this.serverId, that.serverId)
|
||||
&& Objects.equal(this.device, that.device)
|
||||
;
|
||||
&& Objects.equal(this.volumeId, that.volumeId)
|
||||
&& Objects.equal(this.serverId, that.serverId)
|
||||
&& Objects.equal(this.device, that.device);
|
||||
}
|
||||
|
||||
protected ToStringHelper string() {
|
||||
return Objects.toStringHelper("")
|
||||
.add("id", id)
|
||||
.add("volumeId", volumeId)
|
||||
.add("serverId", serverId)
|
||||
.add("device", device)
|
||||
;
|
||||
return Objects.toStringHelper(this)
|
||||
.add("id", id).add("volumeId", volumeId).add("serverId", serverId).add("device", device);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
/*
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
|
@ -20,17 +20,19 @@ package org.jclouds.openstack.nova.v2_0.domain;
|
|||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
import java.util.Date;
|
||||
|
||||
import javax.inject.Named;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
/**
|
||||
* An Openstack Nova Volume Snapshot
|
||||
*/
|
||||
*/
|
||||
public class VolumeSnapshot {
|
||||
|
||||
public static Builder<?> builder() {
|
||||
|
@ -38,78 +40,90 @@ public class VolumeSnapshot {
|
|||
}
|
||||
|
||||
public Builder<?> toBuilder() {
|
||||
return new ConcreteBuilder().fromSnapshot(this);
|
||||
return new ConcreteBuilder().fromVolumeSnapshot(this);
|
||||
}
|
||||
|
||||
public static abstract class Builder<T extends Builder<T>> {
|
||||
protected abstract T self();
|
||||
|
||||
private String id;
|
||||
private String volumeId;
|
||||
private Volume.Status status;
|
||||
private int size;
|
||||
private Date created;
|
||||
private String name;
|
||||
private String description;
|
||||
protected String id;
|
||||
protected String volumeId;
|
||||
protected Volume.Status status;
|
||||
protected int size;
|
||||
protected Date created;
|
||||
protected String name;
|
||||
protected String description;
|
||||
|
||||
/** @see VolumeSnapshot#getId() */
|
||||
/**
|
||||
* @see VolumeSnapshot#getId()
|
||||
*/
|
||||
public T id(String id) {
|
||||
this.id = id;
|
||||
return self();
|
||||
}
|
||||
|
||||
/** @see VolumeSnapshot#getVolumeId() */
|
||||
/**
|
||||
* @see VolumeSnapshot#getVolumeId()
|
||||
*/
|
||||
public T volumeId(String volumeId) {
|
||||
this.volumeId = volumeId;
|
||||
return self();
|
||||
}
|
||||
|
||||
/** @see VolumeSnapshot#getStatus() */
|
||||
/**
|
||||
* @see VolumeSnapshot#getStatus()
|
||||
*/
|
||||
public T status(Volume.Status status) {
|
||||
this.status = status;
|
||||
return self();
|
||||
}
|
||||
|
||||
/** @see VolumeSnapshot#getSize() */
|
||||
/**
|
||||
* @see VolumeSnapshot#getSize()
|
||||
*/
|
||||
public T size(int size) {
|
||||
this.size = size;
|
||||
return self();
|
||||
}
|
||||
|
||||
/** @see VolumeSnapshot#getCreated() */
|
||||
/**
|
||||
* @see VolumeSnapshot#getCreated()
|
||||
*/
|
||||
public T created(Date created) {
|
||||
this.created = created;
|
||||
return self();
|
||||
}
|
||||
|
||||
/** @see VolumeSnapshot#getName() */
|
||||
/**
|
||||
* @see VolumeSnapshot#getName()
|
||||
*/
|
||||
public T name(String name) {
|
||||
this.name = name;
|
||||
return self();
|
||||
}
|
||||
|
||||
/** @see VolumeSnapshot#getDescription() */
|
||||
/**
|
||||
* @see VolumeSnapshot#getDescription()
|
||||
*/
|
||||
public T description(String description) {
|
||||
this.description = description;
|
||||
return self();
|
||||
}
|
||||
|
||||
public VolumeSnapshot build() {
|
||||
return new VolumeSnapshot(this);
|
||||
return new VolumeSnapshot(id, volumeId, status, size, created, name, description);
|
||||
}
|
||||
|
||||
public T fromSnapshot(VolumeSnapshot in) {
|
||||
public T fromVolumeSnapshot(VolumeSnapshot in) {
|
||||
return this
|
||||
.id(in.getId())
|
||||
.volumeId(in.getVolumeId())
|
||||
.status(in.getStatus())
|
||||
.size(in.getSize())
|
||||
.created(in.getCreated())
|
||||
.name(in.getName())
|
||||
.description(in.getDescription())
|
||||
;
|
||||
.id(in.getId())
|
||||
.volumeId(in.getVolumeId())
|
||||
.status(in.getStatus())
|
||||
.size(in.getSize())
|
||||
.created(in.getCreated())
|
||||
.name(in.getName())
|
||||
.description(in.getDescription());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
|
@ -119,31 +133,28 @@ public class VolumeSnapshot {
|
|||
}
|
||||
}
|
||||
|
||||
protected VolumeSnapshot() {
|
||||
// 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 final String id;
|
||||
private final String volumeId;
|
||||
private final Volume.Status status;
|
||||
private final int size;
|
||||
@Named("createdAt")
|
||||
private final Date created;
|
||||
@Named("displayName")
|
||||
private final String name;
|
||||
@Named("displayDescription")
|
||||
private final String description;
|
||||
|
||||
private String id;
|
||||
private String volumeId;
|
||||
private Volume.Status status;
|
||||
private int size;
|
||||
@SerializedName(value="createdAt")
|
||||
private Date created;
|
||||
@SerializedName(value="displayName")
|
||||
private String name;
|
||||
@SerializedName(value="displayDescription")
|
||||
private String description;
|
||||
|
||||
protected VolumeSnapshot(Builder<?> builder) {
|
||||
this.id = checkNotNull(builder.id, "id");
|
||||
this.volumeId = checkNotNull(builder.volumeId, "volumeId");
|
||||
this.status = checkNotNull(builder.status, "status");
|
||||
this.size = builder.size;
|
||||
this.created = builder.created;
|
||||
this.name = builder.name;
|
||||
this.description = builder.description;
|
||||
@ConstructorProperties({
|
||||
"id", "volumeId", "status", "size", "createdAt", "displayName", "displayDescription"
|
||||
})
|
||||
protected VolumeSnapshot(String id, String volumeId, Volume.Status status, int size, @Nullable Date created, @Nullable String name, @Nullable String description) {
|
||||
this.id = checkNotNull(id, "id");
|
||||
this.volumeId = checkNotNull(volumeId, "volumeId");
|
||||
this.status = checkNotNull(status, "status");
|
||||
this.size = size;
|
||||
this.created = created;
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -190,7 +201,6 @@ public class VolumeSnapshot {
|
|||
return this.name;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return the description of this snapshot - as displayed in the openstack console
|
||||
*/
|
||||
|
@ -210,25 +220,17 @@ public class VolumeSnapshot {
|
|||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
VolumeSnapshot that = VolumeSnapshot.class.cast(obj);
|
||||
return Objects.equal(this.id, that.id)
|
||||
&& Objects.equal(this.volumeId, that.volumeId)
|
||||
&& Objects.equal(this.status, that.status)
|
||||
&& Objects.equal(this.size, that.size)
|
||||
&& Objects.equal(this.created, that.created)
|
||||
&& Objects.equal(this.name, that.name)
|
||||
&& Objects.equal(this.description, that.description)
|
||||
;
|
||||
&& Objects.equal(this.volumeId, that.volumeId)
|
||||
&& Objects.equal(this.status, that.status)
|
||||
&& Objects.equal(this.size, that.size)
|
||||
&& Objects.equal(this.created, that.created)
|
||||
&& Objects.equal(this.name, that.name)
|
||||
&& Objects.equal(this.description, that.description);
|
||||
}
|
||||
|
||||
protected ToStringHelper string() {
|
||||
return Objects.toStringHelper("")
|
||||
.add("id", id)
|
||||
.add("volumeId", volumeId)
|
||||
.add("status", status)
|
||||
.add("size", size)
|
||||
.add("created", created)
|
||||
.add("name", name)
|
||||
.add("description", description)
|
||||
;
|
||||
return Objects.toStringHelper(this)
|
||||
.add("id", id).add("volumeId", volumeId).add("status", status).add("size", size).add("created", created).add("name", name).add("description", description);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
/*
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
|
@ -20,21 +20,24 @@ package org.jclouds.openstack.nova.v2_0.domain;
|
|||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.beans.ConstructorProperties;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.inject.Named;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.base.Optional;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
import com.google.common.base.Optional;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
/**
|
||||
* Volume Type used in the Volume Type Extension for Nova
|
||||
*
|
||||
* @see org.jclouds.openstack.nova.v2_0.extensions.VolumeTypeClient
|
||||
*/
|
||||
*/
|
||||
public class VolumeType {
|
||||
|
||||
public static Builder<?> builder() {
|
||||
|
@ -45,14 +48,14 @@ public class VolumeType {
|
|||
return new ConcreteBuilder().fromVolumeType(this);
|
||||
}
|
||||
|
||||
public static abstract class Builder<T extends Builder<T>> {
|
||||
public static abstract class Builder<T extends Builder<T>> {
|
||||
protected abstract T self();
|
||||
|
||||
private String id;
|
||||
private String name;
|
||||
private Date created = new Date();
|
||||
private Date updated;
|
||||
private Map<String, String> extraSpecs;
|
||||
protected String id;
|
||||
protected String name;
|
||||
protected Date created;
|
||||
protected Date updated;
|
||||
protected Map<String, String> extraSpecs = ImmutableMap.of();
|
||||
|
||||
/**
|
||||
* @see VolumeType#getId()
|
||||
|
@ -90,23 +93,22 @@ public class VolumeType {
|
|||
* @see VolumeType#getExtraSpecs()
|
||||
*/
|
||||
public T extraSpecs(Map<String, String> extraSpecs) {
|
||||
this.extraSpecs = ImmutableMap.copyOf(extraSpecs);
|
||||
this.extraSpecs = ImmutableMap.copyOf(checkNotNull(extraSpecs, "extraSpecs"));
|
||||
return self();
|
||||
}
|
||||
|
||||
public VolumeType build() {
|
||||
return new VolumeType(this);
|
||||
return new VolumeType(id, name, created, updated, extraSpecs);
|
||||
}
|
||||
|
||||
public T fromVolumeType(VolumeType in) {
|
||||
return this
|
||||
.id(in.getId())
|
||||
.name(in.getName())
|
||||
.extraSpecs(in.getExtraSpecs())
|
||||
.created(in.getCreated())
|
||||
.updated(in.getUpdated().orNull());
|
||||
.id(in.getId())
|
||||
.name(in.getName())
|
||||
.created(in.getCreated())
|
||||
.updated(in.getUpdated().orNull())
|
||||
.extraSpecs(in.getExtraSpecs());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
|
@ -116,27 +118,24 @@ public class VolumeType {
|
|||
}
|
||||
}
|
||||
|
||||
protected VolumeType() {
|
||||
// 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 final String id;
|
||||
private final String name;
|
||||
@Named("created_at")
|
||||
private final Date created;
|
||||
@Named("updated_at")
|
||||
private final Optional<Date> updated;
|
||||
@Named("extra_specs")
|
||||
private final Map<String, String> extraSpecs;
|
||||
|
||||
private String id;
|
||||
private String name;
|
||||
@SerializedName("created_at")
|
||||
private Date created;
|
||||
@SerializedName("updated_at")
|
||||
private Optional<Date> updated = Optional.absent();
|
||||
@SerializedName(value = "extra_specs")
|
||||
private Map<String, String> extraSpecs = ImmutableMap.of();
|
||||
|
||||
protected VolumeType(Builder<?> builder) {
|
||||
this.id = checkNotNull(builder.id, "id");
|
||||
this.name = checkNotNull(builder.name, "name");
|
||||
this.extraSpecs = checkNotNull(builder.extraSpecs, "extraSpecs");
|
||||
this.created = checkNotNull(builder.created, "created");
|
||||
this.updated = Optional.fromNullable(builder.updated);
|
||||
@ConstructorProperties({
|
||||
"id", "name", "created_at", "updated_at", "extra_specs"
|
||||
})
|
||||
protected VolumeType(String id, String name, Date created, @Nullable Date updated, Map<String, String> extraSpecs) {
|
||||
this.id = checkNotNull(id, "id");
|
||||
this.name = checkNotNull(name, "name");
|
||||
this.created = checkNotNull(created, "created");
|
||||
this.updated = Optional.fromNullable(updated);
|
||||
this.extraSpecs = ImmutableMap.copyOf(checkNotNull(extraSpecs, "extraSpecs"));
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
|
@ -147,18 +146,22 @@ public class VolumeType {
|
|||
return this.name;
|
||||
}
|
||||
|
||||
/** The Date the VolumeType was created */
|
||||
/**
|
||||
* The Date the VolumeType was created
|
||||
*/
|
||||
public Date getCreated() {
|
||||
return created;
|
||||
return this.created;
|
||||
}
|
||||
|
||||
/** The Date the VolumeType as last updated - absent if no updates have taken place */
|
||||
/**
|
||||
* The Date the VolumeType as last updated - absent if no updates have taken place
|
||||
*/
|
||||
public Optional<Date> getUpdated() {
|
||||
return updated;
|
||||
return this.updated;
|
||||
}
|
||||
|
||||
public Map<String, String> getExtraSpecs() {
|
||||
return Collections.unmodifiableMap(this.extraSpecs);
|
||||
return this.extraSpecs;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -172,19 +175,15 @@ public class VolumeType {
|
|||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
VolumeType that = VolumeType.class.cast(obj);
|
||||
return Objects.equal(this.id, that.id)
|
||||
&& Objects.equal(this.name, that.name)
|
||||
&& Objects.equal(this.created, that.created)
|
||||
&& Objects.equal(this.updated, that.updated)
|
||||
&& Objects.equal(this.extraSpecs, that.extraSpecs);
|
||||
&& Objects.equal(this.name, that.name)
|
||||
&& Objects.equal(this.created, that.created)
|
||||
&& Objects.equal(this.updated, that.updated)
|
||||
&& Objects.equal(this.extraSpecs, that.extraSpecs);
|
||||
}
|
||||
|
||||
protected ToStringHelper string() {
|
||||
return Objects.toStringHelper("")
|
||||
.add("id", id)
|
||||
.add("name", name)
|
||||
.add("created", created)
|
||||
.add("updated", updated)
|
||||
.add("extraSpecs", extraSpecs);
|
||||
return Objects.toStringHelper(this)
|
||||
.add("id", id).add("name", name).add("created", created).add("updated", updated).add("extraSpecs", extraSpecs);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -34,7 +34,6 @@ import javax.inject.Inject;
|
|||
import org.jclouds.encryption.internal.Base64;
|
||||
import org.jclouds.http.HttpRequest;
|
||||
import org.jclouds.openstack.nova.v2_0.NovaClient;
|
||||
import org.jclouds.openstack.nova.v2_0.domain.SecurityGroup;
|
||||
import org.jclouds.rest.MapBinder;
|
||||
import org.jclouds.rest.binders.BindToJsonPayload;
|
||||
import org.jclouds.util.Preconditions2;
|
||||
|
@ -42,6 +41,7 @@ import org.jclouds.util.Preconditions2;
|
|||
import com.google.common.base.Objects;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
import com.google.common.base.Optional;
|
||||
import com.google.common.collect.ForwardingObject;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Lists;
|
||||
|
@ -162,7 +162,7 @@ public class CreateServerOptions implements MapBinder {
|
|||
List<File> personality;
|
||||
String key_name;
|
||||
@SerializedName(value = "security_groups")
|
||||
Set<SecurityGroup> securityGroupNames;
|
||||
Set<NamedThingy> securityGroupNames;
|
||||
String user_data;
|
||||
|
||||
private ServerRequest(String name, String imageRef, String flavorRef) {
|
||||
|
@ -187,10 +187,9 @@ public class CreateServerOptions implements MapBinder {
|
|||
if (userData != null)
|
||||
server.user_data = Base64.encodeBytes(userData);
|
||||
if (securityGroupNames.size() > 0) {
|
||||
server.securityGroupNames = Sets.newHashSet();
|
||||
server.securityGroupNames = Sets.newLinkedHashSet();
|
||||
for (String groupName : securityGroupNames) {
|
||||
SecurityGroup group = SecurityGroup.builder().name(groupName).build();
|
||||
server.securityGroupNames.add(group);
|
||||
server.securityGroupNames.add(new NamedThingy(groupName));
|
||||
}
|
||||
}
|
||||
if (adminPass != null) {
|
||||
|
@ -200,6 +199,20 @@ public class CreateServerOptions implements MapBinder {
|
|||
return bindToRequest(request, ImmutableMap.of("server", server));
|
||||
}
|
||||
|
||||
private static class NamedThingy extends ForwardingObject {
|
||||
private String name;
|
||||
|
||||
private NamedThingy(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object delegate() {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* You may further customize a cloud server by injecting data into the file
|
||||
* system of the cloud server itself. This is useful, for example, for
|
||||
|
|
|
@ -64,7 +64,7 @@ public class NovaComputeServiceAdapterExpectTest extends BaseNovaComputeServiceC
|
|||
ImmutableMultimap.<String, String> builder().put("Accept", "application/json")
|
||||
.put("X-Auth-Token", authToken).build())
|
||||
.payload(payloadFromStringWithContentType(
|
||||
"{\"server\":{\"name\":\"test-e92\",\"imageRef\":\"1241\",\"flavorRef\":\"100\",\"security_groups\":[{\"name\":\"group2\"},{\"name\":\"group1\"}]}}","application/json"))
|
||||
"{\"server\":{\"name\":\"test-e92\",\"imageRef\":\"1241\",\"flavorRef\":\"100\",\"security_groups\":[{\"name\":\"group1\"}, {\"name\":\"group2\"}]}}","application/json"))
|
||||
.build();
|
||||
|
||||
HttpResponse createServerResponse = HttpResponse.builder().statusCode(202).message("HTTP/1.1 202 Accepted")
|
||||
|
|
|
@ -87,7 +87,7 @@ public class SimpleTenantUsageClientExpectTest extends BaseNovaClientExpectTest
|
|||
SimpleTenantUsage usage = client.getTenantUsage("test-1234");
|
||||
assertEquals(usage.getTenantId(), "f8535069c3fb404cb61c873b1a0b4921");
|
||||
|
||||
SimpleTenantUsage expected = SimpleTenantUsage.builder().totalHours(4.833333333333333E-7).totalLocalGbUsage(1.933333333333333E-05)
|
||||
SimpleTenantUsage expected = SimpleTenantUsage.builder().tenantId("f8535069c3fb404cb61c873b1a0b4921").totalHours(4.833333333333333E-7).totalLocalGbUsage(1.933333333333333E-05)
|
||||
.start(dateService.iso8601DateParse("2012-04-18 13:32:07.255743")).stop(dateService.iso8601DateParse("2012-04-18 13:32:07.255743"))
|
||||
.totalMemoryMbUsage(0.0014847999999999999).totalVcpusUsage(7.249999999999999E-07).serverUsages(
|
||||
ImmutableSet.of(
|
||||
|
|
|
@ -115,7 +115,7 @@ public class ServerClientExpectTest extends BaseNovaClientExpectTest {
|
|||
ImmutableMultimap.<String, String> builder().put("Accept", "application/json")
|
||||
.put("X-Auth-Token", authToken).build())
|
||||
.payload(payloadFromStringWithContentType(
|
||||
"{\"server\":{\"name\":\"test-e92\",\"imageRef\":\"1241\",\"flavorRef\":\"100\",\"security_groups\":[{\"name\":\"group2\"},{\"name\":\"group1\"}]}}","application/json"))
|
||||
"{\"server\":{\"name\":\"test-e92\",\"imageRef\":\"1241\",\"flavorRef\":\"100\",\"security_groups\":[{\"name\":\"group1\"},{\"name\":\"group2\"}]}}","application/json"))
|
||||
.build();
|
||||
|
||||
|
||||
|
|
|
@ -54,17 +54,17 @@ public class ParseComputeServiceTypicalSecurityGroupTest extends BaseItemParserT
|
|||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
public SecurityGroup expected() {
|
||||
|
||||
Set<SecurityGroupRule> securityGroupRules = ImmutableSet.<SecurityGroupRule> of(
|
||||
Set<SecurityGroupRule> securityGroupRules = ImmutableSet.of(
|
||||
SecurityGroupRule.builder().fromPort(22)
|
||||
.ipProtocol(IpProtocol.TCP).toPort(22).parentGroupId("2769")
|
||||
.ipRange("0.0.0.0/0").id("10331").build(),
|
||||
SecurityGroupRule.builder().fromPort(22).group(new TenantIdAndName("37936628937291", "jclouds_mygroup"))
|
||||
SecurityGroupRule.builder().fromPort(22).group(TenantIdAndName.builder().tenantId("37936628937291").name("jclouds_mygroup").build())
|
||||
.ipProtocol(IpProtocol.TCP).toPort(22).parentGroupId("2769")
|
||||
.id("10332").build(),
|
||||
SecurityGroupRule.builder().fromPort(8080)
|
||||
.ipProtocol(IpProtocol.TCP).toPort(8080).parentGroupId("2769")
|
||||
.ipRange("0.0.0.0/0").id("10333").build(),
|
||||
SecurityGroupRule.builder().fromPort(8080).group(new TenantIdAndName("37936628937291", "jclouds_mygroup"))
|
||||
SecurityGroupRule.builder().fromPort(8080).group(TenantIdAndName.builder().tenantId("37936628937291").name("jclouds_mygroup").build())
|
||||
.ipProtocol(IpProtocol.TCP).toPort(8080).parentGroupId("2769")
|
||||
.id("10334").build()
|
||||
);
|
||||
|
|
|
@ -57,7 +57,7 @@ public class ParseSecurityGroupTest extends BaseItemParserTest<SecurityGroup> {
|
|||
SecurityGroupRule.builder().fromPort(22)
|
||||
.ipProtocol(IpProtocol.TCP).toPort(22).parentGroupId("28")
|
||||
.ipRange("10.2.6.0/24").id("108").build(),
|
||||
SecurityGroupRule.builder().fromPort(22).group(new TenantIdAndName("admin", "11111"))
|
||||
SecurityGroupRule.builder().fromPort(22).group(TenantIdAndName.builder().name("11111").tenantId("admin").build())
|
||||
.ipProtocol(IpProtocol.TCP).toPort(22).parentGroupId("28")
|
||||
.id("109").build());
|
||||
|
||||
|
|
|
@ -95,7 +95,7 @@ public class ParseServerWithAllExtensionsTest extends BaseItemParserTest<Server>
|
|||
.addresses(ImmutableMultimap.of("private", Address.createV4("10.0.0.8")))
|
||||
.diskConfig("MANUAL")
|
||||
.extendedStatus(ServerExtendedStatus.builder().vmState("paused").powerState(3).build())
|
||||
.extraAttributes(ServerExtendedAttributes.builder().instanceName("instance-00000014").hostName("ubuntu").build())
|
||||
.extendedAttributes(ServerExtendedAttributes.builder().instanceName("instance-00000014").hostName("ubuntu").build())
|
||||
.build();
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ import org.testng.annotations.Test;
|
|||
*/
|
||||
@Test(groups = "unit", testName = "SecurityGroupPredicatesTest")
|
||||
public class SecurityGroupPredicatesTest {
|
||||
SecurityGroup ref = SecurityGroup.builder().name("jclouds").description("description").build();
|
||||
SecurityGroup ref = SecurityGroup.builder().id("12345").name("jclouds").description("description").build();
|
||||
|
||||
@Test
|
||||
public void testnameEqualsWhenEqual() {
|
||||
|
|
|
@ -23,8 +23,11 @@ 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.beans.ConstructorProperties;
|
||||
import java.net.URI;
|
||||
|
||||
import javax.inject.Named;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
|
@ -134,17 +137,12 @@ public class Link {
|
|||
}
|
||||
}
|
||||
|
||||
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")
|
||||
@Named("rel")
|
||||
protected Relation relation;
|
||||
protected String type;
|
||||
protected URI href;
|
||||
|
||||
@ConstructorProperties({"rel", "type", "href"})
|
||||
protected Link(Relation relation, @Nullable String type, URI href) {
|
||||
this.relation = checkNotNull(relation, "relation");
|
||||
this.type = type;
|
||||
|
|
|
@ -94,8 +94,7 @@ public class Resource implements Comparable<Resource> {
|
|||
return this
|
||||
.id(in.getId())
|
||||
.name(in.getName())
|
||||
.links(in.getLinks())
|
||||
;
|
||||
.links(in.getLinks());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -106,16 +105,17 @@ public class Resource implements Comparable<Resource> {
|
|||
}
|
||||
}
|
||||
|
||||
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(String id, @Nullable String name, @Nullable Set<Link> links) {
|
||||
this.id = checkNotNull(id);
|
||||
this.name = name;
|
||||
this.links = links == null ? ImmutableSet.<Link>of() : ImmutableSet.copyOf(links);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
protected Resource(Builder<?> builder) {
|
||||
this.id = checkNotNull(builder.id, "id");
|
||||
this.name = builder.name;
|
||||
|
|
Loading…
Reference in New Issue