Merge "Add network service provider list to OSC"
This commit is contained in:
commit
d6e058fa1f
18
doc/source/command-objects/network-service-provider.rst
Normal file
18
doc/source/command-objects/network-service-provider.rst
Normal file
@ -0,0 +1,18 @@
|
||||
========================
|
||||
network service provider
|
||||
========================
|
||||
|
||||
A **network service provider** is a particular driver that implements a
|
||||
networking service
|
||||
|
||||
Network v2
|
||||
|
||||
network service provider list
|
||||
-----------------------------
|
||||
|
||||
List service providers
|
||||
|
||||
.. program:: network service provider list
|
||||
.. code:: bash
|
||||
|
||||
os network service provider list
|
@ -114,6 +114,7 @@ referring to both Compute and Volume quotas.
|
||||
* ``network rbac``: (**Network**) - an RBAC policy for network resources
|
||||
* ``network qos policy``: (**Network**) - a QoS policy for network resources
|
||||
* ``network segment``: (**Network**) - a segment of a virtual network
|
||||
* ``network service provider``: (**Network**) - a driver providing a network service
|
||||
* ``object``: (**Object Storage**) a single file in the Object Storage
|
||||
* ``object store account``: (**Object Storage**) owns a group of Object Storage resources
|
||||
* ``policy``: (**Identity**) determines authorization
|
||||
|
41
openstackclient/network/v2/network_service_provider.py
Normal file
41
openstackclient/network/v2/network_service_provider.py
Normal file
@ -0,0 +1,41 @@
|
||||
# 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.
|
||||
#
|
||||
|
||||
"""Network Service Providers Implementation"""
|
||||
|
||||
from osc_lib.command import command
|
||||
from osc_lib import utils
|
||||
|
||||
|
||||
class ListNetworkServiceProvider(command.Lister):
|
||||
"""List Service Providers"""
|
||||
|
||||
def take_action(self, parsed_args):
|
||||
client = self.app.client_manager.network
|
||||
|
||||
columns = (
|
||||
'service_type',
|
||||
'name',
|
||||
'is_default',
|
||||
)
|
||||
column_headers = (
|
||||
'Service Type',
|
||||
'Name',
|
||||
'Default',
|
||||
)
|
||||
|
||||
data = client.service_providers()
|
||||
return(column_headers,
|
||||
(utils.get_item_properties(
|
||||
s, columns,
|
||||
) for s in data))
|
@ -0,0 +1,26 @@
|
||||
# Copyright (c) 2016, Intel Corporation.
|
||||
# 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 openstackclient.tests.functional import base
|
||||
|
||||
|
||||
class TestNetworkServiceProvider(base.TestCase):
|
||||
"""Functional tests for network service provider"""
|
||||
|
||||
SERVICE_TYPE = ['L3_ROUTER_NAT']
|
||||
|
||||
def test_network_service_provider_list(self):
|
||||
raw_output = self.openstack('network service provider list')
|
||||
self.assertIn(self.SERVICE_TYPE, raw_output)
|
@ -1269,3 +1269,38 @@ class FakeSubnetPool(object):
|
||||
if subnet_pools is None:
|
||||
subnet_pools = FakeSubnetPool.create_subnet_pools(count)
|
||||
return mock.Mock(side_effect=subnet_pools)
|
||||
|
||||
|
||||
class FakeNetworkServiceProvider(object):
|
||||
"""Fake Network Service Providers"""
|
||||
|
||||
@staticmethod
|
||||
def create_one_network_service_provider(attrs=None):
|
||||
"""Create service provider"""
|
||||
attrs = attrs or {}
|
||||
|
||||
service_provider = {
|
||||
'name': 'provider-name-' + uuid.uuid4().hex,
|
||||
'service_type': 'service-type-' + uuid.uuid4().hex,
|
||||
'default': False,
|
||||
}
|
||||
|
||||
service_provider.update(attrs)
|
||||
|
||||
provider = fakes.FakeResource(
|
||||
info=copy.deepcopy(service_provider),
|
||||
loaded=True)
|
||||
provider.is_default = service_provider['default']
|
||||
|
||||
return provider
|
||||
|
||||
@staticmethod
|
||||
def create_network_service_providers(attrs=None, count=2):
|
||||
"""Create multiple service providers"""
|
||||
|
||||
service_providers = []
|
||||
for i in range(0, count):
|
||||
service_providers.append(FakeNetworkServiceProvider.
|
||||
create_one_network_service_provider(
|
||||
attrs))
|
||||
return service_providers
|
||||
|
@ -0,0 +1,71 @@
|
||||
# Copyright (c) 2016, Intel Corporation.
|
||||
# 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.
|
||||
|
||||
import mock
|
||||
|
||||
from openstackclient.network.v2 import network_service_provider \
|
||||
as service_provider
|
||||
from openstackclient.tests.unit.network.v2 import fakes
|
||||
|
||||
|
||||
class TestNetworkServiceProvider(fakes.TestNetworkV2):
|
||||
|
||||
def setUp(self):
|
||||
super(TestNetworkServiceProvider, self).setUp()
|
||||
self.network = self.app.client_manager.network
|
||||
|
||||
|
||||
class TestListNetworkServiceProvider(TestNetworkServiceProvider):
|
||||
provider_list = \
|
||||
fakes.FakeNetworkServiceProvider.create_network_service_providers(
|
||||
count=2
|
||||
)
|
||||
|
||||
columns = (
|
||||
'Service Type',
|
||||
'Name',
|
||||
'Default',
|
||||
)
|
||||
|
||||
data = []
|
||||
|
||||
for provider in provider_list:
|
||||
data.append((
|
||||
provider.service_type,
|
||||
provider.name,
|
||||
provider.is_default,
|
||||
))
|
||||
|
||||
def setUp(self):
|
||||
super(TestListNetworkServiceProvider, self).setUp()
|
||||
self.network.service_providers = mock.Mock(
|
||||
return_value=self.provider_list
|
||||
)
|
||||
|
||||
self.cmd = \
|
||||
service_provider.ListNetworkServiceProvider(self.app,
|
||||
self.namespace)
|
||||
|
||||
def test_network_service_provider_list(self):
|
||||
arglist = []
|
||||
verifylist = []
|
||||
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
|
||||
self.network.service_providers.assert_called_with()
|
||||
self.assertEqual(self.columns, columns)
|
||||
self.assertEqual(self.data, list(data))
|
@ -0,0 +1,4 @@
|
||||
---
|
||||
features:
|
||||
- |
|
||||
Add support for the ``network service provider`` command.
|
@ -384,6 +384,8 @@ openstack.network.v2 =
|
||||
network_segment_set = openstackclient.network.v2.network_segment:SetNetworkSegment
|
||||
network_segment_show = openstackclient.network.v2.network_segment:ShowNetworkSegment
|
||||
|
||||
network_service_provider_list = openstackclient.network.v2.network_service_provider:ListNetworkServiceProvider
|
||||
|
||||
port_create = openstackclient.network.v2.port:CreatePort
|
||||
port_delete = openstackclient.network.v2.port:DeletePort
|
||||
port_list = openstackclient.network.v2.port:ListPort
|
||||
|
Loading…
Reference in New Issue
Block a user