Compare commits

..

9 Commits

Author SHA1 Message Date
Jay Faulkner
a09e82470f 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
(cherry picked from commit 946ac3ed2e)
2020-02-03 14:44:51 +00:00
Akihiro Motoki
33ae5ad4e1 Fix pep8 errors with hacking 2.0.0
Change-Id: I4737d4bc4fa116f45e2361eba93f48feae0161a4
(cherry picked from commit 91fb009706)
2020-01-29 16:34:58 +00:00
e4bad046de Update TOX/UPPER_CONSTRAINTS_FILE for stable/train
Update the URL to the upper-constraints file to point to the redirect
rule on releases.openstack.org so that anyone working on this branch
will switch to the correct upper-constraints list automatically when
the requirements repository branches.

Until the requirements repository has as stable/train branch, tests will
continue to use the upper-constraints list on master.

Change-Id: Ieffc1b87a0f899801f8084ecd01c99c40d3991a9
2019-09-20 17:41:46 +00:00
4d50713d54 Update .gitreview for stable/train
Change-Id: I581a3f0f977f1eb9d2eabbfe109ebd13ecb4cb4f
2019-09-20 17:41:44 +00:00
Zuul
115f60f005 Merge "Add router add/remove extra routes operations" 2019-09-13 12:34:03 +00:00
Bence Romsics
1c634ed2c1 Add router add/remove extra routes operations
Add methods to the client to call the two new member actions introduced by
new Neutron extension: extraroute-atomic.

Change-Id: Idb1fa073c2ff31f566b376cfa4f63cf27fecec86
Partial-Bug: #1826396 (rfe)
Related-Change: https://review.opendev.org/655680 (spec)
2019-09-13 09:07:19 +00:00
jiasirui
e35b3c160b Improve help text
Change-Id: Idc8f55567d0d4c95968d34d3b7aa95048623d9d0
2019-08-30 08:28:22 +08:00
Oleg Bondarev
62f4868e6e Fix string in header
Commit ab426a791a changed
sha1 to sha256.
Need to change string correspondingly

Change-Id: I8b35350c32ab551d513f21325931d6697f62fb2f
Related-Bug: #1759250
2019-08-20 15:17:30 +04:00
Oleg Bondarev
ab426a791a Use secure sha256 instead of sha1
Fix for bandit B303: Use of insecure MD2, MD4, MD5, or SHA1 hash function.

Change-Id: I00403d7bd3b40ae00420e6cddcf40f45488284a9
Partial-Bug: #1759250
2019-08-13 18:12:19 +04:00
9 changed files with 29 additions and 13 deletions

View File

@@ -2,3 +2,4 @@
host=review.opendev.org
port=29418
project=openstack/python-neutronclient.git
defaultbranch=stable/train

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

@@ -183,9 +183,9 @@ def http_log_req(_logger, args, kwargs):
for (key, value) in six.iteritems(kwargs['headers']):
if key in SENSITIVE_HEADERS:
v = value.encode('utf-8')
h = hashlib.sha1(v)
h = hashlib.sha256(v)
d = h.hexdigest()
value = "{SHA1}%s" % d
value = "{SHA256}%s" % d
header = ' -H "%s: %s"' % (key, value)
string_parts.append(header)

View File

@@ -222,7 +222,7 @@ class NeutronShell(app.App):
type=check_non_negative_int,
default=0,
help=_("How many times the request to the Neutron server should "
"be retried if it fails."))
"be retried if it fails. Defaults to 0."))
# FIXME(bklei): this method should come from keystoneauth1
self._append_global_identity_args(parser)
@@ -241,12 +241,12 @@ class NeutronShell(app.App):
parser.add_argument(
'--os-service-type', metavar='<os-service-type>',
default=env('OS_NETWORK_SERVICE_TYPE', default='network'),
help=_('Defaults to env[OS_NETWORK_SERVICE_TYPE] or network.'))
help=_('Defaults to env[OS_NETWORK_SERVICE_TYPE] or "network".'))
parser.add_argument(
'--os-endpoint-type', metavar='<os-endpoint-type>',
default=env('OS_ENDPOINT_TYPE', default='public'),
help=_('Defaults to env[OS_ENDPOINT_TYPE] or public.'))
help=_('Defaults to env[OS_ENDPOINT_TYPE] or "public".'))
# FIXME(bklei): --service-type is deprecated but kept in for
# backward compatibility.

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

@@ -934,6 +934,16 @@ class Client(ClientBase):
return self.put((self.router_path % router) +
"/remove_router_interface", body=body)
def add_extra_routes_to_router(self, router, body=None):
"""Adds extra routes to the specified router."""
return self.put((self.router_path % router) + "/add_extraroutes",
body=body)
def remove_extra_routes_from_router(self, router, body=None):
"""Removes extra routes from the specified router."""
return self.put((self.router_path % router) + "/remove_extraroutes",
body=body)
def add_gateway_router(self, router, body=None):
"""Adds an external network gateway to the specified router."""
return self.put((self.router_path % router),

View File

@@ -0,0 +1,5 @@
---
features:
- |
New client methods: ``add_extra_routes_to_router`` and
``remove_extra_routes_from_router``.

View File

@@ -12,7 +12,7 @@ setenv = VIRTUAL_ENV={envdir}
PYTHONWARNINGS=default::DeprecationWarning
usedevelop = True
install_command = pip install {opts} {packages}
deps = -c{env:UPPER_CONSTRAINTS_FILE:https://opendev.org/openstack/requirements/raw/branch/master/upper-constraints.txt}
deps = -c{env:UPPER_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/train}
-r{toxinidir}/requirements.txt
-r{toxinidir}/test-requirements.txt
# Delete bytecodes from normal directories before running tests.