-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmtrcfg_A_change.php
More file actions
250 lines (196 loc) · 5.86 KB
/
Copy pathmtrcfg_A_change.php
File metadata and controls
250 lines (196 loc) · 5.86 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
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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
<?php
echo "<html>";
echo "<head>";
echo "<title>AutoNet\\ A series MTR Changer Configuration</title>";
echo "</head>";
echo "<body bgcolor=#009999 lang=EN-US style='tab-interval:.5in'>";
echo "<P fontsize=15 align=center>";
echo " AutoNet\\ A series MTR Changer Configuration </p>";
echo "<br>";
echo "<p align=center><font size=48 color=NAVY> A series MTR Changer Configuration";
echo "</p></font>";
$host="127.0.0.1";
$user="root";
$password="rezasql";
# Connect to MySQL server
$conn = mysql_connect($host,$user,$password)
or die(mysql_error());
# Select the database
mysql_select_db("", $conn)
or die(mysql_error());
# Send SQL query
$sql="select mtr_id,new_name,bld_newname , sw_fcx,sw_fcx_2x10g, sw_superx, sw_sx1600, sw_sx1600_2x10g, sw_mod_24p_sfp, sw_mod_2x10g, ";
$sql=$sql."sfpmm , sfpsm, xfpmm, xfpsm, installed ";
$sql=$sql." from mtr where ";
$sql=$sql."bld_newname like 'A%' or bld_newname like 'B%' ";
// echo "<R> $sql<BR>";
$result = mysql_query($sql)
or die(mysql_error());
while ($row=mysql_fetch_assoc($result)) {
$bld=$row['bld_newname'];
$mtr_id=$row['mtr_id'];
$new_name=$row['new_name'];
echo "<BR><font color=green size=10> Working on MTR Building $bld </font><BR>";
echo "<BR>";
echo "<BR>";
echo "config t";
//ETC
echo "<BR>";
echo "!";
echo "<BR>";
echo "no ip access-list extended VOIP-MARKING";
echo "<BR>";
echo "enable super-user-password Gr8Vision";
echo "<BR>";
echo "cdp run";
echo "<BR>";
echo "fdp run";
echo "<BR>";
echo "snmp-server community T1F1MH02 ro";
echo "<BR>";
echo "sntp server 10.20.66.123";
echo "<BR>";
echo "!";
echo "<BR>";
echo "!";
echo "<BR>";
//ETC
//loopback, host-name
$sql= "select ip from bld_ip where bld='".$bld."'";
$result2 = mysql_query($sql)
or die(mysql_error());
$row=mysql_fetch_assoc($result2);
$ip=$row['ip'];
$ip2nd=substr($ip,3,3);
echo "interface loopback 1";
echo "<BR>";
echo "ip address 10.$ip2nd.99.99/32";
echo "<BR>";
echo "ip ospf area 0.0.0.0";
echo "<BR>";
echo "exit";
echo "<BR>";
echo "ip multicast-routing";
echo "<BR>";
echo "!";
echo "<BR>";
echo "ip router-id 10.$ip2nd.99.99/32";
echo "<BR>";
echo "hostname SW1-$bld-MTR-$new_name";
echo "<BR>";
//loopback, host-name
//Port delete
echo "no interface ethernet 1/3/1";
echo "<BR>";
echo "no interface ethernet 1/3/2";
echo "<BR>";
echo "no interface ethernet 2/3/1";
echo "<BR>";
echo "no interface ethernet 2/3/2";
echo "<BR>";
/*$r=1;
while ($r<25){
echo "<BR>";
echo "no interface ethernet 1/1/$r";
echo "<BR>";
echo "no interface ethernet 2/1/$r";
$r++;
}
*/
// Uplinks to Core
$sql= "select src_switch, src_slot, src_port, src_ip, dst_switch, dst_slot, dst_port, dst_ip from portmapping ";
$sql=$sql." where dst_type='MTR' ";
$sql=$sql." and dst_bld='".$bld."' and dst_roomid=".$mtr_id." and src_type='CORE' ";
$sql=$sql." order by dst_slot, dst_port";
// echo "<BR> $sql <BR>";
$result2 = mysql_query($sql)
or die(mysql_error());
while ($row=mysql_fetch_assoc($result2)) {
if (substr($row['dst_switch'],0,3)=='SW1') $sw=1;
if (substr($row['dst_switch'],0,3)=='SW2') $sw=2;
echo "<BR>";
echo "!";
echo "<BR>";
echo "interface ethernet $sw/".$row['dst_slot']."/".$row['dst_port'];
echo "<BR>";
echo "port-name [UPLINK TO CORE -".$row['src_switch']." ".$row['src_slot']."/".$row['src_port']." ]";
echo "<BR>";
echo "ip address ".$row['dst_ip'];
echo "<BR>";
echo "ip pim-sparse";
echo "<BR>";
echo "ip ospf area 0.0.0.0";
echo "<BR>";
echo "ip ospf dead-interval 3";
echo "<BR>";
echo "ip ospf hello-interval 1";
echo "<BR>";
echo "ip ospf md5-authentication key-id 1 key 1 $6lUdQUn";
echo "<BR>";
echo "ip ospf auth-change-wait-time 0";
echo "<BR>";
echo "ip ospf network point-to-point";
echo "<BR>";
echo "!";
echo "<BR>";
echo "exit";
echo "<BR>";
echo "!";
}// while
// SWICTH 1 DOWNLINKS to FTR
// Downlinks to FTRs
$sql= "select src_switch, src_slot, src_port, src_ip, dst_switch, dst_slot, dst_port, dst_ip from portmapping where dst_type='MTR' ";
$sql=$sql." and dst_bld='".$bld."' and dst_roomid=".$mtr_id." and src_type='FTR' ";
$sql=$sql." order by src_ip , dst_slot, dst_port ";
echo "<BR>";
// echo "$sql";
echo "<BR>";
$result4 = mysql_query($sql)
or die(mysql_error());
$ip_check='REZA';
while ($row=mysql_fetch_assoc($result4)) {
if (substr($row['dst_switch'],0,3)=='SW1') $sw=1;
if (substr($row['dst_switch'],0,3)=='SW2') $sw=2;
$ip_check2=$row['src_ip'];
if ($ip_check!=$ip_check2) {
$ip_check=$ip_check2;
echo "interface ethernet $sw/".$row['dst_slot']."/".$row['dst_port'];
echo "<BR>";
echo "port-name [DOWNLINK TO FTR -".$row['src_switch']." Port:".substr($row['src_switch'],2,1)."/".$row['src_slot']."/".$row['src_port']." ]";
echo "<BR>";
echo "no ip address *";
echo "<BR>";
echo "ip address ".$row['dst_ip'];
echo "<BR>";
echo "ip ospf area 10.".$ip2nd.".0.0";
echo "<BR>";
echo "ip pim-sparse";
echo "<BR>";
echo "ip ospf dead-interval 3";
echo "<BR>";
echo "ip ospf hello-interval 1";
echo "<BR>";
echo "ip ospf md5-authentication key-id 1 key 1 $6lUGlU";
echo "<BR>";
echo "ip ospf auth-change-wait-time 0";
echo "<BR>";
echo "ip ospf network point-to-point";
echo "<BR>";
echo "<BR>";
echo "!";
echo "<BR>";
echo "!";
echo "<BR>";
}
else {
echo "interface ethernet $sw/".$row['dst_slot']."/".$row['dst_port'];
echo "<BR>";
echo "!";
echo "<BR>";
}
}// while
echo "<BR>";
echo "<BR>";
echo "<BR>";
}// While
?>