Compare commits

...

15 Commits

Author SHA1 Message Date
Jay Faulkner
946ac3ed2e Convert exception to string before passing it in
Before this change, neutronclient was passing in a raw exception
as a kwarg to the ConnectionFailed exception. This caused an
exception to be raised in _safe_decode_dict() due to the exception
not being a text type.

Now, we explicitly convert the raw exception to a string before
passing it as a kwarg.

Closes-bug: 1859068
Change-Id: I323b3aceec0a937874eabf770fbc82995202f6d6
2020-01-14 15:33:30 +00:00
Rodolfo Alonso Hernandez
a363edd761 Avoid py36 error when printing unicode chars in a stream
The IOStream was not able to encode characters out of range 128:
  "UnicodeEncodeError: 'ascii' codec can't encode characters in
   position 19-21: ordinal not in range(128)"

Change-Id: Ic95396a5cf73c49d332928857dc064819a6d7ea6
Closes-Bug: #1858421
2020-01-10 18:57:25 +00:00
liushuobj
29043825e7 fix a typo
Change-Id: I9d82335c37f114aa43f26dec106e7598e776e068
2019-12-27 16:36:30 +08:00
Zuul
918b590fbf Merge "Drop python3 hack for XML serializer" 2019-12-21 23:37:06 +00:00
Zuul
1168458db2 Merge "Drop python 2.7 support" 2019-12-21 23:37:06 +00:00
Akihiro Motoki
91fb009706 Fix pep8 errors with hacking 2.0.0
Change-Id: I4737d4bc4fa116f45e2361eba93f48feae0161a4
2019-12-17 16:39:14 +09:00
Akihiro Motoki
010053df07 Drop python 2.7 support
We no longer support python 2.7 past Train.
Let's stop testings with python 2.7 and drop python 2.7 stuffs.

pypy in tox.ini is also dropped too. It is not used for long.

Change-Id: I8a07c007a129cd2141085a1a3cc7f81658c42db2
2019-12-17 14:46:06 +09:00
Akihiro Motoki
d5c516a5a2 Drop python3 hack for XML serializer
It was added in https://review.opendev.org/#/c/110947/
to make the XML serializer work in python 3.
We dropped the XML serializer support long ago.
I believe we can drop it safely.

Change-Id: I208de891515cb2cbdde779013ba58f19e36fc55c
2019-12-17 14:43:05 +09:00
Zuul
e68234ecf6 Merge "Move grenade neutron-lib job to py3 and in python-neutronclient repo" 2019-12-11 23:45:19 +00:00
Ghanshyam Mann
c430ed8950 Move grenade neutron-lib job to py3 and in python-neutronclient repo
'legacy-grenade-dsvm-neutron-libs' grenade neutron-lib jobs
is present in opensatck-zuul-jobs repo running on python 2. This needs
to run on py3 from Ussuri onwards and py2 for stable/branch.

python-neutronclient is the only repo which is using this job.

py2 version has been kept in opensatck-zuul-jobs and for ussuri
onwwards this has been migrated to python-neutronclient repo with
py3 version.

Change-Id: I165f86e1d05c8830e0b75b5c2db369178a3df7e7
2019-12-09 09:20:20 +01:00
kangyufei
40996e50ea Switch to Ussuri jobs
Change-Id: I59807606d4865cb2f4d9c6a912f659ea45b3fba8
2019-10-22 17:05:41 +08:00
Zuul
f46bf7eca0 Merge "PDF documentation build" 2019-10-07 17:33:23 +00:00
zhanghao2
ee08644c5f Remove 'public' and 'private' parameters in fwaas_v2
The 'public' and 'private' parameters have been replaced
with 'share' and 'no-share' parameters in the Pike version,
they can be removed now.

Change-Id: I57a2e228ec1cdb6ed259914abc38bdada036d369
2019-10-01 05:21:19 -04:00
f61cd94e11 Update master for stable/train
Add file to the reno documentation build to show release notes for
stable/train.

