You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jclouds.apache.org by za...@apache.org on 2014/10/02 22:08:18 UTC
[1/5] Support LBaaS v1
Repository: jclouds-labs-openstack
Updated Branches:
refs/heads/master 75572240c -> 0675d2eab
http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/blob/0675d2ea/openstack-neutron/src/test/resources/extension_list_with_lbaas_v1_response.json
----------------------------------------------------------------------
diff --git a/openstack-neutron/src/test/resources/extension_list_with_lbaas_v1_response.json b/openstack-neutron/src/test/resources/extension_list_with_lbaas_v1_response.json
new file mode 100644
index 0000000..9f85e1e
--- /dev/null
+++ b/openstack-neutron/src/test/resources/extension_list_with_lbaas_v1_response.json
@@ -0,0 +1,140 @@
+{
+ "extensions": [
+ {
+ "updated": "2013-01-20T00:00:00-00:00",
+ "name": "Neutron Service Type Management",
+ "links": [],
+ "namespace": "http://docs.openstack.org/ext/neutron/service-type/api/v1.0",
+ "alias": "service-type",
+ "description": "API for retrieving service providers for Neutron advanced services"
+ },
+ {
+ "updated": "2012-10-05T10:00:00-00:00",
+ "name": "security-group",
+ "links": [],
+ "namespace": "http://docs.openstack.org/ext/securitygroups/api/v2.0",
+ "alias": "security-group",
+ "description": "The security groups extension."
+ },
+ {
+ "updated": "2013-02-07T10:00:00-00:00",
+ "name": "L3 Agent Scheduler",
+ "links": [],
+ "namespace": "http://docs.openstack.org/ext/l3_agent_scheduler/api/v1.0",
+ "alias": "l3_agent_scheduler",
+ "description": "Schedule routers among l3 agents"
+ },
+ {
+ "updated": "2013-02-07T10:00:00-00:00",
+ "name": "Loadbalancer Agent Scheduler",
+ "links": [],
+ "namespace": "http://docs.openstack.org/ext/lbaas_agent_scheduler/api/v1.0",
+ "alias": "lbaas_agent_scheduler",
+ "description": "Schedule pools among lbaas agents"
+ },
+ {
+ "updated": "2013-03-28T10:00:00-00:00",
+ "name": "Neutron L3 Configurable external gateway mode",
+ "links": [],
+ "namespace": "http://docs.openstack.org/ext/neutron/ext-gw-mode/api/v1.0",
+ "alias": "ext-gw-mode",
+ "description": "Extension of the router abstraction for specifying whether SNAT should occur on the external gateway"
+ },
+ {
+ "updated": "2014-02-03T10:00:00-00:00",
+ "name": "Port Binding",
+ "links": [],
+ "namespace": "http://docs.openstack.org/ext/binding/api/v1.0",
+ "alias": "binding",
+ "description": "Expose port bindings of a virtual port to external application"
+ },
+ {
+ "updated": "2012-09-07T10:00:00-00:00",
+ "name": "Provider Network",
+ "links": [],
+ "namespace": "http://docs.openstack.org/ext/provider/api/v1.0",
+ "alias": "provider",
+ "description": "Expose mapping of virtual networks to physical networks"
+ },
+ {
+ "updated": "2013-02-03T10:00:00-00:00",
+ "name": "agent",
+ "links": [],
+ "namespace": "http://docs.openstack.org/ext/agent/api/v2.0",
+ "alias": "agent",
+ "description": "The agent management extension."
+ },
+ {
+ "updated": "2012-07-29T10:00:00-00:00",
+ "name": "Quota management support",
+ "links": [],
+ "namespace": "http://docs.openstack.org/network/ext/quotas-sets/api/v2.0",
+ "alias": "quotas",
+ "description": "Expose functions for quotas management per tenant"
+ },
+ {
+ "updated": "2013-02-07T10:00:00-00:00",
+ "name": "DHCP Agent Scheduler",
+ "links": [],
+ "namespace": "http://docs.openstack.org/ext/dhcp_agent_scheduler/api/v1.0",
+ "alias": "dhcp_agent_scheduler",
+ "description": "Schedule networks among dhcp agents"
+ },
+ {
+ "updated": "2013-06-27T10:00:00-00:00",
+ "name": "Multi Provider Network",
+ "links": [],
+ "namespace": "http://docs.openstack.org/ext/multi-provider/api/v1.0",
+ "alias": "multi-provider",
+ "description": "Expose mapping of virtual networks to multiple physical networks"
+ },
+ {
+ "updated": "2013-01-14T10:00:00-00:00",
+ "name": "Neutron external network",
+ "links": [],
+ "namespace": "http://docs.openstack.org/ext/neutron/external_net/api/v1.0",
+ "alias": "external-net",
+ "description": "Adds external network attribute to network resource."
+ },
+ {
+ "updated": "2012-07-20T10:00:00-00:00",
+ "name": "Neutron L3 Router",
+ "links": [],
+ "namespace": "http://docs.openstack.org/ext/neutron/router/api/v1.0",
+ "alias": "router",
+ "description": "Router abstraction for basic L3 forwarding between L2 Neutron networks and access to external networks via a NAT gateway."
+ },
+ {
+ "updated": "2013-07-23T10:00:00-00:00",
+ "name": "Allowed Address Pairs",
+ "links": [],
+ "namespace": "http://docs.openstack.org/ext/allowedaddresspairs/api/v2.0",
+ "alias": "allowed-address-pairs",
+ "description": "Provides allowed address pairs"
+ },
+ {
+ "updated": "2013-03-17T12:00:00-00:00",
+ "name": "Neutron Extra DHCP opts",
+ "links": [],
+ "namespace": "http://docs.openstack.org/ext/neutron/extra_dhcp_opt/api/v1.0",
+ "alias": "extra_dhcp_opt",
+ "description": "Extra options configuration for DHCP. For example PXE boot options to DHCP clients can be specified (e.g. tftp-server, server-ip-address, bootfile-name)"
+ },
+ {
+ "updated": "2012-10-07T10:00:00-00:00",
+ "name": "LoadBalancing service",
+ "links": [],
+ "namespace": "http://wiki.openstack.org/neutron/LBaaS/API_1.0",
+ "alias": "lbaas",
+ "description": "Extension for LoadBalancing service"
+ },
+ {
+ "updated": "2013-02-01T10:00:00-00:00",
+ "name": "Neutron Extra Route",
+ "links": [],
+ "namespace": "http://docs.openstack.org/ext/neutron/extraroutes/api/v1.0",
+ "alias": "extraroute",
+ "description": "Extra routes configuration for L3 router"
+ }
+ ]
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/blob/0675d2ea/openstack-neutron/src/test/resources/extension_list_without_lbaas_v1_response.json
----------------------------------------------------------------------
diff --git a/openstack-neutron/src/test/resources/extension_list_without_lbaas_v1_response.json b/openstack-neutron/src/test/resources/extension_list_without_lbaas_v1_response.json
new file mode 100644
index 0000000..7f4a7c1
--- /dev/null
+++ b/openstack-neutron/src/test/resources/extension_list_without_lbaas_v1_response.json
@@ -0,0 +1,132 @@
+{
+ "extensions": [
+ {
+ "updated": "2013-01-20T00:00:00-00:00",
+ "name": "Neutron Service Type Management",
+ "links": [],
+ "namespace": "http://docs.openstack.org/ext/neutron/service-type/api/v1.0",
+ "alias": "service-type",
+ "description": "API for retrieving service providers for Neutron advanced services"
+ },
+ {
+ "updated": "2012-10-05T10:00:00-00:00",
+ "name": "security-group",
+ "links": [],
+ "namespace": "http://docs.openstack.org/ext/securitygroups/api/v2.0",
+ "alias": "security-group",
+ "description": "The security groups extension."
+ },
+ {
+ "updated": "2013-02-07T10:00:00-00:00",
+ "name": "L3 Agent Scheduler",
+ "links": [],
+ "namespace": "http://docs.openstack.org/ext/l3_agent_scheduler/api/v1.0",
+ "alias": "l3_agent_scheduler",
+ "description": "Schedule routers among l3 agents"
+ },
+ {
+ "updated": "2013-02-07T10:00:00-00:00",
+ "name": "Loadbalancer Agent Scheduler",
+ "links": [],
+ "namespace": "http://docs.openstack.org/ext/lbaas_agent_scheduler/api/v1.0",
+ "alias": "lbaas_agent_scheduler",
+ "description": "Schedule pools among lbaas agents"
+ },
+ {
+ "updated": "2013-03-28T10:00:00-00:00",
+ "name": "Neutron L3 Configurable external gateway mode",
+ "links": [],
+ "namespace": "http://docs.openstack.org/ext/neutron/ext-gw-mode/api/v1.0",
+ "alias": "ext-gw-mode",
+ "description": "Extension of the router abstraction for specifying whether SNAT should occur on the external gateway"
+ },
+ {
+ "updated": "2014-02-03T10:00:00-00:00",
+ "name": "Port Binding",
+ "links": [],
+ "namespace": "http://docs.openstack.org/ext/binding/api/v1.0",
+ "alias": "binding",
+ "description": "Expose port bindings of a virtual port to external application"
+ },
+ {
+ "updated": "2012-09-07T10:00:00-00:00",
+ "name": "Provider Network",
+ "links": [],
+ "namespace": "http://docs.openstack.org/ext/provider/api/v1.0",
+ "alias": "provider",
+ "description": "Expose mapping of virtual networks to physical networks"
+ },
+ {
+ "updated": "2013-02-03T10:00:00-00:00",
+ "name": "agent",
+ "links": [],
+ "namespace": "http://docs.openstack.org/ext/agent/api/v2.0",
+ "alias": "agent",
+ "description": "The agent management extension."
+ },
+ {
+ "updated": "2012-07-29T10:00:00-00:00",
+ "name": "Quota management support",
+ "links": [],
+ "namespace": "http://docs.openstack.org/network/ext/quotas-sets/api/v2.0",
+ "alias": "quotas",
+ "description": "Expose functions for quotas management per tenant"
+ },
+ {
+ "updated": "2013-02-07T10:00:00-00:00",
+ "name": "DHCP Agent Scheduler",
+ "links": [],
+ "namespace": "http://docs.openstack.org/ext/dhcp_agent_scheduler/api/v1.0",
+ "alias": "dhcp_agent_scheduler",
+ "description": "Schedule networks among dhcp agents"
+ },
+ {
+ "updated": "2013-06-27T10:00:00-00:00",
+ "name": "Multi Provider Network",
+ "links": [],
+ "namespace": "http://docs.openstack.org/ext/multi-provider/api/v1.0",
+ "alias": "multi-provider",
+ "description": "Expose mapping of virtual networks to multiple physical networks"
+ },
+ {
+ "updated": "2013-01-14T10:00:00-00:00",
+ "name": "Neutron external network",
+ "links": [],
+ "namespace": "http://docs.openstack.org/ext/neutron/external_net/api/v1.0",
+ "alias": "external-net",
+ "description": "Adds external network attribute to network resource."
+ },
+ {
+ "updated": "2012-07-20T10:00:00-00:00",
+ "name": "Neutron L3 Router",
+ "links": [],
+ "namespace": "http://docs.openstack.org/ext/neutron/router/api/v1.0",
+ "alias": "router",
+ "description": "Router abstraction for basic L3 forwarding between L2 Neutron networks and access to external networks via a NAT gateway."
+ },
+ {
+ "updated": "2013-07-23T10:00:00-00:00",
+ "name": "Allowed Address Pairs",
+ "links": [],
+ "namespace": "http://docs.openstack.org/ext/allowedaddresspairs/api/v2.0",
+ "alias": "allowed-address-pairs",
+ "description": "Provides allowed address pairs"
+ },
+ {
+ "updated": "2013-03-17T12:00:00-00:00",
+ "name": "Neutron Extra DHCP opts",
+ "links": [],
+ "namespace": "http://docs.openstack.org/ext/neutron/extra_dhcp_opt/api/v1.0",
+ "alias": "extra_dhcp_opt",
+ "description": "Extra options configuration for DHCP. For example PXE boot options to DHCP clients can be specified (e.g. tftp-server, server-ip-address, bootfile-name)"
+ },
+ {
+ "updated": "2013-02-01T10:00:00-00:00",
+ "name": "Neutron Extra Route",
+ "links": [],
+ "namespace": "http://docs.openstack.org/ext/neutron/extraroutes/api/v1.0",
+ "alias": "extraroute",
+ "description": "Extra routes configuration for L3 router"
+ }
+ ]
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/blob/0675d2ea/openstack-neutron/src/test/resources/lbaas/v1/health_monitor_create_request.json
----------------------------------------------------------------------
diff --git a/openstack-neutron/src/test/resources/lbaas/v1/health_monitor_create_request.json b/openstack-neutron/src/test/resources/lbaas/v1/health_monitor_create_request.json
new file mode 100644
index 0000000..7d3b6a4
--- /dev/null
+++ b/openstack-neutron/src/test/resources/lbaas/v1/health_monitor_create_request.json
@@ -0,0 +1,8 @@
+{
+ "health_monitor": {
+ "delay": 1,
+ "max_retries": 1,
+ "type": "HTTP",
+ "timeout": 1
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/blob/0675d2ea/openstack-neutron/src/test/resources/lbaas/v1/health_monitor_create_response.json
----------------------------------------------------------------------
diff --git a/openstack-neutron/src/test/resources/lbaas/v1/health_monitor_create_response.json b/openstack-neutron/src/test/resources/lbaas/v1/health_monitor_create_response.json
new file mode 100644
index 0000000..1a0dbce
--- /dev/null
+++ b/openstack-neutron/src/test/resources/lbaas/v1/health_monitor_create_response.json
@@ -0,0 +1,16 @@
+{
+ "health_monitor": {
+ "status": "PENDING_CREATE",
+ "admin_state_up": true,
+ "tenant_id": "4fd44f30292945e481c7b8a0c8908869",
+ "delay": 1,
+ "expected_codes": "200",
+ "max_retries": 1,
+ "http_method": "GET",
+ "timeout": 1,
+ "pools": [],
+ "url_path": "/",
+ "type": "HTTP",
+ "id": "b624decf-d5d3-4c66-9a3d-f047e7786181"
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/blob/0675d2ea/openstack-neutron/src/test/resources/lbaas/v1/health_monitor_get_response.json
----------------------------------------------------------------------
diff --git a/openstack-neutron/src/test/resources/lbaas/v1/health_monitor_get_response.json b/openstack-neutron/src/test/resources/lbaas/v1/health_monitor_get_response.json
new file mode 100644
index 0000000..fc162dc
--- /dev/null
+++ b/openstack-neutron/src/test/resources/lbaas/v1/health_monitor_get_response.json
@@ -0,0 +1,16 @@
+{
+ "health_monitor": {
+ "status": "ACTIVE",
+ "admin_state_up": true,
+ "tenant_id": "4fd44f30292945e481c7b8a0c8908869",
+ "delay": 5,
+ "expected_codes": "200",
+ "max_retries": 2,
+ "http_method": "GET",
+ "timeout": 2,
+ "url_path": "/",
+ "type": "HTTP",
+ "pools": [],
+ "id": "5d4b5228-33b0-4e60-b225-9b727c1a20e7"
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/blob/0675d2ea/openstack-neutron/src/test/resources/lbaas/v1/health_monitor_list_response_paged1.json
----------------------------------------------------------------------
diff --git a/openstack-neutron/src/test/resources/lbaas/v1/health_monitor_list_response_paged1.json b/openstack-neutron/src/test/resources/lbaas/v1/health_monitor_list_response_paged1.json
new file mode 100644
index 0000000..3856187
--- /dev/null
+++ b/openstack-neutron/src/test/resources/lbaas/v1/health_monitor_list_response_paged1.json
@@ -0,0 +1,20 @@
+{
+ "health_monitors": [
+ {
+ "status": "ACTIVE",
+ "admin_state_up": true,
+ "tenant_id": "4fd44f30292945e481c7b8a0c8908869",
+ "delay": 10,
+ "max_retries": 1,
+ "timeout": 1,
+ "type": "PING",
+ "id": "466c8345-28d8-4f84-a246-e04380b0461d"
+ }
+ ],
+ "health_monitors_links": [
+ {
+ "href": "/v2.0/lb/health_monitors.json?marker=396f12f8-521e-4b91-8e21-2e003500433a",
+ "rel": "next"
+ }
+ ]
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/blob/0675d2ea/openstack-neutron/src/test/resources/lbaas/v1/health_monitor_list_response_paged2.json
----------------------------------------------------------------------
diff --git a/openstack-neutron/src/test/resources/lbaas/v1/health_monitor_list_response_paged2.json b/openstack-neutron/src/test/resources/lbaas/v1/health_monitor_list_response_paged2.json
new file mode 100644
index 0000000..703b123
--- /dev/null
+++ b/openstack-neutron/src/test/resources/lbaas/v1/health_monitor_list_response_paged2.json
@@ -0,0 +1,23 @@
+{
+ "health_monitors": [
+ {
+ "status": "ACTIVE",
+ "admin_state_up": true,
+ "tenant_id": "4fd44f30292945e481c7b8a0c8908869",
+ "delay": 5,
+ "expected_codes": "200",
+ "max_retries": 2,
+ "http_method": "GET",
+ "timeout": 2,
+ "url_path": "/",
+ "type": "HTTP",
+ "id": "5d4b5228-33b0-4e60-b225-9b727c1a20e7"
+ }
+ ],
+ "health_monitors_links": [
+ {
+ "href": "/v2.0/lb/health_monitors.json?marker=396f12f8-521e-4b91-8e21-2e003500433a",
+ "rel": "previous"
+ }
+ ]
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/blob/0675d2ea/openstack-neutron/src/test/resources/lbaas/v1/health_monitor_update_request.json
----------------------------------------------------------------------
diff --git a/openstack-neutron/src/test/resources/lbaas/v1/health_monitor_update_request.json b/openstack-neutron/src/test/resources/lbaas/v1/health_monitor_update_request.json
new file mode 100644
index 0000000..cfb9c2e
--- /dev/null
+++ b/openstack-neutron/src/test/resources/lbaas/v1/health_monitor_update_request.json
@@ -0,0 +1,11 @@
+{
+ "health_monitor": {
+ "delay": 1,
+ "max_retries": 1,
+ "timeout": 1,
+ "http_method": "HEAD",
+ "url_path": "/index.html",
+ "expected_codes": "201",
+ "admin_state_up": false
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/blob/0675d2ea/openstack-neutron/src/test/resources/lbaas/v1/health_monitor_update_response.json
----------------------------------------------------------------------
diff --git a/openstack-neutron/src/test/resources/lbaas/v1/health_monitor_update_response.json b/openstack-neutron/src/test/resources/lbaas/v1/health_monitor_update_response.json
new file mode 100644
index 0000000..95bdf43
--- /dev/null
+++ b/openstack-neutron/src/test/resources/lbaas/v1/health_monitor_update_response.json
@@ -0,0 +1,16 @@
+{
+ "health_monitor": {
+ "status": "ACTIVE",
+ "admin_state_up": false,
+ "tenant_id": "4fd44f30292945e481c7b8a0c8908869",
+ "delay": 1,
+ "expected_codes": "201",
+ "max_retries": 1,
+ "http_method": "HEAD",
+ "timeout": 1,
+ "pools": [],
+ "url_path": "/index.html",
+ "type": "HTTP",
+ "id": "466c8345-28d8-4f84-a246-e04380b0461d"
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/blob/0675d2ea/openstack-neutron/src/test/resources/lbaas/v1/member_create_request.json
----------------------------------------------------------------------
diff --git a/openstack-neutron/src/test/resources/lbaas/v1/member_create_request.json b/openstack-neutron/src/test/resources/lbaas/v1/member_create_request.json
new file mode 100644
index 0000000..20645b8
--- /dev/null
+++ b/openstack-neutron/src/test/resources/lbaas/v1/member_create_request.json
@@ -0,0 +1,6 @@
+{
+ "member": {
+ "protocol_port": 80,
+ "pool_id": "72741b06-df4d-4715-b142-276b6bce75ab"
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/blob/0675d2ea/openstack-neutron/src/test/resources/lbaas/v1/member_create_response.json
----------------------------------------------------------------------
diff --git a/openstack-neutron/src/test/resources/lbaas/v1/member_create_response.json b/openstack-neutron/src/test/resources/lbaas/v1/member_create_response.json
new file mode 100644
index 0000000..cb74c42
--- /dev/null
+++ b/openstack-neutron/src/test/resources/lbaas/v1/member_create_response.json
@@ -0,0 +1,12 @@
+{
+ "member": {
+ "status": "PENDING_CREATE",
+ "protocol_port": 80,
+ "weight": 1,
+ "admin_state_up": true,
+ "tenant_id": "83657cfcdfe44cd5920adaf26c48ceea",
+ "pool_id": "72741b06-df4d-4715-b142-276b6bce75ab",
+ "address": "10.0.0.5",
+ "id":"48a471ea-64f1-4eb6-9be7-dae6bbe40a0f"
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/blob/0675d2ea/openstack-neutron/src/test/resources/lbaas/v1/member_get_response.json
----------------------------------------------------------------------
diff --git a/openstack-neutron/src/test/resources/lbaas/v1/member_get_response.json b/openstack-neutron/src/test/resources/lbaas/v1/member_get_response.json
new file mode 100644
index 0000000..a7302b3
--- /dev/null
+++ b/openstack-neutron/src/test/resources/lbaas/v1/member_get_response.json
@@ -0,0 +1,12 @@
+{
+ "member": {
+ "status": "ACTIVE",
+ "protocol_port": 80,
+ "weight": 1,
+ "admin_state_up": true,
+ "tenant_id": "83657cfcdfe44cd5920adaf26c48ceea",
+ "pool_id": "72741b06-df4d-4715-b142-276b6bce75ab",
+ "address": "10.0.0.5",
+ "id":"48a471ea-64f1-4eb6-9be7-dae6bbe40a0f"
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/blob/0675d2ea/openstack-neutron/src/test/resources/lbaas/v1/member_list_response_paged1.json
----------------------------------------------------------------------
diff --git a/openstack-neutron/src/test/resources/lbaas/v1/member_list_response_paged1.json b/openstack-neutron/src/test/resources/lbaas/v1/member_list_response_paged1.json
new file mode 100644
index 0000000..b793ad4
--- /dev/null
+++ b/openstack-neutron/src/test/resources/lbaas/v1/member_list_response_paged1.json
@@ -0,0 +1,20 @@
+{
+ "members": [
+ {
+ "status": "ACTIVE",
+ "protocol_port": 80,
+ "weight": 1,
+ "admin_state_up": true,
+ "tenant_id": "83657cfcdfe44cd5920adaf26c48ceea",
+ "pool_id": "72741b06-df4d-4715-b142-276b6bce75ab",
+ "address": "10.0.0.5",
+ "id":"48a471ea-64f1-4eb6-9be7-dae6bbe40a0f"
+ }
+ ],
+ "members_links": [
+ {
+ "href": "/v2.0/lb/members.json?marker=396f12f8-521e-4b91-8e21-2e003500433a",
+ "rel": "next"
+ }
+ ]
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/blob/0675d2ea/openstack-neutron/src/test/resources/lbaas/v1/member_list_response_paged2.json
----------------------------------------------------------------------
diff --git a/openstack-neutron/src/test/resources/lbaas/v1/member_list_response_paged2.json b/openstack-neutron/src/test/resources/lbaas/v1/member_list_response_paged2.json
new file mode 100644
index 0000000..c707ae4
--- /dev/null
+++ b/openstack-neutron/src/test/resources/lbaas/v1/member_list_response_paged2.json
@@ -0,0 +1,20 @@
+{
+ "members": [
+ {
+ "status": "ACTIVE",
+ "protocol_port": 80,
+ "weight": 1,
+ "admin_state_up": true,
+ "tenant_id": "83657cfcdfe44cd5920adaf26c48ceea",
+ "pool_id": "72741b06-df4d-4715-b142-276b6bce75ab",
+ "address": "10.0.0.5",
+ "id":"701b531b-111a-4f21-ad85-4795b7b12af6"
+ }
+ ],
+ "members_links": [
+ {
+ "href": "/v2.0/lb/members.json?marker=86ae12f8-521e-4b91-8e21-2e0035005fdc",
+ "rel": "previous"
+ }
+ ]
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/blob/0675d2ea/openstack-neutron/src/test/resources/lbaas/v1/member_update_request.json
----------------------------------------------------------------------
diff --git a/openstack-neutron/src/test/resources/lbaas/v1/member_update_request.json b/openstack-neutron/src/test/resources/lbaas/v1/member_update_request.json
new file mode 100644
index 0000000..4d7ac67
--- /dev/null
+++ b/openstack-neutron/src/test/resources/lbaas/v1/member_update_request.json
@@ -0,0 +1,7 @@
+{
+ "member": {
+ "weight": 2,
+ "admin_state_up": false,
+ "pool_id": "new_pool_id"
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/blob/0675d2ea/openstack-neutron/src/test/resources/lbaas/v1/member_update_response.json
----------------------------------------------------------------------
diff --git a/openstack-neutron/src/test/resources/lbaas/v1/member_update_response.json b/openstack-neutron/src/test/resources/lbaas/v1/member_update_response.json
new file mode 100644
index 0000000..1d14b9e
--- /dev/null
+++ b/openstack-neutron/src/test/resources/lbaas/v1/member_update_response.json
@@ -0,0 +1,12 @@
+{
+ "member": {
+ "status": "ACTIVE",
+ "protocol_port": 80,
+ "weight": 2,
+ "admin_state_up": false,
+ "tenant_id": "83657cfcdfe44cd5920adaf26c48ceea",
+ "pool_id": "new_pool_id",
+ "address": "10.0.0.5",
+ "id":"48a471ea-64f1-4eb6-9be7-dae6bbe40a0f"
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/blob/0675d2ea/openstack-neutron/src/test/resources/lbaas/v1/pool_associate_health_monitor_request.json
----------------------------------------------------------------------
diff --git a/openstack-neutron/src/test/resources/lbaas/v1/pool_associate_health_monitor_request.json b/openstack-neutron/src/test/resources/lbaas/v1/pool_associate_health_monitor_request.json
new file mode 100644
index 0000000..c3b2dd4
--- /dev/null
+++ b/openstack-neutron/src/test/resources/lbaas/v1/pool_associate_health_monitor_request.json
@@ -0,0 +1,5 @@
+{
+ "health_monitor": {
+ "id":"5d4b5228-33b0-4e60-b225-9b727c1a20e7"
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/blob/0675d2ea/openstack-neutron/src/test/resources/lbaas/v1/pool_associate_health_monitor_response.json
----------------------------------------------------------------------
diff --git a/openstack-neutron/src/test/resources/lbaas/v1/pool_associate_health_monitor_response.json b/openstack-neutron/src/test/resources/lbaas/v1/pool_associate_health_monitor_response.json
new file mode 100644
index 0000000..3e0459d
--- /dev/null
+++ b/openstack-neutron/src/test/resources/lbaas/v1/pool_associate_health_monitor_response.json
@@ -0,0 +1,4 @@
+{
+ "health_monitor": {
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/blob/0675d2ea/openstack-neutron/src/test/resources/lbaas/v1/pool_create_request.json
----------------------------------------------------------------------
diff --git a/openstack-neutron/src/test/resources/lbaas/v1/pool_create_request.json b/openstack-neutron/src/test/resources/lbaas/v1/pool_create_request.json
new file mode 100644
index 0000000..077a14b
--- /dev/null
+++ b/openstack-neutron/src/test/resources/lbaas/v1/pool_create_request.json
@@ -0,0 +1,8 @@
+{
+ "pool": {
+ "subnet_id":"8032909d-47a1-4715-90af-5153ffe39861",
+ "lb_method":"ROUND_ROBIN",
+ "protocol":"TCP",
+ "name":"NewPool"
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/blob/0675d2ea/openstack-neutron/src/test/resources/lbaas/v1/pool_create_response.json
----------------------------------------------------------------------
diff --git a/openstack-neutron/src/test/resources/lbaas/v1/pool_create_response.json b/openstack-neutron/src/test/resources/lbaas/v1/pool_create_response.json
new file mode 100644
index 0000000..3cc5cf7
--- /dev/null
+++ b/openstack-neutron/src/test/resources/lbaas/v1/pool_create_response.json
@@ -0,0 +1,18 @@
+{
+ "pool": {
+ "status": "PENDING_CREATE",
+ "lb_method": "ROUND_ROBIN",
+ "protocol": "TCP",
+ "provider": "HAPROXY",
+ "description": "",
+ "health_monitors": [],
+ "health_monitors_status": [],
+ "subnet_id": "8032909d-47a1-4715-90af-5153ffe39861",
+ "tenant_id": "83657cfcdfe44cd5920adaf26c48ceea",
+ "admin_state_up": true,
+ "name": "NewPool",
+ "members": [],
+ "id": "a224402b-794b-4c0c-9d08-d95640a6f5a1",
+ "vip_id": null
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/blob/0675d2ea/openstack-neutron/src/test/resources/lbaas/v1/pool_get_response.json
----------------------------------------------------------------------
diff --git a/openstack-neutron/src/test/resources/lbaas/v1/pool_get_response.json b/openstack-neutron/src/test/resources/lbaas/v1/pool_get_response.json
new file mode 100644
index 0000000..00ecef5
--- /dev/null
+++ b/openstack-neutron/src/test/resources/lbaas/v1/pool_get_response.json
@@ -0,0 +1,35 @@
+{
+ "pool": {
+ "status": "ACTIVE",
+ "lb_method": "ROUND_ROBIN",
+ "protocol": "HTTP",
+ "provider": "HAPROXY",
+ "description": "",
+ "health_monitors": [
+ "466c8345-28d8-4f84-a246-e04380b0461d",
+ "5d4b5228-33b0-4e60-b225-9b727c1a20e7"
+ ],
+ "health_monitors_status": [
+ {
+ "status": "ACTIVE",
+ "monitor_id": "466c8345-28d8-4f84-a246-e04380b0461d",
+ "status_dezcription": null
+ },
+ {
+ "status": "ACTIVE",
+ "monitor_id": "5d4b5228-33b0-4e60-b225-9b727c1a20e7",
+ "status_dezcription": null
+ }
+ ],
+ "subnet_id": "8032909d-47a1-4715-90af-5153ffe39861",
+ "tenant_id": "83657cfcdfe44cd5920adaf26c48ceea",
+ "admin_state_up": true,
+ "name": "app_pool",
+ "members": [
+ "701b531b-111a-4f21-ad85-4795b7b12af6",
+ "beb53b4d-230b-4abd-8118-575b8fa006ef"
+ ],
+ "id": "72741b06-df4d-4715-b142-276b6bce75ab",
+ "vip_id": "4ec89087-d057-4e2c-911f-60a3b47ee304"
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/blob/0675d2ea/openstack-neutron/src/test/resources/lbaas/v1/pool_list_response_paged1.json
----------------------------------------------------------------------
diff --git a/openstack-neutron/src/test/resources/lbaas/v1/pool_list_response_paged1.json b/openstack-neutron/src/test/resources/lbaas/v1/pool_list_response_paged1.json
new file mode 100644
index 0000000..b10ce38
--- /dev/null
+++ b/openstack-neutron/src/test/resources/lbaas/v1/pool_list_response_paged1.json
@@ -0,0 +1,46 @@
+{
+ "pools": [
+ {
+ "status": "ACTIVE",
+ "lb_method": "ROUND_ROBIN",
+ "protocol": "HTTP",
+ "description": "",
+ "health_monitors": [
+ "466c8345-28d8-4f84-a246-e04380b0461d",
+ "5d4b5228-33b0-4e60-b225-9b727c1a20e7"
+ ],
+ "health_monitors_status": [
+ {
+ "status": "ACTIVE",
+ "monitor_id": "466c8345-28d8-4f84-a246-e04380b0461d",
+ "status_dezcription": null
+ },
+ {
+ "status": "ACTIVE",
+ "monitor_id": "5d4b5228-33b0-4e60-b225-9b727c1a20e7",
+ "status_dezcription": null
+ }
+ ],
+ "subnet_id": "8032909d-47a1-4715-90af-5153ffe39861",
+ "tenant_id": "83657cfcdfe44cd5920adaf26c48ceea",
+ "admin_state_up": true,
+ "name": "app_pool",
+ "members": [
+ "701b531b-111a-4f21-ad85-4795b7b12af6",
+ "beb53b4d-230b-4abd-8118-575b8fa006ef"
+ ],
+ "id":"72741b06-df4d-4715-b142-276b6bce75ab",
+ "vip_id":"4ec89087-d057-4e2c-911f-60a3b47ee304"
+ }
+ ],
+ "pools_links": [
+ {
+ "href": "/v2.0/lb/pools.json?marker=71c1e68c-171a-4aa2-aca5-50ea153a3718",
+ "rel": "next"
+ },
+ {
+ "href": "/v2.0/lb/pools.json?marker=396f12f8-521e-4b91-8e21-2e003500433a&page_reverse=True",
+ "rel": "previous"
+ }
+ ]
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/blob/0675d2ea/openstack-neutron/src/test/resources/lbaas/v1/pool_list_response_paged2.json
----------------------------------------------------------------------
diff --git a/openstack-neutron/src/test/resources/lbaas/v1/pool_list_response_paged2.json b/openstack-neutron/src/test/resources/lbaas/v1/pool_list_response_paged2.json
new file mode 100644
index 0000000..dbe902e
--- /dev/null
+++ b/openstack-neutron/src/test/resources/lbaas/v1/pool_list_response_paged2.json
@@ -0,0 +1,42 @@
+{
+ "pools": [
+ {
+ "status": "ACTIVE",
+ "lb_method": "ROUND_ROBIN",
+ "protocol": "TCP",
+ "description": "",
+ "health_monitors": [
+ "466c8345-28d8-4f84-a246-e04380b0461d",
+ "5d4b5228-33b0-4e60-b225-9b727c1a20e7"
+ ],
+ "health_monitors_status": [
+ {
+ "status": "ACTIVE",
+ "monitor_id": "466c8345-28d8-4f84-a246-e04380b0461d",
+ "status_dezcription": null
+ },
+ {
+ "status": "ACTIVE",
+ "monitor_id": "5d4b5228-33b0-4e60-b225-9b727c1a20e7",
+ "status_dezcription": null
+ }
+ ],
+ "subnet_id": "8032909d-47a1-4715-90af-5153ffe39861",
+ "tenant_id": "83657cfcdfe44cd5920adaf26c48ceea",
+ "admin_state_up": true,
+ "name": "app_pool2",
+ "members": [
+ "701b531b-111a-4f21-ad85-4795b7b12af6",
+ "beb53b4d-230b-4abd-8118-575b8fa006ef"
+ ],
+ "id":"72741b06-df4d-4715-b142-276b6bce75ab_2",
+ "vip_id":"4ec89087-d057-4e2c-911f-60a3b47ee304"
+ }
+ ],
+ "pools_links": [
+ {
+ "href": "/v2.0/lb/pools.json?marker=396f12f8-521e-4b91-8e21-2e003500433a&page_reverse=True",
+ "rel": "previous"
+ }
+ ]
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/blob/0675d2ea/openstack-neutron/src/test/resources/lbaas/v1/pool_update_request.json
----------------------------------------------------------------------
diff --git a/openstack-neutron/src/test/resources/lbaas/v1/pool_update_request.json b/openstack-neutron/src/test/resources/lbaas/v1/pool_update_request.json
new file mode 100644
index 0000000..a54b680
--- /dev/null
+++ b/openstack-neutron/src/test/resources/lbaas/v1/pool_update_request.json
@@ -0,0 +1,11 @@
+{
+ "pool": {
+ "name": "new_name",
+ "description": "new description",
+ "lb_method": "NEW_LB_METHOD",
+ "health_monitors": [
+ "5d4b5228-33b0-4e60-b225-9b727c1a20e7"
+ ],
+ "admin_state_up": false
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/blob/0675d2ea/openstack-neutron/src/test/resources/lbaas/v1/pool_update_response.json
----------------------------------------------------------------------
diff --git a/openstack-neutron/src/test/resources/lbaas/v1/pool_update_response.json b/openstack-neutron/src/test/resources/lbaas/v1/pool_update_response.json
new file mode 100644
index 0000000..9159529
--- /dev/null
+++ b/openstack-neutron/src/test/resources/lbaas/v1/pool_update_response.json
@@ -0,0 +1,29 @@
+{
+ "pool": {
+ "status": "ACTIVE",
+ "lb_method":"NEW_LB_METHOD",
+ "protocol": "HTTP",
+ "provider": "HAPROXY",
+ "description": "new description",
+ "health_monitors": [
+ "5d4b5228-33b0-4e60-b225-9b727c1a20e7"
+ ],
+ "health_monitors_status": [
+ {
+ "status": "ACTIVE",
+ "monitor_id": "5d4b5228-33b0-4e60-b225-9b727c1a20e7",
+ "status_dezcription": null
+ }
+ ],
+ "subnet_id": "8032909d-47a1-4715-90af-5153ffe39861",
+ "tenant_id": "83657cfcdfe44cd5920adaf26c48ceea",
+ "admin_state_up": false,
+ "name": "new_name",
+ "members": [
+ "701b531b-111a-4f21-ad85-4795b7b12af6",
+ "beb53b4d-230b-4abd-8118-575b8fa006ef"
+ ],
+ "id": "72741b06-df4d-4715-b142-276b6bce75ab",
+ "vip_id": "4ec89087-d057-4e2c-911f-60a3b47ee304"
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/blob/0675d2ea/openstack-neutron/src/test/resources/lbaas/v1/vip_create_request.json
----------------------------------------------------------------------
diff --git a/openstack-neutron/src/test/resources/lbaas/v1/vip_create_request.json b/openstack-neutron/src/test/resources/lbaas/v1/vip_create_request.json
new file mode 100644
index 0000000..6d159e1
--- /dev/null
+++ b/openstack-neutron/src/test/resources/lbaas/v1/vip_create_request.json
@@ -0,0 +1,9 @@
+{
+ "vip": {
+ "protocol": "HTTP",
+ "name": "NewVip",
+ "subnet_id": "8032909d-47a1-4715-90af-5153ffe39861",
+ "pool_id": "61b1f87a-7a21-4ad3-9dda-7f81d249944f",
+ "protocol_port":80
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/blob/0675d2ea/openstack-neutron/src/test/resources/lbaas/v1/vip_create_response.json
----------------------------------------------------------------------
diff --git a/openstack-neutron/src/test/resources/lbaas/v1/vip_create_response.json b/openstack-neutron/src/test/resources/lbaas/v1/vip_create_response.json
new file mode 100644
index 0000000..7dc958c
--- /dev/null
+++ b/openstack-neutron/src/test/resources/lbaas/v1/vip_create_response.json
@@ -0,0 +1,17 @@
+{
+ "vip": {
+ "status": "PENDING_CREATE",
+ "protocol": "HTTP",
+ "description": "",
+ "admin_state_up": true,
+ "subnet_id": "8032909d-47a1-4715-90af-5153ffe39861",
+ "tenant_id": "83657cfcdfe44cd5920adaf26c48ceea",
+ "connection_limit": -1,
+ "pool_id": "61b1f87a-7a21-4ad3-9dda-7f81d249944f",
+ "address": "10.0.0.11",
+ "protocol_port": 80,
+ "port_id": "f7e6fe6a-b8b5-43a8-8215-73456b32e0f5",
+ "id": "c987d2be-9a3c-4ac9-a046-e8716b1350e2",
+ "name": "NewVip"
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/blob/0675d2ea/openstack-neutron/src/test/resources/lbaas/v1/vip_get_response.json
----------------------------------------------------------------------
diff --git a/openstack-neutron/src/test/resources/lbaas/v1/vip_get_response.json b/openstack-neutron/src/test/resources/lbaas/v1/vip_get_response.json
new file mode 100644
index 0000000..c237b39
--- /dev/null
+++ b/openstack-neutron/src/test/resources/lbaas/v1/vip_get_response.json
@@ -0,0 +1,21 @@
+{
+ "vip": {
+ "status": "ACTIVE",
+ "protocol": "HTTP",
+ "description": "",
+ "admin_state_up": true,
+ "subnet_id": "8032909d-47a1-4715-90af-5153ffe39861",
+ "tenant_id": "83657cfcdfe44cd5920adaf26c48ceea",
+ "connection_limit": 1000,
+ "pool_id": "72741b06-df4d-4715-b142-276b6bce75ab",
+ "session_persistence": {
+ "cookie_name": "MyAppCookie",
+ "type": "APP_COOKIE"
+ },
+ "address": "10.0.0.10",
+ "protocol_port": 80,
+ "port_id": "b5a743d6-056b-468b-862d-fb13a9aa694e",
+ "id": "4ec89087-d057-4e2c-911f-60a3b47ee304",
+ "name": "my-vip"
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/blob/0675d2ea/openstack-neutron/src/test/resources/lbaas/v1/vip_list_response_paged1.json
----------------------------------------------------------------------
diff --git a/openstack-neutron/src/test/resources/lbaas/v1/vip_list_response_paged1.json b/openstack-neutron/src/test/resources/lbaas/v1/vip_list_response_paged1.json
new file mode 100644
index 0000000..eaabe2c
--- /dev/null
+++ b/openstack-neutron/src/test/resources/lbaas/v1/vip_list_response_paged1.json
@@ -0,0 +1,29 @@
+{
+ "vips": [
+ {
+ "status": "ACTIVE",
+ "protocol": "HTTP",
+ "description": "",
+ "admin_state_up": true,
+ "subnet_id": "8032909d-47a1-4715-90af-5153ffe39861",
+ "tenant_id": "83657cfcdfe44cd5920adaf26c48ceea",
+ "connection_limit": 1000,
+ "pool_id": "72741b06-df4d-4715-b142-276b6bce75ab",
+ "session_persistence": {
+ "cookie_name": "MyAppCookie",
+ "type": "APP_COOKIE"
+ },
+ "address": "10.0.0.10",
+ "protocol_port": 80,
+ "port_id": "b5a743d6-056b-468b-862d-fb13a9aa694e",
+ "id": "4ec89087-d057-4e2c-911f-60a3b47ee304",
+ "name": "my-vip1"
+ }
+ ],
+ "vips_links": [
+ {
+ "href": "/v2.0/lb/vips.json?marker=396f12f8-521e-4b91-8e21-2e003500433a",
+ "rel": "next"
+ }
+ ]
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/blob/0675d2ea/openstack-neutron/src/test/resources/lbaas/v1/vip_list_response_paged2.json
----------------------------------------------------------------------
diff --git a/openstack-neutron/src/test/resources/lbaas/v1/vip_list_response_paged2.json b/openstack-neutron/src/test/resources/lbaas/v1/vip_list_response_paged2.json
new file mode 100644
index 0000000..74c46a9
--- /dev/null
+++ b/openstack-neutron/src/test/resources/lbaas/v1/vip_list_response_paged2.json
@@ -0,0 +1,29 @@
+{
+ "vips": [
+ {
+ "status": "ACTIVE",
+ "protocol": "HTTPS",
+ "description": "",
+ "admin_state_up": true,
+ "subnet_id": "8032909d-47a1-4715-90af-5153ffe39861",
+ "tenant_id": "83657cfcdfe44cd5920adaf26c48ceea",
+ "connection_limit": 100,
+ "pool_id": "61b1f87a-7a21-4ad3-9dda-7f81d249944f",
+ "session_persistence": {
+ "cookie_name": null,
+ "type": "HTTP_COOKIE"
+ },
+ "address": "10.0.0.11",
+ "protocol_port": 80,
+ "port_id": "f7e6fe6a-b8b5-43a8-8215-73456b32e0f5",
+ "id": "c987d2be-9a3c-4ac9-a046-e8716b1350e2",
+ "name": "my-vip2"
+ }
+ ],
+ "vips_links": [
+ {
+ "href": "/v2.0/lb/vips.json?marker=ABCDEFf8-521e-4b91-8e21-2e003500433a",
+ "rel": "previous"
+ }
+ ]
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/blob/0675d2ea/openstack-neutron/src/test/resources/lbaas/v1/vip_update_request.json
----------------------------------------------------------------------
diff --git a/openstack-neutron/src/test/resources/lbaas/v1/vip_update_request.json b/openstack-neutron/src/test/resources/lbaas/v1/vip_update_request.json
new file mode 100644
index 0000000..8d185a3
--- /dev/null
+++ b/openstack-neutron/src/test/resources/lbaas/v1/vip_update_request.json
@@ -0,0 +1,13 @@
+{
+ "vip": {
+ "name": "new-name",
+ "description": "new description",
+ "pool_id": "61b1f87a-7a21-4ad3-9dda-7f81d249944f",
+ "session_persistence": {
+ "cookie_name": "MyNewAppCookie",
+ "type": "APP_COOKIE"
+ },
+ "connection_limit": 50,
+ "admin_state_up": false
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/blob/0675d2ea/openstack-neutron/src/test/resources/lbaas/v1/vip_update_response.json
----------------------------------------------------------------------
diff --git a/openstack-neutron/src/test/resources/lbaas/v1/vip_update_response.json b/openstack-neutron/src/test/resources/lbaas/v1/vip_update_response.json
new file mode 100644
index 0000000..1502be2
--- /dev/null
+++ b/openstack-neutron/src/test/resources/lbaas/v1/vip_update_response.json
@@ -0,0 +1,21 @@
+{
+ "vip": {
+ "status": "PENDING_UPDATE",
+ "protocol": "HTTP",
+ "description": "new description",
+ "admin_state_up": false,
+ "subnet_id": "8032909d-47a1-4715-90af-5153ffe39861",
+ "tenant_id": "83657cfcdfe44cd5920adaf26c48ceea",
+ "connection_limit": 50,
+ "pool_id": "61b1f87a-7a21-4ad3-9dda-7f81d249944f",
+ "session_persistence": {
+ "cookie_name": "MyNewAppCookie",
+ "type": "APP_COOKIE"
+ },
+ "address": "10.0.0.11",
+ "protocol_port": 80,
+ "port_id": "f7e6fe6a-b8b5-43a8-8215-73456b32e0f5",
+ "id": "c987d2be-9a3c-4ac9-a046-e8716b1350e2",
+ "name": "new-name"
+ }
+}
[4/5] Support LBaaS v1
Posted by za...@apache.org.
http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/blob/0675d2ea/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/VIP.java
----------------------------------------------------------------------
diff --git a/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/VIP.java b/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/VIP.java
new file mode 100644
index 0000000..d3539a9
--- /dev/null
+++ b/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/VIP.java
@@ -0,0 +1,493 @@
+/*
+ * 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 VIP.
+ */
+public class VIP {
+
+ // Mandatory attributes when creating
+ @Named("tenant_id")
+ private String tenantId;
+ @Named("subnet_id")
+ private String subnetId;
+ private Protocol protocol;
+ @Named("protocol_port")
+ private Integer protocolPort;
+ // Mandatory attributes that can be updated
+ @Named("pool_id")
+ private String poolId;
+ // Optional attributes when creating
+ private String address;
+ // Optional attributes that can be updated
+ private String name;
+ private String description;
+ @Named("session_persistence")
+ private SessionPersistence sessionPersistence;
+ @Named("connection_limit")
+ private Integer connectionLimit;
+ @Named("admin_state_up")
+ private Boolean adminStateUp;
+ // Read-only attributes
+ private String id;
+ @Named("port_id")
+ private String portId;
+ private LBaaSStatus status;
+ @Named("status_description")
+ private String statusDescription;
+
+ /**
+ * Deserialization constructor.
+ */
+ @ConstructorProperties({ "id", "tenant_id", "name", "description", "subnet_id", "address", "port_id", "protocol",
+ "protocol_port", "pool_id", "session_persistence", "connection_limit", "admin_state_up", "status",
+ "status_description" })
+ private VIP(String id, String tenantId, String name, String description, String subnetId, String address,
+ String portId, Protocol protocol, Integer protocolPort, String poolId, SessionPersistence sessionPersistence,
+ Integer connectionLimit, Boolean adminStateUp, LBaaSStatus status, String statusDescription) {
+ this.id = id;
+ this.tenantId = tenantId;
+ this.name = name;
+ this.description = description;
+ this.subnetId = subnetId;
+ this.address = address;
+ this.portId = portId;
+ this.protocol = protocol;
+ this.protocolPort = protocolPort;
+ this.poolId = poolId;
+ this.sessionPersistence = sessionPersistence;
+ this.connectionLimit = connectionLimit;
+ this.adminStateUp = adminStateUp;
+ this.status = status;
+ this.statusDescription = statusDescription;
+ }
+
+ /**
+ * Default constructor.
+ */
+ private VIP() {
+ }
+
+ /**
+ * Copy constructor.
+ *
+ * @param VIP the VIP to copy from.
+ */
+ private VIP(VIP vip) {
+ this(vip.id, vip.tenantId, vip.name, vip.description, vip.subnetId, vip.address, vip.portId, vip.protocol,
+ vip.protocolPort, vip.poolId, vip.sessionPersistence, vip.connectionLimit, vip.adminStateUp, vip.status,
+ vip.statusDescription);
+ }
+
+ /**
+ * @return the id of the VIP.
+ */
+ @Nullable
+ public String getId() {
+ return id;
+ }
+
+ /**
+ * @return the tenant id of the VIP.
+ */
+ @Nullable
+ public String getTenantId() {
+ return tenantId;
+ }
+
+ /**
+ * @return the name of the VIP.
+ */
+ @Nullable
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * @return the description of the VIP.
+ */
+ @Nullable
+ public String getDescription() {
+ return description;
+ }
+
+ /**
+ * @return the subnet id for this VIP.
+ */
+ @Nullable
+ public String getSubnetId() {
+ return subnetId;
+ }
+
+ /**
+ * @return the address for this VIP.
+ */
+ @Nullable
+ public String getAddress() {
+ return address;
+ }
+
+ /**
+ * @return the port id for this VIP.
+ */
+ @Nullable
+ public String getPortId() {
+ return portId;
+ }
+
+ /**
+ * @return the protocol for this VIP.
+ */
+ @Nullable
+ public Protocol getProtocol() {
+ return protocol;
+ }
+
+ /**
+ * @return the protocol port for this VIP.
+ */
+ @Nullable
+ public Integer getProtocolPort() {
+ return protocolPort;
+ }
+
+ /**
+ * @return the pool id for this VIP.
+ */
+ @Nullable
+ public String getPoolId() {
+ return poolId;
+ }
+
+ /**
+ * @return the session persistence for this VIP.
+ */
+ @Nullable
+ public SessionPersistence getSessionPersistence() {
+ return sessionPersistence;
+ }
+
+ /**
+ * @return the connection limit for this VIP.
+ */
+ @Nullable
+ public Integer getConnectionLimit() {
+ return connectionLimit;
+ }
+
+ /**
+ * @return the administrative state for this VIP.
+ */
+ @Nullable
+ public Boolean getAdminStateUp() {
+ return adminStateUp;
+ }
+
+ /**
+ * @return the status for this VIP.
+ */
+ @Nullable
+ public LBaaSStatus getStatus() {
+ return status;
+ }
+
+ /**
+ * @return the status description for this VIP.
+ */
+ @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;
+
+ VIP that = (VIP) o;
+
+ 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.subnetId, that.subnetId) && Objects.equal(this.address, that.address)
+ && Objects.equal(this.portId, that.portId) && Objects.equal(this.protocol, that.protocol)
+ && Objects.equal(this.protocolPort, that.protocolPort) && Objects.equal(this.poolId, that.poolId)
+ && Objects.equal(this.sessionPersistence, that.sessionPersistence)
+ && Objects.equal(this.connectionLimit, that.connectionLimit)
+ && 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, name, description, subnetId, address, portId, protocol, protocolPort,
+ poolId, sessionPersistence, connectionLimit, adminStateUp, status, statusDescription);
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(this).add("id", id).add("tenantId", tenantId).add("name", name)
+ .add("description", description).add("subnetId", subnetId).add("address", address).add("portId", portId)
+ .add("protocol", protocol).add("protocolPort", protocolPort).add("poolId", poolId)
+ .add("sessionPersistence", sessionPersistence).add("connectionLimit", connectionLimit)
+ .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 VIP.
+ */
+ public static CreateBuilder createBuilder(String subnetId, Protocol protocol, Integer port, String poolId) {
+ return new CreateBuilder(subnetId, protocol, port, poolId);
+ }
+
+ /**
+ * @return the Builder for updating a VIP.
+ */
+ public static UpdateBuilder updateBuilder() {
+ return new UpdateBuilder();
+ }
+
+ private abstract static class Builder<ParameterizedBuilderType> {
+ protected VIP vip;
+
+ /**
+ * Default constructor.
+ */
+ private Builder() {
+ vip = new VIP();
+ }
+
+ protected abstract ParameterizedBuilderType self();
+
+ /**
+ * Provides the name for this VIP's Builder.
+ *
+ * @return the Builder.
+ * @see VIP#getName()
+ */
+ public ParameterizedBuilderType name(String name) {
+ vip.name = name;
+ return self();
+ }
+
+ /**
+ * Provides the description for this VIP's Builder.
+ *
+ * @return the Builder.
+ * @see VIP#getDescription()
+ */
+ public ParameterizedBuilderType description(String description) {
+ vip.description = description;
+ return self();
+ }
+
+ /**
+ * Provides the pool id for this VIP's Builder.
+ *
+ * @return the Builder.
+ * @see VIP#getPoolId()
+ */
+ public ParameterizedBuilderType poolId(String poolId) {
+ vip.poolId = poolId;
+ return self();
+ }
+
+ /**
+ * Provides the session persistence for this VIP's Builder.
+ *
+ * @return the Builder.
+ * @see VIP#getSessionPersistence()
+ */
+ public ParameterizedBuilderType sessionPersistence(SessionPersistence sessionPersistence) {
+ vip.sessionPersistence = sessionPersistence;
+ return self();
+ }
+
+ /**
+ * Provides the connection limit for this VIP's Builder.
+ *
+ * @return the Builder.
+ * @see VIP#getConnectionLimit()
+ */
+ public ParameterizedBuilderType connectionLimit(Integer connectionLimit) {
+ vip.connectionLimit = connectionLimit;
+ return self();
+ }
+
+ /**
+ * Provides the administrative state for this VIP's Builder.
+ *
+ * @return the Builder.
+ * @see VIP#getAdminStateUp()
+ */
+ public ParameterizedBuilderType adminStateUp(Boolean adminStateUp) {
+ vip.adminStateUp = adminStateUp;
+ return self();
+ }
+ }
+
+ /**
+ * Create builder (inheriting from Builder).
+ */
+ public static class CreateBuilder extends Builder<CreateBuilder> {
+ /**
+ * Supply required properties for creating a VIP's CreateBuilder
+ */
+ private CreateBuilder(String subnetId, Protocol protocol, Integer port, String poolId) {
+ subnetId(subnetId).protocol(protocol).protocolPort(port).poolId(poolId);
+ }
+
+ /**
+ * Provides the tenantId for this VIP'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 VIP#getTenantId()
+ */
+ public CreateBuilder tenantId(String tenantId) {
+ vip.tenantId = tenantId;
+ return self();
+ }
+
+ /**
+ * Provides the subnet id for this VIP's Builder.
+ *
+ * @return the Builder.
+ * @see VIP#getSubnetId()
+ */
+ public CreateBuilder subnetId(String subnetId) {
+ vip.subnetId = subnetId;
+ return self();
+ }
+
+ /**
+ * Provides the address for this VIP's Builder.
+ *
+ * @return the Builder.
+ * @see VIP#getAddress()
+ */
+ public CreateBuilder address(String address) {
+ vip.address = address;
+ return self();
+ }
+
+ /**
+ * Provides the protocol for this VIP's Builder.
+ *
+ * @return the Builder.
+ * @see VIP#getProtocol()
+ */
+ public CreateBuilder protocol(Protocol protocol) {
+ vip.protocol = protocol;
+ return self();
+ }
+
+ /**
+ * Provides the protocol port for this VIP's Builder.
+ *
+ * @return the Builder.
+ * @see VIP#getProtocolPort()
+ */
+ public CreateBuilder protocolPort(Integer protocolPort) {
+ vip.protocolPort = protocolPort;
+ return self();
+ }
+
+ /**
+ * @return a CreateVIP constructed with this Builder.
+ */
+ public CreateVIP build() {
+ return new CreateVIP(vip);
+ }
+
+ @Override
+ protected CreateBuilder self() {
+ return this;
+ }
+ }
+
+ /**
+ * Update builder (inheriting from Builder).
+ */
+ public static class UpdateBuilder extends Builder<UpdateBuilder> {
+ /**
+ * Supply required properties for creating a VIP's UpdateBuilder.
+ */
+ private UpdateBuilder() {
+ }
+
+ /**
+ * @return a UpdateVIP constructed with this Builder.
+ */
+ public UpdateVIP build() {
+ return new UpdateVIP(vip);
+ }
+
+ @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 CreateVIP extends VIP {
+ /**
+ * Copy constructor.
+ *
+ * @param vip the VIP to copy from.
+ */
+ private CreateVIP(VIP vip) {
+ super(vip);
+ }
+ }
+
+ /**
+ * 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 UpdateVIP extends VIP {
+ /**
+ * Copy constructor.
+ *
+ * @param vip the VIP to copy from.
+ */
+ private UpdateVIP(VIP vip) {
+ super(vip);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/blob/0675d2ea/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/VIPs.java
----------------------------------------------------------------------
diff --git a/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/VIPs.java b/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/VIPs.java
new file mode 100644
index 0000000..f53223d
--- /dev/null
+++ b/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/VIPs.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 VIPs.
+ */
+public class VIPs extends PaginatedCollection<VIP> {
+ public static final VIPs EMPTY = new VIPs(ImmutableSet.<VIP> of(), ImmutableSet.<Link> of());
+
+ @ConstructorProperties({ "vips", "vips_links" })
+ protected VIPs(Iterable<VIP> vips, Iterable<Link> vipsLinks) {
+ super(vips, vipsLinks);
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/blob/0675d2ea/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/extensions/ExtensionNamespaces.java
----------------------------------------------------------------------
diff --git a/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/extensions/ExtensionNamespaces.java b/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/extensions/ExtensionNamespaces.java
index 00af74d..60d23a3 100644
--- a/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/extensions/ExtensionNamespaces.java
+++ b/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/extensions/ExtensionNamespaces.java
@@ -28,6 +28,10 @@ public final class ExtensionNamespaces {
* Neutron Security Groups Extension
*/
public static final String SECURITY_GROUPS = "http://docs.openstack.org/ext/securitygroups/api/v2.0";
+ /**
+ * LBaaS Extension.
+ */
+ public static final String LBAAS = "http://wiki.openstack.org/neutron/LBaaS/API_1.0";
private ExtensionNamespaces() {
throw new AssertionError("intentionally unimplemented");
http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/blob/0675d2ea/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/extensions/lbaas/v1/LBaaSApi.java
----------------------------------------------------------------------
diff --git a/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/extensions/lbaas/v1/LBaaSApi.java b/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/extensions/lbaas/v1/LBaaSApi.java
new file mode 100644
index 0000000..dad80d8
--- /dev/null
+++ b/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/extensions/lbaas/v1/LBaaSApi.java
@@ -0,0 +1,426 @@
+/*
+ * 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.extensions.lbaas.v1;
+
+import javax.inject.Named;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.Fallbacks.EmptyPagedIterableOnNotFoundOr404;
+import org.jclouds.Fallbacks.FalseOnNotFoundOr404;
+import org.jclouds.Fallbacks.NullOnNotFoundOr404;
+import org.jclouds.collect.PagedIterable;
+import org.jclouds.javax.annotation.Nullable;
+import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest;
+import org.jclouds.openstack.neutron.v2.domain.lbaas.v1.HealthMonitor;
+import org.jclouds.openstack.neutron.v2.domain.lbaas.v1.HealthMonitors;
+import org.jclouds.openstack.neutron.v2.domain.lbaas.v1.Member;
+import org.jclouds.openstack.neutron.v2.domain.lbaas.v1.Members;
+import org.jclouds.openstack.neutron.v2.domain.lbaas.v1.Pool;
+import org.jclouds.openstack.neutron.v2.domain.lbaas.v1.Pools;
+import org.jclouds.openstack.neutron.v2.domain.lbaas.v1.VIP;
+import org.jclouds.openstack.neutron.v2.domain.lbaas.v1.VIPs;
+import org.jclouds.openstack.neutron.v2.extensions.ExtensionNamespaces;
+import org.jclouds.openstack.neutron.v2.fallbacks.lbaas.v1.EmptyHealthMonitorsFallback;
+import org.jclouds.openstack.neutron.v2.fallbacks.lbaas.v1.EmptyMembersFallback;
+import org.jclouds.openstack.neutron.v2.fallbacks.lbaas.v1.EmptyPoolsFallback;
+import org.jclouds.openstack.neutron.v2.fallbacks.lbaas.v1.EmptyVIPsFallback;
+import org.jclouds.openstack.neutron.v2.functions.lbaas.v1.HealthMonitorsToPagedIterable;
+import org.jclouds.openstack.neutron.v2.functions.lbaas.v1.MembersToPagedIterable;
+import org.jclouds.openstack.neutron.v2.functions.lbaas.v1.ParseHealthMonitors;
+import org.jclouds.openstack.neutron.v2.functions.lbaas.v1.ParseMembers;
+import org.jclouds.openstack.neutron.v2.functions.lbaas.v1.ParsePools;
+import org.jclouds.openstack.neutron.v2.functions.lbaas.v1.ParseVIPs;
+import org.jclouds.openstack.neutron.v2.functions.lbaas.v1.PoolsToPagedIterable;
+import org.jclouds.openstack.neutron.v2.functions.lbaas.v1.VIPsToPagedIterable;
+import org.jclouds.openstack.v2_0.ServiceType;
+import org.jclouds.openstack.v2_0.options.PaginationOptions;
+import org.jclouds.openstack.v2_0.services.Extension;
+import org.jclouds.rest.annotations.Fallback;
+import org.jclouds.rest.annotations.Payload;
+import org.jclouds.rest.annotations.PayloadParam;
+import org.jclouds.rest.annotations.RequestFilters;
+import org.jclouds.rest.annotations.ResponseParser;
+import org.jclouds.rest.annotations.SelectJson;
+import org.jclouds.rest.annotations.Transform;
+import org.jclouds.rest.annotations.WrapWith;
+
+import com.google.common.annotations.Beta;
+
+/**
+ * Provides access to load-balancing operations for the OpenStack Networking (Neutron) v2 API.
+ * <p/>
+ * LBaaS v1 is an extension to load-balance the traffic between instances and external networks.
+ */
+@Beta
+@Extension(of = ServiceType.NETWORK, namespace = ExtensionNamespaces.LBAAS)
+@Path("/lb")
+@RequestFilters(AuthenticateRequest.class)
+@Consumes(MediaType.APPLICATION_JSON)
+public interface LBaaSApi {
+
+ /**
+ * Returns a list of VIPs to which the tenant has access. Default policy settings return only
+ * those VIPs that are owned by the tenant who submits the request, unless the request is submitted by an
+ * user with administrative rights.
+ *
+ * @return the list of all VIP references configured for the tenant.
+ */
+ @Named("vip:list")
+ @GET
+ @Path("/vips")
+ @Transform(VIPsToPagedIterable.class)
+ @ResponseParser(ParseVIPs.class)
+ @Fallback(EmptyPagedIterableOnNotFoundOr404.class)
+ PagedIterable<VIP> listVIPs();
+
+ /**
+ * @return the list of all VIP references configured for the tenant.
+ */
+ @Named("vip:list")
+ @GET
+ @Path("/vips")
+ @ResponseParser(ParseVIPs.class)
+ @Fallback(EmptyVIPsFallback.class)
+ VIPs listVIPs(PaginationOptions options);
+
+ /**
+ * Returns the details for a specific VIP.
+ *
+ * @param id the id of the VIP to return.
+ * @return VIP or null if not found.
+ */
+ @Named("vip:get")
+ @GET
+ @Path("/vips/{id}")
+ @SelectJson("vip")
+ @Fallback(NullOnNotFoundOr404.class)
+ @Nullable
+ VIP getVIP(@PathParam("id") String id);
+
+ /**
+ * Creates a new VIP.
+ *
+ * @param vip describes the VIP to be created.
+ * @return a reference of the newly-created VIP.
+ */
+ @Named("vip:create")
+ @POST
+ @Path("/vips")
+ @SelectJson("vip")
+ VIP createVIP(@WrapWith("vip") VIP.CreateVIP vip);
+
+ /**
+ * Update a VIP.
+ *
+ * @param id the id of the VIP to update.
+ * @param vip the VIP's attributes to update.
+ * @return a reference of the updated VIP.
+ */
+ @Named("vip:update")
+ @PUT
+ @Path("/vips/{id}")
+ @SelectJson("vip")
+ @Fallback(NullOnNotFoundOr404.class)
+ @Nullable
+ VIP updateVIP(@PathParam("id") String id, @WrapWith("vip") VIP.UpdateVIP vip);
+
+ /**
+ * Deletes the specified VIP.
+ *
+ * @param id the id of the VIP to delete.
+ * @return true if delete successful, false if not.
+ */
+ @Named("vip:delete")
+ @DELETE
+ @Path("/vips/{id}")
+ @Fallback(FalseOnNotFoundOr404.class)
+ boolean deleteVIP(@PathParam("id") String id);
+
+ /**
+ * Returns a list of Pools to which the tenant has access. Default policy settings return only
+ * those Pools that are owned by the tenant who submits the request, unless the request is submitted by an
+ * user with administrative rights.
+ *
+ * @return the list of all Pool references configured for the tenant.
+ */
+ @Named("pool:list")
+ @GET
+ @Path("/pools")
+ @Transform(PoolsToPagedIterable.class)
+ @ResponseParser(ParsePools.class)
+ @Fallback(EmptyPagedIterableOnNotFoundOr404.class)
+ PagedIterable<Pool> listPools();
+
+ /**
+ * @return the list of all Pool references configured for the tenant.
+ */
+ @Named("pool:list")
+ @GET
+ @Path("/pools")
+ @ResponseParser(ParsePools.class)
+ @Fallback(EmptyPoolsFallback.class)
+ Pools listPools(PaginationOptions options);
+
+ /**
+ * Returns the details for a specific Pool.
+ *
+ * @param id the id of the Pool to return.
+ * @return Pool or null if not found.
+ */
+ @Named("pool:get")
+ @GET
+ @Path("/pools/{id}")
+ @SelectJson("pool")
+ @Fallback(NullOnNotFoundOr404.class)
+ @Nullable
+ Pool getPool(@PathParam("id") String id);
+
+ /**
+ * Creates a new Pool.
+ *
+ * @param pool describes the Pool to be created.
+ * @return a reference of the newly-created Pool.
+ */
+ @Named("pool:create")
+ @POST
+ @Path("/pools")
+ @SelectJson("pool")
+ Pool createPool(@WrapWith("pool") Pool.CreatePool pool);
+
+ /**
+ * Update a Pool.
+ *
+ * @param id the id of the Pool to update.
+ * @param pool the Pool's attributes to update.
+ * @return a reference of the updated Pool.
+ */
+ @Named("pool:update")
+ @PUT
+ @Path("/pools/{id}")
+ @SelectJson("pool")
+ @Fallback(NullOnNotFoundOr404.class)
+ @Nullable
+ Pool updatePool(@PathParam("id") String id, @WrapWith("pool") Pool.UpdatePool pool);
+
+ /**
+ * Deletes the specified Pool.
+ *
+ * @param id the id of the Pool to delete.
+ * @return true if delete successful, false if not.
+ */
+ @Named("pool:delete")
+ @DELETE
+ @Path("/pools/{id}")
+ @Fallback(FalseOnNotFoundOr404.class)
+ boolean deletePool(@PathParam("id") String id);
+
+ /**
+ * Returns a list of Members to which the tenant has access. Default policy settings return only
+ * those Members that are owned by the tenant who submits the request, unless the request is submitted by an
+ * user with administrative rights.
+ *
+ * @return the list of all Member references configured for the tenant.
+ */
+ @Named("member:list")
+ @GET
+ @Path("/members")
+ @Transform(MembersToPagedIterable.class)
+ @ResponseParser(ParseMembers.class)
+ @Fallback(EmptyPagedIterableOnNotFoundOr404.class)
+ PagedIterable<Member> listMembers();
+
+ /**
+ * @return the list of all Member references configured for the tenant.
+ */
+ @Named("member:list")
+ @GET
+ @Path("/members")
+ @ResponseParser(ParseMembers.class)
+ @Fallback(EmptyMembersFallback.class)
+ Members listMembers(PaginationOptions options);
+
+ /**
+ * Returns the details for a specific Member.
+ *
+ * @param id the id of the Member to return.
+ * @return Member or null if not found.
+ */
+ @Named("member:get")
+ @GET
+ @Path("/members/{id}")
+ @SelectJson("member")
+ @Fallback(NullOnNotFoundOr404.class)
+ @Nullable
+ Member getMember(@PathParam("id") String id);
+
+ /**
+ * Creates a new Member.
+ *
+ * @param member describes the Member to be created.
+ * @return a reference of the newly-created Member.
+ */
+ @Named("member:create")
+ @POST
+ @Path("/members")
+ @SelectJson("member")
+ Member createMember(@WrapWith("member") Member.CreateMember member);
+
+ /**
+ * Update a Member.
+ *
+ * @param id the id of the Member to update.
+ * @param member the Member's attributes to update.
+ * @return a reference of the updated Member.
+ */
+ @Named("member:update")
+ @PUT
+ @Path("/members/{id}")
+ @SelectJson("member")
+ @Fallback(NullOnNotFoundOr404.class)
+ @Nullable
+ Member updateMember(@PathParam("id") String id, @WrapWith("member") Member.UpdateMember member);
+
+ /**
+ * Deletes the specified Member.
+ *
+ * @param id the id of the Member to delete.
+ * @return true if delete successful, false if not.
+ */
+ @Named("member:delete")
+ @DELETE
+ @Path("/members/{id}")
+ @Fallback(FalseOnNotFoundOr404.class)
+ boolean deleteMember(@PathParam("id") String id);
+
+ /**
+ * Returns a list of HealthMonitors to which the tenant has access. Default policy settings return only
+ * those HealthMonitors that are owned by the tenant who submits the request, unless the request is submitted by an
+ * user with administrative rights.
+ *
+ * @return the list of all HealthMonitor references configured for the tenant.
+ */
+ @Named("health_monitor:list")
+ @GET
+ @Path("/health_monitors")
+ @Transform(HealthMonitorsToPagedIterable.class)
+ @ResponseParser(ParseHealthMonitors.class)
+ @Fallback(EmptyPagedIterableOnNotFoundOr404.class)
+ PagedIterable<HealthMonitor> listHealthMonitors();
+
+ /**
+ * @return the list of all HealthMonitor references configured for the tenant.
+ */
+ @Named("health_monitor:list")
+ @GET
+ @Path("/health_monitors")
+ @ResponseParser(ParseHealthMonitors.class)
+ @Fallback(EmptyHealthMonitorsFallback.class)
+ HealthMonitors listHealthMonitors(PaginationOptions options);
+
+ /**
+ * Returns the details for a specific HealthMonitor.
+ *
+ * @param id the id of the HealthMonitor to return.
+ * @return Health Monitor or null if not found.
+ */
+ @Named("health_monitor:get")
+ @GET
+ @Path("/health_monitors/{id}")
+ @SelectJson("health_monitor")
+ @Fallback(NullOnNotFoundOr404.class)
+ @Nullable
+ HealthMonitor getHealthMonitor(@PathParam("id") String id);
+
+ /**
+ * Creates a new HealthMonitor.
+ *
+ * @param healthMonitor describes the HealthMonitor to be created.
+ * @return a reference of the newly-created HealthMonitor.
+ */
+ @Named("health_monitor:create")
+ @POST
+ @Path("/health_monitors")
+ @SelectJson("health_monitor")
+ HealthMonitor createHealthMonitor(@WrapWith("health_monitor") HealthMonitor.CreateHealthMonitor healthMonitor);
+
+ /**
+ * Update a HealthMonitor.
+ *
+ * @param id the id of the HealthMonitor to update.
+ * @param healthMonitor the HealthMonitor's attributes to update.
+ * @return a reference of the updated HealthMonitor.
+ */
+ @Named("health_monitor:update")
+ @PUT
+ @Path("/health_monitors/{id}")
+ @SelectJson("health_monitor")
+ @Fallback(NullOnNotFoundOr404.class)
+ @Nullable
+ HealthMonitor updateHealthMonitor(@PathParam("id") String id,
+ @WrapWith("health_monitor") HealthMonitor.UpdateHealthMonitor healthMonitor);
+
+ /**
+ * Deletes the specified Health Monitor.
+ *
+ * @param id the id of the Health Monitor to delete.
+ * @return true if delete successful, false if not.
+ */
+ @Named("health_monitor:delete")
+ @DELETE
+ @Path("/health_monitors/{id}")
+ @Fallback(FalseOnNotFoundOr404.class)
+ boolean deleteHealthMonitor(@PathParam("id") String id);
+
+ /**
+ * Associate a HealthMonitor to a Pool.
+ *
+ * @param poolId the id of the Pool to associate.
+ * @param healthMonitorId the id of the HealthMonitor to associate.
+ * @return the newly associated HealthMonitor.
+ */
+ @Named("pool:associate_health_monitor")
+ @POST
+ @Path("/pools/{pool-id}/health_monitors")
+ @SelectJson("health_monitor")
+ @Payload("%7B\"health_monitor\":%7B\"id\":\"{healthMonitorId}\"%7D%7D")
+ @Produces(MediaType.APPLICATION_JSON)
+ HealthMonitor associateHealthMonitor(@PathParam("pool-id") String poolId,
+ @PayloadParam("healthMonitorId") String healthMonitorId);
+
+ /**
+ * Disassociate a HealthMonitor from a Pool.
+ *
+ * @param poolId the id of the Pool to disassociate.
+ * @param healthMonitorId the id of the HealthMonitor to disassociate.
+ * @return true if disassociate successful, false if not.
+ */
+ @Named("pool:disassociate_health_monitor")
+ @DELETE
+ @Path("/pools/{pool-id}/health_monitors/{health-monitor-id}")
+ @Fallback(FalseOnNotFoundOr404.class)
+ boolean disassociateHealthMonitor(@PathParam("pool-id") String poolId,
+ @PathParam("health-monitor-id") String healthMonitorId);
+
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/blob/0675d2ea/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/fallbacks/lbaas/v1/EmptyHealthMonitorsFallback.java
----------------------------------------------------------------------
diff --git a/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/fallbacks/lbaas/v1/EmptyHealthMonitorsFallback.java b/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/fallbacks/lbaas/v1/EmptyHealthMonitorsFallback.java
new file mode 100644
index 0000000..f298a9c
--- /dev/null
+++ b/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/fallbacks/lbaas/v1/EmptyHealthMonitorsFallback.java
@@ -0,0 +1,46 @@
+/*
+ * 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.fallbacks.lbaas.v1;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.base.Throwables.propagate;
+import static com.google.common.util.concurrent.Futures.immediateFuture;
+import static org.jclouds.http.HttpUtils.contains404;
+import static org.jclouds.util.Throwables2.getFirstThrowableOfType;
+
+import org.jclouds.Fallback;
+import org.jclouds.openstack.neutron.v2.domain.lbaas.v1.HealthMonitors;
+import org.jclouds.rest.ResourceNotFoundException;
+
+import com.google.common.util.concurrent.ListenableFuture;
+
+public class EmptyHealthMonitorsFallback implements Fallback<HealthMonitors> {
+
+ public ListenableFuture<HealthMonitors> create(Throwable t) throws Exception {
+ return immediateFuture(createOrPropagate(t));
+ }
+
+ @Override
+ public HealthMonitors createOrPropagate(Throwable t) throws Exception {
+ if ((getFirstThrowableOfType(checkNotNull(t, "throwable"), ResourceNotFoundException.class) != null)
+ || contains404(t)) {
+ return HealthMonitors.EMPTY;
+ }
+ throw propagate(t);
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/blob/0675d2ea/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/fallbacks/lbaas/v1/EmptyMembersFallback.java
----------------------------------------------------------------------
diff --git a/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/fallbacks/lbaas/v1/EmptyMembersFallback.java b/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/fallbacks/lbaas/v1/EmptyMembersFallback.java
new file mode 100644
index 0000000..1cbc38f
--- /dev/null
+++ b/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/fallbacks/lbaas/v1/EmptyMembersFallback.java
@@ -0,0 +1,46 @@
+/*
+ * 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.fallbacks.lbaas.v1;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.base.Throwables.propagate;
+import static com.google.common.util.concurrent.Futures.immediateFuture;
+import static org.jclouds.http.HttpUtils.contains404;
+import static org.jclouds.util.Throwables2.getFirstThrowableOfType;
+
+import org.jclouds.Fallback;
+import org.jclouds.openstack.neutron.v2.domain.lbaas.v1.Members;
+import org.jclouds.rest.ResourceNotFoundException;
+
+import com.google.common.util.concurrent.ListenableFuture;
+
+public class EmptyMembersFallback implements Fallback<Members> {
+
+ public ListenableFuture<Members> create(Throwable t) throws Exception {
+ return immediateFuture(createOrPropagate(t));
+ }
+
+ @Override
+ public Members createOrPropagate(Throwable t) throws Exception {
+ if ((getFirstThrowableOfType(checkNotNull(t, "throwable"), ResourceNotFoundException.class) != null)
+ || contains404(t)) {
+ return Members.EMPTY;
+ }
+ throw propagate(t);
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/blob/0675d2ea/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/fallbacks/lbaas/v1/EmptyPoolsFallback.java
----------------------------------------------------------------------
diff --git a/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/fallbacks/lbaas/v1/EmptyPoolsFallback.java b/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/fallbacks/lbaas/v1/EmptyPoolsFallback.java
new file mode 100644
index 0000000..8035c6f
--- /dev/null
+++ b/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/fallbacks/lbaas/v1/EmptyPoolsFallback.java
@@ -0,0 +1,46 @@
+/*
+ * 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.fallbacks.lbaas.v1;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.base.Throwables.propagate;
+import static com.google.common.util.concurrent.Futures.immediateFuture;
+import static org.jclouds.http.HttpUtils.contains404;
+import static org.jclouds.util.Throwables2.getFirstThrowableOfType;
+
+import org.jclouds.Fallback;
+import org.jclouds.openstack.neutron.v2.domain.lbaas.v1.Pools;
+import org.jclouds.rest.ResourceNotFoundException;
+
+import com.google.common.util.concurrent.ListenableFuture;
+
+public class EmptyPoolsFallback implements Fallback<Pools> {
+
+ public ListenableFuture<Pools> create(Throwable t) throws Exception {
+ return immediateFuture(createOrPropagate(t));
+ }
+
+ @Override
+ public Pools createOrPropagate(Throwable t) throws Exception {
+ if ((getFirstThrowableOfType(checkNotNull(t, "throwable"), ResourceNotFoundException.class) != null)
+ || contains404(t)) {
+ return Pools.EMPTY;
+ }
+ throw propagate(t);
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/blob/0675d2ea/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/fallbacks/lbaas/v1/EmptyVIPsFallback.java
----------------------------------------------------------------------
diff --git a/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/fallbacks/lbaas/v1/EmptyVIPsFallback.java b/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/fallbacks/lbaas/v1/EmptyVIPsFallback.java
new file mode 100644
index 0000000..df3aa90
--- /dev/null
+++ b/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/fallbacks/lbaas/v1/EmptyVIPsFallback.java
@@ -0,0 +1,46 @@
+/*
+ * 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.fallbacks.lbaas.v1;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.base.Throwables.propagate;
+import static com.google.common.util.concurrent.Futures.immediateFuture;
+import static org.jclouds.http.HttpUtils.contains404;
+import static org.jclouds.util.Throwables2.getFirstThrowableOfType;
+
+import org.jclouds.Fallback;
+import org.jclouds.openstack.neutron.v2.domain.lbaas.v1.VIPs;
+import org.jclouds.rest.ResourceNotFoundException;
+
+import com.google.common.util.concurrent.ListenableFuture;
+
+public class EmptyVIPsFallback implements Fallback<VIPs> {
+
+ public ListenableFuture<VIPs> create(Throwable t) throws Exception {
+ return immediateFuture(createOrPropagate(t));
+ }
+
+ @Override
+ public VIPs createOrPropagate(Throwable t) throws Exception {
+ if ((getFirstThrowableOfType(checkNotNull(t, "throwable"), ResourceNotFoundException.class) != null)
+ || contains404(t)) {
+ return VIPs.EMPTY;
+ }
+ throw propagate(t);
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/blob/0675d2ea/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/functions/lbaas/v1/HealthMonitorsToPagedIterable.java
----------------------------------------------------------------------
diff --git a/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/functions/lbaas/v1/HealthMonitorsToPagedIterable.java b/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/functions/lbaas/v1/HealthMonitorsToPagedIterable.java
new file mode 100644
index 0000000..e925b81
--- /dev/null
+++ b/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/functions/lbaas/v1/HealthMonitorsToPagedIterable.java
@@ -0,0 +1,66 @@
+/*
+ * 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.functions.lbaas.v1;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import javax.inject.Inject;
+
+import org.jclouds.collect.IterableWithMarker;
+import org.jclouds.collect.internal.Arg0ToPagedIterable;
+import org.jclouds.openstack.neutron.v2.NeutronApi;
+import org.jclouds.openstack.neutron.v2.domain.lbaas.v1.HealthMonitor;
+import org.jclouds.openstack.neutron.v2.extensions.lbaas.v1.LBaaSApi;
+import org.jclouds.openstack.v2_0.options.PaginationOptions;
+
+import com.google.common.base.Function;
+import com.google.common.base.Optional;
+
+/**
+ * Makes HealthMonitors work as a PagedIterable.
+ */
+public class HealthMonitorsToPagedIterable extends
+ Arg0ToPagedIterable.FromCaller<HealthMonitor, HealthMonitorsToPagedIterable> {
+
+ private final NeutronApi api;
+
+ @Inject
+ protected HealthMonitorsToPagedIterable(NeutronApi api) {
+ this.api = checkNotNull(api, "api");
+ }
+
+ @Override
+ protected Function<Object, IterableWithMarker<HealthMonitor>> markerToNextForArg0(Optional<Object> arg0) {
+ String region = arg0.isPresent() ? arg0.get().toString() : null;
+ final LBaaSApi lbaasApi = api.getLBaaSApi(region).get();
+ return new Function<Object, IterableWithMarker<HealthMonitor>>() {
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public IterableWithMarker<HealthMonitor> apply(Object input) {
+ PaginationOptions paginationOptions = PaginationOptions.class.cast(input);
+ return IterableWithMarker.class.cast(lbaasApi.listHealthMonitors(paginationOptions));
+ }
+
+ @Override
+ public String toString() {
+ return "listHealthMonitors()";
+ }
+ };
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/blob/0675d2ea/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/functions/lbaas/v1/MembersToPagedIterable.java
----------------------------------------------------------------------
diff --git a/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/functions/lbaas/v1/MembersToPagedIterable.java b/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/functions/lbaas/v1/MembersToPagedIterable.java
new file mode 100644
index 0000000..23b1719
--- /dev/null
+++ b/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/functions/lbaas/v1/MembersToPagedIterable.java
@@ -0,0 +1,65 @@
+/*
+ * 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.functions.lbaas.v1;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import javax.inject.Inject;
+
+import org.jclouds.collect.IterableWithMarker;
+import org.jclouds.collect.internal.Arg0ToPagedIterable;
+import org.jclouds.openstack.neutron.v2.NeutronApi;
+import org.jclouds.openstack.neutron.v2.domain.lbaas.v1.Member;
+import org.jclouds.openstack.neutron.v2.extensions.lbaas.v1.LBaaSApi;
+import org.jclouds.openstack.v2_0.options.PaginationOptions;
+
+import com.google.common.base.Function;
+import com.google.common.base.Optional;
+
+/**
+ * Makes Members work as a PagedIterable.
+ */
+public class MembersToPagedIterable extends Arg0ToPagedIterable.FromCaller<Member, MembersToPagedIterable> {
+
+ private final NeutronApi api;
+
+ @Inject
+ protected MembersToPagedIterable(NeutronApi api) {
+ this.api = checkNotNull(api, "api");
+ }
+
+ @Override
+ protected Function<Object, IterableWithMarker<Member>> markerToNextForArg0(Optional<Object> arg0) {
+ String region = arg0.isPresent() ? arg0.get().toString() : null;
+ final LBaaSApi lbaasApi = api.getLBaaSApi(region).get();
+ return new Function<Object, IterableWithMarker<Member>>() {
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public IterableWithMarker<Member> apply(Object input) {
+ PaginationOptions paginationOptions = PaginationOptions.class.cast(input);
+ return IterableWithMarker.class.cast(lbaasApi.listMembers(paginationOptions));
+ }
+
+ @Override
+ public String toString() {
+ return "listMembers()";
+ }
+ };
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/blob/0675d2ea/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/functions/lbaas/v1/ParseHealthMonitors.java
----------------------------------------------------------------------
diff --git a/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/functions/lbaas/v1/ParseHealthMonitors.java b/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/functions/lbaas/v1/ParseHealthMonitors.java
new file mode 100644
index 0000000..d74ceaf
--- /dev/null
+++ b/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/functions/lbaas/v1/ParseHealthMonitors.java
@@ -0,0 +1,38 @@
+/*
+ * 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.functions.lbaas.v1;
+
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+import org.jclouds.http.functions.ParseJson;
+import org.jclouds.json.Json;
+import org.jclouds.openstack.neutron.v2.domain.lbaas.v1.HealthMonitors;
+
+import com.google.inject.TypeLiteral;
+
+/**
+ * Used by jclouds to provide more specific collections and fallbacks.
+ */
+@Singleton
+public class ParseHealthMonitors extends ParseJson<HealthMonitors> {
+
+ @Inject
+ public ParseHealthMonitors(Json json) {
+ super(json, TypeLiteral.get(HealthMonitors.class));
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/blob/0675d2ea/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/functions/lbaas/v1/ParseMembers.java
----------------------------------------------------------------------
diff --git a/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/functions/lbaas/v1/ParseMembers.java b/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/functions/lbaas/v1/ParseMembers.java
new file mode 100644
index 0000000..252a5b0
--- /dev/null
+++ b/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/functions/lbaas/v1/ParseMembers.java
@@ -0,0 +1,38 @@
+/*
+ * 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.functions.lbaas.v1;
+
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+import org.jclouds.http.functions.ParseJson;
+import org.jclouds.json.Json;
+import org.jclouds.openstack.neutron.v2.domain.lbaas.v1.Members;
+
+import com.google.inject.TypeLiteral;
+
+/**
+ * Used by jclouds to provide more specific collections and fallbacks.
+ */
+@Singleton
+public class ParseMembers extends ParseJson<Members> {
+
+ @Inject
+ public ParseMembers(Json json) {
+ super(json, TypeLiteral.get(Members.class));
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/blob/0675d2ea/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/functions/lbaas/v1/ParsePools.java
----------------------------------------------------------------------
diff --git a/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/functions/lbaas/v1/ParsePools.java b/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/functions/lbaas/v1/ParsePools.java
new file mode 100644
index 0000000..adf81da
--- /dev/null
+++ b/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/functions/lbaas/v1/ParsePools.java
@@ -0,0 +1,38 @@
+/*
+ * 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.functions.lbaas.v1;
+
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+import org.jclouds.http.functions.ParseJson;
+import org.jclouds.json.Json;
+import org.jclouds.openstack.neutron.v2.domain.lbaas.v1.Pools;
+
+import com.google.inject.TypeLiteral;
+
+/**
+ * Used by jclouds to provide more specific collections and fallbacks.
+ */
+@Singleton
+public class ParsePools extends ParseJson<Pools> {
+
+ @Inject
+ public ParsePools(Json json) {
+ super(json, TypeLiteral.get(Pools.class));
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/blob/0675d2ea/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/functions/lbaas/v1/ParseVIPs.java
----------------------------------------------------------------------
diff --git a/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/functions/lbaas/v1/ParseVIPs.java b/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/functions/lbaas/v1/ParseVIPs.java
new file mode 100644
index 0000000..d97710c
--- /dev/null
+++ b/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/functions/lbaas/v1/ParseVIPs.java
@@ -0,0 +1,38 @@
+/*
+ * 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.functions.lbaas.v1;
+
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+import org.jclouds.http.functions.ParseJson;
+import org.jclouds.json.Json;
+import org.jclouds.openstack.neutron.v2.domain.lbaas.v1.VIPs;
+
+import com.google.inject.TypeLiteral;
+
+/**
+ * Used by jclouds to provide more specific collections and fallbacks.
+ */
+@Singleton
+public class ParseVIPs extends ParseJson<VIPs> {
+
+ @Inject
+ public ParseVIPs(Json json) {
+ super(json, TypeLiteral.get(VIPs.class));
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/blob/0675d2ea/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/functions/lbaas/v1/PoolsToPagedIterable.java
----------------------------------------------------------------------
diff --git a/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/functions/lbaas/v1/PoolsToPagedIterable.java b/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/functions/lbaas/v1/PoolsToPagedIterable.java
new file mode 100644
index 0000000..c59b966
--- /dev/null
+++ b/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/functions/lbaas/v1/PoolsToPagedIterable.java
@@ -0,0 +1,65 @@
+/*
+ * 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.functions.lbaas.v1;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import javax.inject.Inject;
+
+import org.jclouds.collect.IterableWithMarker;
+import org.jclouds.collect.internal.Arg0ToPagedIterable;
+import org.jclouds.openstack.neutron.v2.NeutronApi;
+import org.jclouds.openstack.neutron.v2.domain.lbaas.v1.Pool;
+import org.jclouds.openstack.neutron.v2.extensions.lbaas.v1.LBaaSApi;
+import org.jclouds.openstack.v2_0.options.PaginationOptions;
+
+import com.google.common.base.Function;
+import com.google.common.base.Optional;
+
+/**
+ * Makes Pools work as a PagedIterable.
+ */
+public class PoolsToPagedIterable extends Arg0ToPagedIterable.FromCaller<Pool, PoolsToPagedIterable> {
+
+ private final NeutronApi api;
+
+ @Inject
+ protected PoolsToPagedIterable(NeutronApi api) {
+ this.api = checkNotNull(api, "api");
+ }
+
+ @Override
+ protected Function<Object, IterableWithMarker<Pool>> markerToNextForArg0(Optional<Object> arg0) {
+ String region = arg0.isPresent() ? arg0.get().toString() : null;
+ final LBaaSApi lbaasApi = api.getLBaaSApi(region).get();
+ return new Function<Object, IterableWithMarker<Pool>>() {
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public IterableWithMarker<Pool> apply(Object input) {
+ PaginationOptions paginationOptions = PaginationOptions.class.cast(input);
+ return IterableWithMarker.class.cast(lbaasApi.listPools(paginationOptions));
+ }
+
+ @Override
+ public String toString() {
+ return "listPools()";
+ }
+ };
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/blob/0675d2ea/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/functions/lbaas/v1/VIPsToPagedIterable.java
----------------------------------------------------------------------
diff --git a/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/functions/lbaas/v1/VIPsToPagedIterable.java b/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/functions/lbaas/v1/VIPsToPagedIterable.java
new file mode 100644
index 0000000..5731b2f
--- /dev/null
+++ b/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/functions/lbaas/v1/VIPsToPagedIterable.java
@@ -0,0 +1,65 @@
+/*
+ * 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.functions.lbaas.v1;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import javax.inject.Inject;
+
+import org.jclouds.collect.IterableWithMarker;
+import org.jclouds.collect.internal.Arg0ToPagedIterable;
+import org.jclouds.openstack.neutron.v2.NeutronApi;
+import org.jclouds.openstack.neutron.v2.domain.lbaas.v1.VIP;
+import org.jclouds.openstack.neutron.v2.extensions.lbaas.v1.LBaaSApi;
+import org.jclouds.openstack.v2_0.options.PaginationOptions;
+
+import com.google.common.base.Function;
+import com.google.common.base.Optional;
+
+/**
+ * Makes VIPs work as a PagedIterable.
+ */
+public class VIPsToPagedIterable extends Arg0ToPagedIterable.FromCaller<VIP, VIPsToPagedIterable> {
+
+ private final NeutronApi api;
+
+ @Inject
+ protected VIPsToPagedIterable(NeutronApi api) {
+ this.api = checkNotNull(api, "api");
+ }
+
+ @Override
+ protected Function<Object, IterableWithMarker<VIP>> markerToNextForArg0(Optional<Object> arg0) {
+ String region = arg0.isPresent() ? arg0.get().toString() : null;
+ final LBaaSApi lbaasApi = api.getLBaaSApi(region).get();
+ return new Function<Object, IterableWithMarker<VIP>>() {
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public IterableWithMarker<VIP> apply(Object input) {
+ PaginationOptions paginationOptions = PaginationOptions.class.cast(input);
+ return IterableWithMarker.class.cast(lbaasApi.listVIPs(paginationOptions));
+ }
+
+ @Override
+ public String toString() {
+ return "listVIPs()";
+ }
+ };
+ }
+
+}
[2/5] Support LBaaS v1
Posted by za...@apache.org.
http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/blob/0675d2ea/openstack-neutron/src/test/java/org/jclouds/openstack/neutron/v2/extensions/lbaas/v1/LBaaSApiMockTest.java
----------------------------------------------------------------------
diff --git a/openstack-neutron/src/test/java/org/jclouds/openstack/neutron/v2/extensions/lbaas/v1/LBaaSApiMockTest.java b/openstack-neutron/src/test/java/org/jclouds/openstack/neutron/v2/extensions/lbaas/v1/LBaaSApiMockTest.java
new file mode 100644
index 0000000..31a7ecf
--- /dev/null
+++ b/openstack-neutron/src/test/java/org/jclouds/openstack/neutron/v2/extensions/lbaas/v1/LBaaSApiMockTest.java
@@ -0,0 +1,1787 @@
+/*
+ * 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.extensions.lbaas.v1;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertNull;
+import static org.testng.Assert.assertTrue;
+import static org.testng.Assert.fail;
+
+import java.io.IOException;
+import java.util.List;
+
+import org.jclouds.openstack.neutron.v2.NeutronApi;
+import org.jclouds.openstack.neutron.v2.domain.lbaas.v1.HealthMonitor;
+import org.jclouds.openstack.neutron.v2.domain.lbaas.v1.HealthMonitors;
+import org.jclouds.openstack.neutron.v2.domain.lbaas.v1.HttpMethod;
+import org.jclouds.openstack.neutron.v2.domain.lbaas.v1.LBaaSStatus;
+import org.jclouds.openstack.neutron.v2.domain.lbaas.v1.Member;
+import org.jclouds.openstack.neutron.v2.domain.lbaas.v1.Members;
+import org.jclouds.openstack.neutron.v2.domain.lbaas.v1.Pool;
+import org.jclouds.openstack.neutron.v2.domain.lbaas.v1.Pools;
+import org.jclouds.openstack.neutron.v2.domain.lbaas.v1.ProbeType;
+import org.jclouds.openstack.neutron.v2.domain.lbaas.v1.Protocol;
+import org.jclouds.openstack.neutron.v2.domain.lbaas.v1.SessionPersistence;
+import org.jclouds.openstack.neutron.v2.domain.lbaas.v1.VIP;
+import org.jclouds.openstack.neutron.v2.domain.lbaas.v1.VIPs;
+import org.jclouds.openstack.neutron.v2.internal.BaseNeutronApiMockTest;
+import org.jclouds.openstack.v2_0.options.PaginationOptions;
+import org.jclouds.rest.ResourceNotFoundException;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Optional;
+import com.google.common.collect.ImmutableSet;
+import com.squareup.okhttp.mockwebserver.MockResponse;
+import com.squareup.okhttp.mockwebserver.MockWebServer;
+
+@Test
+public class LBaaSApiMockTest extends BaseNeutronApiMockTest {
+
+ public void testWhenNamespaceInExtensionsLBaaSPresent() throws IOException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/extension_list_with_lbaas_v1_response.json"))));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ Optional<LBaaSApi> lbaasApiExtension = neutronApi.getLBaaSApi("RegionOne");
+
+ assertAuthentication(server);
+
+ /*
+ * Check response
+ */
+ assertNotNull(lbaasApiExtension);
+ assertEquals(lbaasApiExtension.isPresent(), true, "LBaaS API Version 1 is expected to be available");
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testWhenNamespaceNotInExtensionsListLBaaSNotPresent() throws IOException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/extension_list_without_lbaas_v1_response.json"))));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ Optional<LBaaSApi> lbaasApiExtension = neutronApi.getLBaaSApi("RegionOne");
+
+ assertAuthentication(server);
+
+ /*
+ * Check response
+ */
+ assertNotNull(lbaasApiExtension);
+ assertEquals(lbaasApiExtension.isPresent(), false, "LBaaS API Version 1 is expected to be unavailable");
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testCreatePool() throws IOException, InterruptedException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/extension_list_with_lbaas_v1_response.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(201).setBody(stringFromResource("/lbaas/v1/pool_create_response.json"))));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ LBaaSApi lbaasApi = neutronApi.getLBaaSApi("RegionOne").get();
+
+ Pool.CreatePool createPool = Pool.createBuilder("8032909d-47a1-4715-90af-5153ffe39861", Protocol.TCP, Pool.ROUND_ROBIN)
+ .name("NewPool").description(null).healthMonitors(null).provider(null).adminStateUp(null).build();
+
+ Pool pool = lbaasApi.createPool(createPool);
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ server.takeRequest();
+ assertRequest(server.takeRequest(), "POST", "/v2.0/lb/pools", "/lbaas/v1/pool_create_request.json");
+
+ /*
+ * Check response
+ */
+ assertNotNull(pool);
+ assertNotNull(pool.getId());
+ assertEquals(pool.getTenantId(), "83657cfcdfe44cd5920adaf26c48ceea");
+ assertNull(pool.getVIPId());
+ assertEquals(pool.getName(), "NewPool");
+ assertEquals(pool.getDescription(), "");
+ assertEquals(pool.getSubnetId(), "8032909d-47a1-4715-90af-5153ffe39861");
+ assertEquals(pool.getProtocol(), Protocol.TCP);
+ assertEquals(pool.getProvider(), "HAPROXY");
+ assertEquals(pool.getLBMethod(), Pool.ROUND_ROBIN);
+ assertNotNull(pool.getMembers());
+ assertTrue(pool.getMembers().isEmpty());
+ assertNotNull(pool.getHealthMonitors());
+ assertTrue(pool.getHealthMonitors().isEmpty());
+ assertNotNull(pool.getHealthMonitorsStatus());
+ assertTrue(pool.getHealthMonitorsStatus().isEmpty());
+ assertEquals(pool.getAdminStateUp(), Boolean.TRUE);
+ assertEquals(pool.getStatus(), LBaaSStatus.PENDING_CREATE);
+ assertNull(pool.getStatusDescription());
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ @Test(expectedExceptions = ResourceNotFoundException.class)
+ public void testCreatePoolFail() throws IOException, InterruptedException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/extension_list_with_lbaas_v1_response.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(404)));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ LBaaSApi lbaasApi = neutronApi.getLBaaSApi("RegionOne").get();
+
+ Pool.CreatePool createPool = Pool.createBuilder("8032909d-47a1-4715-90af-5153ffe39861", Protocol.TCP, Pool.ROUND_ROBIN)
+ .name("NewPool").description(null).healthMonitors(null).provider(null).adminStateUp(null).build();
+
+ lbaasApi.createPool(createPool);
+
+ fail("Should have failed with not found exception");
+
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testListSpecificPagePool() throws IOException, InterruptedException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/extension_list_with_lbaas_v1_response.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(201).setBody(stringFromResource("/lbaas/v1/pool_list_response_paged1.json"))));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ LBaaSApi lbaasApi = neutronApi.getLBaaSApi("RegionOne").get();
+
+ Pools pools = lbaasApi.listPools(PaginationOptions.Builder.limit(2).marker("abcdefg"));
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ server.takeRequest();
+ assertRequest(server.takeRequest(), "GET", "/v2.0/lb/pools?limit=2&marker=abcdefg");
+
+ /*
+ * Check response
+ */
+ assertNotNull(pools);
+ assertEquals(pools.size(), 1);
+ assertEquals(pools.first().get().getId(), "72741b06-df4d-4715-b142-276b6bce75ab");
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testListSpecificPagePoolFail() throws IOException, InterruptedException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/extension_list_with_lbaas_v1_response.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(404)));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ LBaaSApi lbaasApi = neutronApi.getLBaaSApi("RegionOne").get();
+
+ Pools pools = lbaasApi.listPools(PaginationOptions.Builder.limit(2).marker("abcdefg"));
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ server.takeRequest();
+ assertRequest(server.takeRequest(), "GET", "/v2.0/lb/pools?limit=2&marker=abcdefg");
+
+ /*
+ * Check response
+ */
+ assertNotNull(pools);
+ assertTrue(pools.isEmpty());
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testListPagedPool() throws IOException, InterruptedException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/extension_list_with_lbaas_v1_response.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/lbaas/v1/pool_list_response_paged1.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/lbaas/v1/pool_list_response_paged2.json"))));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ LBaaSApi lbaasApi = neutronApi.getLBaaSApi("RegionOne").get();
+
+ // Note: Lazy! Have to actually look at the collection.
+ List<Pool> pools = lbaasApi.listPools().concat().toList();
+
+ /*
+ * Check request
+ */
+ assertEquals(server.getRequestCount(), 4);
+ assertAuthentication(server);
+ server.takeRequest();
+ assertRequest(server.takeRequest(), "GET", "/v2.0/lb/pools");
+ assertRequest(server.takeRequest(), "GET", "/v2.0/lb/pools?marker=71c1e68c-171a-4aa2-aca5-50ea153a3718");
+
+ /*
+ * Check response
+ */
+ assertNotNull(pools);
+ assertEquals(pools.size(), 2);
+ assertEquals(pools.get(0).getId(), "72741b06-df4d-4715-b142-276b6bce75ab");
+ assertEquals(pools.get(1).getId(), "72741b06-df4d-4715-b142-276b6bce75ab_2");
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testListPagedPoolFail() throws IOException, InterruptedException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/extension_list_with_lbaas_v1_response.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(404)));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ LBaaSApi lbaasApi = neutronApi.getLBaaSApi("RegionOne").get();
+
+ // Note: Lazy! Have to actually look at the collection.
+ List<Pool> pools = lbaasApi.listPools().concat().toList();
+
+ /*
+ * Check request
+ */
+ assertEquals(server.getRequestCount(), 3);
+ assertAuthentication(server);
+ server.takeRequest();
+ assertRequest(server.takeRequest(), "GET", "/v2.0/lb/pools");
+
+ /*
+ * Check response
+ */
+ assertNotNull(pools);
+ assertTrue(pools.isEmpty());
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testGetPool() throws IOException, InterruptedException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/extension_list_with_lbaas_v1_response.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(201).setBody(stringFromResource("/lbaas/v1/pool_get_response.json"))));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ LBaaSApi lbaasApi = neutronApi.getLBaaSApi("RegionOne").get();
+
+ Pool pool = lbaasApi.getPool("72741b06-df4d-4715-b142-276b6bce75ab");
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ server.takeRequest();
+ assertRequest(server.takeRequest(), "GET", "/v2.0/lb/pools/72741b06-df4d-4715-b142-276b6bce75ab");
+
+ /*
+ * Check response
+ */
+ assertNotNull(pool);
+ assertEquals(pool.getId(), "72741b06-df4d-4715-b142-276b6bce75ab");
+ assertEquals(pool.getTenantId(), "83657cfcdfe44cd5920adaf26c48ceea");
+ assertNotNull(pool.getVIPId());
+ assertEquals(pool.getName(), "app_pool");
+ assertEquals(pool.getDescription(), "");
+ assertEquals(pool.getSubnetId(), "8032909d-47a1-4715-90af-5153ffe39861");
+ assertEquals(pool.getProtocol(), Protocol.HTTP);
+ assertEquals(pool.getProvider(), "HAPROXY");
+ assertEquals(pool.getLBMethod(), Pool.ROUND_ROBIN);
+ assertNotNull(pool.getMembers());
+ assertEquals(pool.getMembers().size(), 2);
+ assertNotNull(pool.getHealthMonitors());
+ assertEquals(pool.getHealthMonitors().size(), 2);
+ assertNotNull(pool.getHealthMonitorsStatus());
+ assertEquals(pool.getHealthMonitorsStatus().size(), 2);
+ assertEquals(pool.getAdminStateUp(), Boolean.TRUE);
+ assertEquals(pool.getStatus(), LBaaSStatus.ACTIVE);
+ assertNull(pool.getStatusDescription());
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testGetPoolFail() throws IOException, InterruptedException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/extension_list_with_lbaas_v1_response.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(404)));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ LBaaSApi lbaasApi = neutronApi.getLBaaSApi("RegionOne").get();
+
+ Pool pool = lbaasApi.getPool("72741b06-df4d-4715-b142-276b6bce75ab");
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ server.takeRequest();
+ assertRequest(server.takeRequest(), "GET", "/v2.0/lb/pools/72741b06-df4d-4715-b142-276b6bce75ab");
+
+ /*
+ * Check response
+ */
+ assertNull(pool);
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testUpdatePool() throws IOException, InterruptedException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/extension_list_with_lbaas_v1_response.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(201).setBody(stringFromResource("/lbaas/v1/pool_update_response.json"))));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ LBaaSApi lbaasApi = neutronApi.getLBaaSApi("RegionOne").get();
+
+ Pool.UpdatePool updatePool = Pool.updateBuilder().name("new_name").description("new description").lbMethod("NEW_LB_METHOD")
+ .healthMonitors(ImmutableSet.of("5d4b5228-33b0-4e60-b225-9b727c1a20e7")).adminStateUp(Boolean.FALSE).build();
+
+ Pool pool = lbaasApi.updatePool("72741b06-df4d-4715-b142-276b6bce75ab", updatePool);
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ server.takeRequest();
+ assertRequest(server.takeRequest(), "PUT", "/v2.0/lb/pools/72741b06-df4d-4715-b142-276b6bce75ab", "/lbaas/v1/pool_update_request.json");
+
+ /*
+ * Check response
+ */
+ assertNotNull(pool);
+ assertEquals(pool.getId(), "72741b06-df4d-4715-b142-276b6bce75ab");
+ assertEquals(pool.getTenantId(), "83657cfcdfe44cd5920adaf26c48ceea");
+ assertNotNull(pool.getVIPId());
+ assertEquals(pool.getName(), "new_name");
+ assertEquals(pool.getDescription(), "new description");
+ assertEquals(pool.getSubnetId(), "8032909d-47a1-4715-90af-5153ffe39861");
+ assertEquals(pool.getProtocol(), Protocol.HTTP);
+ assertEquals(pool.getProvider(), "HAPROXY");
+ assertEquals(pool.getLBMethod(), "NEW_LB_METHOD");
+ assertNotNull(pool.getMembers());
+ assertEquals(pool.getMembers().size(), 2);
+ assertNotNull(pool.getHealthMonitors());
+ assertEquals(pool.getHealthMonitors().size(), 1);
+ assertEquals(pool.getHealthMonitors().iterator().next(), "5d4b5228-33b0-4e60-b225-9b727c1a20e7");
+ assertNotNull(pool.getHealthMonitorsStatus());
+ assertEquals(pool.getHealthMonitorsStatus().size(), 1);
+ assertEquals(pool.getHealthMonitorsStatus().iterator().next().getId(), "5d4b5228-33b0-4e60-b225-9b727c1a20e7");
+ assertEquals(pool.getAdminStateUp(), Boolean.FALSE);
+ assertEquals(pool.getStatus(), LBaaSStatus.ACTIVE);
+ assertNull(pool.getStatusDescription());
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testUpdatePoolFail() throws IOException, InterruptedException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/extension_list_with_lbaas_v1_response.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(404)));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ LBaaSApi lbaasApi = neutronApi.getLBaaSApi("RegionOne").get();
+
+ Pool.UpdatePool updatePool = Pool.updateBuilder().name("new_name").description("new description").lbMethod("NEW_LB_METHOD")
+ .healthMonitors(ImmutableSet.of("5d4b5228-33b0-4e60-b225-9b727c1a20e7")).adminStateUp(Boolean.FALSE).build();
+
+ Pool pool = lbaasApi.updatePool("72741b06-df4d-4715-b142-276b6bce75ab", updatePool);
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ server.takeRequest();
+ assertRequest(server.takeRequest(), "PUT", "/v2.0/lb/pools/72741b06-df4d-4715-b142-276b6bce75ab", "/lbaas/v1/pool_update_request.json");
+
+ /*
+ * Check response
+ */
+ assertNull(pool);
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testDeletePool() throws IOException, InterruptedException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/extension_list_with_lbaas_v1_response.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(204)));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ LBaaSApi lbaasApi = neutronApi.getLBaaSApi("RegionOne").get();
+
+ boolean result = lbaasApi.deletePool("72741b06-df4d-4715-b142-276b6bce75ab");
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ server.takeRequest();
+ assertRequest(server.takeRequest(), "DELETE", "/v2.0/lb/pools/72741b06-df4d-4715-b142-276b6bce75ab");
+
+ /*
+ * Check response
+ */
+ assertTrue(result);
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testDeletePoolFail() throws IOException, InterruptedException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/extension_list_with_lbaas_v1_response.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(404)));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ LBaaSApi lbaasApi = neutronApi.getLBaaSApi("RegionOne").get();
+
+ boolean result = lbaasApi.deletePool("72741b06-df4d-4715-b142-276b6bce75ab");
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ server.takeRequest();
+ assertRequest(server.takeRequest(), "DELETE", "/v2.0/lb/pools/72741b06-df4d-4715-b142-276b6bce75ab");
+
+ /*
+ * Check response
+ */
+ assertFalse(result);
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testCreateMember() throws IOException, InterruptedException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/extension_list_with_lbaas_v1_response.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(201).setBody(stringFromResource("/lbaas/v1/member_create_response.json"))));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ LBaaSApi lbaasApi = neutronApi.getLBaaSApi("RegionOne").get();
+
+ Member.CreateMember createMember = Member.createBuilder("72741b06-df4d-4715-b142-276b6bce75ab", null, 80)
+ .weight(null).adminStateUp(null).build();
+
+ Member member = lbaasApi.createMember(createMember);
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ server.takeRequest();
+ assertRequest(server.takeRequest(), "POST", "/v2.0/lb/members", "/lbaas/v1/member_create_request.json");
+
+ /*
+ * Check response
+ */
+ assertNotNull(member);
+ assertNotNull(member.getId());
+ assertEquals(member.getTenantId(), "83657cfcdfe44cd5920adaf26c48ceea");
+ assertEquals(member.getPoolId(), "72741b06-df4d-4715-b142-276b6bce75ab");
+ assertNotNull(member.getAddress());
+ assertEquals(member.getProtocolPort(), Integer.valueOf(80));
+ assertEquals(member.getWeight(), Integer.valueOf(1));
+ assertEquals(member.getAdminStateUp(), Boolean.TRUE);
+ assertEquals(member.getStatus(), LBaaSStatus.PENDING_CREATE);
+ assertNull(member.getStatusDescription());
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ @Test(expectedExceptions = ResourceNotFoundException.class)
+ public void testCreateMemberFail() throws IOException, InterruptedException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/extension_list_with_lbaas_v1_response.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(404)));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ LBaaSApi lbaasApi = neutronApi.getLBaaSApi("RegionOne").get();
+
+ Member.CreateMember createMember = Member.createBuilder("72741b06-df4d-4715-b142-276b6bce75ab", null, 80)
+ .weight(null).adminStateUp(null).build();
+
+ lbaasApi.createMember(createMember);
+
+ fail("Should have failed with not found exception");
+
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testListSpecificPageMember() throws IOException, InterruptedException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/extension_list_with_lbaas_v1_response.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(201).setBody(stringFromResource("/lbaas/v1/member_list_response_paged1.json"))));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ LBaaSApi lbaasApi = neutronApi.getLBaaSApi("RegionOne").get();
+
+ Members members = lbaasApi.listMembers(PaginationOptions.Builder.limit(2).marker("abcdefg"));
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ server.takeRequest();
+ assertRequest(server.takeRequest(), "GET", "/v2.0/lb/members?limit=2&marker=abcdefg");
+
+ /*
+ * Check response
+ */
+ assertNotNull(members);
+ assertEquals(members.size(), 1);
+ assertEquals(members.first().get().getId(), "48a471ea-64f1-4eb6-9be7-dae6bbe40a0f");
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testListSpecificPageMemberFail() throws IOException, InterruptedException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/extension_list_with_lbaas_v1_response.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(404)));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ LBaaSApi lbaasApi = neutronApi.getLBaaSApi("RegionOne").get();
+
+ Members members = lbaasApi.listMembers(PaginationOptions.Builder.limit(2).marker("abcdefg"));
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ server.takeRequest();
+ assertRequest(server.takeRequest(), "GET", "/v2.0/lb/members?limit=2&marker=abcdefg");
+
+ /*
+ * Check response
+ */
+ assertNotNull(members);
+ assertTrue(members.isEmpty());
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testListPagedMember() throws IOException, InterruptedException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/extension_list_with_lbaas_v1_response.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/lbaas/v1/member_list_response_paged1.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/lbaas/v1/member_list_response_paged2.json"))));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ LBaaSApi lbaasApi = neutronApi.getLBaaSApi("RegionOne").get();
+
+ // Note: Lazy! Have to actually look at the collection.
+ List<Member> members = lbaasApi.listMembers().concat().toList();
+
+ /*
+ * Check request
+ */
+ assertEquals(server.getRequestCount(), 4);
+ assertAuthentication(server);
+ server.takeRequest();
+ assertRequest(server.takeRequest(), "GET", "/v2.0/lb/members");
+ assertRequest(server.takeRequest(), "GET", "/v2.0/lb/members?marker=396f12f8-521e-4b91-8e21-2e003500433a");
+
+ /*
+ * Check response
+ */
+ assertNotNull(members);
+ assertEquals(members.size(), 2);
+ assertEquals(members.get(0).getId(), "48a471ea-64f1-4eb6-9be7-dae6bbe40a0f");
+ assertEquals(members.get(1).getId(), "701b531b-111a-4f21-ad85-4795b7b12af6");
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testListPagedMemberFail() throws IOException, InterruptedException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/extension_list_with_lbaas_v1_response.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(404)));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ LBaaSApi lbaasApi = neutronApi.getLBaaSApi("RegionOne").get();
+
+ // Note: Lazy! Have to actually look at the collection.
+ List<Member> members = lbaasApi.listMembers().concat().toList();
+
+ /*
+ * Check request
+ */
+ assertEquals(server.getRequestCount(), 3);
+ assertAuthentication(server);
+ server.takeRequest();
+ assertRequest(server.takeRequest(), "GET", "/v2.0/lb/members");
+
+ /*
+ * Check response
+ */
+ assertNotNull(members);
+ assertTrue(members.isEmpty());
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testGetMember() throws IOException, InterruptedException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/extension_list_with_lbaas_v1_response.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(201).setBody(stringFromResource("/lbaas/v1/member_get_response.json"))));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ LBaaSApi lbaasApi = neutronApi.getLBaaSApi("RegionOne").get();
+
+ Member member = lbaasApi.getMember("48a471ea-64f1-4eb6-9be7-dae6bbe40a0f");
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ server.takeRequest();
+ assertRequest(server.takeRequest(), "GET", "/v2.0/lb/members/48a471ea-64f1-4eb6-9be7-dae6bbe40a0f");
+
+ /*
+ * Check response
+ */
+ assertNotNull(member);
+ assertEquals(member.getId(), "48a471ea-64f1-4eb6-9be7-dae6bbe40a0f");
+ assertEquals(member.getTenantId(), "83657cfcdfe44cd5920adaf26c48ceea");
+ assertEquals(member.getPoolId(), "72741b06-df4d-4715-b142-276b6bce75ab");
+ assertEquals(member.getAddress(), "10.0.0.5");
+ assertEquals(member.getProtocolPort(), Integer.valueOf(80));
+ assertEquals(member.getWeight(), Integer.valueOf(1));
+ assertEquals(member.getAdminStateUp(), Boolean.TRUE);
+ assertEquals(member.getStatus(), LBaaSStatus.ACTIVE);
+ assertNull(member.getStatusDescription());
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testGetMemberFail() throws IOException, InterruptedException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/extension_list_with_lbaas_v1_response.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(404)));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ LBaaSApi lbaasApi = neutronApi.getLBaaSApi("RegionOne").get();
+
+ Member member = lbaasApi.getMember("48a471ea-64f1-4eb6-9be7-dae6bbe40a0f");
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ server.takeRequest();
+ assertRequest(server.takeRequest(), "GET", "/v2.0/lb/members/48a471ea-64f1-4eb6-9be7-dae6bbe40a0f");
+
+ /*
+ * Check response
+ */
+ assertNull(member);
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testUpdateMember() throws IOException, InterruptedException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/extension_list_with_lbaas_v1_response.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(201).setBody(stringFromResource("/lbaas/v1/member_update_response.json"))));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ LBaaSApi lbaasApi = neutronApi.getLBaaSApi("RegionOne").get();
+
+ Member.UpdateMember updateMember = Member.updateBuilder().poolId("new_pool_id").weight(2)
+ .adminStateUp(Boolean.FALSE).build();
+
+ Member member = lbaasApi.updateMember("48a471ea-64f1-4eb6-9be7-dae6bbe40a0f", updateMember);
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ server.takeRequest();
+ assertRequest(server.takeRequest(), "PUT", "/v2.0/lb/members/48a471ea-64f1-4eb6-9be7-dae6bbe40a0f", "/lbaas/v1/member_update_request.json");
+
+ /*
+ * Check response
+ */
+ assertNotNull(member);
+ assertEquals(member.getId(), "48a471ea-64f1-4eb6-9be7-dae6bbe40a0f");
+ assertEquals(member.getTenantId(), "83657cfcdfe44cd5920adaf26c48ceea");
+ assertEquals(member.getPoolId(), "new_pool_id");
+ assertEquals(member.getAddress(), "10.0.0.5");
+ assertEquals(member.getProtocolPort(), Integer.valueOf(80));
+ assertEquals(member.getWeight(), Integer.valueOf(2));
+ assertEquals(member.getAdminStateUp(), Boolean.FALSE);
+ assertEquals(member.getStatus(), LBaaSStatus.ACTIVE);
+ assertNull(member.getStatusDescription());
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testUpdateMemberFail() throws IOException, InterruptedException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/extension_list_with_lbaas_v1_response.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(404)));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ LBaaSApi lbaasApi = neutronApi.getLBaaSApi("RegionOne").get();
+
+ Member.UpdateMember updateMember = Member.updateBuilder().poolId("new_pool_id").weight(2)
+ .adminStateUp(Boolean.FALSE).build();
+
+ Member member = lbaasApi.updateMember("48a471ea-64f1-4eb6-9be7-dae6bbe40a0f", updateMember);
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ server.takeRequest();
+ assertRequest(server.takeRequest(), "PUT", "/v2.0/lb/members/48a471ea-64f1-4eb6-9be7-dae6bbe40a0f", "/lbaas/v1/member_update_request.json");
+
+ /*
+ * Check response
+ */
+ assertNull(member);
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testDeleteMember() throws IOException, InterruptedException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/extension_list_with_lbaas_v1_response.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(204)));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ LBaaSApi lbaasApi = neutronApi.getLBaaSApi("RegionOne").get();
+
+ boolean result = lbaasApi.deleteMember("48a471ea-64f1-4eb6-9be7-dae6bbe40a0f");
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ server.takeRequest();
+ assertRequest(server.takeRequest(), "DELETE", "/v2.0/lb/members/48a471ea-64f1-4eb6-9be7-dae6bbe40a0f");
+
+ /*
+ * Check response
+ */
+ assertTrue(result);
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testDeleteMemberFail() throws IOException, InterruptedException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/extension_list_with_lbaas_v1_response.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(404)));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ LBaaSApi lbaasApi = neutronApi.getLBaaSApi("RegionOne").get();
+
+ boolean result = lbaasApi.deleteMember("48a471ea-64f1-4eb6-9be7-dae6bbe40a0f");
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ server.takeRequest();
+ assertRequest(server.takeRequest(), "DELETE", "/v2.0/lb/members/48a471ea-64f1-4eb6-9be7-dae6bbe40a0f");
+
+ /*
+ * Check response
+ */
+ assertFalse(result);
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testCreateVIP() throws IOException, InterruptedException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/extension_list_with_lbaas_v1_response.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(201).setBody(stringFromResource("/lbaas/v1/vip_create_response.json"))));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ LBaaSApi lbaasApi = neutronApi.getLBaaSApi("RegionOne").get();
+
+ VIP.CreateVIP createVIP = VIP.createBuilder("8032909d-47a1-4715-90af-5153ffe39861", Protocol.HTTP, 80, "61b1f87a-7a21-4ad3-9dda-7f81d249944f")
+ .name("NewVip").description(null).address(null).sessionPersistence(null).connectionLimit(null).build();
+
+ VIP vip = lbaasApi.createVIP(createVIP);
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ server.takeRequest();
+ assertRequest(server.takeRequest(), "POST", "/v2.0/lb/vips", "/lbaas/v1/vip_create_request.json");
+
+ /*
+ * Check response
+ */
+ assertNotNull(vip);
+ assertNotNull(vip.getId());
+ assertEquals(vip.getTenantId(), "83657cfcdfe44cd5920adaf26c48ceea");
+ assertEquals(vip.getName(), "NewVip");
+ assertEquals(vip.getDescription(), "");
+ assertEquals(vip.getSubnetId(), "8032909d-47a1-4715-90af-5153ffe39861");
+ assertEquals(vip.getAddress(), "10.0.0.11");
+ assertEquals(vip.getPortId(), "f7e6fe6a-b8b5-43a8-8215-73456b32e0f5");
+ assertEquals(vip.getProtocol(), Protocol.HTTP);
+ assertEquals(vip.getProtocolPort(), Integer.valueOf(80));
+ assertEquals(vip.getPoolId(), "61b1f87a-7a21-4ad3-9dda-7f81d249944f");
+ assertNull(vip.getSessionPersistence());
+ assertEquals(vip.getConnectionLimit(), Integer.valueOf(-1));
+ assertEquals(vip.getAdminStateUp(), Boolean.TRUE);
+ assertEquals(vip.getStatus(), LBaaSStatus.PENDING_CREATE);
+ assertNull(vip.getStatusDescription());
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ @Test(expectedExceptions = ResourceNotFoundException.class)
+ public void testCreateVIPFail() throws IOException, InterruptedException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/extension_list_with_lbaas_v1_response.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(404)));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ LBaaSApi lbaasApi = neutronApi.getLBaaSApi("RegionOne").get();
+
+ VIP.CreateVIP createVIP = VIP.createBuilder("8032909d-47a1-4715-90af-5153ffe39861", Protocol.HTTP, 80, "61b1f87a-7a21-4ad3-9dda-7f81d249944f")
+ .name("NewVip").description(null).address(null).sessionPersistence(null).connectionLimit(null).build();
+
+ lbaasApi.createVIP(createVIP);
+
+ fail("Should have failed with not found exception");
+
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testListSpecificPageVIP() throws IOException, InterruptedException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/extension_list_with_lbaas_v1_response.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(201).setBody(stringFromResource("/lbaas/v1/vip_list_response_paged1.json"))));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ LBaaSApi lbaasApi = neutronApi.getLBaaSApi("RegionOne").get();
+
+ VIPs vips = lbaasApi.listVIPs(PaginationOptions.Builder.limit(2).marker("abcdefg"));
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ server.takeRequest();
+ assertRequest(server.takeRequest(), "GET", "/v2.0/lb/vips?limit=2&marker=abcdefg");
+
+ /*
+ * Check response
+ */
+ assertNotNull(vips);
+ assertEquals(vips.size(), 1);
+ assertEquals(vips.first().get().getId(), "4ec89087-d057-4e2c-911f-60a3b47ee304");
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testListSpecificPageVIPFail() throws IOException, InterruptedException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/extension_list_with_lbaas_v1_response.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(404)));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ LBaaSApi lbaasApi = neutronApi.getLBaaSApi("RegionOne").get();
+
+ VIPs vips = lbaasApi.listVIPs(PaginationOptions.Builder.limit(2).marker("abcdefg"));
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ server.takeRequest();
+ assertRequest(server.takeRequest(), "GET", "/v2.0/lb/vips?limit=2&marker=abcdefg");
+
+ /*
+ * Check response
+ */
+ assertNotNull(vips);
+ assertTrue(vips.isEmpty());
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testListPagedVIP() throws IOException, InterruptedException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/extension_list_with_lbaas_v1_response.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/lbaas/v1/vip_list_response_paged1.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/lbaas/v1/vip_list_response_paged2.json"))));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ LBaaSApi lbaasApi = neutronApi.getLBaaSApi("RegionOne").get();
+
+ // Note: Lazy! Have to actually look at the collection.
+ List<VIP> vips = lbaasApi.listVIPs().concat().toList();
+
+ /*
+ * Check request
+ */
+ assertEquals(server.getRequestCount(), 4);
+ assertAuthentication(server);
+ server.takeRequest();
+ assertRequest(server.takeRequest(), "GET", "/v2.0/lb/vips");
+ assertRequest(server.takeRequest(), "GET", "/v2.0/lb/vips?marker=396f12f8-521e-4b91-8e21-2e003500433a");
+
+ /*
+ * Check response
+ */
+ assertNotNull(vips);
+ assertEquals(vips.size(), 2);
+ assertEquals(vips.get(0).getId(), "4ec89087-d057-4e2c-911f-60a3b47ee304");
+ assertEquals(vips.get(1).getId(), "c987d2be-9a3c-4ac9-a046-e8716b1350e2");
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testListPagedVIPFail() throws IOException, InterruptedException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/extension_list_with_lbaas_v1_response.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(404)));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ LBaaSApi lbaasApi = neutronApi.getLBaaSApi("RegionOne").get();
+
+ // Note: Lazy! Have to actually look at the collection.
+ List<VIP> vips = lbaasApi.listVIPs().concat().toList();
+
+ /*
+ * Check request
+ */
+ assertEquals(server.getRequestCount(), 3);
+ assertAuthentication(server);
+ server.takeRequest();
+ assertRequest(server.takeRequest(), "GET", "/v2.0/lb/vips");
+
+ /*
+ * Check response
+ */
+ assertNotNull(vips);
+ assertTrue(vips.isEmpty());
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testGetVIP() throws IOException, InterruptedException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/extension_list_with_lbaas_v1_response.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(201).setBody(stringFromResource("/lbaas/v1/vip_get_response.json"))));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ LBaaSApi lbaasApi = neutronApi.getLBaaSApi("RegionOne").get();
+
+ VIP vip = lbaasApi.getVIP("4ec89087-d057-4e2c-911f-60a3b47ee304");
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ server.takeRequest();
+ assertRequest(server.takeRequest(), "GET", "/v2.0/lb/vips/4ec89087-d057-4e2c-911f-60a3b47ee304");
+
+ /*
+ * Check response
+ */
+ assertNotNull(vip);
+ assertNotNull(vip.getId());
+ assertEquals(vip.getTenantId(), "83657cfcdfe44cd5920adaf26c48ceea");
+ assertEquals(vip.getName(), "my-vip");
+ assertEquals(vip.getDescription(), "");
+ assertEquals(vip.getSubnetId(), "8032909d-47a1-4715-90af-5153ffe39861");
+ assertEquals(vip.getAddress(), "10.0.0.10");
+ assertEquals(vip.getPortId(), "b5a743d6-056b-468b-862d-fb13a9aa694e");
+ assertEquals(vip.getProtocol(), Protocol.HTTP);
+ assertEquals(vip.getProtocolPort(), Integer.valueOf(80));
+ assertEquals(vip.getPoolId(), "72741b06-df4d-4715-b142-276b6bce75ab");
+ SessionPersistence sessionPersistence = SessionPersistence.builder().type(SessionPersistence.Type.APP_COOKIE).cookieName("MyAppCookie").build();
+ assertEquals(vip.getSessionPersistence(), sessionPersistence);
+ assertEquals(vip.getConnectionLimit(), Integer.valueOf(1000));
+ assertEquals(vip.getAdminStateUp(), Boolean.TRUE);
+ assertEquals(vip.getStatus(), LBaaSStatus.ACTIVE);
+ assertNull(vip.getStatusDescription());
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testGetVIPFail() throws IOException, InterruptedException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/extension_list_with_lbaas_v1_response.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(404)));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ LBaaSApi lbaasApi = neutronApi.getLBaaSApi("RegionOne").get();
+
+ VIP vip = lbaasApi.getVIP("4ec89087-d057-4e2c-911f-60a3b47ee304");
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ server.takeRequest();
+ assertRequest(server.takeRequest(), "GET", "/v2.0/lb/vips/4ec89087-d057-4e2c-911f-60a3b47ee304");
+
+ /*
+ * Check response
+ */
+ assertNull(vip);
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testUpdateVIP() throws IOException, InterruptedException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/extension_list_with_lbaas_v1_response.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(201).setBody(stringFromResource("/lbaas/v1/vip_update_response.json"))));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ LBaaSApi lbaasApi = neutronApi.getLBaaSApi("RegionOne").get();
+
+ SessionPersistence sessionPersistence = SessionPersistence.builder().type(SessionPersistence.Type.APP_COOKIE).cookieName("MyNewAppCookie").build();
+ VIP.UpdateVIP updateVIP = VIP.updateBuilder().name("new-name").description("new description").poolId("61b1f87a-7a21-4ad3-9dda-7f81d249944f")
+ .sessionPersistence(sessionPersistence).connectionLimit(50).adminStateUp(Boolean.FALSE).build();
+
+ VIP vip = lbaasApi.updateVIP("c987d2be-9a3c-4ac9-a046-e8716b1350e2", updateVIP);
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ server.takeRequest();
+ assertRequest(server.takeRequest(), "PUT", "/v2.0/lb/vips/c987d2be-9a3c-4ac9-a046-e8716b1350e2", "/lbaas/v1/vip_update_request.json");
+
+ /*
+ * Check response
+ */
+ assertNotNull(vip);
+ assertNotNull(vip.getId());
+ assertEquals(vip.getTenantId(), "83657cfcdfe44cd5920adaf26c48ceea");
+ assertEquals(vip.getName(), "new-name");
+ assertEquals(vip.getDescription(), "new description");
+ assertEquals(vip.getSubnetId(), "8032909d-47a1-4715-90af-5153ffe39861");
+ assertEquals(vip.getAddress(), "10.0.0.11");
+ assertEquals(vip.getPortId(), "f7e6fe6a-b8b5-43a8-8215-73456b32e0f5");
+ assertEquals(vip.getProtocol(), Protocol.HTTP);
+ assertEquals(vip.getProtocolPort(), Integer.valueOf(80));
+ assertEquals(vip.getPoolId(), "61b1f87a-7a21-4ad3-9dda-7f81d249944f");
+ assertEquals(vip.getSessionPersistence(), sessionPersistence);
+ assertEquals(vip.getConnectionLimit(), Integer.valueOf(50));
+ assertEquals(vip.getAdminStateUp(), Boolean.FALSE);
+ assertEquals(vip.getStatus(), LBaaSStatus.PENDING_UPDATE);
+ assertNull(vip.getStatusDescription());
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testUpdateVIPFail() throws IOException, InterruptedException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/extension_list_with_lbaas_v1_response.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(404)));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ LBaaSApi lbaasApi = neutronApi.getLBaaSApi("RegionOne").get();
+
+ SessionPersistence sessionPersistence = SessionPersistence.builder().type(SessionPersistence.Type.APP_COOKIE).cookieName("MyNewAppCookie").build();
+ VIP.UpdateVIP updateVIP = VIP.updateBuilder().name("new-name").description("new description").poolId("61b1f87a-7a21-4ad3-9dda-7f81d249944f")
+ .sessionPersistence(sessionPersistence).connectionLimit(50).adminStateUp(Boolean.FALSE).build();
+
+ VIP vip = lbaasApi.updateVIP("c987d2be-9a3c-4ac9-a046-e8716b1350e2", updateVIP);
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ server.takeRequest();
+ assertRequest(server.takeRequest(), "PUT", "/v2.0/lb/vips/c987d2be-9a3c-4ac9-a046-e8716b1350e2", "/lbaas/v1/vip_update_request.json");
+
+ /*
+ * Check response
+ */
+ assertNull(vip);
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testDeleteVIP() throws IOException, InterruptedException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/extension_list_with_lbaas_v1_response.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(204)));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ LBaaSApi lbaasApi = neutronApi.getLBaaSApi("RegionOne").get();
+
+ boolean result = lbaasApi.deleteVIP("c987d2be-9a3c-4ac9-a046-e8716b1350e2");
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ server.takeRequest();
+ assertRequest(server.takeRequest(), "DELETE", "/v2.0/lb/vips/c987d2be-9a3c-4ac9-a046-e8716b1350e2");
+
+ /*
+ * Check response
+ */
+ assertTrue(result);
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testDeleteVIPFail() throws IOException, InterruptedException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/extension_list_with_lbaas_v1_response.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(404)));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ LBaaSApi lbaasApi = neutronApi.getLBaaSApi("RegionOne").get();
+
+ boolean result = lbaasApi.deleteVIP("c987d2be-9a3c-4ac9-a046-e8716b1350e2");
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ server.takeRequest();
+ assertRequest(server.takeRequest(), "DELETE", "/v2.0/lb/vips/c987d2be-9a3c-4ac9-a046-e8716b1350e2");
+
+ /*
+ * Check response
+ */
+ assertFalse(result);
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testCreateHealthMonitor() throws IOException, InterruptedException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/extension_list_with_lbaas_v1_response.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(201).setBody(stringFromResource("/lbaas/v1/health_monitor_create_response.json"))));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ LBaaSApi lbaasApi = neutronApi.getLBaaSApi("RegionOne").get();
+
+ HealthMonitor.CreateHealthMonitor createHealthMonitor = HealthMonitor.createBuilder(ProbeType.HTTP, Integer.valueOf(1), Integer.valueOf(1), Integer.valueOf(1))
+ .httpMethod(null).urlPath(null).expectedCodes(null).adminStateUp(null).build();
+
+ HealthMonitor healthMonitor = lbaasApi.createHealthMonitor(createHealthMonitor);
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ server.takeRequest();
+ assertRequest(server.takeRequest(), "POST", "/v2.0/lb/health_monitors", "/lbaas/v1/health_monitor_create_request.json");
+
+ /*
+ * Check response
+ */
+ assertNotNull(healthMonitor);
+ assertNotNull(healthMonitor.getId());
+ assertEquals(healthMonitor.getTenantId(), "4fd44f30292945e481c7b8a0c8908869");
+ assertEquals(healthMonitor.getType(), ProbeType.HTTP);
+ assertEquals(healthMonitor.getDelay(), Integer.valueOf(1));
+ assertEquals(healthMonitor.getTimeout(), Integer.valueOf(1));
+ assertEquals(healthMonitor.getMaxRetries(), Integer.valueOf(1));
+ assertEquals(healthMonitor.getHttpMethod(), HttpMethod.GET);
+ assertEquals(healthMonitor.getUrlPath(), "/");
+ assertEquals(healthMonitor.getExpectedCodes(), "200");
+ assertNotNull(healthMonitor.getPools());
+ assertTrue(healthMonitor.getPools().isEmpty());
+ assertEquals(healthMonitor.getAdminStateUp(), Boolean.TRUE);
+ assertEquals(healthMonitor.getStatus(), LBaaSStatus.PENDING_CREATE);
+ assertNull(healthMonitor.getStatusDescription());
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ @Test(expectedExceptions = ResourceNotFoundException.class)
+ public void testCreateHealthMonitorFail() throws IOException, InterruptedException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/extension_list_with_lbaas_v1_response.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(404)));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ LBaaSApi lbaasApi = neutronApi.getLBaaSApi("RegionOne").get();
+
+ HealthMonitor.CreateHealthMonitor createHealthMonitor = HealthMonitor.createBuilder(ProbeType.HTTP, Integer.valueOf(1), Integer.valueOf(1), Integer.valueOf(1))
+ .httpMethod(null).urlPath(null).expectedCodes(null).adminStateUp(null).build();
+
+ lbaasApi.createHealthMonitor(createHealthMonitor);
+
+ fail("Should have failed with not found exception");
+
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testListSpecificPageHealthMonitor() throws IOException, InterruptedException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/extension_list_with_lbaas_v1_response.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(201).setBody(stringFromResource("/lbaas/v1/health_monitor_list_response_paged1.json"))));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ LBaaSApi lbaasApi = neutronApi.getLBaaSApi("RegionOne").get();
+
+ HealthMonitors healthMonitors = lbaasApi.listHealthMonitors(PaginationOptions.Builder.limit(2).marker("abcdefg"));
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ server.takeRequest();
+ assertRequest(server.takeRequest(), "GET", "/v2.0/lb/health_monitors?limit=2&marker=abcdefg");
+
+ /*
+ * Check response
+ */
+ assertNotNull(healthMonitors);
+ assertEquals(healthMonitors.size(), 1);
+ assertEquals(healthMonitors.first().get().getId(), "466c8345-28d8-4f84-a246-e04380b0461d");
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testListSpecificPageHealthMonitorFail() throws IOException, InterruptedException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/extension_list_with_lbaas_v1_response.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(404)));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ LBaaSApi lbaasApi = neutronApi.getLBaaSApi("RegionOne").get();
+
+ HealthMonitors healthMonitors = lbaasApi.listHealthMonitors(PaginationOptions.Builder.limit(2).marker("abcdefg"));
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ server.takeRequest();
+ assertRequest(server.takeRequest(), "GET", "/v2.0/lb/health_monitors?limit=2&marker=abcdefg");
+
+ /*
+ * Check response
+ */
+ assertNotNull(healthMonitors);
+ assertTrue(healthMonitors.isEmpty());
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testListPagedHealthMonitor() throws IOException, InterruptedException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/extension_list_with_lbaas_v1_response.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/lbaas/v1/health_monitor_list_response_paged1.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/lbaas/v1/health_monitor_list_response_paged2.json"))));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ LBaaSApi lbaasApi = neutronApi.getLBaaSApi("RegionOne").get();
+
+ // Note: Lazy! Have to actually look at the collection.
+ List<HealthMonitor> healthMonitors = lbaasApi.listHealthMonitors().concat().toList();
+
+ /*
+ * Check request
+ */
+ assertEquals(server.getRequestCount(), 4);
+ assertAuthentication(server);
+ server.takeRequest();
+ assertRequest(server.takeRequest(), "GET", "/v2.0/lb/health_monitors");
+ assertRequest(server.takeRequest(), "GET", "/v2.0/lb/health_monitors?marker=396f12f8-521e-4b91-8e21-2e003500433a");
+
+ /*
+ * Check response
+ */
+ assertNotNull(healthMonitors);
+ assertEquals(healthMonitors.size(), 2);
+ assertEquals(healthMonitors.get(0).getId(), "466c8345-28d8-4f84-a246-e04380b0461d");
+ assertEquals(healthMonitors.get(1).getId(), "5d4b5228-33b0-4e60-b225-9b727c1a20e7");
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testListPagedHealthMonitorFail() throws IOException, InterruptedException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/extension_list_with_lbaas_v1_response.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(404)));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ LBaaSApi lbaasApi = neutronApi.getLBaaSApi("RegionOne").get();
+
+ // Note: Lazy! Have to actually look at the collection.
+ List<HealthMonitor> healthMonitors = lbaasApi.listHealthMonitors().concat().toList();
+
+ /*
+ * Check request
+ */
+ assertEquals(server.getRequestCount(), 3);
+ assertAuthentication(server);
+ server.takeRequest();
+ assertRequest(server.takeRequest(), "GET", "/v2.0/lb/health_monitors");
+
+ /*
+ * Check response
+ */
+ assertNotNull(healthMonitors);
+ assertTrue(healthMonitors.isEmpty());
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testGetHealthMonitor() throws IOException, InterruptedException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/extension_list_with_lbaas_v1_response.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(201).setBody(stringFromResource("/lbaas/v1/health_monitor_get_response.json"))));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ LBaaSApi lbaasApi = neutronApi.getLBaaSApi("RegionOne").get();
+
+ HealthMonitor healthMonitor = lbaasApi.getHealthMonitor("5d4b5228-33b0-4e60-b225-9b727c1a20e7");
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ server.takeRequest();
+ assertRequest(server.takeRequest(), "GET", "/v2.0/lb/health_monitors/5d4b5228-33b0-4e60-b225-9b727c1a20e7");
+
+ /*
+ * Check response
+ */
+ assertNotNull(healthMonitor);
+ assertEquals(healthMonitor.getId(), "5d4b5228-33b0-4e60-b225-9b727c1a20e7");
+ assertEquals(healthMonitor.getTenantId(), "4fd44f30292945e481c7b8a0c8908869");
+ assertEquals(healthMonitor.getType(), ProbeType.HTTP);
+ assertEquals(healthMonitor.getDelay(), Integer.valueOf(5));
+ assertEquals(healthMonitor.getTimeout(), Integer.valueOf(2));
+ assertEquals(healthMonitor.getMaxRetries(), Integer.valueOf(2));
+ assertEquals(healthMonitor.getHttpMethod(), HttpMethod.GET);
+ assertEquals(healthMonitor.getUrlPath(), "/");
+ assertEquals(healthMonitor.getExpectedCodes(), "200");
+ assertNotNull(healthMonitor.getPools());
+ assertTrue(healthMonitor.getPools().isEmpty());
+ assertEquals(healthMonitor.getAdminStateUp(), Boolean.TRUE);
+ assertEquals(healthMonitor.getStatus(), LBaaSStatus.ACTIVE);
+ assertNull(healthMonitor.getStatusDescription());
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testGetHealthMonitorFail() throws IOException, InterruptedException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/extension_list_with_lbaas_v1_response.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(404)));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ LBaaSApi lbaasApi = neutronApi.getLBaaSApi("RegionOne").get();
+
+ HealthMonitor healthMonitor = lbaasApi.getHealthMonitor("5d4b5228-33b0-4e60-b225-9b727c1a20e7");
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ server.takeRequest();
+ assertRequest(server.takeRequest(), "GET", "/v2.0/lb/health_monitors/5d4b5228-33b0-4e60-b225-9b727c1a20e7");
+
+ /*
+ * Check response
+ */
+ assertNull(healthMonitor);
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testUpdateHealthMonitor() throws IOException, InterruptedException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/extension_list_with_lbaas_v1_response.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(201).setBody(stringFromResource("/lbaas/v1/health_monitor_update_response.json"))));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ LBaaSApi lbaasApi = neutronApi.getLBaaSApi("RegionOne").get();
+
+ HealthMonitor.UpdateHealthMonitor updateHealthMonitor = HealthMonitor.updateBuilder().delay(Integer.valueOf(1)).timeout(Integer.valueOf(1)).maxRetries(Integer.valueOf(1))
+ .httpMethod(HttpMethod.HEAD).urlPath("/index.html").expectedCodes("201").adminStateUp(Boolean.FALSE).build();
+
+ HealthMonitor healthMonitor = lbaasApi.updateHealthMonitor("466c8345-28d8-4f84-a246-e04380b0461d", updateHealthMonitor);
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ server.takeRequest();
+ assertRequest(server.takeRequest(), "PUT", "/v2.0/lb/health_monitors/466c8345-28d8-4f84-a246-e04380b0461d", "/lbaas/v1/health_monitor_update_request.json");
+
+ /*
+ * Check response
+ */
+ assertNotNull(healthMonitor);
+ assertEquals(healthMonitor.getId(), "466c8345-28d8-4f84-a246-e04380b0461d");
+ assertEquals(healthMonitor.getTenantId(), "4fd44f30292945e481c7b8a0c8908869");
+ assertEquals(healthMonitor.getType(), ProbeType.HTTP);
+ assertEquals(healthMonitor.getDelay(), Integer.valueOf(1));
+ assertEquals(healthMonitor.getTimeout(), Integer.valueOf(1));
+ assertEquals(healthMonitor.getMaxRetries(), Integer.valueOf(1));
+ assertEquals(healthMonitor.getHttpMethod(), HttpMethod.HEAD);
+ assertEquals(healthMonitor.getUrlPath(), "/index.html");
+ assertEquals(healthMonitor.getExpectedCodes(), "201");
+ assertNotNull(healthMonitor.getPools());
+ assertTrue(healthMonitor.getPools().isEmpty());
+ assertEquals(healthMonitor.getAdminStateUp(), Boolean.FALSE);
+ assertEquals(healthMonitor.getStatus(), LBaaSStatus.ACTIVE);
+ assertNull(healthMonitor.getStatusDescription());
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testUpdateHealthMonitorFail() throws IOException, InterruptedException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/extension_list_with_lbaas_v1_response.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(404)));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ LBaaSApi lbaasApi = neutronApi.getLBaaSApi("RegionOne").get();
+
+ HealthMonitor.UpdateHealthMonitor updateHealthMonitor = HealthMonitor.updateBuilder().delay(Integer.valueOf(1)).timeout(Integer.valueOf(1)).maxRetries(Integer.valueOf(1))
+ .httpMethod(HttpMethod.HEAD).urlPath("/index.html").expectedCodes("201").adminStateUp(Boolean.FALSE).build();
+
+ HealthMonitor healthMonitor = lbaasApi.updateHealthMonitor("466c8345-28d8-4f84-a246-e04380b0461d", updateHealthMonitor);
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ server.takeRequest();
+ assertRequest(server.takeRequest(), "PUT", "/v2.0/lb/health_monitors/466c8345-28d8-4f84-a246-e04380b0461d", "/lbaas/v1/health_monitor_update_request.json");
+
+ /*
+ * Check response
+ */
+ assertNull(healthMonitor);
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testDeleteHealthMonitor() throws IOException, InterruptedException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/extension_list_with_lbaas_v1_response.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(204)));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ LBaaSApi lbaasApi = neutronApi.getLBaaSApi("RegionOne").get();
+
+ boolean result = lbaasApi.deleteHealthMonitor("466c8345-28d8-4f84-a246-e04380b0461d");
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ server.takeRequest();
+ assertRequest(server.takeRequest(), "DELETE", "/v2.0/lb/health_monitors/466c8345-28d8-4f84-a246-e04380b0461d");
+
+ /*
+ * Check response
+ */
+ assertTrue(result);
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testDeleteHealthMonitorFail() throws IOException, InterruptedException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/extension_list_with_lbaas_v1_response.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(404)));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ LBaaSApi lbaasApi = neutronApi.getLBaaSApi("RegionOne").get();
+
+ boolean result = lbaasApi.deleteHealthMonitor("466c8345-28d8-4f84-a246-e04380b0461d");
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ server.takeRequest();
+ assertRequest(server.takeRequest(), "DELETE", "/v2.0/lb/health_monitors/466c8345-28d8-4f84-a246-e04380b0461d");
+
+ /*
+ * Check response
+ */
+ assertFalse(result);
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testAssociateHealthMonitorWithPool() throws IOException, InterruptedException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/extension_list_with_lbaas_v1_response.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(201).setBody(stringFromResource("/lbaas/v1/pool_associate_health_monitor_response.json"))));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ LBaaSApi lbaasApi = neutronApi.getLBaaSApi("RegionOne").get();
+
+ HealthMonitor healthMonitor = lbaasApi.associateHealthMonitor("72741b06-df4d-4715-b142-276b6bce75ab", "5d4b5228-33b0-4e60-b225-9b727c1a20e7");
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ server.takeRequest();
+ assertRequest(server.takeRequest(), "POST", "/v2.0/lb/pools/72741b06-df4d-4715-b142-276b6bce75ab/health_monitors", "/lbaas/v1/pool_associate_health_monitor_request.json");
+
+ /*
+ * Check response
+ */
+ assertNotNull(healthMonitor);
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ @Test(expectedExceptions = ResourceNotFoundException.class)
+ public void testAssociateHealthMonitorWithPoolFail() throws IOException, InterruptedException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/extension_list_with_lbaas_v1_response.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(404)));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ LBaaSApi lbaasApi = neutronApi.getLBaaSApi("RegionOne").get();
+
+ lbaasApi.associateHealthMonitor("72741b06-df4d-4715-b142-276b6bce75ab", "5d4b5228-33b0-4e60-b225-9b727c1a20e7");
+
+ fail("Should have failed with not found exception");
+
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testDisassociateHealthMonitorFromPool() throws IOException, InterruptedException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/extension_list_with_lbaas_v1_response.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(204)));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ LBaaSApi lbaasApi = neutronApi.getLBaaSApi("RegionOne").get();
+
+ boolean result = lbaasApi.disassociateHealthMonitor("72741b06-df4d-4715-b142-276b6bce75ab", "5d4b5228-33b0-4e60-b225-9b727c1a20e7");
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ server.takeRequest();
+ assertRequest(server.takeRequest(), "DELETE", "/v2.0/lb/pools/72741b06-df4d-4715-b142-276b6bce75ab/health_monitors/5d4b5228-33b0-4e60-b225-9b727c1a20e7");
+
+ /*
+ * Check response
+ */
+ assertTrue(result);
+ } finally {
+ server.shutdown();
+ }
+ }
+
+ public void testDisassociateHealthMonitorFromPoolFail() throws IOException, InterruptedException {
+ MockWebServer server = mockOpenStackServer();
+ server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(200).setBody(stringFromResource("/extension_list_with_lbaas_v1_response.json"))));
+ server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(404)));
+
+ try {
+ NeutronApi neutronApi = api(server.getUrl("/").toString(), "openstack-neutron", overrides);
+ LBaaSApi lbaasApi = neutronApi.getLBaaSApi("RegionOne").get();
+
+ boolean result = lbaasApi.disassociateHealthMonitor("72741b06-df4d-4715-b142-276b6bce75ab", "5d4b5228-33b0-4e60-b225-9b727c1a20e7");
+
+ /*
+ * Check request
+ */
+ assertAuthentication(server);
+ server.takeRequest();
+ assertRequest(server.takeRequest(), "DELETE", "/v2.0/lb/pools/72741b06-df4d-4715-b142-276b6bce75ab/health_monitors/5d4b5228-33b0-4e60-b225-9b727c1a20e7");
+
+ /*
+ * Check response
+ */
+ assertFalse(result);
+ } finally {
+ server.shutdown();
+ }
+ }
+
+}
[3/5] Support LBaaS v1
Posted by za...@apache.org.
http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/blob/0675d2ea/openstack-neutron/src/test/java/org/jclouds/openstack/neutron/v2/extensions/lbaas/v1/LBaaSApiLiveTest.java
----------------------------------------------------------------------
diff --git a/openstack-neutron/src/test/java/org/jclouds/openstack/neutron/v2/extensions/lbaas/v1/LBaaSApiLiveTest.java b/openstack-neutron/src/test/java/org/jclouds/openstack/neutron/v2/extensions/lbaas/v1/LBaaSApiLiveTest.java
new file mode 100644
index 0000000..64275e0
--- /dev/null
+++ b/openstack-neutron/src/test/java/org/jclouds/openstack/neutron/v2/extensions/lbaas/v1/LBaaSApiLiveTest.java
@@ -0,0 +1,637 @@
+/*
+ * 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.extensions.lbaas.v1;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertNotEquals;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertNull;
+import static org.testng.Assert.assertTrue;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jclouds.logging.Logger;
+import org.jclouds.openstack.neutron.v2.domain.Network;
+import org.jclouds.openstack.neutron.v2.domain.NetworkType;
+import org.jclouds.openstack.neutron.v2.domain.Subnet;
+import org.jclouds.openstack.neutron.v2.domain.lbaas.v1.HealthMonitor;
+import org.jclouds.openstack.neutron.v2.domain.lbaas.v1.HealthMonitors;
+import org.jclouds.openstack.neutron.v2.domain.lbaas.v1.HttpMethod;
+import org.jclouds.openstack.neutron.v2.domain.lbaas.v1.LBaaSStatus;
+import org.jclouds.openstack.neutron.v2.domain.lbaas.v1.Member;
+import org.jclouds.openstack.neutron.v2.domain.lbaas.v1.Members;
+import org.jclouds.openstack.neutron.v2.domain.lbaas.v1.Pool;
+import org.jclouds.openstack.neutron.v2.domain.lbaas.v1.Pools;
+import org.jclouds.openstack.neutron.v2.domain.lbaas.v1.ProbeType;
+import org.jclouds.openstack.neutron.v2.domain.lbaas.v1.Protocol;
+import org.jclouds.openstack.neutron.v2.domain.lbaas.v1.SessionPersistence;
+import org.jclouds.openstack.neutron.v2.domain.lbaas.v1.VIP;
+import org.jclouds.openstack.neutron.v2.domain.lbaas.v1.VIPs;
+import org.jclouds.openstack.neutron.v2.features.NetworkApi;
+import org.jclouds.openstack.neutron.v2.features.SubnetApi;
+import org.jclouds.openstack.neutron.v2.internal.BaseNeutronApiLiveTest;
+import org.jclouds.openstack.v2_0.options.PaginationOptions;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Optional;
+import com.google.common.collect.ImmutableMap;
+
+/**
+ * Tests parsing and Guice wiring of RouterApi
+ */
+@Test(groups = "live", testName = "LBaaSApiLiveTest")
+public class LBaaSApiLiveTest extends BaseNeutronApiLiveTest {
+
+ private Logger logger = getLoggingModule().createLoggerFactory().getLogger(LBaaSApiLiveTest.class.getName());
+
+ private Map<String, Network> networks;
+ private Map<String, Subnet> subnets;
+
+ public void testLBaaSPresence() throws Exception {
+ for (String region : api.getConfiguredRegions()) {
+ Optional<LBaaSApi> lBaaSv1Api = api.getLBaaSApi(region);
+
+ /*
+ * Check response
+ */
+ assertNotNull(lBaaSv1Api);
+ if (lBaaSv1Api.isPresent()) {
+ logger.info("LBaaS API Version 1 is available");
+ } else {
+ logger.info("LBaaS API Version 1 is unavailable");
+ }
+ }
+ }
+
+ @BeforeClass
+ public void createSubnets() {
+ networks = new HashMap<>();
+ subnets = new HashMap<>();
+ for (String region : api.getConfiguredRegions()) {
+ Optional<LBaaSApi> lbaasApiExtension = api.getLBaaSApi(region);
+ if (!lbaasApiExtension.isPresent()) {
+ continue;
+ }
+ NetworkApi networkApi = api.getNetworkApi(region);
+ SubnetApi subnetApi = api.getSubnetApi(region);
+
+ Network network = networkApi.create(Network.createBuilder("jclouds-lbaas-test-network").networkType(NetworkType.LOCAL).build());
+ assertNotNull(network);
+ networks.put(region, network);
+
+ Subnet subnet = subnetApi.create(Subnet.createBuilder(network.getId(), "10.0.0.0/24").ipVersion(4).name("jclouds-lbaas-test-subnet").build());
+ assertNotNull(subnet);
+ subnets.put(region, subnet);
+ }
+ }
+
+ @AfterClass
+ public void deleteSubnets() {
+ for (String region : api.getConfiguredRegions()) {
+ NetworkApi networkApi = api.getNetworkApi(region);
+ SubnetApi subnetApi = api.getSubnetApi(region);
+
+ try {
+ Subnet subnet = subnets.get(region);
+ if (subnet != null) {
+ assertTrue(subnetApi.delete(subnet.getId()));
+ }
+ } finally {
+ Network network = networks.get(region);
+ if (network != null) {
+ assertTrue(networkApi.delete(network.getId()));
+ }
+ }
+ }
+ networks = null;
+ subnets = null;
+ }
+
+ public void testCreateUpdateAndDeletePool() {
+ for (String region : api.getConfiguredRegions()) {
+ Optional<LBaaSApi> lbaasApiExtension = api.getLBaaSApi(region);
+ if (!lbaasApiExtension.isPresent()) {
+ continue;
+ }
+ LBaaSApi lbaasApi = lbaasApiExtension.get();
+
+ Subnet subnet = subnets.get(region);
+ Pool pool = null;
+
+ try {
+ // Create
+ Pool.CreatePool createPool = Pool.createBuilder(subnet.getId(), Protocol.HTTP, Pool.ROUND_ROBIN)
+ .name("jclouds-lbaas-test-pool").description(null).healthMonitors(null).provider(null).adminStateUp(null).build();
+ pool = lbaasApi.createPool(createPool);
+ assertNotNull(pool);
+ assertNotNull(pool.getId());
+ assertEquals(pool.getTenantId(), subnet.getTenantId());
+ assertNull(pool.getVIPId());
+ assertEquals(pool.getName(), "jclouds-lbaas-test-pool");
+ assertEquals(pool.getDescription(), "");
+ assertEquals(pool.getSubnetId(), subnet.getId());
+ assertEquals(pool.getProtocol(), Protocol.HTTP);
+ assertNotNull(pool.getProvider());
+ assertEquals(pool.getLBMethod(), Pool.ROUND_ROBIN);
+ assertNotNull(pool.getHealthMonitors());
+ assertTrue(pool.getHealthMonitors().isEmpty());
+ assertNotNull(pool.getHealthMonitorsStatus());
+ assertTrue(pool.getHealthMonitorsStatus().isEmpty());
+ assertNotNull(pool.getMembers());
+ assertTrue(pool.getMembers().isEmpty());
+ assertEquals(pool.getAdminStateUp(), Boolean.TRUE);
+ assertTrue(pool.getStatus() == LBaaSStatus.PENDING_CREATE || pool.getStatus() == LBaaSStatus.ACTIVE);
+ assertNull(pool.getStatusDescription());
+
+ // List and Get
+ Pools pools = lbaasApi.listPools(PaginationOptions.Builder.queryParameters(ImmutableMap.of("name", "jclouds-lbaas-test-pool").asMultimap()));
+ assertNotNull(pools);
+ assertFalse(pools.isEmpty());
+ Pool poolList = pools.first().get();
+ Pool poolGet = lbaasApi.getPool(poolList.getId());
+ assertNotNull(poolGet);
+ assertEquals(poolGet, poolList);
+
+ poolGet = lbaasApi.getPool(pool.getId());
+ assertNotNull(poolGet);
+ assertEquals(poolGet.getName(), pool.getName());
+ assertEquals(poolGet.getId(), pool.getId());
+
+ // Update
+ Pool.UpdatePool updatePool = Pool.updateBuilder().name("jclouds-lbaas-test-pool-renamed").description("new description").lbMethod(Pool.ROUND_ROBIN)
+ .healthMonitors(null).adminStateUp(Boolean.FALSE).build();
+ Pool poolUpdate = lbaasApi.updatePool(pool.getId(), updatePool);
+ assertNotNull(poolUpdate);
+ assertEquals(poolUpdate.getName(), "jclouds-lbaas-test-pool-renamed");
+ assertEquals(poolUpdate.getLBMethod(), Pool.ROUND_ROBIN);
+ assertNotNull(poolUpdate.getHealthMonitors());
+ assertTrue(poolUpdate.getHealthMonitors().isEmpty());
+ assertNotNull(poolUpdate.getHealthMonitorsStatus());
+ assertTrue(poolUpdate.getHealthMonitorsStatus().isEmpty());
+ assertEquals(poolUpdate.getAdminStateUp(), Boolean.FALSE);
+
+ poolGet = lbaasApi.getPool(pool.getId());
+ assertNotNull(poolGet);
+ assertEquals(poolGet.getId(), pool.getId());
+ assertEquals(poolGet.getTenantId(), subnet.getTenantId());
+ assertNull(poolGet.getVIPId());
+ assertEquals(poolGet.getName(), "jclouds-lbaas-test-pool-renamed");
+ assertEquals(poolGet.getDescription(), "new description");
+ assertEquals(poolGet.getSubnetId(), subnet.getId());
+ assertEquals(poolGet.getProtocol(), Protocol.HTTP);
+ assertNotNull(poolGet.getProvider());
+ assertEquals(poolGet.getLBMethod(), Pool.ROUND_ROBIN);
+ assertNotNull(poolGet.getHealthMonitors());
+ assertTrue(poolGet.getHealthMonitors().isEmpty());
+ assertNotNull(poolGet.getHealthMonitorsStatus());
+ assertTrue(poolGet.getHealthMonitorsStatus().isEmpty());
+ assertNotNull(poolGet.getMembers());
+ assertTrue(poolGet.getMembers().isEmpty());
+ assertEquals(poolGet.getAdminStateUp(), Boolean.FALSE);
+ assertTrue(poolGet.getStatus() == LBaaSStatus.PENDING_UPDATE || poolGet.getStatus() == LBaaSStatus.ACTIVE);
+ assertNull(poolGet.getStatusDescription());
+ } finally {
+ if (pool != null) {
+ // Delete
+ assertTrue(lbaasApi.deletePool(pool.getId()));
+ Pool poolGet = lbaasApi.getPool(pool.getId());
+ assertNull(poolGet);
+ }
+ }
+ }
+ }
+
+ public void testCreateUpdateAndDeleteMember() {
+ for (String region : api.getConfiguredRegions()) {
+ Optional<LBaaSApi> lbaasApiExtension = api.getLBaaSApi(region);
+ if (!lbaasApiExtension.isPresent()) {
+ continue;
+ }
+ LBaaSApi lbaasApi = lbaasApiExtension.get();
+
+ Subnet subnet = subnets.get(region);
+ Pool pool1 = null;
+ Pool pool2 = null;
+ Member member = null;
+
+ try {
+ // Create pools
+ Pool.CreateBuilder createBuilder = Pool.createBuilder(subnet.getId(), Protocol.HTTP, Pool.ROUND_ROBIN)
+ .name("jclouds-lbaas-test-member-pool-1").description(null).healthMonitors(null).provider(null).adminStateUp(null);
+ pool1 = lbaasApi.createPool(createBuilder.build());
+ assertNotNull(pool1);
+ createBuilder.name("jclouds-lbaas-test-member-pool-2");
+ pool2 = lbaasApi.createPool(createBuilder.build());
+ assertNotNull(pool2);
+
+ // Create
+ Member.CreateMember createMember = Member.createBuilder(pool1.getId(), "10.0.0.100", 80)
+ .weight(null).adminStateUp(null).build();
+ member = lbaasApi.createMember(createMember);
+ assertNotNull(member);
+ assertNotNull(member.getId());
+ assertEquals(member.getTenantId(), subnet.getTenantId());
+ assertEquals(member.getPoolId(), pool1.getId());
+ assertEquals(member.getAddress(), "10.0.0.100");
+ assertEquals(member.getProtocolPort(), Integer.valueOf(80));
+ assertEquals(member.getWeight(), Integer.valueOf(1));
+ assertEquals(member.getAdminStateUp(), Boolean.TRUE);
+ assertTrue(member.getStatus() == LBaaSStatus.PENDING_CREATE || member.getStatus() == LBaaSStatus.ACTIVE);
+ assertNull(member.getStatusDescription());
+
+ // List and Get
+ Members members = lbaasApi.listMembers(PaginationOptions.Builder.queryParameters(ImmutableMap.of("tenant_id", subnet.getTenantId()).asMultimap()));
+ assertNotNull(members);
+ assertFalse(members.isEmpty());
+ Member memberList = members.first().get();
+ Member memberGet = lbaasApi.getMember(memberList.getId());
+ assertNotNull(memberGet);
+ assertEquals(memberGet, memberList);
+
+ memberGet = lbaasApi.getMember(member.getId());
+ assertNotNull(memberGet);
+ assertEquals(memberGet.getId(), member.getId());
+
+ // Verify member appears in pool1 and not in pool2
+ Pool pool1Get = lbaasApi.getPool(pool1.getId());
+ assertNotNull(pool1Get);
+ assertNotNull(pool1Get.getMembers());
+ assertFalse(pool1Get.getMembers().isEmpty());
+ assertEquals(pool1Get.getMembers().iterator().next(), member.getId());
+ Pool pool2Get = lbaasApi.getPool(pool2.getId());
+ assertNotNull(pool2Get);
+ assertNotNull(pool2Get.getMembers());
+ assertTrue(pool2Get.getMembers().isEmpty());
+
+ // Update
+ Member.UpdateMember updateMember = Member.updateBuilder()
+ .poolId(pool2.getId()).weight(2).adminStateUp(Boolean.FALSE).build();
+ Member memberUpdate = lbaasApi.updateMember(member.getId(), updateMember);
+ assertNotNull(memberUpdate);
+ assertEquals(memberUpdate.getPoolId(), pool2.getId());
+ assertEquals(memberUpdate.getWeight(), Integer.valueOf(2));
+ assertEquals(memberUpdate.getAdminStateUp(), Boolean.FALSE);
+
+ memberGet = lbaasApi.getMember(member.getId());
+ assertNotNull(memberGet);
+ assertNotNull(memberGet.getId());
+ assertEquals(memberGet.getTenantId(), subnet.getTenantId());
+ assertEquals(memberGet.getPoolId(), pool2.getId());
+ assertEquals(member.getAddress(), "10.0.0.100");
+ assertEquals(memberGet.getProtocolPort(), Integer.valueOf(80));
+ assertEquals(memberGet.getWeight(), Integer.valueOf(2));
+ assertEquals(memberGet.getAdminStateUp(), Boolean.FALSE);
+ assertTrue(memberGet.getStatus() == LBaaSStatus.PENDING_UPDATE || memberGet.getStatus() == LBaaSStatus.ACTIVE);
+ assertNull(memberGet.getStatusDescription());
+
+ // Verify member appears in pool2 and not in pool1
+ pool1Get = lbaasApi.getPool(pool1.getId());
+ assertNotNull(pool1Get);
+ assertNotNull(pool1Get.getMembers());
+ assertTrue(pool1Get.getMembers().isEmpty());
+ pool2Get = lbaasApi.getPool(pool2.getId());
+ assertNotNull(pool2Get);
+ assertNotNull(pool2Get.getMembers());
+ assertFalse(pool2Get.getMembers().isEmpty());
+ assertEquals(pool2Get.getMembers().iterator().next(), member.getId());
+ } finally {
+ if (member != null) {
+ // Delete
+ assertTrue(lbaasApi.deleteMember(member.getId()));
+ Member memberGet = lbaasApi.getMember(member.getId());
+ assertNull(memberGet);
+
+ // Verify member does not appear in pool1 and in pool2
+ Pool pool1Get = lbaasApi.getPool(pool1.getId());
+ assertNotNull(pool1Get);
+ assertNotNull(pool1Get.getMembers());
+ assertTrue(pool1Get.getMembers().isEmpty());
+ Pool pool2Get = lbaasApi.getPool(pool2.getId());
+ assertNotNull(pool2Get);
+ assertNotNull(pool2Get.getMembers());
+ assertTrue(pool2Get.getMembers().isEmpty());
+ }
+ if (pool2 != null) {
+ assertTrue(lbaasApi.deletePool(pool2.getId()));
+ }
+ if (pool1 != null) {
+ assertTrue(lbaasApi.deletePool(pool1.getId()));
+ }
+ }
+ }
+ }
+
+ public void testCreateUpdateAndDeleteVIP() {
+ for (String region : api.getConfiguredRegions()) {
+ Optional<LBaaSApi> lbaasApiExtension = api.getLBaaSApi(region);
+ if (!lbaasApiExtension.isPresent()) {
+ continue;
+ }
+ LBaaSApi lbaasApi = lbaasApiExtension.get();
+
+ Subnet subnet = subnets.get(region);
+ Pool pool1 = null;
+ Pool pool2 = null;
+ VIP vip = null;
+
+ try {
+ // Create pools
+ Pool.CreateBuilder createBuilder = Pool.createBuilder(subnet.getId(), Protocol.HTTP, Pool.ROUND_ROBIN)
+ .name("jclouds-lbaas-test-vip-pool-1").description(null).healthMonitors(null).provider(null).adminStateUp(null);
+ pool1 = lbaasApi.createPool(createBuilder.build());
+ assertNotNull(pool1);
+ createBuilder.name("jclouds-lbaas-test-vip-pool-2");
+ pool2 = lbaasApi.createPool(createBuilder.build());
+ assertNotNull(pool2);
+
+ // Create
+ VIP.CreateVIP createVIP = VIP.createBuilder(subnet.getId(), Protocol.HTTP, 80, pool1.getId())
+ .name("jclouds-lbaas-test-vip").description(null).address(null).sessionPersistence(null).connectionLimit(null).build();
+ vip = lbaasApi.createVIP(createVIP);
+ assertNotNull(vip);
+ assertNotNull(vip.getId());
+ assertEquals(vip.getTenantId(), subnet.getTenantId());
+ assertEquals(vip.getName(), "jclouds-lbaas-test-vip");
+ assertEquals(vip.getDescription(), "");
+ assertEquals(vip.getSubnetId(), subnet.getId());
+ assertNotNull(vip.getAddress());
+ assertNotNull(vip.getPortId());
+ assertEquals(vip.getProtocol(), Protocol.HTTP);
+ assertEquals(vip.getProtocolPort(), Integer.valueOf(80));
+ assertEquals(vip.getPoolId(), pool1.getId());
+ assertNull(vip.getSessionPersistence());
+ assertEquals(vip.getConnectionLimit(), Integer.valueOf(-1));
+ assertEquals(vip.getAdminStateUp(), Boolean.TRUE);
+ assertTrue(vip.getStatus() == LBaaSStatus.PENDING_CREATE || vip.getStatus() == LBaaSStatus.ACTIVE);
+ assertNull(vip.getStatusDescription());
+
+ // List and Get
+ VIPs vips = lbaasApi.listVIPs(PaginationOptions.Builder.queryParameters(ImmutableMap.of("tenant_id", subnet.getTenantId()).asMultimap()));
+ assertNotNull(vips);
+ assertFalse(vips.isEmpty());
+ VIP vipList = vips.first().get();
+ VIP vipGet = lbaasApi.getVIP(vipList.getId());
+ assertNotNull(vipGet);
+ assertEquals(vipGet, vipList);
+
+ vipGet = lbaasApi.getVIP(vip.getId());
+ assertNotNull(vipGet);
+ assertEquals(vipGet.getId(), vip.getId());
+
+ // Verify VIP appears in pool1 and not in pool2
+ Pool pool1Get = lbaasApi.getPool(pool1.getId());
+ assertNotNull(pool1Get);
+ assertEquals(pool1Get.getVIPId(), vip.getId());
+ Pool pool2Get = lbaasApi.getPool(pool2.getId());
+ assertNotNull(pool2Get);
+ assertNotEquals(pool2Get.getVIPId(), vip.getId());
+
+ // Update
+ SessionPersistence sessionPersistence = SessionPersistence.builder().type(SessionPersistence.Type.HTTP_COOKIE).cookieName(null).build();
+ VIP.UpdateVIP updateVIP = VIP.updateBuilder()
+ .name("jclouds-lbaas-test-vip-renamed").description("new description").poolId(pool2.getId())
+ .sessionPersistence(sessionPersistence).connectionLimit(2).adminStateUp(Boolean.FALSE).build();
+ VIP vipUpdate = lbaasApi.updateVIP(vip.getId(), updateVIP);
+ assertNotNull(vipUpdate);
+ assertEquals(vipUpdate.getName(), "jclouds-lbaas-test-vip-renamed");
+ assertEquals(vipUpdate.getDescription(), "new description");
+ assertEquals(vipUpdate.getPoolId(), pool2.getId());
+ assertEquals(vipUpdate.getSessionPersistence(), sessionPersistence);
+ assertEquals(vipUpdate.getConnectionLimit(), Integer.valueOf(2));
+ assertEquals(vipUpdate.getAdminStateUp(), Boolean.FALSE);
+
+ vipGet = lbaasApi.getVIP(vip.getId());
+ assertNotNull(vipGet);
+ assertNotNull(vipGet.getId());
+ assertEquals(vipGet.getTenantId(), subnet.getTenantId());
+ assertEquals(vipGet.getName(), "jclouds-lbaas-test-vip-renamed");
+ assertEquals(vipGet.getDescription(), "new description");
+ assertEquals(vipGet.getSubnetId(), subnet.getId());
+ assertNotNull(vipGet.getAddress());
+ assertNotNull(vipGet.getPortId());
+ assertEquals(vipGet.getProtocol(), Protocol.HTTP);
+ assertEquals(vipGet.getProtocolPort(), Integer.valueOf(80));
+ assertEquals(vipGet.getPoolId(), pool2.getId());
+ assertEquals(vipGet.getSessionPersistence(), sessionPersistence);
+ assertEquals(vipGet.getConnectionLimit(), Integer.valueOf(2));
+ assertEquals(vipGet.getAdminStateUp(), Boolean.FALSE);
+ assertTrue(vipGet.getStatus() == LBaaSStatus.PENDING_UPDATE || vipGet.getStatus() == LBaaSStatus.ACTIVE);
+ assertNull(vipGet.getStatusDescription());
+
+ // Verify VIP appears in pool2 and not in pool1
+ pool1Get = lbaasApi.getPool(pool1.getId());
+ assertNotNull(pool1Get);
+ assertNotEquals(pool1Get.getVIPId(), vip.getId());
+ pool2Get = lbaasApi.getPool(pool2.getId());
+ assertNotNull(pool2Get);
+ assertEquals(pool2Get.getVIPId(), vip.getId());
+ } finally {
+ if (vip != null) {
+ // Delete
+ assertTrue(lbaasApi.deleteVIP(vip.getId()));
+ VIP vipGet = lbaasApi.getVIP(vip.getId());
+ assertNull(vipGet);
+
+ // Verify VIP does not appear in pool1 and in pool2
+ Pool pool1Get = lbaasApi.getPool(pool1.getId());
+ assertNotNull(pool1Get);
+ assertNotEquals(pool1Get.getVIPId(), vip.getId());
+ Pool pool2Get = lbaasApi.getPool(pool2.getId());
+ assertNotNull(pool2Get);
+ assertNotEquals(pool2Get.getVIPId(), vip.getId());
+ }
+ if (pool2 != null) {
+ assertTrue(lbaasApi.deletePool(pool2.getId()));
+ }
+ if (pool1 != null) {
+ assertTrue(lbaasApi.deletePool(pool1.getId()));
+ }
+ }
+ }
+ }
+
+ public void testCreateUpdateAndDeleteHealthMonitor() {
+ for (String region : api.getConfiguredRegions()) {
+ Optional<LBaaSApi> lbaasApiExtension = api.getLBaaSApi(region);
+ if (!lbaasApiExtension.isPresent()) {
+ continue;
+ }
+ LBaaSApi lbaasApi = lbaasApiExtension.get();
+
+ Subnet subnet = subnets.get(region);
+ HealthMonitor healthMonitor = null;
+
+ try {
+ // Create
+ HealthMonitor.CreateHealthMonitor createHealthMonitor = HealthMonitor.createBuilder(ProbeType.HTTP, Integer.valueOf(1), Integer.valueOf(1), Integer.valueOf(1))
+ .httpMethod(null).urlPath(null).expectedCodes(null).adminStateUp(null).build();
+ healthMonitor = lbaasApi.createHealthMonitor(createHealthMonitor);
+ assertNotNull(healthMonitor);
+ assertNotNull(healthMonitor.getId());
+ assertEquals(healthMonitor.getTenantId(), subnet.getTenantId());
+ assertEquals(healthMonitor.getType(), ProbeType.HTTP);
+ assertEquals(healthMonitor.getDelay(), Integer.valueOf(1));
+ assertEquals(healthMonitor.getTimeout(), Integer.valueOf(1));
+ assertEquals(healthMonitor.getMaxRetries(), Integer.valueOf(1));
+ assertEquals(healthMonitor.getHttpMethod(), HttpMethod.GET);
+ assertEquals(healthMonitor.getUrlPath(), "/");
+ assertEquals(healthMonitor.getExpectedCodes(), "200");
+ assertNotNull(healthMonitor.getPools());
+ assertTrue(healthMonitor.getPools().isEmpty());
+ assertEquals(healthMonitor.getAdminStateUp(), Boolean.TRUE);
+ //assertEquals(healthMonitor.getStatus(), LBaaSStatus.PENDING_CREATE);
+ assertNull(healthMonitor.getStatus());
+ assertNull(healthMonitor.getStatusDescription());
+
+ // List and Get
+ HealthMonitors healthMonitors = lbaasApi.listHealthMonitors(PaginationOptions.Builder.queryParameters(ImmutableMap.of("tenant_id", subnet.getTenantId()).asMultimap()));
+ assertNotNull(healthMonitors);
+ assertFalse(healthMonitors.isEmpty());
+ HealthMonitor healthMonitorList = healthMonitors.first().get();
+ HealthMonitor healthMonitorGet = lbaasApi.getHealthMonitor(healthMonitorList.getId());
+ assertNotNull(healthMonitorGet);
+ assertEquals(healthMonitorGet, healthMonitorList);
+
+ healthMonitorGet = lbaasApi.getHealthMonitor(healthMonitor.getId());
+ assertNotNull(healthMonitorGet);
+ assertEquals(healthMonitorGet.getId(), healthMonitor.getId());
+
+ // Update
+ HealthMonitor.UpdateHealthMonitor updateHealthMonitor = HealthMonitor.updateBuilder().delay(Integer.valueOf(2)).timeout(Integer.valueOf(2)).maxRetries(Integer.valueOf(2))
+ .httpMethod(HttpMethod.HEAD).urlPath("/index.html").expectedCodes("201").adminStateUp(Boolean.FALSE).build();
+ HealthMonitor healthMonitorUpdate = lbaasApi.updateHealthMonitor(healthMonitor.getId(), updateHealthMonitor);
+ assertNotNull(healthMonitorUpdate);
+ assertEquals(healthMonitorUpdate.getDelay(), Integer.valueOf(2));
+ assertEquals(healthMonitorUpdate.getTimeout(), Integer.valueOf(2));
+ assertEquals(healthMonitorUpdate.getMaxRetries(), Integer.valueOf(2));
+ assertEquals(healthMonitorUpdate.getHttpMethod(), HttpMethod.HEAD);
+ assertEquals(healthMonitorUpdate.getUrlPath(), "/index.html");
+ assertEquals(healthMonitorUpdate.getExpectedCodes(), "201");
+ assertEquals(healthMonitorUpdate.getAdminStateUp(), Boolean.FALSE);
+
+ healthMonitorGet = lbaasApi.getHealthMonitor(healthMonitor.getId());
+ assertNotNull(healthMonitorGet);
+ assertNotNull(healthMonitorGet.getId());
+ assertEquals(healthMonitorGet.getTenantId(), subnet.getTenantId());
+ assertEquals(healthMonitorGet.getType(), ProbeType.HTTP);
+ assertEquals(healthMonitorGet.getDelay(), Integer.valueOf(2));
+ assertEquals(healthMonitorGet.getTimeout(), Integer.valueOf(2));
+ assertEquals(healthMonitorGet.getMaxRetries(), Integer.valueOf(2));
+ assertEquals(healthMonitorGet.getHttpMethod(), HttpMethod.HEAD);
+ assertEquals(healthMonitorGet.getUrlPath(), "/index.html");
+ assertEquals(healthMonitorGet.getExpectedCodes(), "201");
+ assertNotNull(healthMonitorGet.getPools());
+ assertTrue(healthMonitorGet.getPools().isEmpty());
+ assertEquals(healthMonitorGet.getAdminStateUp(), Boolean.FALSE);
+ //assertEquals(healthMonitorGet.getStatus(), LBaaSStatus.PENDING_UPDATE);
+ assertNull(healthMonitorGet.getStatus());
+ assertNull(healthMonitorGet.getStatusDescription());
+ } finally {
+ if (healthMonitor != null) {
+ // Delete
+ assertTrue(lbaasApi.deleteHealthMonitor(healthMonitor.getId()));
+ HealthMonitor healthMonitorGet = lbaasApi.getHealthMonitor(healthMonitor.getId());
+ assertNull(healthMonitorGet);
+ }
+ }
+ }
+ }
+
+ public void testAssociateAndDisassociateHealthMonitorWithPool() {
+ for (String region : api.getConfiguredRegions()) {
+ Optional<LBaaSApi> lbaasApiExtension = api.getLBaaSApi(region);
+ if (!lbaasApiExtension.isPresent()) {
+ continue;
+ }
+ LBaaSApi lbaasApi = lbaasApiExtension.get();
+
+ Subnet subnet = subnets.get(region);
+ Pool pool = null;
+ HealthMonitor healthMonitor = null;
+
+ try {
+ // Create pool
+ Pool.CreatePool poolCreateOptions = Pool.createBuilder(subnet.getId(), Protocol.TCP, Pool.ROUND_ROBIN)
+ .name("jclouds-lbaas-test-pool-association").build();
+ pool = lbaasApi.createPool(poolCreateOptions);
+ assertNotNull(pool);
+ assertNotNull(pool.getId());
+ assertNotNull(pool.getHealthMonitors());
+ assertTrue(pool.getHealthMonitors().isEmpty());
+ assertNotNull(pool.getHealthMonitorsStatus());
+ assertTrue(pool.getHealthMonitorsStatus().isEmpty());
+
+ // Create health monitor
+ HealthMonitor.CreateHealthMonitor healthMonitorCreateOptions = HealthMonitor.createBuilder(ProbeType.HTTP, Integer.valueOf(1), Integer.valueOf(1), Integer.valueOf(1)).build();
+ healthMonitor = lbaasApi.createHealthMonitor(healthMonitorCreateOptions);
+ assertNotNull(healthMonitor);
+ assertNotNull(healthMonitor.getId());
+ assertNotNull(healthMonitor.getPools());
+ assertTrue(healthMonitor.getPools().isEmpty());
+
+ // Associate health monitor with pool
+ HealthMonitor healthMonitorAssociated = lbaasApi.associateHealthMonitor(pool.getId(), healthMonitor.getId());
+ assertNotNull(healthMonitorAssociated);
+
+ // Verify health monitor is associated with pool
+ Pool poolGet = lbaasApi.getPool(pool.getId());
+ assertNotNull(poolGet);
+ assertNotNull(poolGet.getHealthMonitors());
+ assertEquals(poolGet.getHealthMonitors().size(), 1);
+ assertEquals(poolGet.getHealthMonitors().iterator().next(), healthMonitor.getId());
+ assertNotNull(poolGet.getHealthMonitorsStatus());
+ assertEquals(poolGet.getHealthMonitorsStatus().size(), 1);
+ assertEquals(poolGet.getHealthMonitorsStatus().iterator().next().getId(), healthMonitor.getId());
+
+ HealthMonitor healthMonitorGet = lbaasApi.getHealthMonitor(healthMonitor.getId());
+ assertNotNull(healthMonitorGet);
+ assertNotNull(healthMonitorGet.getPools());
+ assertEquals(healthMonitorGet.getPools().size(), 1);
+ assertEquals(healthMonitorGet.getPools().iterator().next().getId(), pool.getId());
+
+ // Disassociate health monitor from pool
+ assertTrue(lbaasApi.disassociateHealthMonitor(pool.getId(), healthMonitor.getId()));
+
+ // Verify health monitor is disassociated from pool
+ poolGet = lbaasApi.getPool(pool.getId());
+ assertNotNull(poolGet);
+ assertNotNull(poolGet.getHealthMonitors());
+ assertTrue(poolGet.getHealthMonitors().isEmpty());
+ assertNotNull(poolGet.getHealthMonitorsStatus());
+ assertTrue(poolGet.getHealthMonitorsStatus().isEmpty());
+
+ healthMonitorGet = lbaasApi.getHealthMonitor(healthMonitor.getId());
+ assertNotNull(healthMonitorGet);
+ assertNotNull(healthMonitorGet.getPools());
+ assertTrue(healthMonitorGet.getPools().isEmpty());
+ } finally {
+ if (healthMonitor != null) {
+ assertTrue(lbaasApi.deleteHealthMonitor(healthMonitor.getId()));
+ }
+ if (pool != null) {
+ assertTrue(lbaasApi.deletePool(pool.getId()));
+ }
+ }
+ }
+ }
+
+}
[5/5] git commit: Support LBaaS v1
Posted by za...@apache.org.
Support LBaaS v1
Project: http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/commit/0675d2ea
Tree: http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/tree/0675d2ea
Diff: http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/diff/0675d2ea
Branch: refs/heads/master
Commit: 0675d2eabb8db835bcaf35a2543610536adad307
Parents: 7557224
Author: fbrouille <f....@akka.eu>
Authored: Wed Oct 1 11:34:03 2014 +0200
Committer: Zack Shoylev <za...@rackspace.com>
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-labs-openstack/blob/0675d2ea/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/NeutronApi.java
----------------------------------------------------------------------
diff --git a/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/NeutronApi.java b/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/NeutronApi.java
index b54fa39..983fe94 100644
--- a/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/NeutronApi.java
+++ b/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-labs-openstack/blob/0675d2ea/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/config/NeutronHttpApiModule.java
----------------------------------------------------------------------
diff --git a/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/config/NeutronHttpApiModule.java b/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/config/NeutronHttpApiModule.java
index f05439a..e7b33c6 100644
--- a/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/config/NeutronHttpApiModule.java
+++ b/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-labs-openstack/blob/0675d2ea/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/HealthMonitor.java
----------------------------------------------------------------------
diff --git a/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/HealthMonitor.java b/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/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-labs-openstack/blob/0675d2ea/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/HealthMonitorStatus.java
----------------------------------------------------------------------
diff --git a/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/HealthMonitorStatus.java b/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/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-labs-openstack/blob/0675d2ea/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/HealthMonitors.java
----------------------------------------------------------------------
diff --git a/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/HealthMonitors.java b/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/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-labs-openstack/blob/0675d2ea/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/HttpMethod.java
----------------------------------------------------------------------
diff --git a/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/HttpMethod.java b/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/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-labs-openstack/blob/0675d2ea/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/LBaaSStatus.java
----------------------------------------------------------------------
diff --git a/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/LBaaSStatus.java b/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/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-labs-openstack/blob/0675d2ea/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/Member.java
----------------------------------------------------------------------
diff --git a/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/Member.java b/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/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-labs-openstack/blob/0675d2ea/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/Members.java
----------------------------------------------------------------------
diff --git a/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/Members.java b/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/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-labs-openstack/blob/0675d2ea/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/Pool.java
----------------------------------------------------------------------
diff --git a/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/Pool.java b/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/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-labs-openstack/blob/0675d2ea/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/PoolStatus.java
----------------------------------------------------------------------
diff --git a/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/PoolStatus.java b/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/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-labs-openstack/blob/0675d2ea/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/Pools.java
----------------------------------------------------------------------
diff --git a/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/Pools.java b/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/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-labs-openstack/blob/0675d2ea/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/ProbeType.java
----------------------------------------------------------------------
diff --git a/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/ProbeType.java b/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/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-labs-openstack/blob/0675d2ea/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/Protocol.java
----------------------------------------------------------------------
diff --git a/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/Protocol.java b/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/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-labs-openstack/blob/0675d2ea/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/SessionPersistence.java
----------------------------------------------------------------------
diff --git a/openstack-neutron/src/main/java/org/jclouds/openstack/neutron/v2/domain/lbaas/v1/SessionPersistence.java b/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/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;
+ }
+ }
+}