aboutsummaryrefslogtreecommitdiffstats
path: root/resources/libraries/python/Cop.py
diff options
context:
space:
mode:
authorJan Gelety <jgelety@cisco.com>2019-11-12 05:27:43 +0100
committerJan Gelety <jgelety@cisco.com>2019-11-28 18:26:21 +0100
commitd68951ac245150eeefa6e0f4156e4c1b5c9e9325 (patch)
tree487554a7547218d27f0a61ec02b70502c32cdcb4 /resources/libraries/python/Cop.py
parented0258a440cfad7023d643f717ab78ac568dc59b (diff)
Python3: resources and libraries
Change-Id: I1392c06b1d64f62b141d24c0d42a8e36913b15e2 Signed-off-by: Jan Gelety <jgelety@cisco.com>
Diffstat (limited to 'resources/libraries/python/Cop.py')
-rw-r--r--resources/libraries/python/Cop.py28
1 files changed, 14 insertions, 14 deletions
diff --git a/resources/libraries/python/Cop.py b/resources/libraries/python/Cop.py
index 24b0debdc4..29530b1277 100644
--- a/resources/libraries/python/Cop.py
+++ b/resources/libraries/python/Cop.py
@@ -17,7 +17,7 @@ from resources.libraries.python.PapiExecutor import PapiSocketExecutor
from resources.libraries.python.topology import Topology
-class Cop(object):
+class Cop:
"""COP utilities."""
@staticmethod
@@ -38,17 +38,17 @@ class Cop(object):
:type default_cop: int
:raises ValueError: If parameter 'ip_version' has incorrect value.
"""
- if ip_version not in ('ip4', 'ip6'):
- raise ValueError('IP version is not in correct format')
+ if ip_version not in (u"ip4", u"ip6"):
+ raise ValueError(u"IP version is not in correct format")
- cmd = 'cop_whitelist_enable_disable'
- err_msg = 'Failed to add COP whitelist on interface {ifc} on host' \
- ' {host}'.format(ifc=interface, host=node['host'])
+ cmd = u"cop_whitelist_enable_disable"
+ err_msg = f"Failed to add COP whitelist on interface {interface} " \
+ f"on host {node[u'host']}"
args = dict(
sw_if_index=Topology.get_interface_sw_index(node, interface),
fib_id=int(fib_id),
- ip4=True if ip_version == 'ip4' else False,
- ip6=True if ip_version == 'ip6' else False,
+ ip4=bool(ip_version == u"ip4"),
+ ip6=bool(ip_version == u"ip6"),
default_cop=default_cop
)
@@ -68,14 +68,14 @@ class Cop(object):
:raises ValueError: If parameter 'state' has incorrect value.
"""
state = state.lower()
- if state in ('enable', 'disable'):
- enable = True if state == 'enable' else False
+ if state in (u"enable", u"disable"):
+ enable = bool(state == u"enable")
else:
- raise ValueError("Possible state values are 'enable' or 'disable'")
+ raise ValueError(u"Possible state values are 'enable' or 'disable'")
- cmd = 'cop_interface_enable_disable'
- err_msg = 'Failed to enable/disable COP on interface {ifc} on host' \
- ' {host}'.format(ifc=interface, host=node['host'])
+ cmd = u"cop_interface_enable_disable"
+ err_msg = f"Failed to enable/disable COP on interface {interface} " \
+ f"on host {node[u'host']}"
args = dict(
sw_if_index=Topology.get_interface_sw_index(node, interface),
enable_disable=enable