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
|
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||||
* contributor license agreements. See the NOTICE file
|
* contributor license agreements. See the NOTICE file
|
||||||
* distributed with this work for additional information
|
* distributed with this work for additional information
|
||||||
* regarding copyright ownership. jclouds licenses this file
|
* 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
|
* "License"); you may not use this file except in compliance
|
||||||
* with the License. You may obtain a copy of the License at
|
* with the License. You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
|
@ -18,33 +18,35 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.openstack.keystone.v2_0.domain;
|
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 static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
|
import java.beans.ConstructorProperties;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import com.google.common.base.Objects;
|
import com.google.common.base.Objects;
|
||||||
|
import com.google.common.base.Objects.ToStringHelper;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO
|
* TODO
|
||||||
*
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
* @see <a href="http://docs.openstack.org/api/openstack-identity-service/2.0/content/Service_API_Client_Operations.html"
|
* @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 class Access implements Comparable<Access> {
|
||||||
|
|
||||||
public static Builder builder() {
|
public static Builder<?> builder() {
|
||||||
return new Builder();
|
return new ConcreteBuilder();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder toBuilder() {
|
public Builder<?> toBuilder() {
|
||||||
return builder().fromAccess(this);
|
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 Token token;
|
||||||
protected User user;
|
protected User user;
|
||||||
protected Set<Service> serviceCatalog = ImmutableSet.of();
|
protected Set<Service> serviceCatalog = ImmutableSet.of();
|
||||||
|
@ -52,55 +54,58 @@ public class Access implements Comparable<Access> {
|
||||||
/**
|
/**
|
||||||
* @see Access#getToken()
|
* @see Access#getToken()
|
||||||
*/
|
*/
|
||||||
public Builder token(Token token) {
|
public T token(Token token) {
|
||||||
this.token = checkNotNull(token, "token");
|
this.token = token;
|
||||||
return this;
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see Access#getUser()
|
* @see Access#getUser()
|
||||||
*/
|
*/
|
||||||
public Builder user(User user) {
|
public T user(User user) {
|
||||||
this.user = checkNotNull(user, "user");
|
this.user = user;
|
||||||
return this;
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see Access#getServiceCatalog()
|
* @see Access#getServiceCatalog()
|
||||||
*/
|
*/
|
||||||
public Builder serviceCatalog(Service... serviceCatalog) {
|
public T serviceCatalog(Set<Service> serviceCatalog) {
|
||||||
return serviceCatalog(ImmutableSet.copyOf(checkNotNull(serviceCatalog, "serviceCatalog")));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see Access#getServiceCatalog()
|
|
||||||
*/
|
|
||||||
public Builder serviceCatalog(Set<Service> serviceCatalog) {
|
|
||||||
this.serviceCatalog = ImmutableSet.copyOf(checkNotNull(serviceCatalog, "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() {
|
public Access build() {
|
||||||
return new Access(token, user, serviceCatalog);
|
return new Access(token, user, serviceCatalog);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder fromAccess(Access from) {
|
public T fromAccess(Access in) {
|
||||||
return token(from.getToken()).user(from.getUser()).serviceCatalog(from.getServiceCatalog());
|
return this
|
||||||
|
.token(in.getToken())
|
||||||
|
.user(in.getUser())
|
||||||
|
.serviceCatalog(in.getServiceCatalog());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||||
protected Access() {
|
@Override
|
||||||
// we want serializers like Gson to work w/o using sun.misc.Unsafe,
|
protected ConcreteBuilder self() {
|
||||||
// prohibited in GAE. This also implies fields are not final.
|
return this;
|
||||||
// see http://code.google.com/p/jclouds/issues/detail?id=925
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Token token;
|
private final Token token;
|
||||||
protected User user;
|
private final User user;
|
||||||
protected Set<Service> serviceCatalog = ImmutableSet.of();
|
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.token = checkNotNull(token, "token");
|
||||||
this.user = checkNotNull(user, "user");
|
this.user = checkNotNull(user, "user");
|
||||||
this.serviceCatalog = ImmutableSet.copyOf(checkNotNull(serviceCatalog, "serviceCatalog"));
|
this.serviceCatalog = ImmutableSet.copyOf(checkNotNull(serviceCatalog, "serviceCatalog"));
|
||||||
|
@ -110,34 +115,21 @@ public class Access implements Comparable<Access> {
|
||||||
* TODO
|
* TODO
|
||||||
*/
|
*/
|
||||||
public Token getToken() {
|
public Token getToken() {
|
||||||
return token;
|
return this.token;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO
|
* TODO
|
||||||
*/
|
*/
|
||||||
public User getUser() {
|
public User getUser() {
|
||||||
return user;
|
return this.user;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO
|
* TODO
|
||||||
*/
|
*/
|
||||||
public Set<Service> getServiceCatalog() {
|
public Set<Service> getServiceCatalog() {
|
||||||
return serviceCatalog;
|
return this.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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -146,10 +138,25 @@ public class Access implements Comparable<Access> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public boolean equals(Object obj) {
|
||||||
return toStringHelper("").add("token", token).add("user", user).add("serviceCatalog", serviceCatalog).toString();
|
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 string().toString();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compareTo(Access that) {
|
public int compareTo(Access that) {
|
||||||
if (that == null)
|
if (that == null)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/**
|
/*
|
||||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||||
* contributor license agreements. See the NOTICE file
|
* contributor license agreements. See the NOTICE file
|
||||||
* distributed with this work for additional information
|
* distributed with this work for additional information
|
||||||
|
@ -16,71 +16,86 @@
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.jclouds.openstack.keystone.v2_0.domain;
|
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 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.CredentialType;
|
||||||
import org.jclouds.openstack.keystone.v2_0.config.CredentialTypes;
|
import org.jclouds.openstack.keystone.v2_0.config.CredentialTypes;
|
||||||
|
|
||||||
import com.google.common.base.Objects;
|
import com.google.common.base.Objects;
|
||||||
|
import com.google.common.base.Objects.ToStringHelper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Api AccessKey Credentials
|
* 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"
|
* @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
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@CredentialType(CredentialTypes.API_ACCESS_KEY_CREDENTIALS)
|
@CredentialType(CredentialTypes.API_ACCESS_KEY_CREDENTIALS)
|
||||||
public class ApiAccessKeyCredentials {
|
public class ApiAccessKeyCredentials {
|
||||||
public static Builder builder() {
|
|
||||||
return new Builder();
|
public static Builder<?> builder() {
|
||||||
|
return new ConcreteBuilder();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder toBuilder() {
|
public Builder<?> toBuilder() {
|
||||||
return builder().fromSecretKeyCredentials(this);
|
return new ConcreteBuilder().fromApiAccessKeyCredentials(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ApiAccessKeyCredentials createWithAccessKeyAndSecretKey(String accessKey, String secretKey) {
|
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 accessKey;
|
||||||
protected String secretKey;
|
protected String secretKey;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see ApiAccessKeyCredentials#getAccessKey()
|
* @see ApiAccessKeyCredentials#getAccessKey()
|
||||||
*/
|
*/
|
||||||
protected Builder secretKey(String secretKey) {
|
public T accessKey(String accessKey) {
|
||||||
this.secretKey = secretKey;
|
this.accessKey = accessKey;
|
||||||
return this;
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see ApiAccessKeyCredentials#getSecretKey()
|
* @see ApiAccessKeyCredentials#getSecretKey()
|
||||||
*/
|
*/
|
||||||
public Builder accessKey(String accessKey) {
|
public T secretKey(String secretKey) {
|
||||||
this.accessKey = accessKey;
|
this.secretKey = secretKey;
|
||||||
return this;
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ApiAccessKeyCredentials build() {
|
public ApiAccessKeyCredentials build() {
|
||||||
return new ApiAccessKeyCredentials(accessKey, secretKey);
|
return new ApiAccessKeyCredentials(accessKey, secretKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder fromSecretKeyCredentials(ApiAccessKeyCredentials from) {
|
public T fromApiAccessKeyCredentials(ApiAccessKeyCredentials in) {
|
||||||
return accessKey(from.getAccessKey()).secretKey(from.getSecretKey());
|
return this
|
||||||
|
.accessKey(in.getAccessKey())
|
||||||
|
.secretKey(in.getSecretKey());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected final String accessKey;
|
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||||
protected final String secretKey;
|
@Override
|
||||||
|
protected ConcreteBuilder self() {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private final String accessKey;
|
||||||
|
private final String secretKey;
|
||||||
|
|
||||||
|
@ConstructorProperties({
|
||||||
|
"accessKey", "secretKey"
|
||||||
|
})
|
||||||
protected ApiAccessKeyCredentials(String accessKey, String secretKey) {
|
protected ApiAccessKeyCredentials(String accessKey, String secretKey) {
|
||||||
this.accessKey = checkNotNull(accessKey, "accessKey");
|
this.accessKey = checkNotNull(accessKey, "accessKey");
|
||||||
this.secretKey = checkNotNull(secretKey, "secretKey");
|
this.secretKey = checkNotNull(secretKey, "secretKey");
|
||||||
|
@ -90,27 +105,14 @@ public class ApiAccessKeyCredentials {
|
||||||
* @return the accessKey
|
* @return the accessKey
|
||||||
*/
|
*/
|
||||||
public String getAccessKey() {
|
public String getAccessKey() {
|
||||||
return accessKey;
|
return this.accessKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the secretKey
|
* @return the secretKey
|
||||||
*/
|
*/
|
||||||
public String getSecretKey() {
|
public String getSecretKey() {
|
||||||
return secretKey;
|
return this.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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -118,9 +120,23 @@ public class ApiAccessKeyCredentials {
|
||||||
return Objects.hashCode(accessKey, secretKey);
|
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
|
@Override
|
||||||
public String toString() {
|
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
|
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||||
* contributor license agreements. See the NOTICE file
|
* contributor license agreements. See the NOTICE file
|
||||||
* distributed with this work for additional information
|
* 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 static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.beans.ConstructorProperties;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import javax.inject.Named;
|
||||||
|
|
||||||
import org.jclouds.javax.annotation.Nullable;
|
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.openstack.v2_0.domain.Resource;
|
||||||
|
|
||||||
import com.google.common.base.Objects;
|
import com.google.common.base.Objects;
|
||||||
import com.google.common.base.Objects.ToStringHelper;
|
import com.google.common.base.Objects.ToStringHelper;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.collect.Sets;
|
|
||||||
import com.google.gson.annotations.SerializedName;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Class ApiMetadata
|
||||||
|
*
|
||||||
* @author Adam Lowe
|
* @author Adam Lowe
|
||||||
*/
|
*/
|
||||||
public class ApiMetadata extends Resource {
|
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> {
|
public static abstract class Builder<T extends Builder<T>> extends Resource.Builder<T> {
|
||||||
private String status;
|
protected String status;
|
||||||
private Date updated;
|
protected Date updated;
|
||||||
private Set<MediaType> mediaTypes = Sets.newLinkedHashSet();
|
protected Set<MediaType> mediaTypes = ImmutableSet.of();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see ApiMetadata#getStatus()
|
* @see ApiMetadata#getStatus()
|
||||||
|
@ -71,12 +74,16 @@ public class ApiMetadata extends Resource {
|
||||||
* @see ApiMetadata#getMediaTypes()
|
* @see ApiMetadata#getMediaTypes()
|
||||||
*/
|
*/
|
||||||
public T mediaTypes(Set<MediaType> mediaTypes) {
|
public T mediaTypes(Set<MediaType> mediaTypes) {
|
||||||
this.mediaTypes = mediaTypes;
|
this.mediaTypes = ImmutableSet.copyOf(checkNotNull(mediaTypes, "mediaTypes"));
|
||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public T mediaTypes(MediaType... in) {
|
||||||
|
return mediaTypes(ImmutableSet.copyOf(in));
|
||||||
|
}
|
||||||
|
|
||||||
public ApiMetadata build() {
|
public ApiMetadata build() {
|
||||||
return new ApiMetadata(this);
|
return new ApiMetadata(id, name, links, status, updated, mediaTypes);
|
||||||
}
|
}
|
||||||
|
|
||||||
public T fromApiMetadata(ApiMetadata in) {
|
public T fromApiMetadata(ApiMetadata in) {
|
||||||
|
@ -85,7 +92,6 @@ public class ApiMetadata extends Resource {
|
||||||
.updated(in.getUpdated())
|
.updated(in.getUpdated())
|
||||||
.mediaTypes(in.getMediaTypes());
|
.mediaTypes(in.getMediaTypes());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||||
|
@ -94,44 +100,34 @@ public class ApiMetadata extends Resource {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ApiMetadata() {
|
private final String status;
|
||||||
// we want serializers like Gson to work w/o using sun.misc.Unsafe,
|
private final Date updated;
|
||||||
// prohibited in GAE. This also implies fields are not final.
|
@Named("media-types")
|
||||||
// see http://code.google.com/p/jclouds/issues/detail?id=925
|
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
|
@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() {
|
public String getStatus() {
|
||||||
return this.status;
|
return this.status;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Nullable
|
||||||
*/
|
|
||||||
public Date getUpdated() {
|
public Date getUpdated() {
|
||||||
return this.updated;
|
return this.updated;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
public Set<MediaType> getMediaTypes() {
|
public Set<MediaType> getMediaTypes() {
|
||||||
return Collections.unmodifiableSet(this.mediaTypes);
|
return this.mediaTypes;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -151,9 +147,7 @@ public class ApiMetadata extends Resource {
|
||||||
|
|
||||||
protected ToStringHelper string() {
|
protected ToStringHelper string() {
|
||||||
return super.string()
|
return super.string()
|
||||||
.add("status", status)
|
.add("status", status).add("updated", updated).add("mediaTypes", mediaTypes);
|
||||||
.add("updated", updated)
|
|
||||||
.add("mediaTypes", mediaTypes);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
/**
|
/*
|
||||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||||
* contributor license agreements. See the NOTICE file
|
* contributor license agreements. See the NOTICE file
|
||||||
* distributed with this work for additional information
|
* distributed with this work for additional information
|
||||||
* regarding copyright ownership. jclouds licenses this file
|
* 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
|
* "License"); you may not use this file except in compliance
|
||||||
* with the License. You may obtain a copy of the License at
|
* with the License. You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
|
@ -16,40 +16,39 @@
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.jclouds.openstack.keystone.v2_0.domain;
|
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 static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
|
import java.beans.ConstructorProperties;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
|
||||||
import org.jclouds.javax.annotation.Nullable;
|
import org.jclouds.javax.annotation.Nullable;
|
||||||
|
|
||||||
import com.google.common.base.Objects;
|
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
|
* An network-accessible address, usually described by URL, where a service may be accessed. If
|
||||||
* using an extension for templates, you can create an endpoint template, which represents the
|
* using an extension for templates, you can create an endpoint template, which represents the
|
||||||
* templates of all the consumable services that are available across the regions.
|
* templates of all the consumable services that are available across the regions.
|
||||||
*
|
*
|
||||||
* @author AdrianCole
|
* @author AdrianCole
|
||||||
* @see <a href="http://docs.openstack.org/api/openstack-identity-service/2.0/content/Identity-Endpoint-Concepts-e1362.html"
|
* @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() {
|
public static Builder<?> builder() {
|
||||||
return new Builder();
|
return new ConcreteBuilder();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder toBuilder() {
|
public Builder<?> toBuilder() {
|
||||||
return builder().fromEndpoint(this);
|
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 versionId;
|
||||||
protected String region;
|
protected String region;
|
||||||
|
@ -63,108 +62,112 @@ public class Endpoint implements Comparable<Endpoint> {
|
||||||
/**
|
/**
|
||||||
* @see Endpoint#getVersionId()
|
* @see Endpoint#getVersionId()
|
||||||
*/
|
*/
|
||||||
public Builder versionId(String versionId) {
|
public T versionId(String versionId) {
|
||||||
this.versionId = checkNotNull(versionId, "versionId");
|
this.versionId = versionId;
|
||||||
return this;
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see Endpoint#getRegion()
|
* @see Endpoint#getRegion()
|
||||||
*/
|
*/
|
||||||
public Builder region(String region) {
|
public T region(String region) {
|
||||||
this.region = checkNotNull(region, "region");
|
this.region = region;
|
||||||
return this;
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see Endpoint#getPublicURL()
|
* @see Endpoint#getPublicURL()
|
||||||
*/
|
*/
|
||||||
public Builder publicURL(URI publicURL) {
|
public T publicURL(URI publicURL) {
|
||||||
this.publicURL = checkNotNull(publicURL, "publicURL");
|
this.publicURL = publicURL;
|
||||||
return this;
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see Endpoint#getInternalURL()
|
* @see Endpoint#getInternalURL()
|
||||||
*/
|
*/
|
||||||
public Builder internalURL(URI internalURL) {
|
public T internalURL(URI internalURL) {
|
||||||
this.internalURL = checkNotNull(internalURL, "internalURL");
|
this.internalURL = internalURL;
|
||||||
return this;
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see Endpoint#getInternalURL()
|
* @see Endpoint#getAdminURL()
|
||||||
*/
|
*/
|
||||||
public Builder adminURL(URI adminURL) {
|
public T adminURL(URI adminURL) {
|
||||||
this.adminURL = checkNotNull(adminURL, "adminURL");
|
this.adminURL = adminURL;
|
||||||
return this;
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @see Endpoint#getTenantId()
|
|
||||||
*/
|
|
||||||
public Builder tenantId(@Nullable String tenantId) {
|
|
||||||
this.tenantId = tenantId;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see Endpoint#getVersionInfo()
|
* @see Endpoint#getVersionInfo()
|
||||||
*/
|
*/
|
||||||
public Builder versionInfo(URI versionInfo) {
|
public T versionInfo(URI versionInfo) {
|
||||||
this.versionInfo = checkNotNull(versionInfo, "versionInfo");
|
this.versionInfo = versionInfo;
|
||||||
return this;
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see Endpoint#getVersionList()
|
* @see Endpoint#getVersionList()
|
||||||
*/
|
*/
|
||||||
public Builder versionList(URI versionList) {
|
public T versionList(URI versionList) {
|
||||||
this.versionList = checkNotNull(versionList, "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(null, versionId, region, publicURL, internalURL, adminURL, versionInfo, versionList, null, tenantId);
|
||||||
|
}
|
||||||
|
|
||||||
|
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());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||||
|
@Override
|
||||||
|
protected ConcreteBuilder self() {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Endpoint build() {
|
|
||||||
return new Endpoint(versionId, region, publicURL, internalURL, adminURL, tenantId, versionInfo, versionList);
|
|
||||||
}
|
|
||||||
|
|
||||||
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());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
|
||||||
}
|
|
||||||
|
|
||||||
// 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;
|
|
||||||
|
|
||||||
// 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,
|
private final String versionId;
|
||||||
@Nullable URI adminURL, @Nullable String tenantId, @Nullable URI versionInfo, @Nullable URI versionList) {
|
private final String region;
|
||||||
this.versionId = versionId;
|
private final URI publicURL;
|
||||||
|
private final URI internalURL;
|
||||||
|
private final URI adminURL;
|
||||||
|
private final URI versionInfo;
|
||||||
|
private final URI versionList;
|
||||||
|
private final String tenantId;
|
||||||
|
|
||||||
|
@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.region = region;
|
||||||
this.publicURL = publicURL;
|
this.publicURL = publicURL;
|
||||||
this.internalURL = internalURL;
|
this.internalURL = internalURL;
|
||||||
this.adminURL = adminURL;
|
this.adminURL = adminURL;
|
||||||
this.tenantId = tenantId;
|
|
||||||
this.versionInfo = versionInfo;
|
this.versionInfo = versionInfo;
|
||||||
this.versionList = versionList;
|
this.versionList = versionList;
|
||||||
}
|
}
|
||||||
|
@ -172,20 +175,20 @@ public class Endpoint implements Comparable<Endpoint> {
|
||||||
/**
|
/**
|
||||||
* When providing an ID, it is assumed that the endpoint exists in the current OpenStack
|
* When providing an ID, it is assumed that the endpoint exists in the current OpenStack
|
||||||
* deployment
|
* deployment
|
||||||
*
|
*
|
||||||
* @return the versionId of the endpoint in the current OpenStack deployment, or null if not specified
|
* @return the versionId of the endpoint in the current OpenStack deployment, or null if not specified
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
public String getVersionId() {
|
public String getVersionId() {
|
||||||
return versionId != null ? versionId : id;
|
return this.versionId;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the region of the endpoint, or null if not specified
|
* @return the region of the endpoint, or null if not specified
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
public String getRegion() {
|
public String getRegion() {
|
||||||
return region;
|
return this.region;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -193,7 +196,7 @@ public class Endpoint implements Comparable<Endpoint> {
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
public URI getPublicURL() {
|
public URI getPublicURL() {
|
||||||
return publicURL;
|
return this.publicURL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -201,7 +204,7 @@ public class Endpoint implements Comparable<Endpoint> {
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
public URI getInternalURL() {
|
public URI getInternalURL() {
|
||||||
return internalURL;
|
return this.internalURL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -209,7 +212,17 @@ public class Endpoint implements Comparable<Endpoint> {
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
public URI getAdminURL() {
|
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
|
@Nullable
|
||||||
public String getTenantId() {
|
public String getTenantId() {
|
||||||
return tenantId != null ? tenantId : tenantName;
|
return this.tenantId;
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
@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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
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
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return toStringHelper("").add("versionId", getVersionId()).add("region", region).add("publicURL", publicURL).add(
|
return string().toString();
|
||||||
"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();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/**
|
/*
|
||||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||||
* contributor license agreements. See the NOTICE file
|
* contributor license agreements. See the NOTICE file
|
||||||
* distributed with this work for additional information
|
* distributed with this work for additional information
|
||||||
|
@ -18,6 +18,8 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.openstack.keystone.v2_0.domain;
|
package org.jclouds.openstack.keystone.v2_0.domain;
|
||||||
|
|
||||||
|
import java.beans.ConstructorProperties;
|
||||||
|
|
||||||
import org.jclouds.javax.annotation.Nullable;
|
import org.jclouds.javax.annotation.Nullable;
|
||||||
|
|
||||||
import com.google.common.base.Objects;
|
import com.google.common.base.Objects;
|
||||||
|
@ -28,61 +30,70 @@ import com.google.common.base.Objects.ToStringHelper;
|
||||||
*/
|
*/
|
||||||
public class MediaType {
|
public class MediaType {
|
||||||
|
|
||||||
public static Builder builder() {
|
public static Builder<?> builder() {
|
||||||
return new Builder();
|
return new ConcreteBuilder();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder toBuilder() {
|
public Builder<?> toBuilder() {
|
||||||
return builder().fromMediaType(this);
|
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;
|
protected String base;
|
||||||
private String type;
|
protected String type;
|
||||||
|
|
||||||
public Builder base(String base) {
|
/**
|
||||||
|
* @see MediaType#getBase()
|
||||||
|
*/
|
||||||
|
public T base(String base) {
|
||||||
this.base = base;
|
this.base = base;
|
||||||
return this;
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder type(String type) {
|
/**
|
||||||
|
* @see MediaType#getType()
|
||||||
|
*/
|
||||||
|
public T type(String type) {
|
||||||
this.type = type;
|
this.type = type;
|
||||||
return this;
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
public MediaType build() {
|
public MediaType build() {
|
||||||
return new MediaType(this);
|
return new MediaType(base, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder fromMediaType(MediaType in) {
|
public T fromMediaType(MediaType in) {
|
||||||
return this.base(in.getBase()).type(in.getType());
|
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 String base;
|
|
||||||
private String type;
|
|
||||||
|
|
||||||
protected MediaType(Builder builder) {
|
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||||
this.base = builder.base;
|
@Override
|
||||||
this.type = builder.type;
|
protected ConcreteBuilder self() {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private final String base;
|
||||||
|
private final String type;
|
||||||
|
|
||||||
|
@ConstructorProperties({
|
||||||
|
"base", "type"
|
||||||
|
})
|
||||||
|
protected MediaType(@Nullable String base, @Nullable String type) {
|
||||||
|
this.base = base;
|
||||||
|
this.type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public String getBase() {
|
public String getBase() {
|
||||||
return this.base;
|
return this.base;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public String getType() {
|
public String getType() {
|
||||||
return this.type;
|
return this.type;
|
||||||
|
@ -99,14 +110,12 @@ public class MediaType {
|
||||||
if (obj == null || getClass() != obj.getClass()) return false;
|
if (obj == null || getClass() != obj.getClass()) return false;
|
||||||
MediaType that = MediaType.class.cast(obj);
|
MediaType that = MediaType.class.cast(obj);
|
||||||
return Objects.equal(this.base, that.base)
|
return Objects.equal(this.base, that.base)
|
||||||
&& Objects.equal(this.type, that.type)
|
&& Objects.equal(this.type, that.type);
|
||||||
;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ToStringHelper string() {
|
protected ToStringHelper string() {
|
||||||
return Objects.toStringHelper("")
|
return Objects.toStringHelper(this)
|
||||||
.add("base", base)
|
.add("base", base).add("type", type);
|
||||||
.add("type", type);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -114,4 +123,4 @@ public class MediaType {
|
||||||
return string().toString();
|
return string().toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/**
|
/*
|
||||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||||
* contributor license agreements. See the NOTICE file
|
* contributor license agreements. See the NOTICE file
|
||||||
* distributed with this work for additional information
|
* distributed with this work for additional information
|
||||||
|
@ -16,71 +16,85 @@
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.jclouds.openstack.keystone.v2_0.domain;
|
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 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.CredentialType;
|
||||||
import org.jclouds.openstack.keystone.v2_0.config.CredentialTypes;
|
|
||||||
|
|
||||||
import com.google.common.base.Objects;
|
import com.google.common.base.Objects;
|
||||||
|
import com.google.common.base.Objects.ToStringHelper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Password Credentials
|
* 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"
|
* @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
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@CredentialType(CredentialTypes.PASSWORD_CREDENTIALS)
|
@CredentialType("passwordCredentials")
|
||||||
public class PasswordCredentials {
|
public class PasswordCredentials {
|
||||||
public static Builder builder() {
|
|
||||||
return new Builder();
|
public static Builder<?> builder() {
|
||||||
|
return new ConcreteBuilder();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder toBuilder() {
|
public Builder<?> toBuilder() {
|
||||||
return builder().fromPasswordCredentials(this);
|
return new ConcreteBuilder().fromPasswordCredentials(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static PasswordCredentials createWithUsernameAndPassword(String username, String password) {
|
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 username;
|
||||||
protected String password;
|
protected String password;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see PasswordCredentials#getUsername()
|
* @see PasswordCredentials#getUsername()
|
||||||
*/
|
*/
|
||||||
protected Builder password(String password) {
|
public T username(String username) {
|
||||||
this.password = password;
|
this.username = username;
|
||||||
return this;
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see PasswordCredentials#getPassword()
|
* @see PasswordCredentials#getPassword()
|
||||||
*/
|
*/
|
||||||
public Builder username(String username) {
|
public T password(String password) {
|
||||||
this.username = username;
|
this.password = password;
|
||||||
return this;
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
public PasswordCredentials build() {
|
public PasswordCredentials build() {
|
||||||
return new PasswordCredentials(username, password);
|
return new PasswordCredentials(username, password);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder fromPasswordCredentials(PasswordCredentials from) {
|
public T fromPasswordCredentials(PasswordCredentials in) {
|
||||||
return username(from.getUsername()).password(from.getPassword());
|
return this
|
||||||
|
.username(in.getUsername())
|
||||||
|
.password(in.getPassword());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected final String username;
|
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||||
protected final String password;
|
@Override
|
||||||
|
protected ConcreteBuilder self() {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private final String username;
|
||||||
|
private final String password;
|
||||||
|
|
||||||
|
@ConstructorProperties({
|
||||||
|
"username", "password"
|
||||||
|
})
|
||||||
protected PasswordCredentials(String username, String password) {
|
protected PasswordCredentials(String username, String password) {
|
||||||
this.username = checkNotNull(username, "username");
|
this.username = checkNotNull(username, "username");
|
||||||
this.password = checkNotNull(password, "password");
|
this.password = checkNotNull(password, "password");
|
||||||
|
@ -90,27 +104,14 @@ public class PasswordCredentials {
|
||||||
* @return the username
|
* @return the username
|
||||||
*/
|
*/
|
||||||
public String getUsername() {
|
public String getUsername() {
|
||||||
return username;
|
return this.username;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the password
|
* @return the password
|
||||||
*/
|
*/
|
||||||
public String getPassword() {
|
public String getPassword() {
|
||||||
return password;
|
return this.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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -118,9 +119,23 @@ public class PasswordCredentials {
|
||||||
return Objects.hashCode(username, password);
|
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
|
@Override
|
||||||
public String toString() {
|
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
|
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||||
* contributor license agreements. See the NOTICE file
|
* contributor license agreements. See the NOTICE file
|
||||||
* distributed with this work for additional information
|
* distributed with this work for additional information
|
||||||
* regarding copyright ownership. jclouds licenses this file
|
* 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
|
* "License"); you may not use this file except in compliance
|
||||||
* with the License. You may obtain a copy of the License at
|
* with the License. You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
|
@ -16,17 +16,16 @@
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.jclouds.openstack.keystone.v2_0.domain;
|
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 static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
|
import java.beans.ConstructorProperties;
|
||||||
|
|
||||||
import org.jclouds.javax.annotation.Nullable;
|
import org.jclouds.javax.annotation.Nullable;
|
||||||
|
|
||||||
import com.google.common.base.Objects;
|
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
|
* A personality that a user assumes when performing a specific set of operations. A role includes a
|
||||||
|
@ -35,22 +34,23 @@ import com.google.common.collect.ComparisonChain;
|
||||||
* In Keystone, a token that is issued to a user includes the list of roles that user can assume.
|
* In Keystone, a token that is issued to a user includes the list of roles that user can assume.
|
||||||
* Services that are being called by that user determine how they interpret the set of roles a user
|
* Services that are being called by that user determine how they interpret the set of roles a user
|
||||||
* has and which operations or resources each roles grants access to.
|
* has and which operations or resources each roles grants access to.
|
||||||
*
|
*
|
||||||
* @author AdrianCole
|
* @author AdrianCole
|
||||||
* @see <a href="http://docs.openstack.org/api/openstack-identity-service/2.0/content/Identity-Service-Concepts-e1362.html"
|
* @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() {
|
public static Builder<?> builder() {
|
||||||
return new Builder();
|
return new ConcreteBuilder();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder toBuilder() {
|
public Builder<?> toBuilder() {
|
||||||
return builder().fromRole(this);
|
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 id;
|
||||||
protected String name;
|
protected String name;
|
||||||
protected String description;
|
protected String description;
|
||||||
|
@ -60,97 +60,104 @@ public class Role implements Comparable<Role> {
|
||||||
/**
|
/**
|
||||||
* @see Role#getId()
|
* @see Role#getId()
|
||||||
*/
|
*/
|
||||||
public Builder id(String id) {
|
public T id(String id) {
|
||||||
this.id = checkNotNull(id, "id");
|
this.id = id;
|
||||||
return this;
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see Role#getName()
|
* @see Role#getName()
|
||||||
*/
|
*/
|
||||||
public Builder name(String name) {
|
public T name(String name) {
|
||||||
this.name = checkNotNull(name, "name");
|
this.name = name;
|
||||||
return this;
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see Role#getDescription()
|
* @see Role#getDescription()
|
||||||
*/
|
*/
|
||||||
public Builder description(String description) {
|
public T description(String description) {
|
||||||
this.description = checkNotNull(description, "description");
|
this.description = description;
|
||||||
return this;
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see Role#getServiceId()
|
* @see Role#getServiceId()
|
||||||
*/
|
*/
|
||||||
public Builder serviceId(@Nullable String serviceId) {
|
public T serviceId(String serviceId) {
|
||||||
this.serviceId = serviceId;
|
this.serviceId = serviceId;
|
||||||
return this;
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see Role#getTenantId()
|
* @see Role#getTenantId()
|
||||||
*/
|
*/
|
||||||
public Builder tenantId(@Nullable String tenantId) {
|
public T tenantId(String tenantId) {
|
||||||
this.tenantId = tenantId;
|
this.tenantId = tenantId;
|
||||||
return this;
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Role build() {
|
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) {
|
public T fromRole(Role in) {
|
||||||
return id(from.getId()).name(from.getName()).description(from.getName()).serviceId(from.getServiceId()).tenantId(from.getTenantId());
|
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
|
|
||||||
}
|
|
||||||
|
|
||||||
protected String id;
|
|
||||||
protected String name;
|
|
||||||
protected String description;
|
|
||||||
protected String serviceId;
|
|
||||||
// renamed half-way through
|
|
||||||
@Deprecated
|
|
||||||
protected String tenantName;
|
|
||||||
protected String tenantId;
|
|
||||||
|
|
||||||
protected Role(String id, String name, @Nullable String description, @Nullable String serviceId, @Nullable String tenantId) {
|
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||||
|
@Override
|
||||||
|
protected ConcreteBuilder self() {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private final String id;
|
||||||
|
private final String name;
|
||||||
|
private final String description;
|
||||||
|
private final String serviceId;
|
||||||
|
private final 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.id = checkNotNull(id, "id");
|
||||||
this.name = checkNotNull(name, "name");
|
this.name = checkNotNull(name, "name");
|
||||||
this.description = description;
|
this.description = description;
|
||||||
this.serviceId = serviceId;
|
this.serviceId = serviceId;
|
||||||
this.tenantId = tenantId;
|
this.tenantId = tenantId != null ? tenantId : tenantName;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* When providing an ID, it is assumed that the role exists in the current OpenStack deployment
|
* When providing an ID, it is assumed that the role exists in the current OpenStack deployment
|
||||||
*
|
*
|
||||||
* @return the id of the role in the current OpenStack deployment
|
* @return the id of the role in the current OpenStack deployment
|
||||||
*/
|
*/
|
||||||
public String getId() {
|
public String getId() {
|
||||||
return id;
|
return this.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the name of the role
|
* @return the name of the role
|
||||||
*/
|
*/
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return this.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the description of the role
|
* @return the description of the role
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
return description;
|
return this.description;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -158,7 +165,7 @@ public class Role implements Comparable<Role> {
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
public String getServiceId() {
|
public String getServiceId() {
|
||||||
return serviceId;
|
return this.serviceId;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -166,37 +173,34 @@ public class Role implements Comparable<Role> {
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
public String getTenantId() {
|
public String getTenantId() {
|
||||||
return tenantId != null ? tenantId : tenantName;
|
return this.tenantId;
|
||||||
}
|
|
||||||
|
|
||||||
@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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
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
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return toStringHelper("").add("id", id).add("name", name).add("description", description).add("serviceId", serviceId).add("tenantId", getTenantId())
|
return string().toString();
|
||||||
.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int compareTo(Role that) {
|
|
||||||
return ComparisonChain.start().compare(this.id, that.id).result();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
/**
|
/*
|
||||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||||
* contributor license agreements. See the NOTICE file
|
* contributor license agreements. See the NOTICE file
|
||||||
* distributed with this work for additional information
|
* distributed with this work for additional information
|
||||||
* regarding copyright ownership. jclouds licenses this file
|
* 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
|
* "License"); you may not use this file except in compliance
|
||||||
* with the License. You may obtain a copy of the License at
|
* with the License. You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
|
@ -18,14 +18,13 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.openstack.keystone.v2_0.domain;
|
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 static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
import java.beans.ConstructorProperties;
|
import java.beans.ConstructorProperties;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import com.google.common.base.Objects;
|
import com.google.common.base.Objects;
|
||||||
|
import com.google.common.base.Objects.ToStringHelper;
|
||||||
import com.google.common.collect.ComparisonChain;
|
import com.google.common.collect.ComparisonChain;
|
||||||
import com.google.common.collect.ForwardingSet;
|
import com.google.common.collect.ForwardingSet;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
@ -34,22 +33,24 @@ import com.google.common.collect.ImmutableSet;
|
||||||
* An OpenStack service, such as Compute (Nova), Object Storage (Swift), or Image Service (Glance).
|
* An OpenStack service, such as Compute (Nova), Object Storage (Swift), or Image Service (Glance).
|
||||||
* A service provides one or more endpoints through which users can access resources and perform
|
* A service provides one or more endpoints through which users can access resources and perform
|
||||||
* (presumably useful) operations.
|
* (presumably useful) operations.
|
||||||
*
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
* @see <a href="http://docs.openstack.org/api/openstack-typeentity-service/2.0/content/Identity-Service-Concepts-e1362.html"
|
* @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 class Service extends ForwardingSet<Endpoint> implements Comparable<Service> {
|
||||||
|
|
||||||
public static Builder builder() {
|
public static Builder<?> builder() {
|
||||||
return new Builder();
|
return new ConcreteBuilder();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder toBuilder() {
|
public Builder<?> toBuilder() {
|
||||||
return builder().fromService(this);
|
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 type;
|
||||||
protected String name;
|
protected String name;
|
||||||
protected Set<Endpoint> endpoints = ImmutableSet.of();
|
protected Set<Endpoint> endpoints = ImmutableSet.of();
|
||||||
|
@ -57,49 +58,57 @@ public class Service extends ForwardingSet<Endpoint> implements Comparable<Servi
|
||||||
/**
|
/**
|
||||||
* @see Service#getType()
|
* @see Service#getType()
|
||||||
*/
|
*/
|
||||||
public Builder type(String type) {
|
public T type(String type) {
|
||||||
this.type = checkNotNull(type, "type");
|
this.type = type;
|
||||||
return this;
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see Service#getName()
|
* @see Service#getName()
|
||||||
*/
|
*/
|
||||||
public Builder name(String name) {
|
public T name(String name) {
|
||||||
this.name = checkNotNull(name, "name");
|
this.name = name;
|
||||||
return this;
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see Service#getEndpoints()
|
* @see Service#getEndpoints()
|
||||||
*/
|
*/
|
||||||
public Builder endpoints(Endpoint... endpoints) {
|
public T endpoints(Set<Endpoint> endpoints) {
|
||||||
return endpoints(ImmutableSet.copyOf(checkNotNull(endpoints, "endpoints")));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see Service#getEndpoints()
|
|
||||||
*/
|
|
||||||
public Builder endpoints(Set<Endpoint> endpoints) {
|
|
||||||
this.endpoints = ImmutableSet.copyOf(checkNotNull(endpoints, "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() {
|
public Service build() {
|
||||||
return new Service(type, name, endpoints);
|
return new Service(type, name, endpoints);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder fromService(Service from) {
|
public T fromService(Service in) {
|
||||||
return type(from.getType()).name(from.getName()).endpoints(from.getEndpoints());
|
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;
|
|
||||||
|
|
||||||
@ConstructorProperties({ "type", "name", "endpoints" })
|
private final String type;
|
||||||
public Service(String type, String name, Set<Endpoint> endpoints) {
|
private final String name;
|
||||||
|
private final Set<Endpoint> endpoints;
|
||||||
|
|
||||||
|
@ConstructorProperties({
|
||||||
|
"type", "name", "endpoints"
|
||||||
|
})
|
||||||
|
protected Service(String type, String name, Set<Endpoint> endpoints) {
|
||||||
this.type = checkNotNull(type, "type");
|
this.type = checkNotNull(type, "type");
|
||||||
this.name = checkNotNull(name, "name");
|
this.name = checkNotNull(name, "name");
|
||||||
this.endpoints = ImmutableSet.copyOf(checkNotNull(endpoints, "endpoints"));
|
this.endpoints = ImmutableSet.copyOf(checkNotNull(endpoints, "endpoints"));
|
||||||
|
@ -107,38 +116,25 @@ public class Service extends ForwardingSet<Endpoint> implements Comparable<Servi
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* such as {@code compute} (Nova), {@code object-store} (Swift), or {@code image} (Glance)
|
* such as {@code compute} (Nova), {@code object-store} (Swift), or {@code image} (Glance)
|
||||||
*
|
*
|
||||||
* @return the type of the service in the current OpenStack deployment
|
* @return the type of the service in the current OpenStack deployment
|
||||||
*/
|
*/
|
||||||
public String getType() {
|
public String getType() {
|
||||||
return type;
|
return this.type;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the name of the service
|
* @return the name of the service
|
||||||
*/
|
*/
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return this.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the endpoints assigned to the service
|
* @return the endpoints assigned to the service
|
||||||
*/
|
*/
|
||||||
public Set<Endpoint> getEndpoints() {
|
public Set<Endpoint> getEndpoints() {
|
||||||
return endpoints;
|
return this.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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -146,9 +142,24 @@ public class Service extends ForwardingSet<Endpoint> implements Comparable<Servi
|
||||||
return Objects.hashCode(type, name, endpoints);
|
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
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return toStringHelper("").add("type", type).add("name", name).add("endpoints", endpoints).toString();
|
return string().toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -163,5 +174,4 @@ public class Service extends ForwardingSet<Endpoint> implements Comparable<Servi
|
||||||
protected Set<Endpoint> delegate() {
|
protected Set<Endpoint> delegate() {
|
||||||
return endpoints;
|
return endpoints;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/**
|
/*
|
||||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||||
* contributor license agreements. See the NOTICE file
|
* contributor license agreements. See the NOTICE file
|
||||||
* distributed with this work for additional information
|
* distributed with this work for additional information
|
||||||
|
@ -16,16 +16,16 @@
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.jclouds.openstack.keystone.v2_0.domain;
|
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 static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
|
import java.beans.ConstructorProperties;
|
||||||
|
|
||||||
import org.jclouds.javax.annotation.Nullable;
|
import org.jclouds.javax.annotation.Nullable;
|
||||||
|
|
||||||
import com.google.common.base.Objects;
|
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
|
* 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
|
* @author Adrian Cole
|
||||||
* @see <a href="http://docs.openstack.org/api/openstack-identity-service/2.0/content/Identity-Service-Concepts-e1362.html"
|
* @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() {
|
public static Builder<?> builder() {
|
||||||
return new Builder();
|
return new ConcreteBuilder();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder toBuilder() {
|
public Builder<?> toBuilder() {
|
||||||
return builder().fromTenant(this);
|
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 id;
|
||||||
protected String name;
|
protected String name;
|
||||||
protected String description;
|
protected String description;
|
||||||
|
@ -53,47 +55,54 @@ public class Tenant implements Comparable<Tenant> {
|
||||||
/**
|
/**
|
||||||
* @see Tenant#getId()
|
* @see Tenant#getId()
|
||||||
*/
|
*/
|
||||||
public Builder id(String id) {
|
public T id(String id) {
|
||||||
this.id = checkNotNull(id, "id");
|
this.id = id;
|
||||||
return this;
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see Tenant#getName()
|
* @see Tenant#getName()
|
||||||
*/
|
*/
|
||||||
public Builder name(String name) {
|
public T name(String name) {
|
||||||
this.name = checkNotNull(name, "name");
|
this.name = name;
|
||||||
return this;
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see Tenant#getDescription()
|
* @see Tenant#getDescription()
|
||||||
*/
|
*/
|
||||||
public Builder description(String description) {
|
public T description(String description) {
|
||||||
this.description = description;
|
this.description = description;
|
||||||
return this;
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Tenant build() {
|
public Tenant build() {
|
||||||
return new Tenant(id, name, description);
|
return new Tenant(id, name, description);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder fromTenant(Tenant from) {
|
public T fromTenant(Tenant in) {
|
||||||
return id(from.getId()).name(from.getName());
|
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
|
|
||||||
}
|
|
||||||
|
|
||||||
protected String id;
|
|
||||||
protected String name;
|
|
||||||
protected String description;
|
|
||||||
|
|
||||||
protected Tenant(String id, String name, String description) {
|
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||||
|
@Override
|
||||||
|
protected ConcreteBuilder self() {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private final String id;
|
||||||
|
private final String name;
|
||||||
|
private final String description;
|
||||||
|
|
||||||
|
@ConstructorProperties({
|
||||||
|
"id", "name", "description"
|
||||||
|
})
|
||||||
|
protected Tenant(String id, String name, @Nullable String description) {
|
||||||
this.id = checkNotNull(id, "id");
|
this.id = checkNotNull(id, "id");
|
||||||
this.name = checkNotNull(name, "name");
|
this.name = checkNotNull(name, "name");
|
||||||
this.description = description;
|
this.description = description;
|
||||||
|
@ -105,14 +114,14 @@ public class Tenant implements Comparable<Tenant> {
|
||||||
* @return the id of the tenant in the current OpenStack deployment
|
* @return the id of the tenant in the current OpenStack deployment
|
||||||
*/
|
*/
|
||||||
public String getId() {
|
public String getId() {
|
||||||
return id;
|
return this.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the name of the tenant
|
* @return the name of the tenant
|
||||||
*/
|
*/
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return this.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -120,21 +129,7 @@ public class Tenant implements Comparable<Tenant> {
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
return description;
|
return this.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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -143,17 +138,23 @@ public class Tenant implements Comparable<Tenant> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public boolean equals(Object obj) {
|
||||||
return toStringHelper("").add("id", id).add("name", name).add("description", description).toString();
|
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
|
@Override
|
||||||
public int compareTo(Tenant that) {
|
public String toString() {
|
||||||
if (that == null)
|
return string().toString();
|
||||||
return 1;
|
|
||||||
if (this == that)
|
|
||||||
return 0;
|
|
||||||
return this.id.compareTo(that.id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
/**
|
/*
|
||||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||||
* contributor license agreements. See the NOTICE file
|
* contributor license agreements. See the NOTICE file
|
||||||
* distributed with this work for additional information
|
* distributed with this work for additional information
|
||||||
* regarding copyright ownership. jclouds licenses this file
|
* 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
|
* "License"); you may not use this file except in compliance
|
||||||
* with the License. You may obtain a copy of the License at
|
* with the License. You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
|
@ -16,16 +16,15 @@
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.jclouds.openstack.keystone.v2_0.domain;
|
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 static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
|
import java.beans.ConstructorProperties;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
import com.google.common.base.Objects;
|
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
|
* A token is an arbitrary bit of text that is used to access resources. Each token has a scope
|
||||||
|
@ -35,22 +34,24 @@ import com.google.common.base.Objects;
|
||||||
* While Keystone supports token-based authentication in this release, the intention is for it to
|
* While Keystone supports token-based authentication in this release, the intention is for it to
|
||||||
* support additional protocols in the future. The intent is for it to be an integration service
|
* support additional protocols in the future. The intent is for it to be an integration service
|
||||||
* foremost, and not a aspire to be a full-fledged identity store and management solution.
|
* foremost, and not a aspire to be a full-fledged identity store and management solution.
|
||||||
*
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
* @see <a href="http://docs.openstack.org/api/openstack-identity-service/2.0/content/Identity-Service-Concepts-e1362.html"
|
* @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 class Token implements Comparable<Token> {
|
||||||
|
|
||||||
public static Builder builder() {
|
public static Builder<?> builder() {
|
||||||
return new Builder();
|
return new ConcreteBuilder();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder toBuilder() {
|
public Builder<?> toBuilder() {
|
||||||
return builder().fromToken(this);
|
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 String id;
|
||||||
protected Date expires;
|
protected Date expires;
|
||||||
protected Tenant tenant;
|
protected Tenant tenant;
|
||||||
|
@ -58,47 +59,54 @@ public class Token implements Comparable<Token> {
|
||||||
/**
|
/**
|
||||||
* @see Token#getId()
|
* @see Token#getId()
|
||||||
*/
|
*/
|
||||||
public Builder id(String id) {
|
public T id(String id) {
|
||||||
this.id = checkNotNull(id, "id");
|
this.id = id;
|
||||||
return this;
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see Token#getExpires()
|
* @see Token#getExpires()
|
||||||
*/
|
*/
|
||||||
public Builder expires(Date expires) {
|
public T expires(Date expires) {
|
||||||
this.expires = checkNotNull(expires, "expires");
|
this.expires = expires;
|
||||||
return this;
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see Token#getTenant()
|
* @see Token#getTenant()
|
||||||
*/
|
*/
|
||||||
public Builder tenant(Tenant tenant) {
|
public T tenant(Tenant tenant) {
|
||||||
this.tenant = checkNotNull(tenant, "tenant");
|
this.tenant = tenant;
|
||||||
return this;
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Token build() {
|
public Token build() {
|
||||||
return new Token(id, expires, tenant);
|
return new Token(id, expires, tenant);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder fromToken(Token from) {
|
public T fromToken(Token in) {
|
||||||
return id(from.getId()).expires(from.getExpires()).tenant(from.getTenant());
|
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
|
|
||||||
}
|
|
||||||
|
|
||||||
protected String id;
|
|
||||||
protected Date expires;
|
|
||||||
protected Tenant tenant;
|
|
||||||
|
|
||||||
public Token(String id, Date expires, Tenant tenant) {
|
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||||
|
@Override
|
||||||
|
protected ConcreteBuilder self() {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private final String id;
|
||||||
|
private final Date expires;
|
||||||
|
private final Tenant tenant;
|
||||||
|
|
||||||
|
@ConstructorProperties({
|
||||||
|
"id", "expires", "tenant"
|
||||||
|
})
|
||||||
|
protected Token(String id, Date expires, Tenant tenant) {
|
||||||
this.id = checkNotNull(id, "id");
|
this.id = checkNotNull(id, "id");
|
||||||
this.expires = checkNotNull(expires, "expires");
|
this.expires = checkNotNull(expires, "expires");
|
||||||
this.tenant = checkNotNull(tenant, "tenant");
|
this.tenant = checkNotNull(tenant, "tenant");
|
||||||
|
@ -106,38 +114,25 @@ public class Token implements Comparable<Token> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* When providing an ID, it is assumed that the token exists in the current OpenStack deployment
|
* When providing an ID, it is assumed that the token exists in the current OpenStack deployment
|
||||||
*
|
*
|
||||||
* @return the id of the token in the current OpenStack deployment
|
* @return the id of the token in the current OpenStack deployment
|
||||||
*/
|
*/
|
||||||
public String getId() {
|
public String getId() {
|
||||||
return id;
|
return this.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the expires of the token
|
* @return the expires of the token
|
||||||
*/
|
*/
|
||||||
public Date getExpires() {
|
public Date getExpires() {
|
||||||
return expires;
|
return this.expires;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the tenant assigned to the token
|
* @return the tenant assigned to the token
|
||||||
*/
|
*/
|
||||||
public Tenant getTenant() {
|
public Tenant getTenant() {
|
||||||
return tenant;
|
return this.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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -145,9 +140,24 @@ public class Token implements Comparable<Token> {
|
||||||
return Objects.hashCode(id, expires, tenant);
|
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
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return toStringHelper("").add("id", id).add("expires", expires).add("tenant", tenant).toString();
|
return string().toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -158,5 +168,4 @@ public class Token implements Comparable<Token> {
|
||||||
return 0;
|
return 0;
|
||||||
return this.id.compareTo(that.id);
|
return this.id.compareTo(that.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
/**
|
/*
|
||||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||||
* contributor license agreements. See the NOTICE file
|
* contributor license agreements. See the NOTICE file
|
||||||
* distributed with this work for additional information
|
* distributed with this work for additional information
|
||||||
* regarding copyright ownership. jclouds licenses this file
|
* 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
|
* "License"); you may not use this file except in compliance
|
||||||
* with the License. You may obtain a copy of the License at
|
* with the License. You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
|
@ -16,16 +16,17 @@
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.jclouds.openstack.keystone.v2_0.domain;
|
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 static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
|
import java.beans.ConstructorProperties;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.jclouds.javax.annotation.Nullable;
|
||||||
|
|
||||||
import com.google.common.base.Objects;
|
import com.google.common.base.Objects;
|
||||||
|
import com.google.common.base.Objects.ToStringHelper;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -34,22 +35,24 @@ import com.google.common.collect.ImmutableSet;
|
||||||
* who claims to be making the call. Users have a login and may be assigned tokens to access users.
|
* who claims to be making the call. Users have a login and may be assigned tokens to access users.
|
||||||
* Users may be directly assigned to a particular tenant and behave as if they are contained in that
|
* Users may be directly assigned to a particular tenant and behave as if they are contained in that
|
||||||
* tenant.
|
* tenant.
|
||||||
*
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
* @see <a href="http://docs.openstack.org/api/openstack-identity-service/2.0/content/Identity-Service-Concepts-e1362.html"
|
* @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() {
|
public static Builder<?> builder() {
|
||||||
return new Builder();
|
return new ConcreteBuilder();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder toBuilder() {
|
public Builder<?> toBuilder() {
|
||||||
return builder().fromUser(this);
|
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 id;
|
||||||
protected String name;
|
protected String name;
|
||||||
protected Set<Role> roles = ImmutableSet.of();
|
protected Set<Role> roles = ImmutableSet.of();
|
||||||
|
@ -57,93 +60,84 @@ public class User implements Comparable<User> {
|
||||||
/**
|
/**
|
||||||
* @see User#getId()
|
* @see User#getId()
|
||||||
*/
|
*/
|
||||||
public Builder id(String id) {
|
public T id(String id) {
|
||||||
this.id = checkNotNull(id, "id");
|
this.id = id;
|
||||||
return this;
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see User#getName()
|
* @see User#getName()
|
||||||
*/
|
*/
|
||||||
public Builder name(String name) {
|
public T name(String name) {
|
||||||
this.name = checkNotNull(name, "name");
|
this.name = name;
|
||||||
return this;
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see User#getRoles()
|
* @see User#getRoles()
|
||||||
*/
|
*/
|
||||||
public Builder roles(Role... roles) {
|
public T roles(Set<Role> roles) {
|
||||||
return roles(ImmutableSet.copyOf(checkNotNull(roles, "roles")));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see User#getRoles()
|
|
||||||
*/
|
|
||||||
public Builder roles(Set<Role> roles) {
|
|
||||||
this.roles = ImmutableSet.copyOf(checkNotNull(roles, "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() {
|
public User build() {
|
||||||
return new User(id, name, roles);
|
return new User(id, name, roles);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder fromUser(User from) {
|
public T fromUser(User in) {
|
||||||
return id(from.getId()).name(from.getName()).roles(from.getRoles());
|
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
|
|
||||||
}
|
|
||||||
|
|
||||||
protected String id;
|
|
||||||
protected String name;
|
|
||||||
protected Set<Role> roles = ImmutableSet.of();
|
|
||||||
|
|
||||||
protected User(String id, String name, Set<Role> roles) {
|
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||||
|
@Override
|
||||||
|
protected ConcreteBuilder self() {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private final String id;
|
||||||
|
private final String name;
|
||||||
|
private final Set<Role> roles;
|
||||||
|
|
||||||
|
@ConstructorProperties({
|
||||||
|
"id", "name", "roles"
|
||||||
|
})
|
||||||
|
protected User(String id, String name, @Nullable Set<Role> roles) {
|
||||||
this.id = checkNotNull(id, "id");
|
this.id = checkNotNull(id, "id");
|
||||||
this.name = checkNotNull(name, "name");
|
this.name = checkNotNull(name, "name");
|
||||||
this.roles = ImmutableSet.copyOf(checkNotNull(roles, "roles"));
|
this.roles = roles == null ? ImmutableSet.<Role>of() : ImmutableSet.copyOf(checkNotNull(roles, "roles"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* When providing an ID, it is assumed that the user exists in the current OpenStack deployment
|
* When providing an ID, it is assumed that the user exists in the current OpenStack deployment
|
||||||
*
|
*
|
||||||
* @return the id of the user in the current OpenStack deployment
|
* @return the id of the user in the current OpenStack deployment
|
||||||
*/
|
*/
|
||||||
public String getId() {
|
public String getId() {
|
||||||
return id;
|
return this.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the name of the user
|
* @return the name of the user
|
||||||
*/
|
*/
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return this.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the roles assigned to the user
|
* @return the roles assigned to the user
|
||||||
*/
|
*/
|
||||||
public Set<Role> getRoles() {
|
public Set<Role> getRoles() {
|
||||||
return roles;
|
return this.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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -152,17 +146,23 @@ public class User implements Comparable<User> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public boolean equals(Object obj) {
|
||||||
return toStringHelper("").add("id", id).add("name", name).add("roles", roles).toString();
|
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
|
@Override
|
||||||
public int compareTo(User that) {
|
public String toString() {
|
||||||
if (that == null)
|
return string().toString();
|
||||||
return 1;
|
|
||||||
if (this == that)
|
|
||||||
return 0;
|
|
||||||
return this.id.compareTo(that.id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
/**
|
/*
|
||||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||||
* contributor license agreements. See the NOTICE file
|
* contributor license agreements. See the NOTICE file
|
||||||
* distributed with this work for additional information
|
* distributed with this work for additional information
|
||||||
* regarding copyright ownership. jclouds licenses this file
|
* 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
|
* "License"); you may not use this file except in compliance
|
||||||
* with the License. You may obtain a copy of the License at
|
* with the License. You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
|
@ -16,27 +16,27 @@
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.jclouds.openstack.v2_0.domain;
|
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 static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
|
import java.beans.ConstructorProperties;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
|
||||||
|
import javax.inject.Named;
|
||||||
|
|
||||||
import org.jclouds.javax.annotation.Nullable;
|
import org.jclouds.javax.annotation.Nullable;
|
||||||
|
|
||||||
import com.google.common.base.Objects;
|
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
|
* For convenience, resources contain links to themselves. This allows a client to easily obtain a
|
||||||
* resource URIs rather than to construct them.
|
* resource URIs rather than to construct them.
|
||||||
*
|
*
|
||||||
* @author AdrianCole
|
* @author AdrianCole
|
||||||
* @see <a href= "http://docs.openstack.org/api/openstack-compute/1.1/content/LinksReferences.html"
|
* @see <a href= "http://docs.openstack.org/api/openstack-compute/1.1/content/LinksReferences.html"
|
||||||
* />
|
/>
|
||||||
*/
|
*/
|
||||||
public class Link {
|
public class Link {
|
||||||
/**
|
/**
|
||||||
|
@ -77,75 +77,83 @@ public class Link {
|
||||||
return UNRECOGNIZED;
|
return UNRECOGNIZED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Link create(Relation relation, URI href) {
|
public static Link create(Relation relation, URI href) {
|
||||||
return new Link(relation, null, href);
|
return new Link(relation, null, href);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Link create(Relation relation,String type, URI href) {
|
public static Link create(Relation relation,String type, URI href) {
|
||||||
return new Link(relation, type, href);
|
return new Link(relation, type, href);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Builder builder() {
|
public static Builder<?> builder() {
|
||||||
return new Builder();
|
return new ConcreteBuilder();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder toBuilder() {
|
public Builder<?> toBuilder() {
|
||||||
return builder().fromLink(this);
|
return new ConcreteBuilder().fromLink(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Builder {
|
public static abstract class Builder<T extends Builder<T>> {
|
||||||
protected Relation relation;
|
protected abstract T self();
|
||||||
|
|
||||||
|
protected Link.Relation relation;
|
||||||
protected String type;
|
protected String type;
|
||||||
protected URI href;
|
protected URI href;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see Link#getRelation()
|
* @see Link#getRelation()
|
||||||
*/
|
*/
|
||||||
public Builder relation(Relation relation) {
|
public T relation(Link.Relation relation) {
|
||||||
this.relation = checkNotNull(relation, "relation");
|
this.relation = relation;
|
||||||
return this;
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see Link#getType()
|
* @see Link#getType()
|
||||||
*/
|
*/
|
||||||
public Builder type(String type) {
|
public T type(String type) {
|
||||||
this.type = type;
|
this.type = type;
|
||||||
return this;
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see Link#getHref()
|
* @see Link#getHref()
|
||||||
*/
|
*/
|
||||||
public Builder href(URI href) {
|
public T href(URI href) {
|
||||||
this.href = checkNotNull(href, "href");
|
this.href = href;
|
||||||
return this;
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Link build(){
|
public Link build() {
|
||||||
return new Link(relation, type, href);
|
return new Link(relation, type, href);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder fromLink(Link from) {
|
public T fromLink(Link in) {
|
||||||
return relation(from.getRelation()).type(from.getType()).href(from.getHref());
|
return this
|
||||||
|
.relation(in.getRelation())
|
||||||
|
.type(in.getType())
|
||||||
|
.href(in.getHref());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Link() {
|
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||||
// we want serializers like Gson to work w/o using sun.misc.Unsafe,
|
@Override
|
||||||
// prohibited in GAE. This also implies fields are not final.
|
protected ConcreteBuilder self() {
|
||||||
// see http://code.google.com/p/jclouds/issues/detail?id=925
|
return this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SerializedName("rel")
|
@Named("rel")
|
||||||
protected Relation relation;
|
private final Link.Relation relation;
|
||||||
protected String type;
|
private final String type;
|
||||||
protected URI href;
|
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.relation = checkNotNull(relation, "relation");
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.href = checkNotNull(href, "href");
|
this.href = checkNotNull(href, "href");
|
||||||
|
@ -159,39 +167,26 @@ public class Link {
|
||||||
* of the resource. For example, an OpenStack Compute image may have an alternate representation
|
* of the resource. For example, an OpenStack Compute image may have an alternate representation
|
||||||
* in the OpenStack Image service. Note that the type attribute here is used to provide a hint as
|
* in the OpenStack Image service. Note that the type attribute here is used to provide a hint as
|
||||||
* to the type of representation to expect when following the link.
|
* to the type of representation to expect when following the link.
|
||||||
*
|
*
|
||||||
* @return the relation of the resource in the current OpenStack deployment
|
* @return the relation of the resource in the current OpenStack deployment
|
||||||
*/
|
*/
|
||||||
public Relation getRelation() {
|
public Link.Relation getRelation() {
|
||||||
return relation;
|
return this.relation;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the type of the resource or null if not specified
|
* @return the type of the resource or null if not specified
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
public String getType() {
|
public String getType() {
|
||||||
return type;
|
return this.type;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the href of the resource
|
* @return the href of the resource
|
||||||
*/
|
*/
|
||||||
public URI getHref() {
|
public URI getHref() {
|
||||||
return href;
|
return this.href;
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object object) {
|
|
||||||
if (this == object) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (object instanceof Link) {
|
|
||||||
final Link other = Link.class.cast(object);
|
|
||||||
return equal(relation, other.relation) && equal(type, other.type) && equal(href, other.href);
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -199,9 +194,24 @@ public class Link {
|
||||||
return Objects.hashCode(relation, type, href);
|
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
|
@Override
|
||||||
public String toString() {
|
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
|
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||||
* contributor license agreements. See the NOTICE file
|
* contributor license agreements. See the NOTICE file
|
||||||
* distributed with this work for additional information
|
* distributed with this work for additional information
|
||||||
* regarding copyright ownership. jclouds licenses this file
|
* 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
|
* "License"); you may not use this file except in compliance
|
||||||
* with the License. You may obtain a copy of the License at
|
* with the License. You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
|
@ -16,12 +16,11 @@
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.jclouds.openstack.v2_0.domain;
|
package org.jclouds.openstack.v2_0.domain;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.beans.ConstructorProperties;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.jclouds.javax.annotation.Nullable;
|
import org.jclouds.javax.annotation.Nullable;
|
||||||
|
@ -32,11 +31,11 @@ import com.google.common.collect.ImmutableSet;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resource found in a paginated collection
|
* Resource found in a paginated collection
|
||||||
*
|
*
|
||||||
* @author AdrianCole
|
* @author AdrianCole
|
||||||
* @see <a href=
|
* @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> {
|
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>> {
|
public static abstract class Builder<T extends Builder<T>> {
|
||||||
protected abstract T self();
|
protected abstract T self();
|
||||||
|
|
||||||
private String id;
|
protected String id;
|
||||||
private String name;
|
protected String name;
|
||||||
private Set<Link> links = ImmutableSet.of();
|
protected Set<Link> links = ImmutableSet.of();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see Resource#getId()
|
* @see Resource#getId()
|
||||||
|
@ -71,31 +70,27 @@ public class Resource implements Comparable<Resource> {
|
||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @see Resource#getLinks()
|
|
||||||
*/
|
|
||||||
public T links(Link... links) {
|
|
||||||
return links(ImmutableSet.copyOf(checkNotNull(links, "links")));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see Resource#getLinks()
|
* @see Resource#getLinks()
|
||||||
*/
|
*/
|
||||||
public T links(Set<Link> links) {
|
public T links(Set<Link> links) {
|
||||||
this.links = links;
|
this.links = ImmutableSet.copyOf(checkNotNull(links, "links"));
|
||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public T links(Link... in) {
|
||||||
|
return links(ImmutableSet.copyOf(in));
|
||||||
|
}
|
||||||
|
|
||||||
public Resource build() {
|
public Resource build() {
|
||||||
return new Resource(this);
|
return new Resource(id, name, links);
|
||||||
}
|
}
|
||||||
|
|
||||||
public T fromResource(Resource in) {
|
public T fromResource(Resource in) {
|
||||||
return this
|
return this
|
||||||
.id(in.getId())
|
.id(in.getId())
|
||||||
.name(in.getName())
|
.name(in.getName())
|
||||||
.links(in.getLinks())
|
.links(in.getLinks());
|
||||||
;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,21 +100,29 @@ public class Resource implements Comparable<Resource> {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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"));
|
||||||
|
}
|
||||||
|
|
||||||
protected Resource() {
|
// leaving till beans in other openstack projects are updated
|
||||||
// we want serializers like Gson to work w/o using sun.misc.Unsafe,
|
@Deprecated
|
||||||
// prohibited in GAE. This also implies fields are not final.
|
protected Resource(Builder<?> builder) {
|
||||||
// see http://code.google.com/p/jclouds/issues/detail?id=925
|
this(builder.id, builder.name, builder.links);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String id;
|
@Deprecated
|
||||||
private String name;
|
protected Resource() {
|
||||||
private Set<Link> links = ImmutableSet.of();
|
id = null; name = null; links = ImmutableSet.of();
|
||||||
|
|
||||||
protected Resource(Builder<?> builder) {
|
|
||||||
this.id = checkNotNull(builder.id, "id");
|
|
||||||
this.name = builder.name;
|
|
||||||
this.links = ImmutableSet.copyOf(checkNotNull(builder.links, "links"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -129,7 +132,7 @@ public class Resource implements Comparable<Resource> {
|
||||||
* @return the id of the resource in the current OpenStack deployment
|
* @return the id of the resource in the current OpenStack deployment
|
||||||
*/
|
*/
|
||||||
public String getId() {
|
public String getId() {
|
||||||
return id;
|
return this.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -137,14 +140,14 @@ public class Resource implements Comparable<Resource> {
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return this.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the links of the id address allocated to the new server
|
* @return the links of the id address allocated to the new server
|
||||||
*/
|
*/
|
||||||
public Set<Link> getLinks() {
|
public Set<Link> getLinks() {
|
||||||
return Collections.unmodifiableSet(this.links);
|
return this.links;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -157,22 +160,21 @@ public class Resource implements Comparable<Resource> {
|
||||||
if (this == obj) return true;
|
if (this == obj) return true;
|
||||||
if (obj == null || getClass() != obj.getClass()) return false;
|
if (obj == null || getClass() != obj.getClass()) return false;
|
||||||
Resource that = Resource.class.cast(obj);
|
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.name, that.name)
|
||||||
&& Objects.equal(this.links, that.links);
|
&& Objects.equal(this.links, that.links);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ToStringHelper string() {
|
protected ToStringHelper string() {
|
||||||
return Objects.toStringHelper("")
|
return Objects.toStringHelper(this)
|
||||||
.add("id", getId())
|
.add("id", id).add("name", name).add("links", links);
|
||||||
.add("name", name)
|
|
||||||
.add("links", links);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return string().toString();
|
return string().toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compareTo(Resource that) {
|
public int compareTo(Resource that) {
|
||||||
if (that == null)
|
if (that == null)
|
||||||
|
|
|
@ -18,19 +18,20 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.openstack.nova.v2_0.config;
|
package org.jclouds.openstack.nova.v2_0.config;
|
||||||
|
|
||||||
|
import java.beans.ConstructorProperties;
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
|
import org.jclouds.javax.annotation.Nullable;
|
||||||
import org.jclouds.json.config.GsonModule;
|
import org.jclouds.json.config.GsonModule;
|
||||||
import org.jclouds.json.config.GsonModule.DateAdapter;
|
import org.jclouds.json.config.GsonModule.DateAdapter;
|
||||||
import org.jclouds.openstack.nova.v2_0.domain.HostResourceUsage;
|
import org.jclouds.openstack.nova.v2_0.domain.*;
|
||||||
import org.jclouds.openstack.nova.v2_0.domain.Server;
|
import org.jclouds.openstack.v2_0.domain.Link;
|
||||||
import org.jclouds.openstack.nova.v2_0.domain.ServerExtendedAttributes;
|
import org.jclouds.openstack.v2_0.domain.Resource;
|
||||||
import org.jclouds.openstack.nova.v2_0.domain.ServerExtendedStatus;
|
|
||||||
import org.jclouds.openstack.nova.v2_0.domain.ServerWithSecurityGroups;
|
|
||||||
|
|
||||||
import com.google.common.base.Objects;
|
import com.google.common.base.Objects;
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
@ -57,7 +58,8 @@ public class NovaParserModule extends AbstractModule {
|
||||||
return ImmutableMap.<Type, Object>of(
|
return ImmutableMap.<Type, Object>of(
|
||||||
HostResourceUsage.class, new HostResourceUsageAdapter(),
|
HostResourceUsage.class, new HostResourceUsageAdapter(),
|
||||||
ServerWithSecurityGroups.class, new ServerWithSecurityGroupsAdapter(),
|
ServerWithSecurityGroups.class, new ServerWithSecurityGroupsAdapter(),
|
||||||
Server.class, new ServerAdapter()
|
Server.class, new ServerAdapter(),
|
||||||
|
SecurityGroupRule.class, new SecurityGroupRuleAdapter()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,7 +73,7 @@ public class NovaParserModule extends AbstractModule {
|
||||||
public HostResourceUsage apply(HostResourceUsageView in) {
|
public HostResourceUsage apply(HostResourceUsageView in) {
|
||||||
return in.resource.toBuilder().build();
|
return in.resource.toBuilder().build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HostResourceUsage deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext context) throws JsonParseException {
|
public HostResourceUsage deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext context) throws JsonParseException {
|
||||||
return apply((HostResourceUsageView) context.deserialize(jsonElement, HostResourceUsageView.class));
|
return apply((HostResourceUsageView) context.deserialize(jsonElement, HostResourceUsageView.class));
|
||||||
|
@ -81,13 +83,18 @@ public class NovaParserModule extends AbstractModule {
|
||||||
public JsonElement serialize(HostResourceUsage hostResourceUsage, Type type, JsonSerializationContext context) {
|
public JsonElement serialize(HostResourceUsage hostResourceUsage, Type type, JsonSerializationContext context) {
|
||||||
return context.serialize(hostResourceUsage);
|
return context.serialize(hostResourceUsage);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class HostResourceUsageView {
|
private static class HostResourceUsageView {
|
||||||
protected HostResourceUsageInternal resource;
|
protected HostResourceUsageInternal resource;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class HostResourceUsageInternal extends HostResourceUsage {
|
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);
|
ServerExtendedAttributes extraAttributes = context.deserialize(jsonElement, ServerExtendedAttributes.class);
|
||||||
if (!Objects.equal(extraAttributes, ServerExtendedAttributes.builder().build())) {
|
if (!Objects.equal(extraAttributes, ServerExtendedAttributes.builder().build())) {
|
||||||
result.extraAttributes(extraAttributes);
|
result.extendedAttributes(extraAttributes);
|
||||||
}
|
}
|
||||||
return result.build();
|
return result.build();
|
||||||
}
|
}
|
||||||
|
@ -134,9 +141,47 @@ public class NovaParserModule extends AbstractModule {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class ServerInternal extends Server {
|
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
|
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||||
* contributor license agreements. See the NOTICE file
|
* contributor license agreements. See the NOTICE file
|
||||||
* distributed with this work for additional information
|
* distributed with this work for additional information
|
||||||
|
@ -16,27 +16,28 @@
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.jclouds.openstack.nova.v2_0.domain;
|
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 static com.google.common.base.Objects.toStringHelper;
|
|
||||||
|
import java.beans.ConstructorProperties;
|
||||||
|
|
||||||
import com.google.common.base.Objects;
|
import com.google.common.base.Objects;
|
||||||
|
import com.google.common.base.Objects.ToStringHelper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* IP address
|
* IP address
|
||||||
*
|
*
|
||||||
* @author AdrianCole
|
* @author AdrianCole
|
||||||
*/
|
*/
|
||||||
public class Address {
|
public class Address {
|
||||||
|
|
||||||
public static Builder builder() {
|
|
||||||
return new Builder();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder toBuilder() {
|
public static Builder<?> builder() {
|
||||||
return builder().fromAddress(this);
|
return new ConcreteBuilder();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder<?> toBuilder() {
|
||||||
|
return new ConcreteBuilder().fromAddress(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Address createV4(String addr) {
|
public static Address createV4(String addr) {
|
||||||
|
@ -47,46 +48,54 @@ public class Address {
|
||||||
return builder().version(6).addr(addr).build();
|
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 String addr;
|
||||||
protected int version;
|
protected int version;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see Address#getVersion()
|
|
||||||
*/
|
|
||||||
protected Builder version(int version) {
|
|
||||||
this.version = version;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see Address#getAddr()
|
* @see Address#getAddr()
|
||||||
*/
|
*/
|
||||||
public Builder addr(String addr) {
|
public T addr(String addr) {
|
||||||
this.addr = addr;
|
this.addr = addr;
|
||||||
return this;
|
return self();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see Address#getVersion()
|
||||||
|
*/
|
||||||
|
public T version(int version) {
|
||||||
|
this.version = version;
|
||||||
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Address build() {
|
public Address build() {
|
||||||
return new Address(addr, version);
|
return new Address(addr, version);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder fromAddress(Address from) {
|
public T fromAddress(Address in) {
|
||||||
return addr(from.getAddr()).version(from.getVersion());
|
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
|
|
||||||
}
|
|
||||||
|
|
||||||
protected String addr;
|
|
||||||
protected int version;
|
|
||||||
|
|
||||||
public Address(String addr, int version) {
|
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||||
this.addr = addr;
|
@Override
|
||||||
|
protected ConcreteBuilder self() {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private final String addr;
|
||||||
|
private final int version;
|
||||||
|
|
||||||
|
@ConstructorProperties({
|
||||||
|
"addr", "version"
|
||||||
|
})
|
||||||
|
protected Address(String addr, int version) {
|
||||||
|
this.addr = checkNotNull(addr, "addr");
|
||||||
this.version = version;
|
this.version = version;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -94,27 +103,14 @@ public class Address {
|
||||||
* @return the ip address
|
* @return the ip address
|
||||||
*/
|
*/
|
||||||
public String getAddr() {
|
public String getAddr() {
|
||||||
return addr;
|
return this.addr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the IP version, ex. 4
|
* @return the IP version, ex. 4
|
||||||
*/
|
*/
|
||||||
public int getVersion() {
|
public int getVersion() {
|
||||||
return version;
|
return this.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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -122,9 +118,23 @@ public class Address {
|
||||||
return Objects.hashCode(addr, version);
|
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
|
@Override
|
||||||
public String toString() {
|
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
|
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||||
* contributor license agreements. See the NOTICE file
|
* contributor license agreements. See the NOTICE file
|
||||||
* distributed with this work for additional information
|
* distributed with this work for additional information
|
||||||
* regarding copyright ownership. jclouds licenses this file
|
* 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
|
* "License"); you may not use this file except in compliance
|
||||||
* with the License. You may obtain a copy of the License at
|
* with the License. You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
|
@ -18,12 +18,19 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.openstack.nova.v2_0.domain;
|
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.net.URI;
|
||||||
import java.util.Date;
|
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 org.jclouds.openstack.v2_0.domain.Resource;
|
||||||
|
|
||||||
import com.google.common.base.Objects;
|
import com.google.common.base.Objects;
|
||||||
|
import com.google.common.base.Objects.ToStringHelper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The OpenStack Compute API is extensible. Extensions serve two purposes: They
|
* The OpenStack Compute API is extensible. Extensions serve two purposes: They
|
||||||
|
@ -33,25 +40,26 @@ import com.google.common.base.Objects;
|
||||||
*
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
* @see <a href=
|
* @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 class Extension extends Resource {
|
||||||
public static Builder<?> builder() {
|
|
||||||
|
public static Builder<?> builder() {
|
||||||
return new ConcreteBuilder();
|
return new ConcreteBuilder();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder<?> toBuilder() {
|
public Builder<?> toBuilder() {
|
||||||
return new ConcreteBuilder().fromExtension(this);
|
return new ConcreteBuilder().fromExtension(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static abstract class Builder<T extends Builder<T>> extends Resource.Builder<T> {
|
public static abstract class Builder<T extends Builder<T>> extends Resource.Builder<T> {
|
||||||
private URI namespace;
|
protected URI namespace;
|
||||||
private String alias;
|
protected String alias;
|
||||||
private Date updated;
|
protected Date updated;
|
||||||
private String description;
|
protected String description;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see Extension#getNamespace()
|
* @see Extension#getNamespace()
|
||||||
*/
|
*/
|
||||||
public T namespace(URI namespace) {
|
public T namespace(URI namespace) {
|
||||||
|
@ -59,16 +67,23 @@ public class Extension extends Resource {
|
||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see Extension#getAlias()
|
* @see Extension#getAlias()
|
||||||
*/
|
*/
|
||||||
public T alias(String alias) {
|
public T alias(String alias) {
|
||||||
id(alias);
|
|
||||||
this.alias = alias;
|
this.alias = alias;
|
||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @see Extension#getAlias()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public T id(String id) {
|
||||||
|
return alias(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
* @see Extension#getUpdated()
|
* @see Extension#getUpdated()
|
||||||
*/
|
*/
|
||||||
public T updated(Date updated) {
|
public T updated(Date updated) {
|
||||||
|
@ -76,7 +91,7 @@ public class Extension extends Resource {
|
||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see Extension#getDescription()
|
* @see Extension#getDescription()
|
||||||
*/
|
*/
|
||||||
public T description(String description) {
|
public T description(String description) {
|
||||||
|
@ -85,18 +100,16 @@ public class Extension extends Resource {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Extension build() {
|
public Extension build() {
|
||||||
return new Extension(this);
|
return new Extension(name, links, namespace, alias, updated, description);
|
||||||
}
|
}
|
||||||
|
|
||||||
public T fromExtension(Extension in) {
|
public T fromExtension(Extension in) {
|
||||||
return super.fromResource(in)
|
return super.fromResource(in)
|
||||||
.namespace(in.getNamespace())
|
.namespace(in.getNamespace())
|
||||||
.alias(in.getAlias())
|
.alias(in.getAlias())
|
||||||
.updated(in.getUpdated())
|
.updated(in.getUpdated())
|
||||||
.description(in.getDescription())
|
.description(in.getDescription());
|
||||||
;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||||
|
@ -105,39 +118,32 @@ public class Extension extends Resource {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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 URI namespace;
|
|
||||||
private String alias;
|
|
||||||
private Date updated;
|
|
||||||
private String description;
|
|
||||||
|
|
||||||
protected Extension(Builder<?> builder) {
|
private final URI namespace;
|
||||||
super(builder);
|
private final String alias;
|
||||||
this.namespace = builder.namespace;
|
private final Date updated;
|
||||||
this.alias = builder.alias;
|
private final String description;
|
||||||
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() {
|
public URI getNamespace() {
|
||||||
return this.namespace;
|
return this.namespace;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getId() {
|
|
||||||
return this.alias;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getAlias() {
|
public String getAlias() {
|
||||||
return this.alias;
|
return this.alias;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
public Date getUpdated() {
|
public Date getUpdated() {
|
||||||
return this.updated;
|
return this.updated;
|
||||||
}
|
}
|
||||||
|
@ -147,11 +153,24 @@ public class Extension extends Resource {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Objects.ToStringHelper string() {
|
public int hashCode() {
|
||||||
return super.string()
|
return Objects.hashCode(namespace, alias, updated, description);
|
||||||
.add("namespace", namespace)
|
|
||||||
.add("alias", alias)
|
|
||||||
.add("updated", updated)
|
|
||||||
.add("description", 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
|
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||||
* contributor license agreements. See the NOTICE file
|
* contributor license agreements. See the NOTICE file
|
||||||
* distributed with this work for additional information
|
* distributed with this work for additional information
|
||||||
|
@ -18,40 +18,46 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.openstack.nova.v2_0.domain;
|
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 org.jclouds.openstack.v2_0.domain.Resource;
|
||||||
|
|
||||||
import com.google.common.base.Objects;
|
import com.google.common.base.Objects;
|
||||||
|
import com.google.common.base.Objects.ToStringHelper;
|
||||||
import com.google.common.base.Optional;
|
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
|
* A flavor is an available hardware configuration for a server. Each flavor has
|
||||||
* a unique combination of disk space and memory capacity.
|
* a unique combination of disk space and memory capacity.
|
||||||
*
|
*
|
||||||
* @author Jeremy Daggett
|
* @author Jeremy Daggett
|
||||||
* @see <a href=
|
* @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 class Flavor extends Resource {
|
||||||
public static Builder<?> builder() {
|
|
||||||
|
public static Builder<?> builder() {
|
||||||
return new ConcreteBuilder();
|
return new ConcreteBuilder();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder<?> toBuilder() {
|
public Builder<?> toBuilder() {
|
||||||
return new ConcreteBuilder().fromFlavor(this);
|
return new ConcreteBuilder().fromFlavor(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static abstract class Builder<T extends Builder<T>> extends Resource.Builder<T> {
|
public static abstract class Builder<T extends Builder<T>> extends Resource.Builder<T> {
|
||||||
private int ram;
|
protected int ram;
|
||||||
private int disk;
|
protected int disk;
|
||||||
private int vcpus;
|
protected int vcpus;
|
||||||
private String swap;
|
protected String swap;
|
||||||
private Double rxtxFactor;
|
protected Double rxtxFactor;
|
||||||
private Integer ephemeral;
|
protected Integer ephemeral;
|
||||||
|
|
||||||
|
/**
|
||||||
/**
|
|
||||||
* @see Flavor#getRam()
|
* @see Flavor#getRam()
|
||||||
*/
|
*/
|
||||||
public T ram(int ram) {
|
public T ram(int ram) {
|
||||||
|
@ -59,7 +65,7 @@ public class Flavor extends Resource {
|
||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see Flavor#getDisk()
|
* @see Flavor#getDisk()
|
||||||
*/
|
*/
|
||||||
public T disk(int disk) {
|
public T disk(int disk) {
|
||||||
|
@ -67,7 +73,7 @@ public class Flavor extends Resource {
|
||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see Flavor#getVcpus()
|
* @see Flavor#getVcpus()
|
||||||
*/
|
*/
|
||||||
public T vcpus(int vcpus) {
|
public T vcpus(int vcpus) {
|
||||||
|
@ -75,45 +81,43 @@ public class Flavor extends Resource {
|
||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see Flavor#getVcpus()
|
* @see Flavor#getSwap()
|
||||||
*/
|
*/
|
||||||
public T swap(String swap) {
|
public T swap(String swap) {
|
||||||
this.swap = swap;
|
this.swap = swap;
|
||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see Flavor#getVcpus()
|
* @see Flavor#getRxtxFactor()
|
||||||
*/
|
*/
|
||||||
public T rxtxFactor(Double rxtxFactor) {
|
public T rxtxFactor(Double rxtxFactor) {
|
||||||
this.rxtxFactor = rxtxFactor;
|
this.rxtxFactor = rxtxFactor;
|
||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see Flavor#getVcpus()
|
* @see Flavor#getEphemeral()
|
||||||
*/
|
*/
|
||||||
public T ephemeral(Integer ephemeral) {
|
public T ephemeral(Integer ephemeral) {
|
||||||
this.ephemeral = ephemeral;
|
this.ephemeral = ephemeral;
|
||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Flavor build() {
|
public Flavor build() {
|
||||||
return new Flavor(this);
|
return new Flavor(id, name, links, ram, disk, vcpus, swap, rxtxFactor, ephemeral);
|
||||||
}
|
}
|
||||||
|
|
||||||
public T fromFlavor(Flavor in) {
|
public T fromFlavor(Flavor in) {
|
||||||
return super.fromResource(in)
|
return super.fromResource(in)
|
||||||
.ram(in.getRam())
|
.ram(in.getRam())
|
||||||
.disk(in.getDisk())
|
.disk(in.getDisk())
|
||||||
.vcpus(in.getVcpus())
|
.vcpus(in.getVcpus())
|
||||||
.swap(in.getSwap().orNull())
|
.swap(in.getSwap().orNull())
|
||||||
.rxtxFactor(in.getRxtxFactor().orNull())
|
.rxtxFactor(in.getRxtxFactor().orNull())
|
||||||
.ephemeral(in.getEphemeral().orNull());
|
.ephemeral(in.getEphemeral().orNull());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||||
|
@ -122,30 +126,28 @@ public class Flavor extends Resource {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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 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) {
|
private final int ram;
|
||||||
super(builder);
|
private final int disk;
|
||||||
this.ram = builder.ram;
|
private final int vcpus;
|
||||||
this.disk = builder.disk;
|
private final Optional<String> swap;
|
||||||
this.vcpus = builder.vcpus;
|
@Named("rxtx_factor")
|
||||||
this.swap = Optional.fromNullable(builder.swap);
|
private final Optional<Double> rxtxFactor;
|
||||||
this.rxtxFactor = Optional.fromNullable(builder.rxtxFactor);
|
@Named("OS-FLV-EXT-DATA:ephemeral")
|
||||||
this.ephemeral = Optional.fromNullable(builder.ephemeral);
|
private final Optional<Integer> 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() {
|
public int getRam() {
|
||||||
|
@ -161,33 +163,46 @@ public class Flavor extends Resource {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Optional<String> getSwap() {
|
public Optional<String> getSwap() {
|
||||||
return swap;
|
return this.swap;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Optional<Double> getRxtxFactor() {
|
public Optional<Double> getRxtxFactor() {
|
||||||
return rxtxFactor;
|
return this.rxtxFactor;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves ephemeral disk space in GB
|
* Retrieves ephemeral disk space in GB
|
||||||
* <p/>
|
* <p/>
|
||||||
* NOTE: This field is only present if the Flavor Extra Data extension is installed (alias "OS-FLV-EXT-DATA").
|
* NOTE: This field is only present if the Flavor Extra Data extension is installed (alias "OS-FLV-EXT-DATA").
|
||||||
*
|
*
|
||||||
* @see org.jclouds.openstack.nova.v2_0.features.ExtensionClient#getExtensionByAlias
|
* @see org.jclouds.openstack.nova.v2_0.features.ExtensionClient#getExtensionByAlias
|
||||||
* @see org.jclouds.openstack.nova.v2_0.extensions.ExtensionNamespaces#FLAVOR_EXTRA_DATA
|
* @see org.jclouds.openstack.nova.v2_0.extensions.ExtensionNamespaces#FLAVOR_EXTRA_DATA
|
||||||
*/
|
*/
|
||||||
public Optional<Integer> getEphemeral() {
|
public Optional<Integer> getEphemeral() {
|
||||||
return ephemeral;
|
return this.ephemeral;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Objects.ToStringHelper string() {
|
public int hashCode() {
|
||||||
return super.string()
|
return Objects.hashCode(ram, disk, vcpus, swap, rxtxFactor, ephemeral);
|
||||||
.add("ram", ram)
|
|
||||||
.add("disk", disk)
|
|
||||||
.add("vcpus", vcpus)
|
|
||||||
.add("swap", swap)
|
|
||||||
.add("rxtxFactor", rxtxFactor)
|
|
||||||
.add("ephemeral", 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
|
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||||
* contributor license agreements. See the NOTICE file
|
* contributor license agreements. See the NOTICE file
|
||||||
* distributed with this work for additional information
|
* distributed with this work for additional information
|
||||||
|
@ -18,11 +18,16 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.openstack.nova.v2_0.domain;
|
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 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
|
* 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 Jeremy Daggett
|
||||||
* @author chamerling
|
* @author chamerling
|
||||||
*/
|
*/
|
||||||
public class FloatingIP implements Comparable<FloatingIP> {
|
public class FloatingIP implements Comparable<FloatingIP> {
|
||||||
public static Builder builder() {
|
|
||||||
return new Builder();
|
public static Builder<?> builder() {
|
||||||
|
return new ConcreteBuilder();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder<?> toBuilder() {
|
||||||
|
return new ConcreteBuilder().fromFloatingIP(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder toBuilder() {
|
public static abstract class Builder<T extends Builder<T>> {
|
||||||
return builder().fromFloatingIp(this);
|
protected abstract T self();
|
||||||
}
|
|
||||||
|
|
||||||
public static class Builder {
|
protected String id;
|
||||||
private String id;
|
protected String ip;
|
||||||
private String ip;
|
protected String fixedIp;
|
||||||
private String fixedIp;
|
protected String instanceId;
|
||||||
private String instanceId;
|
|
||||||
|
/**
|
||||||
public Builder id(String id) {
|
* @see FloatingIP#getId()
|
||||||
|
*/
|
||||||
|
public T id(String id) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
return this;
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder ip(String ip) {
|
/**
|
||||||
|
* @see FloatingIP#getIp()
|
||||||
|
*/
|
||||||
|
public T ip(String ip) {
|
||||||
this.ip = ip;
|
this.ip = ip;
|
||||||
return this;
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder fixedIp(String fixedIp) {
|
/**
|
||||||
|
* @see FloatingIP#getFixedIp()
|
||||||
|
*/
|
||||||
|
public T fixedIp(String fixedIp) {
|
||||||
this.fixedIp = fixedIp;
|
this.fixedIp = fixedIp;
|
||||||
return this;
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder instanceId(String instanceId) {
|
/**
|
||||||
|
* @see FloatingIP#getInstanceId()
|
||||||
|
*/
|
||||||
|
public T instanceId(String instanceId) {
|
||||||
this.instanceId = instanceId;
|
this.instanceId = instanceId;
|
||||||
return this;
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
public FloatingIP build() {
|
public FloatingIP build() {
|
||||||
return new FloatingIP(id, ip, fixedIp, instanceId);
|
return new FloatingIP(id, ip, fixedIp, instanceId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder fromFloatingIp(FloatingIP in) {
|
public T fromFloatingIP(FloatingIP in) {
|
||||||
return id(in.getId()).ip(in.getIp()).fixedIp(in.getFixedIp()).instanceId(in.getInstanceId());
|
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 String id;
|
|
||||||
private String ip;
|
|
||||||
@SerializedName("fixed_ip")
|
|
||||||
private String fixedIp;
|
|
||||||
@SerializedName("instance_id")
|
|
||||||
private String instanceId;
|
|
||||||
|
|
||||||
|
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||||
|
@Override
|
||||||
|
protected ConcreteBuilder self() {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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) {
|
protected FloatingIP(String id, String ip, @Nullable String fixedIp, @Nullable String instanceId) {
|
||||||
this.id = id;
|
this.id = checkNotNull(id, "id");
|
||||||
this.ip = ip;
|
this.ip = checkNotNull(ip, "ip");
|
||||||
this.fixedIp = fixedIp;
|
this.fixedIp = fixedIp;
|
||||||
this.instanceId = instanceId;
|
this.instanceId = instanceId;
|
||||||
}
|
}
|
||||||
|
@ -105,66 +132,44 @@ public class FloatingIP implements Comparable<FloatingIP> {
|
||||||
return this.ip;
|
return this.ip;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
public String getFixedIp() {
|
public String getFixedIp() {
|
||||||
return this.fixedIp;
|
return this.fixedIp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
public String getInstanceId() {
|
public String getInstanceId() {
|
||||||
return this.instanceId;
|
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
|
@Override
|
||||||
public int compareTo(FloatingIP o) {
|
public int compareTo(FloatingIP o) {
|
||||||
return this.id.compareTo(o.getId());
|
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
|
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||||
* contributor license agreements. See the NOTICE file
|
* contributor license agreements. See the NOTICE file
|
||||||
* distributed with this work for additional information
|
* distributed with this work for additional information
|
||||||
|
@ -18,52 +18,59 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.openstack.nova.v2_0.domain;
|
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.javax.annotation.Nullable;
|
||||||
|
|
||||||
import com.google.common.base.Objects;
|
import com.google.common.base.Objects;
|
||||||
import com.google.common.base.Objects.ToStringHelper;
|
import com.google.common.base.Objects.ToStringHelper;
|
||||||
import com.google.gson.annotations.SerializedName;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class Host
|
* Class Host
|
||||||
*/
|
*/
|
||||||
public class Host {
|
public class Host {
|
||||||
|
|
||||||
public static Builder<?> builder() {
|
public static Builder<?> builder() {
|
||||||
return new ConcreteBuilder();
|
return new ConcreteBuilder();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder<?> toBuilder() {
|
public Builder<?> toBuilder() {
|
||||||
return new ConcreteBuilder().fromHost(this);
|
return new ConcreteBuilder().fromHost(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static abstract class Builder<T extends Builder<T>> {
|
public static abstract class Builder<T extends Builder<T>> {
|
||||||
protected abstract T self();
|
protected abstract T self();
|
||||||
|
|
||||||
private String name;
|
protected String name;
|
||||||
private String service;
|
protected String service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see Host#getName()
|
||||||
|
*/
|
||||||
public T name(String name) {
|
public T name(String name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see Host#getService()
|
||||||
|
*/
|
||||||
public T service(String service) {
|
public T service(String service) {
|
||||||
this.service = service;
|
this.service = service;
|
||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Host build() {
|
public Host build() {
|
||||||
return new Host(this);
|
return new Host(name, service);
|
||||||
}
|
}
|
||||||
|
|
||||||
public T fromHost(Host in) {
|
public T fromHost(Host in) {
|
||||||
return this
|
return this
|
||||||
.name(in.getName())
|
.name(in.getName())
|
||||||
.service(in.getService())
|
.service(in.getService());
|
||||||
;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||||
|
@ -72,31 +79,24 @@ public class Host {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
|
||||||
}
|
|
||||||
|
|
||||||
@SerializedName(value="host_name")
|
|
||||||
private String name;
|
|
||||||
private String service;
|
|
||||||
|
|
||||||
protected Host(Builder<?> builder) {
|
@Named("host_name")
|
||||||
this.name = builder.name;
|
private final String name;
|
||||||
this.service = builder.service;
|
private final String service;
|
||||||
|
|
||||||
|
@ConstructorProperties({
|
||||||
|
"host_name", "service"
|
||||||
|
})
|
||||||
|
protected Host(@Nullable String name, @Nullable String service) {
|
||||||
|
this.name = name;
|
||||||
|
this.service = service;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return this.name;
|
return this.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public String getService() {
|
public String getService() {
|
||||||
return this.service;
|
return this.service;
|
||||||
|
@ -113,20 +113,17 @@ public class Host {
|
||||||
if (obj == null || getClass() != obj.getClass()) return false;
|
if (obj == null || getClass() != obj.getClass()) return false;
|
||||||
Host that = Host.class.cast(obj);
|
Host that = Host.class.cast(obj);
|
||||||
return Objects.equal(this.name, that.name)
|
return Objects.equal(this.name, that.name)
|
||||||
&& Objects.equal(this.service, that.service)
|
&& Objects.equal(this.service, that.service);
|
||||||
;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ToStringHelper string() {
|
protected ToStringHelper string() {
|
||||||
return Objects.toStringHelper("")
|
return Objects.toStringHelper(this)
|
||||||
.add("name", name)
|
.add("name", name).add("service", service);
|
||||||
.add("service", service)
|
|
||||||
;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return string().toString();
|
return string().toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/**
|
/*
|
||||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||||
* contributor license agreements. See the NOTICE file
|
* contributor license agreements. See the NOTICE file
|
||||||
* distributed with this work for additional information
|
* distributed with this work for additional information
|
||||||
|
@ -20,46 +20,49 @@ package org.jclouds.openstack.nova.v2_0.domain;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.beans.ConstructorProperties;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
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;
|
||||||
import com.google.common.base.Optional;
|
|
||||||
import com.google.common.base.Objects.ToStringHelper;
|
import com.google.common.base.Objects.ToStringHelper;
|
||||||
|
import com.google.common.base.Optional;
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.common.collect.ImmutableSet;
|
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")
|
* Aggregates can be manipulated using the Aggregate Extension to Nova (alias "OS-AGGREGATES")
|
||||||
*
|
*
|
||||||
* @see org.jclouds.openstack.nova.v2_0.extensions.HostAggregateClient
|
* @see org.jclouds.openstack.nova.v2_0.extensions.HostAggregateClient
|
||||||
*/
|
*/
|
||||||
public class HostAggregate {
|
public class HostAggregate {
|
||||||
|
|
||||||
public static Builder<?> builder() {
|
public static Builder<?> builder() {
|
||||||
return new ConcreteBuilder();
|
return new ConcreteBuilder();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder<?> toBuilder() {
|
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();
|
protected abstract T self();
|
||||||
|
|
||||||
private String id;
|
protected String id;
|
||||||
private String name;
|
protected String name;
|
||||||
private String availabilityZone;
|
protected String availabilityZone;
|
||||||
private Set<String> hosts = ImmutableSet.of();
|
protected Set<String> hosts = ImmutableSet.of();
|
||||||
private String state;
|
protected String state;
|
||||||
private Date created = new Date();
|
protected Date created;
|
||||||
private Date updated;
|
protected Date updated;
|
||||||
private Map<String, String> metadata = ImmutableMap.of();
|
protected Map<String, String> metadata = ImmutableMap.of();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see HostAggregate#getId()
|
* @see HostAggregate#getId()
|
||||||
*/
|
*/
|
||||||
public T id(String id) {
|
public T id(String id) {
|
||||||
|
@ -67,7 +70,7 @@ public class HostAggregate {
|
||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see HostAggregate#getName()
|
* @see HostAggregate#getName()
|
||||||
*/
|
*/
|
||||||
public T name(String name) {
|
public T name(String name) {
|
||||||
|
@ -75,7 +78,7 @@ public class HostAggregate {
|
||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see HostAggregate#getAvailabilityZone()
|
* @see HostAggregate#getAvailabilityZone()
|
||||||
*/
|
*/
|
||||||
public T availabilityZone(String availabilityZone) {
|
public T availabilityZone(String availabilityZone) {
|
||||||
|
@ -83,22 +86,19 @@ public class HostAggregate {
|
||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see HostAggregate#getHosts()
|
|
||||||
*/
|
|
||||||
public T hosts(String... hosts) {
|
|
||||||
return hosts(ImmutableSet.copyOf(hosts));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see HostAggregate#getHosts()
|
* @see HostAggregate#getHosts()
|
||||||
*/
|
*/
|
||||||
public T hosts(Set<String> hosts) {
|
public T hosts(Set<String> hosts) {
|
||||||
this.hosts = hosts;
|
this.hosts = ImmutableSet.copyOf(checkNotNull(hosts, "hosts"));
|
||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public T hosts(String... in) {
|
||||||
|
return hosts(ImmutableSet.copyOf(in));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
* @see HostAggregate#getState()
|
* @see HostAggregate#getState()
|
||||||
*/
|
*/
|
||||||
public T state(String state) {
|
public T state(String state) {
|
||||||
|
@ -106,7 +106,7 @@ public class HostAggregate {
|
||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see HostAggregate#getCreated()
|
* @see HostAggregate#getCreated()
|
||||||
*/
|
*/
|
||||||
public T created(Date created) {
|
public T created(Date created) {
|
||||||
|
@ -114,7 +114,7 @@ public class HostAggregate {
|
||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see HostAggregate#getUpdated()
|
* @see HostAggregate#getUpdated()
|
||||||
*/
|
*/
|
||||||
public T updated(Date updated) {
|
public T updated(Date updated) {
|
||||||
|
@ -122,30 +122,29 @@ public class HostAggregate {
|
||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see HostAggregate#getMetadata()
|
* @see HostAggregate#getMetadata()
|
||||||
*/
|
*/
|
||||||
public T metadata(Map<String, String> metadata) {
|
public T metadata(Map<String, String> metadata) {
|
||||||
this.metadata = metadata;
|
this.metadata = ImmutableMap.copyOf(checkNotNull(metadata, "metadata"));
|
||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
public HostAggregate build() {
|
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
|
return this
|
||||||
.id(in.getId())
|
.id(in.getId())
|
||||||
.name(in.getName())
|
.name(in.getName())
|
||||||
.availabilityZone(in.getAvailabilityZone())
|
.availabilityZone(in.getAvailabilityZone())
|
||||||
.hosts(in.getHosts())
|
.hosts(in.getHosts())
|
||||||
.state(in.getState())
|
.state(in.getState())
|
||||||
.created(in.getCreated())
|
.created(in.getCreated())
|
||||||
.updated(in.getUpdated().orNull())
|
.updated(in.getUpdated().get())
|
||||||
.metadata(in.getMetadata());
|
.metadata(in.getMetadata());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||||
|
@ -154,35 +153,33 @@ public class HostAggregate {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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 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) {
|
private final String id;
|
||||||
this.id = checkNotNull(builder.id, "id");
|
private final String name;
|
||||||
this.name = checkNotNull(builder.name, "name");
|
@Named("availability_zone")
|
||||||
this.availabilityZone = checkNotNull(builder.availabilityZone, "availabilityZone");
|
private final String availabilityZone;
|
||||||
this.hosts = ImmutableSet.copyOf(checkNotNull(builder.hosts, "hosts"));
|
private final Set<String> hosts;
|
||||||
this.state = checkNotNull(builder.state, "state");
|
@Named("operational_state")
|
||||||
this.created = checkNotNull(builder.created, "created");
|
private final String state;
|
||||||
this.updated = Optional.fromNullable(builder.updated);
|
@Named("created_at")
|
||||||
this.metadata = ImmutableMap.copyOf(checkNotNull(builder.metadata, "metadata"));
|
private final Date created;
|
||||||
|
@Named("updated_at")
|
||||||
|
private final Optional<Date> updated;
|
||||||
|
private final Map<String, String> 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() {
|
public String getId() {
|
||||||
|
@ -195,7 +192,7 @@ public class HostAggregate {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* note: an "Availability Zone" is different from a Nova "Zone"
|
* note: an "Availability Zone" is different from a Nova "Zone"
|
||||||
*
|
*
|
||||||
* @return the availability zone this aggregate is in
|
* @return the availability zone this aggregate is in
|
||||||
*/
|
*/
|
||||||
public String getAvailabilityZone() {
|
public String getAvailabilityZone() {
|
||||||
|
@ -203,7 +200,7 @@ public class HostAggregate {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<String> getHosts() {
|
public Set<String> getHosts() {
|
||||||
return Collections.unmodifiableSet(this.hosts);
|
return this.hosts;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getState() {
|
public String getState() {
|
||||||
|
@ -233,31 +230,23 @@ public class HostAggregate {
|
||||||
if (obj == null || getClass() != obj.getClass()) return false;
|
if (obj == null || getClass() != obj.getClass()) return false;
|
||||||
HostAggregate that = HostAggregate.class.cast(obj);
|
HostAggregate that = HostAggregate.class.cast(obj);
|
||||||
return Objects.equal(this.id, that.id)
|
return Objects.equal(this.id, that.id)
|
||||||
&& Objects.equal(this.name, that.name)
|
&& Objects.equal(this.name, that.name)
|
||||||
&& Objects.equal(this.availabilityZone, that.availabilityZone)
|
&& Objects.equal(this.availabilityZone, that.availabilityZone)
|
||||||
&& Objects.equal(this.hosts, that.hosts)
|
&& Objects.equal(this.hosts, that.hosts)
|
||||||
&& Objects.equal(this.state, that.state)
|
&& Objects.equal(this.state, that.state)
|
||||||
&& Objects.equal(this.created, that.created)
|
&& Objects.equal(this.created, that.created)
|
||||||
&& Objects.equal(this.updated, that.updated)
|
&& Objects.equal(this.updated, that.updated)
|
||||||
&& Objects.equal(this.metadata, that.metadata)
|
&& Objects.equal(this.metadata, that.metadata);
|
||||||
;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ToStringHelper string() {
|
protected ToStringHelper string() {
|
||||||
return Objects.toStringHelper("")
|
return Objects.toStringHelper(this)
|
||||||
.add("id", id)
|
.add("id", id).add("name", name).add("availabilityZone", availabilityZone).add("hosts", hosts).add("state", state).add("created", created).add("updated", updated).add("metadata", metadata);
|
||||||
.add("name", name)
|
|
||||||
.add("availabilityZone", availabilityZone)
|
|
||||||
.add("hosts", hosts)
|
|
||||||
.add("state", state)
|
|
||||||
.add("created", created)
|
|
||||||
.add("updated", updated)
|
|
||||||
.add("metadata", metadata);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return string().toString();
|
return string().toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/**
|
/*
|
||||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||||
* contributor license agreements. See the NOTICE file
|
* contributor license agreements. See the NOTICE file
|
||||||
* distributed with this work for additional information
|
* distributed with this work for additional information
|
||||||
|
@ -20,73 +20,89 @@ package org.jclouds.openstack.nova.v2_0.domain;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
|
import java.beans.ConstructorProperties;
|
||||||
|
|
||||||
|
import javax.inject.Named;
|
||||||
|
|
||||||
import org.jclouds.javax.annotation.Nullable;
|
import org.jclouds.javax.annotation.Nullable;
|
||||||
|
|
||||||
import com.google.common.base.Objects;
|
import com.google.common.base.Objects;
|
||||||
import com.google.common.base.Objects.ToStringHelper;
|
import com.google.common.base.Objects.ToStringHelper;
|
||||||
import com.google.gson.annotations.SerializedName;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class HostResourceUsage
|
* Class HostResourceUsage
|
||||||
*/
|
*/
|
||||||
public class HostResourceUsage {
|
public class HostResourceUsage {
|
||||||
|
|
||||||
public static Builder<?> builder() {
|
public static Builder<?> builder() {
|
||||||
return new ConcreteBuilder();
|
return new ConcreteBuilder();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder<?> toBuilder() {
|
public Builder<?> toBuilder() {
|
||||||
return new ConcreteBuilder().fromHostResourceUsage(this);
|
return new ConcreteBuilder().fromHostResourceUsage(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static abstract class Builder<T extends Builder<T>> {
|
public static abstract class Builder<T extends Builder<T>> {
|
||||||
protected abstract T self();
|
protected abstract T self();
|
||||||
|
|
||||||
private String host;
|
protected String host;
|
||||||
private String project;
|
protected String project;
|
||||||
private int memoryMb;
|
protected int memoryMb;
|
||||||
private int cpu;
|
protected int cpu;
|
||||||
private int diskGb;
|
protected int diskGb;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see HostResourceUsage#getHost()
|
||||||
|
*/
|
||||||
public T host(String host) {
|
public T host(String host) {
|
||||||
this.host = host;
|
this.host = host;
|
||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see HostResourceUsage#getProject()
|
||||||
|
*/
|
||||||
public T project(String project) {
|
public T project(String project) {
|
||||||
this.project = project;
|
this.project = project;
|
||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see HostResourceUsage#getMemoryMb()
|
||||||
|
*/
|
||||||
public T memoryMb(int memoryMb) {
|
public T memoryMb(int memoryMb) {
|
||||||
this.memoryMb = memoryMb;
|
this.memoryMb = memoryMb;
|
||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see HostResourceUsage#getCpu()
|
||||||
|
*/
|
||||||
public T cpu(int cpu) {
|
public T cpu(int cpu) {
|
||||||
this.cpu = cpu;
|
this.cpu = cpu;
|
||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see HostResourceUsage#getDiskGb()
|
||||||
|
*/
|
||||||
public T diskGb(int diskGb) {
|
public T diskGb(int diskGb) {
|
||||||
this.diskGb = diskGb;
|
this.diskGb = diskGb;
|
||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
public HostResourceUsage build() {
|
public HostResourceUsage build() {
|
||||||
return new HostResourceUsage(this);
|
return new HostResourceUsage(host, project, memoryMb, cpu, diskGb);
|
||||||
}
|
}
|
||||||
|
|
||||||
public T fromHostResourceUsage(HostResourceUsage in) {
|
public T fromHostResourceUsage(HostResourceUsage in) {
|
||||||
return this
|
return this
|
||||||
.host(in.getHost())
|
.host(in.getHost())
|
||||||
.project(in.getProject())
|
.project(in.getProject())
|
||||||
.memoryMb(in.getMemoryMb())
|
.memoryMb(in.getMemoryMb())
|
||||||
.cpu(in.getCpu())
|
.cpu(in.getCpu())
|
||||||
.diskGb(in.getDiskGb())
|
.diskGb(in.getDiskGb());
|
||||||
;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||||
|
@ -95,56 +111,43 @@ public class HostResourceUsage {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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 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) {
|
private final String host;
|
||||||
this.host = checkNotNull(builder.host, "host");
|
private final String project;
|
||||||
this.project = builder.project;
|
@Named("memory_mb")
|
||||||
this.memoryMb = checkNotNull(builder.memoryMb, "memoryMb");
|
private final int memoryMb;
|
||||||
this.cpu = checkNotNull(builder.cpu, "cpu");
|
private final int cpu;
|
||||||
this.diskGb = checkNotNull(builder.diskGb, "diskGb");
|
@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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
public String getHost() {
|
public String getHost() {
|
||||||
return this.host;
|
return this.host;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public String getProject() {
|
public String getProject() {
|
||||||
return this.project;
|
return this.project;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
public int getMemoryMb() {
|
public int getMemoryMb() {
|
||||||
return this.memoryMb;
|
return this.memoryMb;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
public int getCpu() {
|
public int getCpu() {
|
||||||
return this.cpu;
|
return this.cpu;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
public int getDiskGb() {
|
public int getDiskGb() {
|
||||||
return this.diskGb;
|
return this.diskGb;
|
||||||
}
|
}
|
||||||
|
@ -160,24 +163,20 @@ public class HostResourceUsage {
|
||||||
if (obj == null || getClass() != obj.getClass()) return false;
|
if (obj == null || getClass() != obj.getClass()) return false;
|
||||||
HostResourceUsage that = HostResourceUsage.class.cast(obj);
|
HostResourceUsage that = HostResourceUsage.class.cast(obj);
|
||||||
return Objects.equal(this.host, that.host)
|
return Objects.equal(this.host, that.host)
|
||||||
&& Objects.equal(this.project, that.project)
|
&& Objects.equal(this.project, that.project)
|
||||||
&& Objects.equal(this.memoryMb, that.memoryMb)
|
&& Objects.equal(this.memoryMb, that.memoryMb)
|
||||||
&& Objects.equal(this.cpu, that.cpu)
|
&& Objects.equal(this.cpu, that.cpu)
|
||||||
&& Objects.equal(this.diskGb, that.diskGb);
|
&& Objects.equal(this.diskGb, that.diskGb);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ToStringHelper string() {
|
protected ToStringHelper string() {
|
||||||
return Objects.toStringHelper("")
|
return Objects.toStringHelper(this)
|
||||||
.add("host", host)
|
.add("host", host).add("project", project).add("memoryMb", memoryMb).add("cpu", cpu).add("diskGb", diskGb);
|
||||||
.add("project", project)
|
|
||||||
.add("memoryMb", memoryMb)
|
|
||||||
.add("cpu", cpu)
|
|
||||||
.add("diskGb", diskGb);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return string().toString();
|
return string().toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/**
|
/*
|
||||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||||
* contributor license agreements. See the NOTICE file
|
* contributor license agreements. See the NOTICE file
|
||||||
* distributed with this work for additional information
|
* distributed with this work for additional information
|
||||||
|
@ -18,16 +18,23 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.openstack.nova.v2_0.domain;
|
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.Date;
|
||||||
import java.util.Map;
|
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 org.jclouds.openstack.v2_0.domain.Resource;
|
||||||
|
|
||||||
import com.google.common.base.Objects;
|
import com.google.common.base.Objects;
|
||||||
|
import com.google.common.base.Objects.ToStringHelper;
|
||||||
import com.google.common.base.Predicates;
|
import com.google.common.base.Predicates;
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.common.collect.Maps;
|
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
|
* 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
|
* @author Jeremy Daggett
|
||||||
* @see <a href= "http://docs.openstack.org/api/openstack-compute/1.1/content/Images-d1e4427.html"
|
* @see <a href= "http://docs.openstack.org/api/openstack-compute/1.1/content/Images-d1e4427.html"
|
||||||
* />
|
/>
|
||||||
*/
|
*/
|
||||||
public class Image extends Resource {
|
public class Image extends Resource {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* In-flight images will have the status attribute set to SAVING and the conditional progress
|
* 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
|
* element (0-100% completion) will also be returned. Other possible values for the status
|
||||||
|
@ -48,44 +56,44 @@ public class Image extends Resource {
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
public static enum Status {
|
public static enum Status {
|
||||||
|
|
||||||
UNRECOGNIZED, UNKNOWN, ACTIVE, SAVING, ERROR, DELETED;
|
UNRECOGNIZED, UNKNOWN, ACTIVE, SAVING, ERROR, DELETED;
|
||||||
|
|
||||||
public String value() {
|
public String value() {
|
||||||
return name();
|
return name();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Status fromValue(String v) {
|
public static Status fromValue(String v) {
|
||||||
try {
|
try {
|
||||||
return valueOf(v);
|
return valueOf(v);
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
return UNRECOGNIZED;
|
return UNRECOGNIZED;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Builder<?> builder() {
|
public static Builder<?> builder() {
|
||||||
return new ConcreteBuilder();
|
return new ConcreteBuilder();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder<?> toBuilder() {
|
public Builder<?> toBuilder() {
|
||||||
return new ConcreteBuilder().fromImage(this);
|
return new ConcreteBuilder().fromImage(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static abstract class Builder<T extends Builder<T>> extends Resource.Builder<T> {
|
public static abstract class Builder<T extends Builder<T>> extends Resource.Builder<T> {
|
||||||
private Date updated;
|
protected Date updated;
|
||||||
private Date created;
|
protected Date created;
|
||||||
private String tenantId;
|
protected String tenantId;
|
||||||
private String userId;
|
protected String userId;
|
||||||
private Image.Status status;
|
protected Image.Status status;
|
||||||
private int progress;
|
protected int progress;
|
||||||
private int minDisk;
|
protected int minDisk;
|
||||||
private int minRam;
|
protected int minRam;
|
||||||
private Resource server;
|
protected Resource server;
|
||||||
private Map<String, String> metadata = ImmutableMap.of();
|
protected Map<String, String> metadata = ImmutableMap.of();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see Image#getUpdated()
|
* @see Image#getUpdated()
|
||||||
*/
|
*/
|
||||||
public T updated(Date updated) {
|
public T updated(Date updated) {
|
||||||
|
@ -93,7 +101,7 @@ public class Image extends Resource {
|
||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see Image#getCreated()
|
* @see Image#getCreated()
|
||||||
*/
|
*/
|
||||||
public T created(Date created) {
|
public T created(Date created) {
|
||||||
|
@ -101,7 +109,7 @@ public class Image extends Resource {
|
||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see Image#getTenantId()
|
* @see Image#getTenantId()
|
||||||
*/
|
*/
|
||||||
public T tenantId(String tenantId) {
|
public T tenantId(String tenantId) {
|
||||||
|
@ -109,7 +117,7 @@ public class Image extends Resource {
|
||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see Image#getUserId()
|
* @see Image#getUserId()
|
||||||
*/
|
*/
|
||||||
public T userId(String userId) {
|
public T userId(String userId) {
|
||||||
|
@ -117,7 +125,7 @@ public class Image extends Resource {
|
||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see Image#getStatus()
|
* @see Image#getStatus()
|
||||||
*/
|
*/
|
||||||
public T status(Image.Status status) {
|
public T status(Image.Status status) {
|
||||||
|
@ -125,7 +133,7 @@ public class Image extends Resource {
|
||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see Image#getProgress()
|
* @see Image#getProgress()
|
||||||
*/
|
*/
|
||||||
public T progress(int progress) {
|
public T progress(int progress) {
|
||||||
|
@ -133,7 +141,7 @@ public class Image extends Resource {
|
||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see Image#getMinDisk()
|
* @see Image#getMinDisk()
|
||||||
*/
|
*/
|
||||||
public T minDisk(int minDisk) {
|
public T minDisk(int minDisk) {
|
||||||
|
@ -141,7 +149,7 @@ public class Image extends Resource {
|
||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see Image#getMinRam()
|
* @see Image#getMinRam()
|
||||||
*/
|
*/
|
||||||
public T minRam(int minRam) {
|
public T minRam(int minRam) {
|
||||||
|
@ -149,7 +157,7 @@ public class Image extends Resource {
|
||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see Image#getServer()
|
* @see Image#getServer()
|
||||||
*/
|
*/
|
||||||
public T server(Resource server) {
|
public T server(Resource server) {
|
||||||
|
@ -157,32 +165,31 @@ public class Image extends Resource {
|
||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see Image#getMetadata()
|
* @see Image#getMetadata()
|
||||||
*/
|
*/
|
||||||
public T metadata(Map<String, String> metadata) {
|
public T metadata(Map<String, String> metadata) {
|
||||||
this.metadata = metadata;
|
this.metadata = ImmutableMap.copyOf(checkNotNull(metadata, "metadata"));
|
||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Image build() {
|
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) {
|
public T fromImage(Image in) {
|
||||||
return super.fromResource(in)
|
return super.fromResource(in)
|
||||||
.updated(in.getUpdated())
|
.updated(in.getUpdated())
|
||||||
.created(in.getCreated())
|
.created(in.getCreated())
|
||||||
.tenantId(in.getTenantId())
|
.tenantId(in.getTenantId())
|
||||||
.userId(in.getUserId())
|
.userId(in.getUserId())
|
||||||
.status(in.getStatus())
|
.status(in.getStatus())
|
||||||
.progress(in.getProgress())
|
.progress(in.getProgress())
|
||||||
.minDisk(in.getMinDisk())
|
.minDisk(in.getMinDisk())
|
||||||
.minRam(in.getMinRam())
|
.minRam(in.getMinRam())
|
||||||
.server(in.getServer())
|
.server(in.getServer())
|
||||||
.metadata(in.getMetadata());
|
.metadata(in.getMetadata());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||||
|
@ -191,56 +198,60 @@ public class Image extends Resource {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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) {
|
private final Date updated;
|
||||||
super(builder);
|
private final Date created;
|
||||||
this.updated = builder.updated;
|
@Named("tenant_id")
|
||||||
this.created = builder.created;
|
private final String tenantId;
|
||||||
this.tenantId = builder.tenantId;
|
@Named("user_id")
|
||||||
this.userId = builder.userId;
|
private final String userId;
|
||||||
this.status = builder.status;
|
private final Image.Status status;
|
||||||
this.progress = builder.progress;
|
private final int progress;
|
||||||
this.minDisk = builder.minDisk;
|
private final int minDisk;
|
||||||
this.minRam = builder.minRam;
|
private final int minRam;
|
||||||
this.server = builder.server;
|
private final Resource server;
|
||||||
this.metadata = ImmutableMap.copyOf(builder.metadata);
|
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() {
|
public Date getUpdated() {
|
||||||
return this.updated;
|
return this.updated;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
public Date getCreated() {
|
public Date getCreated() {
|
||||||
return this.created;
|
return this.created;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
public String getTenantId() {
|
public String getTenantId() {
|
||||||
return this.tenantId;
|
return this.tenantId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
public String getUserId() {
|
public String getUserId() {
|
||||||
return this.userId;
|
return this.userId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
public Status getStatus() {
|
public Status getStatus() {
|
||||||
return this.status;
|
return this.status;
|
||||||
}
|
}
|
||||||
|
@ -257,28 +268,40 @@ public class Image extends Resource {
|
||||||
return this.minRam;
|
return this.minRam;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
public Resource getServer() {
|
public Resource getServer() {
|
||||||
return this.server;
|
return this.server;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, String> getMetadata() {
|
public Map<String, String> getMetadata() {
|
||||||
// in case this was assigned in gson
|
return this.metadata;
|
||||||
return ImmutableMap.copyOf(Maps.filterValues(this.metadata, Predicates.notNull()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Objects.ToStringHelper string() {
|
public int hashCode() {
|
||||||
return super.string()
|
return Objects.hashCode(updated, created, tenantId, userId, status, progress, minDisk, minRam, server, 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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@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);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/**
|
/*
|
||||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||||
* contributor license agreements. See the NOTICE file
|
* contributor license agreements. See the NOTICE file
|
||||||
* distributed with this work for additional information
|
* distributed with this work for additional information
|
||||||
|
@ -18,86 +18,103 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.openstack.nova.v2_0.domain;
|
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 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.annotations.Beta;
|
||||||
import com.google.common.base.Objects;
|
import com.google.common.base.Objects;
|
||||||
import com.google.common.base.Objects.ToStringHelper;
|
import com.google.common.base.Objects.ToStringHelper;
|
||||||
import com.google.gson.annotations.SerializedName;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ingress access to a destination protocol on particular ports
|
* Ingress access to a destination protocol on particular ports
|
||||||
*
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Beta
|
@Beta
|
||||||
public class Ingress {
|
public class Ingress {
|
||||||
public static Builder builder() {
|
|
||||||
return new Builder();
|
public static Builder<?> builder() {
|
||||||
|
return new ConcreteBuilder();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder<?> toBuilder() {
|
||||||
|
return new ConcreteBuilder().fromIngress(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Builder {
|
public static abstract class Builder<T extends Builder<T>> {
|
||||||
|
protected abstract T self();
|
||||||
|
|
||||||
protected IpProtocol ipProtocol;
|
protected IpProtocol ipProtocol;
|
||||||
protected int fromPort;
|
protected int fromPort;
|
||||||
protected int toPort;
|
protected int toPort;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @see Ingress#getIpProtocol()
|
* @see Ingress#getIpProtocol()
|
||||||
*/
|
*/
|
||||||
public Builder ipProtocol(IpProtocol ipProtocol) {
|
public T ipProtocol(IpProtocol ipProtocol) {
|
||||||
this.ipProtocol = ipProtocol;
|
this.ipProtocol = ipProtocol;
|
||||||
return this;
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @see Ingress#getFromPort()
|
* @see Ingress#getFromPort()
|
||||||
*/
|
*/
|
||||||
public Builder fromPort(int fromPort) {
|
public T fromPort(int fromPort) {
|
||||||
this.fromPort = fromPort;
|
this.fromPort = fromPort;
|
||||||
return this;
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @see Ingress#getToPort()
|
* @see Ingress#getToPort()
|
||||||
*/
|
*/
|
||||||
public Builder toPort(int toPort) {
|
public T toPort(int toPort) {
|
||||||
this.toPort = toPort;
|
this.toPort = toPort;
|
||||||
return this;
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Ingress build() {
|
public Ingress build() {
|
||||||
return new Ingress(ipProtocol, fromPort, toPort);
|
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
|
|
||||||
}
|
|
||||||
|
|
||||||
@SerializedName(value = "ip_protocol")
|
|
||||||
protected IpProtocol ipProtocol;
|
|
||||||
@SerializedName(value = "from_port")
|
|
||||||
protected int fromPort;
|
|
||||||
@SerializedName(value = "to_port")
|
|
||||||
protected int toPort;
|
|
||||||
|
|
||||||
|
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||||
|
@Override
|
||||||
|
protected ConcreteBuilder self() {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@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) {
|
protected Ingress(IpProtocol ipProtocol, int fromPort, int toPort) {
|
||||||
|
this.ipProtocol = checkNotNull(ipProtocol, "ipProtocol");
|
||||||
this.fromPort = fromPort;
|
this.fromPort = fromPort;
|
||||||
this.toPort = toPort;
|
this.toPort = toPort;
|
||||||
this.ipProtocol = checkNotNull(ipProtocol, "ipProtocol");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* destination IP protocol
|
* destination IP protocol
|
||||||
*/
|
*/
|
||||||
public IpProtocol getIpProtocol() {
|
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).
|
* type number of -1 indicates a wildcard (i.e., any ICMP type number).
|
||||||
*/
|
*/
|
||||||
public int getFromPort() {
|
public int getFromPort() {
|
||||||
return fromPort;
|
return this.fromPort;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -113,19 +130,7 @@ public class Ingress {
|
||||||
* -1 indicates a wildcard (i.e., any ICMP code).
|
* -1 indicates a wildcard (i.e., any ICMP code).
|
||||||
*/
|
*/
|
||||||
public int getToPort() {
|
public int getToPort() {
|
||||||
return toPort;
|
return this.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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -133,13 +138,24 @@ public class Ingress {
|
||||||
return Objects.hashCode(ipProtocol, fromPort, toPort);
|
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
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return 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
|
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||||
* contributor license agreements. See the NOTICE file
|
* contributor license agreements. See the NOTICE file
|
||||||
* distributed with this work for additional information
|
* distributed with this work for additional information
|
||||||
|
@ -18,158 +18,169 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.openstack.nova.v2_0.domain;
|
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 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() {
|
* Class KeyPair
|
||||||
return new Builder();
|
*/
|
||||||
|
public class KeyPair {
|
||||||
|
|
||||||
|
public static Builder<?> builder() {
|
||||||
|
return new ConcreteBuilder();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder<?> toBuilder() {
|
||||||
|
return new ConcreteBuilder().fromKeyPair(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder toBuilder() {
|
public static abstract class Builder<T extends Builder<T>> {
|
||||||
return builder().fromKeyPair(this);
|
protected abstract T self();
|
||||||
}
|
|
||||||
|
|
||||||
public static class Builder {
|
protected String publicKey;
|
||||||
|
protected String privateKey;
|
||||||
private String publicKey;
|
protected String userId;
|
||||||
private String privateKey;
|
protected String name;
|
||||||
private String userId;
|
protected String fingerprint;
|
||||||
private String name;
|
|
||||||
private String fingerprint;
|
/**
|
||||||
|
* @see KeyPair#getPublicKey()
|
||||||
public Builder publicKey(String publicKey) {
|
*/
|
||||||
|
public T publicKey(String publicKey) {
|
||||||
this.publicKey = publicKey;
|
this.publicKey = publicKey;
|
||||||
return this;
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder privateKey(String privateKey) {
|
/**
|
||||||
|
* @see KeyPair#getPrivateKey()
|
||||||
|
*/
|
||||||
|
public T privateKey(String privateKey) {
|
||||||
this.privateKey = privateKey;
|
this.privateKey = privateKey;
|
||||||
return this;
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder userId(String userId) {
|
/**
|
||||||
|
* @see KeyPair#getUserId()
|
||||||
|
*/
|
||||||
|
public T userId(String userId) {
|
||||||
this.userId = userId;
|
this.userId = userId;
|
||||||
return this;
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder name(String name) {
|
/**
|
||||||
|
* @see KeyPair#getName()
|
||||||
|
*/
|
||||||
|
public T name(String name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
return this;
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder fingerprint(String fingerprint) {
|
/**
|
||||||
|
* @see KeyPair#getFingerprint()
|
||||||
|
*/
|
||||||
|
public T fingerprint(String fingerprint) {
|
||||||
this.fingerprint = fingerprint;
|
this.fingerprint = fingerprint;
|
||||||
return this;
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
public KeyPair build() {
|
public KeyPair build() {
|
||||||
return new KeyPair(publicKey, privateKey, userId, name, fingerprint);
|
return new KeyPair(publicKey, privateKey, userId, name, fingerprint);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder fromKeyPair(KeyPair in) {
|
public T fromKeyPair(KeyPair in) {
|
||||||
return publicKey(in.getPublicKey()).privateKey(in.getPrivateKey()).userId(in.getUserId()).name(in.getName())
|
return this
|
||||||
.fingerprint(in.getFingerprint());
|
.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
|
|
||||||
}
|
|
||||||
|
|
||||||
@SerializedName("public_key")
|
|
||||||
private String publicKey;
|
|
||||||
@SerializedName("private_key")
|
|
||||||
private String privateKey;
|
|
||||||
@SerializedName("user_id")
|
|
||||||
private String userId;
|
|
||||||
private String name;
|
|
||||||
private String fingerprint;
|
|
||||||
|
|
||||||
protected KeyPair(String publicKey, String privateKey, @Nullable String userId, String name, String fingerprint) {
|
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||||
|
@Override
|
||||||
|
protected ConcreteBuilder self() {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@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;
|
||||||
|
|
||||||
|
@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.publicKey = publicKey;
|
||||||
this.privateKey = privateKey;
|
this.privateKey = privateKey;
|
||||||
this.userId = userId;
|
this.userId = userId;
|
||||||
this.name = name;
|
this.name = checkNotNull(name, "name");
|
||||||
this.fingerprint = fingerprint;
|
this.fingerprint = fingerprint;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
public String getPublicKey() {
|
public String getPublicKey() {
|
||||||
return this.publicKey;
|
return this.publicKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
public String getPrivateKey() {
|
public String getPrivateKey() {
|
||||||
return this.privateKey;
|
return this.privateKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
public String getUserId() {
|
public String getUserId() {
|
||||||
return this.privateKey;
|
return this.userId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return this.name;
|
return this.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
public String getFingerprint() {
|
public String getFingerprint() {
|
||||||
return this.fingerprint;
|
return this.fingerprint;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int compareTo(KeyPair o) {
|
|
||||||
return this.fingerprint.compareTo(o.getFingerprint());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
final int prime = 31;
|
return Objects.hashCode(publicKey, privateKey, userId, name, fingerprint);
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object obj) {
|
||||||
if (this == obj)
|
if (this == obj) return true;
|
||||||
return true;
|
if (obj == null || getClass() != obj.getClass()) return false;
|
||||||
if (obj == null)
|
KeyPair that = KeyPair.class.cast(obj);
|
||||||
return false;
|
return Objects.equal(this.publicKey, that.publicKey)
|
||||||
if (getClass() != obj.getClass())
|
&& Objects.equal(this.privateKey, that.privateKey)
|
||||||
return false;
|
&& Objects.equal(this.userId, that.userId)
|
||||||
KeyPair other = (KeyPair) obj;
|
&& Objects.equal(this.name, that.name)
|
||||||
if (publicKey == null) {
|
&& Objects.equal(this.fingerprint, that.fingerprint);
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected ToStringHelper string() {
|
||||||
|
return Objects.toStringHelper(this)
|
||||||
|
.add("publicKey", publicKey).add("privateKey", privateKey).add("userId", userId).add("name", name).add("fingerprint", fingerprint);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
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
|
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||||
* contributor license agreements. See the NOTICE file
|
* contributor license agreements. See the NOTICE file
|
||||||
* distributed with this work for additional information
|
* distributed with this work for additional information
|
||||||
|
@ -18,33 +18,32 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.openstack.nova.v2_0.domain;
|
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
|
* Represents the set of limits (quota class) returned by the Quota Class Extension
|
||||||
*
|
*
|
||||||
* @see org.jclouds.openstack.nova.v2_0.extensions.QuotaClassClient
|
* @see org.jclouds.openstack.nova.v2_0.extensions.QuotaClassClient
|
||||||
*/
|
*/
|
||||||
public class QuotaClass extends Quotas {
|
public class QuotaClass extends Quotas {
|
||||||
|
|
||||||
public static Builder<?> builder() {
|
public static Builder<?> builder() {
|
||||||
return new ConcreteBuilder();
|
return new ConcreteBuilder();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder<?> toBuilder() {
|
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> {
|
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 QuotaClass build() {
|
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> {
|
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
|
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||||
* contributor license agreements. See the NOTICE file
|
* contributor license agreements. See the NOTICE file
|
||||||
* distributed with this work for additional information
|
* distributed with this work for additional information
|
||||||
|
@ -20,43 +20,46 @@ package org.jclouds.openstack.nova.v2_0.domain;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
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;
|
||||||
import com.google.common.base.Objects.ToStringHelper;
|
import com.google.common.base.Objects.ToStringHelper;
|
||||||
import com.google.gson.annotations.SerializedName;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents the set of limits (quotas) returned by the Quota Extension
|
* Represents the set of limits (quotas) returned by the Quota Extension
|
||||||
*
|
*
|
||||||
* @see org.jclouds.openstack.nova.v2_0.extensions.QuotaClient
|
* @see org.jclouds.openstack.nova.v2_0.extensions.QuotaClient
|
||||||
*/
|
*/
|
||||||
public class Quotas {
|
public class Quotas {
|
||||||
|
|
||||||
public static Builder<?> builder() {
|
public static Builder<?> builder() {
|
||||||
return new ConcreteBuilder();
|
return new ConcreteBuilder();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder<?> toBuilder() {
|
public Builder<?> toBuilder() {
|
||||||
return new ConcreteBuilder().fromQuotas(this);
|
return new ConcreteBuilder().fromQuotas(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static abstract class Builder<T extends Builder<T>> {
|
public static abstract class Builder<T extends Builder<T>> {
|
||||||
protected abstract T self();
|
protected abstract T self();
|
||||||
|
|
||||||
private String id;
|
protected String id;
|
||||||
private int metadataItems;
|
protected int metadataItems;
|
||||||
private int injectedFileContentBytes;
|
protected int injectedFileContentBytes;
|
||||||
private int volumes;
|
protected int volumes;
|
||||||
private int gigabytes;
|
protected int gigabytes;
|
||||||
private int ram;
|
protected int ram;
|
||||||
private int floatingIps;
|
protected int floatingIps;
|
||||||
private int instances;
|
protected int instances;
|
||||||
private int injectedFiles;
|
protected int injectedFiles;
|
||||||
private int cores;
|
protected int cores;
|
||||||
private int securityGroups;
|
protected int securityGroups;
|
||||||
private int securityGroupRules;
|
protected int securityGroupRules;
|
||||||
private int keyPairs;
|
protected int keyPairs;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see Quotas#getId()
|
* @see Quotas#getId()
|
||||||
*/
|
*/
|
||||||
public T id(String id) {
|
public T id(String id) {
|
||||||
|
@ -64,7 +67,7 @@ public class Quotas {
|
||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see Quotas#getMetadataItems()
|
* @see Quotas#getMetadataItems()
|
||||||
*/
|
*/
|
||||||
public T metadataItems(int metadataItems) {
|
public T metadataItems(int metadataItems) {
|
||||||
|
@ -72,7 +75,7 @@ public class Quotas {
|
||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see Quotas#getInjectedFileContentBytes()
|
* @see Quotas#getInjectedFileContentBytes()
|
||||||
*/
|
*/
|
||||||
public T injectedFileContentBytes(int injectedFileContentBytes) {
|
public T injectedFileContentBytes(int injectedFileContentBytes) {
|
||||||
|
@ -80,7 +83,7 @@ public class Quotas {
|
||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see Quotas#getVolumes()
|
* @see Quotas#getVolumes()
|
||||||
*/
|
*/
|
||||||
public T volumes(int volumes) {
|
public T volumes(int volumes) {
|
||||||
|
@ -88,7 +91,7 @@ public class Quotas {
|
||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see Quotas#getGigabytes()
|
* @see Quotas#getGigabytes()
|
||||||
*/
|
*/
|
||||||
public T gigabytes(int gigabytes) {
|
public T gigabytes(int gigabytes) {
|
||||||
|
@ -96,7 +99,7 @@ public class Quotas {
|
||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see Quotas#getRam()
|
* @see Quotas#getRam()
|
||||||
*/
|
*/
|
||||||
public T ram(int ram) {
|
public T ram(int ram) {
|
||||||
|
@ -104,7 +107,7 @@ public class Quotas {
|
||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see Quotas#getFloatingIps()
|
* @see Quotas#getFloatingIps()
|
||||||
*/
|
*/
|
||||||
public T floatingIps(int floatingIps) {
|
public T floatingIps(int floatingIps) {
|
||||||
|
@ -112,7 +115,7 @@ public class Quotas {
|
||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see Quotas#getInstances()
|
* @see Quotas#getInstances()
|
||||||
*/
|
*/
|
||||||
public T instances(int instances) {
|
public T instances(int instances) {
|
||||||
|
@ -120,7 +123,7 @@ public class Quotas {
|
||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see Quotas#getInjectedFiles()
|
* @see Quotas#getInjectedFiles()
|
||||||
*/
|
*/
|
||||||
public T injectedFiles(int injectedFiles) {
|
public T injectedFiles(int injectedFiles) {
|
||||||
|
@ -128,7 +131,7 @@ public class Quotas {
|
||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see Quotas#getCores()
|
* @see Quotas#getCores()
|
||||||
*/
|
*/
|
||||||
public T cores(int cores) {
|
public T cores(int cores) {
|
||||||
|
@ -136,7 +139,7 @@ public class Quotas {
|
||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see Quotas#getSecurityGroups()
|
* @see Quotas#getSecurityGroups()
|
||||||
*/
|
*/
|
||||||
public T securityGroups(int securityGroups) {
|
public T securityGroups(int securityGroups) {
|
||||||
|
@ -144,7 +147,7 @@ public class Quotas {
|
||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see Quotas#getSecurityGroupRules()
|
* @see Quotas#getSecurityGroupRules()
|
||||||
*/
|
*/
|
||||||
public T securityGroupRules(int securityGroupRules) {
|
public T securityGroupRules(int securityGroupRules) {
|
||||||
|
@ -152,7 +155,7 @@ public class Quotas {
|
||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see Quotas#getKeyPairs()
|
* @see Quotas#getKeyPairs()
|
||||||
*/
|
*/
|
||||||
public T keyPairs(int keyPairs) {
|
public T keyPairs(int keyPairs) {
|
||||||
|
@ -161,23 +164,24 @@ public class Quotas {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Quotas build() {
|
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) {
|
public T fromQuotas(Quotas in) {
|
||||||
return this.id(in.getId())
|
return this
|
||||||
.metadataItems(in.getMetadataItems())
|
.id(in.getId())
|
||||||
.injectedFileContentBytes(in.getInjectedFileContentBytes())
|
.metadataItems(in.getMetadataItems())
|
||||||
.volumes(in.getVolumes())
|
.injectedFileContentBytes(in.getInjectedFileContentBytes())
|
||||||
.gigabytes(in.getGigabytes())
|
.volumes(in.getVolumes())
|
||||||
.ram(in.getRam())
|
.gigabytes(in.getGigabytes())
|
||||||
.floatingIps(in.getFloatingIps())
|
.ram(in.getRam())
|
||||||
.instances(in.getInstances())
|
.floatingIps(in.getFloatingIps())
|
||||||
.injectedFiles(in.getInjectedFiles())
|
.instances(in.getInstances())
|
||||||
.cores(in.getCores())
|
.injectedFiles(in.getInjectedFiles())
|
||||||
.securityGroups(in.getSecurityGroups())
|
.cores(in.getCores())
|
||||||
.securityGroupRules(in.getSecurityGroupRules())
|
.securityGroups(in.getSecurityGroups())
|
||||||
.keyPairs(in.getKeyPairs());
|
.securityGroupRules(in.getSecurityGroupRules())
|
||||||
|
.keyPairs(in.getKeyPairs());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -187,49 +191,45 @@ public class Quotas {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
|
||||||
}
|
|
||||||
|
|
||||||
@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) {
|
private final String id;
|
||||||
this.id = checkNotNull(builder.id, "id");
|
@Named("metadata_items")
|
||||||
this.metadataItems = checkNotNull(builder.metadataItems, "metadataItems");
|
private final int metadataItems;
|
||||||
this.injectedFileContentBytes = checkNotNull(builder.injectedFileContentBytes, "injectedFileContentBytes");
|
@Named("injected_file_content_bytes")
|
||||||
this.volumes = checkNotNull(builder.volumes, "volumes");
|
private final int injectedFileContentBytes;
|
||||||
this.gigabytes = checkNotNull(builder.gigabytes, "gigabytes");
|
private final int volumes;
|
||||||
this.ram = checkNotNull(builder.ram, "ram");
|
private final int gigabytes;
|
||||||
this.floatingIps = checkNotNull(builder.floatingIps, "floatingIps");
|
private final int ram;
|
||||||
this.instances = checkNotNull(builder.instances, "instances");
|
@Named("floating_ips")
|
||||||
this.injectedFiles = checkNotNull(builder.injectedFiles, "injectedFiles");
|
private final int floatingIps;
|
||||||
this.cores = checkNotNull(builder.cores, "cores");
|
private final int instances;
|
||||||
this.securityGroups = checkNotNull(builder.securityGroups, "securityGroups");
|
@Named("injected_files")
|
||||||
this.securityGroupRules = checkNotNull(builder.securityGroupRules, "securityGroupRules");
|
private final int injectedFiles;
|
||||||
this.keyPairs = checkNotNull(builder.keyPairs, "keyPairs");
|
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;
|
||||||
|
|
||||||
|
@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
|
* @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
|
* @see org.jclouds.openstack.nova.v2_0.extensions.SecurityGroupClient
|
||||||
*/
|
*/
|
||||||
public int getSecurityGroups() {
|
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
|
* @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
|
* @see org.jclouds.openstack.nova.v2_0.extensions.SecurityGroupClient
|
||||||
*/
|
*/
|
||||||
public int getSecurityGroupRules() {
|
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
|
* @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
|
* @see org.jclouds.openstack.nova.v2_0.extensions.KeyPairClient
|
||||||
*/
|
*/
|
||||||
public int getKeyPairs() {
|
public int getKeyPairs() {
|
||||||
|
@ -334,40 +331,28 @@ public class Quotas {
|
||||||
if (obj == null || getClass() != obj.getClass()) return false;
|
if (obj == null || getClass() != obj.getClass()) return false;
|
||||||
Quotas that = Quotas.class.cast(obj);
|
Quotas that = Quotas.class.cast(obj);
|
||||||
return Objects.equal(this.id, that.id)
|
return Objects.equal(this.id, that.id)
|
||||||
&& Objects.equal(this.metadataItems, that.metadataItems)
|
&& Objects.equal(this.metadataItems, that.metadataItems)
|
||||||
&& Objects.equal(this.injectedFileContentBytes, that.injectedFileContentBytes)
|
&& Objects.equal(this.injectedFileContentBytes, that.injectedFileContentBytes)
|
||||||
&& Objects.equal(this.volumes, that.volumes)
|
&& Objects.equal(this.volumes, that.volumes)
|
||||||
&& Objects.equal(this.gigabytes, that.gigabytes)
|
&& Objects.equal(this.gigabytes, that.gigabytes)
|
||||||
&& Objects.equal(this.ram, that.ram)
|
&& Objects.equal(this.ram, that.ram)
|
||||||
&& Objects.equal(this.floatingIps, that.floatingIps)
|
&& Objects.equal(this.floatingIps, that.floatingIps)
|
||||||
&& Objects.equal(this.instances, that.instances)
|
&& Objects.equal(this.instances, that.instances)
|
||||||
&& Objects.equal(this.injectedFiles, that.injectedFiles)
|
&& Objects.equal(this.injectedFiles, that.injectedFiles)
|
||||||
&& Objects.equal(this.cores, that.cores)
|
&& Objects.equal(this.cores, that.cores)
|
||||||
&& Objects.equal(this.securityGroups, that.securityGroups)
|
&& Objects.equal(this.securityGroups, that.securityGroups)
|
||||||
&& Objects.equal(this.securityGroupRules, that.securityGroupRules)
|
&& Objects.equal(this.securityGroupRules, that.securityGroupRules)
|
||||||
&& Objects.equal(this.keyPairs, that.keyPairs);
|
&& Objects.equal(this.keyPairs, that.keyPairs);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ToStringHelper string() {
|
protected ToStringHelper string() {
|
||||||
return Objects.toStringHelper("")
|
return Objects.toStringHelper(this)
|
||||||
.add("id", id)
|
.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);
|
||||||
.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
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return string().toString();
|
return string().toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/**
|
/*
|
||||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||||
* contributor license agreements. See the NOTICE file
|
* contributor license agreements. See the NOTICE file
|
||||||
* distributed with this work for additional information
|
* distributed with this work for additional information
|
||||||
|
@ -18,107 +18,118 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.openstack.nova.v2_0.domain;
|
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 static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
|
import java.beans.ConstructorProperties;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import javax.inject.Named;
|
||||||
|
|
||||||
import org.jclouds.javax.annotation.Nullable;
|
import org.jclouds.javax.annotation.Nullable;
|
||||||
|
|
||||||
import com.google.common.base.Objects;
|
import com.google.common.base.Objects;
|
||||||
|
import com.google.common.base.Objects.ToStringHelper;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.gson.annotations.SerializedName;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defines a security group
|
* Defines a security group
|
||||||
*
|
*/
|
||||||
*/
|
|
||||||
public class SecurityGroup {
|
public class SecurityGroup {
|
||||||
public static Builder builder() {
|
|
||||||
return new Builder();
|
public static Builder<?> builder() {
|
||||||
|
return new ConcreteBuilder();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder<?> toBuilder() {
|
||||||
|
return new ConcreteBuilder().fromSecurityGroup(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder toBuilder() {
|
public static abstract class Builder<T extends Builder<T>> {
|
||||||
return builder().fromSecurityGroup(this);
|
protected abstract T self();
|
||||||
}
|
|
||||||
|
|
||||||
public static class Builder {
|
protected String id;
|
||||||
|
protected String tenantId;
|
||||||
private String id;
|
protected String name;
|
||||||
private String tenantId;
|
protected String description;
|
||||||
private String name;
|
protected Set<SecurityGroupRule> rules = ImmutableSet.of();
|
||||||
private String description;
|
|
||||||
private Set<SecurityGroupRule> rules = ImmutableSet.<SecurityGroupRule> of();
|
/**
|
||||||
|
* @see SecurityGroup#getId()
|
||||||
public Builder id(String id) {
|
*/
|
||||||
|
public T id(String id) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
return this;
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder tenantId(String tenantId) {
|
/**
|
||||||
|
* @see SecurityGroup#getTenantId()
|
||||||
|
*/
|
||||||
|
public T tenantId(String tenantId) {
|
||||||
this.tenantId = tenantId;
|
this.tenantId = tenantId;
|
||||||
return this;
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder name(String name) {
|
/**
|
||||||
|
* @see SecurityGroup#getName()
|
||||||
|
*/
|
||||||
|
public T name(String name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
return this;
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder description(String description) {
|
/**
|
||||||
|
* @see SecurityGroup#getDescription()
|
||||||
|
*/
|
||||||
|
public T description(String description) {
|
||||||
this.description = description;
|
this.description = description;
|
||||||
return this;
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* @see SecurityGroup#getRules()
|
||||||
* @see #getSecurityGroupNames
|
|
||||||
*/
|
*/
|
||||||
public Builder rules(SecurityGroupRule... rules) {
|
public T rules(Set<SecurityGroupRule> rules) {
|
||||||
return rules(ImmutableSet.copyOf(checkNotNull(rules, "rules")));
|
this.rules = ImmutableSet.copyOf(checkNotNull(rules, "rules"));
|
||||||
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public T rules(SecurityGroupRule... in) {
|
||||||
* @see #getSecurityGroupNames
|
return rules(ImmutableSet.copyOf(in));
|
||||||
*/
|
|
||||||
public Builder rules(Iterable<SecurityGroupRule> rules) {
|
|
||||||
this.rules = ImmutableSet.copyOf(checkNotNull(rules, "rules"));
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder rules(Set<SecurityGroupRule> rules) {
|
|
||||||
this.rules = rules;
|
|
||||||
return this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public SecurityGroup build() {
|
public SecurityGroup build() {
|
||||||
return new SecurityGroup(id, tenantId, name, description, rules);
|
return new SecurityGroup(id, tenantId, name, description, rules);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder fromSecurityGroup(SecurityGroup in) {
|
public T fromSecurityGroup(SecurityGroup in) {
|
||||||
return id(in.getId()).tenantId(in.getTenantId()).name(in.getName()).description(in.getDescription()).rules(
|
return this
|
||||||
in.getRules());
|
.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
|
|
||||||
}
|
|
||||||
|
|
||||||
protected String id;
|
|
||||||
@SerializedName("tenant_id")
|
|
||||||
protected String tenantId;
|
|
||||||
protected String name;
|
|
||||||
protected String description;
|
|
||||||
protected Set<SecurityGroupRule> rules = ImmutableSet.of();
|
|
||||||
|
|
||||||
protected SecurityGroup(String id, String tenantId, @Nullable String name, @Nullable String description,
|
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||||
Set<SecurityGroupRule> rules) {
|
@Override
|
||||||
this.id = id;
|
protected ConcreteBuilder self() {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private final String id;
|
||||||
|
@Named("tenant_id")
|
||||||
|
private final String tenantId;
|
||||||
|
private final String name;
|
||||||
|
private final String description;
|
||||||
|
private final Set<SecurityGroupRule> rules;
|
||||||
|
|
||||||
|
@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.tenantId = tenantId;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.description = description;
|
this.description = description;
|
||||||
|
@ -130,44 +141,50 @@ public class SecurityGroup {
|
||||||
return this.id;
|
return this.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
public String getTenantId() {
|
public String getTenantId() {
|
||||||
return this.tenantId;
|
return this.tenantId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return this.name;
|
return this.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
return this.description;
|
return this.description;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<SecurityGroupRule> getRules() {
|
public Set<SecurityGroupRule> getRules() {
|
||||||
return this.rules == null ? ImmutableSet.<SecurityGroupRule> of() : rules;
|
return this.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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
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
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return toStringHelper("").add("tenantId", getTenantId()).add("id", getId()).add("name", getName()).add(
|
return string().toString();
|
||||||
"description", description).add("rules", getRules()).toString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/**
|
/*
|
||||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||||
* contributor license agreements. See the NOTICE file
|
* contributor license agreements. See the NOTICE file
|
||||||
* distributed with this work for additional information
|
* distributed with this work for additional information
|
||||||
|
@ -18,99 +18,24 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.openstack.nova.v2_0.domain;
|
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 static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
|
import java.beans.ConstructorProperties;
|
||||||
|
|
||||||
|
import javax.inject.Named;
|
||||||
|
|
||||||
import org.jclouds.javax.annotation.Nullable;
|
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.common.collect.ForwardingObject;
|
||||||
import com.google.gson.annotations.SerializedName;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defines a security group rule
|
* Defines a security group rule
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class SecurityGroupRule extends Ingress {
|
public class SecurityGroupRule extends Ingress {
|
||||||
|
|
||||||
public static Builder builder() {
|
public static class Cidr extends ForwardingObject {
|
||||||
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 {
|
|
||||||
private String cidr;
|
private String cidr;
|
||||||
|
|
||||||
private Cidr(String cidr) {
|
private Cidr(String cidr) {
|
||||||
|
@ -123,18 +48,88 @@ public class SecurityGroupRule extends Ingress {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Builder<?> builder() {
|
||||||
protected SecurityGroupRule(IpProtocol ipProtocol, int fromPort, int toPort, String id, String parentGroupId,
|
return new ConcreteBuilder();
|
||||||
@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 String getParentGroupId() {
|
public Builder<?> toBuilder() {
|
||||||
return this.parentGroupId;
|
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() {
|
public String getId() {
|
||||||
|
@ -143,73 +138,37 @@ public class SecurityGroupRule extends Ingress {
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public TenantIdAndName getGroup() {
|
public TenantIdAndName getGroup() {
|
||||||
if (this.group == null || this.group.getName() == null)
|
|
||||||
return null;
|
|
||||||
return this.group;
|
return this.group;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getParentGroupId() {
|
||||||
|
return this.parentGroupId;
|
||||||
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public String getIpRange() {
|
public String getIpRange() {
|
||||||
return this.ipRange == null ? null : ipRange.cidr;
|
return ipRange == null ? null : ipRange.cidr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
final int prime = 31;
|
return Objects.hashCode(id, group, parentGroupId, ipRange);
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object obj) {
|
||||||
if (this == obj)
|
if (this == obj) return true;
|
||||||
return true;
|
if (obj == null || getClass() != obj.getClass()) return false;
|
||||||
if (obj == null)
|
SecurityGroupRule that = SecurityGroupRule.class.cast(obj);
|
||||||
return false;
|
return super.equals(that) && Objects.equal(this.id, that.id)
|
||||||
if (getClass() != obj.getClass())
|
&& Objects.equal(this.group, that.group)
|
||||||
return false;
|
&& Objects.equal(this.parentGroupId, that.parentGroupId)
|
||||||
SecurityGroupRule other = (SecurityGroupRule) obj;
|
&& Objects.equal(this.ipRange, that.ipRange);
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
protected ToStringHelper string() {
|
||||||
public String toString() {
|
return super.string()
|
||||||
return toStringHelper("").add("id", id).add("fromPort", fromPort).add("group", getGroup()).add("ipProtocol",
|
.add("id", id).add("group", group).add("parentGroupId", parentGroupId).add("ipRange", ipRange);
|
||||||
ipProtocol).add("toPort", toPort).add("parentGroupId", parentGroupId).add("ipRange", getIpRange())
|
|
||||||
.toString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/**
|
/*
|
||||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||||
* contributor license agreements. See the NOTICE file
|
* contributor license agreements. See the NOTICE file
|
||||||
* distributed with this work for additional information
|
* distributed with this work for additional information
|
||||||
|
@ -20,29 +20,33 @@ package org.jclouds.openstack.nova.v2_0.domain;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
|
import java.beans.ConstructorProperties;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import javax.inject.Named;
|
||||||
|
|
||||||
import org.jclouds.javax.annotation.Nullable;
|
import org.jclouds.javax.annotation.Nullable;
|
||||||
import org.jclouds.openstack.nova.v2_0.extensions.KeyPairClient;
|
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.openstack.v2_0.domain.Resource;
|
||||||
import org.jclouds.util.Multimaps2;
|
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.Optional;
|
||||||
import com.google.common.base.Predicates;
|
import com.google.common.base.Predicates;
|
||||||
import com.google.common.base.Strings;
|
import com.google.common.base.Strings;
|
||||||
import com.google.common.base.Objects.ToStringHelper;
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.common.collect.ImmutableMultimap;
|
import com.google.common.collect.ImmutableMultimap;
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
import com.google.common.collect.Multimap;
|
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
|
* A server is a virtual machine instance in the compute system. Flavor and image are requisite
|
||||||
* elements when creating a server.
|
* elements when creating a server.
|
||||||
*
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
* @see <a href=
|
* @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"
|
||||||
|
@ -53,10 +57,10 @@ public class Server extends Resource {
|
||||||
/**
|
/**
|
||||||
* Servers contain a status attribute that can be used as an indication of the current server
|
* 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.
|
* state. Servers with an ACTIVE status are available for use.
|
||||||
*
|
* <p/>
|
||||||
* Other possible values for the status attribute include: BUILD, REBUILD, SUSPENDED, RESIZE,
|
* Other possible values for the status attribute include: BUILD, REBUILD, SUSPENDED, RESIZE,
|
||||||
* VERIFY_RESIZE, REVERT_RESIZE, PASSWORD, REBOOT, HARD_REBOOT, DELETED, UNKNOWN, and ERROR.
|
* VERIFY_RESIZE, REVERT_RESIZE, PASSWORD, REBOOT, HARD_REBOOT, DELETED, UNKNOWN, and ERROR.
|
||||||
*
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
public static enum Status {
|
public static enum Status {
|
||||||
|
@ -76,7 +80,6 @@ public class Server extends Resource {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static Builder<?> builder() {
|
public static Builder<?> builder() {
|
||||||
return new ConcreteBuilder();
|
return new ConcreteBuilder();
|
||||||
}
|
}
|
||||||
|
@ -85,28 +88,25 @@ public class Server extends Resource {
|
||||||
return new ConcreteBuilder().fromServer(this);
|
return new ConcreteBuilder().fromServer(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static abstract class Builder<T extends Builder<T>> extends Resource.Builder<T> {
|
public static abstract class Builder<T extends Builder<T>> extends Resource.Builder<T> {
|
||||||
private String uuid;
|
protected String uuid;
|
||||||
private String tenantId;
|
protected String tenantId;
|
||||||
private String userId;
|
protected String userId;
|
||||||
private Date updated;
|
protected Date updated;
|
||||||
private Date created;
|
protected Date created;
|
||||||
private String hostId;
|
protected String hostId;
|
||||||
private String accessIPv4;
|
protected String accessIPv4;
|
||||||
private String accessIPv6;
|
protected String accessIPv6;
|
||||||
private Server.Status status;
|
protected Server.Status status;
|
||||||
private Resource image;
|
protected Resource image;
|
||||||
private Resource flavor;
|
protected Resource flavor;
|
||||||
private String keyName;
|
protected String keyName;
|
||||||
private String configDrive;
|
protected String configDrive;
|
||||||
private Multimap<String, Address> addresses = ImmutableMultimap.of();
|
protected Multimap<String, Address> addresses = ImmutableMultimap.of();
|
||||||
private Map<String, String> metadata = ImmutableMap.of();
|
protected Map<String, String> metadata = ImmutableMap.of();
|
||||||
// Extended status extension
|
protected ServerExtendedStatus extendedStatus;
|
||||||
private ServerExtendedStatus extendedStatus;
|
protected ServerExtendedAttributes extendedAttributes;
|
||||||
// Extended server attributes extension
|
protected String diskConfig;
|
||||||
private ServerExtendedAttributes extendedAttributes;
|
|
||||||
// Disk Config extension
|
|
||||||
private String diskConfig;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see Server#getUuid()
|
* @see Server#getUuid()
|
||||||
|
@ -224,10 +224,10 @@ public class Server extends Resource {
|
||||||
* @see Server#getMetadata()
|
* @see Server#getMetadata()
|
||||||
*/
|
*/
|
||||||
public T metadata(Map<String, String> metadata) {
|
public T metadata(Map<String, String> metadata) {
|
||||||
this.metadata = metadata;
|
this.metadata = ImmutableMap.copyOf(checkNotNull(metadata, "metadata"));
|
||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see Server#getExtendedStatus()
|
* @see Server#getExtendedStatus()
|
||||||
*/
|
*/
|
||||||
|
@ -237,9 +237,9 @@ public class Server extends Resource {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see Server#getExtendedAttributes()
|
* @see Server#getExtendedAttributes()
|
||||||
*/
|
*/
|
||||||
public T extraAttributes(ServerExtendedAttributes extendedAttributes) {
|
public T extendedAttributes(ServerExtendedAttributes extendedAttributes) {
|
||||||
this.extendedAttributes = extendedAttributes;
|
this.extendedAttributes = extendedAttributes;
|
||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
@ -253,7 +253,9 @@ public class Server extends Resource {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Server build() {
|
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) {
|
public T fromServer(Server in) {
|
||||||
|
@ -274,7 +276,7 @@ public class Server extends Resource {
|
||||||
.addresses(in.getAddresses())
|
.addresses(in.getAddresses())
|
||||||
.metadata(in.getMetadata())
|
.metadata(in.getMetadata())
|
||||||
.extendedStatus(in.getExtendedStatus().orNull())
|
.extendedStatus(in.getExtendedStatus().orNull())
|
||||||
.extraAttributes(in.getExtendedAttributes().orNull())
|
.extendedAttributes(in.getExtendedAttributes().orNull())
|
||||||
.diskConfig(in.getDiskConfig().orNull());
|
.diskConfig(in.getDiskConfig().orNull());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -285,68 +287,64 @@ public class Server extends Resource {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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 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) {
|
private final String uuid;
|
||||||
super(builder);
|
@Named("tenant_id")
|
||||||
this.uuid = builder.uuid; // TODO: see what version this came up in
|
private final String tenantId;
|
||||||
this.tenantId = checkNotNull(builder.tenantId, "tenantId");
|
@Named("user_id")
|
||||||
this.userId = checkNotNull(builder.userId, "userId");
|
private final String userId;
|
||||||
this.updated = checkNotNull(builder.updated, "updated");
|
private final Date updated;
|
||||||
this.created = checkNotNull(builder.created, "created");
|
private final Date created;
|
||||||
this.hostId = builder.hostId;
|
private final String hostId;
|
||||||
this.accessIPv4 = builder.accessIPv4;
|
private final String accessIPv4;
|
||||||
this.accessIPv6 = builder.accessIPv6;
|
private final String accessIPv6;
|
||||||
this.status = checkNotNull(builder.status, "status");
|
private final Server.Status status;
|
||||||
this.configDrive = builder.configDrive;
|
private final Resource image;
|
||||||
this.image = checkNotNull(builder.image, "image");
|
private final Resource flavor;
|
||||||
this.flavor = checkNotNull(builder.flavor, "flavor");
|
@Named("key_name")
|
||||||
this.metadata = Maps.newHashMap(builder.metadata);
|
private final String keyName;
|
||||||
this.addresses = Multimaps2.toOldSchool(ImmutableMultimap.copyOf(checkNotNull(builder.addresses, "addresses")));
|
@Named("config_drive")
|
||||||
this.keyName = builder.keyName;
|
private final String configDrive;
|
||||||
this.extendedStatus = Optional.fromNullable(builder.extendedStatus);
|
private final Map<String, Set<Address>> addresses;
|
||||||
this.extendedAttributes = Optional.fromNullable(builder.extendedAttributes);
|
private final Map<String, String> metadata;
|
||||||
this.diskConfig = builder.diskConfig == null ? Optional.<String>absent() : Optional.of(builder.diskConfig);
|
private final Optional<ServerExtendedStatus> extendedStatus;
|
||||||
|
private final Optional<ServerExtendedAttributes> extendedAttributes;
|
||||||
|
@Named("OS-DCF:diskConfig")
|
||||||
|
private final Optional<String> 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* only present until the id is in uuid form
|
* only present until the id is in uuid form
|
||||||
*
|
*
|
||||||
* @return uuid, if id is an integer val
|
* @return uuid, if id is an integer val
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
|
@ -362,6 +360,7 @@ public class Server extends Resource {
|
||||||
return this.userId;
|
return this.userId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
public Date getUpdated() {
|
public Date getUpdated() {
|
||||||
return this.updated;
|
return this.updated;
|
||||||
}
|
}
|
||||||
|
@ -375,17 +374,17 @@ public class Server extends Resource {
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
public String getHostId() {
|
public String getHostId() {
|
||||||
return Strings.emptyToNull(this.hostId);
|
return this.hostId;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public String getAccessIPv4() {
|
public String getAccessIPv4() {
|
||||||
return Strings.emptyToNull(this.accessIPv4);
|
return this.accessIPv4;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public String getAccessIPv6() {
|
public String getAccessIPv6() {
|
||||||
return Strings.emptyToNull(this.accessIPv6);
|
return this.accessIPv6;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Status getStatus() {
|
public Status getStatus() {
|
||||||
|
@ -394,7 +393,7 @@ public class Server extends Resource {
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public String getConfigDrive() {
|
public String getConfigDrive() {
|
||||||
return Strings.emptyToNull(this.configDrive);
|
return this.configDrive;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Resource getImage() {
|
public Resource getImage() {
|
||||||
|
@ -426,7 +425,6 @@ public class Server extends Resource {
|
||||||
return keyName;
|
return keyName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves the extended server status fields (alias "OS-EXT-STS")
|
* Retrieves the extended server status fields (alias "OS-EXT-STS")
|
||||||
* <p/>
|
* <p/>
|
||||||
|
@ -468,11 +466,12 @@ public class Server extends Resource {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ToStringHelper string() {
|
protected ToStringHelper string() {
|
||||||
return super.string().add("uuid", uuid).add("tenantId", tenantId).add(
|
return super.string()
|
||||||
"userId", userId).add("hostId", getHostId()).add("updated", updated).add("created", created).add(
|
.add("uuid", uuid).add("tenantId", tenantId).add("userId", userId).add("updated", updated).add("created", created)
|
||||||
"accessIPv4", getAccessIPv4()).add("accessIPv6", getAccessIPv6()).add("status", status).add(
|
.add("hostId", hostId).add("accessIPv4", accessIPv4).add("accessIPv6", accessIPv6).add("status", status).add("image", image)
|
||||||
"configDrive", getConfigDrive()).add("image", image).add("flavor", flavor).add("metadata", metadata)
|
.add("flavor", flavor).add("keyName", keyName).add("configDrive", configDrive).add("addresses", addresses)
|
||||||
.add("addresses", getAddresses()).add("diskConfig", diskConfig)
|
.add("metadata", metadata).add("extendedStatus", extendedStatus).add("extendedAttributes", extendedAttributes)
|
||||||
.add("extendedStatus", extendedStatus).add("extendedAttributes", extendedAttributes);
|
.add("diskConfig", diskConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/**
|
/*
|
||||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||||
* contributor license agreements. See the NOTICE file
|
* contributor license agreements. See the NOTICE file
|
||||||
* distributed with this work for additional information
|
* distributed with this work for additional information
|
||||||
|
@ -18,8 +18,16 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.openstack.nova.v2_0.domain;
|
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 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.Objects.ToStringHelper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -27,23 +35,23 @@ import com.google.common.base.Objects.ToStringHelper;
|
||||||
*
|
*
|
||||||
* @author Adam Lowe
|
* @author Adam Lowe
|
||||||
* @see <a href=
|
* @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 class ServerCreated extends Resource {
|
||||||
|
|
||||||
public static Builder<?> builder() {
|
public static Builder<?> builder() {
|
||||||
return new ConcreteBuilder();
|
return new ConcreteBuilder();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder<?> toBuilder() {
|
public Builder<?> toBuilder() {
|
||||||
return new ConcreteBuilder().fromServerCreated(this);
|
return new ConcreteBuilder().fromServerCreated(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static abstract class Builder<T extends Builder<T>> extends Resource.Builder<T> {
|
public static abstract class Builder<T extends Builder<T>> extends Resource.Builder<T> {
|
||||||
private String adminPass;
|
protected String adminPass;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see ServerCreated#getAdminPass()
|
* @see ServerCreated#getAdminPass()
|
||||||
*/
|
*/
|
||||||
public T adminPass(String adminPass) {
|
public T adminPass(String adminPass) {
|
||||||
|
@ -51,12 +59,13 @@ public class ServerCreated extends Resource {
|
||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
public T fromServerCreated(ServerCreated in) {
|
|
||||||
return super.fromResource(in).adminPass(in.getAdminPass());
|
|
||||||
}
|
|
||||||
|
|
||||||
public ServerCreated build() {
|
public ServerCreated build() {
|
||||||
return new ServerCreated(this);
|
return new ServerCreated(id, name, links, adminPass);
|
||||||
|
}
|
||||||
|
|
||||||
|
public T fromServerCreated(ServerCreated in) {
|
||||||
|
return super.fromResource(in)
|
||||||
|
.adminPass(in.getAdminPass());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,31 +75,40 @@ public class ServerCreated extends Resource {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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 String adminPass;
|
|
||||||
|
|
||||||
protected ServerCreated(Builder<?> builder) {
|
private final String adminPass;
|
||||||
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.
|
* @return the administrative password for this server. Note: this is not available in Server responses.
|
||||||
*/
|
*/
|
||||||
public String getAdminPass() {
|
public String getAdminPass() {
|
||||||
return adminPass;
|
return this.adminPass;
|
||||||
}
|
}
|
||||||
|
|
||||||
// hashCode/equals from super is ok
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ToStringHelper string() {
|
public int hashCode() {
|
||||||
return super.string().add("adminPass", adminPass);
|
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
|
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||||
* contributor license agreements. See the NOTICE file
|
* contributor license agreements. See the NOTICE file
|
||||||
* distributed with this work for additional information
|
* distributed with this work for additional information
|
||||||
|
@ -18,39 +18,45 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.openstack.nova.v2_0.domain;
|
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;
|
||||||
import com.google.common.base.Objects.ToStringHelper;
|
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")
|
* Additional attributes delivered by Extended Server Attributes extension (alias "OS-EXT-SRV-ATTR")
|
||||||
*
|
*
|
||||||
* @author Adam Lowe
|
* @author Adam Lowe
|
||||||
* @see <a href=
|
* @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.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 class ServerExtendedAttributes {
|
||||||
public static final String PREFIX = "OS-EXT-SRV-ATTR:";
|
|
||||||
|
|
||||||
public static Builder<?> builder() {
|
public static String PREFIX;
|
||||||
|
|
||||||
|
public static Builder<?> builder() {
|
||||||
return new ConcreteBuilder();
|
return new ConcreteBuilder();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder<?> toBuilder() {
|
public Builder<?> toBuilder() {
|
||||||
return new ConcreteBuilder().fromServerExtraAttributes(this);
|
return new ConcreteBuilder().fromServerExtendedAttributes(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static abstract class Builder<T extends Builder<T>> {
|
public static abstract class Builder<T extends Builder<T>> {
|
||||||
protected abstract T self();
|
protected abstract T self();
|
||||||
|
|
||||||
private String instanceName;
|
protected String instanceName;
|
||||||
private String hostName;
|
protected String hostName;
|
||||||
private String hypervisorHostName;
|
protected String hypervisorHostName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see ServerExtendedAttributes#getInstanceName()
|
* @see ServerExtendedAttributes#getInstanceName()
|
||||||
*/
|
*/
|
||||||
public T instanceName(String instanceName) {
|
public T instanceName(String instanceName) {
|
||||||
|
@ -58,7 +64,7 @@ public class ServerExtendedAttributes {
|
||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see ServerExtendedAttributes#getHostName()
|
* @see ServerExtendedAttributes#getHostName()
|
||||||
*/
|
*/
|
||||||
public T hostName(String hostName) {
|
public T hostName(String hostName) {
|
||||||
|
@ -66,23 +72,23 @@ public class ServerExtendedAttributes {
|
||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see ServerExtendedAttributes#getHypervisorHostName()
|
* @see ServerExtendedAttributes#getHypervisorHostName()
|
||||||
*/
|
*/
|
||||||
public T hypervisorHostame(String hypervisorHostName) {
|
public T hypervisorHostName(String hypervisorHostName) {
|
||||||
this.hypervisorHostName = hypervisorHostName;
|
this.hypervisorHostName = hypervisorHostName;
|
||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ServerExtendedAttributes build() {
|
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
|
return this
|
||||||
.instanceName(in.getInstanceName())
|
.instanceName(in.getInstanceName())
|
||||||
.hostName(in.getHostName())
|
.hostName(in.getHostName())
|
||||||
.hypervisorHostame(in.getHypervisorHostName());
|
.hypervisorHostName(in.getHypervisorHostName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,34 +98,34 @@ public class ServerExtendedAttributes {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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) {
|
@Named("OS-EXT-SRV-ATTR:instance_name")
|
||||||
this.instanceName = builder.instanceName;
|
private final String instanceName;
|
||||||
this.hostName = builder.hostName;
|
@Named("OS-EXT-SRV-ATTR:host")
|
||||||
this.hypervisorHostName = builder.hypervisorHostName;
|
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() {
|
public String getInstanceName() {
|
||||||
return this.instanceName;
|
return this.instanceName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
public String getHostName() {
|
public String getHostName() {
|
||||||
return this.hostName;
|
return this.hostName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
public String getHypervisorHostName() {
|
public String getHypervisorHostName() {
|
||||||
return this.hypervisorHostName;
|
return this.hypervisorHostName;
|
||||||
}
|
}
|
||||||
|
@ -135,20 +141,18 @@ public class ServerExtendedAttributes {
|
||||||
if (obj == null || getClass() != obj.getClass()) return false;
|
if (obj == null || getClass() != obj.getClass()) return false;
|
||||||
ServerExtendedAttributes that = ServerExtendedAttributes.class.cast(obj);
|
ServerExtendedAttributes that = ServerExtendedAttributes.class.cast(obj);
|
||||||
return Objects.equal(this.instanceName, that.instanceName)
|
return Objects.equal(this.instanceName, that.instanceName)
|
||||||
&& Objects.equal(this.hostName, that.hostName)
|
&& Objects.equal(this.hostName, that.hostName)
|
||||||
&& Objects.equal(this.hypervisorHostName, that.hypervisorHostName);
|
&& Objects.equal(this.hypervisorHostName, that.hypervisorHostName);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ToStringHelper string() {
|
protected ToStringHelper string() {
|
||||||
return Objects.toStringHelper("")
|
return Objects.toStringHelper(this)
|
||||||
.add("instanceName", instanceName)
|
.add("instanceName", instanceName).add("hostName", hostName).add("hypervisorHostName", hypervisorHostName);
|
||||||
.add("hostName", hostName)
|
|
||||||
.add("hypervisorHostName", hypervisorHostName);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return string().toString();
|
return string().toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/**
|
/*
|
||||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||||
* contributor license agreements. See the NOTICE file
|
* contributor license agreements. See the NOTICE file
|
||||||
* distributed with this work for additional information
|
* distributed with this work for additional information
|
||||||
|
@ -18,41 +18,45 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.openstack.nova.v2_0.domain;
|
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.javax.annotation.Nullable;
|
||||||
|
|
||||||
import com.google.common.base.Objects;
|
import com.google.common.base.Objects;
|
||||||
import com.google.common.base.Objects.ToStringHelper;
|
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")
|
* Additional attributes delivered by Extended Server Status extension (alias "OS-EXT-STS")
|
||||||
*
|
*
|
||||||
* @author Adam Lowe
|
* @author Adam Lowe
|
||||||
* @see <a href=
|
* @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.v2_0.features.ExtensionClient#getExtensionByAlias
|
||||||
* @see org.jclouds.openstack.nova.v1_1.extensions.ExtensionNamespaces#EXTENDED_STATUS (extended status?)
|
* @see org.jclouds.openstack.nova.v1_1.extensions.ExtensionNamespaces#EXTENDED_STATUS (extended status?)
|
||||||
*/
|
*/
|
||||||
public class ServerExtendedStatus {
|
public class ServerExtendedStatus {
|
||||||
public static final String PREFIX = "OS-EXT-STS:";
|
|
||||||
|
|
||||||
public static Builder<?> builder() {
|
public static String PREFIX;
|
||||||
|
|
||||||
|
public static Builder<?> builder() {
|
||||||
return new ConcreteBuilder();
|
return new ConcreteBuilder();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder<?> toBuilder() {
|
public Builder<?> toBuilder() {
|
||||||
return new ConcreteBuilder().fromServerExtendedStatus(this);
|
return new ConcreteBuilder().fromServerExtendedStatus(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static abstract class Builder<T extends Builder<T>> {
|
public static abstract class Builder<T extends Builder<T>> {
|
||||||
protected abstract T self();
|
protected abstract T self();
|
||||||
|
|
||||||
private String taskState;
|
protected String taskState;
|
||||||
private String vmState;
|
protected String vmState;
|
||||||
private int powerState = Integer.MIN_VALUE;
|
protected int powerState;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see ServerExtendedStatus#getTaskState()
|
* @see ServerExtendedStatus#getTaskState()
|
||||||
*/
|
*/
|
||||||
public T taskState(String taskState) {
|
public T taskState(String taskState) {
|
||||||
|
@ -60,7 +64,7 @@ public class ServerExtendedStatus {
|
||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see ServerExtendedStatus#getVmState()
|
* @see ServerExtendedStatus#getVmState()
|
||||||
*/
|
*/
|
||||||
public T vmState(String vmState) {
|
public T vmState(String vmState) {
|
||||||
|
@ -68,7 +72,7 @@ public class ServerExtendedStatus {
|
||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see ServerExtendedStatus#getPowerState()
|
* @see ServerExtendedStatus#getPowerState()
|
||||||
*/
|
*/
|
||||||
public T powerState(int powerState) {
|
public T powerState(int powerState) {
|
||||||
|
@ -77,14 +81,14 @@ public class ServerExtendedStatus {
|
||||||
}
|
}
|
||||||
|
|
||||||
public ServerExtendedStatus build() {
|
public ServerExtendedStatus build() {
|
||||||
return new ServerExtendedStatus(this);
|
return new ServerExtendedStatus(taskState, vmState, powerState);
|
||||||
}
|
}
|
||||||
|
|
||||||
public T fromServerExtendedStatus(ServerExtendedStatus in) {
|
public T fromServerExtendedStatus(ServerExtendedStatus in) {
|
||||||
return this
|
return this
|
||||||
.taskState(in.getTaskState())
|
.taskState(in.getTaskState())
|
||||||
.vmState(in.getVmState())
|
.vmState(in.getVmState())
|
||||||
.powerState(in.getPowerState());
|
.powerState(in.getPowerState());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -94,26 +98,23 @@ public class ServerExtendedStatus {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
|
||||||
}
|
|
||||||
|
|
||||||
@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) {
|
@Named("OS-EXT-STS:task_state")
|
||||||
this.taskState = builder.taskState;
|
private final String taskState;
|
||||||
this.vmState = builder.vmState;
|
@Named("OS-EXT-STS:vm_state")
|
||||||
this.powerState = builder.powerState;
|
private final String vmState;
|
||||||
|
@Named("OS-EXT-STS:power_state")
|
||||||
|
private final int 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
|
@Nullable
|
||||||
public String getTaskState() {
|
public String getTaskState() {
|
||||||
return this.taskState;
|
return this.taskState;
|
||||||
|
@ -139,22 +140,18 @@ public class ServerExtendedStatus {
|
||||||
if (obj == null || getClass() != obj.getClass()) return false;
|
if (obj == null || getClass() != obj.getClass()) return false;
|
||||||
ServerExtendedStatus that = ServerExtendedStatus.class.cast(obj);
|
ServerExtendedStatus that = ServerExtendedStatus.class.cast(obj);
|
||||||
return Objects.equal(this.taskState, that.taskState)
|
return Objects.equal(this.taskState, that.taskState)
|
||||||
&& Objects.equal(this.vmState, that.vmState)
|
&& Objects.equal(this.vmState, that.vmState)
|
||||||
&& Objects.equal(this.powerState, that.powerState)
|
&& Objects.equal(this.powerState, that.powerState);
|
||||||
;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ToStringHelper string() {
|
protected ToStringHelper string() {
|
||||||
return Objects.toStringHelper("")
|
return Objects.toStringHelper(this)
|
||||||
.add("taskState", taskState)
|
.add("taskState", taskState).add("vmState", vmState).add("powerState", powerState);
|
||||||
.add("vmState", vmState)
|
|
||||||
.add("powerState", powerState)
|
|
||||||
;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return string().toString();
|
return string().toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/**
|
/*
|
||||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||||
* contributor license agreements. See the NOTICE file
|
* contributor license agreements. See the NOTICE file
|
||||||
* distributed with this work for additional information
|
* distributed with this work for additional information
|
||||||
|
@ -20,51 +20,65 @@ package org.jclouds.openstack.nova.v2_0.domain;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
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 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;
|
||||||
import com.google.common.base.Objects.ToStringHelper;
|
import com.google.common.base.Objects.ToStringHelper;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.gson.annotations.SerializedName;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extended server returned by ServerWithSecurityGroupsClient
|
* Extended server returned by ServerWithSecurityGroupsClient
|
||||||
*
|
*
|
||||||
* @author Adam Lowe
|
* @author Adam Lowe
|
||||||
* @see <a href=
|
* @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 ServerWithSecurityGroups extends Server {
|
public class ServerWithSecurityGroups extends Server {
|
||||||
|
|
||||||
public static Builder<?> builder() {
|
public static Builder<?> builder() {
|
||||||
return new ConcreteBuilder();
|
return new ConcreteBuilder();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder<?> toBuilder() {
|
public Builder<?> toBuilder() {
|
||||||
return new ConcreteBuilder().fromServerWithSecurityGroups(this);
|
return new ConcreteBuilder().fromServerWithSecurityGroups(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static abstract class Builder<T extends Builder<T>> extends Server.Builder<T> {
|
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()
|
* @see ServerWithSecurityGroups#getSecurityGroupNames()
|
||||||
*/
|
*/
|
||||||
public T securityGroupNames(Set<String> securityGroupNames) {
|
public T securityGroupNames(Set<String> securityGroupNames) {
|
||||||
this.securityGroupNames = securityGroupNames;
|
this.securityGroupNames = ImmutableSet.copyOf(checkNotNull(securityGroupNames, "securityGroupNames"));
|
||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public T securityGroupNames(String... in) {
|
||||||
|
return securityGroupNames(ImmutableSet.copyOf(in));
|
||||||
|
}
|
||||||
|
|
||||||
public ServerWithSecurityGroups build() {
|
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) {
|
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> {
|
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||||
|
@ -73,25 +87,26 @@ public class ServerWithSecurityGroups extends Server {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
|
||||||
}
|
|
||||||
|
|
||||||
@SerializedName(value="security_groups")
|
|
||||||
private Set<String> securityGroupNames = ImmutableSet.of();
|
|
||||||
|
|
||||||
protected ServerWithSecurityGroups(Builder<?> builder) {
|
@Named("security_groups")
|
||||||
super(builder);
|
private final Set<String> securityGroupNames;
|
||||||
this.securityGroupNames = ImmutableSet.copyOf(checkNotNull(builder.securityGroupNames, "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"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
public Set<String> getSecurityGroupNames() {
|
public Set<String> getSecurityGroupNames() {
|
||||||
return Collections.unmodifiableSet(this.securityGroupNames);
|
return this.securityGroupNames;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -106,10 +121,10 @@ public class ServerWithSecurityGroups extends Server {
|
||||||
ServerWithSecurityGroups that = ServerWithSecurityGroups.class.cast(obj);
|
ServerWithSecurityGroups that = ServerWithSecurityGroups.class.cast(obj);
|
||||||
return super.equals(that) && Objects.equal(this.securityGroupNames, that.securityGroupNames);
|
return super.equals(that) && Objects.equal(this.securityGroupNames, that.securityGroupNames);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ToStringHelper string() {
|
protected ToStringHelper string() {
|
||||||
return super.string()
|
return super.string()
|
||||||
.add("securityGroupNames", securityGroupNames);
|
.add("securityGroupNames", securityGroupNames);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/**
|
/*
|
||||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||||
* contributor license agreements. See the NOTICE file
|
* contributor license agreements. See the NOTICE file
|
||||||
* distributed with this work for additional information
|
* distributed with this work for additional information
|
||||||
|
@ -20,137 +20,172 @@ package org.jclouds.openstack.nova.v2_0.domain;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
|
import java.beans.ConstructorProperties;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
|
import javax.inject.Named;
|
||||||
|
|
||||||
import org.jclouds.javax.annotation.Nullable;
|
import org.jclouds.javax.annotation.Nullable;
|
||||||
|
|
||||||
import com.google.common.base.Objects;
|
import com.google.common.base.Objects;
|
||||||
import com.google.common.base.Objects.ToStringHelper;
|
import com.google.common.base.Objects.ToStringHelper;
|
||||||
import com.google.gson.annotations.SerializedName;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Information the SimpleTenantUsage extension return data about each Server
|
* Information the SimpleTenantUsage extension return data about each Server
|
||||||
*
|
*
|
||||||
* @author Adam Lowe
|
* @author Adam Lowe
|
||||||
*/
|
*/
|
||||||
public class SimpleServerUsage {
|
public class SimpleServerUsage {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
public static enum Status {
|
public static enum Status {
|
||||||
|
|
||||||
UNRECOGNIZED, ACTIVE;
|
UNRECOGNIZED, ACTIVE;
|
||||||
|
|
||||||
public String value() {
|
public String value() {
|
||||||
return name();
|
return name();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Status fromValue(String v) {
|
public static Status fromValue(String v) {
|
||||||
try {
|
try {
|
||||||
return valueOf(v.toUpperCase());
|
return valueOf(v.toUpperCase());
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
return UNRECOGNIZED;
|
return UNRECOGNIZED;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Builder<?> builder() {
|
public static Builder<?> builder() {
|
||||||
return new ConcreteBuilder();
|
return new ConcreteBuilder();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder<?> toBuilder() {
|
public Builder<?> toBuilder() {
|
||||||
return new ConcreteBuilder().fromSimpleServerUsage(this);
|
return new ConcreteBuilder().fromSimpleServerUsage(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static abstract class Builder<T extends Builder<T>> {
|
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 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) {
|
public T instanceName(String instanceName) {
|
||||||
this.instanceName = instanceName;
|
this.instanceName = instanceName;
|
||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see SimpleServerUsage#getHours()
|
||||||
|
*/
|
||||||
public T hours(double hours) {
|
public T hours(double hours) {
|
||||||
this.hours = hours;
|
this.hours = hours;
|
||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see SimpleServerUsage#getFlavorMemoryMb()
|
||||||
|
*/
|
||||||
public T flavorMemoryMb(double flavorMemoryMb) {
|
public T flavorMemoryMb(double flavorMemoryMb) {
|
||||||
this.flavorMemoryMb = flavorMemoryMb;
|
this.flavorMemoryMb = flavorMemoryMb;
|
||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see SimpleServerUsage#getFlavorLocalGb()
|
||||||
|
*/
|
||||||
public T flavorLocalGb(double flavorLocalGb) {
|
public T flavorLocalGb(double flavorLocalGb) {
|
||||||
this.flavorLocalGb = flavorLocalGb;
|
this.flavorLocalGb = flavorLocalGb;
|
||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see SimpleServerUsage#getFlavorVcpus()
|
||||||
|
*/
|
||||||
public T flavorVcpus(double flavorVcpus) {
|
public T flavorVcpus(double flavorVcpus) {
|
||||||
this.flavorVcpus = flavorVcpus;
|
this.flavorVcpus = flavorVcpus;
|
||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see SimpleServerUsage#getTenantId()
|
||||||
|
*/
|
||||||
public T tenantId(String tenantId) {
|
public T tenantId(String tenantId) {
|
||||||
this.tenantId = tenantId;
|
this.tenantId = tenantId;
|
||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see SimpleServerUsage#getFlavorName()
|
||||||
|
*/
|
||||||
public T flavorName(String flavorName) {
|
public T flavorName(String flavorName) {
|
||||||
this.flavorName = flavorName;
|
this.flavorName = flavorName;
|
||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see SimpleServerUsage#getInstanceCreated()
|
||||||
|
*/
|
||||||
public T instanceCreated(Date instanceCreated) {
|
public T instanceCreated(Date instanceCreated) {
|
||||||
this.instanceCreated = instanceCreated;
|
this.instanceCreated = instanceCreated;
|
||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see SimpleServerUsage#getInstanceTerminiated()
|
||||||
|
*/
|
||||||
public T instanceTerminiated(Date instanceTerminiated) {
|
public T instanceTerminiated(Date instanceTerminiated) {
|
||||||
this.instanceTerminiated = instanceTerminiated;
|
this.instanceTerminiated = instanceTerminiated;
|
||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
public T instanceStatus(Status instanceStatus) {
|
/**
|
||||||
|
* @see SimpleServerUsage#getInstanceStatus()
|
||||||
|
*/
|
||||||
|
public T instanceStatus(SimpleServerUsage.Status instanceStatus) {
|
||||||
this.instanceStatus = instanceStatus;
|
this.instanceStatus = instanceStatus;
|
||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see SimpleServerUsage#getUptime()
|
||||||
|
*/
|
||||||
public T uptime(long uptime) {
|
public T uptime(long uptime) {
|
||||||
this.uptime = uptime;
|
this.uptime = uptime;
|
||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
public SimpleServerUsage build() {
|
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) {
|
public T fromSimpleServerUsage(SimpleServerUsage in) {
|
||||||
return this
|
return this
|
||||||
.instanceName(in.getInstanceName())
|
.instanceName(in.getInstanceName())
|
||||||
.flavorMemoryMb(in.getFlavorMemoryMb())
|
.hours(in.getHours())
|
||||||
.flavorLocalGb(in.getFlavorLocalGb())
|
.flavorMemoryMb(in.getFlavorMemoryMb())
|
||||||
.flavorVcpus(in.getFlavorVcpus())
|
.flavorLocalGb(in.getFlavorLocalGb())
|
||||||
.tenantId(in.getTenantId())
|
.flavorVcpus(in.getFlavorVcpus())
|
||||||
.flavorName(in.getFlavorName())
|
.tenantId(in.getTenantId())
|
||||||
.instanceCreated(in.getInstanceCreated())
|
.flavorName(in.getFlavorName())
|
||||||
.instanceTerminiated(in.getInstanceTerminiated())
|
.instanceCreated(in.getInstanceCreated())
|
||||||
.instanceStatus(in.getInstanceStatus())
|
.instanceTerminiated(in.getInstanceTerminiated())
|
||||||
.uptime(in.getUptime())
|
.instanceStatus(in.getInstanceStatus())
|
||||||
;
|
.uptime(in.getUptime());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||||
|
@ -159,112 +194,93 @@ public class SimpleServerUsage {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
|
||||||
}
|
|
||||||
|
|
||||||
@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) {
|
@Named("name")
|
||||||
this.instanceName = checkNotNull(builder.instanceName, "instanceName");
|
private final String instanceName;
|
||||||
this.hours = builder.hours;
|
private final double hours;
|
||||||
this.flavorMemoryMb = builder.flavorMemoryMb;
|
@Named("memory_mb")
|
||||||
this.flavorLocalGb = builder.flavorLocalGb;
|
private final double flavorMemoryMb;
|
||||||
this.flavorVcpus = builder.flavorVcpus;
|
@Named("local_gb")
|
||||||
this.tenantId = checkNotNull(builder.tenantId, "tenantId");
|
private final double flavorLocalGb;
|
||||||
this.flavorName = checkNotNull(builder.flavorName, "flavorName");
|
@Named("vcpus")
|
||||||
this.instanceCreated = builder.instanceCreated; //checkNotNull(builder.instanceCreated, "instanceCreated");
|
private final double flavorVcpus;
|
||||||
this.instanceTerminiated = builder.instanceTerminiated;
|
@Named("tenant_id")
|
||||||
this.instanceStatus = checkNotNull(builder.instanceStatus, "instanceStatus");
|
private final String tenantId;
|
||||||
this.uptime = checkNotNull(builder.uptime, "uptime");
|
@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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
public String getInstanceName() {
|
public String getInstanceName() {
|
||||||
return this.instanceName;
|
return this.instanceName;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public double getHours() {
|
||||||
*/
|
return this.hours;
|
||||||
|
}
|
||||||
|
|
||||||
public double getFlavorMemoryMb() {
|
public double getFlavorMemoryMb() {
|
||||||
return this.flavorMemoryMb;
|
return this.flavorMemoryMb;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
public double getFlavorLocalGb() {
|
public double getFlavorLocalGb() {
|
||||||
return this.flavorLocalGb;
|
return this.flavorLocalGb;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
public double getFlavorVcpus() {
|
public double getFlavorVcpus() {
|
||||||
return this.flavorVcpus;
|
return this.flavorVcpus;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
public String getTenantId() {
|
public String getTenantId() {
|
||||||
return this.tenantId;
|
return this.tenantId;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
public String getFlavorName() {
|
public String getFlavorName() {
|
||||||
return this.flavorName;
|
return this.flavorName;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
public Date getInstanceCreated() {
|
public Date getInstanceCreated() {
|
||||||
return this.instanceCreated;
|
return this.instanceCreated;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public Date getInstanceTerminiated() {
|
public Date getInstanceTerminiated() {
|
||||||
return this.instanceTerminiated;
|
return this.instanceTerminiated;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public SimpleServerUsage.Status getInstanceStatus() {
|
||||||
*/
|
|
||||||
public Status getInstanceStatus() {
|
|
||||||
return this.instanceStatus;
|
return this.instanceStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
public long getUptime() {
|
public long getUptime() {
|
||||||
return this.uptime;
|
return this.uptime;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
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
|
@Override
|
||||||
|
@ -273,33 +289,23 @@ public class SimpleServerUsage {
|
||||||
if (obj == null || getClass() != obj.getClass()) return false;
|
if (obj == null || getClass() != obj.getClass()) return false;
|
||||||
SimpleServerUsage that = SimpleServerUsage.class.cast(obj);
|
SimpleServerUsage that = SimpleServerUsage.class.cast(obj);
|
||||||
return Objects.equal(this.instanceName, that.instanceName)
|
return Objects.equal(this.instanceName, that.instanceName)
|
||||||
&& Objects.equal(this.flavorMemoryMb, that.flavorMemoryMb)
|
&& Objects.equal(this.hours, that.hours)
|
||||||
&& Objects.equal(this.flavorLocalGb, that.flavorLocalGb)
|
&& Objects.equal(this.flavorMemoryMb, that.flavorMemoryMb)
|
||||||
&& Objects.equal(this.flavorVcpus, that.flavorVcpus)
|
&& Objects.equal(this.flavorLocalGb, that.flavorLocalGb)
|
||||||
&& Objects.equal(this.tenantId, that.tenantId)
|
&& Objects.equal(this.flavorVcpus, that.flavorVcpus)
|
||||||
&& Objects.equal(this.flavorName, that.flavorName)
|
&& Objects.equal(this.tenantId, that.tenantId)
|
||||||
&& Objects.equal(this.instanceCreated, that.instanceCreated)
|
&& Objects.equal(this.flavorName, that.flavorName)
|
||||||
&& Objects.equal(this.instanceTerminiated, that.instanceTerminiated)
|
&& Objects.equal(this.instanceCreated, that.instanceCreated)
|
||||||
&& Objects.equal(this.instanceStatus, that.instanceStatus)
|
&& Objects.equal(this.instanceTerminiated, that.instanceTerminiated)
|
||||||
&& Objects.equal(this.uptime, that.uptime)
|
&& Objects.equal(this.instanceStatus, that.instanceStatus)
|
||||||
;
|
&& Objects.equal(this.uptime, that.uptime);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ToStringHelper string() {
|
protected ToStringHelper string() {
|
||||||
return Objects.toStringHelper("")
|
return Objects.toStringHelper(this)
|
||||||
.add("instanceName", instanceName)
|
.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);
|
||||||
.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
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return string().toString();
|
return string().toString();
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/**
|
/*
|
||||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||||
* contributor license agreements. See the NOTICE file
|
* contributor license agreements. See the NOTICE file
|
||||||
* distributed with this work for additional information
|
* distributed with this work for additional information
|
||||||
|
@ -20,101 +20,128 @@ package org.jclouds.openstack.nova.v2_0.domain;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.beans.ConstructorProperties;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import javax.inject.Named;
|
||||||
|
|
||||||
import org.jclouds.javax.annotation.Nullable;
|
import org.jclouds.javax.annotation.Nullable;
|
||||||
|
|
||||||
import com.google.common.base.Objects;
|
import com.google.common.base.Objects;
|
||||||
import com.google.common.base.Objects.ToStringHelper;
|
import com.google.common.base.Objects.ToStringHelper;
|
||||||
import com.google.common.collect.ImmutableSet;
|
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
|
* Information the SimpleTenantUsage extension returns data about each tenant
|
||||||
*
|
*
|
||||||
* @author Adam Lowe
|
* @author Adam Lowe
|
||||||
*/
|
*/
|
||||||
public class SimpleTenantUsage {
|
public class SimpleTenantUsage {
|
||||||
public static Builder<?> builder() {
|
|
||||||
|
public static Builder<?> builder() {
|
||||||
return new ConcreteBuilder();
|
return new ConcreteBuilder();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder<?> toBuilder() {
|
public Builder<?> toBuilder() {
|
||||||
return new ConcreteBuilder().fromSimpleTenantUsage(this);
|
return new ConcreteBuilder().fromSimpleTenantUsage(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static abstract class Builder<T extends Builder<T>> {
|
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();
|
|
||||||
|
|
||||||
protected abstract T self();
|
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) {
|
public T tenantId(String tenantId) {
|
||||||
this.tenantId = tenantId;
|
this.tenantId = tenantId;
|
||||||
return self();
|
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();
|
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();
|
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();
|
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();
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see SimpleTenantUsage#getStart()
|
||||||
|
*/
|
||||||
public T start(Date start) {
|
public T start(Date start) {
|
||||||
this.start = start;
|
this.start = start;
|
||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see SimpleTenantUsage#getStop()
|
||||||
|
*/
|
||||||
public T stop(Date stop) {
|
public T stop(Date stop) {
|
||||||
this.stop = stop;
|
this.stop = stop;
|
||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see SimpleTenantUsage#getServerUsages()
|
||||||
|
*/
|
||||||
public T serverUsages(Set<SimpleServerUsage> serverUsages) {
|
public T serverUsages(Set<SimpleServerUsage> serverUsages) {
|
||||||
this.serverUsages = serverUsages;
|
this.serverUsages = ImmutableSet.copyOf(checkNotNull(serverUsages, "serverUsages"));
|
||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
public SimpleTenantUsage build() {
|
public T serverUsages(SimpleServerUsage... in) {
|
||||||
return new SimpleTenantUsage(this);
|
return serverUsages(ImmutableSet.copyOf(in));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SimpleTenantUsage build() {
|
||||||
|
return new SimpleTenantUsage(tenantId, totalLocalGbUsage, totalVcpusUsage, totalMemoryMbUsage, totalHours, start, stop, serverUsages);
|
||||||
|
}
|
||||||
|
|
||||||
public T fromSimpleTenantUsage(SimpleTenantUsage in) {
|
public T fromSimpleTenantUsage(SimpleTenantUsage in) {
|
||||||
return this
|
return this
|
||||||
.totalLocalGbUsage(in.getTotalLocalGbUsage())
|
.tenantId(in.getTenantId())
|
||||||
.totalVcpusUsage(in.getTotalVcpusUsage())
|
.totalLocalGbUsage(in.getTotalLocalGbUsage())
|
||||||
.totalMemoryMbUsage(in.getTotalMemoryMbUsage())
|
.totalVcpusUsage(in.getTotalVcpusUsage())
|
||||||
.totalHours(in.getTotalHours())
|
.totalMemoryMbUsage(in.getTotalMemoryMbUsage())
|
||||||
.start(in.getStart())
|
.totalHours(in.getTotalHours())
|
||||||
.stop(in.getStop())
|
.start(in.getStart())
|
||||||
.serverUsages(in.getServerUsages())
|
.stop(in.getStop())
|
||||||
;
|
.serverUsages(in.getServerUsages());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||||
|
@ -123,91 +150,73 @@ public class SimpleTenantUsage {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
|
||||||
}
|
|
||||||
|
|
||||||
@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) {
|
@Named("tenant_id")
|
||||||
this.tenantId = builder.tenantId;
|
private final String tenantId;
|
||||||
this.totalLocalGbUsage = builder.totalLocalGbUsage;
|
@Named("total_local_gb_usage")
|
||||||
this.totalVcpusUsage = builder.totalVcpusUsage;
|
private final double totalLocalGbUsage;
|
||||||
this.totalMemoryMbUsage = builder.totalMemoryMbUsage;
|
@Named("total_vcpus_usage")
|
||||||
this.totalHours = builder.totalHours;
|
private final double totalVcpusUsage;
|
||||||
this.start = builder.start;
|
@Named("total_memory_mb_usage")
|
||||||
this.stop = builder.stop;
|
private final double totalMemoryMbUsage;
|
||||||
this.serverUsages = ImmutableSet.copyOf(checkNotNull(builder.serverUsages, "serverUsages"));
|
@Named("total_hours")
|
||||||
|
private final double totalHours;
|
||||||
|
private final Date start;
|
||||||
|
private final Date stop;
|
||||||
|
@Named("server_usages")
|
||||||
|
private final Set<SimpleServerUsage> 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() {
|
public String getTenantId() {
|
||||||
return tenantId;
|
return this.tenantId;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
public double getTotalLocalGbUsage() {
|
public double getTotalLocalGbUsage() {
|
||||||
return this.totalLocalGbUsage;
|
return this.totalLocalGbUsage;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
public double getTotalVcpusUsage() {
|
public double getTotalVcpusUsage() {
|
||||||
return this.totalVcpusUsage;
|
return this.totalVcpusUsage;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
public double getTotalMemoryMbUsage() {
|
public double getTotalMemoryMbUsage() {
|
||||||
return this.totalMemoryMbUsage;
|
return this.totalMemoryMbUsage;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
public double getTotalHours() {
|
public double getTotalHours() {
|
||||||
return this.totalHours;
|
return this.totalHours;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public Date getStart() {
|
public Date getStart() {
|
||||||
return this.start;
|
return this.start;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public Date getStop() {
|
public Date getStop() {
|
||||||
return this.stop;
|
return this.stop;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
@Nullable
|
|
||||||
public Set<SimpleServerUsage> getServerUsages() {
|
public Set<SimpleServerUsage> getServerUsages() {
|
||||||
return serverUsages == null ? ImmutableSet.<SimpleServerUsage>of() : Collections.unmodifiableSet(this.serverUsages);
|
return this.serverUsages;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
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
|
@Override
|
||||||
|
@ -215,28 +224,21 @@ public class SimpleTenantUsage {
|
||||||
if (this == obj) return true;
|
if (this == obj) return true;
|
||||||
if (obj == null || getClass() != obj.getClass()) return false;
|
if (obj == null || getClass() != obj.getClass()) return false;
|
||||||
SimpleTenantUsage that = SimpleTenantUsage.class.cast(obj);
|
SimpleTenantUsage that = SimpleTenantUsage.class.cast(obj);
|
||||||
return Objects.equal(this.totalLocalGbUsage, that.totalLocalGbUsage)
|
return Objects.equal(this.tenantId, that.tenantId)
|
||||||
&& Objects.equal(this.totalVcpusUsage, that.totalVcpusUsage)
|
&& Objects.equal(this.totalLocalGbUsage, that.totalLocalGbUsage)
|
||||||
&& Objects.equal(this.totalMemoryMbUsage, that.totalMemoryMbUsage)
|
&& Objects.equal(this.totalVcpusUsage, that.totalVcpusUsage)
|
||||||
&& Objects.equal(this.totalHours, that.totalHours)
|
&& Objects.equal(this.totalMemoryMbUsage, that.totalMemoryMbUsage)
|
||||||
&& Objects.equal(this.start, that.start)
|
&& Objects.equal(this.totalHours, that.totalHours)
|
||||||
&& Objects.equal(this.stop, that.stop)
|
&& Objects.equal(this.start, that.start)
|
||||||
&& Objects.equal(this.serverUsages, that.serverUsages)
|
&& Objects.equal(this.stop, that.stop)
|
||||||
;
|
&& Objects.equal(this.serverUsages, that.serverUsages);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ToStringHelper string() {
|
protected ToStringHelper string() {
|
||||||
return Objects.toStringHelper("")
|
return Objects.toStringHelper(this)
|
||||||
.add("totalLocalGbUsage", totalLocalGbUsage)
|
.add("tenantId", tenantId).add("totalLocalGbUsage", totalLocalGbUsage).add("totalVcpusUsage", totalVcpusUsage).add("totalMemoryMbUsage", totalMemoryMbUsage).add("totalHours", totalHours).add("start", start).add("stop", stop).add("serverUsages", serverUsages);
|
||||||
.add("totalVcpusUsage", totalVcpusUsage)
|
|
||||||
.add("totalMemoryMbUsage", totalMemoryMbUsage)
|
|
||||||
.add("totalHours", totalHours)
|
|
||||||
.add("start", start)
|
|
||||||
.add("stop", stop)
|
|
||||||
.add("serverUsages", serverUsages)
|
|
||||||
;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return string().toString();
|
return string().toString();
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/**
|
/*
|
||||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||||
* contributor license agreements. See the NOTICE file
|
* contributor license agreements. See the NOTICE file
|
||||||
* distributed with this work for additional information
|
* distributed with this work for additional information
|
||||||
|
@ -18,50 +18,88 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.openstack.nova.v2_0.domain;
|
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 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;
|
||||||
import com.google.common.base.Objects.ToStringHelper;
|
import com.google.common.base.Objects.ToStringHelper;
|
||||||
import com.google.gson.annotations.SerializedName;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Class TenantIdAndName
|
||||||
*
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
public class TenantIdAndName {
|
public class TenantIdAndName {
|
||||||
|
|
||||||
protected TenantIdAndName() {
|
public static Builder<?> builder() {
|
||||||
// we want serializers like Gson to work w/o using sun.misc.Unsafe,
|
return new ConcreteBuilder();
|
||||||
// prohibited in GAE. This also implies fields are not final.
|
}
|
||||||
// see http://code.google.com/p/jclouds/issues/detail?id=925
|
|
||||||
|
public Builder<?> toBuilder() {
|
||||||
|
return new ConcreteBuilder().fromTenantIdAndName(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SerializedName("tenant_id")
|
|
||||||
protected String tenantId;
|
|
||||||
protected String name;
|
|
||||||
|
|
||||||
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.tenantId = checkNotNull(tenantId, "tenantId");
|
||||||
this.name = checkNotNull(name, "name");
|
this.name = checkNotNull(name, "name");
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTenantId() {
|
public String getTenantId() {
|
||||||
return tenantId;
|
return this.tenantId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return this.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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -69,12 +107,23 @@ public class TenantIdAndName {
|
||||||
return Objects.hashCode(tenantId, name);
|
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
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return 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
|
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||||
* contributor license agreements. See the NOTICE file
|
* contributor license agreements. See the NOTICE file
|
||||||
* distributed with this work for additional information
|
* distributed with this work for additional information
|
||||||
|
@ -20,33 +20,36 @@ package org.jclouds.openstack.nova.v2_0.domain;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
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;
|
||||||
import com.google.common.base.Objects.ToStringHelper;
|
import com.google.common.base.Objects.ToStringHelper;
|
||||||
import com.google.gson.annotations.SerializedName;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a Virtual Interface (VIF)
|
* Represents a Virtual Interface (VIF)
|
||||||
*
|
*
|
||||||
* @author Adam Lowe
|
* @author Adam Lowe
|
||||||
* @see org.jclouds.openstack.nova.v2_0.extensions.VirtualInterfaceClient
|
* @see org.jclouds.openstack.nova.v2_0.extensions.VirtualInterfaceClient
|
||||||
*/
|
*/
|
||||||
public class VirtualInterface {
|
public class VirtualInterface {
|
||||||
|
|
||||||
public static Builder<?> builder() {
|
public static Builder<?> builder() {
|
||||||
return new ConcreteBuilder();
|
return new ConcreteBuilder();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder<?> toBuilder() {
|
public Builder<?> toBuilder() {
|
||||||
return new ConcreteBuilder().fromVirtualInterface(this);
|
return new ConcreteBuilder().fromVirtualInterface(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static abstract class Builder<T extends Builder<T>> {
|
public static abstract class Builder<T extends Builder<T>> {
|
||||||
protected abstract T self();
|
protected abstract T self();
|
||||||
|
|
||||||
private String id;
|
protected String id;
|
||||||
private String macAddress;
|
protected String macAddress;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see VirtualInterface#getId()
|
* @see VirtualInterface#getId()
|
||||||
*/
|
*/
|
||||||
public T id(String id) {
|
public T id(String id) {
|
||||||
|
@ -54,7 +57,7 @@ public class VirtualInterface {
|
||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see VirtualInterface#getMacAddress()
|
* @see VirtualInterface#getMacAddress()
|
||||||
*/
|
*/
|
||||||
public T macAddress(String macAddress) {
|
public T macAddress(String macAddress) {
|
||||||
|
@ -63,16 +66,14 @@ public class VirtualInterface {
|
||||||
}
|
}
|
||||||
|
|
||||||
public VirtualInterface build() {
|
public VirtualInterface build() {
|
||||||
return new VirtualInterface(this);
|
return new VirtualInterface(id, macAddress);
|
||||||
}
|
}
|
||||||
|
|
||||||
public T fromVirtualInterface(VirtualInterface in) {
|
public T fromVirtualInterface(VirtualInterface in) {
|
||||||
return this
|
return this
|
||||||
.id(in.getId())
|
.id(in.getId())
|
||||||
.macAddress(in.getMacAddress())
|
.macAddress(in.getMacAddress());
|
||||||
;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||||
|
@ -82,25 +83,22 @@ public class VirtualInterface {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected VirtualInterface() {
|
private final String id;
|
||||||
// we want serializers like Gson to work w/o using sun.misc.Unsafe,
|
@Named("mac_address")
|
||||||
// prohibited in GAE. This also implies fields are not final.
|
private final String macAddress;
|
||||||
// see http://code.google.com/p/jclouds/issues/detail?id=925
|
|
||||||
}
|
|
||||||
|
|
||||||
private String id;
|
|
||||||
@SerializedName(value="mac_address")
|
|
||||||
private String macAddress;
|
|
||||||
|
|
||||||
protected VirtualInterface(Builder<?> builder) {
|
@ConstructorProperties({
|
||||||
this.id = checkNotNull(builder.id, "id");
|
"id", "mac_address"
|
||||||
this.macAddress = checkNotNull(builder.macAddress, "macAddress");
|
})
|
||||||
|
protected VirtualInterface(String id, String macAddress) {
|
||||||
|
this.id = checkNotNull(id, "id");
|
||||||
|
this.macAddress = checkNotNull(macAddress, "macAddress");
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getId() {
|
public String getId() {
|
||||||
return this.id;
|
return this.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getMacAddress() {
|
public String getMacAddress() {
|
||||||
return this.macAddress;
|
return this.macAddress;
|
||||||
}
|
}
|
||||||
|
@ -116,20 +114,17 @@ public class VirtualInterface {
|
||||||
if (obj == null || getClass() != obj.getClass()) return false;
|
if (obj == null || getClass() != obj.getClass()) return false;
|
||||||
VirtualInterface that = VirtualInterface.class.cast(obj);
|
VirtualInterface that = VirtualInterface.class.cast(obj);
|
||||||
return Objects.equal(this.id, that.id)
|
return Objects.equal(this.id, that.id)
|
||||||
&& Objects.equal(this.macAddress, that.macAddress)
|
&& Objects.equal(this.macAddress, that.macAddress);
|
||||||
;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ToStringHelper string() {
|
protected ToStringHelper string() {
|
||||||
return Objects.toStringHelper("")
|
return Objects.toStringHelper(this)
|
||||||
.add("id", id)
|
.add("id", id).add("macAddress", macAddress);
|
||||||
.add("macAddress", macAddress)
|
|
||||||
;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return string().toString();
|
return string().toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/**
|
/*
|
||||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||||
* contributor license agreements. See the NOTICE file
|
* contributor license agreements. See the NOTICE file
|
||||||
* distributed with this work for additional information
|
* 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 static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.beans.ConstructorProperties;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import javax.inject.Named;
|
||||||
|
|
||||||
import org.jclouds.javax.annotation.Nullable;
|
import org.jclouds.javax.annotation.Nullable;
|
||||||
|
|
||||||
import com.google.common.base.CaseFormat;
|
import com.google.common.base.CaseFormat;
|
||||||
|
@ -32,142 +34,167 @@ import com.google.common.base.Objects;
|
||||||
import com.google.common.base.Objects.ToStringHelper;
|
import com.google.common.base.Objects.ToStringHelper;
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.common.collect.ImmutableSet;
|
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
|
* An Openstack Nova Volume
|
||||||
*/
|
*/
|
||||||
public class Volume {
|
public class Volume {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
public static enum Status {
|
public static enum Status {
|
||||||
CREATING, AVAILABLE, IN_USE, DELETING, ERROR, UNRECOGNIZED;
|
CREATING, AVAILABLE, IN_USE, DELETING, ERROR, UNRECOGNIZED;
|
||||||
public String value() {
|
public String value() {
|
||||||
return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_HYPHEN, name());
|
return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_HYPHEN, name());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return value();
|
return value();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Status fromValue(String status) {
|
public static Status fromValue(String status) {
|
||||||
try {
|
try {
|
||||||
return valueOf(CaseFormat.LOWER_HYPHEN.to(CaseFormat.UPPER_UNDERSCORE, checkNotNull(status, "status")));
|
return valueOf(CaseFormat.LOWER_HYPHEN.to(CaseFormat.UPPER_UNDERSCORE, checkNotNull(status, "status")));
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
return UNRECOGNIZED;
|
return UNRECOGNIZED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Builder<?> builder() {
|
public static Builder<?> builder() {
|
||||||
return new ConcreteBuilder();
|
return new ConcreteBuilder();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder<?> toBuilder() {
|
public Builder<?> toBuilder() {
|
||||||
return new ConcreteBuilder().fromVolume(this);
|
return new ConcreteBuilder().fromVolume(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static abstract class Builder<T extends Builder<T>> {
|
public static abstract class Builder<T extends Builder<T>> {
|
||||||
protected abstract T self();
|
protected abstract T self();
|
||||||
|
|
||||||
private String id;
|
protected String id;
|
||||||
private Status status;
|
protected Volume.Status status;
|
||||||
private int size;
|
protected int size;
|
||||||
private String zone;
|
protected String zone;
|
||||||
private Date created;
|
protected Date created;
|
||||||
private Set<VolumeAttachment> attachments = Sets.newLinkedHashSet();
|
protected Set<VolumeAttachment> attachments = ImmutableSet.of();
|
||||||
private String volumeType;
|
protected String volumeType;
|
||||||
private String snapshotId;
|
protected String snapshotId;
|
||||||
private String name;
|
protected String name;
|
||||||
private String description;
|
protected String description;
|
||||||
private Map<String, String> metadata = Maps.newHashMap();
|
protected Map<String, String> metadata = ImmutableMap.of();
|
||||||
|
|
||||||
/** @see Volume#getId() */
|
/**
|
||||||
|
* @see Volume#getId()
|
||||||
|
*/
|
||||||
public T id(String id) {
|
public T id(String id) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @see Volume#getStatus() */
|
/**
|
||||||
public T status(Status status) {
|
* @see Volume#getStatus()
|
||||||
|
*/
|
||||||
|
public T status(Volume.Status status) {
|
||||||
this.status = status;
|
this.status = status;
|
||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @see Volume#getSize() */
|
/**
|
||||||
|
* @see Volume#getSize()
|
||||||
|
*/
|
||||||
public T size(int size) {
|
public T size(int size) {
|
||||||
this.size = size;
|
this.size = size;
|
||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @see Volume#getZone() */
|
/**
|
||||||
|
* @see Volume#getZone()
|
||||||
|
*/
|
||||||
public T zone(String zone) {
|
public T zone(String zone) {
|
||||||
this.zone = zone;
|
this.zone = zone;
|
||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @see Volume#getCreated() */
|
/**
|
||||||
|
* @see Volume#getCreated()
|
||||||
|
*/
|
||||||
public T created(Date created) {
|
public T created(Date created) {
|
||||||
this.created = created;
|
this.created = created;
|
||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @see Volume#getAttachments() */
|
/**
|
||||||
|
* @see Volume#getAttachments()
|
||||||
|
*/
|
||||||
public T attachments(Set<VolumeAttachment> attachments) {
|
public T attachments(Set<VolumeAttachment> attachments) {
|
||||||
this.attachments = attachments;
|
this.attachments = ImmutableSet.copyOf(checkNotNull(attachments, "attachments"));
|
||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @see Volume#getVolumeType() */
|
public T attachments(VolumeAttachment... in) {
|
||||||
|
return attachments(ImmutableSet.copyOf(in));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see Volume#getVolumeType()
|
||||||
|
*/
|
||||||
public T volumeType(String volumeType) {
|
public T volumeType(String volumeType) {
|
||||||
this.volumeType = volumeType;
|
this.volumeType = volumeType;
|
||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @see Volume#getSnapshotId() */
|
/**
|
||||||
|
* @see Volume#getSnapshotId()
|
||||||
|
*/
|
||||||
public T snapshotId(String snapshotId) {
|
public T snapshotId(String snapshotId) {
|
||||||
this.snapshotId = snapshotId;
|
this.snapshotId = snapshotId;
|
||||||
return self();
|
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) {
|
public T name(String name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @see Volume#getDescription() */
|
/**
|
||||||
|
* @see Volume#getDescription()
|
||||||
|
*/
|
||||||
public T description(String description) {
|
public T description(String description) {
|
||||||
this.description = description;
|
this.description = description;
|
||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Volume build() {
|
/**
|
||||||
return new Volume(this);
|
* @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(id, status, size, zone, created, attachments, volumeType, snapshotId, name, description, metadata);
|
||||||
|
}
|
||||||
|
|
||||||
public T fromVolume(Volume in) {
|
public T fromVolume(Volume in) {
|
||||||
return this
|
return this
|
||||||
.id(in.getId())
|
.id(in.getId())
|
||||||
.status(in.getStatus())
|
.status(in.getStatus())
|
||||||
.size(in.getSize())
|
.size(in.getSize())
|
||||||
.zone(in.getZone())
|
.zone(in.getZone())
|
||||||
.created(in.getCreated())
|
.created(in.getCreated())
|
||||||
.attachments(in.getAttachments())
|
.attachments(in.getAttachments())
|
||||||
.volumeType(in.getVolumeType())
|
.volumeType(in.getVolumeType())
|
||||||
.snapshotId(in.getSnapshotId())
|
.snapshotId(in.getSnapshotId())
|
||||||
.metadata(in.getMetadata())
|
.name(in.getName())
|
||||||
;
|
.description(in.getDescription())
|
||||||
|
.metadata(in.getMetadata());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||||
|
@ -177,40 +204,37 @@ public class Volume {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Volume() {
|
private final String id;
|
||||||
// we want serializers like Gson to work w/o using sun.misc.Unsafe,
|
private final Volume.Status status;
|
||||||
// prohibited in GAE. This also implies fields are not final.
|
private final int size;
|
||||||
// see http://code.google.com/p/jclouds/issues/detail?id=925
|
@Named("availabilityZone")
|
||||||
}
|
private final String zone;
|
||||||
|
@Named("createdAt")
|
||||||
private String id;
|
private final Date created;
|
||||||
private Status status;
|
private final Set<VolumeAttachment> attachments;
|
||||||
private int size;
|
private final String volumeType;
|
||||||
@SerializedName(value="availabilityZone")
|
private final String snapshotId;
|
||||||
private String zone;
|
@Named("displayName")
|
||||||
@SerializedName(value="createdAt")
|
private final String name;
|
||||||
private Date created;
|
@Named("displayDescription")
|
||||||
private Set<VolumeAttachment> attachments = ImmutableSet.of();
|
private final String description;
|
||||||
private String volumeType;
|
private final Map<String, String> metadata;
|
||||||
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) {
|
@ConstructorProperties({
|
||||||
this.id = builder.id;
|
"id", "status", "size", "availabilityZone", "createdAt", "attachments", "volumeType", "snapshotId", "displayName", "displayDescription", "metadata"
|
||||||
this.status = builder.status;
|
})
|
||||||
this.size = builder.size;
|
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.zone = builder.zone;
|
this.id = checkNotNull(id, "id");
|
||||||
this.created = builder.created;
|
this.status = checkNotNull(status, "status");
|
||||||
this.attachments = ImmutableSet.copyOf(checkNotNull(builder.attachments, "attachments"));
|
this.size = size;
|
||||||
this.volumeType = builder.volumeType;
|
this.zone = checkNotNull(zone, "zone");
|
||||||
this.snapshotId = builder.snapshotId;
|
this.created = checkNotNull(created, "created");
|
||||||
this.name = builder.name;
|
this.attachments = attachments == null ? ImmutableSet.<VolumeAttachment>of() : ImmutableSet.copyOf(attachments);
|
||||||
this.description = builder.description;
|
this.volumeType = volumeType;
|
||||||
this.metadata = ImmutableMap.copyOf(checkNotNull(builder.metadata, "metadata"));
|
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
|
* @return the status of this volume
|
||||||
*/
|
*/
|
||||||
public Status getStatus() {
|
public Volume.Status getStatus() {
|
||||||
return this.status;
|
return this.status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -251,9 +275,8 @@ public class Volume {
|
||||||
/**
|
/**
|
||||||
* @return the set of attachments (to Servers)
|
* @return the set of attachments (to Servers)
|
||||||
*/
|
*/
|
||||||
@Nullable
|
|
||||||
public Set<VolumeAttachment> getAttachments() {
|
public Set<VolumeAttachment> getAttachments() {
|
||||||
return Collections.unmodifiableSet(this.attachments);
|
return this.attachments;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -284,47 +307,42 @@ public class Volume {
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
return this.description;
|
return this.description;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
|
||||||
public Map<String, String> getMetadata() {
|
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
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return Objects.hashCode(id, zone);
|
return Objects.hashCode(id, status, size, zone, created, attachments, volumeType, snapshotId, name, description, metadata);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object obj) {
|
||||||
if (this == obj)
|
if (this == obj) return true;
|
||||||
return true;
|
if (obj == null || getClass() != obj.getClass()) return false;
|
||||||
if (obj == null || getClass() != obj.getClass())
|
|
||||||
return false;
|
|
||||||
Volume that = Volume.class.cast(obj);
|
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() {
|
protected ToStringHelper string() {
|
||||||
return Objects.toStringHelper("")
|
return Objects.toStringHelper(this)
|
||||||
.add("id", id)
|
.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);
|
||||||
.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
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return string().toString();
|
return string().toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/**
|
/*
|
||||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||||
* contributor license agreements. See the NOTICE file
|
* contributor license agreements. See the NOTICE file
|
||||||
* distributed with this work for additional information
|
* 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 static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
|
import java.beans.ConstructorProperties;
|
||||||
|
|
||||||
import org.jclouds.javax.annotation.Nullable;
|
import org.jclouds.javax.annotation.Nullable;
|
||||||
|
|
||||||
import com.google.common.base.Objects;
|
import com.google.common.base.Objects;
|
||||||
|
@ -27,62 +29,68 @@ import com.google.common.base.Objects.ToStringHelper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An Openstack Nova Volume Attachment (describes how Volumes are attached to Servers)
|
* An Openstack Nova Volume Attachment (describes how Volumes are attached to Servers)
|
||||||
*/
|
*/
|
||||||
public class VolumeAttachment {
|
public class VolumeAttachment {
|
||||||
|
|
||||||
public static Builder<?> builder() {
|
public static Builder<?> builder() {
|
||||||
return new ConcreteBuilder();
|
return new ConcreteBuilder();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder<?> toBuilder() {
|
public Builder<?> toBuilder() {
|
||||||
return new ConcreteBuilder().fromAttachment(this);
|
return new ConcreteBuilder().fromVolumeAttachment(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static abstract class Builder<T extends Builder<T>> {
|
public static abstract class Builder<T extends Builder<T>> {
|
||||||
protected abstract T self();
|
protected abstract T self();
|
||||||
|
|
||||||
private String id;
|
protected String id;
|
||||||
private String volumeId;
|
protected String volumeId;
|
||||||
private String serverId;
|
protected String serverId;
|
||||||
private String device;
|
protected String device;
|
||||||
|
|
||||||
/** @see VolumeAttachment#getId() */
|
/**
|
||||||
|
* @see VolumeAttachment#getId()
|
||||||
|
*/
|
||||||
public T id(String id) {
|
public T id(String id) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @see VolumeAttachment#getVolumeId() */
|
/**
|
||||||
|
* @see VolumeAttachment#getVolumeId()
|
||||||
|
*/
|
||||||
public T volumeId(String volumeId) {
|
public T volumeId(String volumeId) {
|
||||||
this.volumeId = volumeId;
|
this.volumeId = volumeId;
|
||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @see VolumeAttachment#getServerId() */
|
/**
|
||||||
|
* @see VolumeAttachment#getServerId()
|
||||||
|
*/
|
||||||
public T serverId(String serverId) {
|
public T serverId(String serverId) {
|
||||||
this.serverId = serverId;
|
this.serverId = serverId;
|
||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @see VolumeAttachment#getDevice() */
|
/**
|
||||||
|
* @see VolumeAttachment#getDevice()
|
||||||
|
*/
|
||||||
public T device(String device) {
|
public T device(String device) {
|
||||||
this.device = device;
|
this.device = device;
|
||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
public VolumeAttachment build() {
|
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
|
return this
|
||||||
.id(in.getId())
|
.id(in.getId())
|
||||||
.volumeId(in.getVolumeId())
|
.volumeId(in.getVolumeId())
|
||||||
.serverId(in.getServerId())
|
.serverId(in.getServerId())
|
||||||
.device(in.getDevice())
|
.device(in.getDevice());
|
||||||
;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||||
|
@ -92,22 +100,19 @@ public class VolumeAttachment {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected VolumeAttachment() {
|
private final String id;
|
||||||
// we want serializers like Gson to work w/o using sun.misc.Unsafe,
|
private final String volumeId;
|
||||||
// prohibited in GAE. This also implies fields are not final.
|
private final String serverId;
|
||||||
// see http://code.google.com/p/jclouds/issues/detail?id=925
|
private final String device;
|
||||||
}
|
|
||||||
|
|
||||||
private String id;
|
|
||||||
private String volumeId;
|
|
||||||
private String serverId;
|
|
||||||
private String device;
|
|
||||||
|
|
||||||
protected VolumeAttachment(Builder<?> builder) {
|
@ConstructorProperties({
|
||||||
this.id = checkNotNull(builder.id, "id");
|
"id", "volumeId", "serverId", "device"
|
||||||
this.volumeId = checkNotNull(builder.volumeId, "volumeId");
|
})
|
||||||
this.serverId = builder.serverId;
|
protected VolumeAttachment(String id, String volumeId, @Nullable String serverId, @Nullable String device) {
|
||||||
this.device = builder.device;
|
this.id = checkNotNull(id, "id");
|
||||||
|
this.volumeId = checkNotNull(volumeId, "volumeId");
|
||||||
|
this.serverId = serverId;
|
||||||
|
this.device = device;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -151,24 +156,19 @@ public class VolumeAttachment {
|
||||||
if (obj == null || getClass() != obj.getClass()) return false;
|
if (obj == null || getClass() != obj.getClass()) return false;
|
||||||
VolumeAttachment that = VolumeAttachment.class.cast(obj);
|
VolumeAttachment that = VolumeAttachment.class.cast(obj);
|
||||||
return Objects.equal(this.id, that.id)
|
return Objects.equal(this.id, that.id)
|
||||||
&& Objects.equal(this.volumeId, that.volumeId)
|
&& Objects.equal(this.volumeId, that.volumeId)
|
||||||
&& Objects.equal(this.serverId, that.serverId)
|
&& Objects.equal(this.serverId, that.serverId)
|
||||||
&& Objects.equal(this.device, that.device)
|
&& Objects.equal(this.device, that.device);
|
||||||
;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ToStringHelper string() {
|
protected ToStringHelper string() {
|
||||||
return Objects.toStringHelper("")
|
return Objects.toStringHelper(this)
|
||||||
.add("id", id)
|
.add("id", id).add("volumeId", volumeId).add("serverId", serverId).add("device", device);
|
||||||
.add("volumeId", volumeId)
|
|
||||||
.add("serverId", serverId)
|
|
||||||
.add("device", device)
|
|
||||||
;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return string().toString();
|
return string().toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/**
|
/*
|
||||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||||
* contributor license agreements. See the NOTICE file
|
* contributor license agreements. See the NOTICE file
|
||||||
* distributed with this work for additional information
|
* distributed with this work for additional information
|
||||||
|
@ -20,96 +20,110 @@ package org.jclouds.openstack.nova.v2_0.domain;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
|
import java.beans.ConstructorProperties;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
|
import javax.inject.Named;
|
||||||
|
|
||||||
import org.jclouds.javax.annotation.Nullable;
|
import org.jclouds.javax.annotation.Nullable;
|
||||||
|
|
||||||
import com.google.common.base.Objects;
|
import com.google.common.base.Objects;
|
||||||
import com.google.common.base.Objects.ToStringHelper;
|
import com.google.common.base.Objects.ToStringHelper;
|
||||||
import com.google.gson.annotations.SerializedName;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An Openstack Nova Volume Snapshot
|
* An Openstack Nova Volume Snapshot
|
||||||
*/
|
*/
|
||||||
public class VolumeSnapshot {
|
public class VolumeSnapshot {
|
||||||
|
|
||||||
public static Builder<?> builder() {
|
public static Builder<?> builder() {
|
||||||
return new ConcreteBuilder();
|
return new ConcreteBuilder();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder<?> toBuilder() {
|
public Builder<?> toBuilder() {
|
||||||
return new ConcreteBuilder().fromSnapshot(this);
|
return new ConcreteBuilder().fromVolumeSnapshot(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static abstract class Builder<T extends Builder<T>> {
|
public static abstract class Builder<T extends Builder<T>> {
|
||||||
protected abstract T self();
|
protected abstract T self();
|
||||||
|
|
||||||
private String id;
|
protected String id;
|
||||||
private String volumeId;
|
protected String volumeId;
|
||||||
private Volume.Status status;
|
protected Volume.Status status;
|
||||||
private int size;
|
protected int size;
|
||||||
private Date created;
|
protected Date created;
|
||||||
private String name;
|
protected String name;
|
||||||
private String description;
|
protected String description;
|
||||||
|
|
||||||
/** @see VolumeSnapshot#getId() */
|
/**
|
||||||
|
* @see VolumeSnapshot#getId()
|
||||||
|
*/
|
||||||
public T id(String id) {
|
public T id(String id) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @see VolumeSnapshot#getVolumeId() */
|
/**
|
||||||
|
* @see VolumeSnapshot#getVolumeId()
|
||||||
|
*/
|
||||||
public T volumeId(String volumeId) {
|
public T volumeId(String volumeId) {
|
||||||
this.volumeId = volumeId;
|
this.volumeId = volumeId;
|
||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @see VolumeSnapshot#getStatus() */
|
/**
|
||||||
|
* @see VolumeSnapshot#getStatus()
|
||||||
|
*/
|
||||||
public T status(Volume.Status status) {
|
public T status(Volume.Status status) {
|
||||||
this.status = status;
|
this.status = status;
|
||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @see VolumeSnapshot#getSize() */
|
/**
|
||||||
|
* @see VolumeSnapshot#getSize()
|
||||||
|
*/
|
||||||
public T size(int size) {
|
public T size(int size) {
|
||||||
this.size = size;
|
this.size = size;
|
||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @see VolumeSnapshot#getCreated() */
|
/**
|
||||||
|
* @see VolumeSnapshot#getCreated()
|
||||||
|
*/
|
||||||
public T created(Date created) {
|
public T created(Date created) {
|
||||||
this.created = created;
|
this.created = created;
|
||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @see VolumeSnapshot#getName() */
|
/**
|
||||||
|
* @see VolumeSnapshot#getName()
|
||||||
|
*/
|
||||||
public T name(String name) {
|
public T name(String name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @see VolumeSnapshot#getDescription() */
|
/**
|
||||||
|
* @see VolumeSnapshot#getDescription()
|
||||||
|
*/
|
||||||
public T description(String description) {
|
public T description(String description) {
|
||||||
this.description = description;
|
this.description = description;
|
||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
public VolumeSnapshot build() {
|
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
|
return this
|
||||||
.id(in.getId())
|
.id(in.getId())
|
||||||
.volumeId(in.getVolumeId())
|
.volumeId(in.getVolumeId())
|
||||||
.status(in.getStatus())
|
.status(in.getStatus())
|
||||||
.size(in.getSize())
|
.size(in.getSize())
|
||||||
.created(in.getCreated())
|
.created(in.getCreated())
|
||||||
.name(in.getName())
|
.name(in.getName())
|
||||||
.description(in.getDescription())
|
.description(in.getDescription());
|
||||||
;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||||
|
@ -119,31 +133,28 @@ public class VolumeSnapshot {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected VolumeSnapshot() {
|
private final String id;
|
||||||
// we want serializers like Gson to work w/o using sun.misc.Unsafe,
|
private final String volumeId;
|
||||||
// prohibited in GAE. This also implies fields are not final.
|
private final Volume.Status status;
|
||||||
// see http://code.google.com/p/jclouds/issues/detail?id=925
|
private final int size;
|
||||||
}
|
@Named("createdAt")
|
||||||
|
private final Date created;
|
||||||
private String id;
|
@Named("displayName")
|
||||||
private String volumeId;
|
private final String name;
|
||||||
private Volume.Status status;
|
@Named("displayDescription")
|
||||||
private int size;
|
private final String description;
|
||||||
@SerializedName(value="createdAt")
|
|
||||||
private Date created;
|
|
||||||
@SerializedName(value="displayName")
|
|
||||||
private String name;
|
|
||||||
@SerializedName(value="displayDescription")
|
|
||||||
private String description;
|
|
||||||
|
|
||||||
protected VolumeSnapshot(Builder<?> builder) {
|
@ConstructorProperties({
|
||||||
this.id = checkNotNull(builder.id, "id");
|
"id", "volumeId", "status", "size", "createdAt", "displayName", "displayDescription"
|
||||||
this.volumeId = checkNotNull(builder.volumeId, "volumeId");
|
})
|
||||||
this.status = checkNotNull(builder.status, "status");
|
protected VolumeSnapshot(String id, String volumeId, Volume.Status status, int size, @Nullable Date created, @Nullable String name, @Nullable String description) {
|
||||||
this.size = builder.size;
|
this.id = checkNotNull(id, "id");
|
||||||
this.created = builder.created;
|
this.volumeId = checkNotNull(volumeId, "volumeId");
|
||||||
this.name = builder.name;
|
this.status = checkNotNull(status, "status");
|
||||||
this.description = builder.description;
|
this.size = size;
|
||||||
|
this.created = created;
|
||||||
|
this.name = name;
|
||||||
|
this.description = description;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -190,7 +201,6 @@ public class VolumeSnapshot {
|
||||||
return this.name;
|
return this.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the description of this snapshot - as displayed in the openstack console
|
* @return the description of this snapshot - as displayed in the openstack console
|
||||||
*/
|
*/
|
||||||
|
@ -210,30 +220,22 @@ public class VolumeSnapshot {
|
||||||
if (obj == null || getClass() != obj.getClass()) return false;
|
if (obj == null || getClass() != obj.getClass()) return false;
|
||||||
VolumeSnapshot that = VolumeSnapshot.class.cast(obj);
|
VolumeSnapshot that = VolumeSnapshot.class.cast(obj);
|
||||||
return Objects.equal(this.id, that.id)
|
return Objects.equal(this.id, that.id)
|
||||||
&& Objects.equal(this.volumeId, that.volumeId)
|
&& Objects.equal(this.volumeId, that.volumeId)
|
||||||
&& Objects.equal(this.status, that.status)
|
&& Objects.equal(this.status, that.status)
|
||||||
&& Objects.equal(this.size, that.size)
|
&& Objects.equal(this.size, that.size)
|
||||||
&& Objects.equal(this.created, that.created)
|
&& Objects.equal(this.created, that.created)
|
||||||
&& Objects.equal(this.name, that.name)
|
&& Objects.equal(this.name, that.name)
|
||||||
&& Objects.equal(this.description, that.description)
|
&& Objects.equal(this.description, that.description);
|
||||||
;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ToStringHelper string() {
|
protected ToStringHelper string() {
|
||||||
return Objects.toStringHelper("")
|
return Objects.toStringHelper(this)
|
||||||
.add("id", id)
|
.add("id", id).add("volumeId", volumeId).add("status", status).add("size", size).add("created", created).add("name", name).add("description", description);
|
||||||
.add("volumeId", volumeId)
|
|
||||||
.add("status", status)
|
|
||||||
.add("size", size)
|
|
||||||
.add("created", created)
|
|
||||||
.add("name", name)
|
|
||||||
.add("description", description)
|
|
||||||
;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return string().toString();
|
return string().toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/**
|
/*
|
||||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||||
* contributor license agreements. See the NOTICE file
|
* contributor license agreements. See the NOTICE file
|
||||||
* distributed with this work for additional information
|
* distributed with this work for additional information
|
||||||
|
@ -20,41 +20,44 @@ package org.jclouds.openstack.nova.v2_0.domain;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.beans.ConstructorProperties;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Map;
|
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.Objects;
|
||||||
import com.google.common.base.Optional;
|
|
||||||
import com.google.common.base.Objects.ToStringHelper;
|
import com.google.common.base.Objects.ToStringHelper;
|
||||||
|
import com.google.common.base.Optional;
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.gson.annotations.SerializedName;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Volume Type used in the Volume Type Extension for Nova
|
* Volume Type used in the Volume Type Extension for Nova
|
||||||
*
|
*
|
||||||
* @see org.jclouds.openstack.nova.v2_0.extensions.VolumeTypeClient
|
* @see org.jclouds.openstack.nova.v2_0.extensions.VolumeTypeClient
|
||||||
*/
|
*/
|
||||||
public class VolumeType {
|
public class VolumeType {
|
||||||
|
|
||||||
public static Builder<?> builder() {
|
public static Builder<?> builder() {
|
||||||
return new ConcreteBuilder();
|
return new ConcreteBuilder();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder<?> toBuilder() {
|
public Builder<?> toBuilder() {
|
||||||
return new ConcreteBuilder().fromVolumeType(this);
|
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();
|
protected abstract T self();
|
||||||
|
|
||||||
private String id;
|
protected String id;
|
||||||
private String name;
|
protected String name;
|
||||||
private Date created = new Date();
|
protected Date created;
|
||||||
private Date updated;
|
protected Date updated;
|
||||||
private Map<String, String> extraSpecs;
|
protected Map<String, String> extraSpecs = ImmutableMap.of();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see VolumeType#getId()
|
* @see VolumeType#getId()
|
||||||
*/
|
*/
|
||||||
public T id(String id) {
|
public T id(String id) {
|
||||||
|
@ -62,7 +65,7 @@ public class VolumeType {
|
||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see VolumeType#getName()
|
* @see VolumeType#getName()
|
||||||
*/
|
*/
|
||||||
public T name(String name) {
|
public T name(String name) {
|
||||||
|
@ -70,7 +73,7 @@ public class VolumeType {
|
||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see VolumeType#getCreated()
|
* @see VolumeType#getCreated()
|
||||||
*/
|
*/
|
||||||
public T created(Date created) {
|
public T created(Date created) {
|
||||||
|
@ -78,7 +81,7 @@ public class VolumeType {
|
||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see VolumeType#getUpdated()
|
* @see VolumeType#getUpdated()
|
||||||
*/
|
*/
|
||||||
public T updated(Date updated) {
|
public T updated(Date updated) {
|
||||||
|
@ -86,27 +89,26 @@ public class VolumeType {
|
||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see VolumeType#getExtraSpecs()
|
* @see VolumeType#getExtraSpecs()
|
||||||
*/
|
*/
|
||||||
public T extraSpecs(Map<String, String> extraSpecs) {
|
public T extraSpecs(Map<String, String> extraSpecs) {
|
||||||
this.extraSpecs = ImmutableMap.copyOf(extraSpecs);
|
this.extraSpecs = ImmutableMap.copyOf(checkNotNull(extraSpecs, "extraSpecs"));
|
||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
public VolumeType build() {
|
public VolumeType build() {
|
||||||
return new VolumeType(this);
|
return new VolumeType(id, name, created, updated, extraSpecs);
|
||||||
}
|
}
|
||||||
|
|
||||||
public T fromVolumeType(VolumeType in) {
|
public T fromVolumeType(VolumeType in) {
|
||||||
return this
|
return this
|
||||||
.id(in.getId())
|
.id(in.getId())
|
||||||
.name(in.getName())
|
.name(in.getName())
|
||||||
.extraSpecs(in.getExtraSpecs())
|
.created(in.getCreated())
|
||||||
.created(in.getCreated())
|
.updated(in.getUpdated().orNull())
|
||||||
.updated(in.getUpdated().orNull());
|
.extraSpecs(in.getExtraSpecs());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||||
|
@ -116,27 +118,24 @@ public class VolumeType {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected VolumeType() {
|
private final String id;
|
||||||
// we want serializers like Gson to work w/o using sun.misc.Unsafe,
|
private final String name;
|
||||||
// prohibited in GAE. This also implies fields are not final.
|
@Named("created_at")
|
||||||
// see http://code.google.com/p/jclouds/issues/detail?id=925
|
private final Date created;
|
||||||
}
|
@Named("updated_at")
|
||||||
|
private final Optional<Date> updated;
|
||||||
private String id;
|
@Named("extra_specs")
|
||||||
private String name;
|
private final Map<String, String> extraSpecs;
|
||||||
@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) {
|
@ConstructorProperties({
|
||||||
this.id = checkNotNull(builder.id, "id");
|
"id", "name", "created_at", "updated_at", "extra_specs"
|
||||||
this.name = checkNotNull(builder.name, "name");
|
})
|
||||||
this.extraSpecs = checkNotNull(builder.extraSpecs, "extraSpecs");
|
protected VolumeType(String id, String name, Date created, @Nullable Date updated, Map<String, String> extraSpecs) {
|
||||||
this.created = checkNotNull(builder.created, "created");
|
this.id = checkNotNull(id, "id");
|
||||||
this.updated = Optional.fromNullable(builder.updated);
|
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() {
|
public String getId() {
|
||||||
|
@ -147,18 +146,22 @@ public class VolumeType {
|
||||||
return this.name;
|
return this.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** The Date the VolumeType was created */
|
/**
|
||||||
|
* The Date the VolumeType was created
|
||||||
|
*/
|
||||||
public Date getCreated() {
|
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() {
|
public Optional<Date> getUpdated() {
|
||||||
return updated;
|
return this.updated;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, String> getExtraSpecs() {
|
public Map<String, String> getExtraSpecs() {
|
||||||
return Collections.unmodifiableMap(this.extraSpecs);
|
return this.extraSpecs;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -172,24 +175,20 @@ public class VolumeType {
|
||||||
if (obj == null || getClass() != obj.getClass()) return false;
|
if (obj == null || getClass() != obj.getClass()) return false;
|
||||||
VolumeType that = VolumeType.class.cast(obj);
|
VolumeType that = VolumeType.class.cast(obj);
|
||||||
return Objects.equal(this.id, that.id)
|
return Objects.equal(this.id, that.id)
|
||||||
&& Objects.equal(this.name, that.name)
|
&& Objects.equal(this.name, that.name)
|
||||||
&& Objects.equal(this.created, that.created)
|
&& Objects.equal(this.created, that.created)
|
||||||
&& Objects.equal(this.updated, that.updated)
|
&& Objects.equal(this.updated, that.updated)
|
||||||
&& Objects.equal(this.extraSpecs, that.extraSpecs);
|
&& Objects.equal(this.extraSpecs, that.extraSpecs);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ToStringHelper string() {
|
protected ToStringHelper string() {
|
||||||
return Objects.toStringHelper("")
|
return Objects.toStringHelper(this)
|
||||||
.add("id", id)
|
.add("id", id).add("name", name).add("created", created).add("updated", updated).add("extraSpecs", extraSpecs);
|
||||||
.add("name", name)
|
|
||||||
.add("created", created)
|
|
||||||
.add("updated", updated)
|
|
||||||
.add("extraSpecs", extraSpecs);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return string().toString();
|
return string().toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,6 @@ import javax.inject.Inject;
|
||||||
import org.jclouds.encryption.internal.Base64;
|
import org.jclouds.encryption.internal.Base64;
|
||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.openstack.nova.v2_0.NovaClient;
|
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.MapBinder;
|
||||||
import org.jclouds.rest.binders.BindToJsonPayload;
|
import org.jclouds.rest.binders.BindToJsonPayload;
|
||||||
import org.jclouds.util.Preconditions2;
|
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;
|
||||||
import com.google.common.base.Objects.ToStringHelper;
|
import com.google.common.base.Objects.ToStringHelper;
|
||||||
import com.google.common.base.Optional;
|
import com.google.common.base.Optional;
|
||||||
|
import com.google.common.collect.ForwardingObject;
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
|
@ -162,7 +162,7 @@ public class CreateServerOptions implements MapBinder {
|
||||||
List<File> personality;
|
List<File> personality;
|
||||||
String key_name;
|
String key_name;
|
||||||
@SerializedName(value = "security_groups")
|
@SerializedName(value = "security_groups")
|
||||||
Set<SecurityGroup> securityGroupNames;
|
Set<NamedThingy> securityGroupNames;
|
||||||
String user_data;
|
String user_data;
|
||||||
|
|
||||||
private ServerRequest(String name, String imageRef, String flavorRef) {
|
private ServerRequest(String name, String imageRef, String flavorRef) {
|
||||||
|
@ -187,10 +187,9 @@ public class CreateServerOptions implements MapBinder {
|
||||||
if (userData != null)
|
if (userData != null)
|
||||||
server.user_data = Base64.encodeBytes(userData);
|
server.user_data = Base64.encodeBytes(userData);
|
||||||
if (securityGroupNames.size() > 0) {
|
if (securityGroupNames.size() > 0) {
|
||||||
server.securityGroupNames = Sets.newHashSet();
|
server.securityGroupNames = Sets.newLinkedHashSet();
|
||||||
for (String groupName : securityGroupNames) {
|
for (String groupName : securityGroupNames) {
|
||||||
SecurityGroup group = SecurityGroup.builder().name(groupName).build();
|
server.securityGroupNames.add(new NamedThingy(groupName));
|
||||||
server.securityGroupNames.add(group);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (adminPass != null) {
|
if (adminPass != null) {
|
||||||
|
@ -200,6 +199,20 @@ public class CreateServerOptions implements MapBinder {
|
||||||
return bindToRequest(request, ImmutableMap.of("server", server));
|
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
|
* 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
|
* 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")
|
ImmutableMultimap.<String, String> builder().put("Accept", "application/json")
|
||||||
.put("X-Auth-Token", authToken).build())
|
.put("X-Auth-Token", authToken).build())
|
||||||
.payload(payloadFromStringWithContentType(
|
.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();
|
.build();
|
||||||
|
|
||||||
HttpResponse createServerResponse = HttpResponse.builder().statusCode(202).message("HTTP/1.1 202 Accepted")
|
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");
|
SimpleTenantUsage usage = client.getTenantUsage("test-1234");
|
||||||
assertEquals(usage.getTenantId(), "f8535069c3fb404cb61c873b1a0b4921");
|
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"))
|
.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(
|
.totalMemoryMbUsage(0.0014847999999999999).totalVcpusUsage(7.249999999999999E-07).serverUsages(
|
||||||
ImmutableSet.of(
|
ImmutableSet.of(
|
||||||
|
|
|
@ -115,7 +115,7 @@ public class ServerClientExpectTest extends BaseNovaClientExpectTest {
|
||||||
ImmutableMultimap.<String, String> builder().put("Accept", "application/json")
|
ImmutableMultimap.<String, String> builder().put("Accept", "application/json")
|
||||||
.put("X-Auth-Token", authToken).build())
|
.put("X-Auth-Token", authToken).build())
|
||||||
.payload(payloadFromStringWithContentType(
|
.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();
|
.build();
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -54,17 +54,17 @@ public class ParseComputeServiceTypicalSecurityGroupTest extends BaseItemParserT
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
public SecurityGroup expected() {
|
public SecurityGroup expected() {
|
||||||
|
|
||||||
Set<SecurityGroupRule> securityGroupRules = ImmutableSet.<SecurityGroupRule> of(
|
Set<SecurityGroupRule> securityGroupRules = ImmutableSet.of(
|
||||||
SecurityGroupRule.builder().fromPort(22)
|
SecurityGroupRule.builder().fromPort(22)
|
||||||
.ipProtocol(IpProtocol.TCP).toPort(22).parentGroupId("2769")
|
.ipProtocol(IpProtocol.TCP).toPort(22).parentGroupId("2769")
|
||||||
.ipRange("0.0.0.0/0").id("10331").build(),
|
.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")
|
.ipProtocol(IpProtocol.TCP).toPort(22).parentGroupId("2769")
|
||||||
.id("10332").build(),
|
.id("10332").build(),
|
||||||
SecurityGroupRule.builder().fromPort(8080)
|
SecurityGroupRule.builder().fromPort(8080)
|
||||||
.ipProtocol(IpProtocol.TCP).toPort(8080).parentGroupId("2769")
|
.ipProtocol(IpProtocol.TCP).toPort(8080).parentGroupId("2769")
|
||||||
.ipRange("0.0.0.0/0").id("10333").build(),
|
.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")
|
.ipProtocol(IpProtocol.TCP).toPort(8080).parentGroupId("2769")
|
||||||
.id("10334").build()
|
.id("10334").build()
|
||||||
);
|
);
|
||||||
|
|
|
@ -57,7 +57,7 @@ public class ParseSecurityGroupTest extends BaseItemParserTest<SecurityGroup> {
|
||||||
SecurityGroupRule.builder().fromPort(22)
|
SecurityGroupRule.builder().fromPort(22)
|
||||||
.ipProtocol(IpProtocol.TCP).toPort(22).parentGroupId("28")
|
.ipProtocol(IpProtocol.TCP).toPort(22).parentGroupId("28")
|
||||||
.ipRange("10.2.6.0/24").id("108").build(),
|
.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")
|
.ipProtocol(IpProtocol.TCP).toPort(22).parentGroupId("28")
|
||||||
.id("109").build());
|
.id("109").build());
|
||||||
|
|
||||||
|
|
|
@ -95,7 +95,7 @@ public class ParseServerWithAllExtensionsTest extends BaseItemParserTest<Server>
|
||||||
.addresses(ImmutableMultimap.of("private", Address.createV4("10.0.0.8")))
|
.addresses(ImmutableMultimap.of("private", Address.createV4("10.0.0.8")))
|
||||||
.diskConfig("MANUAL")
|
.diskConfig("MANUAL")
|
||||||
.extendedStatus(ServerExtendedStatus.builder().vmState("paused").powerState(3).build())
|
.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();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@ import org.testng.annotations.Test;
|
||||||
*/
|
*/
|
||||||
@Test(groups = "unit", testName = "SecurityGroupPredicatesTest")
|
@Test(groups = "unit", testName = "SecurityGroupPredicatesTest")
|
||||||
public class 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
|
@Test
|
||||||
public void testnameEqualsWhenEqual() {
|
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.Objects.toStringHelper;
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
|
import java.beans.ConstructorProperties;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
|
||||||
|
import javax.inject.Named;
|
||||||
|
|
||||||
import org.jclouds.javax.annotation.Nullable;
|
import org.jclouds.javax.annotation.Nullable;
|
||||||
|
|
||||||
import com.google.common.base.Objects;
|
import com.google.common.base.Objects;
|
||||||
|
@ -134,17 +137,12 @@ public class Link {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Link() {
|
@Named("rel")
|
||||||
// we want serializers like Gson to work w/o using sun.misc.Unsafe,
|
|
||||||
// prohibited in GAE. This also implies fields are not final.
|
|
||||||
// see http://code.google.com/p/jclouds/issues/detail?id=925
|
|
||||||
}
|
|
||||||
|
|
||||||
@SerializedName("rel")
|
|
||||||
protected Relation relation;
|
protected Relation relation;
|
||||||
protected String type;
|
protected String type;
|
||||||
protected URI href;
|
protected URI href;
|
||||||
|
|
||||||
|
@ConstructorProperties({"rel", "type", "href"})
|
||||||
protected Link(Relation relation, @Nullable String type, URI href) {
|
protected Link(Relation relation, @Nullable String type, URI href) {
|
||||||
this.relation = checkNotNull(relation, "relation");
|
this.relation = checkNotNull(relation, "relation");
|
||||||
this.type = type;
|
this.type = type;
|
||||||
|
|
|
@ -94,8 +94,7 @@ public class Resource implements Comparable<Resource> {
|
||||||
return this
|
return this
|
||||||
.id(in.getId())
|
.id(in.getId())
|
||||||
.name(in.getName())
|
.name(in.getName())
|
||||||
.links(in.getLinks())
|
.links(in.getLinks());
|
||||||
;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,17 +104,18 @@ public class Resource implements Comparable<Resource> {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Resource() {
|
|
||||||
// we want serializers like Gson to work w/o using sun.misc.Unsafe,
|
|
||||||
// prohibited in GAE. This also implies fields are not final.
|
|
||||||
// see http://code.google.com/p/jclouds/issues/detail?id=925
|
|
||||||
}
|
|
||||||
|
|
||||||
private String id;
|
private String id;
|
||||||
private String name;
|
private String name;
|
||||||
private Set<Link> links = ImmutableSet.of();
|
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) {
|
protected Resource(Builder<?> builder) {
|
||||||
this.id = checkNotNull(builder.id, "id");
|
this.id = checkNotNull(builder.id, "id");
|
||||||
this.name = builder.name;
|
this.name = builder.name;
|
||||||
|
|
Loading…
Reference in New Issue