r2247 - use 'default' tab to make the URL in search results list work more often
[racktables] / inc / snmp.php
CommitLineData
2ffd5a2a
DO
1<?php
2
3function doSNMPmining ($object_id, $community)
4{
7056988c 5 // FIXME: switch to message log version 2
2ffd5a2a
DO
6 $log = array();
7// IDs: http://cisco.com/en/US/products/sw/cscowork/ps2064/products_device_support_table09186a0080803bb4.html
8// 2950: http://www.cisco.com/en/US/products/hw/switches/ps628/prod_models_home.html
9// 2960: http://www.cisco.com/en/US/products/ps6406/prod_models_comparison.html
10// 2970: http://cisco.com/en/US/products/hw/switches/ps5206/products_qanda_item09186a00801b1750.shtml
11// 3500XL: http://cisco.com/en/US/products/hw/switches/ps637/products_eol_models.html
12// 3560: http://cisco.com/en/US/products/hw/switches/ps5528/products_data_sheet09186a00801f3d7f.html
13// 3750: http://cisco.com/en/US/products/hw/switches/ps5023/products_data_sheet09186a008016136f.html
14
389e01ee 15 // Cisco sysObjectID to model (not product number, i.e. image code is missing) decoder
2ffd5a2a
DO
16 $ciscomodel = array
17 (
b3f866fc 18 278 => 'WS-C3548-XL (48 Ethernet 10/100 ports and 2 10/100/1000 uplinks)',
2ffd5a2a
DO
19 283 => 'WS-C6509-E (9-slot system)',
20# 694 => 'WS-C2960-24TC-L (24 Ethernet 10/100 ports and 2 dual-purpose uplinks)',
21# 695 => 'WS-C2960-48TC-L (48 Ethernet 10/100 ports and 2 dual-purpose uplinks)',
22 696 => 'WS-C2960G-24TC-L (20 Ethernet 10/100/1000 ports and 4 dual-purpose uplinks)',
23 697 => 'WS-C2960G-48TC-L (44 Ethernet 10/100/1000 ports and 4 dual-purpose uplinks)',
069c186f
DO
24 716 => 'WS-C2960-24TT-L (24 Ethernet 10/100 ports and 2 10/100/1000 uplinks)',
25 717 => 'WS-C2960-48TT-L (48 Ethernet 10/100 ports and 2 10/100/1000 uplinks)',
2ffd5a2a
DO
26 527 => 'WS-C2970G-24T (24 Ethernet 10/100/1000 ports)',
27 561 => 'WS-C2970G-24TS (24 Ethernet 10/100/1000 ports and 4 10/100/1000 SFP uplinks)',
28 633 => 'WS-C3560-24TS (24 Ethernet 10/100 ports and 2 10/100/1000 SFP uplinks)',
29 634 => 'WS-C3560-48TS (48 Ethernet 10/100 ports and 4 10/100/1000 SFP uplinks)',
30 563 => 'WS-C3560-24PS (24 Ethernet 10/100 POE ports and 2 10/100/1000 SFP uplinks)',
31 564 => 'WS-C3560-48PS (48 Ethernet 10/100 POE ports and 4 10/100/1000 SFP uplinks)',
b3f866fc 32 516 => 'WS-C3750-XXPS (24 or 48 Ethernet 10/100 POE ports and 4 10/100/1000 SFP uplinks)',
2ffd5a2a
DO
33 614 => 'WS-C3560G-24PS (24 Ethernet 10/100/1000 POE ports and 4 10/100/1000 SFP uplinks)',
34 615 => 'WS-C3560G-24TS (24 Ethernet 10/100/1000 ports and 4 10/100/1000 SFP uplinks)',
35 616 => 'WS-C3560G-48PS (48 Ethernet 10/100/1000 POE ports and 4 10/100/1000 SFP uplinks)',
36 617 => 'WS-C3560G-48TS (48 Ethernet 10/100/1000 ports and 4 10/100/1000 SFP uplinks)',
b3f866fc 37 624 => 'WS-C3750G-24TS (24 Ethernet 10/100/1000 ports and 4 10/100/1000 SFP uplinks)',
2ffd5a2a
DO
38 58 => 'WS-C4503 (3-slot system)',
39 503 => '4503 (3-slot system)',
40 59 => 'WS-C4506 (6-slot system)',
41 502 => '4506 (6-slot system)',
42 626 => 'WS-C4948 (48 Ethernet 10/100/1000 ports and 4 10/100/1000 SFP uplinks)',
43 659 => 'WS-C4948-10GE (48 Ethernet 10/100/1000 ports and 2 10Gb X2 uplinks)',
3ec29bf4
DO
44 428 => 'WS-C2950G-24 (24 Ethernet 10/100 ports and 2 1000 GBIC uplinks)',
45 429 => 'WS-C2950G-48 (48 Ethernet 10/100 ports and 2 1000 GBIC uplinks)',
389e01ee 46 559 => 'WS-C2950T-48 (48 Ethernet 10/100 ports and 2 10/100/1000 uplinks)',
b3f866fc 47 920 => 'WS-CBS3032-DEL-F (16 Ethernet 10/100/1000 and up to 8 10/100/1000 uplinks)',
2ffd5a2a 48 );
389e01ee 49 // Cisco sysObjectID to Dictionary dict_key map
2ffd5a2a
DO
50 $hwtype = array
51 (
b3f866fc 52 278 => 395,
2ffd5a2a
DO
53 283 => 148,
54 696 => 167,
55 697 => 166,
56 527 => 210,
57 561 => 115,
58 633 => 169,
59 634 => 170,
60 563 => 171,
61 564 => 172,
62 614 => 175,
63 615 => 173,
64 616 => 176,
65 617 => 174,
b3f866fc 66 624 => 143,
2ffd5a2a
DO
67 58 => 145,
68 503 => 145,
69 59 => 156,
70 502 => 156,
71 626 => 147,
3ec29bf4
DO
72 659 => 377,
73 428 => 389,
74 429 => 390,
389e01ee 75 559 => 387,
069c186f
DO
76 516 => 179,
77 716 => 164,
78 717 => 162,
b3f866fc
AD
79 920 => 795,
80 );
81 // Cisco portType to Dictionary dict_key map
82 $porttype = array
83 (
84 18 => 19, // 10/100BaseT => RJ-45/100Base-T
85 28 => 25, // 1000BaseSX => SC/1000Base-SX
86 31 => 440, // No Transceiver => unknown
87 61 => 24, // 10/100/1000BaseT => RJ-45/1000Base-T
2ffd5a2a
DO
88 );
89
90 $objectInfo = getObjectInfo ($object_id);
91 $endpoints = findAllEndpoints ($object_id, $objectInfo['name']);
92 $sysName = substr (snmpget ($endpoints[0], $community, 'sysName.0'), strlen ('STRING: '));
93 $sysDescr = snmpget ($endpoints[0], $community, 'sysDescr.0');
94 $sysChassi = snmpget ($endpoints[0], $community, '1.3.6.1.4.1.9.3.6.3.0');
95 // Strip the object type, it's always string here.
96 $sysDescr = substr ($sysDescr, strlen ('STRING: '));
3ec29bf4 97 $IOSversion = ereg_replace ('^.*, Version ([^ ]+), .*$', '\\1', $sysDescr);
2ffd5a2a
DO
98 $sysChassi = str_replace ('"', '', substr ($sysChassi, strlen ('STRING: ')));
99 if (strpos ($sysDescr, 'Cisco IOS Software') === 0 or strpos ($sysDescr, 'Cisco Internetwork Operating System Software') === 0)
100 $log[] = array ('code' => 'success', 'message' => 'Seems to be a Cisco box');
101 else
102 {
103 $log[] = array ('code' => 'error', 'message' => 'No idea how to handle ' . $sysDescr);
3ec29bf4 104 return $log;
2ffd5a2a
DO
105 }
106
107 // It's a Cisco box. Go on.
108 $attrs = getAttrValues ($object_id);
109 // Only fill in attribute values, if they are not set.
110 // FIXME: this is hardcoded
111
112 if (empty ($attrs[3]['value']) && !empty ($sysName)) // FQDN
113 {
114 $error = commitUpdateAttrValue ($object_id, 3, $sysName);
115 if ($error == TRUE)
116 $log[] = array ('code' => 'success', 'message' => 'FQDN set to ' . $sysName);
117 else
118 $log[] = array ('code' => 'error', 'message' => 'Failed settig FQDN: ' . $error);
119 }
120
3ec29bf4 121 if (empty ($attrs[5]['value']) and strlen ($IOSversion) > 0) // SW version
2ffd5a2a 122 {
2ffd5a2a
DO
123 $error = commitUpdateAttrValue ($object_id, 5, $IOSversion);
124 if ($error == TRUE)
125 $log[] = array ('code' => 'success', 'message' => 'SW version set to ' . $IOSversion);
126 else
127 $log[] = array ('code' => 'error', 'message' => 'Failed settig SW version: ' . $error);
128 }
129
130 if (empty ($attrs[1]['value']) and strlen ($sysChassi) > 0) // OEM Serial #1
131 {
132 $error = commitUpdateAttrValue ($object_id, 1, $sysChassi);
133 if ($error == TRUE)
134 $log[] = array ('code' => 'success', 'message' => 'OEM S/N 1 set to ' . $sysChassi);
135 else
136 $log[] = array ('code' => 'error', 'message' => 'Failed settig OEM S/N 1: ' . $error);
137 }
138
139 if (empty ($attrs[4]['value'])) // switch OS type
3ec29bf4 140 {
2ffd5a2a
DO
141 switch (substr ($IOSversion, 0, 4))
142 {
143 case '12.2':
144 $error = commitUpdateAttrValue ($object_id, 4, 252);
145 break;
146 case '12.1':
147 $error = commitUpdateAttrValue ($object_id, 4, 251);
148 break;
149 case '12.0':
150 $error = commitUpdateAttrValue ($object_id, 4, 244);
151 break;
3ec29bf4
DO
152 default:
153 $log[] = array ('code' => 'error', 'message' => "Unknown IOS version ${IOSversion}");
154 $error = TRUE;
155 break;
2ffd5a2a 156 }
3ec29bf4
DO
157 if ($error == TRUE)
158 $log[] = array ('code' => 'success', 'message' => 'Switch OS type set to Cisco IOS ' . substr ($IOSversion, 0, 4));
159 else
160 $log[] = array ('code' => 'error', 'message' => 'Failed setting Switch OS type');
161 }
2ffd5a2a
DO
162
163 $sysObjectID = snmpget ($endpoints[0], $community, 'sysObjectID.0');
164 // Transform OID
165 $sysObjectID = substr ($sysObjectID, strlen ('OID: SNMPv2-SMI::enterprises.9.1.'));
166 if (!isset ($ciscomodel[$sysObjectID]))
167 {
168 $log[] = array ('code' => 'error', 'message' => 'Could not guess exact HW model!');
3ec29bf4 169 return $log;
2ffd5a2a
DO
170 }
171 $log[] = array ('code' => 'success', 'message' => 'HW is ' . $ciscomodel[$sysObjectID]);
172 if (empty ($attrs[2]['value']) and isset ($hwtype[$sysObjectID])) // switch HW type
173 {
174 $error = commitUpdateAttrValue ($object_id, 2, $hwtype[$sysObjectID]);
175 if ($error == TRUE)
176 $log[] = array ('code' => 'success', 'message' => 'HW type updated Ok');
177 else
178 $log[] = array ('code' => 'error', 'message' => 'Failed settig HW type: ' . $error);
179 }
180 // Now fetch ifType, ifDescr and ifPhysAddr and let model-specific code sort the data out.
181 $ifType = snmpwalkoid ($endpoints[0], $community, 'ifType');
182 $ifDescr = snmpwalkoid ($endpoints[0], $community, 'ifdescr');
183 $ifPhysAddress = snmpwalkoid ($endpoints[0], $community, 'ifPhysAddress');
184 // Combine 3 tables into 1...
185 $ifList1 = array();
186 foreach ($ifType as $key => $val)
187 {
188 list ($dummy, $ifIndex) = explode ('.', $key);
189 list ($dummy, $type) = explode (' ', $val);
190 $ifList1[$ifIndex]['type'] = $type;
191 }
192 foreach ($ifDescr as $key => $val)
193 {
194 list ($dummy, $ifIndex) = explode ('.', $key);
195 list ($dummy, $descr) = explode (' ', $val);
196 $ifList1[$ifIndex]['descr'] = trim ($descr, '"');
197 }
198 foreach ($ifPhysAddress as $key => $val)
199 {
5fc57c5b 200 $val = trim ($val);
2ffd5a2a 201 list ($dummy, $ifIndex) = explode ('.', $key);
5fc57c5b
DO
202 // NET-SNMP may return MAC addresses in one of two (?) formats depending on
203 // DISPLAY-HINT internal database. The best we can do about it is to accept both.
204 // Bug originally reported by Walery Wysotsky against openSUSE 11.0.
205 if (preg_match ('/^string: /i', $val)) // STRING: x:yy:z:xx:y:zz
206 {
207 list ($dummy, $val) = explode (' ', $val);
208 $addrbytes = explode (':', $val);
209 foreach ($addrbytes as $bidx => $bytestr)
210 if (strlen ($bytestr) == 1)
211 $addrbytes[$bidx] = '0' . $bytestr;
212 }
213 elseif (preg_match ('/^hex-string: /i', $val)) // Hex-STRING: xx yy zz xx yy zz
214 $addrbytes = explode (' ', substr ($val, -17));
215 else
216 continue; // martian format
217 $ifList1[$ifIndex]['phyad'] = implode ('', $addrbytes);
2ffd5a2a
DO
218 }
219 // ...and then reverse it inside out to make description the key.
220 $ifList2 = array();
221 foreach ($ifList1 as $ifIndex => $data)
222 {
223 $ifList2[$data['descr']]['type'] = $data['type'];
224 $ifList2[$data['descr']]['phyad'] = $data['phyad'];
225 $ifList2[$data['descr']]['idx'] = $ifIndex;
226 }
227 $newports = 0;
228 // Now we can directly pick necessary ports from the table accordingly
229 // to our known hardware model.
230 switch ($sysObjectID)
231 {
232 // FIXME: chassis edge switches often share a common naming scheme, so
233 // the sequences below have to be generalized. Let's have some duplicated
234 // code for the time being, as this is the first implementation ever.
235 case '697': // WS-C2960G-48TC-L
236 // 44 copper ports: 1X, 2X, 3X...
237 // 4 combo ports: 45, 46, 47, 48. Don't list SFP connectors atm, as it's not
238 // clear how to fit them into current Ports table structure.
239 for ($i = 1; $i <= 48; $i++)
240 {
241 $label = ($i >= 45) ? "${i}" : "${i}X";
242 $error = commitAddPort ($object_id, 'gi0/' . $i, 24, $label, $ifList2["GigabitEthernet0/${i}"]['phyad']);
243 if ($error == '')
244 $newports++;
245 else
246 $log[] = array ('code' => 'error', 'message' => 'Failed to add port ' . $label . ': ' . $error);
247 }
248 break;
b3f866fc 249 case '624': // WS-C3750-24TS
2ffd5a2a
DO
250 case '696': // WS-C2960G-24TC-L
251 // Quite similar to the above.
252 for ($i = 1; $i <= 24; $i++)
253 {
254 $label = ($i >= 21) ? "${i}" : "${i}X";
255 $error = commitAddPort ($object_id, 'gi0/' . $i, 24, $label, $ifList2["GigabitEthernet0/${i}"]['phyad']);
256 if ($error == '')
257 $newports++;
258 else
259 $log[] = array ('code' => 'error', 'message' => 'Failed to add port ' . $label . ': ' . $error);
260 }
261 break;
069c186f 262 case '716': // WS-C2960-24TT-L
2ffd5a2a
DO
263 case '563': // WS-C3560-24PS
264 case '633': // WS-C3560-24TS
3ec29bf4 265 case '428': // WS-C2950G-24
2ffd5a2a
DO
266 for ($i = 1; $i <= 24; $i++)
267 {
268 $label = "${i}X";
269 $error = commitAddPort ($object_id, 'fa0/' . $i, 19, $label, $ifList2["FastEthernet0/${i}"]['phyad']);
270 if ($error == '')
271 $newports++;
272 else
273 $log[] = array ('code' => 'error', 'message' => 'Failed to add port ' . $label . ': ' . $error);
274 }
275 for ($i = 1; $i <= 2; $i++)
276 {
277 $label = "${i}";
278 $error = commitAddPort ($object_id, 'gi0/' . $i, 24, $label, $ifList2["GigabitEthernet0/${i}"]['phyad']);
279 if ($error == '')
280 $newports++;
281 else
282 $log[] = array ('code' => 'error', 'message' => 'Failed to add port ' . $label . ': ' . $error);
283 }
284 break;
069c186f 285 case '717': // WS-C2960-48TT-L
3ec29bf4 286 case '429': // WS-C2950G-48
389e01ee 287 case '559': // WS-C2950T-48
3ec29bf4
DO
288 for ($i = 1; $i <= 48; $i++)
289 {
290 $label = "${i}X";
291 $error = commitAddPort ($object_id, 'fa0/' . $i, 19, $label, $ifList2["FastEthernet0/${i}"]['phyad']);
292 if ($error == '')
293 $newports++;
294 else
295 $log[] = array ('code' => 'error', 'message' => 'Failed to add port ' . $label . ': ' . $error);
296 }
297 for ($i = 1; $i <= 2; $i++)
298 {
299 $label = "${i}";
300 $error = commitAddPort ($object_id, 'gi0/' . $i, 24, $label, $ifList2["GigabitEthernet0/${i}"]['phyad']);
301 if ($error == '')
302 $newports++;
303 else
304 $log[] = array ('code' => 'error', 'message' => 'Failed to add port ' . $label . ': ' . $error);
305 }
306 break;
b3f866fc
AD
307 case '516': // WS-C3750G-24TS OR WS-C3750-48PS
308 // FIXME: only handles 2 models of 3750, make it handle all of them
309 // see if it has 24 or 48 ports
310 $numports = substr (snmpget ($endpoints[0], $community, '.1.3.6.1.4.1.9.5.1.3.1.1.14.1'), strlen('INTEGER: '));
311
312 if ($numports == 28) // has 24 ports (+4 SFP) meaning it's a WS-C3750G-24TS
069c186f 313 {
b3f866fc
AD
314 for ($i = 1; $i <= 28; $i++)
315 {
316 $label = "${i}";
317 $error = commitAddPort ($object_id, 'gi1/0/' . $i, 24, $label, $ifList2["GigabitEthernet1/0/${i}"]['phyad']);
318 if ($error == '')
319 $newports++;
320 else
321 $log[] = array ('code' => 'error', 'message' => 'Failed to add port ' . $label . ': ' . $error);
322 }
069c186f 323 }
b3f866fc 324 elseif ($numports == 52) // has 48 ports (+4 SFP) meaning it's a WS-C3750-48PS
069c186f 325 {
b3f866fc
AD
326 for ($i = 1; $i <= 48; $i++)
327 {
328 $label = "${i}X";
329 $error = commitAddPort ($object_id, 'fa1/0/' . $i, 19, $label, $ifList2["FastEthernet1/0/${i}"]['phyad']);
330 if ($error == '')
331 $newports++;
332 else
333 $log[] = array ('code' => 'error', 'message' => 'Failed to add port ' . $label . ': ' . $error);
334 }
335 for ($i = 1; $i <= 4; $i++)
336 {
337 $label = "${i}";
338 $error = commitAddPort ($object_id, 'gi1/0/' . $i, 24, $label, $ifList2["GigabitEthernet1/0/${i}"]['phyad']);
339 if ($error == '')
340 $newports++;
341 else
342 $log[] = array ('code' => 'error', 'message' => 'Failed to add port ' . $label . ': ' . $error);
343 }
069c186f
DO
344 }
345 break;
2ffd5a2a
DO
346 case '564': // WS-C3560-48PS
347 case '634': // WS-C3560-48TS
348 for ($i = 1; $i <= 48; $i++)
349 {
350 $label = "${i}X";
351 $error = commitAddPort ($object_id, 'fa0/' . $i, 19, $label, $ifList2["FastEthernet0/${i}"]['phyad']);
352 if ($error == '')
353 $newports++;
354 else
355 $log[] = array ('code' => 'error', 'message' => 'Failed to add port ' . $label . ': ' . $error);
356 }
357 for ($i = 1; $i <= 4; $i++)
358 {
359 $label = "${i}";
360 $error = commitAddPort ($object_id, 'gi0/' . $i, 24, $label, $ifList2["GigabitEthernet0/${i}"]['phyad']);
361 if ($error == '')
362 $newports++;
363 else
364 $log[] = array ('code' => 'error', 'message' => 'Failed to add port ' . $label . ': ' . $error);
365 }
366 break;
367 case '614': // WS-C3560G-24PS
368 case '615': // WS-C3560G-24TS
369 case '527': // WS-C2970G-24T
370 case '561': // WS-C2970G-24TS
2ffd5a2a
DO
371 for ($i = 1; $i <= 24; $i++)
372 {
373 $label = "${i}X";
374 $error = commitAddPort ($object_id, 'gi0/' . $i, 24, $label, $ifList2["GigabitEthernet0/${i}"]['phyad']);
375 if ($error == '')
376 $newports++;
377 else
378 $log[] = array ('code' => 'error', 'message' => 'Failed to add port ' . $label . ': ' . $error);
379 }
380 break;
381 case '616': // WS-C3560G-48PS
382 case '617': // WS-C3560G-48TS
2ffd5a2a
DO
383 for ($i = 1; $i <= 48; $i++)
384 {
385 $label = "${i}X";
386 $error = commitAddPort ($object_id, 'gi0/' . $i, 24, $label, $ifList2["GigabitEthernet0/${i}"]['phyad']);
387 if ($error == '')
388 $newports++;
389 else
390 $log[] = array ('code' => 'error', 'message' => 'Failed to add port ' . $label . ': ' . $error);
391 }
392 break;
393 case '626': // WS-C4948
394 case '659': // WS-C4948-10GE
395 for ($i = 1; $i <= 48; $i++)
396 {
397 $label = "${i}X";
398 $error = commitAddPort ($object_id, 'gi1/' . $i, 24, $label, $ifList2["GigabitEthernet1/${i}"]['phyad']);
399 if ($error == '')
400 $newports++;
401 else
402 $log[] = array ('code' => 'error', 'message' => 'Failed to add port ' . $label . ': ' . $error);
403 }
404 break;
b3f866fc
AD
405 // For modular devices we issue a separate SNMP query to determine port type,
406 // then extract blade & port numbers from the results.
407 case '58': // WS-C4503
408 case '503': // WS-C4503
409 case '59': // WS-C4506
410 case '502': // WS-C4506
2ffd5a2a 411 case '283': // WS-C6509-E
b3f866fc
AD
412 // get slot #, port # and port type using Cisco's MIB
413 $portType = snmpwalkoid ($endpoints[0], $community, '.1.3.6.1.4.1.9.5.1.4.1.1.5');
414 $ifList = array();
415 $i = 0;
416 foreach ($portType as $key => $val)
2ffd5a2a 417 {
b3f866fc
AD
418 // slot = $portIndex[8]
419 // port = $portIndex[9]
420 $portIndex = explode('.', $key);
421 $ifList[$i]['slotno'] = $portIndex[8];
422 $ifList[$i]['portno'] = $portIndex[9];
423
424 // note the Cisco port type and corresponding RackTables port type
425 list ($dummy, $cptype) = explode (' ', $val);
426 $ifList[$i]['cptype'] = $cptype;
427 if (array_key_exists($cptype, $porttype))
428 $ifList[$i]['ptype'] = $porttype[$cptype];
429 else
430 $ifList[$i]['ptype'] = null;
431 $i++;
432 }
433
434 // use Cisco's ifIndex attribute to map Cisco table to standard SNMP table
435 $ifIndex = snmpwalkoid ($endpoints[0], $community, '.1.3.6.1.4.1.9.5.1.4.1.1.11');
436 $i = 0;
437 foreach ($ifIndex as $val)
438 {
439 if (is_null($ifList[$i]['ptype']))
2ffd5a2a 440 {
b3f866fc
AD
441 $log[] = array ('code' => 'error', 'message' => 'Unknown port type: ' . $ifList[$i]['cptype']);
442 } else {
443 switch ($ifList[$i]['ptype'])
444 {
445 case 19: // fast eth
446 $prefix = 'fa';
447 break;
448 case 28: // 1000base-sx
449 case 61: // gig eth
450 $prefix = 'gi';
451 break;
452 default: // unknown, default to gig eth
453 $prefix = 'gi';
454 }
455 $pname = "{$prefix}{$ifList[$i]['slotno']}/{$ifList[$i]['portno']}";
456 $label = "slot {$ifList[$i]['slotno']} port {$ifList[$i]['portno']}";
457 list($dummy, $index) = explode(' ', $val);
458
459 // if l2address already exists in DB, nullify value so new row gets added without error
460 if (!is_null(searchByl2address($ifList1[$index]['phyad']))) $ifList1[$index]['phyad'] = null;
461
462 $error = commitAddPort ($object_id, $pname, $ifList[$i]['ptype'], $label, $ifList1[$index]['phyad']);
463 if ($error == '')
464 $newports++;
465 else
466 $log[] = array ('code' => 'error', 'message' => 'Failed to add port ' . $pname . ': ' . $error);
2ffd5a2a 467 }
b3f866fc
AD
468 $i++;
469 }
470 break;
471 case '278': // WS-C3548-XL
472 for ($i = 1; $i <= 48; $i++)
473 {
474 $label = "${i}X";
475 $error = commitAddPort ($object_id, 'fa0/' . $i, 19, $label, $ifList2["FastEthernet0/${i}"]['phyad']);
2ffd5a2a
DO
476 if ($error == '')
477 $newports++;
478 else
b3f866fc
AD
479 $log[] = array ('code' => 'error', 'message' => 'Failed to add port ' . $label . ': ' . $error);
480 }
481 for ($i = 1; $i <= 2; $i++)
482 {
483 $label = "${i}";
484 $error = commitAddPort ($object_id, 'gi0/' . $i, 24, $label, $ifList2["GigabitEthernet0/${i}"]['phyad']);
485 if ($error == '')
486 $newports++;
487 else
488 $log[] = array ('code' => 'error', 'message' => 'Failed to add port ' . $label . ': ' . $error);
489 }
490 break;
491 case '920': // WS-CBS3032-DEL-F
492 for ($i = 1; $i <= 24; $i++)
493 {
494 $label = "${i}";
495 $error = commitAddPort ($object_id, 'gi0/' . $i, 24, $label, $ifList2["GigabitEthernet0/${i}"]['phyad']);
496 if ($error == '')
497 $newports++;
498 else
499 $log[] = array ('code' => 'error', 'message' => 'Failed to add port ' . $label . ': ' . $error);
2ffd5a2a
DO
500 }
501 break;
502 default:
503 showError ("Unexpected sysObjectID '${sysObjectID}'", __FUNCTION__);
504 }
505 $error = commitAddPort ($object_id, 'con0', 29, 'console', '');
506 if ($error == '')
507 $newports++;
508 else
509 $log[] = array ('code' => 'error', 'message' => 'Failed to add console port : ' . $error);
510 if ($newports > 0)
511 $log[] = array ('code' => 'success', 'message' => "Added ${newports} new ports");
512 return $log;
513}
514
515?>