[racktables-users] AutoPorts Configuration

  • From: Jan Ulferts <Jan.Ulferts@xxxxxxxx>
  • To: "racktables-users@xxxxxxxxxxxxx" <racktables-users@xxxxxxxxxxxxx>
  • Date: Sun, 21 Aug 2011 10:47:51 +0200

Hi,

I've added a new Feature to the "AutoPorts configuration" to provide the
same functionalities of the bulk AddPort operation:

the new format looks like this
<number of ports>*<port_type_id>*<sprintf_name>*<startnumber>

this gives the feature more flexibility.

I've patched the functions.php from RackTables-0.19.7

--
ToDo: add the new format to install and update procedure
--

Cheers,
Jan
Index: wwwroot/inc/functions.php
===================================================================
--- wwwroot/inc/functions.php   (revision 4749)
+++ wwwroot/inc/functions.php   (working copy)
@@ -998,13 +998,15 @@
                foreach (explode ('+', $portlist) as $product)
                {
                        $tmp = explode ('*', $product);
-                       if (count ($tmp) != 3)
+                       if (count ($tmp) != 4)
                                continue;
+                       //the new format looks like this <number of 
ports>*<port_type_id>*<sprintf_name>*<startnumber>
                        $nports = $tmp[0];
                        $port_type = $tmp[1];
                        $format = $tmp[2];
+                       $startnum = $tmp[3];
                        for ($i = 0; $i < $nports; $i++)
-                               $ret[] = array ('type' => $port_type, 'name' => 
@sprintf ($format, $i));
+                               $ret[] = array ('type' => $port_type, 'name' => 
@sprintf ($format, ($i+$startnum)));
                }
        }
        return $ret;

Other related posts: