summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCraig Tracey <craigtracey@gmail.com>2014-08-02 11:26:59 -0400
committerMichael Johnson <johnsom@hp.com>2015-02-04 21:29:22 +0000
commit0be3b622c656a80709f015e6c250aa1917da39e9 (patch)
treeb695129d5d7acda6db6331e2bf0ca46b160e49c8
parent2dce00b41dd6d6206566085161dc0958e805a9b9 (diff)
downloadpython-neutronclient-0be3b622c656a80709f015e6c250aa1917da39e9.tar.gz
Implement LBaaS object model v2
This change implements the LBaaS v2 object model changes necessary for python-neutronclient. It includes new objects loadbalancer and listener, as well as new implementations for pool, member, and healthmonitor. While many constructs are the same as in v1, many are not, and have therefore been namespaced under lb/v2. This client now supports both the v1 and v2 implementations simultaneously. v1 commands retain their original form: neutron lb-<object>-<command> and v2 commands take the form: neutron lbaas-<object>-<command> Co-Authored-By: Michael Johnson <johnsom@hp.com> Change-Id: I970b1de39d0dd8872459a584dd1f5c9110796ac9 Partially-implements: blueprint lbaas-api-and-objmodel-improvement DocImpact
-rw-r--r--neutronclient/neutron/v2_0/__init__.py17
-rw-r--r--neutronclient/neutron/v2_0/lb/member.py6
-rw-r--r--neutronclient/neutron/v2_0/lb/v2/__init__.py0
-rw-r--r--neutronclient/neutron/v2_0/lb/v2/healthmonitor.py118
-rw-r--r--neutronclient/neutron/v2_0/lb/v2/listener.py114
-rw-r--r--neutronclient/neutron/v2_0/lb/v2/loadbalancer.py93
-rw-r--r--neutronclient/neutron/v2_0/lb/v2/member.py143
-rw-r--r--neutronclient/neutron/v2_0/lb/v2/pool.py134
-rw-r--r--neutronclient/shell.py30
-rw-r--r--neutronclient/tests/unit/lb/v2/__init__.py0
-rw-r--r--neutronclient/tests/unit/lb/v2/test_cli20_healthmonitor.py154
-rw-r--r--neutronclient/tests/unit/lb/v2/test_cli20_listener.py137
-rw-r--r--neutronclient/tests/unit/lb/v2/test_cli20_loadbalancer.py137
-rw-r--r--neutronclient/tests/unit/lb/v2/test_cli20_member.py159
-rw-r--r--neutronclient/tests/unit/lb/v2/test_cli20_pool.py149
-rw-r--r--neutronclient/tests/unit/test_cli20.py4
-rw-r--r--neutronclient/v2_0/client.py167
17 files changed, 1557 insertions, 5 deletions
diff --git a/neutronclient/neutron/v2_0/__init__.py b/neutronclient/neutron/v2_0/__init__.py
index 2cda5d6..8725b4a 100644
--- a/neutronclient/neutron/v2_0/__init__.py
+++ b/neutronclient/neutron/v2_0/__init__.py
@@ -411,7 +411,11 @@ class NeutronCommand(command.OpenStackCommand):
return parser
+ def cleanup_output_data(self, data):
+ pass
+
def format_output_data(self, data):
+ self.cleanup_output_data(data)
# Modify data to make it more readable
if self.resource in data:
for k, v in six.iteritems(data[self.resource]):
@@ -429,6 +433,9 @@ class NeutronCommand(command.OpenStackCommand):
def add_known_arguments(self, parser):
pass
+ def set_extra_attrs(self, parsed_args):
+ pass
+
def args2body(self, parsed_args):
return {}
@@ -452,6 +459,7 @@ class CreateCommand(NeutronCommand, show.ShowOne):
def get_data(self, parsed_args):
self.log.debug('get_data(%s)' % parsed_args)
+ self.set_extra_attrs(parsed_args)
neutron_client = self.get_client()
neutron_client.format = parsed_args.request_format
_extra_values = parse_args_to_dict(self.values_specs)
@@ -492,6 +500,7 @@ class UpdateCommand(NeutronCommand):
def run(self, parsed_args):
self.log.debug('run(%s)', parsed_args)
+ self.set_extra_attrs(parsed_args)
neutron_client = self.get_client()
neutron_client.format = parsed_args.request_format
_extra_values = parse_args_to_dict(self.values_specs)
@@ -509,7 +518,7 @@ class UpdateCommand(NeutronCommand):
if self.allow_names:
_id = find_resourceid_by_name_or_id(
neutron_client, self.resource, parsed_args.id,
- cmd_resource=self.cmd_resource)
+ cmd_resource=self.cmd_resource, parent_id=self.parent_id)
else:
_id = find_resourceid_by_id(
neutron_client, self.resource, parsed_args.id,
@@ -542,10 +551,12 @@ class DeleteCommand(NeutronCommand):
parser.add_argument(
'id', metavar=self.resource.upper(),
help=help_str % self.resource)
+ self.add_known_arguments(parser)
return parser
def run(self, parsed_args):
self.log.debug('run(%s)', parsed_args)
+ self.set_extra_attrs(parsed_args)
neutron_client = self.get_client()
neutron_client.format = parsed_args.request_format
obj_deleter = getattr(neutron_client,
@@ -589,6 +600,7 @@ class ListCommand(NeutronCommand, lister.Lister):
add_pagination_argument(parser)
if self.sorting_support:
add_sorting_argument(parser)
+ self.add_known_arguments(parser)
return parser
def args2search_opts(self, parsed_args):
@@ -674,6 +686,7 @@ class ListCommand(NeutronCommand, lister.Lister):
def get_data(self, parsed_args):
self.log.debug('get_data(%s)', parsed_args)
+ self.set_extra_attrs(parsed_args)
data = self.retrieve_list(parsed_args)
self.extend_list(data, parsed_args)
return self.setup_columns(data, parsed_args)
@@ -696,10 +709,12 @@ class ShowCommand(NeutronCommand, show.ShowOne):
parser.add_argument(
'id', metavar=self.resource.upper(),
help=help_str % self.resource)
+ self.add_known_arguments(parser)
return parser
def get_data(self, parsed_args):
self.log.debug('get_data(%s)', parsed_args)
+ self.set_extra_attrs(parsed_args)
neutron_client = self.get_client()
neutron_client.format = parsed_args.request_format
diff --git a/neutronclient/neutron/v2_0/lb/member.py b/neutronclient/neutron/v2_0/lb/member.py
index aeed319..6effb30 100644
--- a/neutronclient/neutron/v2_0/lb/member.py
+++ b/neutronclient/neutron/v2_0/lb/member.py
@@ -45,9 +45,6 @@ class CreateMember(neutronV20.CreateCommand):
def add_known_arguments(self, parser):
parser.add_argument(
- 'pool_id', metavar='POOL',
- help=_('Pool ID or name this vip belongs to.'))
- parser.add_argument(
'--admin-state-down',
dest='admin_state', action='store_false',
help=_('Set admin state up to false.'))
@@ -63,6 +60,9 @@ class CreateMember(neutronV20.CreateCommand):
required=True,
help=_('Port on which the pool member listens for requests or '
'connections.'))
+ parser.add_argument(
+ 'pool_id', metavar='POOL',
+ help=_('Pool ID or name this vip belongs to.'))
def args2body(self, parsed_args):
_pool_id = neutronV20.find_resourceid_by_name_or_id(
diff --git a/neutronclient/neutron/v2_0/lb/v2/__init__.py b/neutronclient/neutron/v2_0/lb/v2/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/neutronclient/neutron/v2_0/lb/v2/__init__.py
diff --git a/neutronclient/neutron/v2_0/lb/v2/healthmonitor.py b/neutronclient/neutron/v2_0/lb/v2/healthmonitor.py
new file mode 100644
index 0000000..23136f7
--- /dev/null
+++ b/neutronclient/neutron/v2_0/lb/v2/healthmonitor.py
@@ -0,0 +1,118 @@
+# Copyright 2013 Mirantis Inc.
+# Copyright 2014 Blue Box Group, Inc.
+# All Rights Reserved
+#
+# Author: Ilya Shakhat, Mirantis Inc.
+# Author: Craig Tracey <craigtracey@gmail.com>
+#
+# Licensed 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.
+#
+
+from neutronclient.i18n import _
+from neutronclient.neutron import v2_0 as neutronV20
+
+
+class ListHealthMonitor(neutronV20.ListCommand):
+ """LBaaS v2 List healthmonitors that belong to a given tenant."""
+
+ resource = 'healthmonitor'
+ shadow_resource = 'lbaas_healthmonitor'
+ list_columns = ['id', 'type', 'admin_state_up']
+ pagination_support = True
+ sorting_support = True
+
+
+class ShowHealthMonitor(neutronV20.ShowCommand):
+ """LBaaS v2 Show information of a given healthmonitor."""
+
+ resource = 'healthmonitor'
+ shadow_resource = 'lbaas_healthmonitor'
+
+
+class CreateHealthMonitor(neutronV20.CreateCommand):
+ """LBaaS v2 Create a healthmonitor."""
+
+ resource = 'healthmonitor'
+ shadow_resource = 'lbaas_healthmonitor'
+
+ def add_known_arguments(self, parser):
+ parser.add_argument(
+ '--admin-state-down',
+ dest='admin_state', action='store_false',
+ help=_('Set admin state up to false.'))
+ parser.add_argument(
+ '--expected-codes',
+ help=_('The list of HTTP status codes expected in '
+ 'response from the member to declare it healthy. This '
+ 'attribute can contain one value, '
+ 'or a list of values separated by comma, '
+ 'or a range of values (e.g. "200-299"). If this attribute '
+ 'is not specified, it defaults to "200".'))
+ parser.add_argument(
+ '--http-method',
+ help=_('The HTTP method used for requests by the monitor of type '
+ 'HTTP.'))
+ parser.add_argument(
+ '--url-path',
+ help=_('The HTTP path used in the HTTP request used by the monitor'
+ ' to test a member health. This must be a string '
+ 'beginning with a / (forward slash).'))
+ parser.add_argument(
+ '--delay',
+ required=True,
+ help=_('The time in seconds between sending probes to members.'))
+ parser.add_argument(
+ '--max-retries',
+ required=True,
+ help=_('Number of permissible connection failures before changing '
+ 'the member status to INACTIVE. [1..10].'))
+ parser.add_argument(
+ '--timeout',
+ required=True,
+ help=_('Maximum number of seconds for a monitor to wait for a '
+ 'connection to be established before it times out. The '
+ 'value must be less than the delay value.'))
+ parser.add_argument(
+ '--type',
+ required=True, choices=['PING', 'TCP', 'HTTP', 'HTTPS'],
+ help=_('One of the predefined health monitor types.'))
+
+ def args2body(self, parsed_args):
+ body = {
+ self.resource: {
+ 'admin_state_up': parsed_args.admin_state,
+ 'delay': parsed_args.delay,
+ 'max_retries': parsed_args.max_retries,
+ 'timeout': parsed_args.timeout,
+ 'type': parsed_args.type,
+ },
+ }
+ neutronV20.update_dict(parsed_args, body[self.resource],
+ ['expected_codes', 'http_method', 'url_path',
+ 'tenant_id'])
+ return body
+
+
+class UpdateHealthMonitor(neutronV20.UpdateCommand):
+ """LBaaS v2 Update a given healthmonitor."""
+
+ resource = 'healthmonitor'
+ shadow_resource = 'lbaas_healthmonitor'
+ allow_names = False
+
+
+class DeleteHealthMonitor(neutronV20.DeleteCommand):
+ """LBaaS v2 Delete a given healthmonitor."""
+
+ resource = 'healthmonitor'
+ shadow_resource = 'lbaas_healthmonitor'
diff --git a/neutronclient/neutron/v2_0/lb/v2/listener.py b/neutronclient/neutron/v2_0/lb/v2/listener.py
new file mode 100644
index 0000000..6b398ff
--- /dev/null
+++ b/neutronclient/neutron/v2_0/lb/v2/listener.py
@@ -0,0 +1,114 @@
+# Copyright 2014 Blue Box Group, Inc.
+# Copyright 2015 Hewlett-Packard Development Company, L.P.
+# All Rights Reserved
+#
+# Author: Craig Tracey <craigtracey@gmail.com>
+#
+# Licensed 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.
+#
+
+from neutronclient.i18n import _
+from neutronclient.neutron import v2_0 as neutronV20
+
+
+def _get_loadbalancer_id(client, lb_id_or_name):
+ return neutronV20.find_resourceid_by_name_or_id(
+ client,
+ 'loadbalancer',
+ lb_id_or_name,
+ cmd_resource='lbaas_loadbalancer')
+
+
+class ListListener(neutronV20.ListCommand):
+ """LBaaS v2 List listeners that belong to a given tenant."""
+
+ resource = 'listener'
+ list_columns = ['id', 'default_pool_id', 'name', 'protocol',
+ 'protocol_port', 'admin_state_up', 'status']
+ pagination_support = True
+ sorting_support = True
+
+
+class ShowListener(neutronV20.ShowCommand):
+ """LBaaS v2 Show information of a given listener."""
+
+ resource = 'listener'
+
+
+class CreateListener(neutronV20.CreateCommand):
+ """LBaaS v2 Create a listener."""
+
+ resource = 'listener'
+
+ def add_known_arguments(self, parser):
+ parser.add_argument(
+ '--admin-state-down',
+ dest='admin_state', action='store_false',
+ help=_('Set admin state up to false.'))
+ parser.add_argument(
+ '--connection-limit',
+ help=_('The maximum number of connections per second allowed for '
+ 'the vip. Positive integer or -1 for unlimited (default).'))
+ parser.add_argument(
+ '--description',
+ help=_('Description of the listener.'))
+ parser.add_argument(
+ '--name',
+ help=_('The name of the listener.'))
+ parser.add_argument(
+ '--loadbalancer',
+ required=True,
+ metavar='LOADBALANCER',
+ help=_('ID or name of the load balancer.'))
+ parser.add_argument(
+ '--protocol',
+ required=True,
+ choices=['TCP', 'HTTP', 'HTTPS'],
+ help=_('Protocol for the listener.'))
+ parser.add_argument(
+ '--protocol-port',
+ dest='protocol_port', required=True,
+ metavar='PORT',
+ help=_('Protocol port for the listener.'))
+
+ def args2body(self, parsed_args):
+ if parsed_args.loadbalancer:
+ parsed_args.loadbalancer = _get_loadbalancer_id(
+ self.get_client(),
+ parsed_args.loadbalancer)
+ body = {
+ self.resource: {
+ 'loadbalancer_id': parsed_args.loadbalancer,
+ 'protocol': parsed_args.protocol,
+ 'protocol_port': parsed_args.protocol_port,
+ 'admin_state_up': parsed_args.admin_state,
+ },
+ }
+
+ neutronV20.update_dict(parsed_args, body[self.resource],
+ ['connection-limit', 'description',
+ 'loadbalancer_id', 'name'])
+ return body
+
+
+class UpdateListener(neutronV20.UpdateCommand):
+ """LBaaS v2 Update a given listener."""
+
+ resource = 'listener'
+ allow_names = False
+
+
+class DeleteListener(neutronV20.DeleteCommand):
+ """LBaaS v2 Delete a given listener."""
+
+ resource = 'listener'
diff --git a/neutronclient/neutron/v2_0/lb/v2/loadbalancer.py b/neutronclient/neutron/v2_0/lb/v2/loadbalancer.py
new file mode 100644
index 0000000..576c5fa
--- /dev/null
+++ b/neutronclient/neutron/v2_0/lb/v2/loadbalancer.py
@@ -0,0 +1,93 @@
+# Copyright 2014 Blue Box Group, Inc.
+# Copyright 2015 Hewlett-Packard Development Company, L.P.
+# All Rights Reserved
+#
+# Author: Craig Tracey <craigtracey@gmail.com>
+#
+# Licensed 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.
+#
+
+from neutronclient.i18n import _
+from neutronclient.neutron import v2_0 as neutronV20
+
+
+class ListLoadBalancer(neutronV20.ListCommand):
+ """LBaaS v2 List loadbalancers that belong to a given tenant."""
+
+ resource = 'loadbalancer'
+ list_columns = ['id', 'name', 'vip_address',
+ 'provisioning_status', 'provider']
+ pagination_support = True
+ sorting_support = True
+
+
+class ShowLoadBalancer(neutronV20.ShowCommand):
+ """LBaaS v2 Show information of a given loadbalancer."""
+
+ resource = 'loadbalancer'
+
+
+class CreateLoadBalancer(neutronV20.CreateCommand):
+ """LBaaS v2 Create a loadbalancer."""
+
+ resource = 'loadbalancer'
+ allow_names = True
+
+ def add_known_arguments(self, parser):
+ parser.add_argument(
+ '--description',
+ help=_('Description of the load balancer.'))
+ parser.add_argument(
+ '--admin-state-down',
+ dest='admin_state', action='store_false',
+ help=_('Set admin state up to false.'))
+ parser.add_argument(
+ '--name', metavar='NAME',
+ help=_('Name of the load balancer.'))
+ parser.add_argument(
+ '--provider',
+ help=_('Provider name of load balancer service.'))
+ parser.add_argument(
+ '--vip-address',
+ help=_('VIP address for the load balancer.'))
+ parser.add_argument(
+ 'vip_subnet', metavar='VIP_SUBNET',
+ help=_('Load balancer VIP subnet.'))
+
+ def args2body(self, parsed_args):
+ _subnet_id = neutronV20.find_resourceid_by_name_or_id(
+ self.get_client(), 'subnet', parsed_args.vip_subnet)
+ body = {
+ self.resource: {
+ 'name': parsed_args.name,
+ 'vip_subnet_id': _subnet_id,
+ 'admin_state_up': parsed_args.admin_state,
+ },
+ }
+ neutronV20.update_dict(parsed_args, body[self.resource],
+ ['description', 'provider', 'vip_address'])
+ return body
+
+
+class UpdateLoadBalancer(neutronV20.UpdateCommand):
+ """LBaaS v2 Update a given loadbalancer."""
+
+ resource = 'loadbalancer'
+ allow_names = True
+
+
+class DeleteLoadBalancer(neutronV20.DeleteCommand):
+ """LBaaS v2 Delete a given loadbalancer."""
+
+ resource = 'loadbalancer'
+ allow_names = True
diff --git a/neutronclient/neutron/v2_0/lb/v2/member.py b/neutronclient/neutron/v2_0/lb/v2/member.py
new file mode 100644
index 0000000..4709f65
--- /dev/null
+++ b/neutronclient/neutron/v2_0/lb/v2/member.py
@@ -0,0 +1,143 @@
+# Copyright 2013 Mirantis Inc.
+# Copyright 2014 Blue Box Group, Inc.
+# Copyright 2015 Hewlett-Packard Development Company, L.P.
+# All Rights Reserved
+#
+# Author: Ilya Shakhat, Mirantis Inc.
+# Author: Craig Tracey <craigtracey@gmail.com>
+#
+# Licensed 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.
+#
+
+from neutronclient.i18n import _
+from neutronclient.neutron import v2_0 as neutronV20
+
+
+def _get_pool_id(client, pool_id_or_name):
+ return neutronV20.find_resourceid_by_name_or_id(client, 'pool',
+ pool_id_or_name,
+ cmd_resource='lbaas_pool')
+
+
+class LbaasMemberMixin(object):
+
+ def set_extra_attrs(self, parsed_args):
+ self.parent_id = _get_pool_id(self.get_client(), parsed_args.pool)
+
+ def add_known_arguments(self, parser):
+ parser.add_argument(
+ 'pool', metavar='POOL',
+ help=_('ID or name of the pool that this member belongs to.'))
+
+
+class ListMember(LbaasMemberMixin, neutronV20.ListCommand):
+ """LBaaS v2 List members that belong to a given tenant."""
+
+ resource = 'member'
+ shadow_resource = 'lbaas_member'
+ list_columns = [
+ 'id', 'address', 'protocol_port', 'weight',
+ 'subnet_id', 'admin_state_up', 'status'
+ ]
+ pagination_support = True
+ sorting_support = True
+
+
+class ShowMember(LbaasMemberMixin, neutronV20.ShowCommand):
+ """LBaaS v2 Show information of a given member."""
+
+ resource = 'member'
+ shadow_resource = 'lbaas_member'
+
+
+class CreateMember(neutronV20.CreateCommand):
+ """LBaaS v2 Create a member."""
+
+ resource = 'member'
+ shadow_resource = 'lbaas_member'
+
+ def add_known_arguments(self, parser):
+ parser.add_argument(
+ '--admin-state-down',
+ dest='admin_state', action='store_false',
+ help=_('Set admin state up to false'))
+ parser.add_argument(
+ '--weight',
+ help=_('Weight of member in the pool (default:1, [0..256]).'))
+ parser.add_argument(
+ '--subnet',
+ required=True,
+ help=_('Subnet ID or name for the member.'))
+ parser.add_argument(
+ '--address',
+ required=True,
+ help=_('IP address of the pool member in the pool.'))
+ parser.add_argument(
+ '--protocol-port',
+ required=True,
+ help=_('Port on which the pool member listens for requests or '
+ 'connections.'))
+ parser.add_argument(
+ 'pool', metavar='POOL',
+ help=_('ID or name of the pool that this member belongs to.'))
+
+ def args2body(self, parsed_args):
+ self.parent_id = _get_pool_id(self.get_client(), parsed_args.pool)
+ _subnet_id = neutronV20.find_resourceid_by_name_or_id(
+ self.get_client(), 'subnet', parsed_args.subnet)
+ body = {
+ self.resource: {
+ 'subnet_id': _subnet_id,
+ 'admin_state_up': parsed_args.admin_state,
+ 'protocol_port': parsed_args.protocol_port,
+ 'address': parsed_args.address,
+ },
+ }
+ neutronV20.update_dict(parsed_args, body[self.resource],
+ ['weight', 'subnet_id'])
+ return body
+
+
+class UpdateMember(neutronV20.UpdateCommand):
+ """LBaaS v2 Update a given member."""
+
+ resource = 'member'
+ shadow_resource = 'lbaas_member'
+
+ def add_known_arguments(self, parser):
+ parser.add_argument(
+ '--admin-state-down',
+ dest='admin_state', action='store_false',
+ help=_('Set admin state up to false'))
+ parser.add_argument(
+ '--weight',
+ help=_('Weight of member in the pool (default:1, [0..256])'))
+ parser.add_argument(
+ 'pool', metavar='POOL',
+ help=_('ID or name of the pool that this member belongs to'))
+
+ def args2body(self, parsed_args):
+ self.parent_id = _get_pool_id(self.get_client(), parsed_args.pool)
+ body = {
+ self.resource: {}
+ }
+ neutronV20.update_dict(parsed_args, body[self.resource],
+ ['admin_state_up', 'weight'])
+ return body
+
+
+class DeleteMember(LbaasMemberMixin, neutronV20.DeleteCommand):
+ """LBaaS v2 Delete a given member."""
+
+ resource = 'member'
+ shadow_resource = 'lbaas_member'
diff --git a/neutronclient/neutron/v2_0/lb/v2/pool.py b/neutronclient/neutron/v2_0/lb/v2/pool.py
new file mode 100644
index 0000000..11644be
--- /dev/null
+++ b/neutronclient/neutron/v2_0/lb/v2/pool.py
@@ -0,0 +1,134 @@
+# Copyright 2013 Mirantis Inc.
+# Copyright 2014 Blue Box Group, Inc.
+# Copyright 2015 Hewlett-Packard Development Company, L.P.
+# All Rights Reserved
+#
+# Author: Ilya Shakhat, Mirantis Inc.
+# Author: Craig Tracey <craigtracey@gmail.com>
+#
+# Licensed 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.
+#
+
+from neutronclient.common import exceptions
+from neutronclient.i18n import _
+from neutronclient.neutron import v2_0 as neutronV20
+
+
+def _parse_persistence(parsed_args):
+ persistence = None
+ if parsed_args.session_persistence:
+ parts = parsed_args.session_persistence.split(':')
+ if not len(parts) == 2:
+ raise exceptions.CommandError('Incorrect --session-persistence'
+ ' format. Format is <TYPE>:<VALUE>')
+ persistence = {'type': parts[0], 'cookie_name': parts[1]}
+ return persistence
+
+
+class ListPool(neutronV20.ListCommand):
+ """LBaaS v2 List pools that belong to a given tenant."""
+
+ resource = 'pool'
+ shadow_resource = 'lbaas_pool'
+ list_columns = ['id', 'name', 'lb_method', 'protocol',
+ 'admin_state_up']
+ pagination_support = True
+ sorting_support = True
+
+
+class ShowPool(neutronV20.ShowCommand):
+ """LBaaS v2 Show information of a given pool."""
+
+ resource = 'pool'
+ shadow_resource = 'lbaas_pool'
+
+ def cleanup_output_data(self, data):
+ if 'members' not in data['pool']:
+ return []
+ member_info = []
+ for member in data['pool']['members']:
+ member_info.append(member['id'])
+ data['pool']['members'] = member_info
+
+
+class CreatePool(neutronV20.CreateCommand):
+ """LBaaS v2 Create a pool."""
+
+ resource = 'pool'
+ shadow_resource = 'lbaas_pool'
+
+ def add_known_arguments(self, parser):
+ parser.add_argument(
+ '--admin-state-down',
+ dest='admin_state', action='store_false',
+ help=_('Set admin state up to false.'))
+ parser.add_argument(
+ '--description',
+ help=_('Description of the pool.'))
+ parser.add_argument(
+ '--healthmonitor-id',
+ help=_('ID of the health monitor to use.'))
+ parser.add_argument(
+ '--session-persistence', metavar='TYPE:VALUE',
+ help=_('The type of session persistence to use.'))
+ parser.add_argument(
+ '--lb-algorithm',
+ required=True,
+ choices=['ROUND_ROBIN', 'LEAST_CONNECTIONS', 'SOURCE_IP'],
+ help=_('The algorithm used to distribute load between the members '
+ 'of the pool.'))
+ parser.add_argument(
+ '--listener',
+ required=True,
+ help=_('The listener to associate with the pool'))
+ parser.add_argument(
+ '--protocol',
+ required=True,
+ choices=['HTTP', 'HTTPS', 'TCP'],
+ help=_('Protocol for balancing.'))
+ parser.add_argument(
+ 'name', metavar='NAME',
+ help=_('The name of the pool.'))
+
+ def args2body(self, parsed_args):
+ if parsed_args.session_persistence:
+ parsed_args.session_persistence = _parse_persistence(parsed_args)
+ _listener_id = neutronV20.find_resourceid_by_name_or_id(
+ self.get_client(), 'listener', parsed_args.listener)
+ body = {
+ self.resource: {
+ 'name': parsed_args.name,
+ 'admin_state_up': parsed_args.admin_state,
+ 'protocol': parsed_args.protocol,
+ 'lb_algorithm': parsed_args.lb_algorithm,
+ 'listener_id': _listener_id,
+ },
+ }
+ neutronV20.update_dict(parsed_args, body[self.resource],
+ ['description', 'healthmonitor_id',
+ 'session_persistence'])
+ return body
+
+
+class UpdatePool(neutronV20.UpdateCommand):
+ """LBaaS v2 Update a given pool."""
+
+ resource = 'pool'
+ shadow_resource = 'lbaas_pool'
+
+
+class DeletePool(neutronV20.DeleteCommand):
+ """LBaaS v2 Delete a given pool."""
+
+ resource = 'pool'
+ shadow_resource = 'lbaas_pool'
diff --git a/neutronclient/shell.py b/neutronclient/shell.py
index 76036a0..f892ba2 100644
--- a/neutronclient/shell.py
+++ b/neutronclient/shell.py
@@ -53,6 +53,11 @@ from neutronclient.neutron.v2_0.fw import firewallrule
from neutronclient.neutron.v2_0.lb import healthmonitor as lb_healthmonitor
from neutronclient.neutron.v2_0.lb import member as lb_member
from neutronclient.neutron.v2_0.lb import pool as lb_pool
+from neutronclient.neutron.v2_0.lb.v2 import healthmonitor as lbaas_healthmon
+from neutronclient.neutron.v2_0.lb.v2 import listener as lbaas_listener
+from neutronclient.neutron.v2_0.lb.v2 import loadbalancer as lbaas_loadbalancer
+from neutronclient.neutron.v2_0.lb.v2 import member as lbaas_member
+from neutronclient.neutron.v2_0.lb.v2 import pool as lbaas_pool
from neutronclient.neutron.v2_0.lb import vip as lb_vip
from neutronclient.neutron.v2_0 import metering
from neutronclient.neutron.v2_0.nec import packetfilter
@@ -170,6 +175,31 @@ COMMAND_V2 = {
'security-group-rule-show': securitygroup.ShowSecurityGroupRule,
'security-group-rule-create': securitygroup.CreateSecurityGroupRule,
'security-group-rule-delete': securitygroup.DeleteSecurityGroupRule,
+ 'lbaas-loadbalancer-list': lbaas_loadbalancer.ListLoadBalancer,
+ 'lbaas-loadbalancer-show': lbaas_loadbalancer.ShowLoadBalancer,
+ 'lbaas-loadbalancer-create': lbaas_loadbalancer.CreateLoadBalancer,
+ 'lbaas-loadbalancer-update': lbaas_loadbalancer.UpdateLoadBalancer,
+ 'lbaas-loadbalancer-delete': lbaas_loadbalancer.DeleteLoadBalancer,
+ 'lbaas-listener-list': lbaas_listener.ListListener,
+ 'lbaas-listener-show': lbaas_listener.ShowListener,
+ 'lbaas-listener-create': lbaas_listener.CreateListener,
+ 'lbaas-listener-update': lbaas_listener.UpdateListener,
+ 'lbaas-listener-delete': lbaas_listener.DeleteListener,
+ 'lbaas-pool-list': lbaas_pool.ListPool,
+ 'lbaas-pool-show': lbaas_pool.ShowPool,
+ 'lbaas-pool-create': lbaas_pool.CreatePool,
+ 'lbaas-pool-update': lbaas_pool.UpdatePool,
+ 'lbaas-pool-delete': lbaas_pool.DeletePool,
+ 'lbaas-healthmonitor-list': lbaas_healthmon.ListHealthMonitor,
+ 'lbaas-healthmonitor-show': lbaas_healthmon.ShowHealthMonitor,
+ 'lbaas-healthmonitor-create': lbaas_healthmon.CreateHealthMonitor,
+ 'lbaas-healthmonitor-update': lbaas_healthmon.UpdateHealthMonitor,
+ 'lbaas-healthmonitor-delete': lbaas_healthmon.DeleteHealthMonitor,
+ 'lbaas-member-list': lbaas_member.ListMember,
+ 'lbaas-member-show': lbaas_member.ShowMember,
+ 'lbaas-member-create': lbaas_member.CreateMember,
+ 'lbaas-member-update': lbaas_member.UpdateMember,
+ 'lbaas-member-delete': lbaas_member.DeleteMember,
'lb-vip-list': lb_vip.ListVip,
'lb-vip-show': lb_vip.ShowVip,
'lb-vip-create': lb_vip.CreateVip,
diff --git a/neutronclient/tests/unit/lb/v2/__init__.py b/neutronclient/tests/unit/lb/v2/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/neutronclient/tests/unit/lb/v2/__init__.py
diff --git a/neutronclient/tests/unit/lb/v2/test_cli20_healthmonitor.py b/neutronclient/tests/unit/lb/v2/test_cli20_healthmonitor.py
new file mode 100644
index 0000000..20af127
--- /dev/null
+++ b/neutronclient/tests/unit/lb/v2/test_cli20_healthmonitor.py
@@ -0,0 +1,154 @@
+# Copyright 2014 Blue Box Group, Inc.
+# All Rights Reserved
+#
+# Licensed 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.
+#
+# @author: Craig Tracey <craigtracey@gmail.com>
+#
+
+import sys
+
+from neutronclient.neutron.v2_0.lb.v2 import healthmonitor
+from neutronclient.tests.unit import test_cli20
+
+
+class CLITestV20LbHealthMonitorJSON(test_cli20.CLITestV20Base):
+
+ def test_create_healthmonitor_with_mandatory_params(self):
+ """lbaas-healthmonitor-create with mandatory params only."""
+ resource = 'healthmonitor'
+ cmd_resource = 'lbaas_healthmonitor'
+ cmd = healthmonitor.CreateHealthMonitor(test_cli20.MyApp(sys.stdout),
+ None)
+ my_id = 'my-id'
+ type = 'PING'
+ max_retries = '3'
+ delay = '10'
+ timeout = '60'
+ args = ['--type', type, '--max-retries', max_retries,
+ '--delay', delay, '--timeout', timeout]
+ position_names = ['type', 'max_retries', 'delay', 'timeout']
+ position_values = [type, max_retries, delay, timeout]
+ self._test_create_resource(resource, cmd, '', my_id, args,
+ position_names, position_values,
+ cmd_resource=cmd_resource)
+
+ def test_create_healthmonitor_with_all_params(self):
+ """lbaas-healthmonitor-create with all params set."""
+ resource = 'healthmonitor'
+ cmd_resource = 'lbaas_healthmonitor'
+ cmd = healthmonitor.CreateHealthMonitor(test_cli20.MyApp(sys.stdout),
+ None)
+ my_id = 'my-id'
+ type = 'PING'
+ max_retries = '3'
+ delay = '10'
+ timeout = '60'
+ http_method = 'GET'
+ expected_codes = '201'
+ url_path = '/somepath'
+ args = ['--admin-state-down', '--http-method', http_method,
+ '--expected-codes', expected_codes, '--url-path', url_path,
+ '--type', type, '--max-retries', max_retries,
+ '--delay', delay, '--timeout', timeout]
+ position_names = ['admin_state_up', 'http_method', 'expected_codes',
+ 'url_path', 'type', 'max_retries', 'delay',
+ 'timeout']
+ position_values = [False, http_method, expected_codes, url_path,
+ type, max_retries, delay, timeout]
+ self._test_create_resource(resource, cmd, '', my_id, args,
+ position_names, position_values,
+ cmd_resource=cmd_resource)
+
+ def test_list_healthmonitors(self):
+ """lbaas-healthmonitor-list."""
+ resources = 'healthmonitors'
+ cmd_resources = 'lbaas_healthmonitors'
+ cmd = healthmonitor.ListHealthMonitor(test_cli20.MyApp(sys.stdout),
+ None)
+ self._test_list_resources(resources, cmd, True,
+ cmd_resources=cmd_resources)
+
+ def test_list_healthmonitors_pagination(self):
+ """lbaas-healthmonitor-list with pagination."""
+ resources = 'healthmonitors'
+ cmd_resources = 'lbaas_healthmonitors'
+ cmd = healthmonitor.ListHealthMonitor(test_cli20.MyApp(sys.stdout),
+ None)
+ self._test_list_resources_with_pagination(resources, cmd,
+ cmd_resources=cmd_resources)
+
+ def test_list_healthmonitors_sort(self):
+ """lbaas-healthmonitor-list --sort-key id --sort-key asc."""
+ resources = 'healthmonitors'
+ cmd_resources = 'lbaas_healthmonitors'
+ cmd = healthmonitor.ListHealthMonitor(test_cli20.MyApp(sys.stdout),
+ None)
+ self._test_list_resources(resources, cmd, True,
+ cmd_resources=cmd_resources)
+
+ def test_list_healthmonitors_limit(self):
+ """lbaas-healthmonitor-list -P."""
+ resources = 'healthmonitors'
+ cmd_resources = 'lbaas_healthmonitors'
+ cmd = healthmonitor.ListHealthMonitor(test_cli20.MyApp(sys.stdout),
+ None)
+ self._test_list_resources(resources, cmd, page_size=1000,
+ cmd_resources=cmd_resources)
+
+ def test_show_healthmonitor_id(self):
+ """lbaas-healthmonitor-show test_id."""
+ resource = 'healthmonitor'
+ cmd_resource = 'lbaas_healthmonitor'
+ cmd = healthmonitor.ShowHealthMonitor(test_cli20.MyApp(sys.stdout),
+ None)
+ args = ['--fields', 'id', self.test_id]
+ self._test_show_resource(resource, cmd, self.test_id, args, ['id'],
+ cmd_resource=cmd_resource)
+
+ def test_show_healthmonitor_id_name(self):
+ """lbaas-healthmonitor-show."""
+ resource = 'healthmonitor'
+ cmd_resource = 'lbaas_healthmonitor'
+ cmd = healthmonitor.ShowHealthMonitor(test_cli20.MyApp(sys.stdout),
+ None)
+ args = ['--fields', 'id', '--fields', 'name', self.test_id]
+ self._test_show_resource(resource, cmd, self.test_id,
+ args, ['id', 'name'],
+ cmd_resource=cmd_resource)
+
+ def test_update_healthmonitor(self):
+ """lbaas-healthmonitor-update myid --name newname."""
+ resource = 'healthmonitor'
+ cmd_resource = 'lbaas_healthmonitor'
+ cmd = healthmonitor.UpdateHealthMonitor(test_cli20.MyApp(sys.stdout),
+ None)
+ self._test_update_resource(resource, cmd, 'myid',
+ ['myid', '--name', 'newname'],
+ {'name': 'newname', },
+ cmd_resource=cmd_resource)
+
+ def test_delete_healthmonitor(self):
+ """lbaas-healthmonitor-delete my-id."""
+ resource = 'healthmonitor'
+ cmd_resource = 'lbaas_healthmonitor'
+ cmd = healthmonitor.DeleteHealthMonitor(test_cli20.MyApp(sys.stdout),
+ None)
+ my_id = 'my-id'
+ args = [my_id]
+ self._test_delete_resource(resource, cmd, my_id, args,
+ cmd_resource=cmd_resource)
+
+
+class CLITestV20LbHealthMonitorXML(CLITestV20LbHealthMonitorJSON):
+ format = 'xml'
diff --git a/neutronclient/tests/unit/lb/v2/test_cli20_listener.py b/neutronclient/tests/unit/lb/v2/test_cli20_listener.py
new file mode 100644
index 0000000..fc0a062
--- /dev/null
+++ b/neutronclient/tests/unit/lb/v2/test_cli20_listener.py
@@ -0,0 +1,137 @@
+# Copyright 2014 Blue Box Group, Inc.
+# All Rights Reserved
+#
+# Licensed 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.
+#
+# @author: Craig Tracey <craigtracey@gmail.com>
+#
+
+import sys
+
+from neutronclient.neutron.v2_0.lb.v2 import listener
+from neutronclient.tests.unit import test_cli20
+
+
+class CLITestV20LbListenerJSON(test_cli20.CLITestV20Base):
+
+ def test_create_listener_with_mandatory_params(self):
+ """lbaas-listener-create with mandatory params only."""
+ resource = 'listener'
+ cmd_resource = 'lbaas_listener'
+ cmd = listener.CreateListener(test_cli20.MyApp(sys.stdout), None)
+ my_id = 'my-id'
+ loadbalancer_id = 'loadbalancer'
+ protocol = 'TCP'
+ protocol_port = '80'
+ args = ['--protocol', protocol, '--protocol-port', protocol_port,
+ '--loadbalancer', loadbalancer_id]
+ position_names = ['protocol', 'protocol_port', 'loadbalancer_id']
+ position_values = [protocol, protocol_port, loadbalancer_id,
+ True]
+ self._test_create_resource(resource, cmd, '', my_id, args,
+ position_names, position_values,
+ cmd_resource=cmd_resource)
+
+ def test_create_listener_with_all_params(self):
+ """lbaas-listener-create with all params set."""
+ resource = 'listener'
+ cmd_resource = 'lbaas_listener'
+ cmd = listener.CreateListener(test_cli20.MyApp(sys.stdout), None)
+ my_id = 'my-id'
+ loadbalancer = 'loadbalancer'
+ protocol = 'TCP'
+ protocol_port = '80'
+ args = ['--admin-state-down',
+ '--protocol', protocol, '--protocol-port', protocol_port,
+ '--loadbalancer', loadbalancer]
+ position_names = ['admin_state_up',
+ 'protocol', 'protocol_port', 'loadbalancer_id']
+ position_values = [False, protocol, protocol_port, loadbalancer]
+ self._test_create_resource(resource, cmd, '', my_id, args,
+ position_names, position_values,
+ cmd_resource=cmd_resource)
+
+ def test_list_listeners(self):
+ """lbaas-listener-list."""
+ resources = 'listeners'
+ cmd_resources = 'lbaas_listeners'
+ cmd = listener.ListListener(test_cli20.MyApp(sys.stdout), None)
+ self._test_list_resources(resources, cmd, True,
+ cmd_resources=cmd_resources)
+
+ def test_list_listeners_pagination(self):
+ """lbaas-listener-list with pagination."""
+ resources = 'listeners'
+ cmd_resources = 'lbaas_listeners'
+ cmd = listener.ListListener(test_cli20.MyApp(sys.stdout), None)
+ self._test_list_resources_with_pagination(resources, cmd,
+ cmd_resources=cmd_resources)
+
+ def test_list_listeners_sort(self):
+ """lbaas-listener-list --sort-key id --sort-key asc."""
+ resources = 'listeners'
+ cmd_resources = 'lbaas_listeners'
+ cmd = listener.ListListener(test_cli20.MyApp(sys.stdout), None)
+ self._test_list_resources(resources, cmd, True,
+ cmd_resources=cmd_resources)
+
+ def test_list_listeners_limit(self):
+ """lbaas-listener-list -P."""
+ resources = 'listeners'
+ cmd_resources = 'lbaas_listeners'
+ cmd = listener.ListListener(test_cli20.MyApp(sys.stdout), None)
+ self._test_list_resources(resources, cmd, page_size=1000,
+ cmd_resources=cmd_resources)
+
+ def test_show_listener_id(self):
+ """lbaas-listener-show test_id."""
+ resource = 'listener'
+ cmd_resource = 'lbaas_listener'
+ cmd = listener.ShowListener(test_cli20.MyApp(sys.stdout), None)
+ args = ['--fields', 'id', self.test_id]
+ self._test_show_resource(resource, cmd, self.test_id, args, ['id'],
+ cmd_resource=cmd_resource)
+
+ def test_show_listener_id_name(self):
+ """lbaas-listener-show."""
+ resource = 'listener'
+ cmd_resource = 'lbaas_listener'
+ cmd = listener.ShowListener(test_cli20.MyApp(sys.stdout), None)
+ args = ['--fields', 'id', '--fields', 'name', self.test_id]
+ self._test_show_resource(resource, cmd, self.test_id,
+ args, ['id', 'name'],
+ cmd_resource=cmd_resource)
+
+ def test_update_listener(self):
+ """lbaas-listener-update myid --name newname."""
+ resource = 'listener'
+ cmd_resource = 'lbaas_listener'
+ cmd = listener.UpdateListener(test_cli20.MyApp(sys.stdout), None)
+ self._test_update_resource(resource, cmd, 'myid',
+ ['myid', '--name', 'newname'],
+ {'name': 'newname', },
+ cmd_resource=cmd_resource)
+
+ def test_delete_listener(self):
+ """lbaas-listener-delete my-id."""
+ resource = 'listener'
+ cmd_resource = 'lbaas_listener'
+ cmd = listener.DeleteListener(test_cli20.MyApp(sys.stdout), None)
+ my_id = 'my-id'
+ args = [my_id]
+ self._test_delete_resource(resource, cmd, my_id, args,
+ cmd_resource=cmd_resource)
+
+
+class CLITestV20LbListenerXML(CLITestV20LbListenerJSON):
+ format = 'xml'
diff --git a/neutronclient/tests/unit/lb/v2/test_cli20_loadbalancer.py b/neutronclient/tests/unit/lb/v2/test_cli20_loadbalancer.py
new file mode 100644
index 0000000..a8ccd4e
--- /dev/null
+++ b/neutronclient/tests/unit/lb/v2/test_cli20_loadbalancer.py
@@ -0,0 +1,137 @@
+# Copyright 2014 Blue Box Group, Inc.
+# All Rights Reserved
+#
+# Licensed 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.
+#
+# @author: Craig Tracey <craigtracey@gmail.com>
+#
+
+import sys
+
+from neutronclient.neutron.v2_0.lb.v2 import loadbalancer as lb
+from neutronclient.tests.unit import test_cli20
+
+
+class CLITestV20LbLoadBalancerJSON(test_cli20.CLITestV20Base):
+
+ def test_create_loadbalancer_with_mandatory_params(self):
+ """lbaas-loadbalancer-create with mandatory params only."""
+ resource = 'loadbalancer'
+ cmd_resource = 'lbaas_loadbalancer'
+ cmd = lb.CreateLoadBalancer(test_cli20.MyApp(sys.stdout), None)
+ name = 'lbaas-loadbalancer-name'
+ vip_subnet_id = 'vip-subnet'
+ my_id = 'my-id'
+ args = ['--name', name, vip_subnet_id]
+ position_names = ['name', 'vip_subnet_id']
+ position_values = [name, vip_subnet_id]
+ self._test_create_resource(resource, cmd, name, my_id, args,
+ position_names, position_values,
+ cmd_resource=cmd_resource)
+
+ def test_create_loadbalancer_with_all_params(self):
+ """lbaas-loadbalancer-create with all params set."""
+ resource = 'loadbalancer'
+ cmd_resource = 'lbaas_loadbalancer'
+ cmd = lb.CreateLoadBalancer(test_cli20.MyApp(sys.stdout), None)
+ name = 'lbaas-loadbalancer-name'
+ description = 'lbaas-loadbalancer-desc'
+ vip_subnet_id = 'vip-subnet'
+ my_id = 'my-id'
+ args = ['--admin-state-down', '--description', description,
+ '--name', name, vip_subnet_id]
+ position_names = ['admin_state_up', 'description', 'name',
+ 'vip_subnet_id']
+ position_values = [False, description, name, vip_subnet_id]
+ self._test_create_resource(resource, cmd, name, my_id, args,
+ position_names, position_values,
+ cmd_resource=cmd_resource)
+
+ def test_list_loadbalancers(self):
+ """lbaas-loadbalancer-list."""
+ resources = 'loadbalancers'
+ cmd_resources = 'lbaas_loadbalancers'
+ cmd = lb.ListLoadBalancer(test_cli20.MyApp(sys.stdout), None)
+ self._test_list_resources(resources, cmd, True,
+ cmd_resources=cmd_resources)
+
+ def test_list_loadbalancers_pagination(self):
+ """lbaas-loadbalancer-list with pagination."""
+ resources = 'loadbalancers'
+ cmd_resources = 'lbaas_loadbalancers'
+ cmd = lb.ListLoadBalancer(test_cli20.MyApp(sys.stdout), None)
+ self._test_list_resources_with_pagination(resources, cmd,
+ cmd_resources=cmd_resources)
+
+ def test_list_loadbalancers_sort(self):
+ """lbaas-loadbalancer-list --sort-key name --sort-key id
+ --sort-key asc --sort-key desc
+ """
+ resources = 'loadbalancers'
+ cmd_resources = 'lbaas_loadbalancers'
+ cmd = lb.ListLoadBalancer(test_cli20.MyApp(sys.stdout), None)
+ self._test_list_resources(resources, cmd,
+ sort_key=["name", "id"],
+ sort_dir=["asc", "desc"],
+ cmd_resources=cmd_resources)
+
+ def test_list_loadbalancers_limit(self):
+ """lbaas-loadbalancer-list -P."""
+ resources = 'loadbalancers'
+ cmd_resources = 'lbaas_loadbalancers'
+ cmd = lb.ListLoadBalancer(test_cli20.MyApp(sys.stdout), None)
+ self._test_list_resources(resources, cmd, page_size=1000,
+ cmd_resources=cmd_resources)
+
+ def test_show_loadbalancer_id(self):
+ """lbaas-loadbalancer-loadbalancer-show test_id."""
+ resource = 'loadbalancer'
+ cmd_resource = 'lbaas_loadbalancer'
+ cmd = lb.ShowLoadBalancer(test_cli20.MyApp(sys.stdout), None)
+ args = ['--fields', 'id', self.test_id]
+ self._test_show_resource(resource, cmd, self.test_id, args, ['id'],
+ cmd_resource=cmd_resource)
+
+ def test_show_loadbalancer_id_name(self):
+ """lbaas-loadbalancer-loadbalancer-show."""
+ resource = 'loadbalancer'
+ cmd_resource = 'lbaas_loadbalancer'
+ cmd = lb.ShowLoadBalancer(test_cli20.MyApp(sys.stdout), None)
+ args = ['--fields', 'id', '--fields', 'name', self.test_id]
+ self._test_show_resource(resource, cmd, self.test_id,
+ args, ['id', 'name'],
+ cmd_resource=cmd_resource)
+
+ def test_update_loadbalancer(self):
+ """lbaas-loadbalancer-loadbalancer-update myid --name newname."""
+ resource = 'loadbalancer'
+ cmd_resource = 'lbaas_loadbalancer'
+ cmd = lb.UpdateLoadBalancer(test_cli20.MyApp(sys.stdout), None)
+ self._test_update_resource(resource, cmd, 'myid',
+ ['myid', '--name', 'newname'],
+ {'name': 'newname', },
+ cmd_resource=cmd_resource)
+
+ def test_delete_loadbalancer(self):
+ """lbaas-loadbalancer-loadbalancer-delete my-id."""
+ resource = 'loadbalancer'
+ cmd_resource = 'lbaas_loadbalancer'
+ cmd = lb.DeleteLoadBalancer(test_cli20.MyApp(sys.stdout), None)
+ my_id = 'my-id'
+ args = [my_id]
+ self._test_delete_resource(resource, cmd, my_id, args,
+ cmd_resource=cmd_resource)
+
+
+class CLITestV20LbLoadBalancerXML(CLITestV20LbLoadBalancerJSON):
+ format = 'xml'
diff --git a/neutronclient/tests/unit/lb/v2/test_cli20_member.py b/neutronclient/tests/unit/lb/v2/test_cli20_member.py
new file mode 100644
index 0000000..2adb036
--- /dev/null
+++ b/neutronclient/tests/unit/lb/v2/test_cli20_member.py
@@ -0,0 +1,159 @@
+# Copyright 2014 Blue Box Group, Inc.
+# All Rights Reserved
+#
+# Licensed 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.
+#
+# @author: Craig Tracey <craigtracey@gmail.com>
+#
+
+import sys
+
+from neutronclient.neutron.v2_0.lb.v2 import member
+from neutronclient.tests.unit import test_cli20
+
+
+class CLITestV20LbMemberJSON(test_cli20.CLITestV20Base):
+
+ def test_create_member_with_mandatory_params(self):
+ """lbaas-member-create with mandatory params only."""
+ resource = 'member'
+ cmd_resource = 'lbaas_member'
+ cmd = member.CreateMember(test_cli20.MyApp(sys.stdout), None)
+ my_id = 'my-id'
+ address = '10.1.1.1'
+ protocol_port = '80'
+ pool_id = 'pool-id'
+ subnet_id = 'subnet-id'
+ args = ['--address', address, '--protocol-port', protocol_port,
+ '--subnet', subnet_id, pool_id]
+ position_names = ['admin_state_up', 'address',
+ 'protocol_port', 'subnet_id']
+ position_values = [True, address, protocol_port, subnet_id]
+ self._test_create_resource(resource, cmd, '', my_id, args,
+ position_names, position_values,
+ cmd_resource=cmd_resource,
+ parent_id=pool_id)
+
+ def test_create_member_with_all_params(self):
+ """lbaas-member-create with all params set."""
+ resource = 'member'
+ cmd_resource = 'lbaas_member'
+ cmd = member.CreateMember(test_cli20.MyApp(sys.stdout), None)
+ my_id = 'my-id'
+ address = '10.1.1.1'
+ protocol_port = '80'
+ pool_id = 'pool-id'
+ subnet_id = 'subnet-id'
+ weight = '100'
+ args = ['--address', address, '--protocol-port', protocol_port,
+ '--subnet', subnet_id, pool_id, '--weight', weight,
+ '--admin-state-down']
+ position_names = ['admin_state_up', 'address', 'protocol_port',
+ 'subnet_id', 'weight']
+ position_values = [False, address, protocol_port, subnet_id, weight]
+ self._test_create_resource(resource, cmd, '', my_id, args,
+ position_names, position_values,
+ cmd_resource=cmd_resource,
+ parent_id=pool_id)
+
+ def test_list_members(self):
+ """lbaas-member-list."""
+ resources = 'members'
+ cmd_resources = 'lbaas_members'
+ pool_id = 'pool-id'
+ cmd = member.ListMember(test_cli20.MyApp(sys.stdout), None)
+ self._test_list_resources(resources, cmd, True, base_args=[pool_id],
+ cmd_resources=cmd_resources,
+ parent_id=pool_id)
+
+ def test_list_members_pagination(self):
+ """lbaas-member-list with pagination."""
+ resources = 'members'
+ cmd_resources = 'lbaas_members'
+ pool_id = 'pool-id'
+ cmd = member.ListMember(test_cli20.MyApp(sys.stdout), None)
+ self._test_list_resources_with_pagination(resources, cmd,
+ base_args=[pool_id],
+ cmd_resources=cmd_resources,
+ parent_id=pool_id)
+
+ def test_list_members_sort(self):
+ """lbaas-member-list --sort-key id --sort-key asc."""
+ resources = 'members'
+ cmd_resources = 'lbaas_members'
+ pool_id = 'pool-id'
+ cmd = member.ListMember(test_cli20.MyApp(sys.stdout), None)
+ self._test_list_resources(resources, cmd, True, base_args=[pool_id],
+ cmd_resources=cmd_resources,
+ parent_id=pool_id)
+
+ def test_list_members_limit(self):
+ """lbaas-member-list -P."""
+ resources = 'members'
+ cmd_resources = 'lbaas_members'
+ pool_id = 'pool-id'
+ cmd = member.ListMember(test_cli20.MyApp(sys.stdout), None)
+ self._test_list_resources(resources, cmd, page_size=1000,
+ base_args=[pool_id],
+ cmd_resources=cmd_resources,
+ parent_id=pool_id)
+
+ def test_show_member_id(self):
+ """lbaas-member-show test_id."""
+ resource = 'member'
+ cmd_resource = 'lbaas_member'
+ pool_id = 'pool-id'
+ cmd = member.ShowMember(test_cli20.MyApp(sys.stdout), None)
+ args = ['--fields', 'id', self.test_id, pool_id]
+ self._test_show_resource(resource, cmd, self.test_id, args, ['id'],
+ cmd_resource=cmd_resource, parent_id=pool_id)
+
+ def test_show_member_id_name(self):
+ """lbaas-member-show."""
+ resource = 'member'
+ cmd_resource = 'lbaas_member'
+ pool_id = 'pool-id'
+ cmd = member.ShowMember(test_cli20.MyApp(sys.stdout), None)
+ args = ['--fields', 'id', '--fields', 'name', self.test_id, pool_id]
+ self._test_show_resource(resource, cmd, self.test_id,
+ args, ['id', 'name'],
+ cmd_resource=cmd_resource, parent_id=pool_id)
+
+ def test_update_member(self):
+ """lbaas-member-update myid --name newname."""
+ resource = 'member'
+ cmd_resource = 'lbaas_member'
+ my_id = 'my-id'
+ pool_id = 'pool-id'
+ args = [my_id, pool_id, '--name', 'newname']
+ cmd = member.UpdateMember(test_cli20.MyApp(sys.stdout), None)
+ self._test_update_resource(resource, cmd, my_id, args,
+ {'name': 'newname', },
+ cmd_resource=cmd_resource,
+ parent_id=pool_id)
+
+ def test_delete_member(self):
+ """lbaas-member-delete my-id."""
+ resource = 'member'
+ cmd_resource = 'lbaas_member'
+ cmd = member.DeleteMember(test_cli20.MyApp(sys.stdout), None)
+ my_id = 'my-id'
+ pool_id = 'pool-id'
+ args = [my_id, pool_id]
+ self._test_delete_resource(resource, cmd, my_id, args,
+ cmd_resource=cmd_resource,
+ parent_id=pool_id)
+
+
+class CLITestV20LbMemberXML(CLITestV20LbMemberJSON):
+ format = 'xml'
diff --git a/neutronclient/tests/unit/lb/v2/test_cli20_pool.py b/neutronclient/tests/unit/lb/v2/test_cli20_pool.py
new file mode 100644
index 0000000..daf3e52
--- /dev/null
+++ b/neutronclient/tests/unit/lb/v2/test_cli20_pool.py
@@ -0,0 +1,149 @@
+# Copyright 2014 Blue Box Group, Inc.
+# All Rights Reserved
+#
+# Licensed 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.
+#
+# @author: Craig Tracey <craigtracey@gmail.com>
+#
+
+import sys
+
+from neutronclient.neutron.v2_0.lb.v2 import pool
+from neutronclient.tests.unit import test_cli20
+
+
+class CLITestV20LbPoolJSON(test_cli20.CLITestV20Base):
+
+ def test_create_pool_with_mandatory_params(self):
+ """lbaas-pool-create with mandatory params only."""
+ resource = 'pool'
+ cmd_resource = 'lbaas_pool'
+ cmd = pool.CreatePool(test_cli20.MyApp(sys.stdout), None)
+ my_id = 'my-id'
+ lb_algorithm = 'ROUND_ROBIN'
+ listener = 'listener'
+ protocol = 'TCP'
+ name = 'my-pool'
+ args = ['--lb-algorithm', lb_algorithm, '--protocol', protocol,
+ '--listener', listener, name]
+ position_names = ['admin_state_up', 'lb_algorithm', 'protocol',
+ 'listener_id', 'name']
+ position_values = [True, lb_algorithm, protocol, listener, name]
+ self._test_create_resource(resource, cmd, '', my_id, args,
+ position_names, position_values,
+ cmd_resource=cmd_resource)
+
+ def test_create_pool_with_all_params(self):
+ """lbaas-pool-create with all params set."""
+ resource = 'pool'
+ cmd_resource = 'lbaas_pool'
+ cmd = pool.CreatePool(test_cli20.MyApp(sys.stdout), None)
+ my_id = 'my-id'
+ lb_algorithm = 'ROUND_ROBIN'
+ listener = 'listener'
+ protocol = 'TCP'
+ description = 'description'
+ session_persistence_str = 'HTTP_COOKIE:1234'
+ session_persistence = {'type': 'HTTP_COOKIE',
+ 'cookie_name': '1234'}
+ healthmon_id = 'healthmon-id'
+ name = 'my-pool'
+ args = ['--lb-algorithm', lb_algorithm, '--protocol', protocol,
+ '--description', description, '--session-persistence',
+ session_persistence_str, '--healthmonitor-id',
+ healthmon_id, '--admin-state-down', name,
+ '--listener', listener]
+ position_names = ['lb_algorithm', 'protocol', 'description',
+ 'session_persistence', 'healthmonitor_id',
+ 'admin_state_up', 'listener_id', 'name']
+ position_values = [lb_algorithm, protocol, description,
+ session_persistence, healthmon_id,
+ False, listener, name]
+ self._test_create_resource(resource, cmd, '', my_id, args,
+ position_names, position_values,
+ cmd_resource=cmd_resource)
+
+ def test_list_pools(self):
+ """lbaas-pool-list."""
+ resources = 'pools'
+ cmd_resources = 'lbaas_pools'
+ cmd = pool.ListPool(test_cli20.MyApp(sys.stdout), None)
+ self._test_list_resources(resources, cmd, True,
+ cmd_resources=cmd_resources)
+
+ def test_list_pools_pagination(self):
+ """lbaas-pool-list with pagination."""
+ resources = 'pools'
+ cmd_resources = 'lbaas_pools'
+ cmd = pool.ListPool(test_cli20.MyApp(sys.stdout), None)
+ self._test_list_resources_with_pagination(resources, cmd,
+ cmd_resources=cmd_resources)
+
+ def test_list_pools_sort(self):
+ """lbaas-pool-list --sort-key id --sort-key asc."""
+ resources = 'pools'
+ cmd_resources = 'lbaas_pools'
+ cmd = pool.ListPool(test_cli20.MyApp(sys.stdout), None)
+ self._test_list_resources(resources, cmd, True,
+ cmd_resources=cmd_resources)
+
+ def test_list_pools_limit(self):
+ """lbaas-pool-list -P."""
+ resources = 'pools'
+ cmd_resources = 'lbaas_pools'
+ cmd = pool.ListPool(test_cli20.MyApp(sys.stdout), None)
+ self._test_list_resources(resources, cmd, page_size=1000,
+ cmd_resources=cmd_resources)
+
+ def test_show_pool_id(self):
+ """lbaas-pool-show test_id."""
+ resource = 'pool'
+ cmd_resource = 'lbaas_pool'
+ cmd = pool.ShowPool(test_cli20.MyApp(sys.stdout), None)
+ args = ['--fields', 'id', self.test_id]
+ self._test_show_resource(resource, cmd, self.test_id, args, ['id'],
+ cmd_resource=cmd_resource)
+
+ def test_show_pool_id_name(self):
+ """lbaas-pool-show."""
+ resource = 'pool'
+ cmd_resource = 'lbaas_pool'
+ cmd = pool.ShowPool(test_cli20.MyApp(sys.stdout), None)
+ args = ['--fields', 'id', '--fields', 'name', self.test_id]
+ self._test_show_resource(resource, cmd, self.test_id,
+ args, ['id', 'name'],
+ cmd_resource=cmd_resource)
+
+ def test_update_pool(self):
+ """lbaas-pool-update myid --name newname."""
+ resource = 'pool'
+ cmd_resource = 'lbaas_pool'
+ cmd = pool.UpdatePool(test_cli20.MyApp(sys.stdout), None)
+ self._test_update_resource(resource, cmd, 'myid',
+ ['myid', '--name', 'newname'],
+ {'name': 'newname', },
+ cmd_resource=cmd_resource)
+
+ def test_delete_pool(self):
+ """lbaas-pool-delete my-id."""
+ resource = 'pool'
+ cmd_resource = 'lbaas_pool'
+ cmd = pool.DeletePool(test_cli20.MyApp(sys.stdout), None)
+ my_id = 'my-id'
+ args = [my_id]
+ self._test_delete_resource(resource, cmd, my_id, args,
+ cmd_resource=cmd_resource)
+
+
+class CLITestV20LbPoolXML(CLITestV20LbPoolJSON):
+ format = 'xml'
diff --git a/neutronclient/tests/unit/test_cli20.py b/neutronclient/tests/unit/test_cli20.py
index 21db502..6b26e6f 100644
--- a/neutronclient/tests/unit/test_cli20.py
+++ b/neutronclient/tests/unit/test_cli20.py
@@ -396,6 +396,7 @@ class CLITestV20Base(base.BaseTestCase):
return _str
def _test_list_resources_with_pagination(self, resources, cmd,
+ base_args=None,
cmd_resources=None,
parent_id=None):
self.mox.StubOutWithMock(cmd, "get_client")
@@ -430,7 +431,8 @@ class CLITestV20Base(base.BaseTestCase):
'X-Auth-Token', TOKEN)).AndReturn((MyResp(200), resstr2))
self.mox.ReplayAll()
cmd_parser = cmd.get_parser("list_" + cmd_resources)
- args = ['--request-format', self.format]
+ args = base_args if base_args is not None else []
+ args.extend(['--request-format', self.format])
shell.run_command(cmd, cmd_parser, args)
self.mox.VerifyAll()
self.mox.UnsetStubs()
diff --git a/neutronclient/v2_0/client.py b/neutronclient/v2_0/client.py
index 0e8e6dc..f33c7aa 100644
--- a/neutronclient/v2_0/client.py
+++ b/neutronclient/v2_0/client.py
@@ -1,4 +1,5 @@
# Copyright 2012 OpenStack Foundation.
+# Copyright 2015 Hewlett-Packard Development Company, L.P.
# All Rights Reserved
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
@@ -178,6 +179,18 @@ class Client(object):
ikepolicy_path = "/vpn/ikepolicies/%s"
ipsec_site_connections_path = "/vpn/ipsec-site-connections"
ipsec_site_connection_path = "/vpn/ipsec-site-connections/%s"
+
+ lbaas_loadbalancers_path = "/lbaas/loadbalancers"
+ lbaas_loadbalancer_path = "/lbaas/loadbalancers/%s"
+ lbaas_listeners_path = "/lbaas/listeners"
+ lbaas_listener_path = "/lbaas/listeners/%s"
+ lbaas_pools_path = "/lbaas/pools"
+ lbaas_pool_path = "/lbaas/pools/%s"
+ lbaas_healthmonitors_path = "/lbaas/healthmonitors"
+ lbaas_healthmonitor_path = "/lbaas/healthmonitors/%s"
+ lbaas_members_path = lbaas_pool_path + "/members"
+ lbaas_member_path = lbaas_pool_path + "/members/%s"
+
vips_path = "/lb/vips"
vip_path = "/lb/vips/%s"
pools_path = "/lb/pools"
@@ -255,6 +268,12 @@ class Client(object):
'metering_label_rules': 'metering_label_rule',
'net_partitions': 'net_partition',
'packet_filters': 'packet_filter',
+ 'loadbalancers': 'loadbalancer',
+ 'listeners': 'listener',
+ 'lbaas_pools': 'lbaas_pool',
+ 'lbaas_healthmonitors': 'lbaas_healthmonitor',
+ 'lbaas_members': 'lbaas_member',
+ 'healthmonitors': 'healthmonitor',
}
def get_attr_metadata(self):
@@ -629,6 +648,154 @@ class Client(object):
return self.delete(self.ipsecpolicy_path % (ipsecpolicy))
@APIParamsCall
+ def list_loadbalancers(self, retrieve_all=True, **_params):
+ """Fetches a list of all loadbalancers for a tenant."""
+ return self.list('loadbalancers', self.lbaas_loadbalancers_path,
+ retrieve_all, **_params)
+
+ @APIParamsCall
+ def show_loadbalancer(self, lbaas_loadbalancer, **_params):
+ """Fetches information for a load balancer."""
+ return self.get(self.lbaas_loadbalancer_path % (lbaas_loadbalancer),
+ params=_params)
+
+ @APIParamsCall
+ def create_loadbalancer(self, body=None):
+ """Creates a new load balancer."""
+ return self.post(self.lbaas_loadbalancers_path, body=body)
+
+ @APIParamsCall
+ def update_loadbalancer(self, lbaas_loadbalancer, body=None):
+ """Updates a load balancer."""
+ return self.put(self.lbaas_loadbalancer_path % (lbaas_loadbalancer),
+ body=body)
+
+ @APIParamsCall
+ def delete_loadbalancer(self, lbaas_loadbalancer):
+ """Deletes the specified load balancer."""
+ return self.delete(self.lbaas_loadbalancer_path %
+ (lbaas_loadbalancer))
+
+ @APIParamsCall
+ def list_listeners(self, retrieve_all=True, **_params):
+ """Fetches a list of all lbaas_listeners for a tenant."""
+ return self.list('listeners', self.lbaas_listeners_path,
+ retrieve_all, **_params)
+
+ @APIParamsCall
+ def show_listener(self, lbaas_listener, **_params):
+ """Fetches information for a lbaas_listener."""
+ return self.get(self.lbaas_listener_path % (lbaas_listener),
+ params=_params)
+
+ @APIParamsCall
+ def create_listener(self, body=None):
+ """Creates a new lbaas_listener."""
+ return self.post(self.lbaas_listeners_path, body=body)
+
+ @APIParamsCall
+ def update_listener(self, lbaas_listener, body=None):
+ """Updates a lbaas_listener."""
+ return self.put(self.lbaas_listener_path % (lbaas_listener),
+ body=body)
+
+ @APIParamsCall
+ def delete_listener(self, lbaas_listener):
+ """Deletes the specified lbaas_listener."""
+ return self.delete(self.lbaas_listener_path % (lbaas_listener))
+
+ @APIParamsCall
+ def list_lbaas_pools(self, retrieve_all=True, **_params):
+ """Fetches a list of all lbaas_pools for a tenant."""
+ return self.list('pools', self.lbaas_pools_path,
+ retrieve_all, **_params)
+
+ @APIParamsCall
+ def show_lbaas_pool(self, lbaas_pool, **_params):
+ """Fetches information for a lbaas_pool."""
+ return self.get(self.lbaas_pool_path % (lbaas_pool),
+ params=_params)
+
+ @APIParamsCall
+ def create_lbaas_pool(self, body=None):
+ """Creates a new lbaas_pool."""
+ return self.post(self.lbaas_pools_path, body=body)
+
+ @APIParamsCall
+ def update_lbaas_pool(self, lbaas_pool, body=None):
+ """Updates a lbaas_pool."""
+ return self.put(self.lbaas_pool_path % (lbaas_pool),
+ body=body)
+
+ @APIParamsCall
+ def delete_lbaas_pool(self, lbaas_pool):
+ """Deletes the specified lbaas_pool."""
+ return self.delete(self.lbaas_pool_path % (lbaas_pool))
+
+ @APIParamsCall
+ def list_lbaas_healthmonitors(self, retrieve_all=True, **_params):
+ """Fetches a list of all lbaas_healthmonitors for a tenant."""
+ return self.list('healthmonitors', self.lbaas_healthmonitors_path,
+ retrieve_all, **_params)
+
+ @APIParamsCall
+ def show_lbaas_healthmonitor(self, lbaas_healthmonitor, **_params):
+ """Fetches information for a lbaas_healthmonitor."""
+ return self.get(self.lbaas_healthmonitor_path % (lbaas_healthmonitor),
+ params=_params)
+
+ @APIParamsCall
+ def create_lbaas_healthmonitor(self, body=None):
+ """Creates a new lbaas_healthmonitor."""
+ return self.post(self.lbaas_healthmonitors_path, body=body)
+
+ @APIParamsCall
+ def update_lbaas_healthmonitor(self, lbaas_healthmonitor, body=None):
+ """Updates a lbaas_healthmonitor."""
+ return self.put(self.lbaas_healthmonitor_path % (lbaas_healthmonitor),
+ body=body)
+
+ @APIParamsCall
+ def delete_lbaas_healthmonitor(self, lbaas_healthmonitor):
+ """Deletes the specified lbaas_healthmonitor."""
+ return self.delete(self.lbaas_healthmonitor_path %
+ (lbaas_healthmonitor))
+
+ @APIParamsCall
+ def list_lbaas_loadbalancers(self, retrieve_all=True, **_params):
+ """Fetches a list of all lbaas_loadbalancers for a tenant."""
+ return self.list('loadbalancers', self.lbaas_loadbalancers_path,
+ retrieve_all, **_params)
+
+ @APIParamsCall
+ def list_lbaas_members(self, lbaas_pool, retrieve_all=True, **_params):
+ """Fetches a list of all lbaas_members for a tenant."""
+ return self.list('members', self.lbaas_members_path % lbaas_pool,
+ retrieve_all, **_params)
+
+ @APIParamsCall
+ def show_lbaas_member(self, lbaas_member, lbaas_pool, **_params):
+ """Fetches information of a certain lbaas_member."""
+ return self.get(self.lbaas_member_path % (lbaas_pool, lbaas_member),
+ params=_params)
+
+ @APIParamsCall
+ def create_lbaas_member(self, lbaas_pool, body=None):
+ """Creates an lbaas_member."""
+ return self.post(self.lbaas_members_path % lbaas_pool, body=body)
+
+ @APIParamsCall
+ def update_lbaas_member(self, lbaas_member, lbaas_pool, body=None):
+ """Updates a lbaas_healthmonitor."""
+ return self.put(self.lbaas_member_path % (lbaas_pool, lbaas_member),
+ body=body)
+
+ @APIParamsCall
+ def delete_lbaas_member(self, lbaas_member, lbaas_pool):
+ """Deletes the specified lbaas_member."""
+ return self.delete(self.lbaas_member_path % (lbaas_pool, lbaas_member))
+
+ @APIParamsCall
def list_vips(self, retrieve_all=True, **_params):
"""Fetches a list of all load balancer vips for a tenant."""
# Pass filters in "params" argument to do_request