Repository navigation
Expand file tree
/
Copy pathconfig_switch
More file actions
executable file
·77 lines (64 loc) · 2.33 KB
/
Copy pathconfig_switch
File metadata and controls
executable file
·77 lines (64 loc) · 2.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/usr/bin/python3
# Copyright (c) 2020-2023 Homa Developers
# SPDX-License-Identifier: BSD-1-Clause
# This program outputs the commands needed to configure a CloudLab switch
# for Homa, or to reset it.
# Usage:
# config_switch [reset]
#
# Commands will be printed on stdout.
import sys
# Ports to configure
nodes = [38, 34, 11, 24, 6, 21, 13, 37, 8, 16, 39]
ports = []
prev_switch = -1
for node in nodes:
switch = (node-1)//40
if (switch != prev_switch) and (prev_switch >= 0):
print("Multiple switches: rack-%d and rack-%d" % (switch, prev_switch),
file=sys.stderr)
prev_switch = switch
ports.append(node - 40*switch)
ports.sort()
# ports = range(1, 41)
def config():
# First, must enter "configure" mode
print("enable")
print("configure terminal")
for port in ports:
# Configure priorities for Homa.
print("interface ethernet 1/%d qos trust both" % (port))
for tc in range(8):
print("interface ethernet 1/%d traffic-class %d dcb ets strict" %
(port, tc))
# Enable large packets
print("interface ethernet 1/%d mtu 9216 force" % (port))
# Set DCTCP marking thresholds:
print("interface ethernet 1/%d traffic-class 0 congestion-control ecn "
"minimum-absolute 70 maximum-absolute 70" % (port))
print("interface ethernet 1/%d traffic-class 1 congestion-control ecn "
"minimum-absolute 70 maximum-absolute 70" % (port))
def reset():
# First, must enter "configure" mode
print("enable")
print("configure terminal")
for port in ports:
# Restore QOS priorities.
print("interface ethernet 1/%d no qos trust" % (port))
for tc in range(8):
print("interface ethernet 1/%d traffic-class %d no dcb ets" %
(port, tc))
# Disable large packets
print("interface ethernet 1/%d mtu 1500 force" % (port))
# Reset DCTCP marking thresholds:
print("interface ethernet 1/%d no traffic-class 0 congestion-control"
% (port))
print("interface ethernet 1/%d no traffic-class 1 congestion-control"
% (port))
if len(sys.argv) > 1:
if sys.argv[1] == "reset":
reset()
else:
print("Usage: config_switch [reset]", file=sys.stderr)
else:
config()