Menu

Adding Device Type

2010-12-16
2012-12-19
  • Yann Godbout

    Yann Godbout - 2010-12-16

    Good afternoon,
    Did I miss something or there isn't a way to add "device type" in the current available list? For example, we do have mouses, screens, projectors, ipads, external hard drives, etc…. The only way I see it is to alter the tables which is not that obvious.
    Thx!
    Yann

     
  • Denis

    Denis - 2011-01-11

    Hi Yann,

    There are actually two ways to extend the list of types: either by changing the values in the *enum* field or by altering the iTop data model a bit further to turn the "typology" into something editable in iTop.

    I wrote a short document explaining the two approaches for "Network Devices types". WHich is quite similar to other devices.

    The document can be downloaded from here: http://www.combodo.com/IMG/pdf/iTop_Customization.pdf

    Hope this helps

     
  • Jonathan Vogt

    Jonathan Vogt - 2011-01-14

    Hi,

    I tried to follow your document using option 2 on a production database. So far all worked well, except now I have a id in the types colon, not a name. The field is not linked, how would I fix that?

    When I edit the field, I see the value (e.g Firewall)? Did I miss something?

    I also attached a patch to https://sourceforge.net/apps/trac/itop/ticket/342 for both options.

     
  • Denis

    Denis - 2011-01-14

    I think you missed one step of the customization.

    In the file “model.itop-config-mgmt.php” in “modules/itop-config-mgmt-1.0.0”, don't forget to replace the line:

    MetaModel::Init_AddAttribute(new AttributeEnum("type", array("allowed_values"=>new ValueSetEnum('wanaccelerator,firewall,hub,loadbalancer,router,switch'), "sql"=>"type", "default_value"=>"switch", "is_null_allowed"=>true, "depends_on"=>array())));
    

    By:

    MetaModel::Init_AddAttribute(new AttributeExternalKey("type", array("targetclass"=>"NetworkDeviceType", "jointype"=>null, "allowed_values"=>null, "sql"=>"type", "is_null_allowed"=>true, "on_target_delete"=>DEL_MANUAL, "depends_on"=>array())));
    
     
  • Denis

    Denis - 2011-01-18

    Once you've modified the definition of the "Network Device" PHP object in iTop, you have to run the following MySQL command to adjust the SQL schema:

    ALTER TABLE `networkdevice` CHANGE `type` `type` INT(11) NULL;
    

    This should wipe out the previous values for the 'type' of the existing objects since MySQL has no way to transform the enum into a foreign key. (And this is also why I don't recommend this on a production database).

     
  • Jonathan Vogt

    Jonathan Vogt - 2011-01-18

    What I did was, adding a temporary type_tmp coloum of type int and then ran the following queries (more or less)

    INSERT INTO networkdevicetype SELECT DISTINCT type FROM networkdevice;
    UPDATE networkdevice AS d SET d.type_tmp = (SELECT t.id FROM networkdevicetype AS t WHERE t.name = d.type);
    

    And then I dropped the type coloum and renamed type_tmp to type. Which should work, if I understood it correctly.

    When I now open a network device I get :
    Name devicename

    Typ 5

    Where 5 is corresondening to UTM. When I modify the device I see a drop down list with UTM selected. It's this last irretating "bug" which I try to fix. (Appart from some permission problem, I haven't looked into yet.)

     
  • Denis

    Denis - 2011-01-18

    I think I got it:

    1) make sure that the 'type' field is clean in MySQL:

    UPDATE `networkdevice` SET type = NULL;
    ALTER TABLE `networkdevice` CHANGE `type` `type` INT(11) NULL;
    

    2) add the following line after the definition of the 'type' field on the NetworkDevice class:

            MetaModel::Init_AddAttribute(new AttributeExternalField("type_name", array("allowed_values"=>null, "extkey_attcode"=>"type", "target_attcode"=>"name", "is_null_allowed"=>true, "depends_on"=>array())));
    

    This tells iTop how to retrieve the name of the 'type' foreign key. This will be automatic in the next release of iTop, but for time being you must declare an 'ExternalField' if you don't want to have a number displayed in the 'type' column, when displaying a list of Network Devices.

     
  • Denis

    Denis - 2011-01-18

    @ulmerspatz : Oops, our replies have crossed each other, I guess. No need to 'empty' the 'type' field if the values are Ok in MySQL.

    Just add the extra 'ExternalField' to the definition of the NetworkDevice class, as explained in the second part of my answer, and iTop will do the proper JOIN in SQL to display the values correctly.

     
  • Jonathan Vogt

    Jonathan Vogt - 2011-01-18

    2) was the missing part. It's now working.

     
  • Jonathan Vogt

    Jonathan Vogt - 2011-01-18

    I updated my patch but now I wonder how I add the permissions for NetworkDeviceType to the patch.

    I managed to get it working adding the corresponding rows to priv_urp_grant_actions. But I want the patch to be complete so I wondered.

     
  • Denis

    Denis - 2011-01-18

    If you patch a live instance of iTop, there is no tool/UI to update the profiles, so you have to update the priv_urp_grant_actions records "manually".

    However if you run the installation process (i.e. on a new instance), then the rights to create/edit/delete the new 'NetworkDeviceType' objects will be given to the profile 'Configuration Manager' since the class has (in its initial parameters) the category 'configmgmt'.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.