hacking: Resolve W605 (invalid escape sequence)
This one's actually important since it will be an error in future versions of Python. Change-Id: Ib9f735216773224f91ac7f49fbe2eee119670872 Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
This commit is contained in:
parent
97b769ef53
commit
dc6fc82c14
|
@ -232,7 +232,7 @@ def ec2_vol_id_to_uuid(ec2_id):
|
||||||
return get_volume_uuid_from_int_id(ctxt, int_id)
|
return get_volume_uuid_from_int_id(ctxt, int_id)
|
||||||
|
|
||||||
|
|
||||||
_ms_time_regex = re.compile('^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3,6}Z$')
|
_ms_time_regex = re.compile(r'^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3,6}Z$')
|
||||||
|
|
||||||
|
|
||||||
def status_to_ec2_attach_status(volume):
|
def status_to_ec2_attach_status(volume):
|
||||||
|
@ -462,4 +462,4 @@ def regex_from_ec2_regex(ec2_re):
|
||||||
py_re += '\\\\' + next_char
|
py_re += '\\\\' + next_char
|
||||||
else:
|
else:
|
||||||
py_re += re.escape(char)
|
py_re += re.escape(char)
|
||||||
return '\A%s\Z(?s)' % py_re
|
return r'(?s)\A%s\Z' % py_re
|
||||||
|
|
|
@ -166,7 +166,7 @@ class ProjectMapper(APIMapper):
|
||||||
# NOTE(sdague): project_id parameter is only valid if its hex
|
# NOTE(sdague): project_id parameter is only valid if its hex
|
||||||
# or hex + dashes (note, integers are a subset of this). This
|
# or hex + dashes (note, integers are a subset of this). This
|
||||||
# is required to hand our overlaping routes issues.
|
# is required to hand our overlaping routes issues.
|
||||||
project_id_regex = '[0-9a-f\-]+'
|
project_id_regex = '[0-9a-f-]+'
|
||||||
if CONF.osapi_v21.project_id_regex:
|
if CONF.osapi_v21.project_id_regex:
|
||||||
project_id_regex = CONF.osapi_v21.project_id_regex
|
project_id_regex = CONF.osapi_v21.project_id_regex
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,7 @@ create = {
|
||||||
# positive ( > 0) float
|
# positive ( > 0) float
|
||||||
'rxtx_factor': {
|
'rxtx_factor': {
|
||||||
'type': ['number', 'string'],
|
'type': ['number', 'string'],
|
||||||
'pattern': '^[0-9]+(\.[0-9]+)?$',
|
'pattern': r'^[0-9]+(\.[0-9]+)?$',
|
||||||
'minimum': 0, 'exclusiveMinimum': True,
|
'minimum': 0, 'exclusiveMinimum': True,
|
||||||
# maximum's value is limited to db constant's
|
# maximum's value is limited to db constant's
|
||||||
# SQL_SP_FLOAT_MAX (in nova/db/constants.py)
|
# SQL_SP_FLOAT_MAX (in nova/db/constants.py)
|
||||||
|
|
|
@ -136,7 +136,7 @@ _hints = {
|
||||||
'build_near_host_ip': parameter_types.ip_address,
|
'build_near_host_ip': parameter_types.ip_address,
|
||||||
'cidr': {
|
'cidr': {
|
||||||
'type': 'string',
|
'type': 'string',
|
||||||
'pattern': '^\/[0-9a-f.:]+$'
|
'pattern': '^/[0-9a-f.:]+$'
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
# NOTE: As this Mail:
|
# NOTE: As this Mail:
|
||||||
|
|
|
@ -75,7 +75,7 @@ def _validate_cidr_format(cidr):
|
||||||
return False
|
return False
|
||||||
if '/' not in cidr:
|
if '/' not in cidr:
|
||||||
return False
|
return False
|
||||||
if re.search('\s', cidr):
|
if re.search(r'\s', cidr):
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
|
@ -419,7 +419,7 @@ def validate_and_default_volume_size(bdm):
|
||||||
details=_("Invalid volume_size."))
|
details=_("Invalid volume_size."))
|
||||||
|
|
||||||
|
|
||||||
_ephemeral = re.compile('^ephemeral(\d|[1-9]\d+)$')
|
_ephemeral = re.compile(r'^ephemeral(\d|[1-9]\d+)$')
|
||||||
|
|
||||||
|
|
||||||
def is_ephemeral(device_name):
|
def is_ephemeral(device_name):
|
||||||
|
@ -499,7 +499,7 @@ def strip_prefix(device_name):
|
||||||
return _pref.sub('', device_name) if device_name else device_name
|
return _pref.sub('', device_name) if device_name else device_name
|
||||||
|
|
||||||
|
|
||||||
_nums = re.compile('\d+')
|
_nums = re.compile(r'\d+')
|
||||||
|
|
||||||
|
|
||||||
def get_device_letter(device_name):
|
def get_device_letter(device_name):
|
||||||
|
|
|
@ -149,7 +149,7 @@ Possible values:
|
||||||
"""),
|
"""),
|
||||||
cfg.StrOpt('qemu_img_cmd',
|
cfg.StrOpt('qemu_img_cmd',
|
||||||
default="qemu-img.exe",
|
default="qemu-img.exe",
|
||||||
help="""
|
help=r"""
|
||||||
qemu-img command
|
qemu-img command
|
||||||
|
|
||||||
qemu-img is required for some of the image related operations
|
qemu-img is required for some of the image related operations
|
||||||
|
|
|
@ -36,7 +36,7 @@ This service is typically executed on the controller node.
|
||||||
cfg.StrOpt('port_range',
|
cfg.StrOpt('port_range',
|
||||||
default=DEFAULT_PORT_RANGE,
|
default=DEFAULT_PORT_RANGE,
|
||||||
regex=r'^\d+:\d+$',
|
regex=r'^\d+:\d+$',
|
||||||
help="""
|
help=r"""
|
||||||
A range of TCP ports a guest can use for its backend.
|
A range of TCP ports a guest can use for its backend.
|
||||||
|
|
||||||
Each instance which gets created will use one port out of this range. If the
|
Each instance which gets created will use one port out of this range. If the
|
||||||
|
@ -45,9 +45,9 @@ instance won't get launched.
|
||||||
|
|
||||||
Possible values:
|
Possible values:
|
||||||
|
|
||||||
* Each string which passes the regex ``^\d+:\d+$`` For example ``10000:20000``.
|
* Each string which passes the regex ``^\d+:\d+$`` For example
|
||||||
Be sure that the first port number is lower than the second port number
|
``10000:20000``. Be sure that the first port number is lower than the second
|
||||||
and that both are in range from 0 to 65535.
|
port number and that both are in range from 0 to 65535.
|
||||||
"""),
|
"""),
|
||||||
# TODO(macsz) check if WS protocol is still being used
|
# TODO(macsz) check if WS protocol is still being used
|
||||||
cfg.URIOpt('base_url',
|
cfg.URIOpt('base_url',
|
||||||
|
|
|
@ -48,10 +48,10 @@ virt_config_re = re.compile(
|
||||||
r"CONF\.import_opt\('.*?', 'nova\.virt\.(\w+)('|.)")
|
r"CONF\.import_opt\('.*?', 'nova\.virt\.(\w+)('|.)")
|
||||||
asse_trueinst_re = re.compile(
|
asse_trueinst_re = re.compile(
|
||||||
r"(.)*assertTrue\(isinstance\((\w|\.|\'|\"|\[|\])+, "
|
r"(.)*assertTrue\(isinstance\((\w|\.|\'|\"|\[|\])+, "
|
||||||
"(\w|\.|\'|\"|\[|\])+\)\)")
|
r"(\w|\.|\'|\"|\[|\])+\)\)")
|
||||||
asse_equal_type_re = re.compile(
|
asse_equal_type_re = re.compile(
|
||||||
r"(.)*assertEqual\(type\((\w|\.|\'|\"|\[|\])+\), "
|
r"(.)*assertEqual\(type\((\w|\.|\'|\"|\[|\])+\), "
|
||||||
"(\w|\.|\'|\"|\[|\])+\)")
|
r"(\w|\.|\'|\"|\[|\])+\)")
|
||||||
asse_equal_in_end_with_true_or_false_re = re.compile(r"assertEqual\("
|
asse_equal_in_end_with_true_or_false_re = re.compile(r"assertEqual\("
|
||||||
r"(\w|[][.'\"])+ in (\w|[][.'\", ])+, (True|False)\)")
|
r"(\w|[][.'\"])+ in (\w|[][.'\", ])+, (True|False)\)")
|
||||||
asse_equal_in_start_with_true_or_false_re = re.compile(r"assertEqual\("
|
asse_equal_in_start_with_true_or_false_re = re.compile(r"assertEqual\("
|
||||||
|
@ -76,7 +76,7 @@ asse_raises_regexp = re.compile(r"assertRaisesRegexp\(")
|
||||||
conf_attribute_set_re = re.compile(r"CONF\.[a-z0-9_.]+\s*=\s*\w")
|
conf_attribute_set_re = re.compile(r"CONF\.[a-z0-9_.]+\s*=\s*\w")
|
||||||
translated_log = re.compile(
|
translated_log = re.compile(
|
||||||
r"(.)*LOG\.(audit|error|info|critical|exception)"
|
r"(.)*LOG\.(audit|error|info|critical|exception)"
|
||||||
"\(\s*_\(\s*('|\")")
|
r"\(\s*_\(\s*('|\")")
|
||||||
mutable_default_args = re.compile(r"^\s*def .+\((.+=\{\}|.+=\[\])")
|
mutable_default_args = re.compile(r"^\s*def .+\((.+=\{\}|.+=\[\])")
|
||||||
string_translation = re.compile(r"[^_]*_\(\s*('|\")")
|
string_translation = re.compile(r"[^_]*_\(\s*('|\")")
|
||||||
underscore_import_check = re.compile(r"(.)*import _(.)*")
|
underscore_import_check = re.compile(r"(.)*import _(.)*")
|
||||||
|
|
|
@ -690,7 +690,7 @@ def ensure_vpn_forward(public_ip, port, private_ip):
|
||||||
def ensure_floating_forward(floating_ip, fixed_ip, device, network):
|
def ensure_floating_forward(floating_ip, fixed_ip, device, network):
|
||||||
"""Ensure floating IP forwarding rule."""
|
"""Ensure floating IP forwarding rule."""
|
||||||
# NOTE(vish): Make sure we never have duplicate rules for the same ip
|
# NOTE(vish): Make sure we never have duplicate rules for the same ip
|
||||||
regex = '.*\s+%s(/32|\s+|$)' % floating_ip
|
regex = r'.*\s+%s(/32|\s+|$)' % floating_ip
|
||||||
num_rules = iptables_manager.ipv4['nat'].remove_rules_regex(regex)
|
num_rules = iptables_manager.ipv4['nat'].remove_rules_regex(regex)
|
||||||
if num_rules:
|
if num_rules:
|
||||||
LOG.warning('Removed %(num)d duplicate rules for floating IP '
|
LOG.warning('Removed %(num)d duplicate rules for floating IP '
|
||||||
|
|
|
@ -70,7 +70,7 @@ def get_my_linklocal(interface):
|
||||||
try:
|
try:
|
||||||
if_str = processutils.execute(
|
if_str = processutils.execute(
|
||||||
'ip', '-f', 'inet6', '-o', 'addr', 'show', interface)
|
'ip', '-f', 'inet6', '-o', 'addr', 'show', interface)
|
||||||
condition = '\s+inet6\s+([0-9a-f:]+)/\d+\s+scope\s+link'
|
condition = r'\s+inet6\s+([0-9a-f:]+)/\d+\s+scope\s+link'
|
||||||
links = [re.search(condition, x) for x in if_str[0].split('\n')]
|
links = [re.search(condition, x) for x in if_str[0].split('\n')]
|
||||||
address = [w.group(1) for w in links if w is not None]
|
address = [w.group(1) for w in links if w is not None]
|
||||||
if address[0] is not None:
|
if address[0] is not None:
|
||||||
|
|
|
@ -26,9 +26,9 @@ from nova import exception
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
PCI_VENDOR_PATTERN = "^(hex{4})$".replace("hex", "[\da-fA-F]")
|
PCI_VENDOR_PATTERN = "^(hex{4})$".replace("hex", r"[\da-fA-F]")
|
||||||
_PCI_ADDRESS_PATTERN = ("^(hex{4}):(hex{2}):(hex{2}).(oct{1})$".
|
_PCI_ADDRESS_PATTERN = ("^(hex{4}):(hex{2}):(hex{2}).(oct{1})$".
|
||||||
replace("hex", "[\da-fA-F]").
|
replace("hex", r"[\da-fA-F]").
|
||||||
replace("oct", "[0-7]"))
|
replace("oct", "[0-7]"))
|
||||||
_PCI_ADDRESS_REGEX = re.compile(_PCI_ADDRESS_PATTERN)
|
_PCI_ADDRESS_REGEX = re.compile(_PCI_ADDRESS_PATTERN)
|
||||||
|
|
||||||
|
@ -186,7 +186,7 @@ def get_vf_num_by_pci_address(pci_addr):
|
||||||
A VF is associated with an VF number, which ip link command uses to
|
A VF is associated with an VF number, which ip link command uses to
|
||||||
configure it. This number can be obtained from the PCI device filesystem.
|
configure it. This number can be obtained from the PCI device filesystem.
|
||||||
"""
|
"""
|
||||||
VIRTFN_RE = re.compile("virtfn(\d+)")
|
VIRTFN_RE = re.compile(r"virtfn(\d+)")
|
||||||
virtfns_path = "/sys/bus/pci/devices/%s/physfn/virtfn*" % (pci_addr)
|
virtfns_path = "/sys/bus/pci/devices/%s/physfn/virtfn*" % (pci_addr)
|
||||||
vf_num = None
|
vf_num = None
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -870,7 +870,7 @@ class WarningsFixture(fixtures.Fixture):
|
||||||
# TODO(mriedem): Change (or remove) this DeprecationWarning once
|
# TODO(mriedem): Change (or remove) this DeprecationWarning once
|
||||||
# https://bugs.launchpad.net/sqlalchemy-migrate/+bug/1814288 is fixed.
|
# https://bugs.launchpad.net/sqlalchemy-migrate/+bug/1814288 is fixed.
|
||||||
warnings.filterwarnings(
|
warnings.filterwarnings(
|
||||||
'ignore', message='inspect\.getargspec\(\) is deprecated',
|
'ignore', message='inspect.getargspec() is deprecated',
|
||||||
category=DeprecationWarning,
|
category=DeprecationWarning,
|
||||||
module='migrate.versioning.script.py')
|
module='migrate.versioning.script.py')
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ class AggregatesSampleJsonTest(api_sample_base.ApiSampleTestBaseV21):
|
||||||
|
|
||||||
def _test_aggregate_create(self):
|
def _test_aggregate_create(self):
|
||||||
subs = {
|
subs = {
|
||||||
"aggregate_id": '(?P<id>\d+)'
|
"aggregate_id": r'(?P<id>\d+)'
|
||||||
}
|
}
|
||||||
response = self._do_post('os-aggregates', 'aggregate-post-req', subs)
|
response = self._do_post('os-aggregates', 'aggregate-post-req', subs)
|
||||||
return self._verify_response('aggregate-post-resp',
|
return self._verify_response('aggregate-post-resp',
|
||||||
|
@ -102,7 +102,7 @@ class AggregatesV2_41_SampleJsonTest(AggregatesSampleJsonTest):
|
||||||
|
|
||||||
def _test_aggregate_create(self):
|
def _test_aggregate_create(self):
|
||||||
subs = {
|
subs = {
|
||||||
"aggregate_id": '(?P<id>\d+)',
|
"aggregate_id": r'(?P<id>\d+)',
|
||||||
}
|
}
|
||||||
response = self._do_post('os-aggregates', 'aggregate-post-req', subs)
|
response = self._do_post('os-aggregates', 'aggregate-post-req', subs)
|
||||||
# This feels like cheating since we're getting the uuid from the
|
# This feels like cheating since we're getting the uuid from the
|
||||||
|
|
|
@ -34,7 +34,7 @@ class ConsolesSampleJsonTests(test_servers.ServersSampleBase):
|
||||||
'get-vnc-console-post-req',
|
'get-vnc-console-post-req',
|
||||||
{'action': 'os-getVNCConsole'})
|
{'action': 'os-getVNCConsole'})
|
||||||
subs = {"url":
|
subs = {"url":
|
||||||
"((https?):((//)|(\\\\))+([\w\d:#@%/;$()~_?\+-=\\\.&](#!)?)*)"}
|
"((https?):((//)|(\\\\))+([\\w\\d:#@%/;$()~_?\\+-=\\\\.&](#!)?)*)"}
|
||||||
self._verify_response('get-vnc-console-post-resp', subs, response, 200)
|
self._verify_response('get-vnc-console-post-resp', subs, response, 200)
|
||||||
|
|
||||||
def test_get_spice_console(self):
|
def test_get_spice_console(self):
|
||||||
|
@ -43,7 +43,7 @@ class ConsolesSampleJsonTests(test_servers.ServersSampleBase):
|
||||||
'get-spice-console-post-req',
|
'get-spice-console-post-req',
|
||||||
{'action': 'os-getSPICEConsole'})
|
{'action': 'os-getSPICEConsole'})
|
||||||
subs = {"url":
|
subs = {"url":
|
||||||
"((https?):((//)|(\\\\))+([\w\d:#@%/;$()~_?\+-=\\\.&](#!)?)*)"}
|
"((https?):((//)|(\\\\))+([\\w\\d:#@%/;$()~_?\\+-=\\\\.&](#!)?)*)"}
|
||||||
self._verify_response('get-spice-console-post-resp', subs,
|
self._verify_response('get-spice-console-post-resp', subs,
|
||||||
response, 200)
|
response, 200)
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ class ConsolesSampleJsonTests(test_servers.ServersSampleBase):
|
||||||
'get-rdp-console-post-req',
|
'get-rdp-console-post-req',
|
||||||
{'action': 'os-getRDPConsole'})
|
{'action': 'os-getRDPConsole'})
|
||||||
subs = {"url":
|
subs = {"url":
|
||||||
"((https?):((//)|(\\\\))+([\w\d:#@%/;$()~_?\+-=\\\.&](#!)?)*)"}
|
"((https?):((//)|(\\\\))+([\\w\\d:#@%/;$()~_?\\+-=\\\\.&](#!)?)*)"}
|
||||||
self._verify_response('get-rdp-console-post-resp', subs,
|
self._verify_response('get-rdp-console-post-resp', subs,
|
||||||
response, 200)
|
response, 200)
|
||||||
|
|
||||||
|
@ -63,7 +63,7 @@ class ConsolesSampleJsonTests(test_servers.ServersSampleBase):
|
||||||
'get-serial-console-post-req',
|
'get-serial-console-post-req',
|
||||||
{'action': 'os-getSerialConsole'})
|
{'action': 'os-getSerialConsole'})
|
||||||
subs = {"url":
|
subs = {"url":
|
||||||
"((https?):((//)|(\\\\))+([\w\d:#@%/;$()~_?\+-=\\\.&](#!)?)*)"}
|
"((https?):((//)|(\\\\))+([\\w\\d:#@%/;$()~_?\\+-=\\\\.&](#!)?)*)"}
|
||||||
self._verify_response('get-serial-console-post-resp', subs,
|
self._verify_response('get-serial-console-post-resp', subs,
|
||||||
response, 200)
|
response, 200)
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ class ConsolesV26SampleJsonTests(test_servers.ServersSampleBase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(ConsolesV26SampleJsonTests, self).setUp()
|
super(ConsolesV26SampleJsonTests, self).setUp()
|
||||||
self.http_regex = "(https?://)([\w\d:#@%/;$()~_?\+-=\\\.&](#!)?)*"
|
self.http_regex = '(https?://)([\\w\\d:#@%/;$()~_?\\+-=\\\\.&](#!)?)*'
|
||||||
|
|
||||||
def test_create_console(self):
|
def test_create_console(self):
|
||||||
uuid = self._post_server()
|
uuid = self._post_server()
|
||||||
|
@ -97,7 +97,7 @@ class ConsolesV28SampleJsonTests(test_servers.ServersSampleBase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(ConsolesV28SampleJsonTests, self).setUp()
|
super(ConsolesV28SampleJsonTests, self).setUp()
|
||||||
self.http_regex = "(https?://)([\w\d:#@%/;$()~_?\+-=\\\.&](#!)?)*"
|
self.http_regex = '(https?://)([\\w\\d:#@%/;$()~_?\\+-=\\\\.&](#!)?)*'
|
||||||
self.flags(enabled=True, group='mks')
|
self.flags(enabled=True, group='mks')
|
||||||
|
|
||||||
def test_create_mks_console(self):
|
def test_create_mks_console(self):
|
||||||
|
|
|
@ -45,7 +45,7 @@ class RescueJsonTest(test_servers.ServersSampleBase):
|
||||||
subs['status'] = 'RESCUE'
|
subs['status'] = 'RESCUE'
|
||||||
subs['access_ip_v4'] = '1.2.3.4'
|
subs['access_ip_v4'] = '1.2.3.4'
|
||||||
subs['access_ip_v6'] = '80fe::'
|
subs['access_ip_v6'] = '80fe::'
|
||||||
subs['instance_name'] = 'instance-\d{8}'
|
subs['instance_name'] = r'instance-\d{8}'
|
||||||
subs['hypervisor_hostname'] = r'[\w\.\-]+'
|
subs['hypervisor_hostname'] = r'[\w\.\-]+'
|
||||||
subs['cdrive'] = '.*'
|
subs['cdrive'] = '.*'
|
||||||
self._verify_response('server-get-resp-rescue', subs, response, 200)
|
self._verify_response('server-get-resp-rescue', subs, response, 200)
|
||||||
|
@ -69,7 +69,7 @@ class RescueJsonTest(test_servers.ServersSampleBase):
|
||||||
subs['status'] = 'RESCUE'
|
subs['status'] = 'RESCUE'
|
||||||
subs['access_ip_v4'] = '1.2.3.4'
|
subs['access_ip_v4'] = '1.2.3.4'
|
||||||
subs['access_ip_v6'] = '80fe::'
|
subs['access_ip_v6'] = '80fe::'
|
||||||
subs['instance_name'] = 'instance-\d{8}'
|
subs['instance_name'] = r'instance-\d{8}'
|
||||||
subs['hypervisor_hostname'] = r'[\w\.\-]+'
|
subs['hypervisor_hostname'] = r'[\w\.\-]+'
|
||||||
subs['cdrive'] = '.*'
|
subs['cdrive'] = '.*'
|
||||||
self._verify_response('server-get-resp-rescue', subs, response, 200)
|
self._verify_response('server-get-resp-rescue', subs, response, 200)
|
||||||
|
@ -88,7 +88,7 @@ class RescueJsonTest(test_servers.ServersSampleBase):
|
||||||
subs['status'] = 'ACTIVE'
|
subs['status'] = 'ACTIVE'
|
||||||
subs['access_ip_v4'] = '1.2.3.4'
|
subs['access_ip_v4'] = '1.2.3.4'
|
||||||
subs['access_ip_v6'] = '80fe::'
|
subs['access_ip_v6'] = '80fe::'
|
||||||
subs['instance_name'] = 'instance-\d{8}'
|
subs['instance_name'] = r'instance-\d{8}'
|
||||||
subs['hypervisor_hostname'] = r'[\w\.\-]+'
|
subs['hypervisor_hostname'] = r'[\w\.\-]+'
|
||||||
subs['cdrive'] = '.*'
|
subs['cdrive'] = '.*'
|
||||||
self._verify_response('server-get-resp-unrescue', subs, response, 200)
|
self._verify_response('server-get-resp-unrescue', subs, response, 200)
|
||||||
|
|
|
@ -36,7 +36,7 @@ class ServerTagsJsonTest(test_servers.ServersSampleBase):
|
||||||
subs['access_ip_v4'] = '1.2.3.4'
|
subs['access_ip_v4'] = '1.2.3.4'
|
||||||
subs['access_ip_v6'] = '80fe::'
|
subs['access_ip_v6'] = '80fe::'
|
||||||
subs['hostname'] = r'[\w\.\-]+'
|
subs['hostname'] = r'[\w\.\-]+'
|
||||||
subs['instance_name'] = 'instance-\d{8}'
|
subs['instance_name'] = r'instance-\d{8}'
|
||||||
subs['hypervisor_hostname'] = r'[\w\.\-]+'
|
subs['hypervisor_hostname'] = r'[\w\.\-]+'
|
||||||
subs['cdrive'] = '.*'
|
subs['cdrive'] = '.*'
|
||||||
subs['user_data'] = (self.user_data if six.PY2
|
subs['user_data'] = (self.user_data if six.PY2
|
||||||
|
|
|
@ -118,7 +118,7 @@ class ServersSampleJsonTest(ServersSampleBase):
|
||||||
subs = {}
|
subs = {}
|
||||||
subs['hostid'] = '[a-f0-9]+'
|
subs['hostid'] = '[a-f0-9]+'
|
||||||
subs['id'] = uuid
|
subs['id'] = uuid
|
||||||
subs['instance_name'] = 'instance-\d{8}'
|
subs['instance_name'] = r'instance-\d{8}'
|
||||||
subs['hypervisor_hostname'] = r'[\w\.\-]+'
|
subs['hypervisor_hostname'] = r'[\w\.\-]+'
|
||||||
subs['hostname'] = r'[\w\.\-]+'
|
subs['hostname'] = r'[\w\.\-]+'
|
||||||
subs['mac_addr'] = '(?:[a-f0-9]{2}:){5}[a-f0-9]{2}'
|
subs['mac_addr'] = '(?:[a-f0-9]{2}:){5}[a-f0-9]{2}'
|
||||||
|
@ -145,7 +145,7 @@ class ServersSampleJsonTest(ServersSampleBase):
|
||||||
subs = {}
|
subs = {}
|
||||||
subs['hostid'] = '[a-f0-9]+'
|
subs['hostid'] = '[a-f0-9]+'
|
||||||
subs['id'] = uuid
|
subs['id'] = uuid
|
||||||
subs['instance_name'] = 'instance-\d{8}'
|
subs['instance_name'] = r'instance-\d{8}'
|
||||||
subs['hypervisor_hostname'] = r'[\w\.\-]+'
|
subs['hypervisor_hostname'] = r'[\w\.\-]+'
|
||||||
subs['hostname'] = r'[\w\.\-]+'
|
subs['hostname'] = r'[\w\.\-]+'
|
||||||
subs['mac_addr'] = '(?:[a-f0-9]{2}:){5}[a-f0-9]{2}'
|
subs['mac_addr'] = '(?:[a-f0-9]{2}:){5}[a-f0-9]{2}'
|
||||||
|
@ -261,7 +261,7 @@ class ServersSampleJson263Test(ServersSampleBase):
|
||||||
super(ServersSampleJson263Test, self).setUp()
|
super(ServersSampleJson263Test, self).setUp()
|
||||||
self.common_subs = {
|
self.common_subs = {
|
||||||
'hostid': '[a-f0-9]+',
|
'hostid': '[a-f0-9]+',
|
||||||
'instance_name': 'instance-\d{8}',
|
'instance_name': r'instance-\d{8}',
|
||||||
'hypervisor_hostname': r'[\w\.\-]+',
|
'hypervisor_hostname': r'[\w\.\-]+',
|
||||||
'hostname': r'[\w\.\-]+',
|
'hostname': r'[\w\.\-]+',
|
||||||
'access_ip_v4': '1.2.3.4',
|
'access_ip_v4': '1.2.3.4',
|
||||||
|
@ -330,7 +330,7 @@ class ServersSampleJson266Test(ServersSampleBase):
|
||||||
super(ServersSampleJson266Test, self).setUp()
|
super(ServersSampleJson266Test, self).setUp()
|
||||||
self.common_subs = {
|
self.common_subs = {
|
||||||
'hostid': '[a-f0-9]+',
|
'hostid': '[a-f0-9]+',
|
||||||
'instance_name': 'instance-\d{8}',
|
'instance_name': r'instance-\d{8}',
|
||||||
'hypervisor_hostname': r'[\w\.\-]+',
|
'hypervisor_hostname': r'[\w\.\-]+',
|
||||||
'hostname': r'[\w\.\-]+',
|
'hostname': r'[\w\.\-]+',
|
||||||
'access_ip_v4': '1.2.3.4',
|
'access_ip_v4': '1.2.3.4',
|
||||||
|
@ -430,7 +430,7 @@ class ServersSampleJson271Test(ServersSampleBase):
|
||||||
super(ServersSampleJson271Test, self).setUp()
|
super(ServersSampleJson271Test, self).setUp()
|
||||||
self.common_subs = {
|
self.common_subs = {
|
||||||
'hostid': '[a-f0-9]+',
|
'hostid': '[a-f0-9]+',
|
||||||
'instance_name': 'instance-\d{8}',
|
'instance_name': r'instance-\d{8}',
|
||||||
'hypervisor_hostname': r'[\w\.\-]+',
|
'hypervisor_hostname': r'[\w\.\-]+',
|
||||||
'hostname': r'[\w\.\-]+',
|
'hostname': r'[\w\.\-]+',
|
||||||
'access_ip_v4': '1.2.3.4',
|
'access_ip_v4': '1.2.3.4',
|
||||||
|
|
|
@ -337,7 +337,7 @@ class ApiSampleTestBase(integrated_helpers._IntegratedTestBase):
|
||||||
|
|
||||||
project_id_exp = '(%s|%s)' % (PROJECT_ID, self.project_id)
|
project_id_exp = '(%s|%s)' % (PROJECT_ID, self.project_id)
|
||||||
|
|
||||||
url_re = self._get_host() + "/v(2|2\.1)/" + project_id_exp
|
url_re = self._get_host() + r"/v(2|2\.1)/" + project_id_exp
|
||||||
new_url = self._get_host() + "/" + self.api_major_version
|
new_url = self._get_host() + "/" + self.api_major_version
|
||||||
if self._use_project_id:
|
if self._use_project_id:
|
||||||
new_url += "/" + self.project_id
|
new_url += "/" + self.project_id
|
||||||
|
@ -431,13 +431,13 @@ class ApiSampleTestBase(integrated_helpers._IntegratedTestBase):
|
||||||
|
|
||||||
def _get_regexes(self):
|
def _get_regexes(self):
|
||||||
text = r'(\\"|[^"])*'
|
text = r'(\\"|[^"])*'
|
||||||
isotime_re = '\d{4}-[0,1]\d-[0-3]\dT\d{2}:\d{2}:\d{2}Z'
|
isotime_re = r'\d{4}-[0,1]\d-[0-3]\dT\d{2}:\d{2}:\d{2}Z'
|
||||||
strtime_re = '\d{4}-[0,1]\d-[0-3]\dT\d{2}:\d{2}:\d{2}\.\d{6}'
|
strtime_re = r'\d{4}-[0,1]\d-[0-3]\dT\d{2}:\d{2}:\d{2}\.\d{6}'
|
||||||
strtime_url_re = ('\d{4}-[0,1]\d-[0-3]\d'
|
strtime_url_re = (r'\d{4}-[0,1]\d-[0-3]\d'
|
||||||
'\+\d{2}\%3A\d{2}\%3A\d{2}\.\d{6}')
|
r'\+\d{2}\%3A\d{2}\%3A\d{2}\.\d{6}')
|
||||||
xmltime_re = ('\d{4}-[0,1]\d-[0-3]\d '
|
xmltime_re = (r'\d{4}-[0,1]\d-[0-3]\d '
|
||||||
'\d{2}:\d{2}:\d{2}'
|
r'\d{2}:\d{2}:\d{2}'
|
||||||
'(\.\d{6})?(\+00:00)?')
|
r'(\.\d{6})?(\+00:00)?')
|
||||||
|
|
||||||
# NOTE(claudiub): the x509 keypairs are different from the
|
# NOTE(claudiub): the x509 keypairs are different from the
|
||||||
# ssh keypairs. For example, the x509 fingerprint has 40 bytes.
|
# ssh keypairs. For example, the x509 fingerprint has 40 bytes.
|
||||||
|
|
|
@ -869,7 +869,7 @@ class TestDBArchiveDeletedRows(integrated_helpers._IntegratedTestBase):
|
||||||
self.cli.archive_deleted_rows(verbose=True)
|
self.cli.archive_deleted_rows(verbose=True)
|
||||||
# Assert only one instance_group_member record was deleted.
|
# Assert only one instance_group_member record was deleted.
|
||||||
self.assertRegex(self.output.getvalue(),
|
self.assertRegex(self.output.getvalue(),
|
||||||
".*instance_group_member.*\| 1.*")
|
r".*instance_group_member.*\| 1.*")
|
||||||
# And that we still have one remaining group member.
|
# And that we still have one remaining group member.
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
1, len(self.api.get_server_group(group['id'])['members']))
|
1, len(self.api.get_server_group(group['id'])['members']))
|
||||||
|
|
|
@ -325,7 +325,7 @@ class SchedulerReportClientTests(SchedulerReportClientTestBase):
|
||||||
global_request_id=global_request_id)
|
global_request_id=global_request_id)
|
||||||
|
|
||||||
def test_get_provider_tree_with_nested_and_aggregates(self):
|
def test_get_provider_tree_with_nested_and_aggregates(self):
|
||||||
"""A more in-depth test of get_provider_tree_and_ensure_root with
|
r"""A more in-depth test of get_provider_tree_and_ensure_root with
|
||||||
nested and sharing resource providers.
|
nested and sharing resource providers.
|
||||||
|
|
||||||
ss1(DISK) ss2(DISK) ss3(DISK)
|
ss1(DISK) ss2(DISK) ss3(DISK)
|
||||||
|
@ -1013,7 +1013,7 @@ class SchedulerReportClientTests(SchedulerReportClientTestBase):
|
||||||
self.context, utils.ResourceRequest())
|
self.context, utils.ResourceRequest())
|
||||||
|
|
||||||
def _set_up_provider_tree(self):
|
def _set_up_provider_tree(self):
|
||||||
"""Create two compute nodes in placement ("this" one, and another one)
|
r"""Create two compute nodes in placement ("this" one, and another one)
|
||||||
and a storage provider sharing with both.
|
and a storage provider sharing with both.
|
||||||
|
|
||||||
+-----------------------+ +------------------------+
|
+-----------------------+ +------------------------+
|
||||||
|
|
|
@ -156,7 +156,7 @@ class ProviderTreeTests(integrated_helpers.ProviderUsageBaseTestCase):
|
||||||
|
|
||||||
def _update_provider_tree_multiple_providers(self, startup=False,
|
def _update_provider_tree_multiple_providers(self, startup=False,
|
||||||
do_reshape=False):
|
do_reshape=False):
|
||||||
"""Make update_provider_tree create multiple providers, including an
|
r"""Make update_provider_tree create multiple providers, including an
|
||||||
additional root as a sharing provider; and some descendants in the
|
additional root as a sharing provider; and some descendants in the
|
||||||
compute node's tree.
|
compute node's tree.
|
||||||
|
|
||||||
|
|
|
@ -1509,13 +1509,13 @@ class ServersControllerTest(ControllerTest):
|
||||||
cell_down_support=False, all_tenants=False):
|
cell_down_support=False, all_tenants=False):
|
||||||
self.assertIsNotNone(search_opts)
|
self.assertIsNotNone(search_opts)
|
||||||
self.assertIn('ip', search_opts)
|
self.assertIn('ip', search_opts)
|
||||||
self.assertEqual(search_opts['ip'], '10\..*')
|
self.assertEqual(search_opts['ip'], r'10\..*')
|
||||||
return objects.InstanceList(
|
return objects.InstanceList(
|
||||||
objects=[fakes.stub_instance_obj(100, uuid=uuids.fake)])
|
objects=[fakes.stub_instance_obj(100, uuid=uuids.fake)])
|
||||||
|
|
||||||
self.mock_get_all.side_effect = fake_get_all
|
self.mock_get_all.side_effect = fake_get_all
|
||||||
|
|
||||||
req = self.req('/fake/servers?ip=10\..*')
|
req = self.req(r'/fake/servers?ip=10\..*')
|
||||||
servers = self.controller.index(req)['servers']
|
servers = self.controller.index(req)['servers']
|
||||||
|
|
||||||
self.assertEqual(1, len(servers))
|
self.assertEqual(1, len(servers))
|
||||||
|
|
|
@ -9472,7 +9472,7 @@ class ComputeAPITestCase(BaseTestCase):
|
||||||
# ip ends up matching 2nd octet here.. so all 3 match ip
|
# ip ends up matching 2nd octet here.. so all 3 match ip
|
||||||
# but 'name' only matches one
|
# but 'name' only matches one
|
||||||
instances = self.compute_api.get_all(c,
|
instances = self.compute_api.get_all(c,
|
||||||
search_opts={'ip': '.*\.1', 'name': 'not.*'})
|
search_opts={'ip': r'.*\.1', 'name': 'not.*'})
|
||||||
self.assertEqual(len(instances), 1)
|
self.assertEqual(len(instances), 1)
|
||||||
self.assertEqual(instances[0]['uuid'], instance3['uuid'])
|
self.assertEqual(instances[0]['uuid'], instance3['uuid'])
|
||||||
|
|
||||||
|
@ -9480,19 +9480,19 @@ class ComputeAPITestCase(BaseTestCase):
|
||||||
# so instance 1 and 3.. but name should only match #1
|
# so instance 1 and 3.. but name should only match #1
|
||||||
# but 'name' only matches one
|
# but 'name' only matches one
|
||||||
instances = self.compute_api.get_all(c,
|
instances = self.compute_api.get_all(c,
|
||||||
search_opts={'ip': '.*\.1$', 'name': '^woo.*'})
|
search_opts={'ip': r'.*\.1$', 'name': '^woo.*'})
|
||||||
self.assertEqual(len(instances), 1)
|
self.assertEqual(len(instances), 1)
|
||||||
self.assertEqual(instances[0]['uuid'], instance1['uuid'])
|
self.assertEqual(instances[0]['uuid'], instance1['uuid'])
|
||||||
|
|
||||||
# same as above but no match on name (name matches instance1
|
# same as above but no match on name (name matches instance1
|
||||||
# but the ip query doesn't
|
# but the ip query doesn't
|
||||||
instances = self.compute_api.get_all(c,
|
instances = self.compute_api.get_all(c,
|
||||||
search_opts={'ip': '.*\.2$', 'name': '^woot.*'})
|
search_opts={'ip': r'.*\.2$', 'name': '^woot.*'})
|
||||||
self.assertEqual(len(instances), 0)
|
self.assertEqual(len(instances), 0)
|
||||||
|
|
||||||
# ip matches all 3... ipv6 matches #2+#3...name matches #3
|
# ip matches all 3... ipv6 matches #2+#3...name matches #3
|
||||||
instances = self.compute_api.get_all(c,
|
instances = self.compute_api.get_all(c,
|
||||||
search_opts={'ip': '.*\.1',
|
search_opts={'ip': r'.*\.1',
|
||||||
'name': 'not.*',
|
'name': 'not.*',
|
||||||
'ip6': '^.*12.*34.*'})
|
'ip6': '^.*12.*34.*'})
|
||||||
self.assertEqual(len(instances), 1)
|
self.assertEqual(len(instances), 1)
|
||||||
|
|
|
@ -46,7 +46,7 @@ class ConfFixture(config_fixture.Config):
|
||||||
# We should fix the tests to use real
|
# We should fix the tests to use real
|
||||||
# UUIDs then drop this work around.
|
# UUIDs then drop this work around.
|
||||||
self.conf.set_default('project_id_regex',
|
self.conf.set_default('project_id_regex',
|
||||||
'[0-9a-fk\-]+', 'osapi_v21')
|
'[0-9a-fk-]+', 'osapi_v21')
|
||||||
self.conf.set_default('use_ipv6', True)
|
self.conf.set_default('use_ipv6', True)
|
||||||
self.conf.set_default('vlan_interface', 'eth0')
|
self.conf.set_default('vlan_interface', 'eth0')
|
||||||
|
|
||||||
|
|
|
@ -60,9 +60,8 @@ class _TestNUMA(object):
|
||||||
numacell.pin_cpus(set([2, 3]))
|
numacell.pin_cpus(set([2, 3]))
|
||||||
self.assertEqual(set([4]), numacell.free_cpus)
|
self.assertEqual(set([4]), numacell.free_cpus)
|
||||||
|
|
||||||
expect_msg = (
|
expect_msg = exception.CPUPinningUnknown.msg_fmt % {
|
||||||
exception.CPUPinningUnknown.msg_fmt % {'requested': "\[1, 55\]",
|
'requested': r'\[1, 55\]', 'cpuset': r'\[1, 2, 3, 4\]'}
|
||||||
'cpuset': "\[1, 2, 3, 4\]"})
|
|
||||||
with testtools.ExpectedException(exception.CPUPinningUnknown,
|
with testtools.ExpectedException(exception.CPUPinningUnknown,
|
||||||
expect_msg):
|
expect_msg):
|
||||||
numacell.pin_cpus(set([1, 55]))
|
numacell.pin_cpus(set([1, 55]))
|
||||||
|
@ -70,8 +69,8 @@ class _TestNUMA(object):
|
||||||
self.assertRaises(exception.CPUPinningInvalid,
|
self.assertRaises(exception.CPUPinningInvalid,
|
||||||
numacell.pin_cpus, set([1, 4]))
|
numacell.pin_cpus, set([1, 4]))
|
||||||
|
|
||||||
expect_msg = (exception.CPUUnpinningUnknown.msg_fmt %
|
expect_msg = exception.CPUUnpinningUnknown.msg_fmt % {
|
||||||
{'requested': "\[1, 55\]", 'cpuset': "\[1, 2, 3, 4\]"})
|
'requested': r'\[1, 55\]', 'cpuset': r'\[1, 2, 3, 4\]'}
|
||||||
with testtools.ExpectedException(exception.CPUUnpinningUnknown,
|
with testtools.ExpectedException(exception.CPUUnpinningUnknown,
|
||||||
expect_msg):
|
expect_msg):
|
||||||
numacell.unpin_cpus(set([1, 55]))
|
numacell.unpin_cpus(set([1, 55]))
|
||||||
|
|
|
@ -143,7 +143,7 @@ class IptablesManagerTestCase(test.NoDBTestCase):
|
||||||
table.add_rule('OUTPUT', '-d 10.10.10.11 -j DNAT --to 10.0.0.10')
|
table.add_rule('OUTPUT', '-d 10.10.10.11 -j DNAT --to 10.0.0.10')
|
||||||
new_lines = self.manager._modify_rules(current_lines, table, 'nat')
|
new_lines = self.manager._modify_rules(current_lines, table, 'nat')
|
||||||
self.assertEqual(len(new_lines) - len(current_lines), 8)
|
self.assertEqual(len(new_lines) - len(current_lines), 8)
|
||||||
regex = '.*\s+%s(/32|\s+|$)'
|
regex = r'.*\s+%s(/32|\s+|$)'
|
||||||
num_removed = table.remove_rules_regex(regex % '10.10.10.10')
|
num_removed = table.remove_rules_regex(regex % '10.10.10.10')
|
||||||
self.assertEqual(num_removed, 4)
|
self.assertEqual(num_removed, 4)
|
||||||
new_lines = self.manager._modify_rules(current_lines, table, 'nat')
|
new_lines = self.manager._modify_rules(current_lines, table, 'nat')
|
||||||
|
|
|
@ -23,7 +23,7 @@ from nova.virt.libvirt.storage import rbd_utils
|
||||||
from nova.virt.libvirt import utils as libvirt_utils
|
from nova.virt.libvirt import utils as libvirt_utils
|
||||||
|
|
||||||
|
|
||||||
CEPH_MON_DUMP = """dumped monmap epoch 1
|
CEPH_MON_DUMP = r"""dumped monmap epoch 1
|
||||||
{ "epoch": 1,
|
{ "epoch": 1,
|
||||||
"fsid": "33630410-6d93-4d66-8e42-3b953cf194aa",
|
"fsid": "33630410-6d93-4d66-8e42-3b953cf194aa",
|
||||||
"modified": "2013-05-22 17:44:56.343618",
|
"modified": "2013-05-22 17:44:56.343618",
|
||||||
|
|
|
@ -13171,8 +13171,8 @@ class LibvirtConnTestCase(test.NoDBTestCase,
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def fake_node_device_lookup_by_name(address):
|
def fake_node_device_lookup_by_name(address):
|
||||||
pattern = ("pci_%(hex)s{4}_%(hex)s{2}_%(hex)s{2}_%(oct)s{1}"
|
pattern = "pci_%(hex)s{4}_%(hex)s{2}_%(hex)s{2}_%(oct)s{1}" % {
|
||||||
% dict(hex='[\da-f]', oct='[0-8]'))
|
'hex': r'[\da-f]', 'oct': '[0-8]'}
|
||||||
pattern = re.compile(pattern)
|
pattern = re.compile(pattern)
|
||||||
if pattern.match(address) is None:
|
if pattern.match(address) is None:
|
||||||
raise fakelibvirt.libvirtError()
|
raise fakelibvirt.libvirtError()
|
||||||
|
@ -15801,8 +15801,8 @@ class LibvirtConnTestCase(test.NoDBTestCase,
|
||||||
self.assertRaisesRegex(
|
self.assertRaisesRegex(
|
||||||
exception.InvalidNetworkNUMAAffinity,
|
exception.InvalidNetworkNUMAAffinity,
|
||||||
"Invalid NUMA network affinity configured: the physnet 'bar' "
|
"Invalid NUMA network affinity configured: the physnet 'bar' "
|
||||||
"was listed in '\[neutron\] physnets' but no corresponding "
|
"was listed in '\\[neutron\\] physnets' but no corresponding "
|
||||||
"'\[neutron_physnet_bar\] numa_nodes' option was defined.",
|
"'\\[neutron_physnet_bar\\] numa_nodes' option was defined.",
|
||||||
drvr._get_host_numa_topology)
|
drvr._get_host_numa_topology)
|
||||||
|
|
||||||
@mock.patch.object(host.Host, 'has_min_version', return_value=True)
|
@mock.patch.object(host.Host, 'has_min_version', return_value=True)
|
||||||
|
|
|
@ -280,13 +280,13 @@ class IptablesFirewallTestCase(test.NoDBTestCase):
|
||||||
self.assertTrue(security_group_chain,
|
self.assertTrue(security_group_chain,
|
||||||
"The security group chain wasn't added")
|
"The security group chain wasn't added")
|
||||||
|
|
||||||
regex = re.compile('\[0\:0\] -A .* -j ACCEPT -p icmp '
|
regex = re.compile(r'\[0\:0\] -A .* -j ACCEPT -p icmp '
|
||||||
'-s 192.168.11.0/24')
|
'-s 192.168.11.0/24')
|
||||||
match_rules = [rule for rule in self.out_rules if regex.match(rule)]
|
match_rules = [rule for rule in self.out_rules if regex.match(rule)]
|
||||||
self.assertGreater(len(match_rules), 0,
|
self.assertGreater(len(match_rules), 0,
|
||||||
"ICMP acceptance rule wasn't added")
|
"ICMP acceptance rule wasn't added")
|
||||||
|
|
||||||
regex = re.compile('\[0\:0\] -A .* -j ACCEPT -p icmp -m icmp '
|
regex = re.compile(r'\[0\:0\] -A .* -j ACCEPT -p icmp -m icmp '
|
||||||
'--icmp-type 8 -s 192.168.11.0/24')
|
'--icmp-type 8 -s 192.168.11.0/24')
|
||||||
match_rules = [rule for rule in self.out_rules if regex.match(rule)]
|
match_rules = [rule for rule in self.out_rules if regex.match(rule)]
|
||||||
self.assertGreater(len(match_rules), 0,
|
self.assertGreater(len(match_rules), 0,
|
||||||
|
@ -295,13 +295,13 @@ class IptablesFirewallTestCase(test.NoDBTestCase):
|
||||||
for ip in network_model.fixed_ips():
|
for ip in network_model.fixed_ips():
|
||||||
if ip['version'] != 4:
|
if ip['version'] != 4:
|
||||||
continue
|
continue
|
||||||
regex = re.compile('\[0\:0\] -A .* -j ACCEPT -p tcp -m multiport '
|
regex = re.compile(r'\[0\:0\] -A .* -j ACCEPT -p tcp -m multiport '
|
||||||
'--dports 80:81 -s %s' % ip['address'])
|
'--dports 80:81 -s %s' % ip['address'])
|
||||||
match_rules = [rule for rule in self.out_rules
|
match_rules = [rule for rule in self.out_rules
|
||||||
if regex.match(rule)]
|
if regex.match(rule)]
|
||||||
self.assertGreater(len(match_rules), 0,
|
self.assertGreater(len(match_rules), 0,
|
||||||
"TCP port 80/81 acceptance rule wasn't added")
|
"TCP port 80/81 acceptance rule wasn't added")
|
||||||
regex = re.compile('\[0\:0\] -A .* -j ACCEPT -s '
|
regex = re.compile(r'\[0\:0\] -A .* -j ACCEPT -s '
|
||||||
'%s' % ip['address'])
|
'%s' % ip['address'])
|
||||||
match_rules = [rule for rule in self.out_rules
|
match_rules = [rule for rule in self.out_rules
|
||||||
if regex.match(rule)]
|
if regex.match(rule)]
|
||||||
|
@ -309,7 +309,7 @@ class IptablesFirewallTestCase(test.NoDBTestCase):
|
||||||
"Protocol/port-less acceptance rule"
|
"Protocol/port-less acceptance rule"
|
||||||
" wasn't added")
|
" wasn't added")
|
||||||
|
|
||||||
regex = re.compile('\[0\:0\] -A .* -j ACCEPT -p tcp '
|
regex = re.compile(r'\[0\:0\] -A .* -j ACCEPT -p tcp '
|
||||||
'-m multiport --dports 80:81 -s 192.168.10.0/24')
|
'-m multiport --dports 80:81 -s 192.168.10.0/24')
|
||||||
match_rules = [rule for rule in self.out_rules if regex.match(rule)]
|
match_rules = [rule for rule in self.out_rules if regex.match(rule)]
|
||||||
self.assertGreater(len(match_rules), 0,
|
self.assertGreater(len(match_rules), 0,
|
||||||
|
|
|
@ -58,8 +58,9 @@ class LibvirtVZStorageTestCase(test_volume.LibvirtVolumeBaseTestCase):
|
||||||
connection_info = {'data': {'export': wrong_export_string,
|
connection_info = {'data': {'export': wrong_export_string,
|
||||||
'name': self.name}}
|
'name': self.name}}
|
||||||
|
|
||||||
err_pattern = ("^Valid share format is "
|
err_pattern = (
|
||||||
"\[mds\[,mds1\[\.\.\.\]\]:/\]clustername\[:password\]$")
|
"^Valid share format is "
|
||||||
|
r"\[mds\[,mds1\[\.\.\.\]\]:/\]clustername\[:password\]$")
|
||||||
self.assertRaisesRegex(exception.InvalidVolume,
|
self.assertRaisesRegex(exception.InvalidVolume,
|
||||||
err_pattern,
|
err_pattern,
|
||||||
drv.connect_volume,
|
drv.connect_volume,
|
||||||
|
|
|
@ -1734,9 +1734,9 @@ class NUMATopologyTest(test.NoDBTestCase):
|
||||||
self.assertEqual(hostusage.cells[1].memory_usage, 128)
|
self.assertEqual(hostusage.cells[1].memory_usage, 128)
|
||||||
|
|
||||||
def test_topo_usage_with_network_metadata(self):
|
def test_topo_usage_with_network_metadata(self):
|
||||||
"""Validate behavior with network_metadata.
|
r"""Validate behavior with network_metadata.
|
||||||
|
|
||||||
Ensure we handle ``NUMACell``\s that have ``network_metadata`` set
|
Ensure we handle ``NUMACell``\ s that have ``network_metadata`` set
|
||||||
along with those where this is unset.
|
along with those where this is unset.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
|
@ -311,7 +311,7 @@ class DsUtilTestCase(test.NoDBTestCase):
|
||||||
|
|
||||||
def test_get_datastore_with_regex(self):
|
def test_get_datastore_with_regex(self):
|
||||||
# Test with a regex that matches with a datastore
|
# Test with a regex that matches with a datastore
|
||||||
datastore_valid_regex = re.compile("^openstack.*\d$")
|
datastore_valid_regex = re.compile(r"^openstack.*\d$")
|
||||||
fake_objects = fake.FakeRetrieveResult()
|
fake_objects = fake.FakeRetrieveResult()
|
||||||
fake_objects.add_object(fake.Datastore("openstack-ds0"))
|
fake_objects.add_object(fake.Datastore("openstack-ds0"))
|
||||||
fake_objects.add_object(fake.Datastore("fake-ds0"))
|
fake_objects.add_object(fake.Datastore("fake-ds0"))
|
||||||
|
@ -323,7 +323,7 @@ class DsUtilTestCase(test.NoDBTestCase):
|
||||||
self.assertEqual("openstack-ds0", result.name)
|
self.assertEqual("openstack-ds0", result.name)
|
||||||
|
|
||||||
def test_get_datastore_with_token(self):
|
def test_get_datastore_with_token(self):
|
||||||
regex = re.compile("^ds.*\d$")
|
regex = re.compile(r"^ds.*\d$")
|
||||||
fake0 = fake.FakeRetrieveResult()
|
fake0 = fake.FakeRetrieveResult()
|
||||||
fake0.add_object(fake.Datastore("ds0", 10 * units.Gi, 5 * units.Gi))
|
fake0.add_object(fake.Datastore("ds0", 10 * units.Gi, 5 * units.Gi))
|
||||||
fake0.add_object(fake.Datastore("foo", 10 * units.Gi, 9 * units.Gi))
|
fake0.add_object(fake.Datastore("foo", 10 * units.Gi, 9 * units.Gi))
|
||||||
|
|
|
@ -2935,19 +2935,19 @@ class XenAPIDom0IptablesFirewallTestCase(stubs.XenAPITestBase):
|
||||||
self.assertTrue(security_group_chain,
|
self.assertTrue(security_group_chain,
|
||||||
"The security group chain wasn't added")
|
"The security group chain wasn't added")
|
||||||
|
|
||||||
regex = re.compile('\[0\:0\] -A .* -j ACCEPT -p icmp'
|
regex = re.compile(r'\[0\:0\] -A .* -j ACCEPT -p icmp'
|
||||||
' -s 192.168.11.0/24')
|
' -s 192.168.11.0/24')
|
||||||
match_rules = [rule for rule in self._out_rules if regex.match(rule)]
|
match_rules = [rule for rule in self._out_rules if regex.match(rule)]
|
||||||
self.assertGreater(len(match_rules), 0,
|
self.assertGreater(len(match_rules), 0,
|
||||||
"ICMP acceptance rule wasn't added")
|
"ICMP acceptance rule wasn't added")
|
||||||
|
|
||||||
regex = re.compile('\[0\:0\] -A .* -j ACCEPT -p icmp -m icmp'
|
regex = re.compile(r'\[0\:0\] -A .* -j ACCEPT -p icmp -m icmp'
|
||||||
' --icmp-type 8 -s 192.168.11.0/24')
|
' --icmp-type 8 -s 192.168.11.0/24')
|
||||||
match_rules = [rule for rule in self._out_rules if regex.match(rule)]
|
match_rules = [rule for rule in self._out_rules if regex.match(rule)]
|
||||||
self.assertGreater(len(match_rules), 0,
|
self.assertGreater(len(match_rules), 0,
|
||||||
"ICMP Echo Request acceptance rule wasn't added")
|
"ICMP Echo Request acceptance rule wasn't added")
|
||||||
|
|
||||||
regex = re.compile('\[0\:0\] -A .* -j ACCEPT -p tcp --dport 80:81'
|
regex = re.compile(r'\[0\:0\] -A .* -j ACCEPT -p tcp --dport 80:81'
|
||||||
' -s 192.168.10.0/24')
|
' -s 192.168.10.0/24')
|
||||||
match_rules = [rule for rule in self._out_rules if regex.match(rule)]
|
match_rules = [rule for rule in self._out_rules if regex.match(rule)]
|
||||||
self.assertGreater(len(match_rules), 0,
|
self.assertGreater(len(match_rules), 0,
|
||||||
|
@ -2991,7 +2991,7 @@ class XenAPIDom0IptablesFirewallTestCase(stubs.XenAPITestBase):
|
||||||
for ip in network_model.fixed_ips():
|
for ip in network_model.fixed_ips():
|
||||||
if ip['version'] != 4:
|
if ip['version'] != 4:
|
||||||
continue
|
continue
|
||||||
regex = re.compile('\[0\:0\] -A .* -j ACCEPT -p tcp'
|
regex = re.compile(r'\[0\:0\] -A .* -j ACCEPT -p tcp'
|
||||||
' --dport 80:81 -s %s' % ip['address'])
|
' --dport 80:81 -s %s' % ip['address'])
|
||||||
match_rules = [rule for rule in self._out_rules
|
match_rules = [rule for rule in self._out_rules
|
||||||
if regex.match(rule)]
|
if regex.match(rule)]
|
||||||
|
@ -3063,7 +3063,7 @@ class XenAPIDom0IptablesFirewallTestCase(stubs.XenAPITestBase):
|
||||||
'cidr': '192.168.99.0/24'})
|
'cidr': '192.168.99.0/24'})
|
||||||
# validate the extra rule
|
# validate the extra rule
|
||||||
self.fw.refresh_security_group_rules(secgroup)
|
self.fw.refresh_security_group_rules(secgroup)
|
||||||
regex = re.compile('\[0\:0\] -A .* -j ACCEPT -p udp --dport 200:299'
|
regex = re.compile(r'\[0\:0\] -A .* -j ACCEPT -p udp --dport 200:299'
|
||||||
' -s 192.168.99.0/24')
|
' -s 192.168.99.0/24')
|
||||||
match_rules = [rule for rule in self._out_rules if regex.match(rule)]
|
match_rules = [rule for rule in self._out_rules if regex.match(rule)]
|
||||||
self.assertGreater(len(match_rules), 0,
|
self.assertGreater(len(match_rules), 0,
|
||||||
|
|
|
@ -515,7 +515,7 @@ def sanitize_hostname(hostname, default_name=None):
|
||||||
|
|
||||||
hostname = truncate_hostname(hostname)
|
hostname = truncate_hostname(hostname)
|
||||||
hostname = re.sub('[ _]', '-', hostname)
|
hostname = re.sub('[ _]', '-', hostname)
|
||||||
hostname = re.sub('[^\w.-]+', '', hostname)
|
hostname = re.sub(r'[^\w.-]+', '', hostname)
|
||||||
hostname = hostname.lower()
|
hostname = hostname.lower()
|
||||||
hostname = hostname.strip('.-')
|
hostname = hostname.strip('.-')
|
||||||
# NOTE(eliqiao): set hostname to default_display_name to avoid
|
# NOTE(eliqiao): set hostname to default_display_name to avoid
|
||||||
|
|
|
@ -88,7 +88,7 @@ class VMwareVCDriver(driver.ComputeDriver):
|
||||||
# We assume <mo id> consists of alphanumeric, _ and -.
|
# We assume <mo id> consists of alphanumeric, _ and -.
|
||||||
# We assume cluster name is everything between the first ( and the last ).
|
# We assume cluster name is everything between the first ( and the last ).
|
||||||
# We pull out <mo id> for re-use.
|
# We pull out <mo id> for re-use.
|
||||||
LEGACY_NODENAME = re.compile('([\w-]+)\(.+\)')
|
LEGACY_NODENAME = re.compile(r'([\w-]+)\(.+\)')
|
||||||
|
|
||||||
# The vCenter driver includes API that acts on ESX hosts or groups
|
# The vCenter driver includes API that acts on ESX hosts or groups
|
||||||
# of ESX hosts in clusters or non-cluster logical-groupings.
|
# of ESX hosts in clusters or non-cluster logical-groupings.
|
||||||
|
|
|
@ -35,7 +35,7 @@ LOG = logging.getLogger(__name__)
|
||||||
# Examples:
|
# Examples:
|
||||||
# - vxw-dvs-22-virtualwire-89-sid-5008-NAME
|
# - vxw-dvs-22-virtualwire-89-sid-5008-NAME
|
||||||
# - vxw-dvs-22-virtualwire-89-sid-5008-UUID
|
# - vxw-dvs-22-virtualwire-89-sid-5008-UUID
|
||||||
VWIRE_REGEX = re.compile('vxw-dvs-(\d+)-virtualwire-(\d+)-sid-(\d+)-(.*)')
|
VWIRE_REGEX = re.compile(r'vxw-dvs-(\d+)-virtualwire-(\d+)-sid-(\d+)-(.*)')
|
||||||
|
|
||||||
|
|
||||||
def _get_name_from_dvs_name(dvs_name):
|
def _get_name_from_dvs_name(dvs_name):
|
||||||
|
|
|
@ -161,7 +161,7 @@ class HostState(object):
|
||||||
:returns: a list of pci devices on the node
|
:returns: a list of pci devices on the node
|
||||||
"""
|
"""
|
||||||
def _compile_hex(pattern):
|
def _compile_hex(pattern):
|
||||||
"""Return a compiled regular expression pattern into which we have
|
r"""Return a compiled regular expression pattern into which we have
|
||||||
replaced occurrences of hex by [\da-fA-F].
|
replaced occurrences of hex by [\da-fA-F].
|
||||||
"""
|
"""
|
||||||
return re.compile(pattern.replace("hex", r"[\da-fA-F]"))
|
return re.compile(pattern.replace("hex", r"[\da-fA-F]"))
|
||||||
|
|
4
tox.ini
4
tox.ini
|
@ -237,10 +237,10 @@ commands = bandit -r nova -x tests -n 5 -ll
|
||||||
#
|
#
|
||||||
# W504 skipped since you must choose either W503 or W504 (they conflict)
|
# W504 skipped since you must choose either W503 or W504 (they conflict)
|
||||||
#
|
#
|
||||||
# W605 and E731 temporarily skipped because of the number of
|
# E731 temporarily skipped because of the number of
|
||||||
# these that have to be fixed
|
# these that have to be fixed
|
||||||
enable-extensions = H106,H203,H904
|
enable-extensions = H106,H203,H904
|
||||||
ignore = E121,E122,E123,E124,E125,E126,E127,E128,E129,E131,E251,H405,W504,W605,E731
|
ignore = E121,E122,E123,E124,E125,E126,E127,E128,E129,E131,E251,H405,W504,E731
|
||||||
exclude = .venv,.git,.tox,dist,*lib/python*,*egg,build,tools/xenserver*,releasenotes
|
exclude = .venv,.git,.tox,dist,*lib/python*,*egg,build,tools/xenserver*,releasenotes
|
||||||
# To get a list of functions that are more complex than 25, set max-complexity
|
# To get a list of functions that are more complex than 25, set max-complexity
|
||||||
# to 25 and run 'tox -epep8'.
|
# to 25 and run 'tox -epep8'.
|
||||||
|
|
Loading…
Reference in New Issue