vmware-nsx/vmware_nsx_tempest/services/lbaas/load_balancers_client.py
Alex Kang 95fb8acd92 [Tempest]: initial lbaasv2 clients and API tests
Ported LBaasV2 clients and API tests from repo neutron_lbaas.

1. LBaasV2 core network is updated to reflect that nsxv
   requiring subnet attached to exclusive router.
2. Modified to comply with tempest service client standard.
3. bugs opened to trace differences against upstream
   1638148, 1637877, 1638571(p0), 1639223,
   1638601(p0), 1639340, 1641643, 1641652, 1641902

Change-Id: I46d9dec3e8e23b9df6561acecf929fc0fd99686b
2016-04-14 14:27:35 +00:00

80 lines
3.1 KiB
Python

# Copyright 2014 Rackspace US 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.
from tempest.lib.services.network import base
class LoadBalancersClient(base.BaseNetworkClient):
resource = 'loadbalancer'
resource_plural = 'loadbalancers'
path = 'lbaas/loadbalancers'
resource_base_path = '/%s' % path
resource_object_path = '/%s/%%s' % path
resource_object_status_path = '/%s/%%s/statuses' % path
resource_object_stats_path = '/%s/%%s/stats' % path
def create_load_balancer(self, **kwargs):
uri = self.resource_base_path
post_data = {self.resource: kwargs}
return self.create_resource(uri, post_data)
def update_load_balancer(self, load_balancer_id, **kwargs):
uri = self.resource_object_path % load_balancer_id
post_data = {self.resource: kwargs}
return self.update_resource(uri, post_data)
def show_load_balancer(self, load_balancer_id, **fields):
uri = self.resource_object_path % load_balancer_id
return self.show_resource(uri, **fields)
def show_load_balancer_status_tree(self, load_balancer_id, **fields):
uri = self.resource_object_status_path % load_balancer_id
return self.show_resource(uri, **fields)
def show_load_balancer_stats(self, load_balancer_id, **fields):
uri = self.resource_object_stats_path % load_balancer_id
return self.show_resource(uri, **fields)
def delete_load_balancer(self, load_balancer_id):
uri = self.resource_object_path % load_balancer_id
return self.delete_resource(uri)
def list_load_balancers(self, **filters):
uri = self.resource_base_path
return self.list_resources(uri, **filters)
def get_client(client_mgr):
"""create a lbaas load-balancers client from manager or networks_client
For itempest user:
from itempest import load_our_solar_system as osn
from vmware_nsx_tempest.services.lbaas import load_balancers_client
lbaas_client = load_balancers_client.get_client(osn.adm.manager)
For tempest user:
lbaas_client = load_balancers_client.get_client(osn.adm)
"""
manager = getattr(client_mgr, 'manager', client_mgr)
net_client = getattr(manager, 'networks_client')
try:
_params = manager.default_params_with_timeout_values.copy()
except Exception:
_params = {}
client = LoadBalancersClient(net_client.auth_provider,
net_client.service,
net_client.region,
net_client.endpoint_type,
**_params)
return client