.format() doesn't understand what to do with binary values by default.
Specify that we expect coersion to string.
Change-Id: Ic4b697f70852124dc85ab231f76b7934d0d71f4d
Signed-off-by: Paul Vinciguerra <pvinci@vinciconsulting.com>
if isinstance(test, unittest.suite._ErrorHolder):
test_name = str(test)
else:
- test_name = "'{}' ({})".format(
+ test_name = "'{!s}' ({!s})".format(
get_testcase_doc_name(test), test.id())
self.current_test_case_info.core_crash_test = test_name
self.core_crash_test_cases_info.add(
self.prefix_length = 0
self.data_length = 6
else:
- raise Exception('Unsupported EID format {}!'.format(eid))
+ raise Exception('Unsupported EID format {!s}!'.format(eid))
def __str__(self):
if self.eid_type == LispEIDType.IP4:
return socket.inet_pton(socket.AF_INET6, self.eid_address)
elif self.eid_type == LispEIDType.MAC:
return Exception('Unimplemented')
- raise Exception('Unknown EID type {}!'.format(self.eid_type))
+ raise Exception('Unknown EID type {!s}!'.format(self.eid_type))
class VppLispMapping(VppObject):
def get_parallel_logger(stream):
- logger = logging.getLogger('parallel_logger_{}'.format(stream))
+ logger = logging.getLogger('parallel_logger_{!s}'.format(stream))
logger.propagate = False
logger.setLevel(logging.DEBUG)
handler = logging.StreamHandler(stream)
mac = ':'.join(re.findall('..', '{:02x}'.format(
src_mac))[:3])+":00:00:00"
else:
- mac = ':'.join(re.findall('..', '{:02x}'.format(src_mac)))
+ mac = ':'.join(re.findall(
+ '..', '{:02x}'.format(src_mac)))
if ip_type == self.EXACT_IP:
ip4[3] = random.randint(100, 200)
:param str dst_port: destination port number <0-ffff>
"""
- return ('{:0>20}{:0>12}{:0>8}{:0>4}{:0>4}'.format(
+ return ('{!s:0>20}{!s:0>12}{!s:0>8}{!s:0>4}{!s:0>4}'.format(
proto, src_ip, dst_ip, src_port, dst_port)).rstrip('0')
@staticmethod
if dst_ip:
dst_ip = binascii.hexlify(socket.inet_aton(dst_ip))
- return ('{:0>20}{:0>12}{:0>8}{:0>4}{:0>4}'.format(
+ return ('{!s:0>20}{!s:0>12}{!s:0>8}{!s:0>4}{!s:0>4}'.format(
hex(proto)[2:], src_ip, dst_ip, hex(src_port)[2:],
hex(dst_port)[2:])).rstrip('0')
:param str ether_type: ethernet type <0-ffff>
"""
- return ('{:0>12}{:0>12}{:0>4}'.format(dst_mac, src_mac,
- ether_type)).rstrip('0')
+ return ('{!s:0>12}{!s:0>12}{!s:0>4}'.format(
+ dst_mac, src_mac, ether_type)).rstrip('0')
@staticmethod
def build_mac_match(dst_mac='', src_mac='', ether_type=''):
if src_mac:
src_mac = src_mac.replace(':', '')
- return ('{:0>12}{:0>12}{:0>4}'.format(dst_mac, src_mac,
- ether_type)).rstrip('0')
+ return ('{!s:0>12}{!s:0>12}{!s:0>4}'.format(
+ dst_mac, src_mac, ether_type)).rstrip('0')
def create_classify_table(self, key, mask, data_offset=0):
"""Create Classify Table
:param str dst_port: destination port number <0-ffff>
"""
- return ('{:0>14}{:0>34}{:0>32}{:0>4}{:0>4}'.format(
+ return ('{!s:0>14}{!s:0>34}{!s:0>32}{!s:0>4}{!s:0>4}'.format(
nh, src_ip, dst_ip, src_port, dst_port)).rstrip('0')
@staticmethod
dst_ip = binascii.hexlify(socket.inet_pton(
socket.AF_INET6, dst_ip))
- return ('{:0>14}{:0>34}{:0>32}{:0>4}{:0>4}'.format(
+ return ('{!s:0>14}{!s:0>34}{!s:0>32}{!s:0>4}{!s:0>4}'.format(
hex(nh)[2:], src_ip, dst_ip, hex(src_port)[2:],
hex(dst_port)[2:])).rstrip('0')
:param str ether_type: ethernet type <0-ffff>
"""
- return ('{:0>12}{:0>12}{:0>4}'.format(dst_mac, src_mac,
- ether_type)).rstrip('0')
+ return ('{!s:0>12}{!s:0>12}{!s:0>4}'.format(
+ dst_mac, src_mac, ether_type)).rstrip('0')
@staticmethod
def build_mac_match(dst_mac='', src_mac='', ether_type=''):
if src_mac:
src_mac = src_mac.replace(':', '')
- return ('{:0>12}{:0>12}{:0>4}'.format(dst_mac, src_mac,
- ether_type)).rstrip('0')
+ return ('{!s:0>12}{!s:0>12}{!s:0>4}'.format(
+ dst_mac, src_mac, ether_type)).rstrip('0')
def create_classify_table(self, key, mask, data_offset=0):
"""Create Classify Table
:param str ether_type: ethernet type <0-ffff>
"""
- return ('{:0>12}{:0>12}{:0>4}'.format(dst_mac, src_mac,
- ether_type)).rstrip('0')
+ return ('{!s:0>12}{!s:0>12}{!s:0>4}'.format(
+ dst_mac, src_mac, ether_type)).rstrip('0')
@staticmethod
def build_mac_match(dst_mac='', src_mac='', ether_type=''):
if src_mac:
src_mac = src_mac.replace(':', '')
- return ('{:0>12}{:0>12}{:0>4}'.format(dst_mac, src_mac,
- ether_type)).rstrip('0')
+ return ('{!s:0>12}{!s:0>12}{!s:0>4}'.format(
+ dst_mac, src_mac, ether_type)).rstrip('0')
def create_classify_table(self, key, mask, data_offset=0, is_add=1):
"""Create Classify Table
for ip in ips:
self.assertTrue(_ip_in_route_dump(ip, fib_dump),
- 'IP {} is not in fib dump.'.format(ip))
+ 'IP {!s} is not in fib dump.'.format(ip))
def verify_not_in_route_dump(self, fib_dump, ips):
for ip in ips:
self.assertFalse(_ip_in_route_dump(ip, fib_dump),
- 'IP {} is in fib dump.'.format(ip))
+ 'IP {!s} is in fib dump.'.format(ip))
@classmethod
def setUpClass(cls):
self.deid_ip4_net = self.faf.net
self.deid_ip4 = self.faf.get_ip4()
- self.seid_ip4 = '{}/{}'.format(self.pg0.local_ip4, 32)
+ self.seid_ip4 = '{!s}/{!s}'.format(self.pg0.local_ip4, 32)
self.rloc_ip4 = self.pg1.remote_ip4n
test_cases = [
for i in range(1, clients+1):
try:
- macs.append(':'.join(re.findall('..', '{:02x}'.format(mac+i))))
+ macs.append(':'.join(re.findall('..', '{:02x}'.format(
+ mac+i))))
self.vapi.p2p_ethernet_add(self.pg2.sw_if_index,
mac_pton(macs[i-1]),
i)
# add classify table
# mask on dst ip address prefix a7::/8
- mask = '{:0<16}'.format('ff')
+ mask = '{!s:0<16}'.format('ff')
r = self.vapi.classify_add_del_table(
1,
binascii.unhexlify(mask),
'sr-pl-rewrite-insert')
inacl_next_node_index = r.node_index
- match = '{:0<16}'.format('a7')
+ match = '{!s:0<16}'.format('a7')
r = self.vapi.classify_add_del_session(
1,
table_index,