-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsvi-config.py
174 lines (160 loc) · 5.33 KB
/
svi-config.py
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
import sys
import re
vname = raw_input("Enter the vlan name:\t")
vnum = raw_input("Enter the vlan number:\t")
#bits = raw_input("Enter the number of bits without the leading /:\t")
subnet= raw_input("Enter the IPv4 of the subnet in the format of x.x.x.x/xx.:\t")
switch1= raw_input("What is the first switch you will be updating?")
switch2= raw_input("What is the second switch you will be updating?")
#network = int(raw_input("Enter the network address for the 4th octet:\t"))
last=re.split(r'(\.|/)', subnet)
hsrp=1+int(last[6])
sw1_ip=2+int(last[6])
sw2_ip=3+int(last[6])
full_hsrp_ip=last[0]+last[1]+last[2]+last[3]+last[4]+last[5]+str(hsrp)+last[7]+last[8]
full_sw1_ip=last[0]+last[1]+last[2]+last[3]+last[4]+last[5]+str(sw1_ip)+last[7]+last[8]
full_sw2_ip=last[0]+last[1]+last[2]+last[3]+last[4]+last[5]+str(sw2_ip)+last[7]+last[8]
# uncomment to make sure math is being done to variables correctly
#print last
#ip=last[0]+last[1]+last[2]+last[3]+last[4]+last[5]+last[6]+last[7]+last[8]
#print ip
#print ("The last octet is %s") %last[6]
#print ("hsrp is %s") %hsrp
#print ("1st ip is %s") %sw1_ip
#print ("2nd ip is %s") %sw2_ip
if int(vnum) % 2 == 0:
print ("VLAN is even")
hsrpprio01=100
hsrpprio02=105
else:
print ("Vlan is odd")
hsrpprio01=105
hsrpprio02=100
### Print Different MOP Sections
### Precheck section below:
print ("Precheck/Baseline for %s and %s") % (switch1, switch2)
print ("NOTE: The same commands will be used for both switches.")
print ("!")
print ("term length 0")
print ("!")
print ("sh vlan brief | include ^%s") %vnum
print ("! ")
print ("! *** Verify above VLAN(s) are not in use (no output expected) ***")
print ("!")
print ("show interface port-channel 1 switchport | include 'VLANs Allowed'")
print ("! ")
print ("! *** Verify VLAN(s) %s is not listed ***") %vnum
print ("! ")
print ("show ip interface brief | include Vlan%s") %vnum
print ("! ")
print ("! *** Verify above interface(s) are not listed (no output expected) ***")
print ("! ")
print ("show interface status | include <ENTER YOUR ACCESS PORTS HERE!!!>")
print ("! ")
print ("! *** Verify above interface(s) are connected and in Cable_Testing state *** ")
print ("!")
print ("show run interface <ENTER YOUR ACCESS PORTS HERE!!!>")
print ("!")
print ("! *** Capture the pre-change output ***")
print ("!")
###Configuratyion for router 02 in the pair
print ("**************%s configuration*******") %switch2
print("!")
print("term length 0")
print("!")
print ("conf t")
print("!")
print("vlan %s") %vnum
print (" %s") % vname
print("!")
#Need to capture port channel info above and you can adjust this below
#For now hard coding port channel 1
print("interface port-channel1")
print(" switchport trunk allowed vlan add %s") %vnum
print("!")
print ("interface Vlan%s") %vnum
print(" no shutdown")
print(" mtu 9216")
print(" description %s") %vname
print(" ip address %s") % full_sw2_ip
print(" no ip redirect")
print(" hsrp version 2")
print(" hsrp %s") %vnum
print(" preempt ")
print(" priority %s") %hsrpprio02
print(" ip %s") % full_hsrp_ip
print(" track 1 ")
print(" track 101 decrement 50 ")
print("!")
print("exit")
print("!")
print("end")
print("!")
print("copy run start")
print("!")
###Configuratyion for router 01 in the pair
print ("**************%s configuration*******") %switch1
print("!")
print("term length 0")
print("!")
print ("conf t")
print("!")
print("vlan %s") %vnum
print (" %s") % vname
print("!")
#Need to capture port channel info above and you can adjust this below
#For now hard coding port channel 1
print("interface port-channel1")
print(" switchport trunk allowed vlan add %s") %vnum
print("!")
print ("interface Vlan%s") %vnum
print(" no shutdown")
print(" mtu 9216")
print(" description %s") %vname
print(" ip address %s") % full_sw1_ip
print(" no ip redirect")
print(" hsrp version 2")
print(" hsrp %s") %vnum
print(" preempt ")
print(" priority %s") %hsrpprio01
print(" ip %s") % full_hsrp_ip
print(" track 1 ")
print(" track 101 decrement 50 ")
print("!")
print("exit")
print("!")
print("end")
print("!")
print("copy run start")
print("!")
### Postcheck section below:
print ("Precheck/Baseline for %s and %s") % (switch1, switch2)
print ("NOTE: The same commands will be used for both switches.")
print ("!")
print ("term length 0")
print ("!")
print ("sh vlan brief | include ^%s") %vnum
print ("! ")
print ("! *** Verify above VLAN(s) are not in use (no output expected) ***")
print ("!")
print ("show interface port-channel 1 switchport | include 'VLANs Allowed'")
print ("! ")
print ("! *** Verify VLAN(s) %s is not listed ***") %vnum
print ("! ")
print ("show ip interface brief | include Vlan%s") %vnum
print ("! ")
print ("! *** Verify above interface(s) are not listed (no output expected) ***")
print ("! ")
print ("show interface status | include <ENTER YOUR ACCESS PORTS HERE!!!>")
print ("! ")
print ("! *** Verify above interface(s) are connected and in Cable_Testing state *** ")
print ("!")
print ("show run interface <ENTER YOUR ACCESS PORTS HERE!!!>")
print ("!")
print ("! *** Capture the pre-change output ***")
print ("!")
print("! *** Verify above interface has VLAN %s applied *** ") % vnum
print("! *** Verify that storm-control broadcast & multicast level is 4.00 ***")
print("! *** Verify that storm-control action is trap ***")
print("! *** Verify that spanning-tree port type is edge and bpduguard enabled ***")
print("!")