Use pbr instruction to increment the minor version number
automatically so that master versions are higher than the versions on
stable/train.

Change-Id: I1dd2ee12854ac7a55baa2114230ab42404dea5c1
Sem-Ver: feature
2019-09-20 17:41:48 +00:00
Akihiro Motoki
d6c78a5d39 PDF documentation build
Change-Id: I0abc5df1dfde23756bc2fd78631141ba685dc6fe
Story: 2006099
Task: 35139
2019-09-05 12:27:30 +00:00
20 changed files with 168 additions and 118 deletions

View File

@@ -2,8 +2,7 @@
templates:
- openstack-cover-jobs
- openstack-lower-constraints-jobs
- openstack-python-jobs
- openstack-python3-train-jobs
- openstack-python3-ussuri-jobs
- publish-openstack-docs-pti
- check-requirements
- lib-forward-testing
@@ -18,7 +17,7 @@
- neutronclient-functional
experimental:
jobs:
- legacy-grenade-dsvm-neutron-libs:
- neutron-lib-grenade-dsvm:
irrelevant-files:
- ^(test-|)requirements.txt$
- ^setup.cfg$
@@ -45,3 +44,29 @@
LIBS_FROM_GIT: python-neutronclient
devstack_plugins:
neutron-vpnaas: https://opendev.org/openstack/neutron-vpnaas
- job:
name: neutron-lib-grenade-dsvm
# Old name: legacy-grenade-dsvm-neutron-libs
parent: legacy-dsvm-base
run: playbooks/legacy/grenade-dsvm-neutron-libs/run.yaml
post-run: playbooks/legacy/grenade-dsvm-neutron-libs/post.yaml
timeout: 10800
required-projects:
- openstack/grenade
- openstack/devstack-gate
- openstack/keystoneauth
- openstack/neutron
- openstack/neutron-lib
- openstack/os-client-config
- openstack/python-cinderclient
- openstack/python-glanceclient
- openstack/python-ironicclient
- openstack/python-keystoneclient
- openstack/python-neutronclient
- openstack/python-novaclient
# This is py3 version for ussuri onwards rest all branch needs to be py2
# version which is present in openstack-zuul-jobs.
# We need to take care of this branch variant and python version while
# migrating these jobs to zuulv3.
branches: ^(?!(stable/(ocata|pike|queens|rocky|stein|train))).*$

View File

@@ -49,6 +49,25 @@ html_theme = 'openstackdocs'
# Output file base name for HTML help builder.
htmlhelp_basename = 'neutronclientdoc'
# -- Options for LaTeX output ------------------------------------------------
latex_documents = [
('index', 'doc-python-neutronclient.tex',
u'python-neutronclient Documentation',
u'Neutron Contributors', 'manual'),
]
# Disable usage of xindy https://bugzilla.redhat.com/show_bug.cgi?id=1643664
latex_use_xindy = False
latex_domain_indices = False
latex_elements = {
'makeindex': '',
'printindex': '',
'preamble': r'\setcounter{tocdepth}{5}',
}
# -- Options for cliff.sphinxext plugin ---------------------------------------
autoprogram_cliff_application = 'openstack'

View File

@@ -104,13 +104,13 @@ class HTTPClient(object):
try:
resp, body = self.request(*args, **kargs)
except requests.exceptions.SSLError as e:
raise exceptions.SslCertificateValidationError(reason=e)
raise exceptions.SslCertificateValidationError(reason=str(e))
except Exception as e:
# Wrap the low-level connection error (socket timeout, redirect
# limit, decompression error, etc) into our custom high-level
# connection exception (it is excepted in the upper layers of code)
_logger.debug("throwing ConnectionFailed : %s", e)
raise exceptions.ConnectionFailed(reason=e)
raise exceptions.ConnectionFailed(reason=str(e))
utils.http_log_resp(_logger, resp, body)
# log request-id for each api call

View File

