View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
321 | RackTables | default | public | 2010-03-18 22:44 | 2012-01-29 07:06 |
Reporter | Assigned To | ||||
Priority | normal | Severity | feature | Reproducibility | N/A |
Status | closed | Resolution | fixed | ||
Product Version | 0.17.9 | ||||
Fixed in Version | 0.17.11 | ||||
Summary | 321: Adding multiple interfaces via web | ||||
Description | as I wrote to racktables-users, this is a small patch to have an easy way to add multiple interfaces (of the same type) to an object. This patch is a quick'n'dirty one. Needs to be improved in error handling and return codes. I tried to stay as close to your coding as possible. I would prefer to insert all ports within one database transaction and rollback if the creation of one port fails. But this would require mysql innodb tables, which racktables doesn't at the moment. and also a major rewrite of database.php, since write locking a table commits a started transaction. Please have a look. | ||||
Tags | No tags attached. | ||||
2010-03-18 22:44
|
racktables-addmanyports.diff (5,761 bytes)
diff -Nurd RackTables-0.17.9.orig//inc/database.php RackTables-0.17.9-multi//inc/database.php --- RackTables-0.17.9.orig//inc/database.php 2010-02-11 18:54:06.000000000 +0100 +++ RackTables-0.17.9-multi//inc/database.php 2010-03-18 21:29:56.000000000 +0100 @@ -2962,6 +2962,24 @@ return $ret; } +function commitAddManyPorts ($object_id = 0, $port_name = '', $port_type_id = 0 , $port_label = '', $port_numbering_start = 0, $port_numbering_count = 0) +{ + + if ($object_id == 0 or $port_type_id == 0 or $port_name == '' or $port_numbering_count == 0) + { + showError ('Invalid arguments', __FUNCTION__); + //echo "o_id: $object_id; type: $port_type_id; port_name: $port_name; count: $port_numbering_count"; + die; + } + $ret = TRUE; + for ($i=0,$c=$port_numbering_start; $i<=$port_numbering_count; $i++,$c++) + $ret = $ret and '' == commitAddPort ($object_id, @sprintf($port_name,$c), $port_type_id, @sprintf($port_label,$c), ''); + //echo "commitAddPort ($object_id, @sprintf($port_name,$i), $port_type_id,'', '');"; + return ($ret?'':"Failed"); + + +} + // Return only implicitly listed tags, the rest of the chain will be // generated/deducted later at higher levels. // Result is a chain: randomly indexed taginfo list. diff -Nurd RackTables-0.17.9.orig//inc/interface.php RackTables-0.17.9-multi//inc/interface.php --- RackTables-0.17.9.orig//inc/interface.php 2010-02-11 18:54:06.000000000 +0100 +++ RackTables-0.17.9-multi//inc/interface.php 2010-03-18 21:12:33.000000000 +0100 @@ -1100,11 +1100,9 @@ echo "<td colspan=3> </td><td>"; printImageHREF ('add', 'add a port', TRUE, 104); echo "</td></tr></form>"; + } - if (getConfigVar('ENABLE_MULTIPORT_FORM') == 'yes') - startPortlet ('Ports and interfaces'); - else - echo '<br>'; + startPortlet ('Ports and interfaces'); $object = spotEntity ('object', $object_id); amplifyCell ($object); echo "<table cellspacing=0 cellpadding='5' align='center' class='widetable'>\n"; @@ -1199,8 +1197,26 @@ if (getConfigVar ('ADDNEW_AT_TOP') != 'yes') printNewItemTR ($prefs); echo "</table><br>\n"; - if (getConfigVar('ENABLE_MULTIPORT_FORM') == 'yes') - finishPortlet(); + finishPortlet(); + + startPortlet ('Add many Ports'); + + echo "<table cellspacing=0 cellpadding='5' align='center' class='widetable'>\n"; + echo "<tr><th> </th><th class=tdleft>Local name</th><th class=tdleft>Visible label</th><th class=tdleft>Interface</th><th class=tdleft>Start Number</th>"; + echo "<th class=tdleft>Count</th><th> </th></tr>\n"; + printOpFormIntro ('addManyPorts'); + echo "<tr><td>"; + printImageHREF ('add', 'add ports', TRUE); + echo "</td><td><input type=text size=8 name=port_name tabindex=105></td>\n"; + echo "<td><input type=text name=port_label tabindex=106></td><td>"; + printNiftySelect (getNewPortTypeOptions(), array ('name' => 'port_type_id', 'tabindex' => 107), $prefs['selected']); + echo "<td><input type=text name=port_numbering_start tabindex=108 size=3 maxlength=3></td>\n"; + echo "<td><input type=text name=port_numbering_count tabindex=109 size=3 maxlength=3></td>\n"; + echo "<td> </td><td>"; + printImageHREF ('add', 'add ports', TRUE, 110); + echo "</td></tr></form>"; + echo "</table><br>\n"; + if (getConfigVar('ENABLE_MULTIPORT_FORM') != 'yes') return; @@ -1427,6 +1443,7 @@ 79 => array ('code' => 'success', 'format' => 'Rack "%s" was deleted successfully'), 80 => array ('code' => 'success', 'format' => "Added new object '%s'"), 81 => array ('code' => 'success', 'format' => "SNMP: completed '%s' work"), + 82 => array ('code' => 'success', 'format' => "Ports have been created successfully"), // records 100~199 with fatal error messages 100 => array ('code' => 'error', 'format' => '%s'), diff -Nurd RackTables-0.17.9.orig//inc/navigation.php RackTables-0.17.9-multi//inc/navigation.php --- RackTables-0.17.9.orig//inc/navigation.php 2010-02-11 18:54:06.000000000 +0100 +++ RackTables-0.17.9-multi//inc/navigation.php 2010-03-18 20:46:45.000000000 +0100 @@ -114,6 +114,7 @@ $trigger['object']['tags'] = 'trigger_tags'; $ophandler['object']['rackspace']['updateObjectAllocation'] = 'updateObjectAllocation'; $ophandler['object']['ports']['addPort'] = 'addPortForObject'; +$ophandler['object']['ports']['addManyPorts'] = 'addManyPortsForObject'; $ophandler['object']['ports']['delPort'] = 'delPortFromObject'; $ophandler['object']['ports']['editPort'] = 'editPortForObject'; $ophandler['object']['ports']['linkPort'] = 'linkPortForObject'; diff -Nurd RackTables-0.17.9.orig//inc/ophandlers.php RackTables-0.17.9-multi//inc/ophandlers.php --- RackTables-0.17.9.orig//inc/ophandlers.php 2010-02-11 18:54:06.000000000 +0100 +++ RackTables-0.17.9-multi//inc/ophandlers.php 2010-03-18 21:16:26.000000000 +0100 @@ -2039,5 +2039,24 @@ return buildRedirectURL (__FUNCTION__, 'ERR'); } +$msgcode['addManyPortsForObject']['OK'] = 82; +$msgcode['addManyPortsForObject']['ERR1'] = 101; +$msgcode['addManyPortsForObject']['ERR2'] = 100; +function addManyPortsForObject () +{ + assertUIntArg ('object_id', __FUNCTION__); + assertStringArg ('port_name', __FUNCTION__, TRUE); + assertStringArg ('port_label', __FUNCTION__, TRUE); + assertUIntArg('port_numbering_start', __FUNCTION__); + assertUIntArg('port_numbering_count', __FUNCTION__); + if (!strlen ($_REQUEST['port_name'])) + return buildRedirectURL (__FUNCTION__, 'ERR1'); + $error = commitAddManyPorts ($_REQUEST['object_id'], $_REQUEST['port_name'], $_REQUEST['port_type_id'], $_REQUEST['port_label'], $_REQUEST['port_numbering_start'], $_REQUEST['port_numbering_count']); + if ($error != '') + return buildRedirectURL (__FUNCTION__, 'ERR2', array ($error)); + else + return buildRedirectURL (__FUNCTION__, 'OK' ); +} + ?> |
Let me have some time to review this. I will update later. | |
This is huge. With the lack of support for the 6509 and 4500 Cisco chassis, it takes forever to add ports to these objects. | |
I have grabbed this and reviewed the code. I see this as a boon for things not included with the snmp discovery. I should have it in the trunk today. | |
merged with the trunk for 0.18 and there are no dependencies on 0.18 so it is merged with 0.17.11 | |
Reminder sent to: RackTables uses InnoDB for all tables now. Please consider adding support for transactions and rollback as you previously mentioned. |
|
Date Modified | Username | Field | Change |
---|---|---|---|
2010-03-18 22:44 |
|
New Issue | |
2010-03-18 22:44 |
|
File Added: racktables-addmanyports.diff | |
2010-03-23 15:08 | infrastation | Status | new => assigned |
2010-03-23 15:08 | infrastation | Assigned To | => infrastation |
2010-03-23 15:09 | infrastation | Note Added: 0000035 | |
2010-03-23 16:34 | infrastation | Assigned To | infrastation => |
2010-03-23 16:34 | infrastation | Status | assigned => acknowledged |
2010-04-29 19:02 |
|
Note Added: 0000054 | |
2010-05-12 14:31 |
|
Status | acknowledged => assigned |
2010-05-12 14:31 |
|
Assigned To | => user145 |
2010-05-13 19:05 |
|
Note Added: 0000076 | |
2010-05-14 01:29 |
|
Note Added: 0000078 | |
2010-05-14 01:29 |
|
Status | assigned => resolved |
2010-05-14 01:29 |
|
Fixed in Version | => 0.17.11 |
2010-05-14 01:29 |
|
Resolution | open => fixed |
2010-07-07 13:15 | infrastation | Category | Interface => Database - core |
2010-11-29 13:21 | infrastation | Status | resolved => closed |
2012-01-29 07:06 | adoom42 | Note Added: 0000553 |