Merge "Add command for listing available service providers"
This commit is contained in:
commit
fad71220ea
31
neutronclient/neutron/v2_0/servicetype.py
Normal file
31
neutronclient/neutron/v2_0/servicetype.py
Normal file
@ -0,0 +1,31 @@
|
||||
# Copyright 2013 OpenStack LLC.
|
||||
# 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.
|
||||
#
|
||||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||
|
||||
import logging
|
||||
|
||||
from neutronclient.neutron import v2_0 as neutronV20
|
||||
|
||||
|
||||
class ListServiceProvider(neutronV20.ListCommand):
|
||||
"""List service providers."""
|
||||
|
||||
resource = 'service_provider'
|
||||
log = logging.getLogger(__name__ + '.ListServiceProviders')
|
||||
list_columns = ['service_type', 'name', 'default']
|
||||
_formatters = {}
|
||||
pagination_support = True
|
||||
sorting_support = True
|
@ -45,6 +45,7 @@ from neutronclient.neutron.v2_0 import port
|
||||
from neutronclient.neutron.v2_0 import quota
|
||||
from neutronclient.neutron.v2_0 import router
|
||||
from neutronclient.neutron.v2_0 import securitygroup
|
||||
from neutronclient.neutron.v2_0 import servicetype
|
||||
from neutronclient.neutron.v2_0 import subnet
|
||||
from neutronclient.openstack.common import strutils
|
||||
from neutronclient.version import __version__
|
||||
@ -179,6 +180,7 @@ COMMAND_V2 = {
|
||||
'l3-agent-list-hosting-router': agentscheduler.ListL3AgentsHostingRouter,
|
||||
'lb-pool-list-on-agent': agentscheduler.ListPoolsOnLbaasAgent,
|
||||
'lb-agent-hosting-pool': agentscheduler.GetLbaasAgentHostingPool,
|
||||
'service-provider-list': servicetype.ListServiceProvider,
|
||||
}
|
||||
|
||||
COMMANDS = {'2.0': COMMAND_V2}
|
||||
|
@ -183,6 +183,7 @@ class Client(object):
|
||||
agent_path = "/agents/%s"
|
||||
network_gateways_path = "/network-gateways"
|
||||
network_gateway_path = "/network-gateways/%s"
|
||||
service_providers_path = "/service-providers"
|
||||
|
||||
DHCP_NETS = '/dhcp-networks'
|
||||
DHCP_AGENTS = '/dhcp-agents'
|
||||
@ -202,6 +203,7 @@ class Client(object):
|
||||
'members': 'member',
|
||||
'health_monitors': 'health_monitor',
|
||||
'quotas': 'quota',
|
||||
'service_providers': 'service_provider'
|
||||
}
|
||||
# 8192 Is the default max URI len for eventlet.wsgi.server
|
||||
MAX_URI_LEN = 8192
|
||||
@ -732,6 +734,13 @@ class Client(object):
|
||||
return self.get((self.agent_path + self.LOADBALANCER_POOLS) %
|
||||
lbaas_agent, params=_params)
|
||||
|
||||
@APIParamsCall
|
||||
def list_service_providers(self, retrieve_all=True, **_params):
|
||||
"""Fetches service providers."""
|
||||
# Pass filters in "params" argument to do_request
|
||||
return self.list('service_providers', self.service_providers_path,
|
||||
retrieve_all, **_params)
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
"""Initialize a new client for the Neutron v2.0 API."""
|
||||
super(Client, self).__init__()
|
||||
|
62
tests/unit/test_cli20_servicetype.py
Normal file
62
tests/unit/test_cli20_servicetype.py
Normal file
@ -0,0 +1,62 @@
|
||||
# Copyright 2013 Mirantis 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: Eugene Nikanorov, Mirantis Inc.
|
||||
#
|
||||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||
|
||||
import sys
|
||||
|
||||
from neutronclient.neutron.v2_0 import servicetype
|
||||
from tests.unit import test_cli20
|
||||
|
||||
|
||||
class CLITestV20ServiceProvidersJSON(test_cli20.CLITestV20Base):
|
||||
id_field = "name"
|
||||
|
||||
def setUp(self):
|
||||
super(CLITestV20ServiceProvidersJSON, self).setUp(
|
||||
plurals={'tags': 'tag'}
|
||||
)
|
||||
|
||||
def test_list_service_providers(self):
|
||||
resources = "service_providers"
|
||||
cmd = servicetype.ListServiceProvider(test_cli20.MyApp(sys.stdout),
|
||||
None)
|
||||
self._test_list_resources(resources, cmd, True)
|
||||
|
||||
def test_list_service_providers_pagination(self):
|
||||
resources = "service_providers"
|
||||
cmd = servicetype.ListServiceProvider(test_cli20.MyApp(sys.stdout),
|
||||
None)
|
||||
self._test_list_resources_with_pagination(resources, cmd)
|
||||
|
||||
def test_list_service_providers_sort(self):
|
||||
resources = "service_providers"
|
||||
cmd = servicetype.ListServiceProvider(test_cli20.MyApp(sys.stdout),
|
||||
None)
|
||||
self._test_list_resources(resources, cmd,
|
||||
sort_key=["name"],
|
||||
sort_dir=["asc", "desc"])
|
||||
|
||||
def test_list_service_providers_limit(self):
|
||||
resources = "service_providers"
|
||||
cmd = servicetype.ListServiceProvider(test_cli20.MyApp(sys.stdout),
|
||||
None)
|
||||
self._test_list_resources(resources, cmd, page_size=1000)
|
||||
|
||||
|
||||
class CLITestV20ServiceProvidersXML(CLITestV20ServiceProvidersJSON):
|
||||
format = 'xml'
|
Loading…
x
Reference in New Issue
Block a user