Skip to content

Commit

Permalink
chore(pipelined): More mypy fixes (#12884)
Browse files Browse the repository at this point in the history
* chore(pipelined): Remove commented out print statements

Signed-off-by: Cameron Voisey <cameron.voisey@tngtech.com>

* chore(pipelined): Fix "Not all arguments converted during string formatting"

Signed-off-by: Cameron Voisey <cameron.voisey@tngtech.com>

* chore(pipelined): Fix 'Function "builtins.hex" is not valid as a type'

Signed-off-by: Cameron Voisey <cameron.voisey@tngtech.com>

* chore(pipelined): Fix incompatible argument with superclass

Signed-off-by: Cameron Voisey <cameron.voisey@tngtech.com>

* chore(pipelined): Fix "Incompatible types in assignment"

Signed-off-by: Cameron Voisey <cameron.voisey@tngtech.com>

* chore(pipelined): Remove more commented out code

Signed-off-by: Cameron Voisey <cameron.voisey@tngtech.com>
  • Loading branch information
voisey committed Jun 2, 2022
1 parent 48a2260 commit 2cfc6ac
Show file tree
Hide file tree
Showing 8 changed files with 9 additions and 13 deletions.
8 changes: 4 additions & 4 deletions lte/gateway/python/magma/pipelined/openflow/flows.py
Original file line number Diff line number Diff line change
Expand Up @@ -654,17 +654,17 @@ def _check_resubmit_action(actions, parser):


def send_stats_request(
datapath, tbl_num, cookie: hex = 0,
cookie_mask: hex = 0, retries: int = 3,
datapath, tbl_num, cookie: int = 0,
cookie_mask: int = 0, retries: int = 3,
):
"""
Send a stats request msg
Args:
datapath (ryu.controller.controller.Datapath):
Datapath to query from
table (int): Table number to query for
cookie (hex): cookie value for the request
cookie_mask (hex): cookie mask for the request
cookie (int): a hex cookie value for the request
cookie_mask (int): a hex cookie mask for the request
retries (int): retry attempts on failure
"""
ofproto, parser = datapath.ofproto, datapath.ofproto_parser
Expand Down
4 changes: 2 additions & 2 deletions lte/gateway/python/magma/pipelined/qos/qos_tc_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@

from lte.protos.policydb_pb2 import FlowMatch

from .tc_ops import TcOpsBase
from .tc_ops_cmd import TcOpsCmd, argSplit, run_cmd
from .tc_ops_pyroute2 import TcOpsPyRoute2
from .types import QosInfo
from .utils import IdManager

LOG = logging.getLogger('pipelined.qos.qos_tc_impl')
# LOG.setLevel(logging.DEBUG)

# TODO - replace this implementation with pyroute2 tc
ROOT_QID = 65534
Expand All @@ -35,7 +35,7 @@ class TrafficClass:
Creates/Deletes queues in linux. Using Qdiscs for flow based
rate limiting(traffic shaping) of user traffic.
"""
tc_ops = None
tc_ops: Optional[TcOpsBase] = None

@staticmethod
def delete_class(intf: str, qid: int, skip_filter=False) -> int:
Expand Down
2 changes: 1 addition & 1 deletion lte/gateway/python/magma/pipelined/qos/tc_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class TcOpsBase(ABC):

@abstractmethod
def create_htb(
self, iface: str, qid: str, max_bw: str, rate: str,
self, iface: str, qid: str, max_bw: int, rate: str,
parent_qid: str = None,
) -> int:
"""
Expand Down
2 changes: 1 addition & 1 deletion lte/gateway/python/magma/pipelined/qos/tc_ops_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def __init__(self):
LOG.info("initialized")

def create_htb(
self, iface: str, qid: str, max_bw: str, rate: str,
self, iface: str, qid: str, max_bw: int, rate: str,
parent_qid: str = None,
) -> int:
tc_cmd = "tc class add dev {intf} parent {parent_qid} "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -676,7 +676,7 @@ def __exit__(self, type, value, traceback):
include_stats=self._include_stats,
)
except WaitTimeExceeded as e:
ofctl_cmd = "sudo ovs-ofctl dump-flows %s".format(self._bridge_name)
ofctl_cmd = f"sudo ovs-ofctl dump-flows {self._bridge_name}"
p = subprocess.Popen(
[ofctl_cmd],
stdout=subprocess.PIPE,
Expand Down
2 changes: 0 additions & 2 deletions lte/gateway/python/magma/pipelined/tests/test_ebpf_ul_dp.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,12 @@ def tearDownClassDevices(cls):

@classmethod
def pkt_cap_fun(cls, packet):
# print("got packet: %s", packet)
cls.packet_cap1.append(packet)

@classmethod
def count_udp_packet(cls):
cnt = 0
for pkt in cls.packet_cap1:
# print(pkt.show(dump=True))
if IP in pkt:
if pkt[IP].src == cls.inner_src_ip and pkt[IP].dst == cls.inner_dst_ip:
cnt = cnt + 1
Expand Down
1 change: 0 additions & 1 deletion lte/gateway/python/magma/pipelined/tests/test_qos.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,6 @@ def _testMultipleSubscribers(
exp_id = id_list[i]
k = get_key_json(get_subscriber_key(imsi, '', rule_num, d))
exp_id_dict[k] = exp_id
# self.assertTrue(qos_mgr._redis_store[k] == exp_id)
qid_info = get_data_json(get_subscriber_data(exp_id, 0, 0))
self.assertEqual(qos_mgr._subscriber_state[imsi].rules[rule_num][0], (d, qid_info))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ def check_qid_in_tc(self, qid):
ln = ln.strip()
if not ln:
continue
# print(ln)
tokens = ln.split(" ")

if len(tokens) > 11 and tokens[11] == qid:
Expand Down

0 comments on commit 2cfc6ac

Please sign in to comment.