iTop by Combodo
Modification Overview:
I have created a mod for managing DHCP Scopes withinh iTop, feel free to use and distribute this modification but please do so at your own risk neither myself, or Combodo offer support for this modification.
If you do make any improvement or fixes to this modification please feel free to share them. Also if you have tested this modification on any other version of iTop let us know the results.
Take a look at these screenshots to get an idea what the modification does;
iTop Version 1.0.1
This article is designed for iTop version 1.0.1, check out the other revisions of this article for implementation with other iTop versions
Features:
- Create multiple DHCP Scopes \ ranges for a single subnet
- Links DHCP Scopes to Subnets so you get a DHCP Scopes tab on the subnet
- Exclude DHCP IPs from the available free IP's
Overview of Changes Mad to iTop:
- Modified the file "modules/itop-config-mgmt-1.0.0/model.itop-config-mgmt.php" to add the "DHCPScope" class and to make changes within the "Subnet" class
- Modified the file "modules/itop-config-mgmt-1.0.0/cis_menu.html" to add a block for "DHCPSCope"
- Modified the file "modules/itop-config-mgmt-1.0.0/en.dic.itop" to add the relevant dictionary entries. Reate for you required dictionaries
- Created a database table "dhcp_scope"
Applying the Modification:
Download the attached ZIP
Simple method
If you have clean install of iTop or have not modified any of the above files simply extract the files in the attached zip, replace the files within your iTop web directory and then create the SQL table using the sql file in the zip.
However if you have previously made any changes to the above files below is a step by step guide to manually applying the modification.
Manual method
Database changes
Create the table "dhcp_scope" using the sql file dhcp_scope_table.sql and you favourite MySql management tool.
Icon
COPY:
iTop Mod – DHCP Scope Files\modules\itop-config-mgmt-1.0.0\images\dhcpscope.png
TO YOUR ITOP DIRECTORY:
modules\itop-config-mgmt-1.0.0\images\dhcpscope.png
cis_menu.html
OPEN YOUR
modules\itop-config-mgmt-1.0.0\cis_menu.html
FIND (approx line 168)
AFTER ADD
SAVE AND CLOSE
en.dict.itop-config-mgmt.php (Repeat and alter for each required dictionary)
OPEN YOUR
modules\itop-config-mgmt-1.0.0\en.dict.itop-config-mgmt.php
FIND (approx line 405)
'Class:Subnet/Attribute:ip_mask+' => '',
AFTER ADD
'Class:Subnet/Attribute:dhcp_scope_list+' => '',
FIND (approx line 408)
'Class:Subnet/Attribute:dhcp_scope_list+' => '',
));
AFTER ADD
// Class: DHCPSCope
//
Dict::Add('EN US', 'English', 'English', array(
'Class:DHCPScope' => 'DHCP Scope',
'Class:DHCPScope+' => '',
'Class:DHCPScope/Attribute:name' => 'Name',
'Class:DHCPScope/Attribute:name+' => '',
'Class:DHCPScope/Attribute:description' => 'Description',
'Class:DHCPScope/Attribute:description+' => '',
'Class:DHCPScope/Attribute:subnet_id' => 'Within Subnet',
'Class:DHCPScope/Attribute:subnet_id+' => '',
'Class:DHCPScope/Attribute:ip_start' => 'Starting IP',
'Class:DHCPScope/Attribute:ip_start+' => '',
'Class:DHCPScope/Attribute:ip_end' => 'Ending IP',
'Class:DHCPScope/Attribute:ip_end+' => ''
));
SAVE AND CLOSE
model.itop-config-mgmt.php
OPEN YOUR
modules\itop-config-mgmt-1.0.0\model.itop-config-mgmt.php
FIND (approx line 442)
AFTER ADD
FIND (approx line 445)
CHANGE TO
FIND (approx line 475)
self::DisplaySet($oPage, $oIfSet, array('block_id' => 'nwif'));
AFTER ADD
$oDHCPSet = new CMDBObjectSet(DBObjectSearch::FromOQL("SELECT DHCPScope AS dhcp WHERE dhcp.subnet_id =$subnetID"));
//Build an array of IPs in this subnets DHCP scopes
$aDHCPips = array();
while ($aDHCPObject = $oDHCPSet->Fetch())
{
$dhcp_ip_start = ip2long($aDHCPObject->Get('ip_start'));
$dhcp_ip_end = ip2long($aDHCPObject->Get('ip_end'));
for ($currentIP = $dhcp_ip_start; $currentIP <= $dhcp_ip_end; $currentIP++)
{
$aDHCPips[] = $currentIP;
}
}
$iCountDHCP = count($aDHCPips) –1;
FIND (approx line 502)
CHANGE TO
FIND (approx line 514)
CHANGE TO
FIND (approx line 526 end of class subnet)
}
}
}
}
AFTER ADD
{
public static function Init()
{
$aParams = array
(
"category" => "bizmodel,searchable,configmgmt",
"key_type" => "autoincrement",
"name_attcode" => "name",
"state_attcode" => "",
"reconc_keys" => array("name", "subnet_id", "ip_start", "ip_end", "description"),
"db_table" => "dhcp_scope",
"db_key_field" => "id",
"db_finalclass_field" => "",
"icon" => "../modules/itop-config-mgmt-1.0.0/images/dhcpscope.png",
);
MetaModel::Init_Params($aParams);
MetaModel::Init_InheritAttributes();
MetaModel::Init_AddAttribute(new AttributeString("name", array("allowed_values"=>null, "sql"=>"name", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeWikiText("description", array("allowed_values"=>null, "sql"=>"description", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeExternalKey("subnet_id", array("targetclass"=>"Subnet", "jointype"=>null, "allowed_values"=>null, "sql"=>"subnet_id", "is_null_allowed"=>false, "on_target_delete"=>DEL_MANUAL, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeExternalField("subnet_ip", array("allowed_values"=>null, "extkey_attcode"=>"subnet_id", "target_attcode"=>"ip", "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeIPAddress("ip_start", array("allowed_values"=>null, "sql"=>"ip_start", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeIPAddress("ip_end", array("allowed_values"=>null, "sql"=>"ip_end", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_SetZListItems('details', array('name', 'subnet_id', 'ip_start', 'ip_end', 'description'));
MetaModel::Init_SetZListItems('advanced_search', array('name', 'subnet_id', 'ip_start', 'ip_end', 'description'));
MetaModel::Init_SetZListItems('standard_search', array('name', 'subnet_id', 'ip_start', 'ip_end', 'description'));
MetaModel::Init_SetZListItems('list', array('subnet_id', 'ip_start', 'ip_end'));
}
}
SAVE AND CLOSE
COMPLETE GIVE IT A TEST
Wonderful! 5/5 I’d try it on QA 🙂
Regards