@@ -20,10 +20,6 @@ from neutronclient._i18n import _
from neutronclient.common import exceptions as exception
if six.PY3:
long = int
class ActionDispatcher(object):
"""Maps method name to local methods through action name."""

View File

@@ -77,19 +77,6 @@ def _get_common_parser(parser):
action='store_true',
help=_('Detach egress firewall policy from the firewall group'))
shared_group = parser.add_mutually_exclusive_group()
shared_group.add_argument(
'--public',
action='store_true',
help=_('Make the firewall group public, which allows it to be '
'used in all projects (as opposed to the default, '
'which is to restrict its use to the current project). '
'This option is deprecated and would be removed in R release.'))
shared_group.add_argument(
'--private',
action='store_true',
help=_('Restrict use of the firewall group to the '
'current project. This option is deprecated '
'and would be removed in R release.'))
shared_group.add_argument(
'--share',
@@ -147,9 +134,9 @@ def _get_common_attrs(client_manager, parsed_args, is_create=True):
cmd_resource=const.CMD_FWP)['id']
elif parsed_args.no_egress_firewall_policy:
attrs['egress_firewall_policy_id'] = None
if parsed_args.share or parsed_args.public:
if parsed_args.share:
attrs['shared'] = True
if parsed_args.no_share or parsed_args.private:
if parsed_args.no_share:
attrs['shared'] = False
if parsed_args.enable:
attrs['admin_state_up'] = True
@@ -349,14 +336,6 @@ class UnsetFirewallGroup(command.Command):
dest='egress_firewall_policy',
help=_('Egress firewall policy (name or ID) to delete'))
shared_group = parser.add_mutually_exclusive_group()
shared_group.add_argument(
'--public',
action='store_true',
help=_('Make the firewall group public, which allows it to be '
'used in all projects (as opposed to the default, '
'which is to restrict its use to the current project). '
'This option is deprecated and would be removed in R'
' release.'))
shared_group.add_argument(
'--share',
action='store_true',
@@ -375,7 +354,7 @@ class UnsetFirewallGroup(command.Command):
attrs['ingress_firewall_policy_id'] = None
if parsed_args.egress_firewall_policy:
attrs['egress_firewall_policy_id'] = None
if parsed_args.share or parsed_args.public:
if parsed_args.share:
attrs['shared'] = False
if parsed_args.enable:
attrs['admin_state_up'] = False

View File

@@ -80,9 +80,9 @@ def _get_common_attrs(client_manager, parsed_args, is_create=True):
attrs['name'] = str(parsed_args.name)
if parsed_args.description:
attrs['description'] = str(parsed_args.description)
if parsed_args.share or parsed_args.public:
if parsed_args.share:
attrs['shared'] = True
if parsed_args.no_share or parsed_args.private:
if parsed_args.no_share:
attrs['shared'] = False
return attrs
@@ -107,19 +107,6 @@ def _get_common_parser(parser):
help=_('Share the firewall policy to be used in all projects '
'(by default, it is restricted to be used by the '
'current project).'))
shared_group.add_argument(
'--public',
action='store_true',
help=_('Make the firewall policy public, which allows it to be '
'used in all projects (as opposed to the default, which '
'is to restrict its use to the current project.) This '
'option is deprecated and would be removed in R release.'))
shared_group.add_argument(
'--private',
action='store_true',
help=_(
'Restrict use of the firewall policy to the current project.'
'This option is deprecated and would be removed in R release.'))
shared_group.add_argument(
'--no-share',
action='store_true',
@@ -403,12 +390,6 @@ class UnsetFirewallPolicy(command.Command):
action='store_true',
help=_('Restrict use of the firewall policy to the '
'current project'))
parser.add_argument(
'--public',
action='store_true',
help=_('Restrict use of the firewall policy to the '
'current project. This option is deprecated '
'and would be removed in R release.'))
return parser
def _get_attrs(self, client_manager, parsed_args):
@@ -428,7 +409,7 @@ class UnsetFirewallPolicy(command.Command):
attrs[const.FWRS] = []
if parsed_args.audited:
attrs['audited'] = False
if parsed_args.share or parsed_args.public:
if parsed_args.share:
attrs['shared'] = False
return attrs

