Support LBaaS v1
Project: http://git-wip-us.apache.org/repos/asf/jclouds/repo Commit: http://git-wip-us.apache.org/repos/asf/jclouds/commit/0c82ed9f Tree: http://git-wip-us.apache.org/repos/asf/jclouds/tree/0c82ed9f Diff: http://git-wip-us.apache.org/repos/asf/jclouds/diff/0c82ed9f Branch: refs/heads/master Commit: 0c82ed9fe14463bb5f5455da9ce0097cab94d3ba Parents: 5827b72 Author: fbrouille <[email protected]> Authored: Wed Oct 1 11:34:03 2014 +0200 Committer: Zack Shoylev <[email protected]> Committed: Thu Oct 2 15:03:17 2014 -0500 ---------------------------------------------------------------------- .../openstack/neutron/v2/NeutronApi.java | 12 +- .../neutron/v2/config/NeutronHttpApiModule.java | 2 + .../v2/domain/lbaas/v1/HealthMonitor.java | 451 +++++ .../v2/domain/lbaas/v1/HealthMonitorStatus.java | 101 + .../v2/domain/lbaas/v1/HealthMonitors.java | 37 + .../neutron/v2/domain/lbaas/v1/HttpMethod.java | 75 + .../neutron/v2/domain/lbaas/v1/LBaaSStatus.java | 78 + .../neutron/v2/domain/lbaas/v1/Member.java | 368 ++++ .../neutron/v2/domain/lbaas/v1/Members.java | 36 + .../neutron/v2/domain/lbaas/v1/Pool.java | 482 +++++ .../neutron/v2/domain/lbaas/v1/PoolStatus.java | 101 + .../neutron/v2/domain/lbaas/v1/Pools.java | 36 + .../neutron/v2/domain/lbaas/v1/ProbeType.java | 70 + .../neutron/v2/domain/lbaas/v1/Protocol.java | 67 + .../v2/domain/lbaas/v1/SessionPersistence.java | 183 ++ .../neutron/v2/domain/lbaas/v1/VIP.java | 493 +++++ .../neutron/v2/domain/lbaas/v1/VIPs.java | 36 + .../v2/extensions/ExtensionNamespaces.java | 4 + .../v2/extensions/lbaas/v1/LBaaSApi.java | 426 +++++ .../lbaas/v1/EmptyHealthMonitorsFallback.java | 46 + .../lbaas/v1/EmptyMembersFallback.java | 46 + .../fallbacks/lbaas/v1/EmptyPoolsFallback.java | 46 + .../fallbacks/lbaas/v1/EmptyVIPsFallback.java | 46 + .../lbaas/v1/HealthMonitorsToPagedIterable.java | 66 + .../lbaas/v1/MembersToPagedIterable.java | 65 + .../functions/lbaas/v1/ParseHealthMonitors.java | 38 + .../v2/functions/lbaas/v1/ParseMembers.java | 38 + .../v2/functions/lbaas/v1/ParsePools.java | 38 + .../v2/functions/lbaas/v1/ParseVIPs.java | 38 + .../lbaas/v1/PoolsToPagedIterable.java | 65 + .../functions/lbaas/v1/VIPsToPagedIterable.java | 65 + .../extensions/lbaas/v1/LBaaSApiLiveTest.java | 637 +++++++ .../extensions/lbaas/v1/LBaaSApiMockTest.java | 1787 ++++++++++++++++++ .../extension_list_with_lbaas_v1_response.json | 140 ++ ...xtension_list_without_lbaas_v1_response.json | 132 ++ .../lbaas/v1/health_monitor_create_request.json | 8 + .../v1/health_monitor_create_response.json | 16 + .../lbaas/v1/health_monitor_get_response.json | 16 + .../v1/health_monitor_list_response_paged1.json | 20 + .../v1/health_monitor_list_response_paged2.json | 23 + .../lbaas/v1/health_monitor_update_request.json | 11 + .../v1/health_monitor_update_response.json | 16 + .../lbaas/v1/member_create_request.json | 6 + .../lbaas/v1/member_create_response.json | 12 + .../resources/lbaas/v1/member_get_response.json | 12 + .../lbaas/v1/member_list_response_paged1.json | 20 + .../lbaas/v1/member_list_response_paged2.json | 20 + .../lbaas/v1/member_update_request.json | 7 + .../lbaas/v1/member_update_response.json | 12 + .../pool_associate_health_monitor_request.json | 5 + .../pool_associate_health_monitor_response.json | 4 + .../resources/lbaas/v1/pool_create_request.json | 8 + .../lbaas/v1/pool_create_response.json | 18 + .../resources/lbaas/v1/pool_get_response.json | 35 + .../lbaas/v1/pool_list_response_paged1.json | 46 + .../lbaas/v1/pool_list_response_paged2.json | 42 + .../resources/lbaas/v1/pool_update_request.json | 11 + .../lbaas/v1/pool_update_response.json | 29 + .../resources/lbaas/v1/vip_create_request.json | 9 + .../resources/lbaas/v1/vip_create_response.json | 17 + .../resources/lbaas/v1/vip_get_response.json | 21 + .../lbaas/v1/vip_list_response_paged1.json | 29 + .../lbaas/v1/vip_list_response_paged2.json | 29 + .../resources/lbaas/v1/vip_update_request.json | 13 + .../resources/lbaas/v1/vip_update_response.json | 21 + 65 files changed, 6886 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/jclouds/blob/0c82ed9f/apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/NeutronApi.java ---------------------------------------------------------------------- diff --git a/apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/NeutronApi.java b/apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/NeutronApi.java index b54fa39..983fe94 100644 --- a/apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/NeutronApi.java +++ b/apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/NeutronApi.java @@ -22,12 +22,12 @@ import java.util.Set; import javax.ws.rs.Path; import org.jclouds.Constants; - import org.jclouds.location.Region; import org.jclouds.location.functions.RegionToEndpoint; import org.jclouds.openstack.neutron.v2.extensions.FloatingIPApi; import org.jclouds.openstack.neutron.v2.extensions.RouterApi; import org.jclouds.openstack.neutron.v2.extensions.SecurityGroupApi; +import org.jclouds.openstack.neutron.v2.extensions.lbaas.v1.LBaaSApi; import org.jclouds.openstack.neutron.v2.features.NetworkApi; import org.jclouds.openstack.neutron.v2.features.PortApi; import org.jclouds.openstack.neutron.v2.features.SubnetApi; @@ -103,4 +103,14 @@ public interface NeutronApi extends Closeable { */ @Delegate Optional<SecurityGroupApi> getSecurityGroupApi(@EndpointParam(parser = RegionToEndpoint.class) String region); + + /** + * Provides access to LBaaS features. + * + * <h3>NOTE</h3> + * This API is an extension that may or may not be present in your OpenStack cloud. Use the Optional return type + * to determine if it is present. + */ + @Delegate + Optional<LBaaSApi> getLBaaSApi(@EndpointParam(parser = RegionToEndpoint.class) String region); } http://git-wip-us.apache.org/repos/asf/jclouds/blob/0c82ed9f/apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/config/NeutronHttpApiModule.java ---------------------------------------------------------------------- diff --git a/apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/config/NeutronHttpApiModule.java b/apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/config/NeutronHttpApiModule.java index f05439a..e7b33c6 100644 --- a/apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/config/NeutronHttpApiModule.java +++ b/apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/config/NeutronHttpApiModule.java @@ -67,6 +67,8 @@ public class NeutronHttpApiModule extends HttpApiModule<NeutronApi> { URI.create("http://docs.openstack.org/ext/neutron/router/api/v1.0")) .put(URI.create(ExtensionNamespaces.SECURITY_GROUPS), URI.create("http://docs.openstack.org/ext/securitygroups/api/v2.0")) + .put(URI.create(ExtensionNamespaces.LBAAS), + URI.create("http://docs.openstack.org/networking/ext/lbaas/api/v1.0")) .build(); } http://git-wip-us.apache.org/repos/asf/jclouds/blob/0c82ed9f/apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/HealthMonitor.java ---------------------------------------------------------------------- diff --git a/apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/HealthMonitor.java b/apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/HealthMonitor.java new file mode 100644 index 0000000..29ec991 --- /dev/null +++ b/apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/HealthMonitor.java @@ -0,0 +1,451 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.openstack.neutron.v2.domain.lbaas.v1; + +import java.beans.ConstructorProperties; + +import javax.inject.Named; + +import org.jclouds.javax.annotation.Nullable; + +import com.google.common.base.MoreObjects; +import com.google.common.base.Objects; +import com.google.common.collect.ImmutableList; + +/** + * A Neutron LBaaS v1 HealthMonitor. + */ +public class HealthMonitor { + + // Mandatory attributes when creating + @Named("tenant_id") + private String tenantId; + private ProbeType type; + // Mandatory attributes that can be updated + private Integer delay; + private Integer timeout; + @Named("max_retries") + private Integer maxRetries; + // Optional attributes that can be updated + @Named("http_method") + private HttpMethod httpMethod; + @Named("url_path") + private String urlPath; + @Named("expected_codes") + private String expectedCodes; + @Named("admin_state_up") + private Boolean adminStateUp; + // Read-only attributes + private String id; + private ImmutableList<PoolStatus> pools; + private LBaaSStatus status; + @Named("status_description") + private String statusDescription; + + /** + * Deserialization constructor + */ + @ConstructorProperties({ "id", "tenant_id", "type", "delay", "timeout", "max_retries", "http_method", "url_path", + "expected_codes", "pools", "admin_state_up", "status", "status_description" }) + private HealthMonitor(String id, String tenantId, ProbeType type, Integer delay, Integer timeout, + Integer maxRetries, HttpMethod httpMethod, String urlPath, String expectedCodes, + ImmutableList<PoolStatus> pools, Boolean adminStateUp, LBaaSStatus status, String statusDescription) { + this.id = id; + this.tenantId = tenantId; + this.type = type; + this.delay = delay; + this.timeout = timeout; + this.maxRetries = maxRetries; + this.httpMethod = httpMethod; + this.urlPath = urlPath; + this.expectedCodes = expectedCodes; + this.pools = pools; + this.adminStateUp = adminStateUp; + this.status = status; + this.statusDescription = statusDescription; + } + + /** + * Default constructor. + */ + private HealthMonitor() { + } + + /** + * Copy constructor. + * + * @param healthMonitor the HealthMonitor to copy from. + */ + private HealthMonitor(HealthMonitor healthMonitor) { + this(healthMonitor.id, healthMonitor.tenantId, healthMonitor.type, healthMonitor.delay, healthMonitor.timeout, + healthMonitor.maxRetries, healthMonitor.httpMethod, healthMonitor.urlPath, healthMonitor.expectedCodes, + healthMonitor.pools, healthMonitor.adminStateUp, healthMonitor.status, healthMonitor.statusDescription); + } + + /** + * @return the id of the HealthMonitor. + */ + @Nullable + public String getId() { + return id; + } + + /** + * @return the tenant id of the HealthMonitor. + */ + @Nullable + public String getTenantId() { + return tenantId; + } + + /** + * @return the probe type for this HealthMonitor. + */ + @Nullable + public ProbeType getType() { + return type; + } + + /** + * @return the delay for this HealthMonitor. + */ + @Nullable + public Integer getDelay() { + return delay; + } + + /** + * @return the timeout for this HealthMonitor. + */ + @Nullable + public Integer getTimeout() { + return timeout; + } + + /** + * @return the max retries for this HealthMonitor. + */ + @Nullable + public Integer getMaxRetries() { + return maxRetries; + } + + /** + * @return the HTTP method for this HealthMonitor. + */ + @Nullable + public HttpMethod getHttpMethod() { + return httpMethod; + } + + /** + * @return the URL path for this HealthMonitor. + */ + @Nullable + public String getUrlPath() { + return urlPath; + } + + /** + * @return the expected codes for this HealthMonitor. + */ + @Nullable + public String getExpectedCodes() { + return expectedCodes; + } + + /** + * @return the pools for this HealthMonitor. + */ + @Nullable + public ImmutableList<PoolStatus> getPools() { + return pools; + } + + /** + * @return the administrative state for this HealthMonitor. + */ + @Nullable + public Boolean getAdminStateUp() { + return adminStateUp; + } + + /** + * @return the status for this HealthMonitor. + */ + @Nullable + public LBaaSStatus getStatus() { + return status; + } + + /** + * @return the status description for this HealthMonitor. + */ + @Nullable + public String getStatusDescription() { + return statusDescription; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + + HealthMonitor that = (HealthMonitor) o; + + return Objects.equal(this.id, that.id) && Objects.equal(this.tenantId, that.tenantId) + && Objects.equal(this.type, that.type) && Objects.equal(this.delay, that.delay) + && Objects.equal(this.timeout, that.timeout) && Objects.equal(this.maxRetries, that.maxRetries) + && Objects.equal(this.httpMethod, that.httpMethod) && Objects.equal(this.urlPath, that.urlPath) + && Objects.equal(this.expectedCodes, that.expectedCodes) && Objects.equal(this.pools, that.pools) + && Objects.equal(this.adminStateUp, that.adminStateUp) && Objects.equal(this.status, that.status) + && Objects.equal(this.statusDescription, that.statusDescription); + } + + @Override + public int hashCode() { + return Objects.hashCode(id, tenantId, type, delay, timeout, maxRetries, httpMethod, urlPath, expectedCodes, + pools, adminStateUp, status, statusDescription); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this).add("id", id).add("tenantId", tenantId).add("type", type) + .add("delay", delay).add("timeout", timeout).add("maxRetries", maxRetries).add("httpMethod", httpMethod) + .add("urlPath", urlPath).add("expectedCodes", expectedCodes).add("pools", pools) + .add("adminStateUp", adminStateUp).add("status", status).add("statusDescription", statusDescription) + .toString(); + } + + /* + * Methods to get the Create and Update builders follow. + */ + + /** + * @return the Builder for creating a new HealthMonitor. + */ + public static CreateBuilder createBuilder(ProbeType type, Integer delay, Integer timeout, Integer maxRetries) { + return new CreateBuilder(type, delay, timeout, maxRetries); + } + + /** + * @return the Builder for updating a HealthMonitor. + */ + public static UpdateBuilder updateBuilder() { + return new UpdateBuilder(); + } + + private abstract static class Builder<ParameterizedBuilderType> { + protected HealthMonitor healthMonitor; + + /** + * Default constructor. + */ + private Builder() { + healthMonitor = new HealthMonitor(); + } + + protected abstract ParameterizedBuilderType self(); + + /** + * Provides the delay for this HealthMonitor's Builder. + * + * @return the Builder. + * @see HealthMonitor#getDelay() + */ + public ParameterizedBuilderType delay(Integer delay) { + healthMonitor.delay = delay; + return self(); + } + + /** + * Provides the timeout for this HealthMonitor's Builder. + * + * @return the Builder. + * @see HealthMonitor#getTimeout() + */ + public ParameterizedBuilderType timeout(Integer timeout) { + healthMonitor.timeout = timeout; + return self(); + } + + /** + * Provides the max retries for this HealthMonitor's Builder. + * + * @return the Builder. + * @see HealthMonitor#getMaxRetries() + */ + public ParameterizedBuilderType maxRetries(Integer maxRetries) { + healthMonitor.maxRetries = maxRetries; + return self(); + } + + /** + * Provides the HTTP method for this HealthMonitor's Builder. + * + * @return the Builder. + * @see HealthMonitor#getHttpMethod() + */ + public ParameterizedBuilderType httpMethod(HttpMethod httpMethod) { + healthMonitor.httpMethod = httpMethod; + return self(); + } + + /** + * Provides the URL path for this HealthMonitor's Builder. + * + * @return the Builder. + * @see HealthMonitor#getUrlPath() + */ + public ParameterizedBuilderType urlPath(String urlPath) { + healthMonitor.urlPath = urlPath; + return self(); + } + + /** + * Provides the expected codes for this HealthMonitor's Builder. + * + * @return the Builder. + * @see HealthMonitor#getExpectedCodes() + */ + public ParameterizedBuilderType expectedCodes(String expectedCodes) { + healthMonitor.expectedCodes = expectedCodes; + return self(); + } + + /** + * Provides the administrative state for this HealthMonitor's Builder. + * + * @return the Builder. + * @see HealthMonitor#getAdminStateUp() + */ + public ParameterizedBuilderType adminStateUp(Boolean adminStateUp) { + healthMonitor.adminStateUp = adminStateUp; + return self(); + } + } + + /** + * Create builder (inheriting from Builder). + */ + public static class CreateBuilder extends Builder<CreateBuilder> { + /** + * Supply required properties for creating a HealthMonitor's CreateBuilder. + * + * @param type the probe type. + * @param delay the delay. + * @param timeout the timeout. + * @param maxRetries the max retries. + */ + private CreateBuilder(ProbeType type, Integer delay, Integer timeout, Integer maxRetries) { + type(type).delay(delay).timeout(timeout).maxRetries(maxRetries); + } + + /** + * Provides the tenantId for this HealthMonitor's CreateBuilder. Admin-only. + * When keystone is enabled, it is not mandatory to specify tenant_id for resources in create requests, as the + * tenant identifier will be derived from the Authentication token. Please note that the default authorization + * settings only allow administrative users to create resources on behalf of a different tenant. + * + * @return the Builder. + * @see HealthMonitor#getTenantId() + */ + public CreateBuilder tenantId(String tenantId) { + healthMonitor.tenantId = tenantId; + return self(); + } + + /** + * Provides the probe type for this HealthMonitor's Builder. + * + * @return the Builder. + * @see HealthMonitor#getType() + */ + public CreateBuilder type(ProbeType type) { + healthMonitor.type = type; + return self(); + } + + /** + * @return a CreateHealthMonitor constructed with this Builder. + */ + public CreateHealthMonitor build() { + return new CreateHealthMonitor(healthMonitor); + } + + @Override + protected CreateBuilder self() { + return this; + } + } + + /** + * Update builder (inheriting from Builder). + */ + public static class UpdateBuilder extends Builder<UpdateBuilder> { + /** + * Supply required properties for creating a HealthMonitor's UpdateBuilder. + */ + private UpdateBuilder() { + } + + /** + * @return an UpdateHealthMonitor constructed with this Builder. + */ + public UpdateHealthMonitor build() { + return new UpdateHealthMonitor(healthMonitor); + } + + @Override + protected UpdateBuilder self() { + return this; + } + } + + /** + * Create options - extend the domain class, passed to API create calls. + * Essentially the same as the domain class. Ensure validation and safe typing. + */ + public static class CreateHealthMonitor extends HealthMonitor { + /** + * Copy constructor. + * + * @param healthMonitor the HealthMonitor to copy from. + */ + private CreateHealthMonitor(HealthMonitor healthMonitor) { + super(healthMonitor); + } + } + + /** + * Update options - extend the domain class, passed to API update calls. + * Essentially the same as the domain class. Ensure validation and safe typing. + */ + public static class UpdateHealthMonitor extends HealthMonitor { + /** + * Copy constructor. + * + * @param healthMonitor the HealthMonitor to copy from. + */ + private UpdateHealthMonitor(HealthMonitor healthMonitor) { + super(healthMonitor); + } + } + +} http://git-wip-us.apache.org/repos/asf/jclouds/blob/0c82ed9f/apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/HealthMonitorStatus.java ---------------------------------------------------------------------- diff --git a/apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/HealthMonitorStatus.java b/apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/HealthMonitorStatus.java new file mode 100644 index 0000000..ad8d468 --- /dev/null +++ b/apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/HealthMonitorStatus.java @@ -0,0 +1,101 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.openstack.neutron.v2.domain.lbaas.v1; + +import java.beans.ConstructorProperties; + +import javax.inject.Named; + +import org.jclouds.javax.annotation.Nullable; + +import com.google.common.base.MoreObjects; +import com.google.common.base.Objects; + +/** + * A Neutron LBaaS v1 HealthMonitorStatus. + * Contains an id and status describing the health monitor's status. + * + * @see Pool#getHealthMonitorsStatus() + */ +public class HealthMonitorStatus { + + // Mandatory attributes + @Named("monitor_id") + protected final String id; + protected final LBaaSStatus status; + // Optional attributes + @Named("status_description") + protected final String statusDescription; + + @ConstructorProperties({ "monitor_id", "status", "status_description" }) + protected HealthMonitorStatus(String id, LBaaSStatus status, String statusDescription) { + this.id = id; + this.status = status; + this.statusDescription = statusDescription; + } + + /** + * @return the id of the HealthMonitorStatus. + */ + @Nullable + public String getId() { + return id; + } + + /** + * @return the status of the HealthMonitorStatus + */ + @Nullable + public LBaaSStatus getStatus() { + return status; + } + + /** + * @return the status description of the HealthMonitorStatus + */ + @Nullable + public String getStatusDescription() { + return statusDescription; + } + + @Override + public int hashCode() { + return Objects.hashCode(id, status, statusDescription); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null || getClass() != obj.getClass()) + return false; + HealthMonitorStatus that = HealthMonitorStatus.class.cast(obj); + return Objects.equal(this.id, that.id) && Objects.equal(this.status, that.status) + && Objects.equal(this.statusDescription, that.statusDescription); + } + + protected MoreObjects.ToStringHelper string() { + return MoreObjects.toStringHelper(this).add("id", id).add("status", status) + .add("statusDescription", statusDescription); + } + + @Override + public String toString() { + return string().toString(); + } + +} http://git-wip-us.apache.org/repos/asf/jclouds/blob/0c82ed9f/apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/HealthMonitors.java ---------------------------------------------------------------------- diff --git a/apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/HealthMonitors.java b/apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/HealthMonitors.java new file mode 100644 index 0000000..a254938 --- /dev/null +++ b/apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/HealthMonitors.java @@ -0,0 +1,37 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.openstack.neutron.v2.domain.lbaas.v1; + +import java.beans.ConstructorProperties; + +import org.jclouds.openstack.v2_0.domain.Link; +import org.jclouds.openstack.v2_0.domain.PaginatedCollection; + +import com.google.common.collect.ImmutableSet; + +/** + * A collection of Neutron LBaaS v1 HealthMonitors. + */ +public class HealthMonitors extends PaginatedCollection<HealthMonitor> { + public static final HealthMonitors EMPTY = new HealthMonitors(ImmutableSet.<HealthMonitor> of(), + ImmutableSet.<Link> of()); + + @ConstructorProperties({ "health_monitors", "health_monitors_links" }) + protected HealthMonitors(Iterable<HealthMonitor> healthMonitors, Iterable<Link> healthMonitorsLinks) { + super(healthMonitors, healthMonitorsLinks); + } +} http://git-wip-us.apache.org/repos/asf/jclouds/blob/0c82ed9f/apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/HttpMethod.java ---------------------------------------------------------------------- diff --git a/apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/HttpMethod.java b/apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/HttpMethod.java new file mode 100644 index 0000000..f795c66 --- /dev/null +++ b/apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/HttpMethod.java @@ -0,0 +1,75 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jclouds.openstack.neutron.v2.domain.lbaas.v1; + + +/** + * Enumerates supported HTTP methods used by probes of type HTTP/HTTPS that are sent by health monitor to verify member state. + */ +public enum HttpMethod { + /** + * Health monitor sends a GET HTTP request to the member. + */ + GET("GET"), + /** + * Health monitor sends a POST HTTP request to the member. + */ + POST("POST"), + /** + * Health monitor sends a PUT HTTP request to the member. + */ + PUT("PUT"), + /** + * Health monitor sends a DELETE HTTP request to the member. + */ + DELETE("DELETE"), + /** + * Health monitor sends a HEAD HTTP request to the member. + */ + HEAD("HEAD"), + /** + * Used by jclouds when the service returns an unknown value other than null. + */ + UNRECOGNIZED("unrecognized"); + + private String name; + + private HttpMethod(String name) { + this.name = name; + } + + @Override + public String toString() { + return name; + } + + /* + * This provides GSON enum support in jclouds. + * */ + public static HttpMethod fromValue(String name){ + if (name != null) { + for (HttpMethod value : HttpMethod.values()) { + if (name.equalsIgnoreCase(value.name)) { + return value; + } + } + return UNRECOGNIZED; + } + return null; + } +} http://git-wip-us.apache.org/repos/asf/jclouds/blob/0c82ed9f/apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/LBaaSStatus.java ---------------------------------------------------------------------- diff --git a/apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/LBaaSStatus.java b/apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/LBaaSStatus.java new file mode 100644 index 0000000..85820fc --- /dev/null +++ b/apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/LBaaSStatus.java @@ -0,0 +1,78 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jclouds.openstack.neutron.v2.domain.lbaas.v1; + +/** + * Enumerates supported Neutron LBaaS v1 resources status. + */ +public enum LBaaSStatus { + /** + * The LBaaS v1 resource is ready and active. + */ + ACTIVE("active"), + /** + * The LBaaS v1 resource is being created. + */ + PENDING_CREATE("pending_create"), + /** + * The LBaaS v1 resource is being updated. + */ + PENDING_UPDATE("pending_update"), + /** + * The LBaaS v1 resource is going to be deleted. + */ + PENDING_DELETE("pending_delete"), + /** + * The LBaaS v1 resource is created but not active. + */ + INACTIVE("inactive"), + /** + * The LBaaS v1 resource is in an error state. + */ + ERROR("error"), + /** + * Used by jclouds when the service returns an unknown value other than null. + */ + UNRECOGNIZED("unrecognized"); + + private String name; + + private LBaaSStatus(String name) { + this.name = name; + } + + @Override + public String toString() { + return name; + } + + /* + * This provides GSON enum support in jclouds. + * */ + public static LBaaSStatus fromValue(String name){ + if (name != null) { + for (LBaaSStatus value : LBaaSStatus.values()) { + if (name.equalsIgnoreCase(value.name)) { + return value; + } + } + return UNRECOGNIZED; + } + return null; + } +} http://git-wip-us.apache.org/repos/asf/jclouds/blob/0c82ed9f/apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/Member.java ---------------------------------------------------------------------- diff --git a/apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/Member.java b/apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/Member.java new file mode 100644 index 0000000..bff6cfe --- /dev/null +++ b/apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/Member.java @@ -0,0 +1,368 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.openstack.neutron.v2.domain.lbaas.v1; + +import java.beans.ConstructorProperties; + +import javax.inject.Named; + +import org.jclouds.javax.annotation.Nullable; + +import com.google.common.base.MoreObjects; +import com.google.common.base.Objects; + +/** + * A Neutron LBaaS v1 Member. + */ +public class Member { + + // Mandatory attributes when creating + @Named("tenant_id") + private String tenantId; + private String address; + @Named("protocol_port") + private Integer protocolPort; + // Mandatory attributes that can be updated + @Named("pool_id") + private String poolId; + // Optional attributes that can be updated + private Integer weight; + @Named("admin_state_up") + private Boolean adminStateUp; + // Read-only attributes + private String id; + private LBaaSStatus status; + @Named("status_description") + private String statusDescription; + + /** + * Deserialization constructor. + */ + @ConstructorProperties({ "id", "tenant_id", "pool_id", "address", "protocol_port", "weight", "admin_state_up", + "status", "status_description" }) + private Member(String id, String tenantId, String poolId, String address, Integer protocolPort, Integer weight, + Boolean adminStateUp, LBaaSStatus status, String statusDescription) { + this.id = id; + this.tenantId = tenantId; + this.poolId = poolId; + this.address = address; + this.protocolPort = protocolPort; + this.weight = weight; + this.adminStateUp = adminStateUp; + this.status = status; + this.statusDescription = statusDescription; + } + + /** + * Default constructor. + */ + private Member() { + } + + /** + * Copy constructor. + * + * @param member the Member to copy from. + */ + private Member(Member member) { + this(member.id, member.tenantId, member.poolId, member.address, member.protocolPort, member.weight, + member.adminStateUp, member.status, member.statusDescription); + } + + /** + * @return the id of the Member. + */ + @Nullable + public String getId() { + return id; + } + + /** + * @return the tenant id of the Member. + */ + @Nullable + public String getTenantId() { + return tenantId; + } + + /** + * @return the pool id for this Member. + */ + @Nullable + public String getPoolId() { + return poolId; + } + + /** + * @return the address for this Member. + */ + @Nullable + public String getAddress() { + return address; + } + + /** + * @return the protocol port for this Member. + */ + @Nullable + public Integer getProtocolPort() { + return protocolPort; + } + + /** + * @return the weight for this Member. + */ + @Nullable + public Integer getWeight() { + return weight; + } + + /** + * @return the administrative state for this Member. + */ + @Nullable + public Boolean getAdminStateUp() { + return adminStateUp; + } + + /** + * @return the status for this Member. + */ + @Nullable + public LBaaSStatus getStatus() { + return status; + } + + /** + * @return the status description for this Member. + */ + @Nullable + public String getStatusDescription() { + return statusDescription; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + + Member that = (Member) o; + + return Objects.equal(this.id, that.id) && Objects.equal(this.tenantId, that.tenantId) + && Objects.equal(this.poolId, that.poolId) && Objects.equal(this.address, that.address) + && Objects.equal(this.protocolPort, that.protocolPort) && Objects.equal(this.weight, that.weight) + && Objects.equal(this.adminStateUp, that.adminStateUp) && Objects.equal(this.status, that.status) + && Objects.equal(this.statusDescription, that.statusDescription); + } + + @Override + public int hashCode() { + return Objects.hashCode(id, tenantId, poolId, address, protocolPort, weight, adminStateUp, status, + statusDescription); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this).add("id", id).add("tenantId", tenantId).add("poolId", poolId) + .add("address", address).add("protocolPort", protocolPort).add("weight", weight) + .add("adminStateUp", adminStateUp).add("status", status).add("statusDescription", statusDescription) + .toString(); + } + + /* + * Methods to get the Create and Update builders follow. + */ + + /** + * @return the Builder for creating a new Member. + */ + public static CreateBuilder createBuilder(String poolId, String address, Integer port) { + return new CreateBuilder(poolId, address, port); + } + + /** + * @return the Builder for updating a Member. + */ + public static UpdateBuilder updateBuilder() { + return new UpdateBuilder(); + } + + private abstract static class Builder<ParameterizedBuilderType> { + protected Member member; + + /** + * Default constructor. + */ + private Builder() { + member = new Member(); + } + + protected abstract ParameterizedBuilderType self(); + + /** + * Provides the pool id for this Member's Builder. + * + * @return the Builder. + * @see Member#getPoolId() + */ + public ParameterizedBuilderType poolId(String poolId) { + member.poolId = poolId; + return self(); + } + + /** + * Provides the weight for this Member's Builder. + * + * @return the Builder. + * @see Member#getWeight() + */ + public ParameterizedBuilderType weight(Integer weight) { + member.weight = weight; + return self(); + } + + /** + * Provides the administrative state for this Member's Builder. + * + * @return the Builder. + * @see Member#getAdminStateUp() + */ + public ParameterizedBuilderType adminStateUp(Boolean adminStateUp) { + member.adminStateUp = adminStateUp; + return self(); + } + } + + /** + * Create builder (inheriting from Builder). + */ + public static class CreateBuilder extends Builder<CreateBuilder> { + /** + * Supply required properties for creating a Member's CreateBuilder. + * + * @param poolId the pool id. + * @param address the IP address. + * @param port the protocol port. + */ + private CreateBuilder(String poolId, String address, Integer port) { + poolId(poolId).address(address).protocolPort(port); + } + + /** + * Provides the tenantId for this Member's Builder. Admin-only. + * When keystone is enabled, it is not mandatory to specify tenant_id for resources in create requests, as the + * tenant identifier will be derived from the Authentication token. Please note that the default authorization + * settings only allow administrative users to create resources on behalf of a different tenant. + * + * @return the Builder. + * @see Member#getTenantId() + */ + public CreateBuilder tenantId(String tenantId) { + member.tenantId = tenantId; + return self(); + } + + /** + * Provides the address for this Member's Builder. + * + * @return the Builder. + * @see Member#getAddress() + */ + public CreateBuilder address(String address) { + member.address = address; + return self(); + } + + /** + * Provides the protocol port for this Member's Builder. + * + * @return the Builder. + * @see Member#getProtocolPort() + */ + public CreateBuilder protocolPort(Integer protocolPort) { + member.protocolPort = protocolPort; + return self(); + } + + /** + * @return a CreateMember constructed with this Builder. + */ + public CreateMember build() { + return new CreateMember(member); + } + + @Override + protected CreateBuilder self() { + return this; + } + } + + /** + * Update builder (inheriting from Builder). + */ + public static class UpdateBuilder extends Builder<UpdateBuilder> { + /** + * Supply required properties for creating a Member's UpdateBuilder. + */ + private UpdateBuilder() { + } + + /** + * @return a UpdateMember constructed with this Builder. + */ + public UpdateMember build() { + return new UpdateMember(member); + } + + @Override + protected UpdateBuilder self() { + return this; + } + } + + /** + * Create options - extend the domain class, passed to API create calls. + * Essentially the same as the domain class. Ensure validation and safe typing. + */ + public static class CreateMember extends Member { + /** + * Copy constructor. + * + * @param member the Member to copy from. + */ + private CreateMember(Member member) { + super(member); + } + } + + /** + * Update options - extend the domain class, passed to API update calls. + * Essentially the same as the domain class. Ensure validation and safe typing. + */ + public static class UpdateMember extends Member { + /** + * Copy constructor. + * + * @param member the Member to copy from. + */ + private UpdateMember(Member member) { + super(member); + } + } +} http://git-wip-us.apache.org/repos/asf/jclouds/blob/0c82ed9f/apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/Members.java ---------------------------------------------------------------------- diff --git a/apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/Members.java b/apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/Members.java new file mode 100644 index 0000000..74a464d --- /dev/null +++ b/apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/Members.java @@ -0,0 +1,36 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.openstack.neutron.v2.domain.lbaas.v1; + +import java.beans.ConstructorProperties; + +import org.jclouds.openstack.v2_0.domain.Link; +import org.jclouds.openstack.v2_0.domain.PaginatedCollection; + +import com.google.common.collect.ImmutableSet; + +/** + * A collection of of Neutron LBaaS v1 Members. + */ +public class Members extends PaginatedCollection<Member> { + public static final Members EMPTY = new Members(ImmutableSet.<Member> of(), ImmutableSet.<Link> of()); + + @ConstructorProperties({ "members", "members_links" }) + protected Members(Iterable<Member> members, Iterable<Link> membersLinks) { + super(members, membersLinks); + } +} http://git-wip-us.apache.org/repos/asf/jclouds/blob/0c82ed9f/apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/Pool.java ---------------------------------------------------------------------- diff --git a/apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/Pool.java b/apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/Pool.java new file mode 100644 index 0000000..5139141 --- /dev/null +++ b/apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/Pool.java @@ -0,0 +1,482 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.openstack.neutron.v2.domain.lbaas.v1; + +import java.beans.ConstructorProperties; + +import javax.inject.Named; + +import org.jclouds.javax.annotation.Nullable; + +import com.google.common.base.MoreObjects; +import com.google.common.base.Objects; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableSet; + +/** + * A Neutron LBaaS v1 Pool. + */ +public class Pool { + + // Load balancing methods that must be supported by all providers. + // Not an enum type because any provider may support additional balancing methods. + public static String ROUND_ROBIN = "ROUND_ROBIN"; + public static String LEAST_CONNECTIONS = "LEAST_CONNECTIONS"; + public static String SOURCE_IP = "SOURCE_IP"; + + // Mandatory attributes when creating + @Named("tenant_id") + private String tenantId; + @Named("subnet_id") + private String subnetId; + private Protocol protocol; + // Mandatory attributes that can be updated + @Named("lb_method") + private String lbMethod; + // Optional attributes when creating + private String provider; + // Optional attributes that can be updated + private String name; + private String description; + @Named("health_monitors") + private ImmutableSet<String> healthMonitors; + @Named("admin_state_up") + private Boolean adminStateUp; + // Read-only attributes + private String id; + @Named("vip_id") + private String vipId; + private ImmutableSet<String> members; + @Named("health_monitors_status") + private ImmutableList<HealthMonitorStatus> healthMonitorsStatus; + private LBaaSStatus status; + @Named("status_description") + private String statusDescription; + + /** + * Deserialization constructor. + */ + @ConstructorProperties({ "id", "tenant_id", "vip_id", "name", "description", "subnet_id", "protocol", "provider", + "lb_method", "health_monitors", "health_monitors_status", "members", "admin_state_up", "status", + "status_description" }) + private Pool(String id, String tenantId, String vipId, String name, String description, String subnetId, + Protocol protocol, String provider, String lbMethod, ImmutableSet<String> healthMonitors, + ImmutableList<HealthMonitorStatus> healthMonitorsStatus, ImmutableSet<String> members, Boolean adminStateUp, + LBaaSStatus status, String statusDescription) { + this.id = id; + this.tenantId = tenantId; + this.vipId = vipId; + this.name = name; + this.description = description; + this.subnetId = subnetId; + this.protocol = protocol; + this.provider = provider; + this.lbMethod = lbMethod; + this.healthMonitors = healthMonitors; + this.healthMonitorsStatus = healthMonitorsStatus; + this.members = members; + this.adminStateUp = adminStateUp; + this.status = status; + this.statusDescription = statusDescription; + } + + /** + * Default constructor. + */ + private Pool() { + } + + /** + * Copy constructor. + * + * @param pool the Pool to copy from. + */ + private Pool(Pool pool) { + this(pool.id, pool.tenantId, pool.vipId, pool.name, pool.description, pool.subnetId, pool.protocol, + pool.provider, pool.lbMethod, pool.healthMonitors, pool.healthMonitorsStatus, pool.members, + pool.adminStateUp, pool.status, pool.statusDescription); + } + + /** + * @return the id of the Pool. + */ + @Nullable + public String getId() { + return id; + } + + /** + * @return the tenant id of the Pool. + */ + @Nullable + public String getTenantId() { + return tenantId; + } + + /** + * @return the virtual IP id of the Pool. + */ + @Nullable + public String getVIPId() { + return vipId; + } + + /** + * @return the name of the Pool. + */ + @Nullable + public String getName() { + return name; + } + + /** + * @return the description of the Pool. + */ + @Nullable + public String getDescription() { + return description; + } + + /** + * @return the subnet id for this Pool. + */ + @Nullable + public String getSubnetId() { + return subnetId; + } + + /** + * @return the protocol for this Pool. + */ + @Nullable + public Protocol getProtocol() { + return protocol; + } + + /** + * @return the provider for this Pool. + */ + @Nullable + public String getProvider() { + return provider; + } + + /** + * @return the load balancing method for this Pool. + */ + @Nullable + public String getLBMethod() { + return lbMethod; + } + + /** + * @return the health monitors for this Pool. + */ + @Nullable + public ImmutableSet<String> getHealthMonitors() { + return healthMonitors; + } + + /** + * @return the health monitors status for this Pool. + */ + @Nullable + public ImmutableList<HealthMonitorStatus> getHealthMonitorsStatus() { + return healthMonitorsStatus; + } + + /** + * @return the members for this Pool. + */ + @Nullable + public ImmutableSet<String> getMembers() { + return members; + } + + /** + * @return the administrative state for this Pool. + */ + @Nullable + public Boolean getAdminStateUp() { + return adminStateUp; + } + + /** + * @return the status for this Pool. + */ + @Nullable + public LBaaSStatus getStatus() { + return status; + } + + /** + * @return the status description for this Pool. + */ + @Nullable + public String getStatusDescription() { + return statusDescription; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + + Pool that = (Pool) o; + + return Objects.equal(this.id, that.id) && Objects.equal(this.tenantId, that.tenantId) + && Objects.equal(this.vipId, that.vipId) && Objects.equal(this.name, that.name) + && Objects.equal(this.description, that.description) && Objects.equal(this.subnetId, that.subnetId) + && Objects.equal(this.protocol, that.protocol) && Objects.equal(this.provider, that.provider) + && Objects.equal(this.lbMethod, that.lbMethod) && Objects.equal(this.healthMonitors, that.healthMonitors) + && Objects.equal(this.healthMonitorsStatus, that.healthMonitorsStatus) + && Objects.equal(this.members, that.members) && Objects.equal(this.adminStateUp, that.adminStateUp) + && Objects.equal(this.status, that.status) && Objects.equal(this.statusDescription, that.statusDescription); + } + + @Override + public int hashCode() { + return Objects.hashCode(id, tenantId, vipId, name, description, subnetId, protocol, provider, lbMethod, + healthMonitors, healthMonitorsStatus, members, adminStateUp, status, statusDescription); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this).add("id", id).add("tenantId", tenantId).add("vipId", vipId) + .add("name", name).add("description", description).add("subnetId", subnetId).add("protocol", protocol) + .add("provider", provider).add("lbMethod", lbMethod).add("healthMonitors", healthMonitors) + .add("healthMonitorsStatus", healthMonitorsStatus).add("members", members) + .add("adminStateUp", adminStateUp).add("status", status).add("statusDescription", statusDescription) + .toString(); + } + + /* + * Methods to get the Create and Update builders follow. + */ + + /** + * @return the Builder for creating a new Pool. + */ + public static CreateBuilder createBuilder(String subnetId, Protocol protocol, String lbMethod) { + return new CreateBuilder(subnetId, protocol, lbMethod); + } + + /** + * @return the Builder for updating a Pool. + */ + public static UpdateBuilder updateBuilder() { + return new UpdateBuilder(); + } + + private abstract static class Builder<ParameterizedBuilderType> { + protected Pool pool; + + /** + * Default constructor. + */ + private Builder() { + pool = new Pool(); + } + + protected abstract ParameterizedBuilderType self(); + + /** + * Provides the name for this Pool's Builder. + * + * @return the Builder. + * @see Pool#getName() + */ + public ParameterizedBuilderType name(String name) { + pool.name = name; + return self(); + } + + /** + * Provides the description for this Pool's Builder. + * + * @return the Builder. + * @see Pool#getDescription() + */ + public ParameterizedBuilderType description(String description) { + pool.description = description; + return self(); + } + + /** + * Provides the load balancing method for this Pool's Builder. + * + * @return the Builder. + * @see Pool#getLBMethod() + */ + public ParameterizedBuilderType lbMethod(String lbMethod) { + pool.lbMethod = lbMethod; + return self(); + } + + /** + * Provides the health monitors for this Pool's Builder. + * + * @return the Builder. + * @see Pool#getHealthMonitors() + */ + public ParameterizedBuilderType healthMonitors(ImmutableSet<String> healthMonitors) { + pool.healthMonitors = healthMonitors; + return self(); + } + + /** + * Provides the administrative state for this Pool's Builder. + * + * @return the Builder. + * @see Pool#getAdminStateUp() + */ + public ParameterizedBuilderType adminStateUp(Boolean adminStateUp) { + pool.adminStateUp = adminStateUp; + return self(); + } + } + + /** + * Create builder (inheriting from Builder). + */ + public static class CreateBuilder extends Builder<CreateBuilder> { + /** + * Supply required properties for creating a Pool's CreateBuilder. + * + * @param subnetId the subnet id. + * @param protocol the protocol. + * @param lbMethod the load balancing method. + */ + private CreateBuilder(String subnetId, Protocol protocol, String lbMethod) { + subnetId(subnetId).protocol(protocol).lbMethod(lbMethod); + } + + /** + * Provides the tenantId for this Pool's Builder. Admin-only. + * When keystone is enabled, it is not mandatory to specify tenant_id for resources in create requests, as the + * tenant identifier will be derived from the Authentication token. Please note that the default authorization + * settings only allow administrative users to create resources on behalf of a different tenant. + * + * @return the Builder. + * @see Pool#getTenantId() + */ + public CreateBuilder tenantId(String tenantId) { + pool.tenantId = tenantId; + return self(); + } + + /** + * Provides the subnet id for this Pool's Builder. + * + * @return the Builder. + * @see Pool#getSubnetId() + */ + public CreateBuilder subnetId(String subnetId) { + pool.subnetId = subnetId; + return self(); + } + + /** + * Provides the protocol for this Pool's Builder. + * + * @return the Builder. + * @see Pool#getProtocol() + */ + public CreateBuilder protocol(Protocol protocol) { + pool.protocol = protocol; + return self(); + } + + /** + * Provides the provider for this Pool's Builder. + * + * @return the Builder. + * @see Pool#getProvider() + */ + public CreateBuilder provider(String provider) { + pool.provider = provider; + return self(); + } + + /** + * @return a CreatePool constructed with this Builder. + */ + public CreatePool build() { + return new CreatePool(pool); + } + + @Override + protected CreateBuilder self() { + return this; + } + } + + /** + * Update builder (inheriting from Builder). + */ + public static class UpdateBuilder extends Builder<UpdateBuilder> { + /** + * Supply required properties for creating a Pool's UpdateBuilder. + */ + private UpdateBuilder() { + } + + /** + * @return a UpdatePool constructed with this Builder. + */ + public UpdatePool build() { + return new UpdatePool(pool); + } + + @Override + protected UpdateBuilder self() { + return this; + } + } + + /** + * Create options - extend the domain class, passed to API create calls. + * Essentially the same as the domain class. Ensure validation and safe typing. + */ + public static class CreatePool extends Pool { + /** + * Copy constructor. + * + * @param pool the Pool to copy from. + */ + private CreatePool(Pool pool) { + super(pool); + } + } + + /** + * Update options - extend the domain class, passed to API update calls. + * Essentially the same as the domain class. Ensure validation and safe typing. + */ + public static class UpdatePool extends Pool { + /** + * Copy constructor. + * + * @param pool the Pool to copy from. + */ + private UpdatePool(Pool pool) { + super(pool); + } + } +} http://git-wip-us.apache.org/repos/asf/jclouds/blob/0c82ed9f/apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/PoolStatus.java ---------------------------------------------------------------------- diff --git a/apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/PoolStatus.java b/apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/PoolStatus.java new file mode 100644 index 0000000..07989e7 --- /dev/null +++ b/apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/PoolStatus.java @@ -0,0 +1,101 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.openstack.neutron.v2.domain.lbaas.v1; + +import java.beans.ConstructorProperties; + +import javax.inject.Named; + +import org.jclouds.javax.annotation.Nullable; + +import com.google.common.base.MoreObjects; +import com.google.common.base.Objects; + +/** + * A Neutron LBaaS v1 PoolStatus. + * Contains an id and status describing the pool's status. + * + * @see HealthMonitor#getPools() + */ +public class PoolStatus { + + // Mandatory attributes + @Named("pool_id") + protected final String id; + protected final LBaaSStatus status; + // Optional attributes + @Named("status_description") + protected final String statusDescription; + + @ConstructorProperties({ "pool_id", "status", "status_description" }) + protected PoolStatus(String id, LBaaSStatus status, String statusDescription) { + this.id = id; + this.status = status; + this.statusDescription = statusDescription; + } + + /** + * @return the id of the PoolStatus. + */ + @Nullable + public String getId() { + return id; + } + + /** + * @return the status of the PoolStatus. + */ + @Nullable + public LBaaSStatus getStatus() { + return status; + } + + /** + * @return the status description of the PoolStatus. + */ + @Nullable + public String getStatusDescription() { + return statusDescription; + } + + @Override + public int hashCode() { + return Objects.hashCode(id, status, statusDescription); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null || getClass() != obj.getClass()) + return false; + PoolStatus that = PoolStatus.class.cast(obj); + return Objects.equal(this.id, that.id) && Objects.equal(this.status, that.status) + && Objects.equal(this.statusDescription, that.statusDescription); + } + + protected MoreObjects.ToStringHelper string() { + return MoreObjects.toStringHelper(this).add("id", id).add("status", status) + .add("statusDescription", statusDescription); + } + + @Override + public String toString() { + return string().toString(); + } + +} http://git-wip-us.apache.org/repos/asf/jclouds/blob/0c82ed9f/apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/Pools.java ---------------------------------------------------------------------- diff --git a/apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/Pools.java b/apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/Pools.java new file mode 100644 index 0000000..c30bc13 --- /dev/null +++ b/apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/Pools.java @@ -0,0 +1,36 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.openstack.neutron.v2.domain.lbaas.v1; + +import java.beans.ConstructorProperties; + +import org.jclouds.openstack.v2_0.domain.Link; +import org.jclouds.openstack.v2_0.domain.PaginatedCollection; + +import com.google.common.collect.ImmutableSet; + +/** + * A collection of of Neutron LBaaS v1 Pools. + */ +public class Pools extends PaginatedCollection<Pool> { + public static final Pools EMPTY = new Pools(ImmutableSet.<Pool> of(), ImmutableSet.<Link> of()); + + @ConstructorProperties({ "pools", "pools_links" }) + protected Pools(Iterable<Pool> pools, Iterable<Link> poolsLinks) { + super(pools, poolsLinks); + } +} http://git-wip-us.apache.org/repos/asf/jclouds/blob/0c82ed9f/apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/ProbeType.java ---------------------------------------------------------------------- diff --git a/apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/ProbeType.java b/apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/ProbeType.java new file mode 100644 index 0000000..fb5d565 --- /dev/null +++ b/apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/ProbeType.java @@ -0,0 +1,70 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jclouds.openstack.neutron.v2.domain.lbaas.v1; + +/** + * Enumerates supported types of probe sent by health monitor to verify member state. + */ +public enum ProbeType { + /** + * Health monitor pings the members by using ICMP. + */ + PING("PING"), + /** + * Health monitor connects to the members by using TCP. + */ + TCP("TCP"), + /** + * Health monitor sends an HTTP request to the member. + */ + HTTP("HTTP"), + /** + * Health monitor sends a secure HTTP request to the member. + */ + HTTPS("HTTPS"), + /** + * Used by jclouds when the service returns an unknown value other than null. + */ + UNRECOGNIZED("unrecognized"); + + private String name; + + private ProbeType(String name) { + this.name = name; + } + + @Override + public String toString() { + return name; + } + + /* + * This provides GSON enum support in jclouds. + * */ + public static ProbeType fromValue(String name){ + if (name != null) { + for (ProbeType value : ProbeType.values()) { + if (name.equalsIgnoreCase(value.name)) { + return value; + } + } + return UNRECOGNIZED; + } + return null; + } +} http://git-wip-us.apache.org/repos/asf/jclouds/blob/0c82ed9f/apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/Protocol.java ---------------------------------------------------------------------- diff --git a/apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/Protocol.java b/apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/Protocol.java new file mode 100644 index 0000000..e353863 --- /dev/null +++ b/apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/Protocol.java @@ -0,0 +1,67 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jclouds.openstack.neutron.v2.domain.lbaas.v1; + +/** + * Enumerates supported protocols. + * Protocol must be specified for the front-end (see {@link VIP}) and for the back-end instances (see {@link Pool}). + */ +public enum Protocol { + /** + * Use TCP for routing traffic. + */ + TCP("TCP"), + /** + * Use HTTP for routing traffic. + */ + HTTP("HTTP"), + /** + * Use HTTPS for routing traffic. + */ + HTTPS("HTTPS"), + /** + * Used by jclouds when the service returns an unknown value other than null. + */ + UNRECOGNIZED("unrecognized"); + + private String name; + + private Protocol(String name) { + this.name = name; + } + + @Override + public String toString() { + return name; + } + + /* + * This provides GSON enum support in jclouds. + * */ + public static Protocol fromValue(String name){ + if (name != null) { + for (Protocol value : Protocol.values()) { + if (name.equalsIgnoreCase(value.name)) { + return value; + } + } + return UNRECOGNIZED; + } + return null; + } +} http://git-wip-us.apache.org/repos/asf/jclouds/blob/0c82ed9f/apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/SessionPersistence.java ---------------------------------------------------------------------- diff --git a/apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/SessionPersistence.java b/apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/SessionPersistence.java new file mode 100644 index 0000000..c984ac4 --- /dev/null +++ b/apis/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/SessionPersistence.java @@ -0,0 +1,183 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.openstack.neutron.v2.domain.lbaas.v1; + +import java.beans.ConstructorProperties; + +import javax.inject.Named; + +import org.jclouds.javax.annotation.Nullable; + +import com.google.common.base.MoreObjects; +import com.google.common.base.Objects; + +/** + * A Neutron LBaaS v1 SessionPersistence. + * Contains a type and cookie name describing the session persistence. + */ +public class SessionPersistence { + + // Mandatory attributes + protected final Type type; + // Optional attributes + @Named("cookie_name") + protected final String cookieName; + + @ConstructorProperties({ "type", "cookie_name" }) + protected SessionPersistence(Type type, String cookieName) { + this.type = type; + this.cookieName = cookieName; + } + + /** + * @return the type of the SessionPersistence. + */ + @Nullable + public Type getType() { + return type; + } + + /** + * @return the cookie name of the SessionPersistence. + */ + @Nullable + public String getCookieName() { + return cookieName; + } + + @Override + public int hashCode() { + return Objects.hashCode(type, cookieName); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null || getClass() != obj.getClass()) + return false; + SessionPersistence that = SessionPersistence.class.cast(obj); + return Objects.equal(this.type, that.type) && Objects.equal(this.cookieName, that.cookieName); + } + + protected MoreObjects.ToStringHelper string() { + return MoreObjects.toStringHelper(this).add("type", type).add("cookieName", cookieName); + } + + @Override + public String toString() { + return string().toString(); + } + + /* + * Methods to get the builder follow. + */ + + /** + * @return the Builder for SessionPersistence. + */ + public static Builder builder() { + return new Builder(); + } + + /** + * Builder. + */ + public static class Builder { + protected Type type; + protected String cookieName; + + /** + * Provides the type to the SessionPersistence's Builder. + * + * @return the Builder. + * @see SessionPersistence#getType() + */ + public Builder type(Type type) { + this.type = type; + return this; + } + + /** + * Provides the cookie name to the SessionPersistence's Builder. + * + * @return the Builder. + * @see SessionPersistence#getCookieName() + */ + public Builder cookieName(String cookieName) { + this.cookieName = cookieName; + return this; + } + + /** + * @return a SessionPersistence constructed with this Builder. + */ + public SessionPersistence build() { + return new SessionPersistence(type, cookieName); + } + } + + /** + * Enumerates supported SessionPersistence types. + */ + public static enum Type { + /** + * All connections that originate from the same source IP address are handled by the same member of the pool. + */ + SOURCE_IP("SOURCE_IP"), + /** + * The load balancing function creates a cookie on the first request from a client. Subsequent requests that + * contain the same cookie value are handled by the same member of the pool. + */ + HTTP_COOKIE("HTTP_COOKIE"), + /** + * The load balancing function relies on a cookie established by the back-end application. All requests with the + * same cookie value are handled by the same member of the pool. + */ + APP_COOKIE("APP_COOKIE"), + /** + * Used by jclouds when the service returns an unknown value other than null. + */ + UNRECOGNIZED("unrecognized"); + + private String name; + + private Type(String name) { + this.name = name; + } + + @Override + public String toString() { + return name; + } + + /* + * This provides GSON enum support in jclouds. + * */ + public static Type fromValue(String name){ + if (name != null) { + for (Type value : Type.values()) { + if (name.equalsIgnoreCase(value.name)) { + return value; + } + } + return UNRECOGNIZED; + } + return null; + } + } +}
