Fix the hacking errors present since neutron-lib 3.21.1
This new neutron-lib 3.21.1 version includes several new hacking checks. Because the eventlet removal is not finished, the N535 is skipped. Signed-off-by: Rodolfo Alonso Hernandez <ralonsoh@redhat.com> Change-Id: Iaad3e87874838eb75d2f6789e71030eda8c587a0
This commit is contained in:
committed by
Rodolfo Alonso
parent
17b3e7b5b0
commit
80df3666e3
@@ -18,6 +18,7 @@ import math
|
||||
import time
|
||||
|
||||
import netaddr
|
||||
from neutron_lib._i18n import _
|
||||
from neutron_lib import constants as const
|
||||
from oslo_log import log
|
||||
from tempest.common import utils as tutils
|
||||
@@ -492,7 +493,7 @@ class BaseNetworkTest(test.BaseTestCase):
|
||||
if ip_version:
|
||||
if ip_version != gateway_ip.version:
|
||||
raise ValueError(
|
||||
"Gateway IP version doesn't match IP version")
|
||||
_("Gateway IP version doesn't match IP version"))
|
||||
else:
|
||||
ip_version = gateway_ip.version
|
||||
else:
|
||||
@@ -541,8 +542,8 @@ class BaseNetworkTest(test.BaseTestCase):
|
||||
"""
|
||||
|
||||
if not cls.try_reserve_subnet_cidr(addr, **ipnetwork_kwargs):
|
||||
raise ValueError('Subnet CIDR already reserved: {0!r}'.format(
|
||||
addr))
|
||||
raise ValueError(_('Subnet CIDR already reserved: {0!r}'.format(
|
||||
addr)))
|
||||
|
||||
@classmethod
|
||||
def try_reserve_subnet_cidr(cls, addr, **ipnetwork_kwargs):
|
||||
@@ -601,7 +602,8 @@ class BaseNetworkTest(test.BaseTestCase):
|
||||
mask_bits = CONF.network.project_network_v6_mask_bits
|
||||
cidr = netaddr.IPNetwork(CONF.network.project_network_v6_cidr)
|
||||
else:
|
||||
raise ValueError('Invalid IP version: {!r}'.format(ip_version))
|
||||
raise ValueError(_(
|
||||
'Invalid IP version: {!r}'.format(ip_version)))
|
||||
|
||||
if mask_bits:
|
||||
subnet_cidrs = cidr.subnet(mask_bits)
|
||||
@@ -687,8 +689,9 @@ class BaseNetworkTest(test.BaseTestCase):
|
||||
if port:
|
||||
port_id = kwargs.setdefault('port_id', port['id'])
|
||||
if port_id != port['id']:
|
||||
message = "Port ID specified twice: {!s} != {!s}".format(
|
||||
port_id, port['id'])
|
||||
message = _(
|
||||
"Port ID specified twice: {!s} != {!s}".format(
|
||||
port_id, port['id']))
|
||||
raise ValueError(message)
|
||||
|
||||
fip = client.create_floatingip(external_network_id,
|
||||
@@ -985,7 +988,7 @@ class BaseNetworkTest(test.BaseTestCase):
|
||||
project_id = kwargs.setdefault('project_id', project['id'])
|
||||
tenant_id = kwargs.setdefault('tenant_id', project['id'])
|
||||
if project_id != project['id'] or tenant_id != project['id']:
|
||||
raise ValueError('Project ID specified multiple times')
|
||||
raise ValueError(_('Project ID specified multiple times'))
|
||||
else:
|
||||
client = client or cls.client
|
||||
|
||||
@@ -1008,7 +1011,7 @@ class BaseNetworkTest(test.BaseTestCase):
|
||||
for security_group in security_groups:
|
||||
if security_group['name'] == name:
|
||||
return security_group
|
||||
raise ValueError("No such security group named {!r}".format(name))
|
||||
raise ValueError(_("No such security group named {!r}".format(name)))
|
||||
|
||||
@classmethod
|
||||
def create_security_group_rule(cls, security_group=None, project=None,
|
||||
@@ -1018,7 +1021,7 @@ class BaseNetworkTest(test.BaseTestCase):
|
||||
project_id = kwargs.setdefault('project_id', project['id'])
|
||||
tenant_id = kwargs.setdefault('tenant_id', project['id'])
|
||||
if project_id != project['id'] or tenant_id != project['id']:
|
||||
raise ValueError('Project ID specified multiple times')
|
||||
raise ValueError(_('Project ID specified multiple times'))
|
||||
|
||||
if 'security_group_id' not in kwargs:
|
||||
security_group = (security_group or
|
||||
@@ -1029,7 +1032,8 @@ class BaseNetworkTest(test.BaseTestCase):
|
||||
security_group_id = kwargs.setdefault('security_group_id',
|
||||
security_group['id'])
|
||||
if security_group_id != security_group['id']:
|
||||
raise ValueError('Security group ID specified multiple times.')
|
||||
raise ValueError(
|
||||
_('Security group ID specified multiple times.'))
|
||||
|
||||
ip_version = ip_version or cls._ip_version
|
||||
default_params = (
|
||||
|
||||
@@ -17,6 +17,7 @@ import os
|
||||
import random
|
||||
|
||||
import netaddr
|
||||
from neutron_lib._i18n import _
|
||||
from neutron_lib.utils import test
|
||||
from oslo_concurrency import lockutils
|
||||
from oslo_log import log as logging
|
||||
@@ -42,8 +43,8 @@ NET_C = 'C'
|
||||
if "SUBNETPOOL_PREFIX_V4" in os.environ:
|
||||
subnet_base = netaddr.IPNetwork(os.environ['SUBNETPOOL_PREFIX_V4'])
|
||||
if subnet_base.prefixlen > 21:
|
||||
raise Exception("if SUBNETPOOL_PREFIX_V4 is set, it needs to offer "
|
||||
"space for at least 8 /24 subnets")
|
||||
raise Exception(_("if SUBNETPOOL_PREFIX_V4 is set, it needs to offer "
|
||||
"space for at least 8 /24 subnets"))
|
||||
else:
|
||||
subnet_base = netaddr.IPNetwork("10.100.0.0/16")
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ import re
|
||||
import subprocess
|
||||
|
||||
import netaddr
|
||||
from neutron_lib._i18n import _
|
||||
from neutron_lib import constants
|
||||
from oslo_log import log
|
||||
from oslo_utils import excutils
|
||||
@@ -89,9 +90,9 @@ class IPCommand(object):
|
||||
for ip, prefix_len in _get_ip_address_prefix_len_pairs(
|
||||
port=subport, subnets=subnets)]
|
||||
if not subport_ips:
|
||||
raise ValueError(
|
||||
raise ValueError(_(
|
||||
"Unable to get IP address and subnet prefix lengths for "
|
||||
"subport")
|
||||
"subport"))
|
||||
|
||||
return self.configure_vlan(addresses, port, vlan_tag, subport_ips,
|
||||
subport['mac_address'])
|
||||
@@ -353,7 +354,7 @@ def get_port_device_name(addresses, port):
|
||||
for address in list_ip_addresses(addresses=addresses, port=port):
|
||||
return address.device.name
|
||||
|
||||
msg = "Port {0!r} fixed IPs not found on server.".format(port['id'])
|
||||
msg = _("Port {0!r} fixed IPs not found on server.".format(port['id']))
|
||||
raise ValueError(msg)
|
||||
|
||||
|
||||
@@ -362,7 +363,8 @@ def get_vlan_device_name(addresses, ip_addresses):
|
||||
ip_addresses=ip_addresses):
|
||||
return address.device.name
|
||||
|
||||
msg = "Fixed IPs {0!r} not found on server.".format(' '.join(ip_addresses))
|
||||
msg = _(
|
||||
"Fixed IPs {0!r} not found on server.".format(' '.join(ip_addresses)))
|
||||
raise ValueError(msg)
|
||||
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ import os
|
||||
import socket
|
||||
import time
|
||||
|
||||
from neutron_lib._i18n import _
|
||||
from oslo_log import log
|
||||
import paramiko
|
||||
from tempest.lib.common import ssh
|
||||
@@ -70,8 +71,8 @@ class Client(ssh.Client):
|
||||
host = cls.proxy_jump_host
|
||||
if not host:
|
||||
# proxy_jump_host string cannot be empty or None
|
||||
raise ValueError(
|
||||
"'proxy_jump_host' configuration option is empty.")
|
||||
raise ValueError(_(
|
||||
"'proxy_jump_host' configuration option is empty."))
|
||||
|
||||
# Let accept an empty string as a synonymous of default value on below
|
||||
# options
|
||||
@@ -82,9 +83,9 @@ class Client(ssh.Client):
|
||||
# Port must be a positive integer
|
||||
port = cls.proxy_jump_port
|
||||
if port <= 0 or port > 65535:
|
||||
raise ValueError(
|
||||
raise ValueError(_(
|
||||
"Invalid value for 'proxy_jump_port' configuration option: "
|
||||
"{!r}".format(port))
|
||||
"{!r}".format(port)))
|
||||
|
||||
login = "{username}@{host}:{port}".format(username=username, host=host,
|
||||
port=port)
|
||||
@@ -99,9 +100,9 @@ class Client(ssh.Client):
|
||||
else:
|
||||
# This message could help the user to identify a
|
||||
# mis-configuration in tempest.conf
|
||||
raise ValueError(
|
||||
raise ValueError(_(
|
||||
"Cannot find file specified as 'proxy_jump_keyfile' "
|
||||
"option: {!r}".format(key_file))
|
||||
"option: {!r}".format(key_file)))
|
||||
|
||||
elif password:
|
||||
LOG.debug("Going to create SSH connection to %r using password.",
|
||||
|
||||
@@ -26,7 +26,7 @@ except ImportError:
|
||||
from urllib import parse as urlparse
|
||||
|
||||
import eventlet
|
||||
|
||||
from neutron_lib._i18n import _
|
||||
from oslo_log import log
|
||||
from tempest.lib import exceptions
|
||||
|
||||
@@ -87,7 +87,7 @@ def wait_until_true(predicate, timeout=60, sleep=1, exception=None):
|
||||
if exception is not None:
|
||||
# pylint: disable=raising-bad-type
|
||||
raise exception
|
||||
raise WaitTimeout("Timed out after %d seconds" % timeout)
|
||||
raise WaitTimeout(_("Timed out after %d seconds" % timeout))
|
||||
|
||||
|
||||
def override_class(overriden_class, overrider_class):
|
||||
|
||||
@@ -18,6 +18,7 @@ import subprocess
|
||||
|
||||
from debtcollector import removals
|
||||
import netaddr
|
||||
from neutron_lib._i18n import _
|
||||
from neutron_lib.api import validators
|
||||
from neutron_lib import constants as neutron_lib_constants
|
||||
from oslo_log import log
|
||||
@@ -680,8 +681,8 @@ class BaseTempestTestCase(base_api.BaseNetworkTest):
|
||||
router = client.update_router(router['id'], **kwargs)['router']
|
||||
return router
|
||||
else:
|
||||
raise Exception("Neither of 'public_router_id' or "
|
||||
"'public_network_id' has been defined.")
|
||||
raise Exception(_("Neither of 'public_router_id' or "
|
||||
"'public_network_id' has been defined."))
|
||||
|
||||
def _update_router_admin_state(self, router, admin_state_up):
|
||||
kwargs = dict(admin_state_up=admin_state_up)
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
# 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 json
|
||||
|
||||
import os
|
||||
import subprocess
|
||||
import time
|
||||
@@ -29,6 +29,7 @@ from neutron_tempest_plugin.scenario import base
|
||||
from neutron_lib import constants as const
|
||||
|
||||
from oslo_log import log
|
||||
from oslo_serialization import jsonutils
|
||||
|
||||
from os_ken.tests.integrated.common import docker_base as ctn_base
|
||||
|
||||
@@ -288,7 +289,7 @@ class BFDContainer(FRRContainer):
|
||||
)
|
||||
|
||||
def show_bfd_peer(self, peer: str) -> typing.Dict[str, typing.Any]:
|
||||
return json.loads(self.vtysh([f'show bfd peer {peer} json']))
|
||||
return jsonutils.loads(self.vtysh([f'show bfd peer {peer} json']))
|
||||
|
||||
def wait_for_bfd_peer_status(
|
||||
self, peer: str, status: str, try_times=30, interval=1
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
import time
|
||||
from urllib import parse as urlparse
|
||||
|
||||
from neutron_lib._i18n import _
|
||||
from oslo_serialization import jsonutils
|
||||
from tempest.lib.common import rest_client as service_client
|
||||
from tempest.lib import exceptions as lib_exc
|
||||
@@ -304,7 +305,7 @@ class NetworkClientJSON(service_client.RestClient):
|
||||
try:
|
||||
getattr(self, method)(id)
|
||||
except AttributeError:
|
||||
raise Exception("Unknown resource type %s " % resource_type)
|
||||
raise Exception(_("Unknown resource type %s " % resource_type))
|
||||
except lib_exc.NotFound:
|
||||
return True
|
||||
return False
|
||||
|
||||
3
tox.ini
3
tox.ini
@@ -62,8 +62,9 @@ commands = oslo_debug_helper -t neutron_tempest_plugin/ {posargs}
|
||||
# E129 visually indented line with same indent as next logical line
|
||||
# I202 Additional newline in a group of imports.
|
||||
# N530 direct neutron imports not allowed
|
||||
# N535 prevent eventlet library import
|
||||
# W504 line break after binary operator
|
||||
ignore = E126,E128,E129,I202,N530,W504
|
||||
ignore = E126,E128,E129,I202,N530,N535,W504
|
||||
# H106: Don't put vim configuration in source files
|
||||
# H203: Use assertIs(Not)None to check for None
|
||||
# H204: Use assert(Not)Equal to check for equality
|
||||
|
||||
Reference in New Issue
Block a user