Merge "Base OSC plugin support"

This commit is contained in:
Jenkins 2016-07-09 01:03:29 +00:00 committed by Gerrit Code Review
commit 06ada316a0
17 changed files with 95 additions and 0 deletions

View File

View File

@ -0,0 +1,61 @@
# 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 logging
# TODO(rtheis/amotoki): Add functional test infrastructure for OSC
# plugin commands.
# TODO(amotoki): Add and update document on OSC pluign.
from osc_lib import utils
LOG = logging.getLogger(__name__)
DEFAULT_API_VERSION = '2.0'
API_VERSION_OPTION = 'os_network_api_version'
# NOTE(rtheis): API_NAME must NOT be set to 'network' since
# 'network' is owned by OSC! The OSC 'network' client uses
# the OpenStack SDK.
API_NAME = 'neutronclient'
API_VERSIONS = {
'2.0': 'neutronclient.v2_0.client.Client',
'2': 'neutronclient.v2_0.client.Client',
}
def make_client(instance):
"""Returns an neutron client."""
neutron_client = utils.get_client_class(
API_NAME,
instance._api_version[API_NAME],
API_VERSIONS)
LOG.debug('Instantiating neutron client: %s', neutron_client)
# TODO(amotoki): Check the following arguments need to be passed
# to neutronclient class. Check keystoneauth code.
# - endpoint_type (do we need to specify it explicitly?)
# - auth (session object contains auth. Is it required?)
client = neutron_client(session=instance.session,
region_name=instance._region_name,
endpoint_type=instance._interface,
insecure=instance._insecure,
ca_cert=instance._cacert)
return client
def build_option_parser(parser):
"""Hook to add global options"""
# NOTE(amotoki): At now we register no option.
# OSC itself has an option for Network API version # and we refer to it.
return parser

View File

View File

View File

View File

View File

View File

@ -0,0 +1,27 @@
# 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 argparse
import mock
from openstackclient.tests import utils
class TestNeutronClientOSCV2(utils.TestCommand):
def setUp(self):
super(TestNeutronClientOSCV2, self).setUp()
self.namespace = argparse.Namespace()
self.app.client_manager.session = mock.Mock()
self.app.client_manager.neutronclient = mock.Mock()
self.neutronclient = self.app.client_manager.neutronclient

View File

@ -6,6 +6,7 @@ cliff!=1.16.0,!=1.17.0,>=1.15.0 # Apache-2.0
debtcollector>=1.2.0 # Apache-2.0
iso8601>=0.1.11 # MIT
netaddr!=0.7.16,>=0.7.12 # BSD
osc-lib>=0.1.0 # Apache-2.0
oslo.i18n>=2.1.0 # Apache-2.0
oslo.serialization>=1.10.0 # Apache-2.0
oslo.utils>=3.14.0 # Apache-2.0

View File

@ -31,6 +31,11 @@ setup-hooks =
console_scripts =
neutron = neutronclient.shell:main
openstack.cli.extension =
neutronclient = neutronclient.osc.plugin
openstack.neutronclient.v2 =
[build_sphinx]
all_files = 1
build-dir = doc/build

View File

@ -10,6 +10,7 @@ mox3>=0.7.0 # Apache-2.0
mock>=2.0 # BSD
oslosphinx!=3.4.0,>=2.5.0 # Apache-2.0
oslotest>=1.10.0 # Apache-2.0
python-openstackclient>=2.1.0 # Apache-2.0
python-subunit>=0.0.18 # Apache-2.0/BSD
reno>=1.8.0 # Apache2
requests-mock>=1.0 # Apache-2.0