Skip to content

Commit 921091a

Browse files
[dhcp]: Cleanup mark_dhcp_packet.py formatting
Signed-off-by: Lawrence Lee <[email protected]>
1 parent 25a2479 commit 921091a

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

files/scripts/mark_dhcp_packet.py

+15-7
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
#!/usr/bin/env python3
22

3-
import os
43
import subprocess
5-
import sys
6-
import time
74

85
from sonic_py_common import logger
96
from swsscommon import swsscommon
107

118
log = logger.Logger('mark_dhcp_packet')
129

10+
1311
class MarkDhcpPacket(object):
1412
"""
1513
Class used to configure dhcp packet mark in ebtables
@@ -38,7 +36,9 @@ def state_db(self):
3836
Initializes the connector during the first call
3937
"""
4038
if self.state_db_connector is None:
41-
self.state_db_connector = swsscommon.SonicV2Connector(host='127.0.0.1')
39+
self.state_db_connector = swsscommon.SonicV2Connector(
40+
host='127.0.0.1'
41+
)
4242
self.state_db_connector.connect(self.state_db_connector.STATE_DB)
4343

4444
return self.state_db_connector
@@ -51,7 +51,8 @@ def is_dualtor(self):
5151
localhost_key = self.config_db.get_keys('DEVICE_METADATA')[0]
5252
metadata = self.config_db.get_entry('DEVICE_METADATA', localhost_key)
5353

54-
return 'subtype' in metadata and 'dualtor' in metadata['subtype'].lower()
54+
return 'subtype' in metadata and \
55+
'dualtor' in metadata['subtype'].lower()
5556

5657
def get_mux_intfs(self):
5758
"""
@@ -82,10 +83,16 @@ def clear_dhcp_packet_marks(self):
8283
self.run_command("sudo ebtables -F INPUT")
8384

8485
def apply_mark_in_ebtables(self, intf, mark):
85-
self.run_command("sudo ebtables -A INPUT -i {} -j mark --mark-set {}".format(intf, mark))
86+
self.run_command("sudo ebtables -A INPUT -i {} -j mark --mark-set {}"
87+
.format(intf, mark))
8688

8789
def update_mark_in_state_db(self, intf, mark):
88-
self.state_db.set(self.state_db.STATE_DB, 'DHCP_PACKET_MARK|' + intf, 'mark', mark)
90+
self.state_db.set(
91+
self.state_db.STATE_DB,
92+
'DHCP_PACKET_MARK|' + intf,
93+
'mark',
94+
mark
95+
)
8996

9097
def apply_marks(self):
9198
"""
@@ -103,6 +110,7 @@ def apply_marks(self):
103110

104111
log.log_info("Finish marking dhcp packets in ebtables.")
105112

113+
106114
if __name__ == '__main__':
107115
mark_dhcp_packet = MarkDhcpPacket()
108116
mark_dhcp_packet.apply_marks()

0 commit comments

Comments
 (0)