View File

@@ -117,19 +117,6 @@ def _get_common_parser(parser):
action='store_true',
help=_('Detach destination port number or range'))
shared_group = parser.add_mutually_exclusive_group()
shared_group.add_argument(
'--public',
action='store_true',
help=_('Make the firewall policy public, which allows it to be '
'used in all projects (as opposed to the default, '
'which is to restrict its use to the current project). '
'This option is deprecated and would be removed in R Release'))
shared_group.add_argument(
'--private',
action='store_true',
help=_(
'Restrict use of the firewall rule to the current project.'
'This option is deprecated and would be removed in R release.'))
shared_group.add_argument(
'--share',
action='store_true',
@@ -212,9 +199,9 @@ def _get_common_attrs(client_manager, parsed_args, is_create=True):
attrs['enabled'] = True
if parsed_args.disable_rule:
attrs['enabled'] = False
if parsed_args.share or parsed_args.public:
if parsed_args.share:
attrs['shared'] = True
if parsed_args.no_share or parsed_args.private:
if parsed_args.no_share:
attrs['shared'] = False
if parsed_args.source_firewall_group:
attrs['source_firewall_group_id'] = client.find_resource(
@@ -416,12 +403,6 @@ class UnsetFirewallRule(command.Command):
'--share',
action='store_true',
help=_('Restrict use of the firewall rule to the current project'))
parser.add_argument(
'--public',
action='store_true',
help=_('Restrict use of the firewall rule to the current project. '
'This option is deprecated and would be removed in '
'R Release.'))
parser.add_argument(
'--enable-rule',
action='store_true',
@@ -448,7 +429,7 @@ class UnsetFirewallRule(command.Command):
attrs['destination_ip_address'] = None
if parsed_args.destination_port:
attrs['destination_port'] = None
if parsed_args.share or parsed_args.public:
if parsed_args.share:
attrs['shared'] = False
if parsed_args.enable_rule:
attrs['enabled'] = False

View File

@@ -120,20 +120,6 @@ class TestSetFWaaS(test_fakes.TestNeutronClientOSCV2):
target, {self.res: {'shared': True}})
self.assertIsNone(result)
def test_set_public(self):
target = self.resource['id']
arglist = [target, '--public']
verifylist = [
(self.res, target),
('public', True),
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
result = self.cmd.take_action(parsed_args)
self.mocked.assert_called_once_with(
target, {self.res: {'shared': True}})
self.assertIsNone(result)
def test_set_duplicate_shared(self):
target = self.resource['id']
arglist = [target, '--share', '--share']

View File

@@ -139,8 +139,8 @@ class TestCreateNetworkLog(TestNetworkLog):
self.mocked = self.neutronclient.create_network_log
self.cmd = network_log.CreateNetworkLog(self.app, self.namespace)
loggables = {
"loggable_resources": [{"type": RES_TYPE_SG,
"type": RES_TYPE_FWG}]
"loggable_resources": [{"type": RES_TYPE_SG},
{"type": RES_TYPE_FWG}]
}
self.neutronclient.list_network_loggable_resources = mock.Mock(
return_value=loggables)

View File

@@ -33,9 +33,9 @@ class CLITestV20QoSRuleJSON(test_cli20.CLITestV20Base):
# qos_rule_types.
resources = 'rule_types'
cmd_resources = 'qos_rule_types'
response_contents = [{'type': 'bandwidth_limit',
'type': 'dscp_marking',
'type': 'minimum_bandwidth'}]
response_contents = [{'type': 'bandwidth_limit'},
{'type': 'dscp_marking'},
{'type': 'minimum_bandwidth'}]
cmd = qos_rule.ListQoSRuleTypes(test_cli20.MyApp(sys.stdout),
None)

View File

@@ -12,7 +12,9 @@
# License for the specific language governing permissions and limitations
# under the License.
import fixtures
import sys
import mock
from oslo_utils import encodeutils
import six
import testtools
@@ -30,12 +32,11 @@ class TestExceptions(testtools.TestCase):
multibyte_unicode_string = u'\uff21\uff22\uff23'
e = TestException(reason=multibyte_unicode_string)
fixture = fixtures.StringStream('stdout')
self.useFixture(fixture)
with fixtures.MonkeyPatch('sys.stdout', fixture.stream):
with mock.patch.object(sys, 'stdout') as mock_stdout:
print(e)
self.assertEqual('Exception with %s' % multibyte_unicode_string,
fixture.getDetails().get('stdout').as_text())
exc_str = 'Exception with %s' % multibyte_unicode_string
mock_stdout.assert_has_calls([mock.call.write(exc_str)])
def test_exception_message_with_encoded_unicode(self):
class TestException(exceptions.NeutronException):

View File

@@ -0,0 +1,15 @@
- hosts: primary
tasks:
- name: Copy files from {{ ansible_user_dir }}/workspace/ on node
synchronize:
src: '{{ ansible_user_dir }}/workspace/'
dest: '{{ zuul.executor.log_root }}'
mode: pull
copy_links: true
verify_host: true
rsync_opts:
- --include=/logs/**
- --include=*/
- --exclude=*
- --prune-empty-dirs

View File

@@ -0,0 +1,52 @@
- hosts: all
name: Autoconverted job legacy-grenade-dsvm-neutron-libs from old job gate-grenade-dsvm-neutron-libs-ubuntu-xenial-nv
tasks:
- name: Ensure legacy workspace directory
file:
path: '{{ ansible_user_dir }}/workspace'
state: directory
- shell:
cmd: |
set -e
set -x
cat > clonemap.yaml << EOF
clonemap:
- name: openstack/devstack-gate
dest: devstack-gate
EOF
/usr/zuul-env/bin/zuul-cloner -m clonemap.yaml --cache-dir /opt/git \
https://opendev.org \
openstack/devstack-gate
executable: /bin/bash
chdir: '{{ ansible_user_dir }}/workspace'
environment: '{{ zuul | zuul_legacy_vars }}'
- shell:
cmd: |
set -e
set -x
export PROJECTS="openstack/grenade $PROJECTS"
export DEVSTACK_PROJECT_FROM_GIT="os-client-config"
export DEVSTACK_PROJECT_FROM_GIT+=",keystoneauth"
export DEVSTACK_PROJECT_FROM_GIT+=",python-novaclient"
export DEVSTACK_PROJECT_FROM_GIT+=",python-keystoneclient"
export DEVSTACK_PROJECT_FROM_GIT+=",python-glanceclient"
export DEVSTACK_PROJECT_FROM_GIT+=",python-cinderclient"
export DEVSTACK_PROJECT_FROM_GIT+=",python-neutronclient"
export DEVSTACK_PROJECT_FROM_GIT+=",python-ironicclient"
export PYTHONUNBUFFERED=true
export DEVSTACK_GATE_TEMPEST=1
export DEVSTACK_GATE_GRENADE=pullup
export DEVSTACK_GATE_USE_PYTHON3=True
export DEVSTACK_GATE_NEUTRON=1
export BRANCH_OVERRIDE=default
if [ "$BRANCH_OVERRIDE" != "default" ] ; then
export OVERRIDE_ZUUL_BRANCH=$BRANCH_OVERRIDE
fi
cp devstack-gate/devstack-vm-gate-wrap.sh ./safe-devstack-vm-gate-wrap.sh
./safe-devstack-vm-gate-wrap.sh
executable: /bin/bash
chdir: '{{ ansible_user_dir }}/workspace'
environment: '{{ zuul | zuul_legacy_vars }}'

View File

@@ -0,0 +1,5 @@
---
upgrade:
- |
Python 2.7 support has been dropped. The minimum version of Python now
supported by python-neutronclient is Python 3.6.

View File

@@ -2,7 +2,7 @@
features:
- Support os-client-config. OS_CLOUD environment variable is used for
selecting named cloud configuration.
- Support keystoneauth1 library which brings us better kyestone v3 support.
- Support keystoneauth1 library which brings us better keystone v3 support.
- Client command extension now supports a child resource.
- New CLI for VPNaaS multiple local subnets.
- New CLI for VPNaaS endpoint group API.

View File

@@ -0,0 +1,6 @@
---
upgrade:
- |
The deprecated options ``--public`` and ``--private`` were
dropped in FWaaS v2 related commands. Use ``--share`` and
``--no-share`` instead.

View File

@@ -6,6 +6,7 @@
:maxdepth: 1
unreleased
train
stein
rocky
queens

View File

@@ -0,0 +1,6 @@
==========================
Train Series Release Notes
==========================
.. release-notes::
:branch: stable/train

View File

@@ -14,8 +14,6 @@ classifier =
License :: OSI Approved :: Apache Software License
Operating System :: POSIX :: Linux
Programming Language :: Python
Programming Language :: Python :: 2
Programming Language :: Python :: 2.7
Programming Language :: Python :: 3
Programming Language :: Python :: 3.6
Programming Language :: Python :: 3.7
@@ -457,9 +455,6 @@ neutron.cli.v2 =
vpn-ikepolicy-update = neutronclient.neutron.v2_0.vpn.ikepolicy:UpdateIKEPolicy
vpn-ikepolicy-delete = neutronclient.neutron.v2_0.vpn.ikepolicy:DeleteIKEPolicy
[wheel]
universal = 1
[extract_messages]
keywords = _ gettext ngettext l_ lazy_gettext
mapping_file = babel.cfg

22
tox.ini
View File

@@ -1,10 +1,11 @@
[tox]
# py3 first to avoid .testrepository incompatibility
envlist = py37,py27,pypy,pep8
envlist = py37,pep8
minversion = 2.3.2
skipsdist = True
ignore_basepython_conflict = True
[testenv]
basepython = python3
setenv = VIRTUAL_ENV={envdir}
LANG=en_US.UTF-8
LANGUAGE=en_US:en
@@ -25,24 +26,20 @@ commands = sh -c "find . -type d -name '.?*' -prune -o \
whitelist_externals = sh
[testenv:pep8]
basepython = python3
commands =
flake8
{[testenv:bandit]commands}
distribute = false
[testenv:venv]
basepython = python3
commands = {posargs}
[testenv:functional]
basepython = python3
setenv =
OS_TEST_PATH = ./neutronclient/tests/functional
OS_NEUTRONCLIENT_EXEC_DIR = {envdir}/bin
[testenv:cover]
basepython = python3
setenv =
{[testenv]setenv}
PYTHON=coverage run --source neutronclient --parallel-mode
@@ -54,12 +51,19 @@ commands =
coverage report
[testenv:docs]
basepython = python3
deps = -r{toxinidir}/doc/requirements.txt
commands = sphinx-build -W -b html doc/source doc/build/html
[testenv:pdf-docs]
envdir = {toxworkdir}/docs
deps = {[testenv:docs]deps}
whitelist_externals =
make
commands =
sphinx-build -W -b latex doc/source doc/build/pdf
make -C doc/build/pdf
[testenv:releasenotes]
basepython = python3
deps = -r{toxinidir}/doc/requirements.txt
commands = sphinx-build -a -E -d releasenotes/build/doctrees -b html releasenotes/source releasenotes/build/html
@@ -72,13 +76,11 @@ import-order-style = pep8
enable-extensions=H904
[testenv:bandit]
basepython = python3
# B303: blacklist calls: md5, sha1
deps = -r{toxinidir}/test-requirements.txt
commands = bandit -r neutronclient -x tests -n5 -s B303
[testenv:lower-constraints]
basepython = python3
deps =
-c{toxinidir}/lower-constraints.txt
-r{toxinidir}/test-requirements.txt